Browse Source

无JIRA任务 远程设计界面配置对应修改(部分)

master
richie 7 years ago
parent
commit
29a7ae32b6
  1. 26
      designer-base/src/com/fr/design/gui/itextfield/PlaceholderTextField.java
  2. 2
      designer-base/src/com/fr/design/gui/itextfield/UIIntNumberField.java
  3. 32
      designer-base/src/com/fr/design/gui/itextfield/UITextField.java
  4. 5
      designer-base/src/com/fr/env/EnvListPane.java
  5. 42
      designer-base/src/com/fr/env/RemoteEnv.java
  6. 145
      designer-base/src/com/fr/env/RemoteEnvPane2.java
  7. 1
      designer-realize/src/com/fr/design/report/freeze/RowSpinner.java

26
designer-base/src/com/fr/design/gui/itextfield/PlaceholderTextField.java

@ -1,12 +1,9 @@
package com.fr.design.gui.itextfield; package com.fr.design.gui.itextfield;
import javax.swing.text.Document; import javax.swing.text.Document;
import java.awt.*;
public class PlaceholderTextField extends UITextField { public class PlaceholderTextField extends UITextField {
private String placeholder;
public PlaceholderTextField() { public PlaceholderTextField() {
} }
@ -28,27 +25,4 @@ public class PlaceholderTextField extends UITextField {
public PlaceholderTextField(final String pText, final int pColumns) { public PlaceholderTextField(final String pText, final int pColumns) {
super(pText, pColumns); super(pText, pColumns);
} }
public String getPlaceholder() {
return placeholder;
}
@Override
protected void paintComponent(final Graphics pG) {
super.paintComponent(pG);
if (placeholder.length() == 0 || getText().length() > 0) {
return;
}
final Graphics2D g = (Graphics2D) pG;
g.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(getDisabledTextColor());
g.drawString(placeholder, getInsets().left, pG.getFontMetrics()
.getMaxAscent() + getInsets().top + 1);
}
public void setPlaceholder(final String s) {
placeholder = s;
}
} }

2
designer-realize/src/com/fr/design/report/freeze/UIIntNumberField.java → designer-base/src/com/fr/design/gui/itextfield/UIIntNumberField.java

@ -1,4 +1,4 @@
package com.fr.design.report.freeze; package com.fr.design.gui.itextfield;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;

32
designer-base/src/com/fr/design/gui/itextfield/UITextField.java

@ -7,6 +7,7 @@ import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener; import com.fr.design.event.UIObserverListener;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -22,9 +23,10 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
private boolean isRoundBorder = true; private boolean isRoundBorder = true;
private int rectDirection = Constants.NULL; private int rectDirection = Constants.NULL;
private UIObserverListener uiObserverListener; private UIObserverListener uiObserverListener;
private String textFeildName = ""; private String textFieldName = StringUtils.EMPTY;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
private Dimension preferredSize = null; private Dimension preferredSize = null;
private String placeholder = StringUtils.EMPTY;
//有些情况下setText的时候不希望触发attributeChange,添加一个属性标识 //有些情况下setText的时候不希望触发attributeChange,添加一个属性标识
private boolean isSetting = false; private boolean isSetting = false;
@ -81,6 +83,15 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
} }
} }
public String getPlaceholder() {
return placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public boolean isSetting() { public boolean isSetting() {
return isSetting; return isSetting;
} }
@ -94,7 +105,7 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
} }
public void setGlobalName(String name) { public void setGlobalName(String name) {
textFeildName = name; textFieldName = name;
} }
protected void attributeChange() { protected void attributeChange() {
@ -102,7 +113,7 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
return; return;
} }
if (globalNameListener != null && shouldResponseNameListener()) { if (globalNameListener != null && shouldResponseNameListener()) {
globalNameListener.setGlobalName(textFeildName); globalNameListener.setGlobalName(textFieldName);
} }
if (uiObserverListener != null) { if (uiObserverListener != null) {
uiObserverListener.doChange(); uiObserverListener.doChange();
@ -141,6 +152,21 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
this.setUI(new UITextFieldUI(this)); this.setUI(new UITextFieldUI(this));
} }
@Override
protected void paintComponent(final Graphics pG) {
super.paintComponent(pG);
if (placeholder.length() == 0 || getText().length() > 0) {
return;
}
final Graphics2D g = (Graphics2D) pG;
g.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(getDisabledTextColor());
g.drawString(placeholder, getInsets().left, pG.getFontMetrics()
.getMaxAscent() + getInsets().top + 1);
}
@Override @Override
protected void paintBorder(Graphics g) { protected void paintBorder(Graphics g) {
if (!isBorderPainted) { if (!isBorderPainted) {

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

@ -14,8 +14,7 @@ import com.fr.stable.Nameable;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.swing.SwingUtilities;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
@ -62,7 +61,7 @@ public class EnvListPane extends JListControlPane {
NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png", NameableCreator local = new NameObjectCreator(Inter.getLocText("Env-Local_Directory"), "com/fr/design/images/data/bind/localconnect.png",
LocalEnvConfig.class, LocalEnvPane.class); LocalEnvConfig.class, LocalEnvPane.class);
NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png", NameableCreator remote = new NameObjectCreator(Inter.getLocText("Env-Remote_Server"), "com/fr/design/images/data/bind/distanceconnect.png",
RemoteEnvConfig.class, RemoteEnvPane.class); RemoteEnvConfig.class, RemoteEnvPane2.class);
return new NameableCreator[]{local, remote}; return new NameableCreator[]{local, remote};
} }

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

@ -2,11 +2,12 @@ package com.fr.env;
import com.fr.base.EnvException; import com.fr.base.EnvException;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.base.operator.connect.ConnectOperator;
import com.fr.base.operator.file.FileOperator; import com.fr.base.operator.file.FileOperator;
import com.fr.base.remote.RemoteDeziConstants; import com.fr.base.remote.RemoteDeziConstants;
import com.fr.common.rpc.RemoteCallServerConfig; import com.fr.common.rpc.RemoteCallServerConfig;
import com.fr.common.rpc.netty.MessageSendExecutor; import com.fr.common.rpc.netty.MessageSendExecutor;
import com.fr.common.rpc.serialize.SerializeProtocol; import com.fr.common.rpc.netty.RemoteCallClient;
import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvConstants;
import com.fr.core.env.EnvContext; import com.fr.core.env.EnvContext;
import com.fr.core.env.resource.RemoteEnvConfig; import com.fr.core.env.resource.RemoteEnvConfig;
@ -49,7 +50,7 @@ import com.fr.third.guava.base.Strings;
import com.fr.third.guava.collect.ImmutableMap; import com.fr.third.guava.collect.ImmutableMap;
import com.fr.web.ResourceConstants; import com.fr.web.ResourceConstants;
import javax.swing.JOptionPane; import javax.swing.*;
import javax.xml.transform.Source; import javax.xml.transform.Source;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerConfigurationException;
@ -57,7 +58,7 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import java.awt.Component; import java.awt.*;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -79,24 +80,41 @@ import static com.fr.third.guava.base.Preconditions.checkArgument;
/** /**
* @author null * @author null
*/ */
public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable { public class RemoteEnv extends AbstractEnv<RemoteEnvConfig> implements DesignAuthorityConfigurable {
private static final String CERT_KEY = "javax.net.ssl.trustStore"; private static final String CERT_KEY = "javax.net.ssl.trustStore";
private static final String PWD_KEY = "javax.net.ssl.trustStorePassword"; private static final String PWD_KEY = "javax.net.ssl.trustStorePassword";
private static final String HTTPS_PREFIX = "https:"; private static final String HTTPS_PREFIX = "https:";
private final static String[] FILE_TYPE = {"cptx", "cpt", "frm", "form", "cht", "chart"}; private final static String[] FILE_TYPE = {"cptx", "cpt", "frm", "form", "cht", "chart"};
private String buildFilePath; private String buildFilePath;
private RemoteEnvConfig env; private RemoteEnvConfig config;
public RemoteEnv(RemoteEnvConfig config) {
this.config = config;
}
public RemoteEnv(String path, String userName, String password) { public RemoteEnv(String path, String userName, String password) {
env = new RemoteEnvConfig(path, userName, password); config = new RemoteEnvConfig(path, userName, password);
}
@Override
public void connect() throws Exception {
} }
@Override @Override
public void connect() { public void connectOnce() throws Exception {
// FIXME:richie ip地址属于测试的,带实际修改为RemoteEnv配置的地址 RemoteCallClient.getInstance().loadOnce(config.getHost(), config.getPort(), RemoteCallServerConfig.getInstance().getSerializeProtocol(), 10 * 1000);
MessageSendExecutor.getInstance().setRpcServerLoader("127.0.0.1", RemoteCallServerConfig.getInstance().getPort(), RemoteCallServerConfig.getInstance().getSerializeProtocol()); ConnectOperator operator = RemoteCallClient.getInstance().execute(ConnectOperator.class);
boolean result = false;
try {
result = operator.connect(config.getUsername(), config.getPassword());
} catch (Exception ignore) {
}
if (!result) {
throw new Exception("Cannot connect to the remote server!");
}
} }
@Override @Override
@ -112,16 +130,16 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl
@Override @Override
public String getPath() { public String getPath() {
return env.getPath(); return config.getPath();
} }
@Override @Override
public String getUser() { public String getUser() {
return env.getUsername(); return config.getUsername();
} }
public String getPassword() { public String getPassword() {
return env.getPassword(); return config.getPassword();
} }
@Override @Override

145
designer-base/src/com/fr/env/RemoteEnvPane2.java vendored

@ -0,0 +1,145 @@
package com.fr.env;
import com.fr.core.env.resource.RemoteEnvConfig;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPassWordField;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.ExecutionException;
/**
* 远程环境设置界面暂时命名为2待做完功能直接替代掉老的RemoteEnvPane
*/
public class RemoteEnvPane2 extends BasicBeanPane<RemoteEnvConfig> {
private UITextField hostTextField;
private UIIntNumberField portTextField;
private UITextField usernameTextField;
private UIPassWordField passwordTextField;
public RemoteEnvPane2() {
initComponents();
}
private void initComponents() {
setLayout(new BorderLayout());
JPanel contentPanel = new JPanel(new BorderLayout());
add(contentPanel, BorderLayout.CENTER);
contentPanel.setBorder(
BorderFactory.createCompoundBorder(
new EmptyBorder(6, 0, 0, 0),
UITitledBorder.createBorderWithTitle(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Config")))
);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] rowSize = new double[]{p, p, p, p, p};
double[] columnSize = new double[]{p, f};
UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try"));
hostTextField = new UITextField();
hostTextField.setPlaceholder("192.168.100.200");
portTextField = new UIIntNumberField();
portTextField.setPlaceholder("39999");
JPanel valuePane = TableLayoutHelper.createTableLayoutPane(
new Component[][]{
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), hostTextField},
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Port") + ":", SwingConstants.RIGHT),portTextField},
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()},
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()},
{null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)}
},
rowSize, columnSize
);
testConnectionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
tryConnectRemoteEnv();
}
});
contentPanel.add(valuePane, BorderLayout.CENTER);
}
private void tryConnectRemoteEnv() {
final RemoteEnv remoteEnv = new RemoteEnv(this.updateBean());
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
remoteEnv.connectOnce();
return null;
}
@Override
protected void done() {
try {
get();
showConnectMessage();
} catch (Exception e) {
showCannotConnectMessage();
}
}
}.execute();
}
private void showCannotConnectMessage() {
JOptionPane.showMessageDialog(
this,
Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"),
UIManager.getString("OptionPane.messageDialogTitle", this.getLocale()),
JOptionPane.ERROR_MESSAGE
);
}
private void showConnectMessage() {
JOptionPane.showMessageDialog(
this,
Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful"),
UIManager.getString("OptionPane.messageDialogTitle", this.getLocale()),
JOptionPane.INFORMATION_MESSAGE
);
}
@Override
protected String title4PopupWindow() {
return "RemoteEnv";
}
@Override
public void populateBean(RemoteEnvConfig config) {
if (config == null) {
return;
}
hostTextField.setText(config.getPath());
if (config.getPort() != 0) {
portTextField.setValue(config.getPort());
}
usernameTextField.setText(config.getUsername());
passwordTextField.setText(config.getPassword());
}
@Override
public RemoteEnvConfig updateBean() {
RemoteEnvConfig config = new RemoteEnvConfig();
config.setHost(hostTextField.getText());
config.setPort((int) portTextField.getValue());
config.setUsername(usernameTextField.getText());
config.setPassword(passwordTextField.getText());
return config;
}
}

1
designer-realize/src/com/fr/design/report/freeze/RowSpinner.java

@ -1,6 +1,7 @@
package com.fr.design.report.freeze; package com.fr.design.report.freeze;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
/** /**

Loading…
Cancel
Save