txtName.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent e) {
txtName.selectAll();
}
});
txtName.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
if( !txtName.getText().equals("") &&
( tableParams.getSelectionCount() == 0 ||
( tableParams.getSelectionCount() > 0 && !tableParams.getSelection()[0].getText(0).equalsIgnoreCase(txtName.getText())))){
isEditableParam=true;
butApplyParam.setEnabled(isEditableParam);
txtValue.setEnabled(true);
butText.setEnabled(true);
paramText.setText("");
txtParamNote.setEnabled(true);
} else {
butText.setEnabled(false);
}
}
});
txtName.addKeyListener(new KeyAdapter() {
public void keyPressed(final KeyEvent e) {
if (e.keyCode == SWT.CR && !txtName.getText().equals("")){
addParam();
}
}
});
txtName.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
txtName.setFocus();
final Label valueLabel = new Label(parameterGroup, SWT.NONE);
valueLabel.setText("Value");
txtValue = new Text(parameterGroup, SWT.BORDER);
txtValue.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent e) {
txtValue.selectAll();
}
});
txtValue.addKeyListener(new KeyAdapter() {
public void keyPressed(final KeyEvent e) {
if (e.keyCode == SWT.CR && !txtName.getText().equals("")){
addParam();
}
}
});
txtValue.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
if( !txtName.getText().equals("") &&
( tableParams.getSelectionCount() == 0 ||
( tableParams.getSelectionCount() > 0 && !tableParams.getSelection()[0].getText(1).equalsIgnoreCase(txtValue.getText())))){
isEditableParam=true;
butApplyParam.setEnabled(isEditableParam);
if(txtValue.getText().trim().length() > 0)
butText.setEnabled(false);
else
butText.setEnabled(true);
}
}
});
txtValue.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
butText = new Button(parameterGroup, SWT.NONE);
butText.setEnabled(false);
butText.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
String ntext = "";
if(tableParams.getSelectionCount() > 0 ) {
TableItem item = tableParams.getSelection()[0];
ntext = item.getText(2);
}
String text = sos.scheduler.editor.app.Utils.showClipboard(ntext, getShell(), true, "");
if(text != null && !text.trim().equalsIgnoreCase(ntext)) {
paramText.setText(text);
txtValue.setText("");
txtValue.setEnabled(false);
butText.setEnabled(true);
addParam();
} else if (text == null) {
txtValue.setEnabled(true);
butText.setEnabled(true);
} else {
txtValue.setEnabled(true);
butText.setEnabled(false);
}
butApply.setEnabled(true);
}
});
butText.setText("Text");
butApplyParam = new Button(parameterGroup, SWT.NONE);
butApplyParam.setEnabled(isEditableParam);
butApplyParam.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
addParam();
}
});
final GridData gridData_9 = new GridData(GridData.FILL, GridData.BEGINNING, false, false);
butApplyParam.setLayoutData(gridData_9);
butApplyParam.setText("Apply");
tableParams = new Table(parameterGroup, SWT.FULL_SELECTION | SWT.BORDER);
tableParams.setEnabled(false);
tableParams.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if(tableParams.getSelectionCount() > 0) {
TableItem item = tableParams.getSelection()[0];
txtName.setText(item.getText(0));
//param value ist angegeben
if(item.getText(1) != null && item.getText(1).trim().length() > 0) {
paramText.setText("");
txtValue.setText(item.getText(1));
txtValue.setEnabled(true);
butText.setEnabled(false);
}
//param Textknoten ist angegeben
if(item.getText(2) != null && item.getText(2).trim().length() > 0) {
paramText.setText(item.getText(2));
txtValue.setText("");
txtValue.setEnabled(false);
butText.setEnabled(true);
}
if(item.getText(1).trim().equals("") && item.getText(2).trim().equals("")) {
paramText.setText("");
txtValue.setText("");
txtValue.setEnabled(true);
butText.setEnabled(true);
}
txtParamNote.setText(detailListener.getParamNote(item.getText(0), comboLanguage.getText()));
butRemove.setEnabled(true);
txtParamNote.setEnabled(true);
isEditableParam=false;
} else {
butRemove.setEnabled(false);
}
}
});
tableParams.setLinesVisible(true);
tableParams.setHeaderVisible(true);
final GridData gridData_4 = new GridData(GridData.FILL, GridData.FILL, true, true, 5, 7);
tableParams.setLayoutData(gridData_4);
final TableColumn newColumnTableColumn = new TableColumn(tableParams, SWT.NONE);
newColumnTableColumn.setWidth(181);
newColumnTableColumn.setText("Name");
final TableColumn newColumnTableColumn_1 = new TableColumn(tableParams, SWT.NONE);
newColumnTableColumn_1.setWidth(150);
newColumnTableColumn_1.setText("Value");
final TableColumn newColumnTableColumn_2 = new TableColumn(tableParams, SWT.NONE);
newColumnTableColumn_2.setWidth(100);
newColumnTableColumn_2.setText("Text");
final Button butNew = new Button(parameterGroup, SWT.NONE);
butNew.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
txtName.setText("");
txtValue.setText("");
paramText.setText("");
txtValue.setEnabled(true);
paramText.setEnabled(true);
tableParams.deselectAll();
txtParamNote.setText("");
}
});
butNew.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
butNew.setText("New");
final Composite composite_2 = new Composite(parameterGroup, SWT.NONE);
final GridData gridData_2_1 = new GridData(GridData.CENTER, GridData.CENTER, false, false);
gridData_2_1.heightHint = 67;
composite_2.setLayoutData(gridData_2_1);
composite_2.setLayout(new GridLayout());
butUp = new Button(composite_2, SWT.NONE);
butUp.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
detailListener.changeUp(tableParams);
}
});
butUp.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
butUp.setImage(ResourceManager.getImageFromResource("/sos/scheduler/editor/icon_up.gif"));
butDown = new Button(composite_2, SWT.NONE);
butDown.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
detailListener.changeDown(tableParams);
}
});
butDown.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
butDown.setImage(ResourceManager.getImageFromResource("/sos/scheduler/editor/icon_down.gif"));
final Button parameterButton = new Button(parameterGroup, SWT.NONE);
parameterButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
startWizzard();
}
});
//parameterButton.setVisible(type != Editor.DETAILS);
parameterButton.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
parameterButton.setText("Wizzard");
butRemove = new Button(parameterGroup, SWT.NONE);
butRemove.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if(tableParams.getSelectionCount() > 0) {
detailListener.deleteParameter(tableParams, tableParams.getSelectionIndex());
txtParamNote.setText("");
txtName.setText("");
txtValue.setText("");
tableParams.deselectAll();
butRemove.setEnabled(false);
txtParamNote.setText("");
isEditableParam = false;
butApplyParam.setEnabled(isEditableParam);
butApply.setEnabled(isEditable);
txtName.setFocus();
if(gui!=null)
gui.updateParam();
}
}
});
final GridData gridData_8 = new GridData(GridData.FILL, GridData.BEGINNING, false, true);
gridData_8.widthHint = 64;
gridData_8.minimumWidth = 50;
butRemove.setLayoutData(gridData_8);
butRemove.setText("Remove");
final Button butTemp = new Button(parameterGroup, SWT.NONE);
butTemp.setLayoutData(new GridData());
butTemp.setText("Documentation");
butTemp.setVisible(false);
butApply = new Button(parameterGroup, SWT.NONE);
butApply.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
butApply.setEnabled(isEditable);
FontData fontDatas[] = butApply.getFont().getFontData();
FontData data = fontDatas[0];
butApply.setFont(new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD));
butApply.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
save();
}
});
butApply.setText("Apply Details");
cancelButton = new Button(parameterGroup, SWT.NONE);
cancelButton.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
cancelButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
if(butApply.getEnabled()) {
int count = MainWindow.message(getShell(), sos.scheduler.editor.app.Messages.getString("detailform.close"), SWT.ICON_WARNING | SWT.OK |SWT.CANCEL );
if(count != SWT.OK) {
return;
}
}
getShell().dispose();
}
});
cancelButton.setText("Cancel");
txtParamNote = new Text(parameterGroup, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL);
txtParamNote.setEnabled(false);
txtParamNote.addVerifyListener(new VerifyListener() {
public void verifyText(final VerifyEvent e) {
if(e.keyCode == 8 || e.keyCode == 127) {
isEditableParam = true;
butApplyParam.setEnabled(isEditableParam);
}
}
});
txtParamNote.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
changeParameNote();
}
});
final GridData gridData_5 = new GridData(GridData.FILL, GridData.FILL, true, true, 5, 3);
gridData_5.heightHint = 73;
txtParamNote.setLayoutData(gridData_5);
comboLanguage = new Combo(parameterGroup, SWT.READ_ONLY);
comboLanguage.setItems(new String[] {"de", "en"});
final GridData gridData_7 = new GridData(GridData.FILL, GridData.BEGINNING, false, true);
comboLanguage.setLayoutData(gridData_7);
comboLanguage.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
txtJobchainNote.setText(detailListener.getNote(comboLanguage.getText()));
if(tableParams.getSelectionCount() > 0) {
TableItem item = tableParams.getSelection()[0];
txtParamNote.setText(detailListener.getParamNote(item.getText(0), comboLanguage.getText()));
} else if (txtName.getText() != null && txtName.getText().length() > 0) {
txtParamNote.setText(detailListener.getParamNote(txtName.getText(), comboLanguage.getText()));
} else if(txtParamNote.getText() != null && txtParamNote.getText().length()>0) {
txtParamNote.setText("");
}
isEditable=false;
isEditableParam = false;
//butApply.setEnabled(isEditable);
butApplyParam.setEnabled(isEditableParam);
butRemove.setEnabled(false);
}
});
comboLanguage.select(0);
butRefreshWizzardNoteParam = new Text(parameterGroup, SWT.CHECK);
butRefreshWizzardNoteParam.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
refreshTable();
}
});
butRefreshWizzardNoteParam.setVisible(false);
butRefreshWizzardNoteParam.setLayoutData(new GridData());
paramText = new Text(parameterGroup, SWT.BORDER);
paramText.setVisible(false);
final GridData gridData_14 = new GridData(GridData.CENTER, GridData.BEGINNING, false, false);
gridData_14.widthHint = 27;
paramText.setLayoutData(gridData_14);
jobChainGroup = new Group(parameterGroup, SWT.NONE);
jobChainGroup.setEnabled(false);
jobChainGroup.setText("Note");
jobChainGroup.setText("Note");
final GridLayout gridLayout_1 = new GridLayout();
gridLayout_1.numColumns = 2;
jobChainGroup.setLayout(gridLayout_1);
final GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false, 6, 1);
gridData.horizontalIndent = -1;
jobChainGroup.setLayoutData(gridData);
txtJobchainNote = new Text(jobChainGroup, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL);
txtJobchainNote.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
if(detailListener != null) {
isEditable=true;
if(gui!=null )
gui.updateNote();
detailListener.setNote(txtJobchainNote.getText(), comboLanguage.getText());
butApply.setEnabled(isEditable);
}
}
});
final GridData gridData_2 = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 2);
txtJobchainNote.setLayoutData(gridData_2);
butXML = new Button(jobChainGroup, SWT.NONE);
butXML.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
butXML.setEnabled(false);
butXML.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
try {
if(dom != null && dom.isChanged()) {
MainWindow.message("Please save jobchain configuration file before opening XML Editor.", SWT.ICON_ERROR);
return;
}
if(dom == null && butApply.isEnabled()) {
//ungespeichert
int c = MainWindow.message("Should the current values be saved?", SWT.YES | SWT.NO | SWT.ICON_ERROR);
if(c == SWT.YES)
detailListener.save();
}
if(type == Editor.JOB_CHAINS) {
DetailXMLEditorDialogForm dialog =
new DetailXMLEditorDialogForm(detailListener.getConfigurationFilename(), jobChainname, state, _orderId, type, isLifeElement, path);
dialog.showXMLEditor();
getShell().dispose();
} else {
if(dom != null && dom.getFilename() != null && dom.getFilename().length() > 0) {
DetailXMLEditorDialogForm dialog = new DetailXMLEditorDialogForm(dom, type, isLifeElement, path);
dialog.setConfigurationData(confListener, tree, parent);
dialog.showXMLEditor();
} else {
MainWindow.message("Please save jobchain configuration file before opening XML Editor.", SWT.ICON_ERROR);
}
}
} catch (Exception ex) {
try {
System.out.println("..error in " + sos.util.SOSClassUtil.getMethodName() + ": " +ex.getMessage());
new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName(), ex);
} catch(Exception ee) {
//tu nichts
}
}
}
});
butXML.setText("Open XML");
butDocumentation = new Button(jobChainGroup, SWT.NONE);
butDocumentation.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
butDocumentation.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent e) {
String filename = null;
try {
if(type == Editor.JOB_CHAINS) {
filename = detailListener.getConfigurationFilename();
} else {
if(dom!=null) {
filename = dom.getFilename();
}
}
if (filename != null && filename.length() > 0) {
File file = new File(filename);
if(file.exists()) {
//Runtime.getRuntime().exec("cmd /C START iExplore ".concat(filename));
Program prog = Program.findProgram("html");
if (prog != null) {
prog.execute(new File(filename).toURL().toString());
} else {
String[] split = Options.getBrowserExec(new File(filename).toURL().toString(), Options.getLanguage());
Runtime.getRuntime().exec(split);
}
} else
MainWindow.message("Missing documentation " + file.getCanonicalPath() , SWT.ICON_ERROR);
} else {
MainWindow.message("Please save jobchain configuration before opening documentation." , SWT.ICON_ERROR);
}
} catch (Exception ex) {
try {
System.out.println("..could not open file " + filename + " " + ex.getMessage());
new ErrorLog("error in " + sos.util.SOSClassUtil.getMethodName() + "..could not open file " + filename, ex);
} catch(Exception ee) {
//tu nichts
}
}
}
});
butDocumentation.setText("Documentation");
final Label fileLabel = new Label(parameterGroup, SWT.NONE);
fileLabel.setLayoutData(new GridData());
fileLabel.setText("Job Documentation: ");
txtParamsFile = new Text(parameterGroup, SWT.BORDER);
txtParamsFile.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent e) {
txtParamsFile.selectAll();
}
});
txtParamsFile.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent e) {
detailListener.setParamsFileName(txtParamsFile.getText());
if(gui!=null )
gui.updateNote();