From 9d8bffd4563fbdd353ee4394f41156f532d52df7 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 16 May 2018 09:28:25 +0800 Subject: [PATCH 01/17] =?UTF-8?q?REPORT-6700=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/toolbar/ToolBarMenuDock.java | 32 +- .../design/remote/RemoteDesignAuthority.java | 14 + .../remote/RemoteDesignAuthorityCreator.java | 45 ++ .../com/fr/design/remote/RemoteMember.java | 20 + .../RemoteDesignAuthorityManagerAction.java | 48 ++ .../images/icon_List_Folder_normal@1x.png | Bin 0 -> 337 bytes .../images/icon_List_Folder_normal@2x.png | Bin 0 -> 548 bytes .../remote/images/icon_Member_normal@1x.png | Bin 0 -> 525 bytes .../remote/images/icon_Member_normal@2x.png | Bin 0 -> 1137 bytes .../remote/images/icon_Member_white@1x.png | Bin 0 -> 350 bytes .../remote/images/icon_Member_white@2x.png | Bin 0 -> 746 bytes .../images/icon_NewFolderIcon_normal.png | Bin 0 -> 288 bytes .../images/icon_NewFolderIcon_normal@2x.png | Bin 0 -> 531 bytes ...te_Design_Permission_Manager_normal@1x.png | Bin 0 -> 575 bytes ...te_Design_Permission_Manager_normal@2x.png | Bin 0 -> 1115 bytes .../design/remote/ui/AuthorityEditorPane.java | 33 ++ .../remote/ui/AuthorityListControlPane.java | 520 ++++++++++++++++++ .../remote/ui/AuthorityManagerPane.java | 37 ++ .../fr/design/remote/ui/UserManagerPane.java | 98 ++++ .../design/remote/ui/list/AuthorityList.java | 28 + .../ui/list/AuthorityListCellRenderer.java | 132 +++++ .../fr/design/remote/ui/list/MemberList.java | 39 ++ .../remote/ui/list/MemberListCellRender.java | 45 ++ .../remote/ui/tree/FileAuthorityTree.java | 6 + 24 files changed, 1094 insertions(+), 3 deletions(-) create mode 100644 designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java create mode 100644 designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java create mode 100644 designer-base/src/com/fr/design/remote/RemoteMember.java create mode 100644 designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java create mode 100644 designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@1x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@2x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_Member_normal@1x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_Member_normal@2x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_Member_white@1x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_Member_white@2x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal@2x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png create mode 100644 designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png create mode 100644 designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java create mode 100644 designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java create mode 100644 designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java create mode 100644 designer-base/src/com/fr/design/remote/ui/UserManagerPane.java create mode 100644 designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java create mode 100644 designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java create mode 100644 designer-base/src/com/fr/design/remote/ui/list/MemberList.java create mode 100644 designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java create mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java diff --git a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 24059928b1..95d8c87f5c 100644 --- a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -32,6 +32,7 @@ import com.fr.design.actions.server.GlobalParameterAction; import com.fr.design.actions.server.GlobalTableDataAction; import com.fr.design.actions.server.PlatformManagerAction; import com.fr.design.actions.server.PluginManagerAction; +import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.TableDataPaneProcessor; @@ -58,11 +59,20 @@ import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; -import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JMenuBar; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -103,10 +113,12 @@ public abstract class ToolBarMenuDock { return new JPanel[0]; } + @Override public JComponent[] toolBarButton4Form() { return new JComponent[0]; } + @Override public JComponent toolBar4Authority() { return new JPanel(); } @@ -116,6 +128,7 @@ public abstract class ToolBarMenuDock { return DesignState.WORK_SHEET; } + @Override public int getToolBarHeight() { return PANLE_HEIGNT; } @@ -125,6 +138,7 @@ public abstract class ToolBarMenuDock { * * @return 子菜单 */ + @Override public ShortCut[] shortcut4ExportMenu() { return new ShortCut[0]; } @@ -404,6 +418,10 @@ public abstract class ToolBarMenuDock { new PlatformManagerAction() ); + if (shouldShowRemotePermission()) { + menuDef.addShortCut(new RemoteDesignAuthorityManagerAction()); + } + if (!BaseUtils.isAuthorityEditing()) { if (shouldShowPlugin()) { menuDef.addShortCut( @@ -425,6 +443,11 @@ public abstract class ToolBarMenuDock { return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction(); } + protected boolean shouldShowRemotePermission() { + // todo 依据是否是远程设计 并且当前登录的用户是否是管理员 进行判断 是否展示远程设计权限管理 + return true; + } + protected boolean shouldShowPlugin() { return !(FRContext.getCurrentEnv() instanceof RemoteEnv) && FRContext.isChineseEnv(); } @@ -527,6 +550,7 @@ public abstract class ToolBarMenuDock { protected JPanel polyToolBar(String text) { JPanel panel = new JPanel(new BorderLayout()) { + @Override public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); dim.height = PANLE_HEIGNT; @@ -711,6 +735,7 @@ public abstract class ToolBarMenuDock { private abstract class AbstractShortCutMethodAction implements ShortCutMethodAction { + @Override public ShortCut methodAction(MenuHandler handler) { return handler.shortcut(); } @@ -731,6 +756,7 @@ public abstract class ToolBarMenuDock { this.plus = plus; } + @Override public ShortCut methodAction(MenuHandler handler) { return handler.shortcut(plus); } diff --git a/designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java b/designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java new file mode 100644 index 0000000000..ffad37e772 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java @@ -0,0 +1,14 @@ +package com.fr.design.remote; + +public class RemoteDesignAuthority { + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java b/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java new file mode 100644 index 0000000000..dc77e92331 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java @@ -0,0 +1,45 @@ +package com.fr.design.remote; + +import com.fr.design.beans.BasicBeanPane; + +import javax.swing.Icon; + +public class RemoteDesignAuthorityCreator { + + private String name; + private Icon icon; + private Class clazz; + private Class editorClazz; + + + public RemoteDesignAuthorityCreator(String name, Icon icon, Class clazz, Class editorClazz) { + this.name = name; + this.icon = icon; + this.clazz = clazz; + this.editorClazz = editorClazz; + } + + public boolean accept(Object object) { + return this.clazz != null && this.clazz.isInstance(object); + } + + public String getName() { + return name; + } + + public Icon getIcon() { + return icon; + } + + public Class getClazz() { + return clazz; + } + + public Class getEditorClazz() { + return editorClazz; + } + + public void saveUpdatedBean(RemoteDesignAuthority authority, Object bean) { + + } +} diff --git a/designer-base/src/com/fr/design/remote/RemoteMember.java b/designer-base/src/com/fr/design/remote/RemoteMember.java new file mode 100644 index 0000000000..aa25da3686 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/RemoteMember.java @@ -0,0 +1,20 @@ +package com.fr.design.remote; + +public class RemoteMember { + + public static final RemoteMember DEFAULT_MEMBER = new RemoteMember("查询中..."); + + private String name; + + public RemoteMember(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java new file mode 100644 index 0000000000..a68e840bb1 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java @@ -0,0 +1,48 @@ +package com.fr.design.remote.action; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.remote.ui.AuthorityManagerPane; + +import java.awt.event.ActionEvent; + +/** + * @author yaohwu + */ +public class RemoteDesignAuthorityManagerAction extends UpdateAction { + + + public RemoteDesignAuthorityManagerAction() { + this.setName("远程设计权限管理"); + this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png")); + } + + + @Override + public void actionPerformed(ActionEvent e) { + + AuthorityManagerPane managerPane = new AuthorityManagerPane(); + + BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame()); + + + //todo read contents from database by hibernate to show + + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + //todo save contents into database by hibernate + } + + @Override + public void doCancel() { + super.doCancel(); + } + }); + dialog.setModal(true); + dialog.setVisible(true); + } +} diff --git a/designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@1x.png b/designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..8aed7d12de0e6afdb4f897a705ac08c27b69d6c3 GIT binary patch literal 337 zcmV-X0j~auP)Px$3rR#lR5%f1U>In?h|2+!PWpq}*ZTGA-$rH@rl2Z2 z#zc@9GH5^iUkSvA8GtN@#Qv}T_s`#}Ko=s3L6|^skgI)|Fl2}nK=H!&-wX_Q-u`3w z_~SnV129Uim5~7$`V2pTJ_5;u0N4Oz%?M*a0m;Dd?)!f*MixhA6L281Qta$OVgNrU<16eA j#4XCt$@CJpEInlaSPfRO^z0Qw00000NkvXXu0mjfXU&$y literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@2x.png b/designer-base/src/com/fr/design/remote/images/icon_List_Folder_normal@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..466bcc75cb27482e50b72876ced0bcdb741463b1 GIT binary patch literal 548 zcmV+<0^9wGP)Px$-bqA3R9Fe^l{-%YK@i7h4irQ&pau#b9ksm{YAlQ`U&6vfW1)?NLgTA4mReC+ z+S>UDg{_6(fJlTG6I2Y4yBlZ3TL@s}j)*bdCX>C}-I@8_e|Po(-1grUKqmt1r)g5x zjRPWBu-tg+TT z=23&x;HZ{diQy4L#28|^_1e~>3_NblXx2k}$z?S~$fS)z#yFL?0B8x;@kXAVG^N1z zU)~fxzI#pawHZ9)nW?7PF9!C~6ebgtXF z93^b10(AzQ1asme2aw1-wtTw|AcyPOG6Z_UL}tPm6{0Qb)XUf#6G078^4)W>zuA%gr5mF~3qTnZo>^la5n m{1l4hkX%0%-;MkC6nF=0i>A5EVcY}&0000Px$$4Nv%R5%f(QNK%DQ53%CzJN%YK@kT*F$KE`EiWd-IAn_0W-ye{Rm7oF2L}iJ z2gJ!m5E0z`LG~;z4>d!Q_Zm7Cnjy3u(t@^&mYN^;_}xb$kC%V}4_xj&-}%1po_nqk z&kX9PkH_PqjYex*2wp^e7^@Hn7#qc6vFhhbKafhLf{jMA2z-jjSR)E#h{W$!tNl3^ zi_Q4?0Y7ka^LHJBKjHB7yId~U?$isWIVWMVgFNHa^mKq?f?1w<#2vmo5rXEuVtwvs z(3Fx#dWcd1<5mye14wbI6n`|$g{f{WnM}S=N^Ih3r(LYO_x%ODcNe#<5YZWk|Ckwr zq$=~9w~lkr?27encoPsQpU;0_7OTJ~AsWXX#(If`@BDQ;F_HdKuR9948;>1ivst57 z`+mf%FlE{jB6#dL*0p9O5{c0LeKU;<(3z-&LcwLrvi|GZqd_DRIYhd^Jd|>rs~@`P z57SJJ5#8m1|FrG$dtG-8<`5X%C59BYZM)(Zdh=*B`l{Vl6)9<{TrOX@--tJ_!)yO3 zu{J7|O5cd&9yFhH-Z9|UIO^603_1sKR+C)=Oj}B+z7D7sh9L&#KI!=Y_Jy3y1TTHU P00000NkvXXu0mjfz4h%v literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/images/icon_Member_normal@2x.png b/designer-base/src/com/fr/design/remote/images/icon_Member_normal@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..492cce2c5e5cf37cfb8d6d81187b84b7615a4c7c GIT binary patch literal 1137 zcmV-%1djWOP)Px(D@jB_R9Fe^R$XiqRTRE=y1T^eVhA=^+Ja3*+czLXcl&3$ghW$8iw_MCJO~L1 zgeMXLSp2K6)&~<4AJhl+K}s5m5-N~jy4EfIn~90BO`s)|5LzAzfmA>{-MM~e_ug@K zJKNbd>yzH(&b{}XbHDT5GiS~n#{TP#uQULSjg1>D%Q_+i+k?J^bM_1{X3&4e{Ohr? zv4NFfu86>n9nr%=*q^{bWEm&lGq&!4XJvgqstI#6wyy*9sy~S6BCjZHo&8gfI^VgTVtsLqk(;;P&?R(Dd~5 z`>;C=xdyu*48z##w(**mcnRII&dyHl#*ImG{v1wzD-ww`C6mc}ZX23UOiZL^W@h@! z%PS}+n$c@3D=QL^-6nm$rsY#8d0$^&Jwp33t%cBzAgq5Vo!3}hUG*X4H%W&iecQ{% zE%PNH1gFzb`-`!y{h4Y0XHQSh0wVR3v}nq2nbG(XV9b7=OaVG!nqOFcfEm5`P1=?D z*%v^7-6s&dhE0B8N{^^j%6WRPl6#GX5V$Tkmg;)ri(VkPGJF9IQl|FinmB7;0{G;9 zgtaUxR+qCg&qUXwyAiFHj9Pq`$IKD?62SNVlymJ<3HTOjLI)gp)(_~maW1}+=u`M) zdmK-BCZ0gKw()p8FhBqJ7i2;`>5z~En#Q|8#0Ufek8IoCy0~b!L4O?TAUeL7K#OS( zkC6Rxtsnvf5R1j0O{MH!INg;4Xk+b;t*xzV=H}*3p`yKmle--AX{dikpGBvOX(Py0 z!A8g2i3Z4=h5Q(<=q05acIlRvfUdu?5!mNp6(dW4&ExqQ3ey=}GUR+o)Ae{M=TF)| z!G&HP-b26;Oss9AW!-g^XZSKZG)=1oXB<^_}qzqX1g$Tw>^IH0%Qv03v zr399>_&Mga=r-Qp{?$4sypfTSVMKuv_c2J|I$!t(W7eUw2t=b%{O5^%v>7LV7s=C` znXmqdeEAgzIYbCZ<|Y)YgKo4e0tnZ8q(r#J*RBoIzh6-rNOS{pAOprvx})F_(Di!C zcA4?413w;%Me!~{P&w0wgYz2X#!iLp5MV5|n}n1s;c)npGAP!Fd`JR|e%~2N_iGB* zMS#Ugi1&1{*rz9498BOzH!H20Gh>NXVJ2+d?D6u4Y$#|keL3SA)|Sf5d{|Hr=pup?_5Klnh*00000NkvXXu0mjf D9LyRw literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/images/icon_Member_white@1x.png b/designer-base/src/com/fr/design/remote/images/icon_Member_white@1x.png new file mode 100644 index 0000000000000000000000000000000000000000..cef7cbfe982f9edba53ae1bc9fda5a7998f8e849 GIT binary patch literal 350 zcmV-k0iphhP)Px$7)eAyR5%f}(myXlQ5Xl{OCynBAf0XO2CKxtZW6ItEC#zTAZc_ZCX0o1mG}e| zu}O79VknD5Bod;YgL~TBUTzFd^5nkf_rCXUZj$`RYPZ`H>~X_AHKy|JHP{;(9Ff(T zWQ`?ST>Nwqz0NYUMV(S7O%nU?M78cLw>EUbW^YqAPk55d>U#ycAO zT~>J@e1p%W9_5@$n*Dk-SmlvjcDUx0p`sH93@vj>ShqBJ=ZJPP-@BEEZUeiwRW&N$BW1hc#_lWF8^%uMslTx{DMQjI}DVRoCNIA+se wF$M*N*#(+mEd7zfu~Bedcl$51-RJe!A7};qpnRS&_W%F@07*qoM6N<$f?F(^U;qFB literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/images/icon_Member_white@2x.png b/designer-base/src/com/fr/design/remote/images/icon_Member_white@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..22dd99ba20f9c96b8fc9abd8688e278387ed7232 GIT binary patch literal 746 zcmVPx%q)9|UR9Fe^mrqC)Q51(AkxYmR5&uA?P|Frcftp&_EiS*ERp z8L*gUaM;7vPl8#OIg=;hMBz&2_Q8GF28ppkO;MjQDur2bBtF1_BqQn%MW}H;N$XX^ z=&ZSsFS-_?kvs8T*9^M!r7i*WHr4zhKX>VaAlO9nOm(d;z0U>IsL315f4dB|KBc+V zrT4jjWi>hKG7Hs@=-AeVO8G;d3z*dd8MvlSP%WM46fKhFaln`jFI1^T_GmrjBmkhsIYnRN0^2s z*nm1{fYT6uvWEHG!};-=HA1PX)4BGX3kN8J+D0pUZVLnp^MIJQiXRmL-i*M$1n zTUOqw)u6>W&3lpN)%2K|hwp$LGz(VTgS@Do)@!E)-;MlhB}ZuW&TO_L@zx&Bx8-a* c|I2QF06qiyVFowe+W-In07*qoM6N<$g1$muod5s; literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal.png b/designer-base/src/com/fr/design/remote/images/icon_NewFolderIcon_normal.png new file mode 100644 index 0000000000000000000000000000000000000000..9ea75fc6d857fef4e30a72519a4afd56ac7d0759 GIT binary patch literal 288 zcmV+*0pI?KP)Px#+DSw~R5%gEQZWv~Fbs4MVnN~&NHDM_p?`o*d;oU-!9REbQ$B&n3KD#!jd9YZ zL{^Iw7P8d7JD;680RKK>Xn>+9W_9gOhd_UWW_n3Ypv)08z%4pKh|E)B%07QE@ZUiymM#>D+As)0WaWr ztQm14H_tYZQa{rs*#@+cg*TuTh9~fYLE8Vz7E)O=cGKD8@dwfyc?I1ENXzXP)Px$%}GQ-R9Fe^Ry|L{Fc6KSsta8h%2e2x8In{2bwdaNTYp3u7#KiIs5=r8VuYy^ zBOA@a(5Vbbeg#Y|?5$98+)>Votfq}aqDoLpR_ybAJioixHjHKa?+l161k~&GtuTZu z!+?EVdm+Rt+8z78?~-jM036hDoYN?R8(lvH!uP!m@>61Gwrw9Eo_heOv26NR41|DA zwOVbvu6t|S&L-NNOxK+*Mg4VNF?o&FZ_-Ya{KOc57J*1oEJ`jJ_<5(x*J@D#RlgE|x{%kLel@E0y!`z=KVMy< VnZPM#3{n69002ovPDHLkV1h}!J%=P)Px$`AI}UR5%fRQaw-GP!xUFPNFDE1{PFI7#SLtR7omX5h6%MY9l((p*tVy$54rh zp;FZjofv>W02>3Wp$Sq|DMNxAVl%LGU;_bZI+Q38jj{0Sae}L7tKmu3d+*$H&b_|( z5&O@|WHL`|o4-fs5fL>xXQgmB^r2d82w;On#aCI#Gabwjh@YB zV}3q~00>IAYo0*xPS^DuS zZ&%>o6-D{TIbES2zrb(XwjB?2I@fRU&kE-OwOlTD{UY&>tgldd6qULUY8qqg&9`P4 z-)kayz&YB-rP;f9RDxRquKEDM0NCDh1I|Ngp{oZjaNmyqF8bnM{sPV_xSpFC_{0DJ N002ovPDHLkV1oSw0wMqa literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png b/designer-base/src/com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..93224106ecb962cff4cc7bd27836b9850c3db6e6 GIT binary patch literal 1115 zcmV-h1f=_kP)Px(6-h)vR9FeUR!e9TQ52mwNmDW7LdB}In}$|Vm(6FJRuH5uRs1bn_(8g`_yNJs z&ZUY}5b@JR(T!Fs+E_Qbs0Fp8Nd{NCuwtc1M2)V}LQ68wbLW#xXC^agQ+$xT`|dsW z^X|Lv&SSz7Mm!#u^7*-=g1~z?=R2Uf9=|_~v5$hl5|Xs~{`mNKehDT8RxLOZi5%oy zxCzG_E9oGRpNt8o)9Lh+N*F8OXJt68;rx=K@Vk&nB!{DEIC=)^73R-auLYZa5`sL? z)YQ0;&1T;b)@yiXfOZb&k99+{aCiYbybY(^FpjJ+;7-E%Rq%qu7e#icnoPI`pq=^b z7d`E>e!nj|IXU^saBQ7pvDo%Pp_l?cNXH>b!4|KY5UobcYbrS7%xULt&Pk8tgd>{t zw1TBo<>49tRXeF-H(x33mCckT`teL_98JG0wNtJEU>9`NF!&qunQJ`fe+|dSRIQS} zGnTln0YJWvK&Y`_G*>%Jcvas`&m#c#gOpM54Q@uPvNB%Nx5~|H*8pH>N&~ZY9EaEqI+&vw{x_9z?*f6s&7Y?Ij#Y4zL^Z<2u@9g?s-|& zPLW)1MkM^L>)U}Qj%xt2JUZv|iN|z&keW<59PYCo2d#;3G$F!6?>On3d^wU;oohH8 zJ9u?_@bq@6P+Ud&`t*Bm`sm{kQpI(iV)>pg~ePL@;s9-xxg zGk|b7hHroI3^dwHTJD5`42|Fr`ZJm2dv~awQYR1!sugE?3$k5K^6Gf(p)98lyI~zO z(AF01#MwT=xvnuO&tqq3u`J>9u}q;5$Tl=ce{;E9BQPOFVJ*-mz%D#KMgTTmN;CMp?#W~_AFPh5S;Gz?2hk_{e0d%lXv8W6g&LK?K*9RiYbxr~5JMYHps1LQUg?>a+KqMnfDFE#J4%X^( z3iC`LP}emvF|nktAQ?0dI6~Ull=&^8(QHbSK}rhPeK!JlK{R%bGw0D-c20KC8F!-& zo`bBXwZlMB3wzZJD2i~_1Q@KK@U5DIOo>E4@zhTZSxwG&MkWPsg(Fpo#X_2J>+q7!g= hJl^XTgeK#?{{TgFvLBllOyB?j002ovPDHLkV1h!x1hoJF literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java new file mode 100644 index 0000000000..73bffbb070 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -0,0 +1,33 @@ +package com.fr.design.remote.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.remote.RemoteDesignAuthority; + +import javax.swing.BorderFactory; +import java.awt.BorderLayout; +import java.awt.Label; + +public class AuthorityEditorPane extends BasicBeanPane { + + public AuthorityEditorPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + this.add(new Label("editor"), BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return "编辑文件权限"; + } + + @Override + public void populateBean(RemoteDesignAuthority ob) { + + } + + @Override + public RemoteDesignAuthority updateBean() { + return new RemoteDesignAuthority(); + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java new file mode 100644 index 0000000000..c228e58899 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -0,0 +1,520 @@ +package com.fr.design.remote.ui; + +import com.fr.base.BaseUtils; +import com.fr.design.actions.UpdateAction; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.controlpane.ShortCut4JControlPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.icon.IconPathConstants; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.menu.ShortCut; +import com.fr.design.menu.ToolBarDef; +import com.fr.design.remote.RemoteDesignAuthority; +import com.fr.design.remote.RemoteDesignAuthorityCreator; +import com.fr.design.remote.ui.list.AuthorityList; +import com.fr.design.remote.ui.list.AuthorityListCellRenderer; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; +import com.fr.stable.ArrayUtils; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.event.ActionEvent; +import java.util.ArrayList; +import java.util.List; + +public class AuthorityListControlPane extends BasicPane { + + + private static final String LIST_NAME = "AuthorityListControlPaneList"; + + private static final String UNSELECTED_EDITOR_NAME = "UNSELECTED"; + private static final String SELECTED_EDITOR_NAME = "SELECTED"; + + private AuthorityList authorityList; + + private static final int SHORT_WIDTH = 30; + + private ListEditorControlPane editorCtrl; + + + private CardLayout cardLayout; + + private JPanel cardPane; + + private ShortCut4JControlPane[] shortCuts; + + private RemoteDesignAuthorityCreator[] authorityCreators; + + private ToolBarDef toolbarDef; + + private UIToolbar toolBar; + + + public AuthorityListControlPane() { + super(); + initComponentPane(); + } + + + private void initComponentPane() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.authorityCreators = new RemoteDesignAuthorityCreator[]{ + new RemoteDesignAuthorityCreator( + "远程设计用户", + BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"), + RemoteDesignAuthority.class, + AuthorityEditorPane.class) + }; + editorCtrl = new ListEditorControlPane(); + + // 左侧列表面板 + JPanel leftPane = new JPanel(new BorderLayout()); + initLeftList(leftPane); + initLeftToolbar(leftPane); + + // 右侧卡片布局 + cardLayout = new CardLayout(); + cardPane = new JPanel(cardLayout); + UILabel selectLabel = new UILabel(); + cardPane.add(selectLabel, UNSELECTED_EDITOR_NAME); + cardPane.add(editorCtrl, SELECTED_EDITOR_NAME); + + // 左右分割布局 + JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftPane, cardPane); + mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); + mainSplitPane.setOneTouchExpandable(true); + add(mainSplitPane, BorderLayout.CENTER); + mainSplitPane.setDividerLocation(shortCuts.length * SHORT_WIDTH); + + checkButtonEnabled(); + } + + + private void initLeftToolbar(JPanel leftPane) { + shortCuts = createShortcuts(); + if (ArrayUtils.isEmpty(shortCuts)) { + return; + } + toolbarDef = new ToolBarDef(); + for (ShortCut4JControlPane sj : shortCuts) { + toolbarDef.addShortCut(sj.getShortCut()); + } + toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + leftPane.add(toolBar, BorderLayout.NORTH); + } + + + private void initLeftList(JPanel leftPane) { + authorityList = createList(); + authorityList.setName(LIST_NAME); + leftPane.add(new UIScrollPane(authorityList), BorderLayout.CENTER); + + + authorityList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + authorityList.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent evt) { + //避免多次update和populate大大降低效率 + if (!evt.getValueIsAdjusting()) { + //切换的时候加检验 + if (hasInvalid()) { + return; + } + AuthorityListControlPane.this.editorCtrl.update(); + AuthorityListControlPane.this.editorCtrl.populate(); + AuthorityListControlPane.this.checkButtonEnabled(); + } + } + }); + } + + private AuthorityList createList() { + AuthorityList list = new AuthorityList(new DefaultListModel()); + list.setCellRenderer(new AuthorityListCellRenderer()); + return list; + } + + + private void doWhenPopulate() { + + } + + private void doBeforePopulate() { + + } + + + public RemoteDesignAuthority[] update() { + List res = new ArrayList<>(); + this.editorCtrl.update(); + DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel(); + for (int i = 0, len = listModel.getSize(); i < len; i++) { + res.add((RemoteDesignAuthority) listModel.getElementAt(i)); + } + return res.toArray(new RemoteDesignAuthority[0]); + } + + public void populate(RemoteDesignAuthority[] authorities) { + DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel(); + listModel.removeAllElements(); + if (ArrayUtils.isEmpty(authorities)) { + return; + } + + for (RemoteDesignAuthority authority : authorities) { + listModel.addElement(authority); + } + + if (listModel.size() > 0) { + this.authorityList.setSelectedIndex(0); + } + this.checkButtonEnabled(); + } + + + public void updateEditorCtrlPane() { + editorCtrl.update(); + } + + /* + * 刷新当前的选中的UpdatePane + */ + public void populateEditorCtrlPane() { + this.editorCtrl.populate(); + } + + + public void setSelectedName(String name) { + DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel(); + for (int i = 0, len = listModel.getSize(); i < len; i++) { + RemoteDesignAuthority authority = (RemoteDesignAuthority) listModel.getElementAt(i); + if (ComparatorUtils.equals(name, authority.getName())) { + this.authorityList.setSelectedIndex(i); + break; + } + } + } + + + /** + * 获取选中的名字 + */ + public String getSelectedName() { + RemoteDesignAuthority authority = (RemoteDesignAuthority) this.authorityList.getSelectedValue(); + return authority == null ? null : authority.getName(); + } + + /** + * 添加 RemoteDesignAuthority + * + * @param authority authority + * @param index 序号 + */ + public void addAuthority(RemoteDesignAuthority authority, int index) { + DefaultListModel model = (DefaultListModel) authorityList.getModel(); + + model.add(index, authority); + authorityList.setSelectedIndex(index); + authorityList.ensureIndexIsVisible(index); + + authorityList.revalidate(); + authorityList.repaint(); + } + + + protected DefaultListModel getModel() { + return (DefaultListModel) this.authorityList.getModel(); + } + + + /** + * 检查按钮可用状态 Check button enabled. + */ + public void checkButtonEnabled() { + + if (authorityList.getSelectedIndex() == -1) { + this.cardLayout.show(cardPane, UNSELECTED_EDITOR_NAME); + } else { + this.cardLayout.show(cardPane, SELECTED_EDITOR_NAME); + } + for (ShortCut4JControlPane shortCut : shortCuts) { + shortCut.checkEnable(); + } + } + + + public class AbsoluteEnableShortCut extends ShortCut4JControlPane { + AbsoluteEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + @Override + public void checkEnable() { + this.shortCut.setEnabled(true); + } + } + + public class NormalEnableShortCut extends ShortCut4JControlPane { + NormalEnableShortCut(ShortCut shortCut) { + this.shortCut = shortCut; + } + + /** + * 检查是否可用 + */ + @Override + public void checkEnable() { + this.shortCut.setEnabled(authorityList.getModel() + .getSize() > 0 + && AuthorityListControlPane.this.authorityList.getSelectedIndex() != -1); + } + } + + + private BasicBeanPane createPaneByCreators(RemoteDesignAuthorityCreator creator) { + try { + return creator.getEditorClazz().newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + + /** + * 检查是否符合规范 + * + * @throws Exception e + */ + @Override + public void checkValid() throws Exception { + this.editorCtrl.checkValid(); + } + + private int getInValidIndex() { + BasicBeanPane[] p = editorCtrl.editorPanes; + if (p != null) { + for (int i = 0; i < p.length; i++) { + if (p[i] != null) { + try { + p[i].checkValid(); + } catch (Exception e) { + return i; + } + } + } + } + return -1; + } + + private boolean hasInvalid() { + int idx = AuthorityListControlPane.this.getInValidIndex(); + if (authorityList.getSelectedIndex() != idx) { + try { + checkValid(); + } catch (Exception exp) { + JOptionPane.showMessageDialog(AuthorityListControlPane.this, exp.getMessage()); + authorityList.setSelectedIndex(idx); + return true; + } + } + return false; + } + + /** + * 设置选中项 + * + * @param index 选中项的序列号 + */ + public void setSelectedIndex(int index) { + authorityList.setSelectedIndex(index); + } + + + private ShortCut4JControlPane[] createShortcuts() { + return new ShortCut4JControlPane[]{ + new AbsoluteEnableShortCut(new AddItemUpdateAction(authorityCreators)), + new NormalEnableShortCut(new RemoveItemAction()) + }; + } + + + private void doBeforeRemove() { + } + + private void doAfterRemove() { + } + + + /** + * 刷新 creators + * + * @param creators 生成器 + */ + public void refreshCreator(RemoteDesignAuthorityCreator[] creators) { + this.authorityCreators = creators; + shortCuts = this.createShortcuts(); + toolbarDef.clearShortCuts(); + for (ShortCut4JControlPane sj : shortCuts) { + toolbarDef.addShortCut(sj.getShortCut()); + } + + toolbarDef.updateToolBar(toolBar); + toolBar.validate(); + toolBar.repaint(); + this.repaint(); + } + + + @Override + protected String title4PopupWindow() { + return null; + } + + + private class ListEditorControlPane extends JPanel { + private CardLayout card; + private JPanel cardPane; + private BasicBeanPane[] editorPanes; + + private RemoteDesignAuthority authority; + + ListEditorControlPane() { + initUpdatePane(); + } + + private void initUpdatePane() { + card = new CardLayout(); + cardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); + cardPane.setLayout(card); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.add(cardPane); + editorPanes = new BasicBeanPane[authorityCreators.length]; + } + + public void populate() { + authority = (RemoteDesignAuthority) AuthorityListControlPane.this.authorityList.getSelectedValue(); + + if (authority == null) { + return; + } + + for (int i = 0, len = editorPanes.length; i < len; i++) { + if (authorityCreators[i].accept(authority)) { + editorPanes[i] = createPaneByCreators(authorityCreators[i]); + cardPane.add(editorPanes[i], String.valueOf(i)); + card.show(cardPane, String.valueOf(i)); + doBeforePopulate(); + editorPanes[i].populateBean(authority); + doWhenPopulate(); + break; + } + } + } + + + public void update() { + for (int i = 0; i < editorPanes.length; i++) { + BasicBeanPane pane = editorPanes[i]; + if (pane != null && pane.isVisible()) { + Object bean = pane.updateBean(); + if (i < authorityCreators.length) { + authorityCreators[i].saveUpdatedBean(authority, bean); + } + } + } + } + + public void checkValid() throws Exception { + if (editorPanes != null) { + for (BasicBeanPane updatePane : editorPanes) { + if (updatePane != null) { + updatePane.checkValid(); + } + } + } + } + } + + /** + * 添加按钮 + */ + private class AddItemUpdateAction extends UpdateAction { + private RemoteDesignAuthorityCreator creator; + + AddItemUpdateAction(RemoteDesignAuthorityCreator[] creators) { + this.creator = creators[0]; + this.setName(Inter.getLocText("FR-Action_Add")); + this.setMnemonic('A'); + this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + } + + @Override + public void actionPerformed(ActionEvent e) { + final UserManagerPane userManagerPane = new UserManagerPane(); + BasicDialog dialog = userManagerPane.showWindow(SwingUtilities.getWindowAncestor(AuthorityListControlPane.this)); + + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + // todo 获取 UserManagerPane 添加的用户 + userManagerPane.title4PopupWindow(); + + RemoteDesignAuthority authority = new RemoteDesignAuthority(); + authority.setName("new User"); + AuthorityListControlPane.this.addAuthority(authority, getModel().getSize()); + } + + @Override + public void doCancel() { + super.doCancel(); + } + }); + dialog.setModal(true); + dialog.setVisible(true); + + + } + } + + /* + * 删除按钮 + */ + private class RemoveItemAction extends UpdateAction { + RemoveItemAction() { + this.setName(Inter.getLocText("FR-Action_Remove")); + this.setMnemonic('R'); + this.setSmallIcon(BaseUtils + .readIcon(IconPathConstants.TD_REMOVE_ICON_PATH)); + } + + @Override + public void actionPerformed(ActionEvent evt) { + doBeforeRemove(); + if (GUICoreUtils.removeJListSelectedNodes(SwingUtilities + .getWindowAncestor(AuthorityListControlPane.this), authorityList)) { + checkButtonEnabled(); + doAfterRemove(); + } + } + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java new file mode 100644 index 0000000000..877d7fe157 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java @@ -0,0 +1,37 @@ +package com.fr.design.remote.ui; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.remote.RemoteDesignAuthority; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import java.awt.BorderLayout; + +public class AuthorityManagerPane extends BasicPane { + + private AuthorityListControlPane list; + + + public AuthorityManagerPane() { + this.setLayout(new BorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder()); + + list = new AuthorityListControlPane(); + this.add(list, BorderLayout.CENTER); + } + + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("远程设计权限管理"); + } + + public void populate(RemoteDesignAuthority[] authorities) { + list.populate(authorities); + } + + private RemoteDesignAuthority[] update() { + + return list.update(); + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java new file mode 100644 index 0000000000..08014ad882 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -0,0 +1,98 @@ +package com.fr.design.remote.ui; + +import com.fr.design.border.UITitledBorder; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.remote.RemoteMember; +import com.fr.design.remote.ui.list.MemberList; +import com.fr.design.remote.ui.list.MemberListCellRender; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.util.ArrayList; +import java.util.List; + + +/** + * @author yaohwu + */ +public class UserManagerPane extends BasicPane { + + private List members = new ArrayList<>(); + + DefaultListModel listModel = new DefaultListModel<>(); + + + public UserManagerPane() { + this.setBorder(BorderFactory.createEmptyBorder()); + this.setLayout(new BorderLayout()); + this.add( + TableLayoutHelper.createTableLayoutPane( + new Component[][]{ + new Component[]{createLeftPanel(), new JPanel()} + }, + new double[]{TableLayout.FILL}, + new double[]{TableLayout.FILL, TableLayout.FILL} + ), + BorderLayout.CENTER); + } + + + @Override + protected String title4PopupWindow() { + return "添加设计成员"; + } + + private JPanel createLeftPanel() { + JPanel content = new JPanel(new BorderLayout()); + + content.setBorder( + BorderFactory.createCompoundBorder( + new EmptyBorder(6, 0, 0, 0), + UITitledBorder.createBorderWithTitle(Inter.getLocText("决策系统成员"))) + ); + + // 搜索 + UITextField searchKeyInput = new UITextField(); + UIButton searchButton = new UIButton("搜索"); + JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + searchPanel.setBorder(BorderFactory.createEmptyBorder()); + searchPanel.add(searchKeyInput); + searchPanel.add(searchButton); + // 内容列表 + listModel = new DefaultListModel<>(); + MemberList list = new MemberList(listModel); + list.setCellRenderer(new MemberListCellRender()); + resetMembers(); + addContentToList(); + UIScrollPane listPane = new UIScrollPane(list); + listPane.setBorder(BorderFactory.createEmptyBorder()); + + content.add(searchPanel, BorderLayout.NORTH); + content.add(listPane, BorderLayout.CENTER); + return content; + } + + + private void addContentToList() { + listModel.removeAllElements(); + for (RemoteMember member : members) { + listModel.addElement(member); + } + } + + private void resetMembers() { + members.clear(); + members.add(RemoteMember.DEFAULT_MEMBER); + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java b/designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java new file mode 100644 index 0000000000..6d0502ff13 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java @@ -0,0 +1,28 @@ +package com.fr.design.remote.ui.list; + +import com.fr.design.remote.RemoteDesignAuthority; + +import javax.swing.JList; +import javax.swing.ListModel; +import java.util.Vector; + +public class AuthorityList extends JList { + + + public AuthorityList() { + super(); + } + + public AuthorityList(ListModel dataModel) { + super(dataModel); + } + + public AuthorityList(final RemoteDesignAuthority[] listData) { + super(listData); + } + + public AuthorityList(final Vector listData) { + super(listData); + } + +} \ No newline at end of file diff --git a/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java b/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java new file mode 100644 index 0000000000..46809ba26a --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java @@ -0,0 +1,132 @@ +package com.fr.design.remote.ui.list; + +import com.fr.base.BaseUtils; +import com.fr.design.remote.RemoteDesignAuthority; +import sun.swing.DefaultLookup; + +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import java.awt.Color; +import java.awt.Component; + +/* + * NameableListCellRenderer + */ +public class AuthorityListCellRenderer extends + JLabel implements ListCellRenderer { + + /** + * An empty Border. This field might not be used. To change the + * Border used by this renderer override the + * getListCellRendererComponent method and set the border + * of the returned component directly. + */ + private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); + private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); + private static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER; + + + /** + * Constructs a default renderer object for an item + * in a list. + */ + public AuthorityListCellRenderer() { + super(); + setOpaque(true); + setBorder(getNoFocusBorder()); + setName("List.cellRenderer"); + } + + @Override + public Component getListCellRendererComponent(JList list, RemoteDesignAuthority authority, + int index, boolean isSelected, boolean cellHasFocus) { + setComponentOrientation(list.getComponentOrientation()); + + Color bg = null; + Color fg = null; + + JList.DropLocation dropLocation = list.getDropLocation(); + if (dropLocation != null + && !dropLocation.isInsert() + && dropLocation.getIndex() == index) { + + bg = DefaultLookup.getColor(this, ui, "List.dropCellBackground"); + fg = DefaultLookup.getColor(this, ui, "List.dropCellForeground"); + + isSelected = true; + } + + if (isSelected) { + setBackground(bg == null ? list.getSelectionBackground() : bg); + setForeground(fg == null ? list.getSelectionForeground() : fg); + } else { + setBackground(list.getBackground()); + setForeground(list.getForeground()); + } + + + setEnabled(list.isEnabled()); + setFont(list.getFont()); + + Border border = null; + if (cellHasFocus) { + if (isSelected) { + border = DefaultLookup.getBorder(this, ui, "List.focusSelectedCellHighlightBorder"); + } + if (border == null) { + border = DefaultLookup.getBorder(this, ui, "List.focusCellHighlightBorder"); + } + } else { + border = getNoFocusBorder(); + } + setBorder(border); + + this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); + this.setText(authority.getName()); + return this; + } + + + private Border getNoFocusBorder() { + Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder"); + if (System.getSecurityManager() != null) { + if (border != null) return border; + return SAFE_NO_FOCUS_BORDER; + } else { + if (border != null && + (noFocusBorder == null || + noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { + return border; + } + return noFocusBorder; + } + } + + + /** + * Overridden for performance reasons. + * See the Implementation Note + * for more information. + * + * @return true if the background is completely opaque + * and differs from the JList's background; + * false otherwise + * @since 1.5 + */ + @Override + public boolean isOpaque() { + Color back = getBackground(); + Component p = getParent(); + if (p != null) { + p = p.getParent(); + } + // p should now be the JList. + boolean colorMatch = (back != null) && (p != null) && + back.equals(p.getBackground()) && + p.isOpaque(); + return !colorMatch && super.isOpaque(); + } +} \ No newline at end of file diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberList.java b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java new file mode 100644 index 0000000000..df1bc866a6 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java @@ -0,0 +1,39 @@ +package com.fr.design.remote.ui.list; + +import com.fr.design.remote.RemoteMember; + +import javax.swing.JList; +import javax.swing.ListModel; +import java.awt.Color; +import java.util.Vector; + +public class MemberList extends JList { + + + public MemberList() { + super(); + init(); + } + + public MemberList(ListModel dataModel) { + super(dataModel); + init(); + } + + public MemberList(RemoteMember[] listData) { + super(listData); + init(); + } + + public MemberList(Vector listData) { + super(listData); + init(); + } + + private void init() { + setBackground(new Color(0xF5F5F7)); + } + +} + + diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java b/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java new file mode 100644 index 0000000000..2d7f886fec --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java @@ -0,0 +1,45 @@ +package com.fr.design.remote.ui.list; + +import com.fr.base.BaseUtils; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.remote.RemoteMember; + +import javax.swing.BorderFactory; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +import java.awt.Component; +import java.awt.FlowLayout; + +public class MemberListCellRender extends JPanel implements ListCellRenderer { + + private UILabel label; + private UICheckBox check; + + + public MemberListCellRender() { + this.setBorder(BorderFactory.createEmptyBorder()); + this.setLayout(new FlowLayout(FlowLayout.LEFT)); + label = new UILabel(); + label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); + check = new UICheckBox(); + check.setSelected(false); + this.add(label); + this.add(check); + } + + + @Override + public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { + this.setLabelName(member.getName()); + check.setSelected(false); + return this; + } + + private void setLabelName(String name) { + label.setName(name); + } + + +} diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java new file mode 100644 index 0000000000..91558f639a --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java @@ -0,0 +1,6 @@ +package com.fr.design.remote.ui.tree; + +import javax.swing.JTree; + +public class FileAuthorityTree extends JTree { +} From 8a81a5d5336a6e152f47c01881b49afc3c8c5d51 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 16 May 2018 17:53:09 +0800 Subject: [PATCH 02/17] =?UTF-8?q?REPORT-6700=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/remote/RemoteMember.java | 12 ++ .../src/com/fr/design/remote/Utils.java | 49 ++++++ .../fr/design/remote/images/icon_Remove_x.png | Bin 0 -> 238 bytes .../remote/ui/AuthorityListControlPane.java | 4 +- .../fr/design/remote/ui/UserManagerPane.java | 144 ++++++++++++++++-- .../remote/ui/list/AddedMemberList.java | 35 +++++ .../ui/list/AddedMemberListCellRender.java | 44 ++++++ .../fr/design/remote/ui/list/MemberList.java | 47 +++++- .../remote/ui/list/MemberListCellRender.java | 13 +- 9 files changed, 324 insertions(+), 24 deletions(-) create mode 100644 designer-base/src/com/fr/design/remote/Utils.java create mode 100644 designer-base/src/com/fr/design/remote/images/icon_Remove_x.png create mode 100644 designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java create mode 100644 designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java diff --git a/designer-base/src/com/fr/design/remote/RemoteMember.java b/designer-base/src/com/fr/design/remote/RemoteMember.java index aa25da3686..019159b30a 100644 --- a/designer-base/src/com/fr/design/remote/RemoteMember.java +++ b/designer-base/src/com/fr/design/remote/RemoteMember.java @@ -4,8 +4,11 @@ public class RemoteMember { public static final RemoteMember DEFAULT_MEMBER = new RemoteMember("查询中..."); + private String name; + private boolean selected; + public RemoteMember(String name) { this.name = name; } @@ -17,4 +20,13 @@ public class RemoteMember { public void setName(String name) { this.name = name; } + + + public boolean isSelected() { + return selected; + } + + public void setSelected(boolean selected) { + this.selected = selected; + } } diff --git a/designer-base/src/com/fr/design/remote/Utils.java b/designer-base/src/com/fr/design/remote/Utils.java new file mode 100644 index 0000000000..1e2e12ebaf --- /dev/null +++ b/designer-base/src/com/fr/design/remote/Utils.java @@ -0,0 +1,49 @@ +package com.fr.design.remote; + +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Random; + +public class Utils { + + private static final String SOURCES = + "._-~`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; + + private Utils() { + + } + + public static Collection getRemoteMember(String keyword) { + // todo 使用决策平台api获取决策平台用户 + List res = new ArrayList<>(); + for (int i = 0; i < 30; i++) { + RemoteMember remoteMember = new RemoteMember(generate()); + if (StringUtils.isEmpty(keyword)) { + res.add(remoteMember); + continue; + } + if (remoteMember.getName().contains(keyword)) { + res.add(remoteMember); + } + } + return res; + } + + + /** + * Generate a random string. + * + * @return String string + */ + private static String generate() { + Random random = new Random(); + char[] text = new char[6]; + for (int i = 0; i < 6; i++) { + text[i] = Utils.SOURCES.charAt(random.nextInt(Utils.SOURCES.length())); + } + return new String(text); + } +} diff --git a/designer-base/src/com/fr/design/remote/images/icon_Remove_x.png b/designer-base/src/com/fr/design/remote/images/icon_Remove_x.png new file mode 100644 index 0000000000000000000000000000000000000000..5a9a05e8add66e9c7b76e4fefb3144d48242618a GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP*AeO zHKHUqKdq!Zu_%?nF(p4KRlzeiF+DXXH8G{K@MNkDP*Js~i(^Q|t>hp7|JyUGO8AI~ zi*qwKiP>fr?}99cEZGUX0S=Q6WO2-T#&2-_QE-Ao zkBnk8&xg!o1`OSb^A}1izy5($%t!f*0`r`U9-+({pO{=5JpxUF=1f>Ib&B+dOgG~t djLMpmyBQ-_wE3U$kpuaR!PC{xWt~$(699PDNCW@? literal 0 HcmV?d00001 diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java index c228e58899..8fc3e120d8 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -217,7 +217,7 @@ public class AuthorityListControlPane extends BasicPane { * 获取选中的名字 */ public String getSelectedName() { - RemoteDesignAuthority authority = (RemoteDesignAuthority) this.authorityList.getSelectedValue(); + RemoteDesignAuthority authority = this.authorityList.getSelectedValue(); return authority == null ? null : authority.getName(); } @@ -412,7 +412,7 @@ public class AuthorityListControlPane extends BasicPane { } public void populate() { - authority = (RemoteDesignAuthority) AuthorityListControlPane.this.authorityList.getSelectedValue(); + authority = AuthorityListControlPane.this.authorityList.getSelectedValue(); if (authority == null) { return; diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index 08014ad882..d5bb9c1e6e 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -4,10 +4,13 @@ import com.fr.design.border.UITitledBorder; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.remote.RemoteMember; +import com.fr.design.remote.Utils; +import com.fr.design.remote.ui.list.AddedMemberList; import com.fr.design.remote.ui.list.MemberList; import com.fr.design.remote.ui.list.MemberListCellRender; import com.fr.general.Inter; @@ -15,10 +18,17 @@ import com.fr.general.Inter; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.JPanel; +import javax.swing.ListSelectionModel; +import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; @@ -28,9 +38,58 @@ import java.util.List; */ public class UserManagerPane extends BasicPane { + /** + * 获取的决策平台成员 + */ private List members = new ArrayList<>(); - - DefaultListModel listModel = new DefaultListModel<>(); + /** + * 添加到设计的决策平台成员 + */ + private List addedMembers = new ArrayList<>(); + + /** + * 决策平台成员列表model + */ + private DefaultListModel listModel = new DefaultListModel<>(); + /** + * 搜索输入框 + */ + private UITextField keyField = new UITextField(); + /** + * 搜索按钮 + */ + private UIButton keyButton = new UIButton(); + + /** + * 搜索按钮绑定事件 + */ + private ActionListener keyButtonActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + searchMembers(keyField.getText()); + } + }; + + /** + * 输入框绑定事件 + */ + private KeyAdapter keyFieldKeyListener = new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + //判断按下的键是否是回车键 + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + searchMembers(keyField.getText()); + } + } + }; + /** + * 添加到设计的决策成员计数标签 + */ + private UILabel countLabel = new UILabel(); + /** + * 添加到设计的决策成员计数标签 + */ + private DefaultListModel addedListModel; public UserManagerPane() { @@ -39,7 +98,7 @@ public class UserManagerPane extends BasicPane { this.add( TableLayoutHelper.createTableLayoutPane( new Component[][]{ - new Component[]{createLeftPanel(), new JPanel()} + new Component[]{createLeftPanel(), createRightPanel()} }, new double[]{TableLayout.FILL}, new double[]{TableLayout.FILL, TableLayout.FILL} @@ -63,18 +122,23 @@ public class UserManagerPane extends BasicPane { ); // 搜索 - UITextField searchKeyInput = new UITextField(); - UIButton searchButton = new UIButton("搜索"); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); searchPanel.setBorder(BorderFactory.createEmptyBorder()); - searchPanel.add(searchKeyInput); - searchPanel.add(searchButton); + keyField.setPreferredSize(new Dimension(200, 20)); + keyField.requestFocus(); + keyField.addKeyListener(keyFieldKeyListener); + keyButton.setText("搜索"); + keyButton.addActionListener(keyButtonActionListener); + searchPanel.add(keyField); + searchPanel.add(keyButton); + // 内容列表 listModel = new DefaultListModel<>(); - MemberList list = new MemberList(listModel); + final MemberList list = new MemberList(listModel); + list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); list.setCellRenderer(new MemberListCellRender()); resetMembers(); - addContentToList(); + addToMemberList(); UIScrollPane listPane = new UIScrollPane(list); listPane.setBorder(BorderFactory.createEmptyBorder()); @@ -84,15 +148,73 @@ public class UserManagerPane extends BasicPane { } - private void addContentToList() { - listModel.removeAllElements(); + private JPanel createRightPanel() { + JPanel content = new JPanel(new BorderLayout()); + + content.setBorder( + BorderFactory.createCompoundBorder( + new EmptyBorder(6, 0, 0, 0), + UITitledBorder.createBorderWithTitle(Inter.getLocText("已选择的设计成员"))) + ); + + // 计数 + countLabel.setText(Inter.getLocText("已选择{R1}人", "0")); + + addedListModel = new DefaultListModel<>(); + final AddedMemberList addedList = new AddedMemberList(listModel); + addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + addedList.setCellRenderer(new MemberListCellRender()); + resetAddedMembers(); + addToAddedMemberList(); + UIScrollPane listPane = new UIScrollPane(addedList); + listPane.setBorder(BorderFactory.createEmptyBorder()); + + content.add(countLabel, BorderLayout.NORTH); + content.add(listPane, BorderLayout.CENTER); + return content; + + } + + + private void addToMemberList() { + listModel.clear(); for (RemoteMember member : members) { listModel.addElement(member); } } + private void addToAddedMemberList() { + addedListModel.clear(); + for (RemoteMember member : addedMembers) { + addedListModel.addElement(member); + } + } + private void resetMembers() { members.clear(); members.add(RemoteMember.DEFAULT_MEMBER); } + + private void resetAddedMembers() { + addedMembers.clear(); + } + + + private void searchMembers(final String keyword) { + + final SwingWorker getMemberWorker = new SwingWorker, Void>() { + @Override + protected List doInBackground() { + members.clear(); + members.addAll(Utils.getRemoteMember(keyword)); + return members; + } + + @Override + protected void done() { + addToMemberList(); + } + }; + getMemberWorker.execute(); + } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java new file mode 100644 index 0000000000..40b4bbd942 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java @@ -0,0 +1,35 @@ +package com.fr.design.remote.ui.list; + +import com.fr.design.remote.RemoteMember; + +import javax.swing.JList; +import javax.swing.ListModel; +import java.awt.Color; +import java.util.Vector; + +public class AddedMemberList extends JList { + + public AddedMemberList() { + super(); + init(this.getModel().getSize()); + } + + public AddedMemberList(ListModel dataModel) { + super(dataModel); + init(dataModel.getSize()); + } + + public AddedMemberList(RemoteMember[] listData) { + super(listData); + init(listData.length); + } + + public AddedMemberList(Vector listData) { + super(listData); + init(listData.size()); + } + + private void init(int size) { + setBackground(new Color(0xF5F5F7)); + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java new file mode 100644 index 0000000000..8af7713bea --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java @@ -0,0 +1,44 @@ +package com.fr.design.remote.ui.list; + +import com.fr.base.BaseUtils; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.remote.RemoteMember; + +import javax.swing.BorderFactory; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +import java.awt.Component; +import java.awt.FlowLayout; + +public class AddedMemberListCellRender extends JPanel implements ListCellRenderer { + + + private UILabel label; + + private UIButton uiButton; + + public AddedMemberListCellRender() { + this.setBorder(BorderFactory.createEmptyBorder()); + this.setLayout(new FlowLayout(FlowLayout.LEFT)); + + label = new UILabel(); + label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); + + uiButton.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png")); + + this.add(label); + this.add(uiButton); + } + + @Override + public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { + this.setLabelText(member.getName()); + return this; + } + + private void setLabelText(String name) { + label.setText(name); + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberList.java b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java index df1bc866a6..71cad5e6df 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/MemberList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java @@ -5,33 +5,70 @@ import com.fr.design.remote.RemoteMember; import javax.swing.JList; import javax.swing.ListModel; import java.awt.Color; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.Vector; public class MemberList extends JList { + private boolean[] selects; + public MemberList() { super(); - init(); + init(this.getModel().getSize()); } public MemberList(ListModel dataModel) { super(dataModel); - init(); + init(dataModel.getSize()); } public MemberList(RemoteMember[] listData) { super(listData); - init(); + init(listData.length); } public MemberList(Vector listData) { super(listData); - init(); + init(listData.size()); + } + + + @Override + public void setModel(ListModel model) { + super.setModel(model); + selects = new boolean[this.getModel().getSize()]; } - private void init() { + private void init(int size) { + selects = new boolean[size]; setBackground(new Color(0xF5F5F7)); + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + displaySelected(); + } + }); + this.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + super.keyReleased(e); + if (e.getKeyCode() == KeyEvent.VK_SPACE) { + displaySelected(); + } + } + }); + } + + private void displaySelected() { + RemoteMember member = getSelectedValue(); + member.setSelected(!member.isSelected()); + revalidate(); + repaint(); } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java b/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java index 2d7f886fec..77ba4941ad 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java +++ b/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java @@ -21,10 +21,13 @@ public class MemberListCellRender extends JPanel implements ListCellRenderer Date: Thu, 17 May 2018 14:51:45 +0800 Subject: [PATCH 03/17] save --- .../fr/design/remote/ui/UserManagerPane.java | 45 ++++++++++--- .../remote/ui/list/AddedMemberList.java | 39 +++++++++--- .../remote/ui/list/AddingMemberList.java | 63 +++++++++++++++++++ ...r.java => AddingMemberListCellRender.java} | 5 +- .../fr/design/remote/ui/list/MemberList.java | 59 +++++------------ .../MemberListSelectedChangeListener.java | 7 +++ 6 files changed, 159 insertions(+), 59 deletions(-) create mode 100644 designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java rename designer-base/src/com/fr/design/remote/ui/list/{MemberListCellRender.java => AddingMemberListCellRender.java} (87%) create mode 100644 designer-base/src/com/fr/design/remote/ui/list/MemberListSelectedChangeListener.java diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index d5bb9c1e6e..018667d157 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -11,8 +11,9 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.remote.RemoteMember; import com.fr.design.remote.Utils; import com.fr.design.remote.ui.list.AddedMemberList; -import com.fr.design.remote.ui.list.MemberList; -import com.fr.design.remote.ui.list.MemberListCellRender; +import com.fr.design.remote.ui.list.AddingMemberList; +import com.fr.design.remote.ui.list.AddingMemberListCellRender; +import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; import com.fr.general.Inter; import javax.swing.BorderFactory; @@ -89,7 +90,19 @@ public class UserManagerPane extends BasicPane { /** * 添加到设计的决策成员计数标签 */ - private DefaultListModel addedListModel; + private DefaultListModel addedListModel; + + + private MemberListSelectedChangeListener memberListSelectedChangeListener = new MemberListSelectedChangeListener() { + @Override + public void selectedChange() { + resetAddedMembers(); + addedMembers.addAll(getNeedAddMember()); + addToAddedMemberList(); + } + }; + private AddedMemberList addedList; + private AddingMemberList list; public UserManagerPane() { @@ -134,9 +147,9 @@ public class UserManagerPane extends BasicPane { // 内容列表 listModel = new DefaultListModel<>(); - final MemberList list = new MemberList(listModel); - list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - list.setCellRenderer(new MemberListCellRender()); + list = new AddingMemberList(listModel); + list.setCellRenderer(new AddingMemberListCellRender()); + list.addSelectedChangeListener(memberListSelectedChangeListener); resetMembers(); addToMemberList(); UIScrollPane listPane = new UIScrollPane(list); @@ -161,9 +174,9 @@ public class UserManagerPane extends BasicPane { countLabel.setText(Inter.getLocText("已选择{R1}人", "0")); addedListModel = new DefaultListModel<>(); - final AddedMemberList addedList = new AddedMemberList(listModel); + addedList = new AddedMemberList(addedListModel); addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - addedList.setCellRenderer(new MemberListCellRender()); + addedList.setCellRenderer(new AddingMemberListCellRender()); resetAddedMembers(); addToAddedMemberList(); UIScrollPane listPane = new UIScrollPane(addedList); @@ -181,6 +194,8 @@ public class UserManagerPane extends BasicPane { for (RemoteMember member : members) { listModel.addElement(member); } + list.revalidate(); + list.repaint(); } private void addToAddedMemberList() { @@ -188,6 +203,8 @@ public class UserManagerPane extends BasicPane { for (RemoteMember member : addedMembers) { addedListModel.addElement(member); } + addedList.revalidate(); + addedList.repaint(); } private void resetMembers() { @@ -217,4 +234,16 @@ public class UserManagerPane extends BasicPane { }; getMemberWorker.execute(); } + + private List getNeedAddMember() { + List res = new ArrayList<>(); + RemoteMember[] members = new RemoteMember[listModel.getSize()]; + listModel.copyInto(members); + for (RemoteMember member : members) { + if (member.isSelected()) { + res.add(member); + } + } + return res; + } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java index 40b4bbd942..86f0e1c79f 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java @@ -2,34 +2,59 @@ package com.fr.design.remote.ui.list; import com.fr.design.remote.RemoteMember; -import javax.swing.JList; import javax.swing.ListModel; +import javax.swing.ListSelectionModel; import java.awt.Color; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.Vector; -public class AddedMemberList extends JList { +public class AddedMemberList extends MemberList { public AddedMemberList() { super(); - init(this.getModel().getSize()); + init(); } public AddedMemberList(ListModel dataModel) { super(dataModel); - init(dataModel.getSize()); + init(); } public AddedMemberList(RemoteMember[] listData) { super(listData); - init(listData.length); + init(); } public AddedMemberList(Vector listData) { super(listData); - init(listData.size()); + init(); } - private void init(int size) { + + private void init() { setBackground(new Color(0xF5F5F7)); + + this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + System.out.println(e.getX() + " " + e.getY()); + displaySelected(); + } + }); + this.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + super.keyReleased(e); + if (e.getKeyCode() == KeyEvent.VK_SPACE) { + displaySelected(); + } + } + }); } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java new file mode 100644 index 0000000000..4f245daf2a --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java @@ -0,0 +1,63 @@ +package com.fr.design.remote.ui.list; + +import com.fr.design.remote.RemoteMember; + +import javax.swing.ListModel; +import javax.swing.ListSelectionModel; +import java.awt.Color; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Vector; + +public class AddingMemberList extends MemberList { + + + public AddingMemberList() { + super(); + init(); + } + + public AddingMemberList(ListModel dataModel) { + super(dataModel); + init(); + } + + public AddingMemberList(RemoteMember[] listData) { + super(listData); + init(); + } + + public AddingMemberList(Vector listData) { + super(listData); + init(); + } + + + private void init() { + setBackground(new Color(0xF5F5F7)); + + this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + System.out.println(e.getX() + " " + e.getY()); + displaySelected(); + } + }); + this.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + super.keyReleased(e); + if (e.getKeyCode() == KeyEvent.VK_SPACE) { + displaySelected(); + } + } + }); + } +} + + diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java similarity index 87% rename from designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java rename to designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java index 77ba4941ad..b953a42888 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/MemberListCellRender.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java @@ -12,13 +12,13 @@ import javax.swing.ListCellRenderer; import java.awt.Component; import java.awt.FlowLayout; -public class MemberListCellRender extends JPanel implements ListCellRenderer { +public class AddingMemberListCellRender extends JPanel implements ListCellRenderer { private UILabel label; private UICheckBox check; - public MemberListCellRender() { + public AddingMemberListCellRender() { this.setBorder(BorderFactory.createEmptyBorder()); this.setLayout(new FlowLayout(FlowLayout.LEFT)); @@ -27,6 +27,7 @@ public class MemberListCellRender extends JPanel implements ListCellRenderer { - - private boolean[] selects; - - public MemberList() { - super(); - init(this.getModel().getSize()); - } - public MemberList(ListModel dataModel) { super(dataModel); - init(dataModel.getSize()); } public MemberList(RemoteMember[] listData) { super(listData); - init(listData.length); } public MemberList(Vector listData) { super(listData); - init(listData.size()); + } + + public MemberList() { } - @Override - public void setModel(ListModel model) { - super.setModel(model); - selects = new boolean[this.getModel().getSize()]; + public void addSelectedChangeListener(MemberListSelectedChangeListener l) { + this.listenerList.add(MemberListSelectedChangeListener.class, l); } - private void init(int size) { - selects = new boolean[size]; - setBackground(new Color(0xF5F5F7)); - this.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - super.mouseReleased(e); - displaySelected(); - } - }); - this.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - super.keyReleased(e); - if (e.getKeyCode() == KeyEvent.VK_SPACE) { - displaySelected(); - } + public void removeSelectedChangeListener(MemberListSelectedChangeListener l) { + this.listenerList.remove(MemberListSelectedChangeListener.class, l); + } + + public void fireSelectedChange() { + Object[] listeners = listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == MemberListSelectedChangeListener.class) { + ((MemberListSelectedChangeListener) listeners[i + 1]).selectedChange(); } - }); + } } - private void displaySelected() { + protected void displaySelected() { RemoteMember member = getSelectedValue(); member.setSelected(!member.isSelected()); revalidate(); repaint(); + fireSelectedChange(); } - } - - diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberListSelectedChangeListener.java b/designer-base/src/com/fr/design/remote/ui/list/MemberListSelectedChangeListener.java new file mode 100644 index 0000000000..1e00cf7930 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/list/MemberListSelectedChangeListener.java @@ -0,0 +1,7 @@ +package com.fr.design.remote.ui.list; + +import java.util.EventListener; + +public interface MemberListSelectedChangeListener extends EventListener { + void selectedChange(); +} From ca778b2b15e215fb213ba1c05a28e59c29956364 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 18 May 2018 11:11:11 +0800 Subject: [PATCH 04/17] update --- .../fr/design/remote/ui/UserManagerPane.java | 95 ++++++++++++------- .../remote/ui/list/AddedMemberList.java | 48 +++------- .../ui/list/AddedMemberListCellRender.java | 1 + .../remote/ui/list/AddingMemberList.java | 48 +++------- .../fr/design/remote/ui/list/MemberList.java | 52 ++++++++-- 5 files changed, 137 insertions(+), 107 deletions(-) diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index 018667d157..dbc02b0cd8 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -11,10 +11,12 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.remote.RemoteMember; import com.fr.design.remote.Utils; import com.fr.design.remote.ui.list.AddedMemberList; +import com.fr.design.remote.ui.list.AddedMemberListCellRender; import com.fr.design.remote.ui.list.AddingMemberList; import com.fr.design.remote.ui.list.AddingMemberListCellRender; import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; import com.fr.general.Inter; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; @@ -31,6 +33,7 @@ import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; @@ -42,7 +45,7 @@ public class UserManagerPane extends BasicPane { /** * 获取的决策平台成员 */ - private List members = new ArrayList<>(); + private List addingMembers = new ArrayList<>(); /** * 添加到设计的决策平台成员 */ @@ -51,7 +54,7 @@ public class UserManagerPane extends BasicPane { /** * 决策平台成员列表model */ - private DefaultListModel listModel = new DefaultListModel<>(); + private DefaultListModel addingListModel = new DefaultListModel<>(); /** * 搜索输入框 */ @@ -67,7 +70,7 @@ public class UserManagerPane extends BasicPane { private ActionListener keyButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - searchMembers(keyField.getText()); + searchAddingMembers(keyField.getText()); } }; @@ -77,9 +80,10 @@ public class UserManagerPane extends BasicPane { private KeyAdapter keyFieldKeyListener = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { - //判断按下的键是否是回车键 + // 判断按下的键是否是回车键 + // todo 对话款回车键绑定的是对话框的确定按钮 if (e.getKeyCode() == KeyEvent.VK_ENTER) { - searchMembers(keyField.getText()); + searchAddingMembers(keyField.getText()); } } }; @@ -93,16 +97,28 @@ public class UserManagerPane extends BasicPane { private DefaultListModel addedListModel; - private MemberListSelectedChangeListener memberListSelectedChangeListener = new MemberListSelectedChangeListener() { + private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() { @Override public void selectedChange() { resetAddedMembers(); - addedMembers.addAll(getNeedAddMember()); + sync2AddedMembersFromAdding(); addToAddedMemberList(); } }; + + private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() { + @Override + public void selectedChange() { + addingList.revalidate(); + addingList.repaint(); + resetAddedMembers(); + sync2AddedMembersFormAdded(); + // 不需要重复更新右侧列表显示 + + } + }; private AddedMemberList addedList; - private AddingMemberList list; + private AddingMemberList addingList; public UserManagerPane() { @@ -146,13 +162,14 @@ public class UserManagerPane extends BasicPane { searchPanel.add(keyButton); // 内容列表 - listModel = new DefaultListModel<>(); - list = new AddingMemberList(listModel); - list.setCellRenderer(new AddingMemberListCellRender()); - list.addSelectedChangeListener(memberListSelectedChangeListener); + addingListModel = new DefaultListModel<>(); + addingList = new AddingMemberList(addingListModel); + addingList.setCellRenderer(new AddingMemberListCellRender()); + addingList.addSelectedChangeListener(addingListChangeListener); resetMembers(); addToMemberList(); - UIScrollPane listPane = new UIScrollPane(list); + searchAddingMembers(StringUtils.EMPTY); + UIScrollPane listPane = new UIScrollPane(addingList); listPane.setBorder(BorderFactory.createEmptyBorder()); content.add(searchPanel, BorderLayout.NORTH); @@ -171,12 +188,13 @@ public class UserManagerPane extends BasicPane { ); // 计数 - countLabel.setText(Inter.getLocText("已选择{R1}人", "0")); + countLabel.setText(Inter.getLocText("已选择{R1}人", String.valueOf(addedMembers.size()))); addedListModel = new DefaultListModel<>(); addedList = new AddedMemberList(addedListModel); addedList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - addedList.setCellRenderer(new AddingMemberListCellRender()); + addedList.setCellRenderer(new AddedMemberListCellRender()); + addedList.addSelectedChangeListener(addedListChangeListener); resetAddedMembers(); addToAddedMemberList(); UIScrollPane listPane = new UIScrollPane(addedList); @@ -190,12 +208,12 @@ public class UserManagerPane extends BasicPane { private void addToMemberList() { - listModel.clear(); - for (RemoteMember member : members) { - listModel.addElement(member); + addingListModel.clear(); + for (RemoteMember member : addingMembers) { + addingListModel.addElement(member); } - list.revalidate(); - list.repaint(); + addingList.revalidate(); + addingList.repaint(); } private void addToAddedMemberList() { @@ -205,11 +223,12 @@ public class UserManagerPane extends BasicPane { } addedList.revalidate(); addedList.repaint(); + countLabel.setText(Inter.getLocText("已选择{R1}人", String.valueOf(addedMembers.size()))); } private void resetMembers() { - members.clear(); - members.add(RemoteMember.DEFAULT_MEMBER); + addingMembers.clear(); + addingMembers.add(RemoteMember.DEFAULT_MEMBER); } private void resetAddedMembers() { @@ -217,14 +236,19 @@ public class UserManagerPane extends BasicPane { } - private void searchMembers(final String keyword) { + private void searchAddingMembers(final String keyword) { final SwingWorker getMemberWorker = new SwingWorker, Void>() { @Override protected List doInBackground() { - members.clear(); - members.addAll(Utils.getRemoteMember(keyword)); - return members; + addingMembers.clear(); + addingMembers.addAll(Utils.getRemoteMember(keyword)); + try { + Thread.sleep(2000L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return addingMembers; } @Override @@ -235,15 +259,22 @@ public class UserManagerPane extends BasicPane { getMemberWorker.execute(); } - private List getNeedAddMember() { - List res = new ArrayList<>(); - RemoteMember[] members = new RemoteMember[listModel.getSize()]; - listModel.copyInto(members); + + private void sync2AddedMembersFromAdding() { + RemoteMember[] members = new RemoteMember[addingListModel.getSize()]; + // shallow copy + addingListModel.copyInto(members); for (RemoteMember member : members) { if (member.isSelected()) { - res.add(member); + addedMembers.add(member); } } - return res; + } + + private void sync2AddedMembersFormAdded() { + RemoteMember[] members = new RemoteMember[addedListModel.getSize()]; + // shallow copy + addedListModel.copyInto(members); + addedMembers.addAll(Arrays.asList(members)); } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java index 86f0e1c79f..28affa826d 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java @@ -2,12 +2,7 @@ package com.fr.design.remote.ui.list; import com.fr.design.remote.RemoteMember; -import javax.swing.ListModel; -import javax.swing.ListSelectionModel; -import java.awt.Color; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; +import javax.swing.DefaultListModel; import java.awt.event.MouseEvent; import java.util.Vector; @@ -15,46 +10,33 @@ public class AddedMemberList extends MemberList { public AddedMemberList() { super(); - init(); } - public AddedMemberList(ListModel dataModel) { + public AddedMemberList(DefaultListModel dataModel) { super(dataModel); - init(); } public AddedMemberList(RemoteMember[] listData) { super(listData); - init(); } public AddedMemberList(Vector listData) { super(listData); - init(); } - private void init() { - setBackground(new Color(0xF5F5F7)); - - this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - this.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - super.mouseReleased(e); - System.out.println(e.getX() + " " + e.getY()); - displaySelected(); - } - }); - this.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - super.keyReleased(e); - if (e.getKeyCode() == KeyEvent.VK_SPACE) { - displaySelected(); - } - } - }); + @Override + protected boolean shouldDisplaySelected(MouseEvent e) { + return true; + } + + @Override + protected void displaySelected() { + RemoteMember member = getSelectedValue(); + member.setSelected(!member.isSelected()); + ((DefaultListModel) getModel()).removeElement(member); + revalidate(); + repaint(); + fireSelectedChange(); } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java index 8af7713bea..ceb761b72b 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java @@ -26,6 +26,7 @@ public class AddedMemberListCellRender extends JPanel implements ListCellRendere label = new UILabel(); label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); + uiButton = new UIButton(); uiButton.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png")); this.add(label); diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java index 4f245daf2a..ced82c1116 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java @@ -2,12 +2,7 @@ package com.fr.design.remote.ui.list; import com.fr.design.remote.RemoteMember; -import javax.swing.ListModel; -import javax.swing.ListSelectionModel; -import java.awt.Color; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; +import javax.swing.DefaultListModel; import java.awt.event.MouseEvent; import java.util.Vector; @@ -16,47 +11,34 @@ public class AddingMemberList extends MemberList { public AddingMemberList() { super(); - init(); } - public AddingMemberList(ListModel dataModel) { + public AddingMemberList(DefaultListModel dataModel) { super(dataModel); - init(); } public AddingMemberList(RemoteMember[] listData) { super(listData); - init(); + } public AddingMemberList(Vector listData) { super(listData); - init(); } - private void init() { - setBackground(new Color(0xF5F5F7)); - - this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - this.addMouseListener(new MouseAdapter() { - @Override - public void mouseReleased(MouseEvent e) { - super.mouseReleased(e); - System.out.println(e.getX() + " " + e.getY()); - displaySelected(); - } - }); - this.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - super.keyReleased(e); - if (e.getKeyCode() == KeyEvent.VK_SPACE) { - displaySelected(); - } - } - }); + @Override + protected void displaySelected() { + RemoteMember member = getSelectedValue(); + member.setSelected(!member.isSelected()); + revalidate(); + repaint(); + fireSelectedChange(); + } + + @Override + protected boolean shouldDisplaySelected(MouseEvent e) { + return true; } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberList.java b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java index 94bfa5d7e7..5a79a08562 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/MemberList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java @@ -2,25 +2,36 @@ package com.fr.design.remote.ui.list; import com.fr.design.remote.RemoteMember; +import javax.swing.DefaultListModel; import javax.swing.JList; -import javax.swing.ListModel; +import javax.swing.ListSelectionModel; +import java.awt.Color; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.Vector; -public class MemberList extends JList { +public abstract class MemberList extends JList { - public MemberList(ListModel dataModel) { + public MemberList(DefaultListModel dataModel) { super(dataModel); + init(); } public MemberList(RemoteMember[] listData) { super(listData); + init(); } public MemberList(Vector listData) { super(listData); + init(); } public MemberList() { + super(); + init(); } @@ -41,11 +52,34 @@ public class MemberList extends JList { } } - protected void displaySelected() { - RemoteMember member = getSelectedValue(); - member.setSelected(!member.isSelected()); - revalidate(); - repaint(); - fireSelectedChange(); + private void init() { + setBackground(new Color(0xF5F5F7)); + this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + this.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + System.out.println("click location: x:" + e.getX() + " y:" + e.getY()); + if (shouldDisplaySelected(e)) { + displaySelected(); + } + } + }); + this.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + super.keyReleased(e); + if (e.getKeyCode() == KeyEvent.VK_SPACE) { + displaySelected(); + } + } + }); } + + abstract protected void displaySelected(); + + abstract protected boolean shouldDisplaySelected(MouseEvent e); + + } From f2131d1f21a854840a4cbcfd35e3b14ca9616a84 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 18 May 2018 20:21:32 +0800 Subject: [PATCH 05/17] file tree --- .../design/remote/ui/AuthorityEditorPane.java | 8 +- .../remote/ui/AuthorityListControlPane.java | 14 +- .../fr/design/remote/ui/UserManagerPane.java | 6 + .../remote/ui/tree/FileAuthorityTree.java | 4 +- .../remote/ui/tree/FileAuthorityTreeNode.java | 141 ++++++++++++++++++ 5 files changed, 162 insertions(+), 11 deletions(-) create mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java index 73bffbb070..9c83da4d2d 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -1,19 +1,21 @@ package com.fr.design.remote.ui; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.remote.RemoteDesignAuthority; import javax.swing.BorderFactory; import java.awt.BorderLayout; -import java.awt.Label; public class AuthorityEditorPane extends BasicBeanPane { + private UILabel label = new UILabel(); + public AuthorityEditorPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); - this.add(new Label("editor"), BorderLayout.CENTER); + this.add(label, BorderLayout.CENTER); } @Override @@ -23,7 +25,7 @@ public class AuthorityEditorPane extends BasicBeanPane { @Override public void populateBean(RemoteDesignAuthority ob) { - + label.setText(ob.getName()); } @Override diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java index 8fc3e120d8..c37e0e69f1 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -16,6 +16,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.remote.RemoteDesignAuthority; import com.fr.design.remote.RemoteDesignAuthorityCreator; +import com.fr.design.remote.RemoteMember; import com.fr.design.remote.ui.list.AuthorityList; import com.fr.design.remote.ui.list.AuthorityListCellRenderer; import com.fr.design.utils.gui.GUICoreUtils; @@ -476,12 +477,13 @@ public class AuthorityListControlPane extends BasicPane { dialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { - // todo 获取 UserManagerPane 添加的用户 - userManagerPane.title4PopupWindow(); - - RemoteDesignAuthority authority = new RemoteDesignAuthority(); - authority.setName("new User"); - AuthorityListControlPane.this.addAuthority(authority, getModel().getSize()); + // 获取添加的用户到权限编辑面板 + List members = userManagerPane.update(); + for (RemoteMember member : members) { + RemoteDesignAuthority authority = new RemoteDesignAuthority(); + authority.setName(member.getName()); + AuthorityListControlPane.this.addAuthority(authority, getModel().getSize()); + } } @Override diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index dbc02b0cd8..df8f87afce 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -17,6 +17,7 @@ import com.fr.design.remote.ui.list.AddingMemberListCellRender; import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; import com.fr.general.Inter; import com.fr.stable.StringUtils; +import com.fr.third.guava.collect.ImmutableList; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; @@ -277,4 +278,9 @@ public class UserManagerPane extends BasicPane { addedListModel.copyInto(members); addedMembers.addAll(Arrays.asList(members)); } + + + public ImmutableList update() { + return ImmutableList.copyOf(addedMembers); + } } diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java index 91558f639a..7389049cb1 100644 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java @@ -1,6 +1,6 @@ package com.fr.design.remote.ui.tree; -import javax.swing.JTree; +import com.fr.design.gui.itree.filetree.TemplateFileTree; -public class FileAuthorityTree extends JTree { +public class FileAuthorityTree extends TemplateFileTree { } diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java new file mode 100644 index 0000000000..aed486730f --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java @@ -0,0 +1,141 @@ +package com.fr.design.remote.ui.tree; + +import javax.swing.tree.DefaultMutableTreeNode; + +public class FileAuthorityTreeNode extends DefaultMutableTreeNode { + + public enum Status { + SELECTED, + UNSELECTED, + INDETERMINATE + } + + + private Status status; + + + public FileAuthorityTreeNode() { + this(null); + } + + public FileAuthorityTreeNode(Object userObject) { + this(userObject, true, Status.UNSELECTED); + } + + public FileAuthorityTreeNode(Object userObject, boolean allowsChildren, Status status) { + super(userObject, allowsChildren); + this.status = status; + } + + public Status getStatus() { + return status; + } + + public boolean isSelected() { + return status == Status.SELECTED; + } + + public boolean isUnselected() { + return status == Status.UNSELECTED; + } + + public boolean isIndeterminate() { + return status == Status.INDETERMINATE; + } + + + public void setSelected(boolean selected) { + setStatus(selected ? Status.SELECTED : Status.UNSELECTED); + } + + public void setStatus(Status status) { + this.status = status; + switch (status) { + case SELECTED: + // 向下 + // 如果选中,则所有的子结点都要选中 + if (children != null) { + for (Object obj : children) { + FileAuthorityTreeNode node = (FileAuthorityTreeNode) obj; + if (!node.isSelected()) { + node.setSelected(true); + } + } + } + // 向上 + // 检查其父节点 + if (parent != null) { + FileAuthorityTreeNode pNode = (FileAuthorityTreeNode) parent; + int index = 0; + for (; index < pNode.children.size(); ++index) { + FileAuthorityTreeNode pChildNode = (FileAuthorityTreeNode) pNode.children.get(index); + if (!pChildNode.isSelected()) { + break; + } + } + // 如果父结点下的子结点都被选中了,那么选中父节点 + if (index == pNode.children.size()) { + if (!pNode.isSelected()) { + pNode.setSelected(true); + } + } + // 如果父结点下的子结点有部分没被选中,那么标记父结点选中状况为未知 + else { + if (!pNode.isIndeterminate()) { + pNode.setStatus(Status.INDETERMINATE); + } + } + } + break; + case UNSELECTED: + // 向下 + // 子结点都要取消选中 + if (children != null) { + for (Object aChildren : children) { + FileAuthorityTreeNode node = (FileAuthorityTreeNode) aChildren; + if (!node.isUnselected()) { + node.setSelected(false); + } + } + } + // 向上 + // 查看父节点的选中情况 + + if (parent != null) { + FileAuthorityTreeNode pNode = (FileAuthorityTreeNode) parent; + int index = 0; + for (; index < pNode.children.size(); ++index) { + FileAuthorityTreeNode pChildNode = (FileAuthorityTreeNode) pNode.children.get(index); + if (!pChildNode.isUnselected()) { + break; + } + } + // 如果父结点下的子结点都是未被选中的,那么取消选中父节点 + if (index == pNode.children.size()) { + if (!pNode.isUnselected()) { + pNode.setSelected(false); + } + } + // 如果父结点下的子结点有部分不是未被选中的,那么标记父结点选中状况为未知 + else { + if (!pNode.isIndeterminate()) { + pNode.setStatus(Status.INDETERMINATE); + } + } + } + break; + case INDETERMINATE: + // todo 标记为未知 + + + + break; + + + default: + break; + } + } +} + + From 0ebd6831eb0ebcb1a1734b8700c843b63cf6e8e3 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 18 May 2018 20:21:32 +0800 Subject: [PATCH 06/17] file tree --- .../design/remote/ui/AuthorityEditorPane.java | 15 +++- .../tree/FileAuthorityTreeCellRenderer.java | 83 +++++++++++++++++++ .../ui/tree/FileAuthorityTreeLabel.java | 69 +++++++++++++++ .../remote/ui/tree/FileAuthorityTreeNode.java | 23 +++-- ...ileAuthorityTreeNodeSelectionListener.java | 27 ++++++ 5 files changed, 208 insertions(+), 9 deletions(-) create mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java create mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java create mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java index 9c83da4d2d..b61f9250ce 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -1,9 +1,13 @@ package com.fr.design.remote.ui; +import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.remote.RemoteDesignAuthority; +import com.fr.design.remote.ui.tree.FileAuthorityTree; +import com.fr.file.filetree.IOFileNodeFilter; import javax.swing.BorderFactory; import java.awt.BorderLayout; @@ -12,10 +16,17 @@ public class AuthorityEditorPane extends BasicBeanPane { private UILabel label = new UILabel(); + private FileAuthorityTree tree = new FileAuthorityTree(); + + public AuthorityEditorPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); - this.add(label, BorderLayout.CENTER); + this.add(label, BorderLayout.NORTH); + IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"}); + tree.setFileNodeFilter(filter); + this.add(new UIScrollPane(tree), BorderLayout.CENTER); + tree.refreshEnv(FRContext.getCurrentEnv()); } @Override @@ -26,10 +37,12 @@ public class AuthorityEditorPane extends BasicBeanPane { @Override public void populateBean(RemoteDesignAuthority ob) { label.setText(ob.getName()); + // todo 选中树的结点 } @Override public RemoteDesignAuthority updateBean() { + // todo 更新权限信息 return new RemoteDesignAuthority(); } } diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java new file mode 100644 index 0000000000..84ed6c723d --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java @@ -0,0 +1,83 @@ +package com.fr.design.remote.ui.tree; + + +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; +import javax.swing.tree.TreeCellRenderer; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; + +public class FileAuthorityTreeCellRenderer extends JPanel implements TreeCellRenderer { + + + protected JCheckBox check; + protected FileAuthorityTreeLabel label; + + public FileAuthorityTreeCellRenderer() { + setLayout(null); + add(check = new JCheckBox()); + add(label = new FileAuthorityTreeLabel()); + check.setBackground(UIManager.getColor("Tree.textBackground")); + label.setForeground(UIManager.getColor("Tree.textForeground")); + } + + /** + * 返回的是一个JPanel对象,该对象中包含一个JCheckBox对象 + * 和一个JLabel对象。并且根据每个结点是否被选中来决定JCheckBox + * 是否被选中。 + */ + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean selected, boolean expanded, boolean leaf, int row, + boolean hasFocus) { + String stringValue = tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus); + setEnabled(tree.isEnabled()); + check.setSelected(((FileAuthorityTreeNode) value).isSelected()); + label.setFont(tree.getFont()); + label.setText(stringValue); + label.setSelected(selected); + label.setFocus(hasFocus); + if (leaf) + label.setIcon(UIManager.getIcon("Tree.leafIcon")); + else if (expanded) + label.setIcon(UIManager.getIcon("Tree.openIcon")); + else + label.setIcon(UIManager.getIcon("Tree.closedIcon")); + + return this; + } + + @Override + public Dimension getPreferredSize() { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + return new Dimension(dCheck.width + dLabel.width, dCheck.height < dLabel.height ? dLabel.height : dCheck.height); + } + + @Override + public void doLayout() { + Dimension dCheck = check.getPreferredSize(); + Dimension dLabel = label.getPreferredSize(); + int yCheck = 0; + int yLabel = 0; + if (dCheck.height < dLabel.height) + yCheck = (dLabel.height - dCheck.height) / 2; + else + yLabel = (dCheck.height - dLabel.height) / 2; + check.setLocation(0, yCheck); + check.setBounds(0, yCheck, dCheck.width, dCheck.height); + label.setLocation(dCheck.width, yLabel); + label.setBounds(dCheck.width, yLabel, dLabel.width, dLabel.height); + } + + @Override + public void setBackground(Color color) { + if (color instanceof ColorUIResource) + color = null; + super.setBackground(color); + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java new file mode 100644 index 0000000000..de4e8cf2dc --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java @@ -0,0 +1,69 @@ +package com.fr.design.remote.ui.tree; + + +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.UIManager; +import javax.swing.plaf.ColorUIResource; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; + +public class FileAuthorityTreeLabel extends JLabel { + private boolean isSelected; + private boolean hasFocus; + + public FileAuthorityTreeLabel() { + } + + @Override + public void setBackground(Color color) { + if (color instanceof ColorUIResource) { + color = null; + } + super.setBackground(color); + } + + @Override + public void paint(Graphics g) { + String str; + if ((str = getText()) != null) { + if (0 < str.length()) { + if (isSelected) { + g.setColor(UIManager.getColor("Tree.selectionBackground")); + } else { + g.setColor(UIManager.getColor("Tree.textBackground")); + } + Dimension d = getPreferredSize(); + int imageOffset = 0; + Icon currentIcon = getIcon(); + if (currentIcon != null) { + imageOffset = currentIcon.getIconWidth() + Math.max(0, getIconTextGap() - 1); + } + g.fillRect(imageOffset, 0, d.width - 1 - imageOffset, d.height); + if (hasFocus) { + g.setColor(UIManager.getColor("Tree.selectionBorderColor")); + g.drawRect(imageOffset, 0, d.width - 1 - imageOffset, d.height - 1); + } + } + } + super.paint(g); + } + + @Override + public Dimension getPreferredSize() { + Dimension retDimension = super.getPreferredSize(); + if (retDimension != null) { + retDimension = new Dimension(retDimension.width + 3, retDimension.height); + } + return retDimension; + } + + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + } + + public void setFocus(boolean hasFocus) { + this.hasFocus = hasFocus; + } +} diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java index aed486730f..ddd8ed22b8 100644 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNode.java @@ -48,10 +48,12 @@ public class FileAuthorityTreeNode extends DefaultMutableTreeNode { setStatus(selected ? Status.SELECTED : Status.UNSELECTED); } + public void setStatus(Status status) { this.status = status; switch (status) { case SELECTED: + // 标记为选中 // 向下 // 如果选中,则所有的子结点都要选中 if (children != null) { @@ -88,6 +90,7 @@ public class FileAuthorityTreeNode extends DefaultMutableTreeNode { } break; case UNSELECTED: + //标记为未被选中 // 向下 // 子结点都要取消选中 if (children != null) { @@ -125,17 +128,21 @@ public class FileAuthorityTreeNode extends DefaultMutableTreeNode { } break; case INDETERMINATE: - // todo 标记为未知 - - + // 标记为未知 + // 向下 + // 不做改动 + // 向上 + // 需要将父结点标记为未知 + if (parent != null) { + FileAuthorityTreeNode pNode = (FileAuthorityTreeNode) parent; + if (!pNode.isIndeterminate()) { + pNode.setStatus(Status.INDETERMINATE); + } + } break; - - default: break; } } -} - - +} \ No newline at end of file diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java new file mode 100644 index 0000000000..e3b9a89f46 --- /dev/null +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java @@ -0,0 +1,27 @@ +package com.fr.design.remote.ui.tree; + + +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class FileAuthorityTreeNodeSelectionListener extends MouseAdapter { + @Override + public void mouseClicked(MouseEvent event) { + JTree tree = (JTree) event.getSource(); + int x = event.getX(); + int y = event.getY(); + int row = tree.getRowForLocation(x, y); + TreePath path = tree.getPathForRow(row); + if (path != null) { + FileAuthorityTreeNode node = (FileAuthorityTreeNode) path.getLastPathComponent(); + if (node != null) { + boolean isSelected = !node.isSelected(); + node.setSelected(isSelected); + ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); + } + } + } +} From 89e0532df10650cc1c8ebcde6ae05d449082b06a Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Sat, 19 May 2018 18:26:26 +0800 Subject: [PATCH 07/17] todo update tree --- .../com/fr/design/gui/itree/filetree/EnvFileTree.java | 4 ++-- .../action/RemoteDesignAuthorityManagerAction.java | 4 ++-- .../com/fr/design/remote/ui/AuthorityEditorPane.java | 3 +++ .../com/fr/design/remote/ui/AuthorityManagerPane.java | 2 +- .../fr/design/remote/ui/tree/FileAuthorityTree.java | 10 ++++++++++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index 9bbd53616b..eecd623004 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -48,7 +48,7 @@ public class EnvFileTree extends RefreshableJTree { this.setFileNodeFilter(filter); this.setSubPathes(subPathes); - this.init(); + this.initi(); } private void setTreeRootPath(String path) { @@ -63,7 +63,7 @@ public class EnvFileTree extends RefreshableJTree { this.filter = filter; } - protected void init() { + protected void initi() { this.putClientProperty("JTree.lineStyle", "Angled"); this.setCellRenderer(fileTreeCellRenderer); diff --git a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java index a68e840bb1..2326bcbf59 100644 --- a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java @@ -24,7 +24,7 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { - AuthorityManagerPane managerPane = new AuthorityManagerPane(); + final AuthorityManagerPane managerPane = new AuthorityManagerPane(); BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame()); @@ -34,7 +34,7 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { dialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { - //todo save contents into database by hibernate + managerPane.update(); } @Override diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java index b61f9250ce..f74cc504e6 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -11,6 +11,7 @@ import com.fr.file.filetree.IOFileNodeFilter; import javax.swing.BorderFactory; import java.awt.BorderLayout; +import java.util.Arrays; public class AuthorityEditorPane extends BasicBeanPane { @@ -24,6 +25,7 @@ public class AuthorityEditorPane extends BasicBeanPane { this.setBorder(BorderFactory.createEmptyBorder()); this.add(label, BorderLayout.NORTH); IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"}); + tree.setDigIn(true); tree.setFileNodeFilter(filter); this.add(new UIScrollPane(tree), BorderLayout.CENTER); tree.refreshEnv(FRContext.getCurrentEnv()); @@ -43,6 +45,7 @@ public class AuthorityEditorPane extends BasicBeanPane { @Override public RemoteDesignAuthority updateBean() { // todo 更新权限信息 + System.out.println(Arrays.toString(tree.getCheckBoxTreeSelectionModel().getSelectionPaths())); return new RemoteDesignAuthority(); } } diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java index 877d7fe157..46943677a7 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java @@ -30,7 +30,7 @@ public class AuthorityManagerPane extends BasicPane { list.populate(authorities); } - private RemoteDesignAuthority[] update() { + public RemoteDesignAuthority[] update() { return list.update(); } diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java index 7389049cb1..5d3203eeb5 100644 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java @@ -2,5 +2,15 @@ package com.fr.design.remote.ui.tree; import com.fr.design.gui.itree.filetree.TemplateFileTree; +import javax.swing.tree.TreePath; + public class FileAuthorityTree extends TemplateFileTree { + + @Override + public boolean isCheckBoxVisible(TreePath path) { +// return super.isCheckBoxVisible(path); + return true; + } + + } From 540d666a13ff655a9274b528ed6d00168f03f3cc Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Sat, 19 May 2018 18:26:26 +0800 Subject: [PATCH 08/17] todo update tree --- .../remote/ui/tree/FileAuthorityTree.java | 1 - .../tree/FileAuthorityTreeCellRenderer.java | 83 ------------------- .../ui/tree/FileAuthorityTreeLabel.java | 69 --------------- ...ileAuthorityTreeNodeSelectionListener.java | 27 ------ 4 files changed, 180 deletions(-) delete mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java delete mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java delete mode 100644 designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java index 5d3203eeb5..a1503de54c 100644 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java @@ -8,7 +8,6 @@ public class FileAuthorityTree extends TemplateFileTree { @Override public boolean isCheckBoxVisible(TreePath path) { -// return super.isCheckBoxVisible(path); return true; } diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java deleted file mode 100644 index 84ed6c723d..0000000000 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeCellRenderer.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.fr.design.remote.ui.tree; - - -import javax.swing.JCheckBox; -import javax.swing.JPanel; -import javax.swing.JTree; -import javax.swing.UIManager; -import javax.swing.plaf.ColorUIResource; -import javax.swing.tree.TreeCellRenderer; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; - -public class FileAuthorityTreeCellRenderer extends JPanel implements TreeCellRenderer { - - - protected JCheckBox check; - protected FileAuthorityTreeLabel label; - - public FileAuthorityTreeCellRenderer() { - setLayout(null); - add(check = new JCheckBox()); - add(label = new FileAuthorityTreeLabel()); - check.setBackground(UIManager.getColor("Tree.textBackground")); - label.setForeground(UIManager.getColor("Tree.textForeground")); - } - - /** - * 返回的是一个JPanel对象,该对象中包含一个JCheckBox对象 - * 和一个JLabel对象。并且根据每个结点是否被选中来决定JCheckBox - * 是否被选中。 - */ - @Override - public Component getTreeCellRendererComponent(JTree tree, Object value, - boolean selected, boolean expanded, boolean leaf, int row, - boolean hasFocus) { - String stringValue = tree.convertValueToText(value, selected, expanded, leaf, row, hasFocus); - setEnabled(tree.isEnabled()); - check.setSelected(((FileAuthorityTreeNode) value).isSelected()); - label.setFont(tree.getFont()); - label.setText(stringValue); - label.setSelected(selected); - label.setFocus(hasFocus); - if (leaf) - label.setIcon(UIManager.getIcon("Tree.leafIcon")); - else if (expanded) - label.setIcon(UIManager.getIcon("Tree.openIcon")); - else - label.setIcon(UIManager.getIcon("Tree.closedIcon")); - - return this; - } - - @Override - public Dimension getPreferredSize() { - Dimension dCheck = check.getPreferredSize(); - Dimension dLabel = label.getPreferredSize(); - return new Dimension(dCheck.width + dLabel.width, dCheck.height < dLabel.height ? dLabel.height : dCheck.height); - } - - @Override - public void doLayout() { - Dimension dCheck = check.getPreferredSize(); - Dimension dLabel = label.getPreferredSize(); - int yCheck = 0; - int yLabel = 0; - if (dCheck.height < dLabel.height) - yCheck = (dLabel.height - dCheck.height) / 2; - else - yLabel = (dCheck.height - dLabel.height) / 2; - check.setLocation(0, yCheck); - check.setBounds(0, yCheck, dCheck.width, dCheck.height); - label.setLocation(dCheck.width, yLabel); - label.setBounds(dCheck.width, yLabel, dLabel.width, dLabel.height); - } - - @Override - public void setBackground(Color color) { - if (color instanceof ColorUIResource) - color = null; - super.setBackground(color); - } -} diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java deleted file mode 100644 index de4e8cf2dc..0000000000 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeLabel.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.fr.design.remote.ui.tree; - - -import javax.swing.Icon; -import javax.swing.JLabel; -import javax.swing.UIManager; -import javax.swing.plaf.ColorUIResource; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; - -public class FileAuthorityTreeLabel extends JLabel { - private boolean isSelected; - private boolean hasFocus; - - public FileAuthorityTreeLabel() { - } - - @Override - public void setBackground(Color color) { - if (color instanceof ColorUIResource) { - color = null; - } - super.setBackground(color); - } - - @Override - public void paint(Graphics g) { - String str; - if ((str = getText()) != null) { - if (0 < str.length()) { - if (isSelected) { - g.setColor(UIManager.getColor("Tree.selectionBackground")); - } else { - g.setColor(UIManager.getColor("Tree.textBackground")); - } - Dimension d = getPreferredSize(); - int imageOffset = 0; - Icon currentIcon = getIcon(); - if (currentIcon != null) { - imageOffset = currentIcon.getIconWidth() + Math.max(0, getIconTextGap() - 1); - } - g.fillRect(imageOffset, 0, d.width - 1 - imageOffset, d.height); - if (hasFocus) { - g.setColor(UIManager.getColor("Tree.selectionBorderColor")); - g.drawRect(imageOffset, 0, d.width - 1 - imageOffset, d.height - 1); - } - } - } - super.paint(g); - } - - @Override - public Dimension getPreferredSize() { - Dimension retDimension = super.getPreferredSize(); - if (retDimension != null) { - retDimension = new Dimension(retDimension.width + 3, retDimension.height); - } - return retDimension; - } - - public void setSelected(boolean isSelected) { - this.isSelected = isSelected; - } - - public void setFocus(boolean hasFocus) { - this.hasFocus = hasFocus; - } -} diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java deleted file mode 100644 index e3b9a89f46..0000000000 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTreeNodeSelectionListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.fr.design.remote.ui.tree; - - -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -public class FileAuthorityTreeNodeSelectionListener extends MouseAdapter { - @Override - public void mouseClicked(MouseEvent event) { - JTree tree = (JTree) event.getSource(); - int x = event.getX(); - int y = event.getY(); - int row = tree.getRowForLocation(x, y); - TreePath path = tree.getPathForRow(row); - if (path != null) { - FileAuthorityTreeNode node = (FileAuthorityTreeNode) path.getLastPathComponent(); - if (node != null) { - boolean isSelected = !node.isSelected(); - node.setSelected(isSelected); - ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); - } - } - } -} From 25acdee050fc35448c2906d0bd99ed140b8c904f Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Sun, 20 May 2018 21:04:07 +0800 Subject: [PATCH 09/17] remote design use http get method --- designer-base/src/com/fr/env/RemoteEnv.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index dbcbd79b55..7fdc3c377e 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -400,6 +400,7 @@ public class RemoteEnv extends AbstractEnv { } HttpClient client = createHttpMethod(para, true); + client.asGet(); String res = stream2String(execute4InputStream(client)); if (res == null) { From 8fa268e8a522463a18e8b6a3216c92a1bd5ce1f6 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Sun, 20 May 2018 21:04:07 +0800 Subject: [PATCH 10/17] remote design use http get method --- designer-base/src/com/fr/env/RemoteEnv.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 7fdc3c377e..6163a75b7d 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -228,7 +228,9 @@ public class RemoteEnv extends AbstractEnv { if (!isSignIn) { methodPath = methodPath + "?id=" + createUserID(); } - return new HttpClient(methodPath, para); + HttpClient client = new HttpClient(methodPath,para); + client.asGet(); + return client; } /** From 9b99bfb7cc025ddd89b202507da820a5a95a87ef Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 21 May 2018 02:05:42 +0800 Subject: [PATCH 11/17] remote design pilot --- .../CheckBoxTreeCellRenderer.java | 26 ++++------ .../mainframe/toolbar/ToolBarMenuDock.java | 48 ++++--------------- .../remote/ui/AuthorityListControlPane.java | 2 +- .../fr/design/remote/ui/UserManagerPane.java | 20 ++------ .../remote/ui/list/AddedMemberList.java | 8 ++-- .../ui/list/AuthorityListCellRenderer.java | 10 +--- 6 files changed, 32 insertions(+), 82 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java b/designer-base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java index 2c7b899ddb..9684d39478 100644 --- a/designer-base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java +++ b/designer-base/src/com/fr/design/gui/itree/checkboxtree/CheckBoxTreeCellRenderer.java @@ -6,24 +6,18 @@ package com.fr.design.gui.itree.checkboxtree; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.event.MouseEvent; -import java.io.Serializable; - -import javax.swing.BorderFactory; -import javax.swing.JComponent; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; -import javax.swing.JTree; +import com.fr.design.layout.FRGUIPaneFactory; + +import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreePath; - -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.layout.FRGUIPaneFactory; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.io.Serializable; /** @@ -52,7 +46,7 @@ public class CheckBoxTreeCellRenderer extends NullPanel implements TreeCellRende public CheckBoxTreeCellRenderer() { this(null); } - + public CheckBoxTreeCellRenderer(TreeCellRenderer renderer) { if (noFocusBorder == null) { noFocusBorder = new EmptyBorder(1, 1, 1, 1); @@ -84,8 +78,7 @@ public class CheckBoxTreeCellRenderer extends NullPanel implements TreeCellRende if (selectionModel.isPathSelected(path, selectionModel.isDigIn())) { _checkBox.setState(TristateCheckBox.SELECTED); _checkBox.setSelected(true); - } - else { + } else { _checkBox.setState(selectionModel.isDigIn() && selectionModel.isPartiallySelected(path) ? null : TristateCheckBox.NOT_SELECTED); _checkBox.setSelected(false); } @@ -102,6 +95,7 @@ public class CheckBoxTreeCellRenderer extends NullPanel implements TreeCellRende Border border = treeCellRendererComponent.getBorder(); setBorder(border); treeCellRendererComponent.setBorder(BorderFactory.createEmptyBorder()); + //todo 可能会发生数组越界,需要处理一下 if (getComponentCount() == 2) { remove(1); } diff --git a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 95d8c87f5c..5b43eb21ca 100644 --- a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -8,31 +8,14 @@ import com.fr.base.FRContext; import com.fr.design.DesignState; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; -import com.fr.design.actions.community.BBSAction; -import com.fr.design.actions.community.BugAction; -import com.fr.design.actions.community.NeedAction; -import com.fr.design.actions.community.QuestionAction; -import com.fr.design.actions.community.SignAction; -import com.fr.design.actions.community.UpAction; -import com.fr.design.actions.community.VideoAction; -import com.fr.design.actions.file.CloseCurrentTemplateAction; -import com.fr.design.actions.file.ExitDesignerAction; -import com.fr.design.actions.file.OpenRecentReportMenuDef; -import com.fr.design.actions.file.OpenTemplateAction; -import com.fr.design.actions.file.PreferenceAction; -import com.fr.design.actions.file.SwitchExistEnv; +import com.fr.design.actions.community.*; +import com.fr.design.actions.file.*; import com.fr.design.actions.help.AboutAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; -import com.fr.design.actions.server.ConnectionListAction; -import com.fr.design.actions.server.FunctionManagerAction; -import com.fr.design.actions.server.GlobalParameterAction; -import com.fr.design.actions.server.GlobalTableDataAction; -import com.fr.design.actions.server.PlatformManagerAction; -import com.fr.design.actions.server.PluginManagerAction; -import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction; +import com.fr.design.actions.server.*; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.TableDataPaneProcessor; @@ -47,6 +30,7 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; +import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction; import com.fr.design.utils.ThemeUtils; import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; @@ -61,23 +45,10 @@ import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import javax.swing.Icon; -import javax.swing.JComponent; -import javax.swing.JMenuBar; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.UIManager; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.util.ArrayList; -import java.util.Arrays; +import javax.swing.*; +import java.awt.*; +import java.util.*; import java.util.List; -import java.util.Locale; -import java.util.Set; /** * @author richer @@ -443,9 +414,8 @@ public abstract class ToolBarMenuDock { return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction(); } - protected boolean shouldShowRemotePermission() { - // todo 依据是否是远程设计 并且当前登录的用户是否是管理员 进行判断 是否展示远程设计权限管理 - return true; + private boolean shouldShowRemotePermission() { + return FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot(); } protected boolean shouldShowPlugin() { diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java index c37e0e69f1..3a117ecdef 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -49,7 +49,7 @@ public class AuthorityListControlPane extends BasicPane { private AuthorityList authorityList; - private static final int SHORT_WIDTH = 30; + private static final int SHORT_WIDTH = 90; private ListEditorControlPane editorCtrl; diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index df8f87afce..41e1cfe07a 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -10,25 +10,14 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.remote.RemoteMember; import com.fr.design.remote.Utils; -import com.fr.design.remote.ui.list.AddedMemberList; -import com.fr.design.remote.ui.list.AddedMemberListCellRender; -import com.fr.design.remote.ui.list.AddingMemberList; -import com.fr.design.remote.ui.list.AddingMemberListCellRender; -import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; +import com.fr.design.remote.ui.list.*; import com.fr.general.Inter; import com.fr.stable.StringUtils; import com.fr.third.guava.collect.ImmutableList; -import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; -import javax.swing.JPanel; -import javax.swing.ListSelectionModel; -import javax.swing.SwingWorker; +import javax.swing.*; import javax.swing.border.EmptyBorder; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -114,7 +103,8 @@ public class UserManagerPane extends BasicPane { addingList.repaint(); resetAddedMembers(); sync2AddedMembersFormAdded(); - // 不需要重复更新右侧列表显示 + // 不需要重复更新右侧列表显示 但是更新一下计数显示 + countLabel.setText(Inter.getLocText("已选择{R1}人", String.valueOf(addedMembers.size()))); } }; diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java index 28affa826d..fd02aa75b4 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java @@ -2,7 +2,7 @@ package com.fr.design.remote.ui.list; import com.fr.design.remote.RemoteMember; -import javax.swing.DefaultListModel; +import javax.swing.*; import java.awt.event.MouseEvent; import java.util.Vector; @@ -33,8 +33,10 @@ public class AddedMemberList extends MemberList { @Override protected void displaySelected() { RemoteMember member = getSelectedValue(); - member.setSelected(!member.isSelected()); - ((DefaultListModel) getModel()).removeElement(member); + if (member != null) { + member.setSelected(!member.isSelected()); + ((DefaultListModel) getModel()).removeElement(member); + } revalidate(); repaint(); fireSelectedChange(); diff --git a/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java b/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java index 46809ba26a..2d3c407f13 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java @@ -4,17 +4,11 @@ import com.fr.base.BaseUtils; import com.fr.design.remote.RemoteDesignAuthority; import sun.swing.DefaultLookup; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.ListCellRenderer; +import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; -import java.awt.Color; -import java.awt.Component; +import java.awt.*; -/* - * NameableListCellRenderer - */ public class AuthorityListCellRenderer extends JLabel implements ListCellRenderer { From 936a76ce290b0b4d52b684e2f1c80a7e777f3704 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Mon, 21 May 2018 17:32:41 +0800 Subject: [PATCH 12/17] REPORT-6700 update --- .../mainframe/toolbar/ToolBarMenuDock.java | 43 ++++++++++++++--- .../com/fr/design/remote/RemoteMember.java | 42 ++++++++++++++--- .../src/com/fr/design/remote/Utils.java | 47 +++++++------------ .../remote/ui/AuthorityListControlPane.java | 2 +- .../ui/list/AddedMemberListCellRender.java | 2 +- .../ui/list/AddingMemberListCellRender.java | 2 +- designer-base/src/com/fr/env/RemoteEnv.java | 1 - 7 files changed, 92 insertions(+), 47 deletions(-) diff --git a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 5b43eb21ca..21f7c3386a 100644 --- a/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -8,14 +8,30 @@ import com.fr.base.FRContext; import com.fr.design.DesignState; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; -import com.fr.design.actions.community.*; -import com.fr.design.actions.file.*; +import com.fr.design.actions.community.BBSAction; +import com.fr.design.actions.community.BugAction; +import com.fr.design.actions.community.NeedAction; +import com.fr.design.actions.community.QuestionAction; +import com.fr.design.actions.community.SignAction; +import com.fr.design.actions.community.UpAction; +import com.fr.design.actions.community.VideoAction; +import com.fr.design.actions.file.CloseCurrentTemplateAction; +import com.fr.design.actions.file.ExitDesignerAction; +import com.fr.design.actions.file.OpenRecentReportMenuDef; +import com.fr.design.actions.file.OpenTemplateAction; +import com.fr.design.actions.file.PreferenceAction; +import com.fr.design.actions.file.SwitchExistEnv; import com.fr.design.actions.help.AboutAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.alphafine.AlphaFineAction; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; -import com.fr.design.actions.server.*; +import com.fr.design.actions.server.ConnectionListAction; +import com.fr.design.actions.server.FunctionManagerAction; +import com.fr.design.actions.server.GlobalParameterAction; +import com.fr.design.actions.server.GlobalTableDataAction; +import com.fr.design.actions.server.PlatformManagerAction; +import com.fr.design.actions.server.PluginManagerAction; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.TableDataPaneProcessor; @@ -45,10 +61,23 @@ import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; -import java.util.*; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JMenuBar; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Locale; +import java.util.Set; /** * @author richer @@ -415,7 +444,7 @@ public abstract class ToolBarMenuDock { } private boolean shouldShowRemotePermission() { - return FRContext.getCurrentEnv() != null && FRContext.getCurrentEnv().isRoot(); + return FRContext.getCurrentEnv() != null && !FRContext.getCurrentEnv().isLocalEnv() && FRContext.getCurrentEnv().isRoot(); } protected boolean shouldShowPlugin() { diff --git a/designer-base/src/com/fr/design/remote/RemoteMember.java b/designer-base/src/com/fr/design/remote/RemoteMember.java index 019159b30a..c3da597e3e 100644 --- a/designer-base/src/com/fr/design/remote/RemoteMember.java +++ b/designer-base/src/com/fr/design/remote/RemoteMember.java @@ -5,20 +5,48 @@ public class RemoteMember { public static final RemoteMember DEFAULT_MEMBER = new RemoteMember("查询中..."); - private String name; + private String username; + private String realName; + private String userId; private boolean selected; - public RemoteMember(String name) { - this.name = name; + public RemoteMember(String username) { + this.username = username; } - public String getName() { - return name; + public RemoteMember realName(String realName) { + this.realName = realName; + return this; } - public void setName(String name) { - this.name = name; + public RemoteMember userId(String userId) { + this.userId = userId; + return this; + } + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; } diff --git a/designer-base/src/com/fr/design/remote/Utils.java b/designer-base/src/com/fr/design/remote/Utils.java index 1e2e12ebaf..ec0a7ddeed 100644 --- a/designer-base/src/com/fr/design/remote/Utils.java +++ b/designer-base/src/com/fr/design/remote/Utils.java @@ -1,49 +1,38 @@ package com.fr.design.remote; -import com.fr.stable.StringUtils; +import com.fr.base.FRContext; +import com.fr.decision.webservice.bean.user.UserAdditionBean; +import com.fr.decision.webservice.v10.user.UserService; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Random; +import java.util.Map; public class Utils { - private static final String SOURCES = - "._-~`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; private Utils() { - } public static Collection getRemoteMember(String keyword) { - // todo 使用决策平台api获取决策平台用户 - List res = new ArrayList<>(); - for (int i = 0; i < 30; i++) { - RemoteMember remoteMember = new RemoteMember(generate()); - if (StringUtils.isEmpty(keyword)) { - res.add(remoteMember); - continue; - } - if (remoteMember.getName().contains(keyword)) { - res.add(remoteMember); - } + + List userBeans = new ArrayList<>(); + try { + Map result = UserService.getInstance().getAllUsers(FRContext.getCurrentEnv().getUser(), 1, 10, keyword, "", true); + userBeans = (List) result.get("items"); + } catch (Exception e) { + e.printStackTrace(); } - return res; - } + List res = new ArrayList<>(); - /** - * Generate a random string. - * - * @return String string - */ - private static String generate() { - Random random = new Random(); - char[] text = new char[6]; - for (int i = 0; i < 6; i++) { - text[i] = Utils.SOURCES.charAt(random.nextInt(Utils.SOURCES.length())); + for (UserAdditionBean userBean : userBeans) { + res.add(new RemoteMember(userBean.getUsername()) + .realName(userBean.getRealName()) + .userId(userBean.getId()) + ); } - return new String(text); + return res; } } diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java index 3a117ecdef..b6094e427d 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -481,7 +481,7 @@ public class AuthorityListControlPane extends BasicPane { List members = userManagerPane.update(); for (RemoteMember member : members) { RemoteDesignAuthority authority = new RemoteDesignAuthority(); - authority.setName(member.getName()); + authority.setName(member.getUsername()); AuthorityListControlPane.this.addAuthority(authority, getModel().getSize()); } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java index ceb761b72b..7c34fad5e7 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java @@ -35,7 +35,7 @@ public class AddedMemberListCellRender extends JPanel implements ListCellRendere @Override public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { - this.setLabelText(member.getName()); + this.setLabelText(member.getUsername()); return this; } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java index b953a42888..24a0a133b2 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java @@ -36,7 +36,7 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender @Override public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { - this.setLabelText(member.getName()); + this.setLabelText(member.getUsername()); check.setSelected(member.isSelected()); return this; } diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 6163a75b7d..bb0b592ded 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -402,7 +402,6 @@ public class RemoteEnv extends AbstractEnv { } HttpClient client = createHttpMethod(para, true); - client.asGet(); String res = stream2String(execute4InputStream(client)); if (res == null) { From bab0b9db35974c96f9fa08afa93d5addeeb4d84e Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Tue, 22 May 2018 22:52:10 +0800 Subject: [PATCH 13/17] =?UTF-8?q?REPORT-6700=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/EnvFileTree.java | 4 +- .../design/remote/RemoteDesignAuthority.java | 14 ----- .../remote/RemoteDesignAuthorityCreator.java | 5 +- .../com/fr/design/remote/RemoteMember.java | 9 +++ .../src/com/fr/design/remote/Utils.java | 8 ++- .../RemoteDesignAuthorityManagerAction.java | 12 +++- .../design/remote/ui/AuthorityEditorPane.java | 55 +++++++++++++++--- .../remote/ui/AuthorityListControlPane.java | 50 ++++++++-------- .../remote/ui/AuthorityManagerPane.java | 12 ++-- .../fr/design/remote/ui/UserManagerPane.java | 22 ++++--- .../design/remote/ui/list/AuthorityList.java | 10 ++-- .../ui/list/AuthorityListCellRenderer.java | 15 +++-- .../remote/ui/tree/FileAuthorityTree.java | 57 +++++++++++++++++++ .../fr/env/DesignAuthorityConfigurable.java | 10 ++++ designer-base/src/com/fr/env/RemoteEnv.java | 57 +++++++++++++++++-- 15 files changed, 254 insertions(+), 86 deletions(-) delete mode 100644 designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java create mode 100644 designer-base/src/com/fr/env/DesignAuthorityConfigurable.java diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index eecd623004..460a05f82c 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -284,7 +284,7 @@ public class EnvFileTree extends RefreshableJTree { /** * currentTreeNode下面如果是PENDING的节点,加载之... */ - private void loadPendingChildTreeNode(ExpandMutableTreeNode currentTreeNode) { + protected void loadPendingChildTreeNode(ExpandMutableTreeNode currentTreeNode) { if (currentTreeNode.isLeaf()) { return; } @@ -342,7 +342,7 @@ public class EnvFileTree extends RefreshableJTree { /* * 是否是父子关系的文件. */ - private static boolean isParentFile(String parentFilePath, String childFilePath) { + protected static boolean isParentFile(String parentFilePath, String childFilePath) { File parentFile = new File(parentFilePath); File childFile = new File(childFilePath); diff --git a/designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java b/designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java deleted file mode 100644 index ffad37e772..0000000000 --- a/designer-base/src/com/fr/design/remote/RemoteDesignAuthority.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fr.design.remote; - -public class RemoteDesignAuthority { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java b/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java index dc77e92331..a4a08fe2f0 100644 --- a/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java +++ b/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java @@ -1,6 +1,7 @@ package com.fr.design.remote; import com.fr.design.beans.BasicBeanPane; +import com.fr.report.DesignAuthority; import javax.swing.Icon; @@ -39,7 +40,7 @@ public class RemoteDesignAuthorityCreator { return editorClazz; } - public void saveUpdatedBean(RemoteDesignAuthority authority, Object bean) { - + public void saveUpdatedBean(DesignAuthority authority, Object bean) { + authority.setItems(((DesignAuthority) bean).getItems()); } } diff --git a/designer-base/src/com/fr/design/remote/RemoteMember.java b/designer-base/src/com/fr/design/remote/RemoteMember.java index c3da597e3e..4d8b6b97cd 100644 --- a/designer-base/src/com/fr/design/remote/RemoteMember.java +++ b/designer-base/src/com/fr/design/remote/RemoteMember.java @@ -11,10 +11,19 @@ public class RemoteMember { private boolean selected; + public RemoteMember() { + + } + public RemoteMember(String username) { this.username = username; } + public RemoteMember username(String username) { + this.username = username; + return this; + } + public RemoteMember realName(String realName) { this.realName = realName; return this; diff --git a/designer-base/src/com/fr/design/remote/Utils.java b/designer-base/src/com/fr/design/remote/Utils.java index ec0a7ddeed..daed94092b 100644 --- a/designer-base/src/com/fr/design/remote/Utils.java +++ b/designer-base/src/com/fr/design/remote/Utils.java @@ -28,9 +28,11 @@ public class Utils { List res = new ArrayList<>(); for (UserAdditionBean userBean : userBeans) { - res.add(new RemoteMember(userBean.getUsername()) - .realName(userBean.getRealName()) - .userId(userBean.getId()) + res.add( + new RemoteMember() + .username(userBean.getUsername()) + .realName(userBean.getRealName()) + .userId(userBean.getId()) ); } return res; diff --git a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java index 2326bcbf59..990569b325 100644 --- a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java @@ -1,11 +1,14 @@ package com.fr.design.remote.action; import com.fr.base.BaseUtils; +import com.fr.base.FRContext; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.remote.ui.AuthorityManagerPane; +import com.fr.env.RemoteEnv; +import com.fr.report.DesignAuthority; import java.awt.event.ActionEvent; @@ -34,7 +37,14 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { dialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { - managerPane.update(); + DesignAuthority[] authorities = managerPane.update(); + if (!FRContext.getCurrentEnv().isLocalEnv()) { + try { + ((RemoteEnv) FRContext.getCurrentEnv()).updateAuthorities(authorities); + } catch (Exception exception) { + FRContext.getLogger().error(exception.getMessage()); + } + } } @Override diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java index f74cc504e6..dd4b569e38 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -4,16 +4,22 @@ import com.fr.base.FRContext; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.remote.RemoteDesignAuthority; import com.fr.design.remote.ui.tree.FileAuthorityTree; +import com.fr.file.filetree.FileNode; import com.fr.file.filetree.IOFileNodeFilter; +import com.fr.report.DesignAuthority; +import com.fr.stable.CoreConstants; import javax.swing.BorderFactory; +import javax.swing.tree.TreePath; import java.awt.BorderLayout; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; -public class AuthorityEditorPane extends BasicBeanPane { +public class AuthorityEditorPane extends BasicBeanPane { private UILabel label = new UILabel(); @@ -29,6 +35,7 @@ public class AuthorityEditorPane extends BasicBeanPane { tree.setFileNodeFilter(filter); this.add(new UIScrollPane(tree), BorderLayout.CENTER); tree.refreshEnv(FRContext.getCurrentEnv()); + } @Override @@ -37,15 +44,45 @@ public class AuthorityEditorPane extends BasicBeanPane { } @Override - public void populateBean(RemoteDesignAuthority ob) { - label.setText(ob.getName()); - // todo 选中树的结点 + public void populateBean(DesignAuthority ob) { + if (ob == null) { + return; + } + label.setText(ob.getUsername()); + + DesignAuthority.Item[] items = ob.getItems(); + if (items == null) { + return; + } + String[] paths = new String[items.length]; + for (int i = 0; i < items.length; i++) { + paths[i] = items[i].getPath(); + } + tree.selectCheckBoxPaths(paths); } @Override - public RemoteDesignAuthority updateBean() { - // todo 更新权限信息 - System.out.println(Arrays.toString(tree.getCheckBoxTreeSelectionModel().getSelectionPaths())); - return new RemoteDesignAuthority(); + public DesignAuthority updateBean() { + DesignAuthority da = new DesignAuthority(); + TreePath[] treePaths = tree.getCheckBoxTreeSelectionModel().getSelectionPaths(); + + List items = new ArrayList<>(); + for (TreePath treePath : treePaths) { + StringBuilder tempSpot = new StringBuilder(); + boolean type = true; + for (int counter = 1, maxCounter = treePath.getPathCount(); counter < maxCounter; + counter++) { + if (counter > 1) { + tempSpot.append(CoreConstants.SEPARATOR); + } + FileNode fileNode = (FileNode) ((ExpandMutableTreeNode) treePath.getPathComponent(counter)).getUserObject(); + type = type && fileNode.isDirectory(); + tempSpot.append(fileNode.getName()); + } + items.add(new DesignAuthority.Item(tempSpot.toString(), type)); + } + da.setItems(items.toArray(new DesignAuthority.Item[0])); + System.out.println(Arrays.toString(da.getItems())); + return da; } } diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java index b6094e427d..61ff35fded 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -14,7 +14,6 @@ import com.fr.design.icon.IconPathConstants; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; -import com.fr.design.remote.RemoteDesignAuthority; import com.fr.design.remote.RemoteDesignAuthorityCreator; import com.fr.design.remote.RemoteMember; import com.fr.design.remote.ui.list.AuthorityList; @@ -22,6 +21,7 @@ import com.fr.design.remote.ui.list.AuthorityListCellRenderer; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.report.DesignAuthority; import com.fr.stable.ArrayUtils; import javax.swing.BorderFactory; @@ -79,7 +79,7 @@ public class AuthorityListControlPane extends BasicPane { new RemoteDesignAuthorityCreator( "远程设计用户", BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"), - RemoteDesignAuthority.class, + DesignAuthority.class, AuthorityEditorPane.class) }; editorCtrl = new ListEditorControlPane(); @@ -147,7 +147,7 @@ public class AuthorityListControlPane extends BasicPane { } private AuthorityList createList() { - AuthorityList list = new AuthorityList(new DefaultListModel()); + AuthorityList list = new AuthorityList(new DefaultListModel()); list.setCellRenderer(new AuthorityListCellRenderer()); return list; } @@ -162,24 +162,24 @@ public class AuthorityListControlPane extends BasicPane { } - public RemoteDesignAuthority[] update() { - List res = new ArrayList<>(); + public DesignAuthority[] update() { + List res = new ArrayList<>(); this.editorCtrl.update(); DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel(); for (int i = 0, len = listModel.getSize(); i < len; i++) { - res.add((RemoteDesignAuthority) listModel.getElementAt(i)); + res.add((DesignAuthority) listModel.getElementAt(i)); } - return res.toArray(new RemoteDesignAuthority[0]); + return res.toArray(new DesignAuthority[0]); } - public void populate(RemoteDesignAuthority[] authorities) { - DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel(); + public void populate(DesignAuthority[] authorities) { + DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel(); listModel.removeAllElements(); if (ArrayUtils.isEmpty(authorities)) { return; } - for (RemoteDesignAuthority authority : authorities) { + for (DesignAuthority authority : authorities) { listModel.addElement(authority); } @@ -205,8 +205,8 @@ public class AuthorityListControlPane extends BasicPane { public void setSelectedName(String name) { DefaultListModel listModel = (DefaultListModel) this.authorityList.getModel(); for (int i = 0, len = listModel.getSize(); i < len; i++) { - RemoteDesignAuthority authority = (RemoteDesignAuthority) listModel.getElementAt(i); - if (ComparatorUtils.equals(name, authority.getName())) { + DesignAuthority authority = (DesignAuthority) listModel.getElementAt(i); + if (ComparatorUtils.equals(name, authority.getUsername())) { this.authorityList.setSelectedIndex(i); break; } @@ -218,8 +218,8 @@ public class AuthorityListControlPane extends BasicPane { * 获取选中的名字 */ public String getSelectedName() { - RemoteDesignAuthority authority = this.authorityList.getSelectedValue(); - return authority == null ? null : authority.getName(); + DesignAuthority authority = this.authorityList.getSelectedValue(); + return authority == null ? null : authority.getUsername(); } /** @@ -228,8 +228,8 @@ public class AuthorityListControlPane extends BasicPane { * @param authority authority * @param index 序号 */ - public void addAuthority(RemoteDesignAuthority authority, int index) { - DefaultListModel model = (DefaultListModel) authorityList.getModel(); + public void addAuthority(DesignAuthority authority, int index) { + DefaultListModel model = (DefaultListModel) authorityList.getModel(); model.add(index, authority); authorityList.setSelectedIndex(index); @@ -240,8 +240,8 @@ public class AuthorityListControlPane extends BasicPane { } - protected DefaultListModel getModel() { - return (DefaultListModel) this.authorityList.getModel(); + protected DefaultListModel getModel() { + return (DefaultListModel) this.authorityList.getModel(); } @@ -353,7 +353,7 @@ public class AuthorityListControlPane extends BasicPane { private ShortCut4JControlPane[] createShortcuts() { return new ShortCut4JControlPane[]{ - new AbsoluteEnableShortCut(new AddItemUpdateAction(authorityCreators)), + new AbsoluteEnableShortCut(new AddItemUpdateAction()), new NormalEnableShortCut(new RemoveItemAction()) }; } @@ -397,7 +397,7 @@ public class AuthorityListControlPane extends BasicPane { private JPanel cardPane; private BasicBeanPane[] editorPanes; - private RemoteDesignAuthority authority; + private DesignAuthority authority; ListEditorControlPane() { initUpdatePane(); @@ -460,10 +460,8 @@ public class AuthorityListControlPane extends BasicPane { * 添加按钮 */ private class AddItemUpdateAction extends UpdateAction { - private RemoteDesignAuthorityCreator creator; - AddItemUpdateAction(RemoteDesignAuthorityCreator[] creators) { - this.creator = creators[0]; + AddItemUpdateAction() { this.setName(Inter.getLocText("FR-Action_Add")); this.setMnemonic('A'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); @@ -480,8 +478,10 @@ public class AuthorityListControlPane extends BasicPane { // 获取添加的用户到权限编辑面板 List members = userManagerPane.update(); for (RemoteMember member : members) { - RemoteDesignAuthority authority = new RemoteDesignAuthority(); - authority.setName(member.getUsername()); + DesignAuthority authority = new DesignAuthority(); + authority.setUsername(member.getUsername()); + authority.setUserId(member.getUserId()); + authority.setRealName(member.getRealName()); AuthorityListControlPane.this.addAuthority(authority, getModel().getSize()); } } diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java index 46943677a7..fa235ca254 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java @@ -1,11 +1,12 @@ package com.fr.design.remote.ui; import com.fr.design.dialog.BasicPane; -import com.fr.design.remote.RemoteDesignAuthority; import com.fr.general.Inter; +import com.fr.report.DesignAuthority; import javax.swing.BorderFactory; import java.awt.BorderLayout; +import java.util.Arrays; public class AuthorityManagerPane extends BasicPane { @@ -26,12 +27,13 @@ public class AuthorityManagerPane extends BasicPane { return Inter.getLocText("远程设计权限管理"); } - public void populate(RemoteDesignAuthority[] authorities) { + public void populate(DesignAuthority[] authorities) { list.populate(authorities); } - public RemoteDesignAuthority[] update() { - - return list.update(); + public DesignAuthority[] update() { + DesignAuthority[] authorities = list.update(); + System.out.println(Arrays.toString(authorities)); + return authorities; } } diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index 41e1cfe07a..19473f7f18 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -10,14 +10,25 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.remote.RemoteMember; import com.fr.design.remote.Utils; -import com.fr.design.remote.ui.list.*; +import com.fr.design.remote.ui.list.AddedMemberList; +import com.fr.design.remote.ui.list.AddedMemberListCellRender; +import com.fr.design.remote.ui.list.AddingMemberList; +import com.fr.design.remote.ui.list.AddingMemberListCellRender; +import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; import com.fr.general.Inter; import com.fr.stable.StringUtils; import com.fr.third.guava.collect.ImmutableList; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JPanel; +import javax.swing.ListSelectionModel; +import javax.swing.SwingWorker; import javax.swing.border.EmptyBorder; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; @@ -234,11 +245,6 @@ public class UserManagerPane extends BasicPane { protected List doInBackground() { addingMembers.clear(); addingMembers.addAll(Utils.getRemoteMember(keyword)); - try { - Thread.sleep(2000L); - } catch (InterruptedException e) { - e.printStackTrace(); - } return addingMembers; } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java b/designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java index 6d0502ff13..75c70aa98b 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AuthorityList.java @@ -1,27 +1,27 @@ package com.fr.design.remote.ui.list; -import com.fr.design.remote.RemoteDesignAuthority; +import com.fr.report.DesignAuthority; import javax.swing.JList; import javax.swing.ListModel; import java.util.Vector; -public class AuthorityList extends JList { +public class AuthorityList extends JList { public AuthorityList() { super(); } - public AuthorityList(ListModel dataModel) { + public AuthorityList(ListModel dataModel) { super(dataModel); } - public AuthorityList(final RemoteDesignAuthority[] listData) { + public AuthorityList(final DesignAuthority[] listData) { super(listData); } - public AuthorityList(final Vector listData) { + public AuthorityList(final Vector listData) { super(listData); } diff --git a/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java b/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java index 2d3c407f13..100e68ee1f 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java +++ b/designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java @@ -1,16 +1,19 @@ package com.fr.design.remote.ui.list; import com.fr.base.BaseUtils; -import com.fr.design.remote.RemoteDesignAuthority; +import com.fr.report.DesignAuthority; import sun.swing.DefaultLookup; -import javax.swing.*; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; public class AuthorityListCellRenderer extends - JLabel implements ListCellRenderer { + JLabel implements ListCellRenderer { /** * An empty Border. This field might not be used. To change the @@ -35,7 +38,7 @@ public class AuthorityListCellRenderer extends } @Override - public Component getListCellRendererComponent(JList list, RemoteDesignAuthority authority, + public Component getListCellRendererComponent(JList list, DesignAuthority authority, int index, boolean isSelected, boolean cellHasFocus) { setComponentOrientation(list.getComponentOrientation()); @@ -79,7 +82,7 @@ public class AuthorityListCellRenderer extends setBorder(border); this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); - this.setText(authority.getName()); + this.setText(authority.getUsername()); return this; } diff --git a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java index a1503de54c..2b22703f77 100644 --- a/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java +++ b/designer-base/src/com/fr/design/remote/ui/tree/FileAuthorityTree.java @@ -1,8 +1,17 @@ package com.fr.design.remote.ui.tree; import com.fr.design.gui.itree.filetree.TemplateFileTree; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.file.filetree.FileNode; +import com.fr.general.ComparatorUtils; +import com.fr.stable.CoreConstants; +import com.fr.stable.StringUtils; +import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; +import java.io.File; +import java.util.ArrayList; +import java.util.List; public class FileAuthorityTree extends TemplateFileTree { @@ -12,4 +21,52 @@ public class FileAuthorityTree extends TemplateFileTree { } + public void selectCheckBoxPaths(String[] paths) { + if (paths == null || paths.length == 0) { + return; + } + + DefaultTreeModel model = (DefaultTreeModel) this.getModel(); + ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) model.getRoot(); + List res = new ArrayList<>(); + for (int i = 0, len = treeNode.getChildCount(); i < len; i++) { + ExpandMutableTreeNode childTreeNode = (ExpandMutableTreeNode) treeNode.getChildAt(i); + for (String path : paths) { + TreePath tPath = getSelectingPath(childTreeNode, StringUtils.EMPTY, path, model); + if (tPath != null) { + res.add(tPath); + } + } + } + // 勾选中这些结点 + this.getCheckBoxTreeSelectionModel().setSelectionPaths(res.toArray(new TreePath[0])); + } + + + private TreePath getSelectingPath(ExpandMutableTreeNode currentTreeNode, String prefix, String filePath, DefaultTreeModel model) { + FileNode fileNode = (FileNode) currentTreeNode.getUserObject(); + String nodePath = fileNode.getName(); + String currentTreePath = prefix + nodePath; + TreePath res; + + // 判断是否是希望选中的 + if (ComparatorUtils.equals(new File(currentTreePath), new File(filePath))) { + return new TreePath(model.getPathToRoot(currentTreeNode)); + } + // 如果当前路径是currentFilePath的ParentFile,则expandTreeNode,并继续往下找 + else if (isParentFile(currentTreePath, filePath)) { + loadPendingChildTreeNode(currentTreeNode); + prefix = currentTreePath + CoreConstants.SEPARATOR; + for (int i = 0, len = currentTreeNode.getChildCount(); i < len; i++) { + ExpandMutableTreeNode childTreeNode = (ExpandMutableTreeNode) currentTreeNode.getChildAt(i); + // 继续在子结点里面找 + res = getSelectingPath(childTreeNode, prefix, filePath, model); + if (res != null) { + return res; + } + } + return null; + } + return null; + } } diff --git a/designer-base/src/com/fr/env/DesignAuthorityConfigurable.java b/designer-base/src/com/fr/env/DesignAuthorityConfigurable.java new file mode 100644 index 0000000000..301c36b386 --- /dev/null +++ b/designer-base/src/com/fr/env/DesignAuthorityConfigurable.java @@ -0,0 +1,10 @@ +package com.fr.env; + +import com.fr.report.DesignAuthority; + +public interface DesignAuthorityConfigurable { + + DesignAuthority[] getAuthorities(); + + boolean updateAuthorities(DesignAuthority[] authorities) throws Exception; +} diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index bb0b592ded..03d565acbb 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -41,6 +41,7 @@ import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.license.function.VT4FR; import com.fr.regist.License; +import com.fr.report.DesignAuthority; import com.fr.share.ShareConstants; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; @@ -56,6 +57,7 @@ import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLableReader; import com.fr.web.ResourceConstants; +import com.fr.web.utils.AuthorityXMLUtils; import javax.swing.JOptionPane; import javax.swing.UIManager; @@ -95,7 +97,7 @@ import java.util.regex.Pattern; /** * @author null */ -public class RemoteEnv extends AbstractEnv { +public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable { private static final int TIME_OUT = 30 * 1000; private static final int PLAIN_SOCKET_PORT = 80; private static final int SSL_PORT = 443; @@ -228,7 +230,13 @@ public class RemoteEnv extends AbstractEnv { if (!isSignIn) { methodPath = methodPath + "?id=" + createUserID(); } - HttpClient client = new HttpClient(methodPath,para); + HttpClient client = new HttpClient(methodPath, para); + /* + todo post 方法好象过去不了 + 但是get方法也会有一些url参数问题,尤其是图表部分 + 比如: + op=fr_remote_design&cmd=design_get_plugin_service_data&serviceID=plugin.phantomjs&req= + */ client.asGet(); return client; } @@ -236,9 +244,20 @@ public class RemoteEnv extends AbstractEnv { /** * 根据nameValuePairs,也就是参数对,生成PostMethod,不同之处在于,参数拼在path后面,不是method.addParameters */ - private HttpClient createHttpMethod2(HashMap para) throws EnvException { + private HttpClient createHttpMethod2(HashMap para) throws EnvException, UnsupportedEncodingException { String methodPath = path + '?' + "id=" + createUserID(); - return new HttpClient(methodPath, para, true); + StringBuilder pathBuilder = new StringBuilder(); + pathBuilder.append(methodPath); + pathBuilder.append('&'); + for (Object o : para.entrySet()) { + Map.Entry entry = (Map.Entry) o; + pathBuilder.append('&'); + pathBuilder.append(URLEncoder.encode((String) entry.getKey(), "UTF-8")); + pathBuilder.append('='); + pathBuilder.append(URLEncoder.encode((String) entry.getValue(), "UTF-8")); + } + methodPath = pathBuilder.toString(); + return new HttpClient(methodPath); } @@ -826,6 +845,27 @@ public class RemoteEnv extends AbstractEnv { return Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); } + @Override + public boolean updateAuthorities(DesignAuthority[] authorities) throws Exception { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + // 序列化到输出流 + AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, out); + + HashMap para = new HashMap<>(); + para.put("op", "remote_design_authority"); + para.put("cmd", "update_authorities"); + + InputStream input = postBytes2ServerB(out.toByteArray(), para); + + return input != null && Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); + } + + @Override + public DesignAuthority[] getAuthorities() { + return new DesignAuthority[0]; + } + /** * ben:取schema */ @@ -1366,6 +1406,13 @@ public class RemoteEnv extends AbstractEnv { */ public InputStream postBytes2ServerB(byte[] bytes, HashMap para) throws Exception { HttpClient client = createHttpMethod2(para); + /* + todo post 方法好象过去不了 + 但是get方法也会有一些url参数问题,尤其是图表部分 + 比如: + op=fr_remote_design&cmd=design_get_plugin_service_data&serviceID=plugin.phantomjs&req= + */ +// client.asGet(); client.setContent(bytes); return execute4InputStream(client); } @@ -1900,8 +1947,6 @@ public class RemoteEnv extends AbstractEnv { } - //TODO: - /** * 预览存储过程 * From 9836db8da7b2a64e62bcd25cf4e6aaa32697f8e0 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 23 May 2018 04:17:48 +0800 Subject: [PATCH 14/17] =?UTF-8?q?REPORT-6700=20=E6=95=B0=E6=8D=AE=E4=BC=A0?= =?UTF-8?q?=E8=BE=93=20=E5=92=8C=20=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remote/RemoteDesignAuthorityCreator.java | 5 +- .../RemoteDesignAuthorityManagerAction.java | 12 ++- designer-base/src/com/fr/env/RemoteEnv.java | 84 +++--------------- .../src/com/fr/env/RemoteEnvUtils.java | 87 +++++++++++++++++++ 4 files changed, 114 insertions(+), 74 deletions(-) create mode 100644 designer-base/src/com/fr/env/RemoteEnvUtils.java diff --git a/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java b/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java index a4a08fe2f0..1487d1a4e7 100644 --- a/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java +++ b/designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java @@ -3,7 +3,7 @@ package com.fr.design.remote; import com.fr.design.beans.BasicBeanPane; import com.fr.report.DesignAuthority; -import javax.swing.Icon; +import javax.swing.*; public class RemoteDesignAuthorityCreator { @@ -41,6 +41,9 @@ public class RemoteDesignAuthorityCreator { } public void saveUpdatedBean(DesignAuthority authority, Object bean) { + if (authority == null) { + return; + } authority.setItems(((DesignAuthority) bean).getItems()); } } diff --git a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java index 990569b325..53174fccf1 100644 --- a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java @@ -31,8 +31,16 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { BasicDialog dialog = managerPane.showWindow(DesignerContext.getDesignerFrame()); - - //todo read contents from database by hibernate to show + if (!FRContext.getCurrentEnv().isLocalEnv()) { + try { + DesignAuthority[] authorities = ((RemoteEnv) FRContext.getCurrentEnv()).getAuthorities(); + if (authorities != null && authorities.length != 0) { + managerPane.populate(authorities); + } + } catch (Exception exception) { + FRContext.getLogger().error(exception.getMessage()); + } + } dialog.addDialogActionListener(new DialogActionAdapter() { @Override diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 03d565acbb..c1533aca59 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -1,13 +1,6 @@ package com.fr.env; -import com.fr.base.AbstractEnv; -import com.fr.base.EnvException; -import com.fr.base.FRContext; -import com.fr.base.ModifiedTable; -import com.fr.base.Parameter; -import com.fr.base.StoreProcedureParameter; -import com.fr.base.TableData; -import com.fr.base.Utils; +import com.fr.base.*; import com.fr.base.remote.RemoteDeziConstants; import com.fr.data.TableDataSource; import com.fr.data.core.DataCoreUtils; @@ -29,11 +22,7 @@ import com.fr.file.CacheManager; import com.fr.file.ConnectionConfig; import com.fr.file.TableDataConfig; import com.fr.file.filetree.FileNode; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; -import com.fr.general.Inter; -import com.fr.general.LogRecordTime; -import com.fr.general.LogUtils; +import com.fr.general.*; import com.fr.general.http.HttpClient; import com.fr.io.utils.ResourceIOUtils; import com.fr.json.JSONArray; @@ -43,54 +32,27 @@ import com.fr.license.function.VT4FR; import com.fr.regist.License; import com.fr.report.DesignAuthority; import com.fr.share.ShareConstants; -import com.fr.stable.ArrayUtils; -import com.fr.stable.EncodeConstants; -import com.fr.stable.Filter; -import com.fr.stable.JavaCompileInfo; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.SvgProvider; +import com.fr.stable.*; import com.fr.stable.file.XMLFileManagerProvider; import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLableReader; import com.fr.web.ResourceConstants; -import com.fr.web.utils.AuthorityXMLUtils; - -import javax.swing.JOptionPane; -import javax.swing.UIManager; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; + +import javax.swing.*; +import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import java.awt.Component; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; +import java.awt.*; +import java.io.*; import java.net.HttpURLConnection; import java.net.NoRouteToHostException; import java.net.Socket; import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; +import java.util.*; import java.util.List; -import java.util.Map; import java.util.Timer; -import java.util.TimerTask; import java.util.logging.Level; import java.util.regex.Pattern; @@ -246,17 +208,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl */ private HttpClient createHttpMethod2(HashMap para) throws EnvException, UnsupportedEncodingException { String methodPath = path + '?' + "id=" + createUserID(); - StringBuilder pathBuilder = new StringBuilder(); - pathBuilder.append(methodPath); - pathBuilder.append('&'); - for (Object o : para.entrySet()) { - Map.Entry entry = (Map.Entry) o; - pathBuilder.append('&'); - pathBuilder.append(URLEncoder.encode((String) entry.getKey(), "UTF-8")); - pathBuilder.append('='); - pathBuilder.append(URLEncoder.encode((String) entry.getValue(), "UTF-8")); - } - methodPath = pathBuilder.toString(); return new HttpClient(methodPath); } @@ -847,23 +798,14 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl @Override public boolean updateAuthorities(DesignAuthority[] authorities) throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - // 序列化到输出流 - AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, out); - - HashMap para = new HashMap<>(); - para.put("op", "remote_design_authority"); - para.put("cmd", "update_authorities"); - - InputStream input = postBytes2ServerB(out.toByteArray(), para); - - return input != null && Boolean.valueOf(IOUtils.inputStream2String(input, EncodeConstants.ENCODING_UTF_8)); + return RemoteEnvUtils.updateAuthorities(authorities, this); } @Override public DesignAuthority[] getAuthorities() { - return new DesignAuthority[0]; + + return RemoteEnvUtils.getAuthorities(this); + } /** diff --git a/designer-base/src/com/fr/env/RemoteEnvUtils.java b/designer-base/src/com/fr/env/RemoteEnvUtils.java new file mode 100644 index 0000000000..5b4ffc1215 --- /dev/null +++ b/designer-base/src/com/fr/env/RemoteEnvUtils.java @@ -0,0 +1,87 @@ +package com.fr.env; + +import com.fr.base.FRContext; +import com.fr.general.IOUtils; +import com.fr.report.DesignAuthority; +import com.fr.stable.EncodeConstants; +import com.fr.third.org.apache.http.HttpEntity; +import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; +import com.fr.third.org.apache.http.client.methods.HttpUriRequest; +import com.fr.third.org.apache.http.client.methods.RequestBuilder; +import com.fr.third.org.apache.http.entity.ContentType; +import com.fr.third.org.apache.http.entity.InputStreamEntity; +import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; +import com.fr.third.org.apache.http.impl.client.HttpClients; +import com.fr.third.org.apache.http.util.EntityUtils; +import com.fr.web.utils.AuthorityXMLUtils; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +public class RemoteEnvUtils { + + private RemoteEnvUtils() { + } + + public static boolean updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) { + String path = env.getPath(); + String userID = env.getUserID(); + + String res = null; + CloseableHttpClient httpClient = HttpClients.createDefault(); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream); + + + InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML); + + HttpUriRequest request = RequestBuilder.post(path) + .addParameter("id", userID) + .addParameter("op", "remote_design_authority") + .addParameter("cmd", "update_authorities") + .setEntity(reqEntity) + .build(); + + try { + CloseableHttpResponse response = httpClient.execute(request); + HttpEntity entity = response.getEntity(); + res = IOUtils.inputStream2String(entity.getContent(), EncodeConstants.ENCODING_UTF_8); + EntityUtils.consume(entity); + System.out.println(res); + } catch (IOException e) { + FRContext.getLogger().error(e.getMessage()); + } + + return res != null && Boolean.valueOf(res); + + } + + public static DesignAuthority[] getAuthorities(RemoteEnv env) { + String path = env.getPath(); + String userID = env.getUserID(); + DesignAuthority[] authorities = null; + CloseableHttpClient httpClient = HttpClients.createDefault(); + + HttpUriRequest request = RequestBuilder.get(path) + .addParameter("id", userID) + .addParameter("op", "remote_design_authority") + .addParameter("cmd", "get_authorities") + .build(); + + try { + CloseableHttpResponse response = httpClient.execute(request); + HttpEntity entity = response.getEntity(); + + authorities = AuthorityXMLUtils.readDesignAuthoritiesXML(entity.getContent()); + EntityUtils.consume(entity); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage()); + } + return authorities; + + } + +} From 773de9c19b3d56d845544ec5d06b567ad2dd0045 Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 23 May 2018 09:51:15 +0800 Subject: [PATCH 15/17] =?UTF-8?q?REPORT-6700=20=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/EnvFileTree.java | 18 ++++------- .../com/fr/design/remote/RemoteMember.java | 5 ++- .../src/com/fr/design/remote/Utils.java | 11 +++++-- .../RemoteDesignAuthorityManagerAction.java | 3 +- .../design/remote/ui/AuthorityEditorPane.java | 3 +- .../remote/ui/AuthorityListControlPane.java | 2 +- .../remote/ui/AuthorityManagerPane.java | 2 +- .../fr/design/remote/ui/UserManagerPane.java | 32 ++++++++++++++----- 8 files changed, 50 insertions(+), 26 deletions(-) diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index 460a05f82c..1f81296b0d 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -48,7 +48,13 @@ public class EnvFileTree extends RefreshableJTree { this.setFileNodeFilter(filter); this.setSubPathes(subPathes); - this.initi(); + this.putClientProperty("JTree.lineStyle", "Angled"); + + this.setCellRenderer(fileTreeCellRenderer); + + this.setRootVisible(false); + this.setShowsRootHandles(true); + this.setEditable(false); } private void setTreeRootPath(String path) { @@ -63,16 +69,6 @@ public class EnvFileTree extends RefreshableJTree { this.filter = filter; } - protected void initi() { - this.putClientProperty("JTree.lineStyle", "Angled"); - - this.setCellRenderer(fileTreeCellRenderer); - - this.setRootVisible(false); - this.setShowsRootHandles(true); - this.setEditable(false); - } - // CellRenderer private DefaultTreeCellRenderer fileTreeCellRenderer = new DefaultTreeCellRenderer() { diff --git a/designer-base/src/com/fr/design/remote/RemoteMember.java b/designer-base/src/com/fr/design/remote/RemoteMember.java index 4d8b6b97cd..dee672406f 100644 --- a/designer-base/src/com/fr/design/remote/RemoteMember.java +++ b/designer-base/src/com/fr/design/remote/RemoteMember.java @@ -1,8 +1,11 @@ package com.fr.design.remote; +import com.fr.general.Inter; + public class RemoteMember { - public static final RemoteMember DEFAULT_MEMBER = new RemoteMember("查询中..."); + public static final RemoteMember DEFAULT_MEMBER = + new RemoteMember(Inter.getLocText("FR-Designer_Remote_Design_Loading")); private String username; diff --git a/designer-base/src/com/fr/design/remote/Utils.java b/designer-base/src/com/fr/design/remote/Utils.java index daed94092b..d251099307 100644 --- a/designer-base/src/com/fr/design/remote/Utils.java +++ b/designer-base/src/com/fr/design/remote/Utils.java @@ -19,10 +19,17 @@ public class Utils { List userBeans = new ArrayList<>(); try { - Map result = UserService.getInstance().getAllUsers(FRContext.getCurrentEnv().getUser(), 1, 10, keyword, "", true); + Map result = + UserService.getInstance().getAllUsers( + FRContext.getCurrentEnv().getUser(), + 1, + 10, + keyword, + "", + true); userBeans = (List) result.get("items"); } catch (Exception e) { - e.printStackTrace(); + FRContext.getLogger().error(e.getMessage()); } List res = new ArrayList<>(); diff --git a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java index 53174fccf1..39d5921d6a 100644 --- a/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java +++ b/designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java @@ -8,6 +8,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.remote.ui.AuthorityManagerPane; import com.fr.env.RemoteEnv; +import com.fr.general.Inter; import com.fr.report.DesignAuthority; import java.awt.event.ActionEvent; @@ -19,7 +20,7 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction { public RemoteDesignAuthorityManagerAction() { - this.setName("远程设计权限管理"); + this.setName(Inter.getLocText("FR-Designer_Remote_Design_Authority_Manager")); this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png")); } diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java index dd4b569e38..c4e49ea273 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -9,6 +9,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.remote.ui.tree.FileAuthorityTree; import com.fr.file.filetree.FileNode; import com.fr.file.filetree.IOFileNodeFilter; +import com.fr.general.Inter; import com.fr.report.DesignAuthority; import com.fr.stable.CoreConstants; @@ -40,7 +41,7 @@ public class AuthorityEditorPane extends BasicBeanPane { @Override protected String title4PopupWindow() { - return "编辑文件权限"; + return Inter.getLocText("FR-Designer_Remote_Design_Configure_Authority"); } @Override diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java index 61ff35fded..60dfc2a3cc 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java @@ -77,7 +77,7 @@ public class AuthorityListControlPane extends BasicPane { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.authorityCreators = new RemoteDesignAuthorityCreator[]{ new RemoteDesignAuthorityCreator( - "远程设计用户", + Inter.getLocText("FR-Designer_Remote_Design_User"), BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"), DesignAuthority.class, AuthorityEditorPane.class) diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java index fa235ca254..6990b764e4 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java @@ -24,7 +24,7 @@ public class AuthorityManagerPane extends BasicPane { @Override protected String title4PopupWindow() { - return Inter.getLocText("远程设计权限管理"); + return Inter.getLocText("FR-Designer_Remote_Design_Authority_Manager"); } public void populate(DesignAuthority[] authorities) { diff --git a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java index 19473f7f18..226602d6f0 100644 --- a/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/UserManagerPane.java @@ -82,7 +82,7 @@ public class UserManagerPane extends BasicPane { @Override public void keyReleased(KeyEvent e) { // 判断按下的键是否是回车键 - // todo 对话款回车键绑定的是对话框的确定按钮 + // todo 对话框回车键绑定的是对话框的确定按钮 if (e.getKeyCode() == KeyEvent.VK_ENTER) { searchAddingMembers(keyField.getText()); } @@ -115,7 +115,11 @@ public class UserManagerPane extends BasicPane { resetAddedMembers(); sync2AddedMembersFormAdded(); // 不需要重复更新右侧列表显示 但是更新一下计数显示 - countLabel.setText(Inter.getLocText("已选择{R1}人", String.valueOf(addedMembers.size()))); + countLabel.setText( + Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count", + String.valueOf(addedMembers.size()) + ) + ); } }; @@ -140,7 +144,7 @@ public class UserManagerPane extends BasicPane { @Override protected String title4PopupWindow() { - return "添加设计成员"; + return Inter.getLocText("FR-Designer_Remote_Design_Add_Member"); } private JPanel createLeftPanel() { @@ -149,7 +153,10 @@ public class UserManagerPane extends BasicPane { content.setBorder( BorderFactory.createCompoundBorder( new EmptyBorder(6, 0, 0, 0), - UITitledBorder.createBorderWithTitle(Inter.getLocText("决策系统成员"))) + UITitledBorder.createBorderWithTitle( + Inter.getLocText("FR-Designer_Remote_Design_Decision_Member") + ) + ) ); // 搜索 @@ -158,7 +165,7 @@ public class UserManagerPane extends BasicPane { keyField.setPreferredSize(new Dimension(200, 20)); keyField.requestFocus(); keyField.addKeyListener(keyFieldKeyListener); - keyButton.setText("搜索"); + keyButton.setText(Inter.getLocText("FR-Designer_Remote_Design_Search")); keyButton.addActionListener(keyButtonActionListener); searchPanel.add(keyField); searchPanel.add(keyButton); @@ -186,11 +193,17 @@ public class UserManagerPane extends BasicPane { content.setBorder( BorderFactory.createCompoundBorder( new EmptyBorder(6, 0, 0, 0), - UITitledBorder.createBorderWithTitle(Inter.getLocText("已选择的设计成员"))) + UITitledBorder.createBorderWithTitle( + Inter.getLocText("FR-Designer_Remote_Design_Selected_Member") + ) + ) ); // 计数 - countLabel.setText(Inter.getLocText("已选择{R1}人", String.valueOf(addedMembers.size()))); + countLabel.setText( + Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count", + String.valueOf(addedMembers.size())) + ); addedListModel = new DefaultListModel<>(); addedList = new AddedMemberList(addedListModel); @@ -225,7 +238,10 @@ public class UserManagerPane extends BasicPane { } addedList.revalidate(); addedList.repaint(); - countLabel.setText(Inter.getLocText("已选择{R1}人", String.valueOf(addedMembers.size()))); + countLabel.setText( + Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count", + String.valueOf(addedMembers.size()) + )); } private void resetMembers() { From d35c4dd5711f77ca77ce4298bb8d5ea125f156fb Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 23 May 2018 10:06:01 +0800 Subject: [PATCH 16/17] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/remote/ui/AuthorityEditorPane.java | 1 - .../src/com/fr/design/remote/ui/AuthorityManagerPane.java | 4 +--- .../src/com/fr/design/remote/ui/list/MemberList.java | 1 - designer-base/src/com/fr/env/RemoteEnvUtils.java | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java index c4e49ea273..5e27bc907c 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java @@ -83,7 +83,6 @@ public class AuthorityEditorPane extends BasicBeanPane { items.add(new DesignAuthority.Item(tempSpot.toString(), type)); } da.setItems(items.toArray(new DesignAuthority.Item[0])); - System.out.println(Arrays.toString(da.getItems())); return da; } } diff --git a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java index 6990b764e4..3ce863af3b 100644 --- a/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java +++ b/designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java @@ -32,8 +32,6 @@ public class AuthorityManagerPane extends BasicPane { } public DesignAuthority[] update() { - DesignAuthority[] authorities = list.update(); - System.out.println(Arrays.toString(authorities)); - return authorities; + return list.update(); } } diff --git a/designer-base/src/com/fr/design/remote/ui/list/MemberList.java b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java index 5a79a08562..9384f3883f 100644 --- a/designer-base/src/com/fr/design/remote/ui/list/MemberList.java +++ b/designer-base/src/com/fr/design/remote/ui/list/MemberList.java @@ -60,7 +60,6 @@ public abstract class MemberList extends JList { @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); - System.out.println("click location: x:" + e.getX() + " y:" + e.getY()); if (shouldDisplaySelected(e)) { displaySelected(); } diff --git a/designer-base/src/com/fr/env/RemoteEnvUtils.java b/designer-base/src/com/fr/env/RemoteEnvUtils.java index 5b4ffc1215..d22150bd8f 100644 --- a/designer-base/src/com/fr/env/RemoteEnvUtils.java +++ b/designer-base/src/com/fr/env/RemoteEnvUtils.java @@ -50,7 +50,6 @@ public class RemoteEnvUtils { HttpEntity entity = response.getEntity(); res = IOUtils.inputStream2String(entity.getContent(), EncodeConstants.ENCODING_UTF_8); EntityUtils.consume(entity); - System.out.println(res); } catch (IOException e) { FRContext.getLogger().error(e.getMessage()); } From 64de3e05a8b0b00697b277dbf5064abd16f73cce Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 23 May 2018 10:14:03 +0800 Subject: [PATCH 17/17] doc --- .../src/com/fr/design/gui/itree/filetree/EnvFileTree.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index 1f81296b0d..c9077b775e 100644 --- a/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -48,6 +48,7 @@ public class EnvFileTree extends RefreshableJTree { this.setFileNodeFilter(filter); this.setSubPathes(subPathes); + /*一些自己的 init 放在这里,防止直接错误重写了父类的 init 方法导致子类不能使用 CheckBoxTree 的一些特性。*/ this.putClientProperty("JTree.lineStyle", "Angled"); this.setCellRenderer(fileTreeCellRenderer);