use of org.pentaho.di.ui.core.widget.StyledTextComp in project pentaho-kettle by pentaho.
the class JobEntryWaitForSQLDialog method open.
public JobEntryInterface open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, props.getJobsDialogStyle());
props.setLook(shell);
JobDialog.setShellImage(shell, jobEntry);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
jobEntry.setChanged();
}
};
changed = jobEntry.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
FormData fd = new FormData();
fd.right = new FormAttachment(50, -10);
fd.bottom = new FormAttachment(100, 0);
fd.width = 100;
wOK.setLayoutData(fd);
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
fd = new FormData();
fd.left = new FormAttachment(50, 10);
fd.bottom = new FormAttachment(100, 0);
fd.width = 100;
wCancel.setLayoutData(fd);
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, null);
// Filename line
wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Name.Label"));
props.setLook(wlName);
fdlName = new FormData();
fdlName.left = new FormAttachment(0, 0);
fdlName.right = new FormAttachment(middle, -margin);
fdlName.top = new FormAttachment(0, margin);
wlName.setLayoutData(fdlName);
wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wName);
wName.addModifyListener(lsMod);
fdName = new FormData();
fdName.left = new FormAttachment(middle, 0);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
// Connection line
wConnection = addConnectionLine(shell, wName, middle, margin);
if (jobEntry.getDatabase() == null && jobMeta.nrDatabases() == 1) {
wConnection.select(0);
}
wConnection.addModifyListener(lsMod);
// Schema name line
wlSchemaname = new Label(shell, SWT.RIGHT);
wlSchemaname.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Schemaname.Label"));
props.setLook(wlSchemaname);
fdlSchemaname = new FormData();
fdlSchemaname.left = new FormAttachment(0, 0);
fdlSchemaname.right = new FormAttachment(middle, 0);
fdlSchemaname.top = new FormAttachment(wConnection, margin);
wlSchemaname.setLayoutData(fdlSchemaname);
wSchemaname = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSchemaname);
wSchemaname.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Schemaname.Tooltip"));
wSchemaname.addModifyListener(lsMod);
fdSchemaname = new FormData();
fdSchemaname.left = new FormAttachment(middle, 0);
fdSchemaname.top = new FormAttachment(wConnection, margin);
fdSchemaname.right = new FormAttachment(100, 0);
wSchemaname.setLayoutData(fdSchemaname);
// Table name line
wlTablename = new Label(shell, SWT.RIGHT);
wlTablename.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Tablename.Label"));
props.setLook(wlTablename);
fdlTablename = new FormData();
fdlTablename.left = new FormAttachment(0, 0);
fdlTablename.right = new FormAttachment(middle, 0);
fdlTablename.top = new FormAttachment(wSchemaname, margin);
wlTablename.setLayoutData(fdlTablename);
wbTable = new Button(shell, SWT.PUSH | SWT.CENTER);
props.setLook(wbTable);
wbTable.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
FormData fdbTable = new FormData();
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wSchemaname, margin / 2);
wbTable.setLayoutData(fdbTable);
wbTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
wTablename = new TextVar(jobMeta, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTablename);
wTablename.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Tablename.Tooltip"));
wTablename.addModifyListener(lsMod);
fdTablename = new FormData();
fdTablename.left = new FormAttachment(middle, 0);
fdTablename.top = new FormAttachment(wSchemaname, margin);
fdTablename.right = new FormAttachment(wbTable, -margin);
wTablename.setLayoutData(fdTablename);
// ////////////////////////
// START OF Success GROUP///
// ///////////////////////////////
wSuccessGroup = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wSuccessGroup);
wSuccessGroup.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessGroup.Group.Label"));
FormLayout SuccessGroupLayout = new FormLayout();
SuccessGroupLayout.marginWidth = 10;
SuccessGroupLayout.marginHeight = 10;
wSuccessGroup.setLayout(SuccessGroupLayout);
// Success Condition
wlSuccessCondition = new Label(wSuccessGroup, SWT.RIGHT);
wlSuccessCondition.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessCondition.Label"));
props.setLook(wlSuccessCondition);
fdlSuccessCondition = new FormData();
fdlSuccessCondition.left = new FormAttachment(0, -margin);
fdlSuccessCondition.right = new FormAttachment(middle, -2 * margin);
fdlSuccessCondition.top = new FormAttachment(0, margin);
wlSuccessCondition.setLayoutData(fdlSuccessCondition);
wSuccessCondition = new CCombo(wSuccessGroup, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wSuccessCondition.setItems(JobEntryWaitForSQL.successConditionsDesc);
// +1: starts at -1
wSuccessCondition.select(0);
props.setLook(wSuccessCondition);
fdSuccessCondition = new FormData();
fdSuccessCondition.left = new FormAttachment(middle, -margin);
fdSuccessCondition.top = new FormAttachment(0, margin);
fdSuccessCondition.right = new FormAttachment(100, 0);
wSuccessCondition.setLayoutData(fdSuccessCondition);
wSuccessCondition.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// activeSuccessCondition();
}
});
// Success when number of errors less than
wlRowsCountValue = new Label(wSuccessGroup, SWT.RIGHT);
wlRowsCountValue.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.RowsCountValue.Label"));
props.setLook(wlRowsCountValue);
fdlRowsCountValue = new FormData();
fdlRowsCountValue.left = new FormAttachment(0, -margin);
fdlRowsCountValue.top = new FormAttachment(wSuccessCondition, margin);
fdlRowsCountValue.right = new FormAttachment(middle, -2 * margin);
wlRowsCountValue.setLayoutData(fdlRowsCountValue);
wRowsCountValue = new TextVar(jobMeta, wSuccessGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobEntryWaitForSQL.RowsCountValue.Tooltip"));
props.setLook(wRowsCountValue);
wRowsCountValue.addModifyListener(lsMod);
fdRowsCountValue = new FormData();
fdRowsCountValue.left = new FormAttachment(middle, -margin);
fdRowsCountValue.top = new FormAttachment(wSuccessCondition, margin);
fdRowsCountValue.right = new FormAttachment(100, 0);
wRowsCountValue.setLayoutData(fdRowsCountValue);
// Maximum timeout
wlMaximumTimeout = new Label(wSuccessGroup, SWT.RIGHT);
wlMaximumTimeout.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.MaximumTimeout.Label"));
props.setLook(wlMaximumTimeout);
fdlMaximumTimeout = new FormData();
fdlMaximumTimeout.left = new FormAttachment(0, -margin);
fdlMaximumTimeout.top = new FormAttachment(wRowsCountValue, margin);
fdlMaximumTimeout.right = new FormAttachment(middle, -2 * margin);
wlMaximumTimeout.setLayoutData(fdlMaximumTimeout);
wMaximumTimeout = new TextVar(jobMeta, wSuccessGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMaximumTimeout);
wMaximumTimeout.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.MaximumTimeout.Tooltip"));
wMaximumTimeout.addModifyListener(lsMod);
fdMaximumTimeout = new FormData();
fdMaximumTimeout.left = new FormAttachment(middle, -margin);
fdMaximumTimeout.top = new FormAttachment(wRowsCountValue, margin);
fdMaximumTimeout.right = new FormAttachment(100, 0);
wMaximumTimeout.setLayoutData(fdMaximumTimeout);
// Cycle time
wlCheckCycleTime = new Label(wSuccessGroup, SWT.RIGHT);
wlCheckCycleTime.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.CheckCycleTime.Label"));
props.setLook(wlCheckCycleTime);
fdlCheckCycleTime = new FormData();
fdlCheckCycleTime.left = new FormAttachment(0, -margin);
fdlCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
fdlCheckCycleTime.right = new FormAttachment(middle, -2 * margin);
wlCheckCycleTime.setLayoutData(fdlCheckCycleTime);
wCheckCycleTime = new TextVar(jobMeta, wSuccessGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wCheckCycleTime);
wCheckCycleTime.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.CheckCycleTime.Tooltip"));
wCheckCycleTime.addModifyListener(lsMod);
fdCheckCycleTime = new FormData();
fdCheckCycleTime.left = new FormAttachment(middle, -margin);
fdCheckCycleTime.top = new FormAttachment(wMaximumTimeout, margin);
fdCheckCycleTime.right = new FormAttachment(100, 0);
wCheckCycleTime.setLayoutData(fdCheckCycleTime);
// Success on timeout
wlSuccesOnTimeout = new Label(wSuccessGroup, SWT.RIGHT);
wlSuccesOnTimeout.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessOnTimeout.Label"));
props.setLook(wlSuccesOnTimeout);
fdlSuccesOnTimeout = new FormData();
fdlSuccesOnTimeout.left = new FormAttachment(0, -margin);
fdlSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
fdlSuccesOnTimeout.right = new FormAttachment(middle, -2 * margin);
wlSuccesOnTimeout.setLayoutData(fdlSuccesOnTimeout);
wSuccesOnTimeout = new Button(wSuccessGroup, SWT.CHECK);
props.setLook(wSuccesOnTimeout);
wSuccesOnTimeout.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.SuccessOnTimeout.Tooltip"));
fdSuccesOnTimeout = new FormData();
fdSuccesOnTimeout.left = new FormAttachment(middle, -margin);
fdSuccesOnTimeout.top = new FormAttachment(wCheckCycleTime, margin);
fdSuccesOnTimeout.right = new FormAttachment(100, -margin);
wSuccesOnTimeout.setLayoutData(fdSuccesOnTimeout);
wSuccesOnTimeout.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
fdSuccessGroup = new FormData();
fdSuccessGroup.left = new FormAttachment(0, margin);
fdSuccessGroup.top = new FormAttachment(wbTable, margin);
fdSuccessGroup.right = new FormAttachment(100, -margin);
wSuccessGroup.setLayoutData(fdSuccessGroup);
// ///////////////////////////////////////////////////////////
// / END OF SuccessGroup GROUP
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF Custom GROUP///
// ///////////////////////////////
wCustomGroup = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wCustomGroup);
wCustomGroup.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.CustomGroup.Group.Label"));
FormLayout CustomGroupLayout = new FormLayout();
CustomGroupLayout.marginWidth = 10;
CustomGroupLayout.marginHeight = 10;
wCustomGroup.setLayout(CustomGroupLayout);
// custom SQL?
wlcustomSQL = new Label(wCustomGroup, SWT.RIGHT);
wlcustomSQL.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.customSQL.Label"));
props.setLook(wlcustomSQL);
fdlcustomSQL = new FormData();
fdlcustomSQL.left = new FormAttachment(0, -margin);
fdlcustomSQL.top = new FormAttachment(wSuccessGroup, margin);
fdlcustomSQL.right = new FormAttachment(middle, -2 * margin);
wlcustomSQL.setLayoutData(fdlcustomSQL);
wcustomSQL = new Button(wCustomGroup, SWT.CHECK);
props.setLook(wcustomSQL);
wcustomSQL.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.customSQL.Tooltip"));
fdcustomSQL = new FormData();
fdcustomSQL.left = new FormAttachment(middle, -margin);
fdcustomSQL.top = new FormAttachment(wSuccessGroup, margin);
fdcustomSQL.right = new FormAttachment(100, 0);
wcustomSQL.setLayoutData(fdcustomSQL);
wcustomSQL.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setCustomerSQL();
jobEntry.setChanged();
}
});
// use Variable substitution?
wlUseSubs = new Label(wCustomGroup, SWT.RIGHT);
wlUseSubs.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.UseVariableSubst.Label"));
props.setLook(wlUseSubs);
fdlUseSubs = new FormData();
fdlUseSubs.left = new FormAttachment(0, -margin);
fdlUseSubs.top = new FormAttachment(wcustomSQL, margin);
fdlUseSubs.right = new FormAttachment(middle, -2 * margin);
wlUseSubs.setLayoutData(fdlUseSubs);
wUseSubs = new Button(wCustomGroup, SWT.CHECK);
props.setLook(wUseSubs);
wUseSubs.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.UseVariableSubst.Tooltip"));
fdUseSubs = new FormData();
fdUseSubs.left = new FormAttachment(middle, -margin);
fdUseSubs.top = new FormAttachment(wcustomSQL, margin);
fdUseSubs.right = new FormAttachment(100, 0);
wUseSubs.setLayoutData(fdUseSubs);
wUseSubs.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// clear result rows ?
wlClearResultList = new Label(wCustomGroup, SWT.RIGHT);
wlClearResultList.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.ClearResultList.Label"));
props.setLook(wlClearResultList);
fdlClearResultList = new FormData();
fdlClearResultList.left = new FormAttachment(0, -margin);
fdlClearResultList.top = new FormAttachment(wUseSubs, margin);
fdlClearResultList.right = new FormAttachment(middle, -2 * margin);
wlClearResultList.setLayoutData(fdlClearResultList);
wClearResultList = new Button(wCustomGroup, SWT.CHECK);
props.setLook(wClearResultList);
wClearResultList.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.ClearResultList.Tooltip"));
fdClearResultList = new FormData();
fdClearResultList.left = new FormAttachment(middle, -margin);
fdClearResultList.top = new FormAttachment(wUseSubs, margin);
fdClearResultList.right = new FormAttachment(100, 0);
wClearResultList.setLayoutData(fdClearResultList);
wClearResultList.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// add rows to result?
wlAddRowsToResult = new Label(wCustomGroup, SWT.RIGHT);
wlAddRowsToResult.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.AddRowsToResult.Label"));
props.setLook(wlAddRowsToResult);
fdlAddRowsToResult = new FormData();
fdlAddRowsToResult.left = new FormAttachment(0, -margin);
fdlAddRowsToResult.top = new FormAttachment(wClearResultList, margin);
fdlAddRowsToResult.right = new FormAttachment(middle, -2 * margin);
wlAddRowsToResult.setLayoutData(fdlAddRowsToResult);
wAddRowsToResult = new Button(wCustomGroup, SWT.CHECK);
props.setLook(wAddRowsToResult);
wAddRowsToResult.setToolTipText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.AddRowsToResult.Tooltip"));
fdAddRowsToResult = new FormData();
fdAddRowsToResult.left = new FormAttachment(middle, -margin);
fdAddRowsToResult.top = new FormAttachment(wClearResultList, margin);
fdAddRowsToResult.right = new FormAttachment(100, 0);
wAddRowsToResult.setLayoutData(fdAddRowsToResult);
wAddRowsToResult.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
wlPosition = new Label(wCustomGroup, SWT.NONE);
props.setLook(wlPosition);
fdlPosition = new FormData();
fdlPosition.left = new FormAttachment(0, 0);
fdlPosition.right = new FormAttachment(100, 0);
// fdlPosition.top= new FormAttachment(wSQL , 0);
fdlPosition.bottom = new FormAttachment(100, -margin);
wlPosition.setLayoutData(fdlPosition);
// Script line
wlSQL = new Label(wCustomGroup, SWT.NONE);
wlSQL.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.Script.Label"));
props.setLook(wlSQL);
fdlSQL = new FormData();
fdlSQL.left = new FormAttachment(0, 0);
fdlSQL.top = new FormAttachment(wAddRowsToResult, margin);
wlSQL.setLayoutData(fdlSQL);
wbSQLTable = new Button(wCustomGroup, SWT.PUSH | SWT.CENTER);
props.setLook(wbSQLTable);
wbSQLTable.setText(BaseMessages.getString(PKG, "JobEntryWaitForSQL.GetSQLAndSelectStatement"));
FormData fdbSQLTable = new FormData();
fdbSQLTable.right = new FormAttachment(100, 0);
fdbSQLTable.top = new FormAttachment(wAddRowsToResult, margin);
wbSQLTable.setLayoutData(fdbSQLTable);
wSQL = new StyledTextComp(jobEntry, wCustomGroup, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
props.setLook(wSQL, Props.WIDGET_STYLE_FIXED);
wSQL.addModifyListener(lsMod);
fdSQL = new FormData();
fdSQL.left = new FormAttachment(0, 0);
fdSQL.top = new FormAttachment(wbSQLTable, margin);
fdSQL.right = new FormAttachment(100, -10);
fdSQL.bottom = new FormAttachment(wlPosition, -margin);
wSQL.setLayoutData(fdSQL);
wSQL.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent arg0) {
setPosition();
}
});
wSQL.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
setPosition();
}
public void keyReleased(KeyEvent e) {
setPosition();
}
});
wSQL.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
setPosition();
}
public void focusLost(FocusEvent e) {
setPosition();
}
});
wSQL.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
setPosition();
}
public void mouseDown(MouseEvent e) {
setPosition();
}
public void mouseUp(MouseEvent e) {
setPosition();
}
});
wSQL.addModifyListener(lsMod);
// Text Higlighting
wSQL.addLineStyleListener(new SQLValuesHighlight());
fdCustomGroup = new FormData();
fdCustomGroup.left = new FormAttachment(0, margin);
fdCustomGroup.top = new FormAttachment(wSuccessGroup, margin);
fdCustomGroup.right = new FormAttachment(100, -margin);
fdCustomGroup.bottom = new FormAttachment(wOK, -margin);
wCustomGroup.setLayoutData(fdCustomGroup);
// ///////////////////////////////////////////////////////////
// / END OF CustomGroup GROUP
// ///////////////////////////////////////////////////////////
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsbSQLTable = new Listener() {
public void handleEvent(Event e) {
getSQL();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wbSQLTable.addListener(SWT.Selection, lsbSQLTable);
wName.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
getData();
setCustomerSQL();
BaseStepDialog.setSize(shell);
shell.open();
props.setDialogSize(shell, "JobEntryWaitForSQLDialogSize");
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobEntry;
}
use of org.pentaho.di.ui.core.widget.StyledTextComp in project pentaho-kettle by pentaho.
the class ScriptDialog method test.
private boolean test(boolean getvars, boolean popup) {
boolean retval = true;
StyledTextComp wScript = getStyledTextComp();
String scr = wScript.getText();
KettleException testException = null;
Context jscx;
Scriptable jsscope;
// Script jsscript;
// Making Refresh to get Active Script State
refreshScripts();
jscx = ContextFactory.getGlobal().enterContext();
jscx.setOptimizationLevel(-1);
jsscope = jscx.initStandardObjects(null, false);
// Adding the existing Scripts to the Context
for (int i = 0; i < folder.getItemCount(); i++) {
StyledTextComp sItem = getStyledTextComp(folder.getItem(i));
Scriptable jsR = Context.toObject(sItem.getText(), jsscope);
jsscope.put(folder.getItem(i).getText(), jsscope, jsR);
}
// Adding the Name of the Transformation to the Context
jsscope.put("_TransformationName_", jsscope, this.stepname);
try {
RowMetaInterface rowMeta = transMeta.getPrevStepFields(stepname);
if (rowMeta != null) {
ScriptDummy dummyStep = new ScriptDummy(rowMeta, transMeta.getStepFields(stepname));
Scriptable jsvalue = Context.toObject(dummyStep, jsscope);
jsscope.put("_step_", jsscope, jsvalue);
// Modification for Additional Script parsing
try {
if (input.getAddClasses() != null) {
for (int i = 0; i < input.getAddClasses().length; i++) {
Object jsOut = Context.javaToJS(input.getAddClasses()[i].getAddObject(), jsscope);
ScriptableObject.putProperty(jsscope, input.getAddClasses()[i].getJSName(), jsOut);
}
}
} catch (Exception e) {
testException = new KettleException(BaseMessages.getString(PKG, "ScriptDialog.CouldNotAddToContext", e.toString()));
retval = false;
}
// Adding some default JavaScriptFunctions to the System
try {
Context.javaToJS(ScriptAddedFunctions.class, jsscope);
((ScriptableObject) jsscope).defineFunctionProperties(jsFunctionList, ScriptAddedFunctions.class, ScriptableObject.DONTENUM);
} catch (Exception ex) {
testException = new KettleException(BaseMessages.getString(PKG, "ScriptDialog.CouldNotAddDefaultFunctions", ex.toString()));
retval = false;
}
// Adding some Constants to the JavaScript
try {
jsscope.put("SKIP_TRANSFORMATION", jsscope, Integer.valueOf(SKIP_TRANSFORMATION));
jsscope.put("ABORT_TRANSFORMATION", jsscope, Integer.valueOf(ABORT_TRANSFORMATION));
jsscope.put("ERROR_TRANSFORMATION", jsscope, Integer.valueOf(ERROR_TRANSFORMATION));
jsscope.put("CONTINUE_TRANSFORMATION", jsscope, Integer.valueOf(CONTINUE_TRANSFORMATION));
} catch (Exception ex) {
testException = new KettleException(BaseMessages.getString(PKG, "ScriptDialog.CouldNotAddTransformationConstants", ex.toString()));
retval = false;
}
try {
Object[] row = new Object[rowMeta.size()];
Scriptable jsRowMeta = Context.toObject(rowMeta, jsscope);
jsscope.put("rowMeta", jsscope, jsRowMeta);
for (int i = 0; i < rowMeta.size(); i++) {
ValueMetaInterface valueMeta = rowMeta.getValueMeta(i);
Object valueData = null;
//
if (valueMeta.isDate()) {
valueData = new Date();
}
if (valueMeta.isString()) {
valueData = "test value test value test value test value test " + "value test value test value test value test value test value";
}
if (valueMeta.isInteger()) {
valueData = Long.valueOf(0L);
}
if (valueMeta.isNumber()) {
valueData = new Double(0.0);
}
if (valueMeta.isBigNumber()) {
valueData = BigDecimal.ZERO;
}
if (valueMeta.isBoolean()) {
valueData = Boolean.TRUE;
}
if (valueMeta.isBinary()) {
valueData = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
if (valueMeta.isStorageBinaryString()) {
valueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
}
row[i] = valueData;
Scriptable jsarg = Context.toObject(valueData, jsscope);
jsscope.put(valueMeta.getName(), jsscope, jsarg);
}
// OK, for these input values, we're going to allow the user to edit the default values...
// We are displaying a
// 2)
// Add support for Value class (new Value())
Scriptable jsval = Context.toObject(Value.class, jsscope);
jsscope.put("Value", jsscope, jsval);
// Add the old style row object for compatibility reasons...
//
Scriptable jsRow = Context.toObject(row, jsscope);
jsscope.put("row", jsscope, jsRow);
} catch (Exception ev) {
testException = new KettleException(BaseMessages.getString(PKG, "ScriptDialog.CouldNotAddInputFields", ev.toString()));
retval = false;
}
try {
// Checking for StartScript
if (strActiveStartScript != null && !folder.getSelection().getText().equals(strActiveStartScript) && strActiveStartScript.length() > 0) {
String strStartScript = getStyledTextComp(folder.getItem(getCTabPosition(strActiveStartScript))).getText();
/* Object startScript = */
jscx.evaluateString(jsscope, strStartScript, "trans_Start", 1, null);
}
} catch (Exception e) {
testException = new KettleException(BaseMessages.getString(PKG, "ScriptDialog.CouldProcessStartScript", e.toString()));
retval = false;
}
try {
Script evalScript = jscx.compileString(scr, "script", 1, null);
evalScript.exec(jscx, jsscope);
if (getvars) {
ScriptNode tree = parseVariables(jscx, jsscope, scr, "script", 1, null);
for (int i = 0; i < tree.getParamAndVarCount(); i++) {
String varname = tree.getParamOrVarName(i);
if (!varname.equalsIgnoreCase("row") && !varname.equalsIgnoreCase("trans_Status")) {
int type = ValueMetaInterface.TYPE_STRING;
int length = -1, precision = -1;
Object result = jsscope.get(varname, jsscope);
if (result != null) {
String classname = result.getClass().getName();
if (classname.equalsIgnoreCase("java.lang.Byte")) {
// MAX = 127
type = ValueMetaInterface.TYPE_INTEGER;
length = 3;
precision = 0;
} else if (classname.equalsIgnoreCase("java.lang.Integer")) {
// MAX = 2147483647
type = ValueMetaInterface.TYPE_INTEGER;
length = 9;
precision = 0;
} else if (classname.equalsIgnoreCase("java.lang.Long")) {
// MAX = 9223372036854775807
type = ValueMetaInterface.TYPE_INTEGER;
length = 18;
precision = 0;
} else if (classname.equalsIgnoreCase("java.lang.Double")) {
type = ValueMetaInterface.TYPE_NUMBER;
length = 16;
precision = 2;
} else if (classname.equalsIgnoreCase("org.mozilla.javascript.NativeDate") || classname.equalsIgnoreCase("java.util.Date")) {
type = ValueMetaInterface.TYPE_DATE;
} else if (classname.equalsIgnoreCase("java.lang.Boolean")) {
type = ValueMetaInterface.TYPE_BOOLEAN;
}
}
TableItem ti = new TableItem(wFields.table, SWT.NONE);
ti.setText(1, varname);
ti.setText(2, "");
ti.setText(3, ValueMetaFactory.getValueMetaName(type));
ti.setText(4, length >= 0 ? ("" + length) : "");
ti.setText(5, precision >= 0 ? ("" + precision) : "");
// If the variable name exists in the input, suggest to replace the value
//
ti.setText(6, (rowMeta.indexOfValue(varname) >= 0) ? YES_NO_COMBO[1] : YES_NO_COMBO[0]);
}
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
}
// End Script!
} catch (EvaluatorException e) {
String position = "(" + e.lineNumber() + ":" + e.columnNumber() + ")";
String message = BaseMessages.getString(PKG, "ScriptDialog.Exception.CouldNotExecuteScript", position);
testException = new KettleException(message, e);
retval = false;
} catch (JavaScriptException e) {
String position = "(" + e.lineNumber() + ":" + e.columnNumber() + ")";
String message = BaseMessages.getString(PKG, "ScriptDialog.Exception.CouldNotExecuteScript", position);
testException = new KettleException(message, e);
retval = false;
} catch (Exception e) {
testException = new KettleException(BaseMessages.getString(PKG, "ScriptDialog.Exception.CouldNotExecuteScript2"), e);
retval = false;
}
} else {
testException = new KettleException(BaseMessages.getString(PKG, "ScriptDialog.Exception.CouldNotGetFields"));
retval = false;
}
if (popup) {
if (retval) {
if (!getvars) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "ScriptDialog.ScriptCompilationOK") + Const.CR);
mb.setText("OK");
mb.open();
}
} else {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ScriptDialog.TestFailed.DialogTitle"), BaseMessages.getString(PKG, "ScriptDialog.TestFailed.DialogMessage"), testException);
}
}
} catch (KettleException ke) {
retval = false;
new ErrorDialog(shell, BaseMessages.getString(PKG, "ScriptDialog.TestFailed.DialogTitle"), BaseMessages.getString(PKG, "ScriptDialog.TestFailed.DialogMessage"), ke);
} finally {
if (jscx != null) {
Context.exit();
}
}
return retval;
}
use of org.pentaho.di.ui.core.widget.StyledTextComp in project pentaho-kettle by pentaho.
the class ScriptDialog method setPosition.
public void setPosition() {
StyledTextComp wScript = getStyledTextComp();
String scr = wScript.getText();
int linenr = wScript.getLineAtOffset(wScript.getCaretOffset()) + 1;
int posnr = wScript.getCaretOffset();
// Go back from position to last CR: how many positions?
int colnr = 0;
while (posnr > 0 && scr.charAt(posnr - 1) != '\n' && scr.charAt(posnr - 1) != '\r') {
posnr--;
colnr++;
}
wlPosition.setText(BaseMessages.getString(PKG, "ScriptDialog.Position.Label2") + linenr + ", " + colnr);
}
use of org.pentaho.di.ui.core.widget.StyledTextComp in project pentaho-kettle by pentaho.
the class ScriptDialog method addCtab.
private void addCtab(String cScriptName, String strScript, int iType) {
CTabItem item = new CTabItem(folder, SWT.CLOSE);
switch(iType) {
case ADD_DEFAULT:
item.setText(cScriptName);
break;
default:
item.setText(getNextName(cScriptName));
break;
}
StyledTextComp wScript = new StyledTextComp(transMeta, item.getParent(), SWT.MULTI | SWT.LEFT | SWT.H_SCROLL | SWT.V_SCROLL, item.getText(), false);
if ((strScript != null) && strScript.length() > 0) {
wScript.setText(strScript);
} else {
wScript.setText(BaseMessages.getString(PKG, "ScriptDialog.ScriptHere.Label") + Const.CR + Const.CR);
}
item.setImage(imageInactiveScript);
props.setLook(wScript, Props.WIDGET_STYLE_FIXED);
wScript.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
setPosition();
}
public void keyReleased(KeyEvent e) {
setPosition();
}
});
wScript.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
setPosition();
}
public void focusLost(FocusEvent e) {
setPosition();
}
});
wScript.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
setPosition();
}
public void mouseDown(MouseEvent e) {
setPosition();
}
public void mouseUp(MouseEvent e) {
setPosition();
}
});
wScript.addModifyListener(lsMod);
// Text Higlighting
wScript.addLineStyleListener(new ScriptHighlight(ScriptAddedFunctions.jsFunctionList));
item.setControl(wScript);
// Adding new Item to Tree
modifyScriptTree(item, ADD_ITEM);
}
use of org.pentaho.di.ui.core.widget.StyledTextComp in project pentaho-kettle by pentaho.
the class RegexEvalDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
input.setChanged();
}
};
SelectionListener lsSel = new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
};
changed = input.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Filename line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wStepname.setText(stepname);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
wSash = new SashForm(shell, SWT.VERTICAL);
wTabFolder = new CTabFolder(wSash, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "RegexEvalDialog.GeneralTab.TabTitle"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// Step Settings grouping?
// ////////////////////////
// START OF Step Settings GROUP
//
wStepSettings = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wStepSettings);
wStepSettings.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Group.StepSettings.Label"));
FormLayout groupLayout = new FormLayout();
groupLayout.marginWidth = 10;
groupLayout.marginHeight = 10;
wStepSettings.setLayout(groupLayout);
// fieldevaluate
wlfieldevaluate = new Label(wStepSettings, SWT.RIGHT);
wlfieldevaluate.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Matcher.Label"));
props.setLook(wlfieldevaluate);
fdlfieldevaluate = new FormData();
fdlfieldevaluate.left = new FormAttachment(0, 0);
fdlfieldevaluate.top = new FormAttachment(wStepname, margin);
fdlfieldevaluate.right = new FormAttachment(middle, -margin);
wlfieldevaluate.setLayoutData(fdlfieldevaluate);
wfieldevaluate = new CCombo(wStepSettings, SWT.BORDER | SWT.READ_ONLY);
wfieldevaluate.setEditable(true);
props.setLook(wfieldevaluate);
wfieldevaluate.addModifyListener(lsMod);
fdfieldevaluate = new FormData();
fdfieldevaluate.left = new FormAttachment(middle, margin);
fdfieldevaluate.top = new FormAttachment(wStepname, margin);
fdfieldevaluate.right = new FormAttachment(100, -margin);
wfieldevaluate.setLayoutData(fdfieldevaluate);
wfieldevaluate.addSelectionListener(lsSel);
wfieldevaluate.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
getPreviousFields();
shell.setCursor(null);
busy.dispose();
}
});
// Output Fieldame
wResultField = new LabelTextVar(transMeta, wStepSettings, BaseMessages.getString(PKG, "RegexEvalDialog.ResultField.Label"), BaseMessages.getString(PKG, "RegexEvalDialog.ResultField.Tooltip"));
props.setLook(wResultField);
wResultField.addModifyListener(lsMod);
fdResultField = new FormData();
fdResultField.left = new FormAttachment(0, 0);
fdResultField.top = new FormAttachment(wfieldevaluate, margin);
fdResultField.right = new FormAttachment(100, 0);
wResultField.setLayoutData(fdResultField);
// Allow capture groups?
wlAllowCaptureGroups = new Label(wStepSettings, SWT.RIGHT);
wlAllowCaptureGroups.setText(BaseMessages.getString(PKG, "RegexEvalDialog.AllowCaptureGroups.Label"));
props.setLook(wlAllowCaptureGroups);
FormData fdlAllowCaptureGroups = new FormData();
fdlAllowCaptureGroups.left = new FormAttachment(0, 0);
fdlAllowCaptureGroups.top = new FormAttachment(wResultField, margin);
fdlAllowCaptureGroups.right = new FormAttachment(middle, -margin);
wlAllowCaptureGroups.setLayoutData(fdlAllowCaptureGroups);
wAllowCaptureGroups = new Button(wStepSettings, SWT.CHECK);
wAllowCaptureGroups.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.AllowCaptureGroups.Tooltip"));
props.setLook(wAllowCaptureGroups);
FormData fdAllowCaptureGroups = new FormData();
fdAllowCaptureGroups.left = new FormAttachment(middle, margin);
fdAllowCaptureGroups.top = new FormAttachment(wResultField, margin);
fdAllowCaptureGroups.right = new FormAttachment(100, 0);
wAllowCaptureGroups.setLayoutData(fdAllowCaptureGroups);
wAllowCaptureGroups.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setFieldsEnabledStatus();
input.setChanged();
}
});
// Replace fields?
wlReplaceFields = new Label(wStepSettings, SWT.RIGHT);
wlReplaceFields.setText(BaseMessages.getString(PKG, "RegexEvalDialog.ReplaceFields.Label"));
props.setLook(wlReplaceFields);
FormData fdlReplaceFields = new FormData();
fdlReplaceFields.left = new FormAttachment(0, 0);
fdlReplaceFields.top = new FormAttachment(wAllowCaptureGroups, margin);
fdlReplaceFields.right = new FormAttachment(middle, -margin);
wlReplaceFields.setLayoutData(fdlReplaceFields);
wReplaceFields = new Button(wStepSettings, SWT.CHECK);
wReplaceFields.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.ReplaceFields.Tooltip"));
props.setLook(wReplaceFields);
FormData fdReplaceFields = new FormData();
fdReplaceFields.left = new FormAttachment(middle, margin);
fdReplaceFields.top = new FormAttachment(wAllowCaptureGroups, margin);
fdReplaceFields.right = new FormAttachment(100, 0);
wReplaceFields.setLayoutData(fdReplaceFields);
wReplaceFields.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// settings layout
fdStepSettings = new FormData();
fdStepSettings.left = new FormAttachment(0, margin);
fdStepSettings.top = new FormAttachment(wStepname, margin);
fdStepSettings.right = new FormAttachment(100, -margin);
wStepSettings.setLayoutData(fdStepSettings);
// ///////////////////////////////////////////////////////////
// / END OF STEP SETTINGS GROUP
// ///////////////////////////////////////////////////////////
// Script line
wlScript = new Label(wGeneralComp, SWT.NONE);
wlScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Javascript.Label"));
props.setLook(wlScript);
fdlScript = new FormData();
fdlScript.left = new FormAttachment(0, 0);
fdlScript.top = new FormAttachment(wStepSettings, margin);
wlScript.setLayoutData(fdlScript);
wbTestRegExScript = new Button(wGeneralComp, SWT.PUSH | SWT.CENTER);
props.setLook(wbTestRegExScript);
wbTestRegExScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.TestScript.Label"));
fdbTestRegExScript = new FormData();
fdbTestRegExScript.right = new FormAttachment(100, -margin);
fdbTestRegExScript.top = new FormAttachment(wStepSettings, margin);
wbTestRegExScript.setLayoutData(fdbTestRegExScript);
wScript = new StyledTextComp(transMeta, wGeneralComp, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, "");
wScript.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Script.Label"));
props.setLook(wScript, Props.WIDGET_STYLE_FIXED);
wScript.addModifyListener(lsMod);
fdScript = new FormData();
fdScript.left = new FormAttachment(0, 0);
fdScript.top = new FormAttachment(wbTestRegExScript, margin);
fdScript.right = new FormAttachment(100, -10);
fdScript.bottom = new FormAttachment(100, -25);
wScript.setLayoutData(fdScript);
// SelectionAdapter lsVar = VariableButtonListenerFactory.getSelectionAdapter(shell, wScript);
// wScript.addKeyListener(TextVar.getControlSpaceKeyListener(wScript, lsVar));
// Variable substitution?
wlUseVar = new Label(wGeneralComp, SWT.NONE);
wlUseVar.setText(BaseMessages.getString(PKG, "RegexEvalDialog.UseVar.Label"));
props.setLook(wlUseVar);
FormData fdlUseVar = new FormData();
fdlUseVar.left = new FormAttachment(0, margin);
fdlUseVar.top = new FormAttachment(wScript, margin);
wlUseVar.setLayoutData(fdlUseVar);
wUseVar = new Button(wGeneralComp, SWT.CHECK);
wUseVar.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.UseVar.Tooltip"));
props.setLook(wUseVar);
FormData fdUseVar = new FormData();
fdUseVar.left = new FormAttachment(wlUseVar, margin);
fdUseVar.top = new FormAttachment(wScript, margin);
wUseVar.setLayoutData(fdUseVar);
wUseVar.addSelectionListener(lsSel);
wBottom = new Composite(wSash, SWT.NONE);
props.setLook(wBottom);
FormLayout bottomLayout = new FormLayout();
bottomLayout.marginWidth = Const.FORM_MARGIN;
bottomLayout.marginHeight = Const.FORM_MARGIN;
wBottom.setLayout(bottomLayout);
wSeparator = new Label(wBottom, SWT.SEPARATOR | SWT.HORIZONTAL);
fdSeparator = new FormData();
fdSeparator.left = new FormAttachment(0, 0);
fdSeparator.right = new FormAttachment(100, 0);
fdSeparator.top = new FormAttachment(0, -margin + 2);
wSeparator.setLayoutData(fdSeparator);
wlFields = new Label(wBottom, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Fields.Label"));
wlFields.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Fields.Tooltip"));
props.setLook(wlFields);
fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wSeparator, 0);
wlFields.setLayoutData(fdlFields);
final int fieldsRows = input.getFieldName().length;
ColumnInfo[] columnInfo = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.NewField"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Type"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaFactory.getValueMetaNames()), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Length"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Precision"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Format"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Group"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Decimal"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Currency"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.Nullif"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.IfNull"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "RegexEvalDialog.ColumnInfo.TrimType"), ColumnInfo.COLUMN_TYPE_CCOMBO, ValueMetaString.trimTypeDesc, true) };
wFields = new TableView(transMeta, wBottom, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, columnInfo, fieldsRows, lsMod, props);
fdFields = new FormData();
fdFields.left = new FormAttachment(0, 0);
fdFields.top = new FormAttachment(wlFields, margin);
fdFields.right = new FormAttachment(100, 0);
fdFields.bottom = new FormAttachment(100, 0);
wFields.setLayoutData(fdFields);
fdGeneralComp = new FormData();
fdGeneralComp.left = new FormAttachment(0, 0);
fdGeneralComp.top = new FormAttachment(0, 0);
fdGeneralComp.right = new FormAttachment(100, 0);
fdGeneralComp.bottom = new FormAttachment(100, 0);
wGeneralComp.setLayoutData(fdGeneralComp);
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
props.setLook(wGeneralComp);
// ///////////////////////////////////////////////////////////
// / END OF GENERAL TAB
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF CONTENT TAB///
// /
wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "RegexEvalDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
wContentComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// Step RegexSettings grouping?
// ////////////////////////
// START OF RegexSettings GROUP
//
wRegexSettings = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wRegexSettings);
wRegexSettings.setText("Regex Settings");
FormLayout regexLayout = new FormLayout();
regexLayout.marginWidth = 10;
regexLayout.marginHeight = 10;
wRegexSettings.setLayout(regexLayout);
// Canon_Eq?
wlCanonEq = new Label(wRegexSettings, SWT.RIGHT);
wlCanonEq.setText(BaseMessages.getString(PKG, "RegexEvalDialog.CanonEq.Label"));
props.setLook(wlCanonEq);
FormData fdlCanonEq = new FormData();
fdlCanonEq.left = new FormAttachment(0, 0);
fdlCanonEq.top = new FormAttachment(wStepSettings, margin);
fdlCanonEq.right = new FormAttachment(middle, -margin);
wlCanonEq.setLayoutData(fdlCanonEq);
wCanonEq = new Button(wRegexSettings, SWT.CHECK);
wCanonEq.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.CanonEq.Tooltip"));
props.setLook(wCanonEq);
FormData fdCanonEq = new FormData();
fdCanonEq.left = new FormAttachment(middle, 0);
fdCanonEq.top = new FormAttachment(wStepSettings, margin);
fdCanonEq.right = new FormAttachment(100, 0);
wCanonEq.setLayoutData(fdCanonEq);
wCanonEq.addSelectionListener(lsSel);
// CASE_INSENSITIVE?
wlCaseInsensitive = new Label(wRegexSettings, SWT.RIGHT);
wlCaseInsensitive.setText(BaseMessages.getString(PKG, "RegexEvalDialog.CaseInsensitive.Label"));
props.setLook(wlCaseInsensitive);
FormData fdlCaseInsensitive = new FormData();
fdlCaseInsensitive.left = new FormAttachment(0, 0);
fdlCaseInsensitive.top = new FormAttachment(wCanonEq, margin);
fdlCaseInsensitive.right = new FormAttachment(middle, -margin);
wlCaseInsensitive.setLayoutData(fdlCaseInsensitive);
wCaseInsensitive = new Button(wRegexSettings, SWT.CHECK);
wCaseInsensitive.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.CaseInsensitive.Tooltip"));
props.setLook(wCaseInsensitive);
FormData fdCaseInsensitive = new FormData();
fdCaseInsensitive.left = new FormAttachment(middle, 0);
fdCaseInsensitive.top = new FormAttachment(wCanonEq, margin);
fdCaseInsensitive.right = new FormAttachment(100, 0);
wCaseInsensitive.setLayoutData(fdCaseInsensitive);
wCaseInsensitive.addSelectionListener(lsSel);
// COMMENT?
wlComment = new Label(wRegexSettings, SWT.RIGHT);
wlComment.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Comment.Label"));
props.setLook(wlComment);
FormData fdlComment = new FormData();
fdlComment.left = new FormAttachment(0, 0);
fdlComment.top = new FormAttachment(wCaseInsensitive, margin);
fdlComment.right = new FormAttachment(middle, -margin);
wlComment.setLayoutData(fdlComment);
wComment = new Button(wRegexSettings, SWT.CHECK);
wComment.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Comment.Tooltip"));
props.setLook(wComment);
FormData fdComment = new FormData();
fdComment.left = new FormAttachment(middle, 0);
fdComment.top = new FormAttachment(wCaseInsensitive, margin);
fdComment.right = new FormAttachment(100, 0);
wComment.setLayoutData(fdComment);
wComment.addSelectionListener(lsSel);
// DOTALL?
wlDotAll = new Label(wRegexSettings, SWT.RIGHT);
wlDotAll.setText(BaseMessages.getString(PKG, "RegexEvalDialog.DotAll.Label"));
props.setLook(wlDotAll);
FormData fdlDotAll = new FormData();
fdlDotAll.left = new FormAttachment(0, 0);
fdlDotAll.top = new FormAttachment(wComment, margin);
fdlDotAll.right = new FormAttachment(middle, -margin);
wlDotAll.setLayoutData(fdlDotAll);
wDotAll = new Button(wRegexSettings, SWT.CHECK);
wDotAll.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.DotAll.Tooltip"));
props.setLook(wDotAll);
FormData fdDotAll = new FormData();
fdDotAll.left = new FormAttachment(middle, 0);
fdDotAll.top = new FormAttachment(wComment, margin);
fdDotAll.right = new FormAttachment(100, 0);
wDotAll.setLayoutData(fdDotAll);
wDotAll.addSelectionListener(lsSel);
// MULTILINE?
wlMultiline = new Label(wRegexSettings, SWT.RIGHT);
wlMultiline.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Multiline.Label"));
props.setLook(wlMultiline);
FormData fdlMultiline = new FormData();
fdlMultiline.left = new FormAttachment(0, 0);
fdlMultiline.top = new FormAttachment(wDotAll, margin);
fdlMultiline.right = new FormAttachment(middle, -margin);
wlMultiline.setLayoutData(fdlMultiline);
wMultiline = new Button(wRegexSettings, SWT.CHECK);
wMultiline.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Multiline.Tooltip"));
props.setLook(wMultiline);
FormData fdMultiline = new FormData();
fdMultiline.left = new FormAttachment(middle, 0);
fdMultiline.top = new FormAttachment(wDotAll, margin);
fdMultiline.right = new FormAttachment(100, 0);
wMultiline.setLayoutData(fdMultiline);
wMultiline.addSelectionListener(lsSel);
// UNICODE?
wlUnicode = new Label(wRegexSettings, SWT.RIGHT);
wlUnicode.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Unicode.Label"));
props.setLook(wlUnicode);
FormData fdlUnicode = new FormData();
fdlUnicode.left = new FormAttachment(0, 0);
fdlUnicode.top = new FormAttachment(wMultiline, margin);
fdlUnicode.right = new FormAttachment(middle, -margin);
wlUnicode.setLayoutData(fdlUnicode);
wUnicode = new Button(wRegexSettings, SWT.CHECK);
wUnicode.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Unicode.Tooltip"));
props.setLook(wUnicode);
FormData fdUnicode = new FormData();
fdUnicode.left = new FormAttachment(middle, 0);
fdUnicode.top = new FormAttachment(wMultiline, margin);
fdUnicode.right = new FormAttachment(100, 0);
wUnicode.setLayoutData(fdUnicode);
wUnicode.addSelectionListener(lsSel);
// UNIX?
wlUnix = new Label(wRegexSettings, SWT.RIGHT);
wlUnix.setText(BaseMessages.getString(PKG, "RegexEvalDialog.Unix.Label"));
props.setLook(wlUnix);
FormData fdlUnix = new FormData();
fdlUnix.left = new FormAttachment(0, 0);
fdlUnix.top = new FormAttachment(wUnicode, margin);
fdlUnix.right = new FormAttachment(middle, -margin);
wlUnix.setLayoutData(fdlUnix);
wUnix = new Button(wRegexSettings, SWT.CHECK);
wUnix.setToolTipText(BaseMessages.getString(PKG, "RegexEvalDialog.Unix.Tooltip"));
props.setLook(wUnix);
FormData fdUnix = new FormData();
fdUnix.left = new FormAttachment(middle, 0);
fdUnix.top = new FormAttachment(wUnicode, margin);
fdUnix.right = new FormAttachment(100, 0);
wUnix.setLayoutData(fdUnix);
wUnix.addSelectionListener(lsSel);
fdRegexSettings = new FormData();
fdRegexSettings.left = new FormAttachment(0, margin);
fdRegexSettings.top = new FormAttachment(wStepSettings, margin);
fdRegexSettings.right = new FormAttachment(100, -margin);
wRegexSettings.setLayoutData(fdRegexSettings);
// ///////////////////////////////////////////////////////////
// / END OF RegexSettings GROUP
// ///////////////////////////////////////////////////////////
fdContentComp = new FormData();
fdContentComp.left = new FormAttachment(0, 0);
fdContentComp.top = new FormAttachment(0, 0);
fdContentComp.right = new FormAttachment(100, 0);
fdContentComp.bottom = new FormAttachment(100, 0);
wContentComp.setLayoutData(wContentComp);
wContentComp.layout();
wContentTab.setControl(wContentComp);
// ///////////////////////////////////////////////////////////
// / END OF CONTENT TAB
// ///////////////////////////////////////////////////////////
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wStepname, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
fdBottom = new FormData();
fdBottom.left = new FormAttachment(0, 0);
fdBottom.top = new FormAttachment(0, 0);
fdBottom.right = new FormAttachment(100, 0);
fdBottom.bottom = new FormAttachment(100, 0);
wBottom.setLayoutData(fdBottom);
fdSash = new FormData();
fdSash.left = new FormAttachment(0, 0);
fdSash.top = new FormAttachment(wStepname, 0);
fdSash.right = new FormAttachment(100, 0);
fdSash.bottom = new FormAttachment(100, -50);
wSash.setLayoutData(fdSash);
wSash.setWeights(new int[] { 60, 40 });
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
lsbTestRegExScript = new Listener() {
public void handleEvent(Event e) {
testRegExScript();
}
};
wbTestRegExScript.addListener(SWT.Selection, lsbTestRegExScript);
setButtonPositions(new Button[] { wOK, wCancel }, margin, null);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData();
setFieldsEnabledStatus();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations