use of org.pentaho.di.ui.core.widget.LabelComboVar in project pentaho-kettle by pentaho.
the class AutoDocDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, inputMeta);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
inputMeta.setChanged();
}
};
changed = inputMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "AutoDoc.Step.Name"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "AutoDocDialog.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);
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);
Control lastControl = wStepname;
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
wFilenameField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Tooltip"));
wFilenameField.setItems(previousFields.getFieldNames());
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
FormData fdFilenameField = new FormData();
fdFilenameField.top = new FormAttachment(lastControl, margin);
fdFilenameField.left = new FormAttachment(0, 0);
fdFilenameField.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilenameField);
lastControl = wFilenameField;
// The FileType field ...
//
wFileTypeField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Tooltip"));
wFileTypeField.setItems(previousFields.getFieldNames());
props.setLook(wFileTypeField);
wFileTypeField.addModifyListener(lsMod);
FormData fdFileTypeField = new FormData();
fdFileTypeField.top = new FormAttachment(lastControl, margin);
fdFileTypeField.left = new FormAttachment(0, 0);
fdFileTypeField.right = new FormAttachment(100, 0);
wFileTypeField.setLayoutData(fdFileTypeField);
lastControl = wFileTypeField;
// The target filename ...
//
wTargetFilename = new LabelTextVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Label"), BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Tooltip"));
props.setLook(wTargetFilename);
wTargetFilename.addModifyListener(lsMod);
FormData fdTargetFilename = new FormData();
fdTargetFilename.top = new FormAttachment(lastControl, margin);
fdTargetFilename.left = new FormAttachment(0, 0);
fdTargetFilename.right = new FormAttachment(100, 0);
wTargetFilename.setLayoutData(fdTargetFilename);
lastControl = wTargetFilename;
// The output type ...
//
wOutputType = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Label"), BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Tooltip"));
OutputType[] outputTypes = KettleReportBuilder.OutputType.values();
String[] items = new String[outputTypes.length];
for (int i = 0; i < outputTypes.length; i++) {
items[i] = outputTypes[i].name();
}
wOutputType.setItems(items);
props.setLook(wOutputType);
wOutputType.addModifyListener(lsMod);
wOutputType.getComboWidget().setEditable(false);
FormData fdOutputType = new FormData();
fdOutputType.top = new FormAttachment(lastControl, margin);
fdOutputType.left = new FormAttachment(0, 0);
fdOutputType.right = new FormAttachment(100, 0);
wOutputType.setLayoutData(fdOutputType);
wOutputType.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFlags();
}
});
lastControl = wOutputType;
// Include name check-box
//
Label wlInclName = new Label(shell, SWT.RIGHT);
wlInclName.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclName.Label"));
props.setLook(wlInclName);
FormData fdlInclName = new FormData();
fdlInclName.left = new FormAttachment(0, 0);
fdlInclName.right = new FormAttachment(middle, -margin);
fdlInclName.top = new FormAttachment(lastControl, margin);
wlInclName.setLayoutData(fdlInclName);
wInclName = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclName);
FormData fdInclName = new FormData();
fdInclName.left = new FormAttachment(middle, 0);
fdInclName.right = new FormAttachment(100, 0);
fdInclName.top = new FormAttachment(lastControl, margin);
wInclName.setLayoutData(fdInclName);
lastControl = wInclName;
// Include description check-box
//
Label wlInclDesc = new Label(shell, SWT.RIGHT);
wlInclDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclDesc.Label"));
props.setLook(wlInclDesc);
FormData fdlInclDesc = new FormData();
fdlInclDesc.left = new FormAttachment(0, 0);
fdlInclDesc.right = new FormAttachment(middle, -margin);
fdlInclDesc.top = new FormAttachment(lastControl, margin);
wlInclDesc.setLayoutData(fdlInclDesc);
wInclDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclDesc);
FormData fdInclDesc = new FormData();
fdInclDesc.left = new FormAttachment(middle, 0);
fdInclDesc.right = new FormAttachment(100, 0);
fdInclDesc.top = new FormAttachment(lastControl, margin);
wInclDesc.setLayoutData(fdInclDesc);
lastControl = wInclDesc;
// Include extended description check-box
//
Label wlInclExtDesc = new Label(shell, SWT.RIGHT);
wlInclExtDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclExtDesc.Label"));
props.setLook(wlInclExtDesc);
FormData fdlInclExtDesc = new FormData();
fdlInclExtDesc.left = new FormAttachment(0, 0);
fdlInclExtDesc.right = new FormAttachment(middle, -margin);
fdlInclExtDesc.top = new FormAttachment(lastControl, margin);
wlInclExtDesc.setLayoutData(fdlInclExtDesc);
wInclExtDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclExtDesc);
FormData fdInclExtDesc = new FormData();
fdInclExtDesc.left = new FormAttachment(middle, 0);
fdInclExtDesc.right = new FormAttachment(100, 0);
fdInclExtDesc.top = new FormAttachment(lastControl, margin);
wInclExtDesc.setLayoutData(fdInclExtDesc);
lastControl = wInclExtDesc;
// Include creation information (user/date) check-box
//
Label wlInclCreated = new Label(shell, SWT.RIGHT);
wlInclCreated.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclCreated.Label"));
props.setLook(wlInclCreated);
FormData fdlInclCreated = new FormData();
fdlInclCreated.left = new FormAttachment(0, 0);
fdlInclCreated.right = new FormAttachment(middle, -margin);
fdlInclCreated.top = new FormAttachment(lastControl, margin);
wlInclCreated.setLayoutData(fdlInclCreated);
wInclCreated = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclCreated);
FormData fdInclCreated = new FormData();
fdInclCreated.left = new FormAttachment(middle, 0);
fdInclCreated.right = new FormAttachment(100, 0);
fdInclCreated.top = new FormAttachment(lastControl, margin);
wInclCreated.setLayoutData(fdInclCreated);
lastControl = wInclCreated;
// Include modified information (user/date) check-box
//
Label wlInclModified = new Label(shell, SWT.RIGHT);
wlInclModified.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclModified.Label"));
props.setLook(wlInclModified);
FormData fdlInclModified = new FormData();
fdlInclModified.left = new FormAttachment(0, 0);
fdlInclModified.right = new FormAttachment(middle, -margin);
fdlInclModified.top = new FormAttachment(lastControl, margin);
wlInclModified.setLayoutData(fdlInclModified);
wInclModified = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclModified);
FormData fdInclModified = new FormData();
fdInclModified.left = new FormAttachment(middle, 0);
fdInclModified.right = new FormAttachment(100, 0);
fdInclModified.top = new FormAttachment(lastControl, margin);
wInclModified.setLayoutData(fdInclModified);
lastControl = wInclModified;
// Include image check-box
//
Label wlInclImage = new Label(shell, SWT.RIGHT);
wlInclImage.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclImage.Label"));
props.setLook(wlInclImage);
FormData fdlInclImage = new FormData();
fdlInclImage.left = new FormAttachment(0, 0);
fdlInclImage.right = new FormAttachment(middle, -margin);
fdlInclImage.top = new FormAttachment(lastControl, margin);
wlInclImage.setLayoutData(fdlInclImage);
wInclImage = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclImage);
FormData fdInclImage = new FormData();
fdInclImage.left = new FormAttachment(middle, 0);
fdInclImage.right = new FormAttachment(100, 0);
fdInclImage.top = new FormAttachment(lastControl, margin);
wInclImage.setLayoutData(fdInclImage);
lastControl = wInclImage;
// Include logging check-box
//
Label wlInclLogging = new Label(shell, SWT.RIGHT);
wlInclLogging.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLogging.Label"));
props.setLook(wlInclLogging);
FormData fdlInclLogging = new FormData();
fdlInclLogging.left = new FormAttachment(0, 0);
fdlInclLogging.right = new FormAttachment(middle, -margin);
fdlInclLogging.top = new FormAttachment(lastControl, margin);
wlInclLogging.setLayoutData(fdlInclLogging);
wInclLogging = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclLogging);
FormData fdInclLogging = new FormData();
fdInclLogging.left = new FormAttachment(middle, 0);
fdInclLogging.right = new FormAttachment(100, 0);
fdInclLogging.top = new FormAttachment(lastControl, margin);
wInclLogging.setLayoutData(fdInclLogging);
lastControl = wInclLogging;
// Include last execution date check-box
//
Label wlInclLastExecResult = new Label(shell, SWT.RIGHT);
wlInclLastExecResult.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLastExecResult.Label"));
props.setLook(wlInclLastExecResult);
FormData fdlInclLastExecResult = new FormData();
fdlInclLastExecResult.left = new FormAttachment(0, 0);
fdlInclLastExecResult.right = new FormAttachment(middle, -margin);
fdlInclLastExecResult.top = new FormAttachment(lastControl, margin);
wlInclLastExecResult.setLayoutData(fdlInclLastExecResult);
wInclLastExecResult = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclLastExecResult);
FormData fdInclLastExecResult = new FormData();
fdInclLastExecResult.left = new FormAttachment(middle, 0);
fdInclLastExecResult.right = new FormAttachment(100, 0);
fdInclLastExecResult.top = new FormAttachment(lastControl, margin);
wInclLastExecResult.setLayoutData(fdInclLastExecResult);
lastControl = wInclLastExecResult;
// Some buttons first, so that the dialog scales nicely...
//
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"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, lastControl);
// 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);
wFilenameField.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
inputMeta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.LabelComboVar in project pentaho-kettle by pentaho.
the class ElasticSearchBulkDialog method fillOptionsGroup.
private void fillOptionsGroup(Composite parentTab) {
int margin = Const.MARGIN;
wSettingsGroup = new Group(parentTab, SWT.SHADOW_NONE);
props.setLook(wSettingsGroup);
wSettingsGroup.setText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.SettingsGroup.Label"));
FormLayout settingGroupLayout = new FormLayout();
settingGroupLayout.marginWidth = 10;
settingGroupLayout.marginHeight = 10;
wSettingsGroup.setLayout(settingGroupLayout);
// Timeout
wTimeOut = new LabelTimeComposite(wSettingsGroup, BaseMessages.getString(PKG, "ElasticSearchBulkDialog.TimeOut" + ".Label"), BaseMessages.getString(PKG, "ElasticSearchBulkDialog.TimeOut.Tooltip"));
props.setLook(wTimeOut);
wTimeOut.addModifyListener(lsMod);
// BatchSize
wlBatchSize = new Label(wSettingsGroup, SWT.RIGHT);
wlBatchSize.setText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.BatchSize.Label"));
props.setLook(wlBatchSize);
wBatchSize = new TextVar(transMeta, wSettingsGroup, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wBatchSize);
wBatchSize.addModifyListener(lsMod);
// Stop on error
wlStopOnError = new Label(wSettingsGroup, SWT.RIGHT);
wlStopOnError.setText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.StopOnError.Label"));
wStopOnError = new Button(wSettingsGroup, SWT.CHECK | SWT.RIGHT);
wStopOnError.setToolTipText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.StopOnError.Tooltip"));
wStopOnError.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
widgetSelected(arg0);
}
public void widgetSelected(SelectionEvent arg0) {
model.setChanged();
}
});
// ID input
wIdInField = new LabelComboVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "ElasticSearchBulkDialog.IdField.Label"), BaseMessages.getString(PKG, "ElasticSearchBulkDialog.IdField.Tooltip"));
props.setLook(wIdInField);
wIdInField.getComboWidget().setEditable(true);
wIdInField.addModifyListener(lsMod);
wIdInField.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
getPreviousFields(wIdInField);
}
});
getPreviousFields(wIdInField);
wlIsOverwrite = new Label(wSettingsGroup, SWT.RIGHT);
wlIsOverwrite.setText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.Overwrite.Label"));
wIsOverwrite = new Button(wSettingsGroup, SWT.CHECK | SWT.RIGHT);
wIsOverwrite.setToolTipText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.Overwrite.Tooltip"));
wIsOverwrite.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
widgetSelected(arg0);
}
public void widgetSelected(SelectionEvent arg0) {
model.setChanged();
}
});
// Output rows
wlUseOutput = new Label(wSettingsGroup, SWT.RIGHT);
wlUseOutput.setText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.UseOutput.Label"));
wUseOutput = new Button(wSettingsGroup, SWT.CHECK | SWT.RIGHT);
wUseOutput.setToolTipText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.UseOutput.Tooltip"));
wUseOutput.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
widgetSelected(arg0);
}
public void widgetSelected(SelectionEvent arg0) {
wIdOutField.setEnabled(wUseOutput.getSelection());
model.setChanged();
}
});
// ID out field
wIdOutField = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "ElasticSearchBulkDialog.IdOutField.Label"), BaseMessages.getString(PKG, "ElasticSearchBulkDialog.IdOutField.Tooltip"));
props.setLook(wIdOutField);
wIdOutField.setEnabled(wUseOutput.getSelection());
wIdOutField.addModifyListener(lsMod);
// use json
wlIsJson = new Label(wSettingsGroup, SWT.RIGHT);
wlIsJson.setText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.IsJson.Label"));
wIsJson = new Button(wSettingsGroup, SWT.CHECK | SWT.RIGHT);
wIsJson.setToolTipText(BaseMessages.getString(PKG, "ElasticSearchBulkDialog.IsJson.Tooltip"));
wIsJson.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
widgetSelected(arg0);
}
public void widgetSelected(SelectionEvent arg0) {
wJsonField.setEnabled(wIsJson.getSelection());
wFields.setEnabled(!wIsJson.getSelection());
wFields.setVisible(!wIsJson.getSelection());
wGet.setEnabled(!wIsJson.getSelection());
model.setChanged();
}
});
// Json field
wJsonField = new LabelComboVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "ElasticSearchBulkDialog.JsonField.Label"), BaseMessages.getString(PKG, "ElasticSearchBulkDialog.JsonField.Tooltip"));
wJsonField.getComboWidget().setEditable(true);
props.setLook(wJsonField);
wJsonField.addModifyListener(lsMod);
wJsonField.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
getPreviousFields(wJsonField);
}
});
getPreviousFields(wJsonField);
wJsonField.setEnabled(wIsJson.getSelection());
Control[] settingsControls = new Control[] { wlBatchSize, wBatchSize, wlStopOnError, wStopOnError, wTimeOut, wIdInField, wlIsOverwrite, wIsOverwrite, wlUseOutput, wUseOutput, wIdOutField, wlIsJson, wIsJson, wJsonField };
placeControls(wSettingsGroup, settingsControls);
fdSettingsGroup = new FormData();
fdSettingsGroup.left = new FormAttachment(0, margin);
fdSettingsGroup.top = new FormAttachment(wIndexGroup, margin);
fdSettingsGroup.right = new FormAttachment(100, -margin);
wSettingsGroup.setLayoutData(fdSettingsGroup);
}
Aggregations