Browse Source

Merge branch 'feature/10.0' of http://cloud.finedevelop.com:2015/scm/~plough/10-design into feature/10.0

master
plough 7 years ago
parent
commit
ed5c8d9567
  1. 6
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 4
      designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java
  3. 47
      designer-base/src/com/fr/design/extra/PluginUtils.java
  4. 7
      designer-base/src/com/fr/design/extra/PluginWebBridge.java
  5. 76
      designer-base/src/com/fr/design/extra/PluginWebPane.java
  6. 6
      designer-base/src/com/fr/design/extra/WebViewDlgHelper.java
  7. 40
      designer-base/src/com/fr/design/extra/exe/GetInstalledPluginsExecutor.java
  8. 170
      designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  9. 2
      designer-base/src/com/fr/design/mainframe/DesignerFrame.java
  10. 4
      designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java
  11. 2
      designer-base/src/com/fr/design/remote/RemoteDesignAuthorityCreator.java
  12. 72
      designer-base/src/com/fr/design/remote/RemoteMember.java
  13. 47
      designer-base/src/com/fr/design/remote/Utils.java
  14. 18
      designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java
  15. 59
      designer-base/src/com/fr/design/remote/button/IconButton.java
  16. 18
      designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java
  17. 24
      designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java
  18. 3
      designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java
  19. 78
      designer-base/src/com/fr/design/remote/ui/UserManagerPane.java
  20. 25
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java
  21. 21
      designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java
  22. 21
      designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java
  23. 11
      designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java
  24. 2
      designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java
  25. 11
      designer-base/src/com/fr/design/remote/ui/list/MemberList.java
  26. 4
      designer-base/src/com/fr/env/EnvListPane.java
  27. 3
      designer-base/src/com/fr/env/LocalEnvPane.java
  28. 6
      designer-base/src/com/fr/env/RemoteEnv.java
  29. 4
      designer-base/src/com/fr/env/RemoteEnvPane.java
  30. 6
      designer-base/src/com/fr/env/SignIn.java

6
designer-base/src/com/fr/design/DesignerEnvManager.java

@ -6,10 +6,10 @@ package com.fr.design;
import com.fr.base.BaseXMLUtils; import com.fr.base.BaseXMLUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.Utils; import com.fr.base.Utils;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.base.env.resource.LocalEnvConfig;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.env.SignIn; import com.fr.env.SignIn;

4
designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java

@ -1,9 +1,9 @@
package com.fr.design.actions.file; package com.fr.design.actions.file;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.env.resource.LocalEnvConfig;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;

47
designer-base/src/com/fr/design/extra/PluginUtils.java

@ -24,6 +24,8 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -205,4 +207,49 @@ public class PluginUtils {
private static boolean isCompatibleCurrentEnv(String envVersion){ private static boolean isCompatibleCurrentEnv(String envVersion){
return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion());
} }
public static JSONArray transferPluginToJson(PluginContext [] pluginContexts){
JSONArray ja = JSONArray.create();
try {
for(PluginContext pluginContext : pluginContexts){
JSONObject jo = JSONObject.create();
jo.put("id", pluginContext.getID());
jo.put("name", pluginContext.getName());
jo.put("version", pluginContext.getVersion());
jo.put("envVersion", pluginContext.getEnvVersion());
jo.put("description", pluginContext.getDescription());
jo.put("changeNotes", pluginContext.getChangeNotes());
jo.put("vendor", pluginContext.getVendor());
jo.put("price", pluginContext.getPrice());
jo.put("jarTime", pluginContext.getRequiredJarTime());
jo.put("isActive", pluginContext.isActive());
jo.put("isHidden", pluginContext.isHidden());
jo.put("isFree", pluginContext.isFree());
jo.put("isLicDamage", pluginContext.isLicDamaged());
jo.put("isAvailable", pluginContext.isAvailable());
jo.put("leftTime", String.valueOf(pluginContext.getLeftDays()));
jo.put("isTrial", pluginContext.isOnTrial());
jo.put("deadline", getDeadline(pluginContext));
jo.put("isRegisterFailed", pluginContext.isRegisterFailed());
ja.put(jo);
}
}catch (Exception e){
}
return ja;
}
private static String getDeadline(PluginContext plugin) {
int leftDays = plugin.getLeftDays();
if (leftDays == Integer.MAX_VALUE) {
return Inter.getLocText("FR-Plugin-Store_Permanent");
}
Calendar deadline = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
deadline.add(Calendar.DATE, leftDays);
return format.format(deadline.getTime());
}
} }

7
designer-base/src/com/fr/design/extra/PluginWebBridge.java

@ -5,6 +5,7 @@ import com.fr.config.MarketConfig;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.bbs.BBSLoginUtils; import com.fr.design.bbs.BBSLoginUtils;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.extra.exe.GetInstalledPluginsExecutor;
import com.fr.design.extra.exe.GetPluginCategoriesExecutor; import com.fr.design.extra.exe.GetPluginCategoriesExecutor;
import com.fr.design.extra.exe.GetPluginFromStoreExecutor; import com.fr.design.extra.exe.GetPluginFromStoreExecutor;
import com.fr.design.extra.exe.GetPluginPrefixExecutor; import com.fr.design.extra.exe.GetPluginPrefixExecutor;
@ -301,9 +302,9 @@ public class PluginWebBridge {
* *
* @return 已安装的插件组成的数组 * @return 已安装的插件组成的数组
*/ */
public PluginContext[] getInstalledPlugins() { public void getInstalledPlugins(final JSObject callback) {
List<PluginContext> plugins = PluginManager.getContexts(); Task<Void> task = new PluginTask<>(webEngine, callback, new GetInstalledPluginsExecutor());
return plugins.toArray(new PluginContext[plugins.size()]); threadPoolExecutor.submit(task);
} }
private String[] jsObjectToStringArray(JSObject obj) { private String[] jsObjectToStringArray(JSObject obj) {

76
designer-base/src/com/fr/design/extra/PluginWebPane.java

@ -1,5 +1,10 @@
package com.fr.design.extra; package com.fr.design.extra;
import com.fr.base.FRContext;
import com.fr.base.TemplateUtils;
import com.fr.general.IOUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.embed.swing.JFXPanel; import javafx.embed.swing.JFXPanel;
import javafx.event.EventHandler; import javafx.event.EventHandler;
@ -10,16 +15,24 @@ import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView; import javafx.scene.web.WebView;
import netscape.javascript.JSObject; import netscape.javascript.JSObject;
import javax.swing.*; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
/** /**
* Created by richie on 16/3/19. * Created by richie on 16/3/19.
*/ */
public class PluginWebPane extends JFXPanel { public class PluginWebPane extends JFXPanel {
private static final String RESOURCE_URL = "resourceURL";
private WebEngine webEngine; private WebEngine webEngine;
public PluginWebPane(final String mainJs) { public PluginWebPane(final String installHome, final String mainJs) {
Platform.setImplicitExit(false); Platform.setImplicitExit(false);
Platform.runLater(new Runnable() { Platform.runLater(new Runnable() {
@Override @Override
@ -29,21 +42,56 @@ public class PluginWebPane extends JFXPanel {
PluginWebPane.this.setScene(scene); PluginWebPane.this.setScene(scene);
WebView webView = new WebView(); WebView webView = new WebView();
webEngine = webView.getEngine(); webEngine = webView.getEngine();
webEngine.load("file:///" + mainJs); try{
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() { String htmlString = getRenderedHtml(installHome, mainJs);
@Override webEngine.loadContent(htmlString);
public void handle(WebEvent<String> event) { webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
showAlert(event.getData()); @Override
} public void handle(WebEvent<String> event) {
}); showAlert(event.getData());
JSObject obj = (JSObject) webEngine.executeScript("window"); }
obj.setMember("PluginHelper", PluginWebBridge.getHelper(webEngine)); });
webView.setContextMenuEnabled(false);//屏蔽右键 JSObject obj = (JSObject) webEngine.executeScript("window");
root.setCenter(webView); obj.setMember("PluginHelper", PluginWebBridge.getHelper(webEngine));
webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView);
}catch (Exception e){
FRContext.getLogger().error(e.getMessage(), e);
}
} }
}); });
} }
private String getRenderedHtml(String installHome, String mainJs) throws IOException {
InputStream inp = IOUtils.readResource(StableUtils.pathJoin(installHome, mainJs));
if (inp == null) {
throw new IOException("Not found template: " + mainJs);
}
BufferedReader reader = new BufferedReader(new InputStreamReader(inp, StableUtils.RESOURCE_ENCODER));
BufferedReader read = new BufferedReader(reader);
StringBuffer sb = new StringBuffer();
String line;
Map<String, Object> map4Tpl = new HashMap<String, Object>();
map4Tpl.put(RESOURCE_URL, "file:///" + URLEncoder.encode(installHome, "UTF-8"));
while ((line = read.readLine()) != null) {
if (sb.length() > 0) {
sb.append('\n');
}
sb.append(line);
}
String htmlString = StringUtils.EMPTY;
try{
htmlString = TemplateUtils.renderParameter4Tpl(sb.toString(), map4Tpl);
}catch (Exception e){
FRContext.getLogger().error(e.getMessage(), e);
}
reader.close();
inp.close();
return htmlString;
}
private void showAlert(final String message) { private void showAlert(final String message) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override @Override

6
designer-base/src/com/fr/design/extra/WebViewDlgHelper.java

@ -73,7 +73,7 @@ public class WebViewDlgHelper {
String indexPath = "plugin.html"; String indexPath = "plugin.html";
String mainIndexPath = StableUtils.pathJoin(installHome, indexPath); String mainIndexPath = StableUtils.pathJoin(installHome, indexPath);
checkAndCopyMainFile(mainIndexPath, mainJsPath); checkAndCopyMainFile(mainIndexPath, mainJsPath);
showPluginDlg(mainIndexPath); showPluginDlg(indexPath);
updateShopScripts(SHOP_SCRIPTS); updateShopScripts(SHOP_SCRIPTS);
} }
} else { } else {
@ -188,8 +188,8 @@ public class WebViewDlgHelper {
private static void showPluginDlg(String mainJsPath) { private static void showPluginDlg(String mainJsPath) {
try { try {
Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane"); Class<?> clazz = Class.forName("com.fr.design.extra.PluginWebPane");
Constructor constructor = clazz.getConstructor(String.class); Constructor constructor = clazz.getConstructor(String.class, String.class);
Component webPane = (Component) constructor.newInstance(mainJsPath); Component webPane = (Component) constructor.newInstance(installHome, mainJsPath);
BasicPane managerPane = new ShopManagerPane(webPane); BasicPane managerPane = new ShopManagerPane(webPane);
UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane); UIDialog dlg = new ShopDialog(DesignerContext.getDesignerFrame(), managerPane);

40
designer-base/src/com/fr/design/extra/exe/GetInstalledPluginsExecutor.java

@ -0,0 +1,40 @@
package com.fr.design.extra.exe;
import com.fr.design.extra.PluginUtils;
import com.fr.design.extra.Process;
import com.fr.json.JSONArray;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginManager;
import java.util.List;
/**
* @author kerry
* @date 2018/6/1
*/
public class GetInstalledPluginsExecutor implements Executor {
private String result ="[]";
@Override
public String getTaskFinishMessage() {
return result;
}
@Override
public Command[] getCommands() {
return new Command[]{
new Command() {
@Override
public String getExecuteMessage() {
return null;
}
@Override
public void run(Process<String> process) {
List<PluginContext> plugins = PluginManager.getContexts();
JSONArray ja = PluginUtils.transferPluginToJson(plugins.toArray(new PluginContext[plugins.size()]));
result = ja.toString();
}
}
};
}
}

170
designer-base/src/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -1,20 +1,29 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.Env;
import com.fr.base.env.EnvContext;
import com.fr.base.env.proxy.EnvProxy;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.env.operator.file.TplFileOperator;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import javax.swing.text.Position; import javax.swing.text.Position;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
/* /*
* 显示Env下的reportlets目录下面的所有cpt文件 * 显示Env下的reportlets目录下面的所有cpt文件
*/ */
public class TemplateFileTree extends EnvFileTree { public class TemplateFileTree extends EnvFileTree {
public TemplateFileTree() { public TemplateFileTree() {
super(ProjectConstants.REPORTLETS_NAME, null, null); super(ProjectConstants.REPORTLETS_NAME, null, null);
@ -42,33 +51,32 @@ public class TemplateFileTree extends EnvFileTree {
return null; return null;
} }
public String[] getSelectedTemplatePaths(){ public String[] getSelectedTemplatePaths() {
TreePath[] selectedTreePaths = this.getSelectionPaths(); TreePath[] selectedTreePaths = this.getSelectionPaths();
if (ArrayUtils.isEmpty(selectedTreePaths)) { if (ArrayUtils.isEmpty(selectedTreePaths)) {
return ArrayUtils.EMPTY_STRING_ARRAY; return ArrayUtils.EMPTY_STRING_ARRAY;
} }
List<String> selectedPathList = new ArrayList<String>(); List<String> selectedPathList = new ArrayList<String>();
for(TreePath treepath : selectedTreePaths){ for (TreePath treepath : selectedTreePaths) {
ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treepath.getLastPathComponent(); ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treepath.getLastPathComponent();
Object userObject = currentTreeNode.getUserObject(); Object userObject = currentTreeNode.getUserObject();
if (userObject instanceof FileNode) { if (userObject instanceof FileNode) {
FileNode fn = (FileNode) userObject; FileNode fn = (FileNode) userObject;
if (!fn.isDirectory()) { if (!fn.isDirectory()) {
String envPath = fn.getEnvPath(); String envPath = fn.getEnvPath();
if (envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) { if (envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
selectedPathList.add(envPath.substring(ProjectConstants.REPORTLETS_NAME.length())); selectedPathList.add(envPath.substring(ProjectConstants.REPORTLETS_NAME.length()));
} }
} }
} }
} }
return selectedPathList.toArray(new String[0]); return selectedPathList.toArray(new String[0]);
} }
public TreePath getNextMatch(String prefix, int startingRow, public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) {
Position.Bias bias) {
int max = getRowCount(); int max = getRowCount();
if (prefix == null) { if (prefix == null) {
@ -78,9 +86,7 @@ public class TemplateFileTree extends EnvFileTree {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
prefix = prefix.toUpperCase(); prefix = prefix.toUpperCase();
// start search from the next/previous element from the selected element
// start search from the next/previous element froom the
// selected element
int increment = (bias == Position.Bias.Forward) ? 1 : -1; int increment = (bias == Position.Bias.Forward) ? 1 : -1;
int row = startingRow; int row = startingRow;
do { do {
@ -96,4 +102,110 @@ public class TemplateFileTree extends EnvFileTree {
} while (row != startingRow); } while (row != startingRow);
return null; return null;
} }
public FileNode[] listFile(String path) {
String username = EnvConfigUtils.getUsername(EnvContext.currentEnv());
String extra = EnvProxy.get(TplFileOperator.class).readExtraResourcePath(path);
return EnvProxy.get(TplFileOperator.class).list(username, extra, path);
}
/*
* 改变Env后,根据构造函数时设置的RootPaths,重新加载
*/
public void refreshEnv(Env env) {
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
rootTreeNode.removeAllChildren();
FileNode[] fns;
// 如果rootPaths是null的话列出所有文件
if (subPathes == null) {
fns = listFileNodes(this.treeRootPath);
} else {
// 重新加载新的FileDirectoryNode
fns = new FileNode[subPathes.length];
for (int i = 0; i < subPathes.length; i++) {
fns[i] = new FileNode(StableUtils.pathJoin(this.treeRootPath, subPathes[i]), true);
}
}
ExpandMutableTreeNode[] subTreeNodes = fileNodeArray2TreeNodeArray(fns);
for (ExpandMutableTreeNode node : subTreeNodes) {
rootTreeNode.add(node);
}
defaultTreeModel.reload(rootTreeNode);
}
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) {
FileNode[] fn_array = listFileNodes(treeNode);
return fileNodeArray2TreeNodeArray(fn_array);
}
/*
* 把FileNode[]转成ExpandMutableTreeNode[]
*/
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode());
}
}
return res;
}
private FileNode[] listFileNodes(String filePath) {
FileNode[] fileNodes = null;
try {
fileNodes = listFile(filePath);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (fileNodes == null) {
fileNodes = new FileNode[0];
}
// 用FileNodeFilter过滤一下
if (filter != null) {
List<FileNode> list = new ArrayList<FileNode>();
for (FileNode fileNode : fileNodes) {
if (filter.accept(fileNode)) {
list.add(fileNode);
}
}
fileNodes = list.toArray(new FileNode[list.size()]);
}
Arrays.sort(fileNodes, new FileNodeComparator());
return fileNodes;
}
/*
* 求当前TreeNode下所有的FileNode.
*/
private FileNode[] listFileNodes(ExpandMutableTreeNode currentTreeNode) {
if (currentTreeNode == null) {
return new FileNode[0];
}
Object object = currentTreeNode.getUserObject();
if (object instanceof FileNode) {
return this.listFileNodes(((FileNode) object).getEnvPath());
}
return new FileNode[0];
}
} }

2
designer-base/src/com/fr/design/mainframe/DesignerFrame.java

@ -6,8 +6,8 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Env; import com.fr.base.Env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;

4
designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java

@ -1,10 +1,10 @@
package com.fr.design.mainframe.loghandler.socketio; package com.fr.design.mainframe.loghandler.socketio;
import com.fr.base.env.EnvContext;
import com.fr.base.env.resource.LocalEnvConfig;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent; import com.fr.core.env.EnvEvent;
import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.design.mainframe.loghandler.DesignerLogHandler;
import com.fr.event.Event; import com.fr.event.Event;

2
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.design.beans.BasicBeanPane;
import com.fr.report.DesignAuthority; import com.fr.report.DesignAuthority;
import javax.swing.*; import javax.swing.Icon;
public class RemoteDesignAuthorityCreator { public class RemoteDesignAuthorityCreator {

72
designer-base/src/com/fr/design/remote/RemoteMember.java

@ -1,72 +0,0 @@
package com.fr.design.remote;
import com.fr.general.Inter;
public class RemoteMember {
public static final RemoteMember DEFAULT_MEMBER =
new RemoteMember(Inter.getLocText("FR-Designer_Remote_Design_Loading"));
private String username;
private String realName;
private String userId;
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;
}
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;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
}

47
designer-base/src/com/fr/design/remote/Utils.java

@ -1,47 +0,0 @@
package com.fr.design.remote;
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.Map;
public class Utils {
private Utils() {
}
public static Collection<? extends RemoteMember> getRemoteMember(String keyword) {
List<UserAdditionBean> userBeans = new ArrayList<>();
try {
Map<String, Object> result =
UserService.getInstance().getAllUsers(
FRContext.getCurrentEnv().getUser(),
1,
10,
keyword,
"",
true);
userBeans = (List<UserAdditionBean>) result.get("items");
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
}
List<RemoteMember> res = new ArrayList<>();
for (UserAdditionBean userBean : userBeans) {
res.add(
new RemoteMember()
.username(userBean.getUsername())
.realName(userBean.getRealName())
.userId(userBean.getId())
);
}
return res;
}
}

18
designer-base/src/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java

@ -2,13 +2,15 @@ package com.fr.design.remote.action;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.env.proxy.EnvProxy;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.remote.ui.AuthorityManagerPane; import com.fr.design.remote.ui.AuthorityManagerPane;
import com.fr.env.RemoteEnv; import com.fr.env.operator.authority.AuthorityOperator;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority; import com.fr.report.DesignAuthority;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -20,7 +22,7 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
public RemoteDesignAuthorityManagerAction() { public RemoteDesignAuthorityManagerAction() {
this.setName(Inter.getLocText("FR-Designer_Remote_Design_Authority_Manager")); this.setName(Inter.getLocText("Fine-Designer_Remote_Design_Authority_Manager"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png")); this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png"));
} }
@ -34,12 +36,13 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
if (!FRContext.getCurrentEnv().isLocalEnv()) { if (!FRContext.getCurrentEnv().isLocalEnv()) {
try { try {
DesignAuthority[] authorities = ((RemoteEnv) FRContext.getCurrentEnv()).getAuthorities(); // 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = EnvProxy.get(AuthorityOperator.class).getAuthorities();
if (authorities != null && authorities.length != 0) { if (authorities != null && authorities.length != 0) {
managerPane.populate(authorities); managerPane.populate(authorities);
} }
} catch (Exception exception) { } catch (Exception exception) {
FRContext.getLogger().error(exception.getMessage()); FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
} }
} }
@ -48,7 +51,12 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
public void doOk() { public void doOk() {
DesignAuthority[] authorities = managerPane.update(); DesignAuthority[] authorities = managerPane.update();
if (!FRContext.getCurrentEnv().isLocalEnv()) { if (!FRContext.getCurrentEnv().isLocalEnv()) {
boolean success = ((RemoteEnv) FRContext.getCurrentEnv()).updateAuthorities(authorities); boolean success = false;
try {
success = EnvProxy.get(AuthorityOperator.class).updateAuthorities(authorities);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
FRContext.getLogger().info("update remote design authority: " + success); FRContext.getLogger().info("update remote design authority: " + success);
} }
} }

59
designer-base/src/com/fr/design/remote/button/IconButton.java

@ -0,0 +1,59 @@
package com.fr.design.remote.button;
import com.fr.base.BaseUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
public final class IconButton extends JButton {
public IconButton() {
super(StringUtils.EMPTY);
setContentAreaFilled(false);
setFocusPainted(false);
setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png"));
setBorder(null);
}
@Override
protected void paintBorder(Graphics g) {
}
@Override
protected void paintComponent(Graphics g) {
final Graphics2D g2 = (Graphics2D) g.create();
g2.setPaint(
new GradientPaint(
new Point(0, 0),
new Color(0xF5F5F7),
new Point(0, getPreferredSize().height),
new Color(0xF5F5F7)
)
);
g2.fillRect(0, 0, getPreferredSize().width, getPreferredSize().height);
g2.dispose();
super.paintComponent(g);
}
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(null);
IconButton a = new IconButton();
a.setBounds(0, 0, a.getPreferredSize().width, a.getPreferredSize().height);
content.add(a);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 400);
jf.setVisible(true);
}
}

18
designer-base/src/com/fr/design/remote/ui/AuthorityEditorPane.java

@ -2,8 +2,8 @@ package com.fr.design.remote.ui;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.icontainer.UIScrollPane; 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.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.remote.ui.tree.FileAuthorityTree; import com.fr.design.remote.ui.tree.FileAuthorityTree;
@ -14,23 +14,28 @@ import com.fr.report.DesignAuthority;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.border.EmptyBorder;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> { public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
private UILabel label = new UILabel();
private FileAuthorityTree tree = new FileAuthorityTree(); private FileAuthorityTree tree = new FileAuthorityTree();
public AuthorityEditorPane() { public AuthorityEditorPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(
this.add(label, BorderLayout.NORTH); BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 6, 6),
UITitledBorder.createBorderWithTitle(
Inter.getLocText("Fine-Designer_Remote_Design_Template_Authority_Config")
)
)
);
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"}); IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"});
tree.setDigIn(true); tree.setDigIn(true);
tree.setFileNodeFilter(filter); tree.setFileNodeFilter(filter);
@ -41,7 +46,7 @@ public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Remote_Design_Configure_Authority"); return Inter.getLocText("Fine-Designer_Remote_Design_Configure_Authority");
} }
@Override @Override
@ -49,7 +54,6 @@ public class AuthorityEditorPane extends BasicBeanPane<DesignAuthority> {
if (ob == null) { if (ob == null) {
return; return;
} }
label.setText(ob.getUsername());
DesignAuthority.Item[] items = ob.getItems(); DesignAuthority.Item[] items = ob.getItems();
if (items == null) { if (items == null) {

24
designer-base/src/com/fr/design/remote/ui/AuthorityListControlPane.java

@ -15,12 +15,13 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut; import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef; import com.fr.design.menu.ToolBarDef;
import com.fr.design.remote.RemoteDesignAuthorityCreator; 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.AuthorityList;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer; import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.env.RemoteDesignMember;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority; import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -77,7 +78,7 @@ public class AuthorityListControlPane extends BasicPane {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.authorityCreators = new RemoteDesignAuthorityCreator[]{ this.authorityCreators = new RemoteDesignAuthorityCreator[]{
new RemoteDesignAuthorityCreator( new RemoteDesignAuthorityCreator(
Inter.getLocText("FR-Designer_Remote_Design_User"), Inter.getLocText("Fine-Designer_Remote_Design_User"),
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"), BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
DesignAuthority.class, DesignAuthority.class,
AuthorityEditorPane.class) AuthorityEditorPane.class)
@ -92,8 +93,8 @@ public class AuthorityListControlPane extends BasicPane {
// 右侧卡片布局 // 右侧卡片布局
cardLayout = new CardLayout(); cardLayout = new CardLayout();
cardPane = new JPanel(cardLayout); cardPane = new JPanel(cardLayout);
UILabel selectLabel = new UILabel(); UILabel emptyLabel = new UILabel();
cardPane.add(selectLabel, UNSELECTED_EDITOR_NAME); cardPane.add(emptyLabel, UNSELECTED_EDITOR_NAME);
cardPane.add(editorCtrl, SELECTED_EDITOR_NAME); cardPane.add(editorCtrl, SELECTED_EDITOR_NAME);
// 左右分割布局 // 左右分割布局
@ -169,7 +170,7 @@ public class AuthorityListControlPane extends BasicPane {
for (int i = 0, len = listModel.getSize(); i < len; i++) { for (int i = 0, len = listModel.getSize(); i < len; i++) {
res.add((DesignAuthority) listModel.getElementAt(i)); res.add((DesignAuthority) listModel.getElementAt(i));
} }
return res.toArray(new DesignAuthority[0]); return res.toArray(new DesignAuthority[res.size()]);
} }
public void populate(DesignAuthority[] authorities) { public void populate(DesignAuthority[] authorities) {
@ -231,6 +232,12 @@ public class AuthorityListControlPane extends BasicPane {
public void addAuthority(DesignAuthority authority, int index) { public void addAuthority(DesignAuthority authority, int index) {
DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel(); DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel();
for (int i = 0; i < model.size(); i++) {
if (model.get(i).getUserId().equals(authority.getUserId())) {
return;
}
}
model.add(index, authority); model.add(index, authority);
authorityList.setSelectedIndex(index); authorityList.setSelectedIndex(index);
authorityList.ensureIndexIsVisible(index); authorityList.ensureIndexIsVisible(index);
@ -318,7 +325,7 @@ public class AuthorityListControlPane extends BasicPane {
if (p[i] != null) { if (p[i] != null) {
try { try {
p[i].checkValid(); p[i].checkValid();
} catch (Exception e) { } catch (Exception ignore) {
return i; return i;
} }
} }
@ -333,6 +340,7 @@ public class AuthorityListControlPane extends BasicPane {
try { try {
checkValid(); checkValid();
} catch (Exception exp) { } catch (Exception exp) {
FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
JOptionPane.showMessageDialog(AuthorityListControlPane.this, exp.getMessage()); JOptionPane.showMessageDialog(AuthorityListControlPane.this, exp.getMessage());
authorityList.setSelectedIndex(idx); authorityList.setSelectedIndex(idx);
return true; return true;
@ -476,8 +484,8 @@ public class AuthorityListControlPane extends BasicPane {
@Override @Override
public void doOk() { public void doOk() {
// 获取添加的用户到权限编辑面板 // 获取添加的用户到权限编辑面板
List<RemoteMember> members = userManagerPane.update(); List<RemoteDesignMember> members = userManagerPane.update();
for (RemoteMember member : members) { for (RemoteDesignMember member : members) {
DesignAuthority authority = new DesignAuthority(); DesignAuthority authority = new DesignAuthority();
authority.setUsername(member.getUsername()); authority.setUsername(member.getUsername());
authority.setUserId(member.getUserId()); authority.setUserId(member.getUserId());

3
designer-base/src/com/fr/design/remote/ui/AuthorityManagerPane.java

@ -6,7 +6,6 @@ import com.fr.report.DesignAuthority;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.util.Arrays;
public class AuthorityManagerPane extends BasicPane { public class AuthorityManagerPane extends BasicPane {
@ -24,7 +23,7 @@ public class AuthorityManagerPane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Remote_Design_Authority_Manager"); return Inter.getLocText("Fine-Designer_Remote_Design_Authority_Manager");
} }
public void populate(DesignAuthority[] authorities) { public void populate(DesignAuthority[] authorities) {

78
designer-base/src/com/fr/design/remote/ui/UserManagerPane.java

@ -1,5 +1,8 @@
package com.fr.design.remote.ui; package com.fr.design.remote.ui;
import com.fr.base.env.EnvContext;
import com.fr.base.env.proxy.EnvProxy;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
@ -8,13 +11,13 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; 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.AddedMemberList;
import com.fr.design.remote.ui.list.AddedMemberListCellRender; import com.fr.design.remote.ui.list.AddedMemberListCellRender;
import com.fr.design.remote.ui.list.AddingMemberList; import com.fr.design.remote.ui.list.AddingMemberList;
import com.fr.design.remote.ui.list.AddingMemberListCellRender; import com.fr.design.remote.ui.list.AddingMemberListCellRender;
import com.fr.design.remote.ui.list.MemberListSelectedChangeListener; import com.fr.design.remote.ui.list.MemberListSelectedChangeListener;
import com.fr.env.RemoteDesignMember;
import com.fr.env.operator.decision.DecisionOperator;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.ImmutableList; import com.fr.third.guava.collect.ImmutableList;
@ -26,6 +29,7 @@ import javax.swing.ListSelectionModel;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
@ -46,16 +50,16 @@ public class UserManagerPane extends BasicPane {
/** /**
* 获取的决策平台成员 * 获取的决策平台成员
*/ */
private List<RemoteMember> addingMembers = new ArrayList<>(); private List<RemoteDesignMember> addingMembers = new ArrayList<>();
/** /**
* 添加到设计的决策平台成员 * 添加到设计的决策平台成员
*/ */
private List<RemoteMember> addedMembers = new ArrayList<>(); private List<RemoteDesignMember> addedMembers = new ArrayList<>();
/** /**
* 决策平台成员列表model * 决策平台成员列表model
*/ */
private DefaultListModel<RemoteMember> addingListModel = new DefaultListModel<>(); private DefaultListModel<RemoteDesignMember> addingListModel = new DefaultListModel<>();
/** /**
* 搜索输入框 * 搜索输入框
*/ */
@ -95,18 +99,25 @@ public class UserManagerPane extends BasicPane {
/** /**
* 添加到设计的决策成员计数标签 * 添加到设计的决策成员计数标签
*/ */
private DefaultListModel<RemoteMember> addedListModel; private DefaultListModel<RemoteDesignMember> addedListModel;
/**
* 左侧列表变动事件
*/
private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() { private MemberListSelectedChangeListener addingListChangeListener = new MemberListSelectedChangeListener() {
@Override @Override
public void selectedChange() { public void selectedChange() {
resetAddedMembers(); // 右侧列表发生变化后,将右侧列表中选中但是在左侧列表中没有的成员添加进来,同时移除取消选中的
sync2AddedMembersFromAdding(); sync2AddedMembersFromAdding();
// 刷新右侧列表显示
addToAddedMemberList(); addToAddedMemberList();
} }
}; };
/**
* 右侧列表变动事件
*/
private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() { private MemberListSelectedChangeListener addedListChangeListener = new MemberListSelectedChangeListener() {
@Override @Override
public void selectedChange() { public void selectedChange() {
@ -116,10 +127,12 @@ public class UserManagerPane extends BasicPane {
sync2AddedMembersFormAdded(); sync2AddedMembersFormAdded();
// 不需要重复更新右侧列表显示 但是更新一下计数显示 // 不需要重复更新右侧列表显示 但是更新一下计数显示
countLabel.setText( countLabel.setText(
Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count", Inter.getLocText("Fine-Designer_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size()) String.valueOf(addedMembers.size())
) )
); );
// 刷新左侧列表显示
addToMemberList();
} }
}; };
@ -144,7 +157,7 @@ public class UserManagerPane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return Inter.getLocText("FR-Designer_Remote_Design_Add_Member"); return Inter.getLocText("Fine-Designer_Remote_Design_Add_Member");
} }
private JPanel createLeftPanel() { private JPanel createLeftPanel() {
@ -154,7 +167,7 @@ public class UserManagerPane extends BasicPane {
BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0), new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle( UITitledBorder.createBorderWithTitle(
Inter.getLocText("FR-Designer_Remote_Design_Decision_Member") Inter.getLocText("Fine-Designer_Remote_Design_Decision_Member")
) )
) )
); );
@ -162,10 +175,10 @@ public class UserManagerPane extends BasicPane {
// 搜索 // 搜索
JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
searchPanel.setBorder(BorderFactory.createEmptyBorder()); searchPanel.setBorder(BorderFactory.createEmptyBorder());
keyField.setPreferredSize(new Dimension(200, 20)); keyField.setPreferredSize(new Dimension(250, 20));
keyField.requestFocus(); keyField.requestFocus();
keyField.addKeyListener(keyFieldKeyListener); keyField.addKeyListener(keyFieldKeyListener);
keyButton.setText(Inter.getLocText("FR-Designer_Remote_Design_Search")); keyButton.setText(Inter.getLocText("Fine-Designer_Remote_Design_Search"));
keyButton.addActionListener(keyButtonActionListener); keyButton.addActionListener(keyButtonActionListener);
searchPanel.add(keyField); searchPanel.add(keyField);
searchPanel.add(keyButton); searchPanel.add(keyButton);
@ -194,16 +207,18 @@ public class UserManagerPane extends BasicPane {
BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0), new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle( UITitledBorder.createBorderWithTitle(
Inter.getLocText("FR-Designer_Remote_Design_Selected_Member") Inter.getLocText("Fine-Designer_Remote_Design_Selected_Member")
) )
) )
); );
// 计数 // 计数
countLabel.setText( countLabel.setText(
Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count", Inter.getLocText("Fine-Designer_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size())) String.valueOf(addedMembers.size()))
); );
countLabel.setBorder(BorderFactory.createEmptyBorder(7, 12, 8, 0));
countLabel.setForeground(new Color(0x8F8F92));
addedListModel = new DefaultListModel<>(); addedListModel = new DefaultListModel<>();
addedList = new AddedMemberList(addedListModel); addedList = new AddedMemberList(addedListModel);
@ -224,7 +239,13 @@ public class UserManagerPane extends BasicPane {
private void addToMemberList() { private void addToMemberList() {
addingListModel.clear(); addingListModel.clear();
for (RemoteMember member : addingMembers) { for (RemoteDesignMember member : addingMembers) {
// 如果包含在右侧列表中,那么左侧列表默认选中
if (addedMembers.contains(member)) {
member.setSelected(true);
} else {
member.setSelected(false);
}
addingListModel.addElement(member); addingListModel.addElement(member);
} }
addingList.revalidate(); addingList.revalidate();
@ -233,20 +254,20 @@ public class UserManagerPane extends BasicPane {
private void addToAddedMemberList() { private void addToAddedMemberList() {
addedListModel.clear(); addedListModel.clear();
for (RemoteMember member : addedMembers) { for (RemoteDesignMember member : addedMembers) {
addedListModel.addElement(member); addedListModel.addElement(member);
} }
addedList.revalidate(); addedList.revalidate();
addedList.repaint(); addedList.repaint();
countLabel.setText( countLabel.setText(
Inter.getLocText("FR-Designer_Remote_Design_Selected_Member_Count", Inter.getLocText("Fine-Designer_Remote_Design_Selected_Member_Count",
String.valueOf(addedMembers.size()) String.valueOf(addedMembers.size())
)); ));
} }
private void resetMembers() { private void resetMembers() {
addingMembers.clear(); addingMembers.clear();
addingMembers.add(RemoteMember.DEFAULT_MEMBER); addingMembers.add(RemoteDesignMember.DEFAULT_MEMBER);
} }
private void resetAddedMembers() { private void resetAddedMembers() {
@ -256,11 +277,12 @@ public class UserManagerPane extends BasicPane {
private void searchAddingMembers(final String keyword) { private void searchAddingMembers(final String keyword) {
final SwingWorker getMemberWorker = new SwingWorker<List<RemoteMember>, Void>() { final SwingWorker getMemberWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override @Override
protected List<RemoteMember> doInBackground() { protected List<RemoteDesignMember> doInBackground() {
addingMembers.clear(); addingMembers.clear();
addingMembers.addAll(Utils.getRemoteMember(keyword)); String username = EnvConfigUtils.getUsername(EnvContext.currentEnv());
addingMembers.addAll(EnvProxy.get(DecisionOperator.class).getMembers(username, keyword));
return addingMembers; return addingMembers;
} }
@ -274,25 +296,29 @@ public class UserManagerPane extends BasicPane {
private void sync2AddedMembersFromAdding() { private void sync2AddedMembersFromAdding() {
RemoteMember[] members = new RemoteMember[addingListModel.getSize()]; RemoteDesignMember[] members = new RemoteDesignMember[addingListModel.getSize()];
// shallow copy // shallow copy
addingListModel.copyInto(members); addingListModel.copyInto(members);
for (RemoteMember member : members) { for (RemoteDesignMember member : members) {
if (member.isSelected()) {
if (!member.isSelected()) {
addedMembers.remove(member);
}
if (member.isSelected() && !addedMembers.contains(member)) {
addedMembers.add(member); addedMembers.add(member);
} }
} }
} }
private void sync2AddedMembersFormAdded() { private void sync2AddedMembersFormAdded() {
RemoteMember[] members = new RemoteMember[addedListModel.getSize()]; RemoteDesignMember[] members = new RemoteDesignMember[addedListModel.getSize()];
// shallow copy // shallow copy
addedListModel.copyInto(members); addedListModel.copyInto(members);
addedMembers.addAll(Arrays.asList(members)); addedMembers.addAll(Arrays.asList(members));
} }
public ImmutableList<RemoteMember> update() { public ImmutableList<RemoteDesignMember> update() {
return ImmutableList.copyOf(addedMembers); return ImmutableList.copyOf(addedMembers);
} }
} }

25
designer-base/src/com/fr/design/remote/ui/list/AddedMemberList.java

@ -1,8 +1,9 @@
package com.fr.design.remote.ui.list; package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember; import com.fr.env.RemoteDesignMember;
import javax.swing.*; import javax.swing.DefaultListModel;
import java.awt.Point;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
@ -12,30 +13,38 @@ public class AddedMemberList extends MemberList {
super(); super();
} }
public AddedMemberList(DefaultListModel<RemoteMember> dataModel) { public AddedMemberList(DefaultListModel<RemoteDesignMember> dataModel) {
super(dataModel); super(dataModel);
} }
public AddedMemberList(RemoteMember[] listData) { public AddedMemberList(RemoteDesignMember[] listData) {
super(listData); super(listData);
} }
public AddedMemberList(Vector<? extends RemoteMember> listData) { public AddedMemberList(Vector<? extends RemoteDesignMember> listData) {
super(listData); super(listData);
} }
@Override @Override
protected boolean shouldDisplaySelected(MouseEvent e) { protected boolean shouldDisplaySelected(MouseEvent e) {
return true; Point point = e.getPoint();
int rX = point.x;
int rY = point.y;
int index = this.getSelectedIndex();
int x = 280;
int y = 25 * index;
int width = 20;
int height = 25;
return x <= rX && rX <= x + width && y <= rY && rY <= y + height;
} }
@Override @Override
protected void displaySelected() { protected void displaySelected() {
RemoteMember member = getSelectedValue(); RemoteDesignMember member = getSelectedValue();
if (member != null) { if (member != null) {
member.setSelected(!member.isSelected()); member.setSelected(!member.isSelected());
((DefaultListModel<RemoteMember>) getModel()).removeElement(member); ((DefaultListModel<RemoteDesignMember>) getModel()).removeElement(member);
} }
revalidate(); revalidate();
repaint(); repaint();

21
designer-base/src/com/fr/design/remote/ui/list/AddedMemberListCellRender.java

@ -1,45 +1,44 @@
package com.fr.design.remote.ui.list; package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.remote.RemoteMember; import com.fr.design.remote.button.IconButton;
import com.fr.env.RemoteDesignMember;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteMember> { public class AddedMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
private UILabel label; private UILabel label;
private UIButton uiButton;
public AddedMemberListCellRender() { public AddedMemberListCellRender() {
this.setBorder(BorderFactory.createEmptyBorder()); this.setBorder(BorderFactory.createEmptyBorder());
this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.setLayout(new FlowLayout(FlowLayout.LEFT));
label = new UILabel(); label = new UILabel();
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
label.setPreferredSize(new Dimension(270, 20));
uiButton = new UIButton(); this.setPreferredSize(new Dimension(this.getPreferredSize().width, 25));
uiButton.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remove_x.png"));
this.add(label); this.add(label);
this.add(uiButton); this.add(new IconButton());
} }
@Override @Override
public Component getListCellRendererComponent(JList<? extends RemoteMember> list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList<? extends RemoteDesignMember> list, RemoteDesignMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelText(member.getUsername()); this.setLabelText(member.getRealName() + "(" + member.getUsername() + ")");
return this; return this;
} }
private void setLabelText(String name) { private void setLabelText(String name) {
label.setText(name); label.setText(name);
} }
} }

21
designer-base/src/com/fr/design/remote/ui/list/AddingMemberList.java

@ -1,8 +1,9 @@
package com.fr.design.remote.ui.list; package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember; import com.fr.env.RemoteDesignMember;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import java.awt.Point;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
@ -13,23 +14,23 @@ public class AddingMemberList extends MemberList {
super(); super();
} }
public AddingMemberList(DefaultListModel<RemoteMember> dataModel) { public AddingMemberList(DefaultListModel<RemoteDesignMember> dataModel) {
super(dataModel); super(dataModel);
} }
public AddingMemberList(RemoteMember[] listData) { public AddingMemberList(RemoteDesignMember[] listData) {
super(listData); super(listData);
} }
public AddingMemberList(Vector<? extends RemoteMember> listData) { public AddingMemberList(Vector<? extends RemoteDesignMember> listData) {
super(listData); super(listData);
} }
@Override @Override
protected void displaySelected() { protected void displaySelected() {
RemoteMember member = getSelectedValue(); RemoteDesignMember member = getSelectedValue();
member.setSelected(!member.isSelected()); member.setSelected(!member.isSelected());
revalidate(); revalidate();
repaint(); repaint();
@ -38,7 +39,15 @@ public class AddingMemberList extends MemberList {
@Override @Override
protected boolean shouldDisplaySelected(MouseEvent e) { protected boolean shouldDisplaySelected(MouseEvent e) {
return true; Point point = e.getPoint();
int rX = point.x;
int rY = point.y;
int index = this.getSelectedIndex();
int x = 280;
int y = 25 * index;
int width = 25;
int height = 25;
return x <= rX && rX <= x + width && y <= rY && rY <= y + height;
} }
} }

11
designer-base/src/com/fr/design/remote/ui/list/AddingMemberListCellRender.java

@ -3,16 +3,17 @@ package com.fr.design.remote.ui.list;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.remote.RemoteMember; import com.fr.env.RemoteDesignMember;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
public class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteMember> { public class AddingMemberListCellRender extends JPanel implements ListCellRenderer<RemoteDesignMember> {
private UILabel label; private UILabel label;
private UICheckBox check; private UICheckBox check;
@ -23,6 +24,8 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender
this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.setLayout(new FlowLayout(FlowLayout.LEFT));
label = new UILabel(); label = new UILabel();
label.setPreferredSize(new Dimension(270, 20));
this.setPreferredSize(new Dimension(this.getPreferredSize().width, 25));
label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); label.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
check = new UICheckBox(); check = new UICheckBox();
@ -35,8 +38,8 @@ public class AddingMemberListCellRender extends JPanel implements ListCellRender
@Override @Override
public Component getListCellRendererComponent(JList list, RemoteMember member, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, RemoteDesignMember member, int index, boolean isSelected, boolean cellHasFocus) {
this.setLabelText(member.getUsername()); this.setLabelText(member.getRealName() + "(" + member.getUsername() + ")");
check.setSelected(member.isSelected()); check.setSelected(member.isSelected());
return this; return this;
} }

2
designer-base/src/com/fr/design/remote/ui/list/AuthorityListCellRenderer.java

@ -82,7 +82,7 @@ public class AuthorityListCellRenderer extends
setBorder(border); setBorder(border);
this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png")); this.setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"));
this.setText(authority.getUsername()); this.setText(authority.getRealName() + "(" + authority.getUsername() + ")");
return this; return this;
} }

11
designer-base/src/com/fr/design/remote/ui/list/MemberList.java

@ -1,6 +1,7 @@
package com.fr.design.remote.ui.list; package com.fr.design.remote.ui.list;
import com.fr.design.remote.RemoteMember;
import com.fr.env.RemoteDesignMember;
import javax.swing.DefaultListModel; import javax.swing.DefaultListModel;
import javax.swing.JList; import javax.swing.JList;
@ -12,19 +13,19 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.Vector; import java.util.Vector;
public abstract class MemberList extends JList<RemoteMember> { public abstract class MemberList extends JList<RemoteDesignMember> {
public MemberList(DefaultListModel<RemoteMember> dataModel) { public MemberList(DefaultListModel<RemoteDesignMember> dataModel) {
super(dataModel); super(dataModel);
init(); init();
} }
public MemberList(RemoteMember[] listData) { public MemberList(RemoteDesignMember[] listData) {
super(listData); super(listData);
init(); init();
} }
public MemberList(Vector<? extends RemoteMember> listData) { public MemberList(Vector<? extends RemoteDesignMember> listData) {
super(listData); super(listData);
init(); init();
} }

4
designer-base/src/com/fr/env/EnvListPane.java vendored

@ -1,8 +1,8 @@
package com.fr.env; package com.fr.env;
import com.fr.base.env.resource.LocalEnvConfig;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameObjectCreator;

3
designer-base/src/com/fr/env/LocalEnvPane.java vendored

@ -1,7 +1,6 @@
package com.fr.env; package com.fr.env;
import com.fr.base.env.resource.LocalEnvConfig; import com.fr.core.env.resource.LocalEnvConfig;
import com.fr.dav.LocalEnv;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;

6
designer-base/src/com/fr/env/RemoteEnv.java vendored

@ -1,15 +1,15 @@
package com.fr.env; package com.fr.env;
import com.fr.base.env.old.AbstractEnv;
import com.fr.base.EnvException; import com.fr.base.EnvException;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.env.EnvContext;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.base.remote.RemoteDeziConstants; import com.fr.base.remote.RemoteDeziConstants;
import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.dav.AbstractEnv;
import com.fr.dav.DavXMLUtils; import com.fr.dav.DavXMLUtils;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;

4
designer-base/src/com/fr/env/RemoteEnvPane.java vendored

@ -1,8 +1,8 @@
package com.fr.env; package com.fr.env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.env.resource.EnvConfigUtils; import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.base.env.resource.RemoteEnvConfig; import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;

6
designer-base/src/com/fr/env/SignIn.java vendored

@ -2,11 +2,11 @@ package com.fr.env;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.env.EnvContext;
import com.fr.base.env.resource.EnvConfigUtils;
import com.fr.base.env.resource.RemoteEnvConfig;
import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvConfig;
import com.fr.core.env.EnvContext;
import com.fr.core.env.EnvEvent; import com.fr.core.env.EnvEvent;
import com.fr.core.env.resource.EnvConfigUtils;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.dav.LocalEnv; import com.fr.dav.LocalEnv;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.event.Event; import com.fr.event.Event;

Loading…
Cancel
Save