ju
7 years ago
5 changed files with 309 additions and 271 deletions
@ -1,192 +1,185 @@ |
|||||||
package com.fr.env; |
//package com.fr.env;
|
||||||
|
//
|
||||||
import com.fr.design.beans.BasicBeanPane; |
//import com.fr.design.beans.BasicBeanPane;
|
||||||
import com.fr.design.border.UITitledBorder; |
//import com.fr.design.border.UITitledBorder;
|
||||||
import com.fr.design.env.DesignerWorkspaceInfo; |
//import com.fr.design.env.DesignerWorkspaceInfo;
|
||||||
import com.fr.design.env.DesignerWorkspaceType; |
//import com.fr.design.env.DesignerWorkspaceType;
|
||||||
import com.fr.design.gui.ibutton.UIButton; |
//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.gui.ipasswordfield.UIPassWordField; |
//import com.fr.design.gui.ipasswordfield.UIPassWordField;
|
||||||
import com.fr.design.gui.itextfield.UIIntNumberField; |
//import com.fr.design.gui.itextfield.UIIntNumberField;
|
||||||
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.utils.gui.GUICoreUtils; |
//import com.fr.design.utils.gui.GUICoreUtils;
|
||||||
import com.fr.general.Inter; |
//import com.fr.general.Inter;
|
||||||
import com.fr.workspace.WorkContext; |
//import com.fr.workspace.WorkContext;
|
||||||
import com.fr.workspace.connect.WorkspaceConnection; |
//import com.fr.workspace.connect.WorkspaceConnection;
|
||||||
|
//
|
||||||
import javax.swing.*; |
//import javax.swing.*;
|
||||||
import javax.swing.border.EmptyBorder; |
//import javax.swing.border.EmptyBorder;
|
||||||
import java.awt.*; |
//import java.awt.*;
|
||||||
import java.awt.event.ActionEvent; |
//import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener; |
//import java.awt.event.ActionListener;
|
||||||
import java.awt.event.WindowAdapter; |
//import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent; |
//import java.awt.event.WindowEvent;
|
||||||
|
//
|
||||||
/** |
///**
|
||||||
* 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane |
// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane
|
||||||
*/ |
// */
|
||||||
public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> { |
//public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> {
|
||||||
|
//
|
||||||
private UITextField hostTextField; |
// private UITextField urlTextField;
|
||||||
private UIIntNumberField portTextField; |
// private UITextField usernameTextField;
|
||||||
private UITextField usernameTextField; |
// private UIPassWordField passwordTextField;
|
||||||
private UIPassWordField passwordTextField; |
// private JDialog dialog;
|
||||||
private JDialog dialog; |
// private UILabel message;
|
||||||
private UILabel message; |
// private UIButton okButton;
|
||||||
private UIButton okButton; |
// private UIButton cancelButton;
|
||||||
private UIButton cancelButton; |
//
|
||||||
|
// public RemoteEnvPane2() {
|
||||||
public RemoteEnvPane2() { |
// initComponents();
|
||||||
initComponents(); |
// }
|
||||||
} |
//
|
||||||
|
// private void initComponents() {
|
||||||
private void initComponents() { |
// setLayout(new BorderLayout());
|
||||||
setLayout(new BorderLayout()); |
//
|
||||||
|
// JPanel contentPanel = new JPanel(new BorderLayout());
|
||||||
JPanel contentPanel = new JPanel(new BorderLayout()); |
// add(contentPanel, BorderLayout.CENTER);
|
||||||
add(contentPanel, BorderLayout.CENTER); |
//
|
||||||
|
// contentPanel.setBorder(
|
||||||
contentPanel.setBorder( |
// BorderFactory.createCompoundBorder(
|
||||||
BorderFactory.createCompoundBorder( |
// new EmptyBorder(6, 0, 0, 0),
|
||||||
new EmptyBorder(6, 0, 0, 0), |
// UITitledBorder.createBorderWithTitle(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Config")))
|
||||||
UITitledBorder.createBorderWithTitle(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Config"))) |
// );
|
||||||
); |
//
|
||||||
|
// double p = TableLayout.PREFERRED;
|
||||||
double p = TableLayout.PREFERRED; |
// double f = TableLayout.FILL;
|
||||||
double f = TableLayout.FILL; |
// double[] rowSize = new double[]{p, p, p, p};
|
||||||
double[] rowSize = new double[]{p, p, p, p, p}; |
// double[] columnSize = new double[]{p, f};
|
||||||
double[] columnSize = new double[]{p, f}; |
// UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try"));
|
||||||
UIButton testConnectionButton = new UIButton(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try")); |
// urlTextField = new UITextField();
|
||||||
hostTextField = new UITextField(); |
// urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision");
|
||||||
hostTextField.setPlaceholder("192.168.100.200"); |
// JPanel valuePane = TableLayoutHelper.createTableLayoutPane(
|
||||||
portTextField = new UIIntNumberField(); |
// new Component[][]{
|
||||||
portTextField.setPlaceholder("39999"); |
// {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField},
|
||||||
JPanel valuePane = TableLayoutHelper.createTableLayoutPane( |
// {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()},
|
||||||
new Component[][]{ |
// {new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()},
|
||||||
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), hostTextField}, |
// {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)}
|
||||||
{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()}, |
// rowSize, columnSize
|
||||||
{new UILabel(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()}, |
// );
|
||||||
{null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)} |
// testConnectionButton.addActionListener(new ActionListener() {
|
||||||
}, |
// @Override
|
||||||
rowSize, columnSize |
// public void actionPerformed(ActionEvent e) {
|
||||||
); |
// tryConnectRemoteEnv();
|
||||||
testConnectionButton.addActionListener(new ActionListener() { |
// }
|
||||||
@Override |
// });
|
||||||
public void actionPerformed(ActionEvent e) { |
// contentPanel.add(valuePane, BorderLayout.CENTER);
|
||||||
tryConnectRemoteEnv(); |
//
|
||||||
} |
// message = new UILabel();
|
||||||
}); |
// okButton = new UIButton(Inter.getLocText("OK"));
|
||||||
contentPanel.add(valuePane, BorderLayout.CENTER); |
// cancelButton = new UIButton(Inter.getLocText("Cancel"));
|
||||||
|
// }
|
||||||
message = new UILabel(); |
//
|
||||||
okButton = new UIButton(Inter.getLocText("OK")); |
// private void tryConnectRemoteEnv() {
|
||||||
cancelButton = new UIButton(Inter.getLocText("Cancel")); |
// final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
|
||||||
} |
//
|
||||||
|
// @Override
|
||||||
private void tryConnectRemoteEnv() { |
// protected Void doInBackground() throws Exception {
|
||||||
final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { |
//
|
||||||
|
// final DesignerWorkspaceInfo remoteEnv = updateBean();
|
||||||
@Override |
// WorkContext.getConnector().testConnection(remoteEnv.getConnection());
|
||||||
protected Void doInBackground() throws Exception { |
// return null;
|
||||||
|
// }
|
||||||
final DesignerWorkspaceInfo remoteEnv = updateBean(); |
//
|
||||||
WorkContext.getConnector().testConnection(remoteEnv.getConnection()); |
// @Override
|
||||||
return null; |
// protected void done() {
|
||||||
} |
// okButton.setEnabled(true);
|
||||||
|
// try {
|
||||||
@Override |
// get();
|
||||||
protected void done() { |
// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful"));
|
||||||
okButton.setEnabled(true); |
// } catch (Exception e) {
|
||||||
try { |
// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed"));
|
||||||
get(); |
// }
|
||||||
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Successful")); |
// }
|
||||||
} catch (Exception e) { |
// };
|
||||||
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Connect_Failed")); |
// worker.execute();
|
||||||
} |
// initMessageDialog();
|
||||||
} |
// okButton.addActionListener(new ActionListener() {
|
||||||
}; |
// public void actionPerformed(ActionEvent e) {
|
||||||
worker.execute(); |
// dialog.dispose();
|
||||||
initMessageDialog(); |
// }
|
||||||
okButton.addActionListener(new ActionListener() { |
// });
|
||||||
public void actionPerformed(ActionEvent e) { |
// cancelButton.addActionListener(new ActionListener() {
|
||||||
dialog.dispose(); |
// public void actionPerformed(ActionEvent e) {
|
||||||
} |
// dialog.dispose();
|
||||||
}); |
// worker.cancel(true);
|
||||||
cancelButton.addActionListener(new ActionListener() { |
// }
|
||||||
public void actionPerformed(ActionEvent e) { |
// });
|
||||||
dialog.dispose(); |
//
|
||||||
worker.cancel(true); |
// dialog.addWindowListener(new WindowAdapter() {
|
||||||
} |
// public void windowClosed(WindowEvent e) {
|
||||||
}); |
// worker.cancel(true);
|
||||||
|
// }
|
||||||
dialog.addWindowListener(new WindowAdapter() { |
// });
|
||||||
public void windowClosed(WindowEvent e) { |
//
|
||||||
worker.cancel(true); |
// dialog.setVisible(true);
|
||||||
} |
// dialog.dispose();
|
||||||
}); |
// }
|
||||||
|
//
|
||||||
dialog.setVisible(true); |
// private void initMessageDialog() {
|
||||||
dialog.dispose(); |
// message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "...");
|
||||||
} |
// message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
|
||||||
|
// okButton.setEnabled(false);
|
||||||
private void initMessageDialog() { |
//
|
||||||
message.setText(Inter.getLocText("Fine-Designer_Basic_Remote_Env_Try") + "..."); |
// dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true);
|
||||||
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0)); |
//
|
||||||
okButton.setEnabled(false); |
// dialog.setSize(new Dimension(268, 118));
|
||||||
|
// okButton.setEnabled(false);
|
||||||
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), Inter.getLocText("Datasource-Test_Connection"), true); |
// JPanel jp = new JPanel();
|
||||||
|
// JPanel upPane = new JPanel();
|
||||||
dialog.setSize(new Dimension(268, 118)); |
// JPanel downPane = new JPanel();
|
||||||
okButton.setEnabled(false); |
// UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
|
||||||
JPanel jp = new JPanel(); |
// upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
|
||||||
JPanel upPane = new JPanel(); |
// upPane.add(uiLabel);
|
||||||
JPanel downPane = new JPanel(); |
// upPane.add(message);
|
||||||
UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon")); |
// downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
|
||||||
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
// downPane.add(okButton);
|
||||||
upPane.add(uiLabel); |
// downPane.add(cancelButton);
|
||||||
upPane.add(message); |
// jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
|
||||||
downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); |
// jp.add(upPane);
|
||||||
downPane.add(okButton); |
// jp.add(downPane);
|
||||||
downPane.add(cancelButton); |
// dialog.add(jp);
|
||||||
jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); |
// dialog.setResizable(false);
|
||||||
jp.add(upPane); |
// dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this));
|
||||||
jp.add(downPane); |
// }
|
||||||
dialog.add(jp); |
//
|
||||||
dialog.setResizable(false); |
// @Override
|
||||||
dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this)); |
// protected String title4PopupWindow() {
|
||||||
} |
// return "RemoteEnv";
|
||||||
|
// }
|
||||||
@Override |
//
|
||||||
protected String title4PopupWindow() { |
// @Override
|
||||||
return "RemoteEnv"; |
// public void populateBean(DesignerWorkspaceInfo config) {
|
||||||
} |
// if (config == null) {
|
||||||
|
// return;
|
||||||
@Override |
// }
|
||||||
public void populateBean(DesignerWorkspaceInfo config) { |
// WorkspaceConnection connection = config.getConnection();
|
||||||
if (config == null) { |
// if (connection != null) {
|
||||||
return; |
// urlTextField.setText(connection.getUrl());
|
||||||
} |
// usernameTextField.setText(connection.getUserName());
|
||||||
WorkspaceConnection connection = config.getConnection(); |
// passwordTextField.setText(connection.getPassword());
|
||||||
if (connection != null) { |
// }
|
||||||
hostTextField.setText(connection.getIp()); |
// }
|
||||||
if (connection.getPort() != 0) { |
//
|
||||||
portTextField.setValue(connection.getPort()); |
// @Override
|
||||||
} |
// public DesignerWorkspaceInfo updateBean() {
|
||||||
usernameTextField.setText(connection.getUserName()); |
//
|
||||||
passwordTextField.setText(connection.getPassword()); |
// DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
|
||||||
} |
// WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText());
|
||||||
} |
// config.setConnection(connection);
|
||||||
|
// config.setType(DesignerWorkspaceType.Remote);
|
||||||
@Override |
// return config;
|
||||||
public DesignerWorkspaceInfo updateBean() { |
// }
|
||||||
|
//}
|
||||||
DesignerWorkspaceInfo config = new DesignerWorkspaceInfo(); |
|
||||||
WorkspaceConnection connection = new WorkspaceConnection(hostTextField.getText(), (int) portTextField.getValue(), usernameTextField.getText(), passwordTextField.getText()); |
|
||||||
config.setConnection(connection); |
|
||||||
config.setType(DesignerWorkspaceType.Remote); |
|
||||||
return config; |
|
||||||
} |
|
||||||
} |
|
||||||
|
Loading…
Reference in new issue