📄 octopusloaderpanel.java
字号:
// button.setPreferredSize(new Dimension(dimension));
//
// return button;
// }
//
// private JComboBox createOctopusCombobox(String componentName, Dimension dimension) {
//
// JComboBox comboBox = new JComboBox();
// comboBox.setName(componentName);
// comboBox.setAlignmentX(Component.LEFT_ALIGNMENT);
// comboBox.setAlignmentY(Component.CENTER_ALIGNMENT);
// comboBox.setMinimumSize(new Dimension(dimension));
// comboBox.setMaximumSize(new Dimension(dimension));
// comboBox.setPreferredSize(new Dimension(dimension));
//
// return comboBox;
// }
//
// private JLabel createOctopusLabel(String componentName, Dimension dimension) {
//
// JLabel label = new JLabel();
// label.setText(componentName);
// label.setAlignmentX(Component.LEFT_ALIGNMENT);
// label.setAlignmentY(Component.CENTER_ALIGNMENT);
// label.setMinimumSize(new Dimension(dimension));
// label.setMaximumSize(new Dimension(dimension));
// label.setPreferredSize(new Dimension(dimension));
//
// return label;
// }
//
// private JTextField createOctopusTextField(String componentName, Dimension dimension) {
//
// JTextField textField = new JTextField();
// textField.setName(componentName);
// textField.setAlignmentX(Component.LEFT_ALIGNMENT);
// textField.setAlignmentY(Component.CENTER_ALIGNMENT);
// textField.setMinimumSize(new Dimension(dimension));
// textField.setMaximumSize(new Dimension(dimension));
// textField.setPreferredSize(new Dimension(dimension));
//
// return textField;
// }
public void setOctopusLoaderInit(OctopusLoaderData initData, String xmlFile,
String confJarStructure) {
this.initData = initData;
setField(LOG_MODE, initData.getLogMode(), "box");
setField(LOG_FILE_DIRECTORY, initData.getLogFileDir(), "textfield");
setField(LOG_FILE_NAME, initData.getLogFileName(), "textfield");
setField(USER_ID, initData.getUserId(), "textfield");
setField(VARIABLES, initData.getVariables(), "textfield");
setField(RESTART_INDICATOR, initData.getRestartIndicator(), "textfield");
setField(VENDOR_CONF_FILE, initData.getVendorConf(), "textfield");
setField(ON_ERRORCONTINUE, initData.getOnErrorCon(), "textfield");
setField(ADDITIONAL_CLASSPATH, initData.getAdditionalPaths(), "textfield");
setField(COMMIT_COUNT, initData.getCommitCount(), "textfield");
setField(RETURN_CODE, initData.getReturnCode(), "textfield");
if(xmlFile != null)
setField(PATH_TO_XML_FILE, xmlFile, "textfield");
else
setField(PATH_TO_XML_FILE, initData.getPathToXml(), "textfield");
setField(INCLUDE_TABLES, initData.getIncludeTables(), "textfield");
if(confJarStructure != null)
setField(PATH_TO_CONF_JAR, confJarStructure, "textfield");
else
setField(PATH_TO_CONF_JAR, initData.getConfJarStructure(), "textfield");
}
public OctopusLoaderData getOctopusLoaderInit() throws Exception {
initData.setLogMode(getField(LOG_MODE, "box"));
initData.setLogFileName(getField(LOG_FILE_NAME, "label"));
initData.setLogFileDir(getField(LOG_FILE_DIRECTORY, "label"));
initData.setRestartIndicator(getField(RESTART_INDICATOR, "label"));
initData.setUserId(getField(USER_ID, "label"));
initData.setVariables(getField(VARIABLES, "label"));
initData.setVendorConf(getField(VENDOR_CONF_FILE, "label"));
initData.setOnErrorCon(getField(ON_ERRORCONTINUE, "label"));
initData.setAdditionalPaths(getField(ADDITIONAL_CLASSPATH, "label"));
initData.setCommitCount(getField(COMMIT_COUNT, "label"));
initData.setReturnCode(getField(RETURN_CODE, "label"));
initData.setPathToXml(getField(PATH_TO_XML_FILE, "label"));
initData.setIncludeTables(getField(INCLUDE_TABLES, "label"));
initData.setConfJarStructure(getField(PATH_TO_CONF_JAR, "label"));
return initData;
}
private void setField(String fieldName, String value, String type) {
if(type.equalsIgnoreCase("textfield")) {
JTextField field = (JTextField)fields.get(fieldName);
field.setText(value);
} else {
JComboBox field = (JComboBox)fields.get(fieldName);
boolean setted = false;
for(int i = 0; i < OctopusLoaderData.getLogModes().length; i++) {
if( field.getItemCount() != OctopusLoaderData.getLogModes().length )
field.addItem(OctopusLoaderData.getLogModes()[i]);
if( value.equalsIgnoreCase(OctopusLoaderData.getLogModes()[i]))
field.setSelectedIndex(i);
}
if(!setted)
field.setSelectedIndex(1);
}
}
private String getField(String fieldName, String type) {
if(type.equalsIgnoreCase("label")) {
JTextField field = (JTextField)fields.get(fieldName);
return field.getText().trim();
} else {
JComboBox field = (JComboBox)fields.get(fieldName);
return field.getSelectedItem().toString();
}
}
private class FullScreenAction
extends AbstractAction {
/**
* This method starts the LoaderGenerator application
*/
public FullScreenAction() {
putValue(SMALL_ICON,
new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
"wizard/images/Host16.gif")));
putValue(SHORT_DESCRIPTION, "Full Screen");
putValue(LONG_DESCRIPTION, "Set Trace to Full Screen");
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('F',
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
putValue(MNEMONIC_KEY, new Integer('F'));
}
/**
* This method check if the action is performed (event key pressed)
* @param e is event
*/
public void actionPerformed(ActionEvent e) {
main.setDividerLocation(0);
}
}
private class NormalScreenAction
extends AbstractAction {
/**
* This method starts the LoaderGenerator application
*/
public NormalScreenAction() {
putValue(SMALL_ICON,
new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
"wizard/images/Unhost16.gif")));
putValue(SHORT_DESCRIPTION, "Normal Screen");
putValue(LONG_DESCRIPTION, "Back to normal screen");
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N',
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
putValue(MNEMONIC_KEY, new Integer('N'));
}
/**
* This method check if the action is performed (event key pressed)
* @param e is event
*/
public void actionPerformed(ActionEvent e) {
main.setDividerLocation(330);
}
}
private class SaveTraceAction
extends AbstractAction {
/**
* This method starts the LoaderGenerator application
*/
public SaveTraceAction() {
putValue(SMALL_ICON,
new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
"wizard/images/Save16.gif")));
putValue(SHORT_DESCRIPTION, "Save Trace");
putValue(LONG_DESCRIPTION, "Save Trace to file");
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S',
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
putValue(MNEMONIC_KEY, new Integer('S'));
}
/**
* This method check if the action is performed (event key pressed)
* @param e is event
*/
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Save Octopus log ...");
int returnVal = fc.showSaveDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
String text = traceArea.getText();
try {
Writer out = new BufferedWriter(new FileWriter(file));
out.write(text);
out.close();
}
catch(Exception ex) {
ex.printStackTrace();
}
} else {
//do nothing
}
}
}
private class ClearTraceAction
extends AbstractAction {
/**
* This method starts the LoaderGenerator application
*/
public ClearTraceAction() {
putValue(SMALL_ICON,
new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" +
"wizard/images/Delete16.gif")));
putValue(SHORT_DESCRIPTION, "Clear Trace");
putValue(LONG_DESCRIPTION, "Clear Trace");
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('L',
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
putValue(MNEMONIC_KEY, new Integer('L'));
}
/**
* This method check if the action is performed (event key pressed)
* @param e is event
*/
public void actionPerformed(ActionEvent e) {
traceArea.setText("");
}
}
//additional paths
private class BrowseAction_AC
extends AbstractAction {
/**
* This method stop the LoaderGenerator application
*/
public BrowseAction_AC() {
putValue(SMALL_ICON,
new ImageIcon(getClass().getClassLoader().
getResource("org/webdocwf/util/loader/" +
"wizard/images/Open16.gif")));
putValue(SHORT_DESCRIPTION, "Add .jar files");
putValue(LONG_DESCRIPTION, "Add .jar (jdbc) files to system classpath");
putValue(MNEMONIC_KEY, new Integer('B'));
}
/**
* This method check if the action is performed (event key pressed)
* @param e is event
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -