ju 7 years ago
parent
commit
2ed28583ef
  1. 24
      designer-base/src/com/fr/design/DesignerEnvManager.java
  2. 16
      designer-base/src/com/fr/design/actions/file/SwitchExistEnv.java
  3. 119
      designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java
  4. 70
      designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java
  5. 83
      designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  6. 25
      designer-base/src/com/fr/design/gui/controlpane/JListControlPane.java
  7. 11
      designer-base/src/com/fr/env/EnvListPane.java
  8. 10
      designer-base/src/com/fr/env/LocalEnvPane.java
  9. 32
      designer-base/src/com/fr/env/RemoteEnvPane.java
  10. 3
      designer-realize/src/com/fr/start/EnvSwitcher.java

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

@ -10,6 +10,8 @@ import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.file.FILEFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogFormatter;
@ -33,9 +35,10 @@ import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.SwingWorker;
import javax.swing.SwingWorker.StateValue;
import java.awt.*;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
@ -193,7 +196,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (installHome != null && !".".equals(installHome)) {
String name = Inter.getLocText("FR-Engine_DEFAULT");
String envPath = StableUtils.pathJoin(installHome, ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBINF_NAME);
designerEnvManager.putEnv(name, DesignerWorkspaceInfo.createLocal(name, envPath));
designerEnvManager.putEnv(name, LocalDesignerWorkspaceInfo.create(name, envPath));
designerEnvManager.setCurEnvName(name);
}
}
@ -495,7 +498,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
}
}
String name = Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"});
DesignerWorkspaceInfo newDefaultEnv = DesignerWorkspaceInfo.createLocal(name, defaultenvPath);
LocalDesignerWorkspaceInfo newDefaultEnv = LocalDesignerWorkspaceInfo.create(name, defaultenvPath);
this.putEnv(name, newDefaultEnv);
return newDefaultEnv;
}
@ -702,7 +705,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* 记录名称 和对应的环境
*
* @param name 名称
* @param info 对应的环境信息
* @param info 对应的环境信息
*/
public void putEnv(String name, DesignerWorkspaceInfo info) {
@ -1419,7 +1422,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
// marks:兼容6.1的
// marks:设置默认的目录.
String curReportServerName = Inter.getLocText("Server-Embedded_Server");
DesignerWorkspaceInfo reportServer = DesignerWorkspaceInfo.createLocal(curReportServerName, tmpVal);
LocalDesignerWorkspaceInfo reportServer = LocalDesignerWorkspaceInfo.create(curReportServerName, tmpVal);
this.putEnv(curReportServerName, reportServer);
this.setCurEnvName(curReportServerName);
@ -1472,8 +1475,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if (DesignerWorkspaceInfo.XML_TAG.equals(tagName)) {
DesignerWorkspaceInfo envConfig = (DesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader);
if (LocalDesignerWorkspaceInfo.XML_TAG.equals(tagName)) {
LocalDesignerWorkspaceInfo envConfig = (LocalDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader);
putEnv(name, envConfig);
} else if (RemoteDesignerWorkspaceInfo.XML_TAG.equals(tagName)) {
RemoteDesignerWorkspaceInfo envConfig = (RemoteDesignerWorkspaceInfo) GeneralXMLTools.readXMLable(reader);
putEnv(name, envConfig);
}
}
@ -1599,7 +1605,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
for (Entry<String, DesignerWorkspaceInfo> entry : nameEnvMap.entrySet()) {
writer.startTAG("EnvConfigElement").attr("name", entry.getKey());
DesignerWorkspaceInfo envConfig = entry.getValue();
GeneralXMLTools.writeXMLable(writer, envConfig, DesignerWorkspaceInfo.XML_TAG);
GeneralXMLTools.writeXMLable(writer, envConfig, envConfig.XML_TAG);
writer.end();
}
writer.end();

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

@ -21,7 +21,7 @@ import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import javax.swing.*;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Iterator;
@ -66,15 +66,15 @@ public class SwitchExistEnv extends MenuDef {
public GetExistEnvAction(String envName) {
this.setName(envName);
DesignerWorkspaceInfo env = DesignerEnvManager.getEnvManager().getWorkspaceInfo(envName);
switch (env.getType())
{
case Local:{
switch (env.getType()) {
case Local: {
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
break;
}case Remote:{
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
break;
}
}
case Remote: {
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
break;
}
}
}

119
designer-base/src/com/fr/design/env/DesignerWorkspaceInfo.java vendored

@ -1,117 +1,14 @@
package com.fr.design.env;
import com.fr.security.SecurityToolbox;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnection;
/**
* Created by juhaoyu on 2018/6/15.
*/
public class DesignerWorkspaceInfo implements XMLable {
private static final int DEFAULT_RPC_PORT = 39999;
public static final String XML_TAG = "DesignerWorkspace";
private DesignerWorkspaceType type;
private String name;
private String path;
private WorkspaceConnection connection;
public static DesignerWorkspaceInfo createLocal(String name, String path) {
DesignerWorkspaceInfo info = new DesignerWorkspaceInfo();
info.connection = null;
info.name = name;
info.path = path;
info.type = DesignerWorkspaceType.Local;
return info;
}
public void setName(String name) {
this.name = name;
}
public DesignerWorkspaceType getType() {
return type;
}
public String getName() {
return name;
}
public String getPath() {
return path;
}
public WorkspaceConnection getConnection() {
return connection;
}
public void setType(DesignerWorkspaceType type) {
this.type = type;
}
public void setPath(String path) {
this.path = path;
}
public void setConnection(WorkspaceConnection connection) {
this.connection = connection;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
this.type = DesignerWorkspaceType.valueOf(reader.getAttrAsString("type", "Local"));
this.path = reader.getAttrAsString("path", StringUtils.EMPTY);
}
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if ("Connection".equals(tagName)) {
String url = reader.getAttrAsString("url", StringUtils.EMPTY);
String username = reader.getAttrAsString("username", StringUtils.EMPTY);
//密码解密
String password = SecurityToolbox.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY));
this.connection = new WorkspaceConnection(url, username, password);
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name);
writer.attr("path", path);
writer.attr("type", type.toString());
if (this.connection != null) {
writer.startTAG("Connection");
writer.attr("url", connection.getUrl());
writer.attr("username", connection.getUserName());
writer.attr("password", SecurityToolbox.encrypt(connection.getPassword()));
writer.end();
}
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
public interface DesignerWorkspaceInfo extends XMLable {
DesignerWorkspaceType getType();
String getName();
String getPath();
WorkspaceConnection getConnection();
}

70
designer-base/src/com/fr/design/env/LocalDesignerWorkspaceInfo.java vendored

@ -0,0 +1,70 @@
package com.fr.design.env;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnection;
/**
* Created by juhaoyu on 2018/6/15.
*/
public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
public static final String XML_TAG = "LocalDesignerWorkspaceInfo";
private String name;
private String path;
public static LocalDesignerWorkspaceInfo create(String name, String path) {
LocalDesignerWorkspaceInfo info = new LocalDesignerWorkspaceInfo();
info.name = name;
info.path = path;
return info;
}
@Override
public DesignerWorkspaceType getType() {
return DesignerWorkspaceType.Local;
}
@Override
public String getName() {
return name;
}
@Override
public String getPath() {
return path;
}
@Override
public WorkspaceConnection getConnection() {
return null;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
this.path = reader.getAttrAsString("path", StringUtils.EMPTY);
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name);
writer.attr("path", path);
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
}

83
designer-base/src/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -0,0 +1,83 @@
package com.fr.design.env;
import com.fr.security.SecurityToolbox;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnection;
public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
public static final String XML_TAG = "RemoteDesignerWorkspaceInfo";
private String name;
private WorkspaceConnection connection;
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnection connection) {
RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo();
info.connection = connection;
return info;
}
@Override
public DesignerWorkspaceType getType() {
return DesignerWorkspaceType.Remote;
}
@Override
public String getName() {
return name;
}
@Override
public String getPath() {
return null;
}
@Override
public WorkspaceConnection getConnection() {
return connection;
}
@Override
public void readXML(XMLableReader reader) {
if (reader.isAttr()) {
this.name = reader.getAttrAsString("name", StringUtils.EMPTY);
}
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if ("Connection".equals(tagName)) {
String url = reader.getAttrAsString("url", StringUtils.EMPTY);
String username = reader.getAttrAsString("username", StringUtils.EMPTY);
//密码解密
String password = SecurityToolbox.decrypt(reader.getAttrAsString("password", StringUtils.EMPTY));
this.connection = new WorkspaceConnection(url, username, password);
}
}
}
@Override
public void writeXML(XMLPrintWriter writer) {
writer.attr("name", name);
if (this.connection != null) {
writer.startTAG("Connection");
writer.attr("url", connection.getUrl());
writer.attr("username", connection.getUserName());
writer.attr("password", SecurityToolbox.encrypt(connection.getPassword()));
writer.end();
}
}
@Override
public Object clone() throws CloneNotSupportedException {
return null;
}
}

25
designer-base/src/com/fr/design/gui/controlpane/JListControlPane.java

@ -25,10 +25,20 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -383,7 +393,7 @@ public abstract class JListControlPane extends JControlPane {
private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) {
if (!HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName())) {
if (filterNameableCreator(creator)) {
continue;
}
boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) ||
@ -942,6 +952,7 @@ public abstract class JListControlPane extends JControlPane {
}
return false;
}
/**
* 设置选中项
*
@ -951,4 +962,12 @@ public abstract class JListControlPane extends JControlPane {
nameableList.setSelectedIndex(index);
}
/**
* 用于在list面板中过滤某些下拉选项
* @return true过滤掉这个creator
*/
protected boolean filterNameableCreator(NameableCreator creator) {
return !HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName());
}
}

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

@ -2,6 +2,8 @@ package com.fr.env;
import com.fr.design.DesignerEnvManager;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
@ -57,9 +59,9 @@ public class EnvListPane extends JListControlPane {
@Override
public NameableCreator[] createNameableCreators() {
NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png",
DesignerWorkspaceInfo.class, LocalEnvPane.class);
LocalDesignerWorkspaceInfo.class, LocalEnvPane.class);
NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png",
DesignerWorkspaceInfo.class, RemoteEnvPane.class);
RemoteDesignerWorkspaceInfo.class, RemoteEnvPane.class);
return new NameableCreator[]{local, remote};
}
@ -106,4 +108,9 @@ public class EnvListPane extends JListControlPane {
}
return this.getSelectedName();
}
@Override
protected boolean filterNameableCreator(NameableCreator creator) {
return false;
}
}

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

@ -1,7 +1,7 @@
package com.fr.env;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.itextfield.UITextField;
@ -21,7 +21,7 @@ import java.io.File;
/**
* @author yaohwu
*/
public class LocalEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
public class LocalEnvPane extends BasicBeanPane<LocalDesignerWorkspaceInfo> {
private UITextField pathTextField;
private JFileTree localEnvTree;
@ -70,9 +70,9 @@ public class LocalEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
}
@Override
public DesignerWorkspaceInfo updateBean() {
public LocalDesignerWorkspaceInfo updateBean() {
String path = pathTextField.getText();
return DesignerWorkspaceInfo.createLocal(StringUtils.EMPTY, path);
return LocalDesignerWorkspaceInfo.create(StringUtils.EMPTY, path);
}
public String getPath() {
@ -80,7 +80,7 @@ public class LocalEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
}
@Override
public void populateBean(DesignerWorkspaceInfo ob) {
public void populateBean(LocalDesignerWorkspaceInfo ob) {
if (StringUtils.isBlank(ob.getPath())) {
return;
}

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

@ -3,8 +3,7 @@ package com.fr.env;
import com.fr.design.DesignerEnvManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
@ -56,7 +55,7 @@ import static com.fr.third.guava.base.Optional.fromNullable;
/**
* @author yaohwu
*/
public class RemoteEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
private static final Color TIPS_FONT_COLOR = new Color(0x8f8f92);
@ -261,11 +260,18 @@ public class RemoteEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
}
@Override
public void populateBean(DesignerWorkspaceInfo ob) {
public void populateBean(RemoteDesignerWorkspaceInfo ob) {
WorkspaceConnection connection = ob.getConnection();
this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl())
? RemoteEnvURL.createDefaultURL()
: new RemoteEnvURL(connection.getUrl());
if (connection != null) {
this.remoteEnvURL = Strings.isNullOrEmpty(connection.getUrl())
? RemoteEnvURL.createDefaultURL()
: new RemoteEnvURL(connection.getUrl());
String username = fromNullable(connection.getUserName()).or(StringUtils.EMPTY);
String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY);
this.usernameInput.setText(username);
this.passwordInput.setText(pwd);
}
fillRemoteEnvURLField();
fillIndividualField();
httpsCheckbox.setSelected(this.remoteEnvURL.getHttps());
@ -274,21 +280,17 @@ public class RemoteEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
fileChooserButton.setEnabled(this.remoteEnvURL.getHttps());
updateHttpsConfigPanel();
this.usernameInput.setText(fromNullable(connection.getUserName()).or(StringUtils.EMPTY));
this.passwordInput.setText(fromNullable(connection.getPassword()).or(StringUtils.EMPTY));
}
@Override
public DesignerWorkspaceInfo updateBean() {
public RemoteDesignerWorkspaceInfo updateBean() {
WorkspaceConnection connection = new WorkspaceConnection(
this.remoteEnvURL.getURL(),
this.usernameInput.getText(),
new String(this.passwordInput.getPassword()));
DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
config.setConnection(connection);
config.setType(DesignerWorkspaceType.Remote);
return config;
return RemoteDesignerWorkspaceInfo.create(connection);
}
@Override
@ -472,7 +474,7 @@ public class RemoteEnvPane extends BasicBeanPane<DesignerWorkspaceInfo> {
@Override
protected Void doInBackground() throws Exception {
final DesignerWorkspaceInfo remoteEnv = updateBean();
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
WorkContext.getConnector().testConnection(remoteEnv.getConnection());
return null;
}

3
designer-realize/src/com/fr/start/EnvSwitcher.java

@ -19,8 +19,9 @@ public class EnvSwitcher {
Workspace workspace = DesignerWorkspaceGenerator.generate(DesignerEnvManager.getEnvManager().getWorkspaceInfo(current));
if (workspace == null) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
} else {
WorkContext.switchTo(workspace);
}
WorkContext.switchTo(workspace);
} catch (Throwable e) {
TemplatePane.getInstance().dealEvnExceptionWhenStartDesigner();
}

Loading…
Cancel
Save