use of org.apache.hop.ui.core.dialog.EnterSelectionDialog in project hop by apache.
the class PropertyOutputDialog method open.
@Override
public String open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = e -> input.setChanged();
backupChanged = input.hasChanged();
int middle = props.getMiddlePct();
int margin = props.getMargin();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.DialogTitle"));
// get previous fields name
getFields();
// Some buttons
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] { wOk, wCancel }, margin, null);
// TransformName line
wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(BaseMessages.getString(PKG, "System.Label.TransformName"));
props.setLook(wlTransformName);
fdlTransformName = new FormData();
fdlTransformName.left = new FormAttachment(0, 0);
fdlTransformName.right = new FormAttachment(middle, -margin);
fdlTransformName.top = new FormAttachment(0, margin);
wlTransformName.setLayoutData(fdlTransformName);
wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformName.setText(transformName);
props.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
fdTransformName = new FormData();
fdTransformName.left = new FormAttachment(middle, 0);
fdTransformName.top = new FormAttachment(0, margin);
fdTransformName.right = new FormAttachment(100, 0);
wTransformName.setLayoutData(fdTransformName);
CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
CTabItem wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.GeneralTab.TabTitle"));
Composite wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// Fields grouping?
// ////////////////////////
// START OF Fields GROUP
//
Group wFields = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wFields);
wFields.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.Group.Fields.Label"));
FormLayout groupFieldsLayout = new FormLayout();
groupFieldsLayout.marginWidth = 10;
groupFieldsLayout.marginHeight = 10;
wFields.setLayout(groupFieldsLayout);
// Key field
Label wlKeyField = new Label(wFields, SWT.RIGHT);
wlKeyField.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.KeyField.Label"));
props.setLook(wlKeyField);
FormData fdlKeyField = new FormData();
fdlKeyField.left = new FormAttachment(0, 0);
fdlKeyField.top = new FormAttachment(0, 3 * margin);
fdlKeyField.right = new FormAttachment(middle, -margin);
wlKeyField.setLayoutData(fdlKeyField);
wKeyField = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wKeyField.setEditable(true);
wKeyField.setItems(fieldNames);
props.setLook(wKeyField);
wKeyField.addModifyListener(lsMod);
FormData fdKeyField = new FormData();
fdKeyField.left = new FormAttachment(middle, 0);
fdKeyField.top = new FormAttachment(0, 3 * margin);
fdKeyField.right = new FormAttachment(100, 0);
wKeyField.setLayoutData(fdKeyField);
// Value field
Label wlValueField = new Label(wFields, SWT.RIGHT);
wlValueField.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.ValueField.Label"));
props.setLook(wlValueField);
FormData fdlValueField = new FormData();
fdlValueField.left = new FormAttachment(0, 0);
fdlValueField.top = new FormAttachment(wKeyField, margin);
fdlValueField.right = new FormAttachment(middle, -margin);
wlValueField.setLayoutData(fdlValueField);
wValueField = new CCombo(wFields, SWT.BORDER | SWT.READ_ONLY);
wValueField.setEditable(true);
wValueField.setItems(fieldNames);
props.setLook(wValueField);
wValueField.addModifyListener(lsMod);
FormData fdValueField = new FormData();
fdValueField.left = new FormAttachment(middle, 0);
fdValueField.top = new FormAttachment(wKeyField, margin);
fdValueField.right = new FormAttachment(100, 0);
wValueField.setLayoutData(fdValueField);
// Comment
Label wlComment = new Label(wGeneralComp, SWT.RIGHT);
wlComment.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.Comment.Label"));
props.setLook(wlComment);
FormData fdlComment = new FormData();
fdlComment.left = new FormAttachment(0, 0);
fdlComment.top = new FormAttachment(wFields, 2 * margin);
fdlComment.right = new FormAttachment(middle, -margin);
wlComment.setLayoutData(fdlComment);
wComment = new Text(wGeneralComp, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
wComment.setToolTipText(BaseMessages.getString(PKG, "PropertyOutputDialog.Comment.Tooltip"));
props.setLook(wComment);
wComment.addModifyListener(lsMod);
FormData fdComment = new FormData();
fdComment.left = new FormAttachment(middle, 0);
fdComment.top = new FormAttachment(wFields, 2 * margin);
fdComment.right = new FormAttachment(100, 0);
fdComment.bottom = new FormAttachment(100, -margin);
wComment.setLayoutData(fdComment);
FormData fdFields = new FormData();
fdFields.left = new FormAttachment(0, margin);
fdFields.top = new FormAttachment(0, margin);
fdFields.right = new FormAttachment(100, -margin);
wFields.setLayoutData(fdFields);
// ///////////////////////////////////////////////////////////
// / END OF Fields GROUP
// ///////////////////////////////////////////////////////////
FormData 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///
// /
CTabItem wContentTab = new CTabItem(wTabFolder, SWT.NONE);
wContentTab.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.ContentTab.TabTitle"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
Composite wContentComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wContentComp);
wContentComp.setLayout(contentLayout);
// File grouping?
// ////////////////////////
// START OF FileName GROUP
//
Group wFileName = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wFileName);
wFileName.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.Group.File.Label"));
FormLayout groupFileLayout = new FormLayout();
groupFileLayout.marginWidth = 10;
groupFileLayout.marginHeight = 10;
wFileName.setLayout(groupFileLayout);
// Filename line
wlFilename = new Label(wFileName, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.Filename.Label"));
props.setLook(wlFilename);
FormData fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(wFields, margin);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wbFilename = new Button(wFileName, SWT.PUSH | SWT.CENTER);
props.setLook(wbFilename);
wbFilename.setText(BaseMessages.getString(PKG, "System.Button.Browse"));
FormData fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(wFields, 0);
wbFilename.setLayoutData(fdbFilename);
wFilename = new TextVar(variables, wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
FormData fdFilename = new FormData();
fdFilename.left = new FormAttachment(middle, 0);
fdFilename.top = new FormAttachment(wFields, margin);
fdFilename.right = new FormAttachment(wbFilename, -margin);
wFilename.setLayoutData(fdFilename);
// Append checkbox
Label wlAppend = new Label(wFileName, SWT.RIGHT);
wlAppend.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.Append.Label"));
props.setLook(wlAppend);
FormData fdlAppend = new FormData();
fdlAppend.left = new FormAttachment(0, 0);
fdlAppend.top = new FormAttachment(wFilename, margin);
fdlAppend.right = new FormAttachment(middle, -margin);
wlAppend.setLayoutData(fdlAppend);
wAppend = new Button(wFileName, SWT.CHECK);
props.setLook(wAppend);
wAppend.setToolTipText(BaseMessages.getString(PKG, "PropertyOutputDialog.Append.Tooltip"));
FormData fdAppend = new FormData();
fdAppend.left = new FormAttachment(middle, 0);
fdAppend.top = new FormAttachment(wlAppend, 0, SWT.CENTER);
fdAppend.right = new FormAttachment(100, 0);
wAppend.setLayoutData(fdAppend);
wAppend.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
});
// Create Parent Folder
Label wlCreateParentFolder = new Label(wFileName, SWT.RIGHT);
wlCreateParentFolder.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.CreateParentFolder.Label"));
props.setLook(wlCreateParentFolder);
FormData fdlCreateParentFolder = new FormData();
fdlCreateParentFolder.left = new FormAttachment(0, 0);
fdlCreateParentFolder.top = new FormAttachment(wAppend, margin);
fdlCreateParentFolder.right = new FormAttachment(middle, -margin);
wlCreateParentFolder.setLayoutData(fdlCreateParentFolder);
wCreateParentFolder = new Button(wFileName, SWT.CHECK);
wCreateParentFolder.setToolTipText(BaseMessages.getString(PKG, "PropertyOutputDialog.CreateParentFolder.Tooltip"));
props.setLook(wCreateParentFolder);
FormData fdCreateParentFolder = new FormData();
fdCreateParentFolder.left = new FormAttachment(middle, 0);
fdCreateParentFolder.top = new FormAttachment(wlCreateParentFolder, 0, SWT.CENTER);
fdCreateParentFolder.right = new FormAttachment(100, 0);
wCreateParentFolder.setLayoutData(fdCreateParentFolder);
wCreateParentFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// FileNameInField line
Label wlFileNameInField = new Label(wFileName, SWT.RIGHT);
wlFileNameInField.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.FileNameInField.Label"));
props.setLook(wlFileNameInField);
FormData fdlFileNameInField = new FormData();
fdlFileNameInField.left = new FormAttachment(0, 0);
fdlFileNameInField.top = new FormAttachment(wCreateParentFolder, margin);
fdlFileNameInField.right = new FormAttachment(middle, -margin);
wlFileNameInField.setLayoutData(fdlFileNameInField);
wFileNameInField = new Button(wFileName, SWT.CHECK);
wlFileNameInField.setToolTipText(BaseMessages.getString(PKG, "PropertyOutputDialog.FileNameInField.Label"));
props.setLook(wFileNameInField);
FormData fdFileNameInField = new FormData();
fdFileNameInField.left = new FormAttachment(middle, 0);
fdFileNameInField.top = new FormAttachment(wlFileNameInField, 0, SWT.CENTER);
fdFileNameInField.right = new FormAttachment(100, 0);
wFileNameInField.setLayoutData(fdFileNameInField);
wFileNameInField.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
activateFilenameInField();
}
});
// FileNameField Line
wlFileNameField = new Label(wFileName, SWT.RIGHT);
wlFileNameField.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.FileNameField.Label"));
props.setLook(wlFileNameField);
FormData fdlFileNameField = new FormData();
fdlFileNameField.left = new FormAttachment(0, 0);
fdlFileNameField.right = new FormAttachment(middle, -margin);
fdlFileNameField.top = new FormAttachment(wFileNameInField, margin);
wlFileNameField.setLayoutData(fdlFileNameField);
wFileNameField = new ComboVar(variables, wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFileNameField);
wFileNameField.addModifyListener(lsMod);
FormData fdFileNameField = new FormData();
fdFileNameField.left = new FormAttachment(middle, 0);
fdFileNameField.top = new FormAttachment(wFileNameInField, margin);
fdFileNameField.right = new FormAttachment(100, 0);
wFileNameField.setLayoutData(fdFileNameField);
wFileNameField.setEnabled(false);
wFileNameField.setItems(fieldNames);
// Extension line
wlExtension = new Label(wFileName, SWT.RIGHT);
wlExtension.setText(BaseMessages.getString(PKG, "System.Label.Extension"));
props.setLook(wlExtension);
FormData fdlExtension = new FormData();
fdlExtension.left = new FormAttachment(0, 0);
fdlExtension.top = new FormAttachment(wFileNameField, margin);
fdlExtension.right = new FormAttachment(middle, -margin);
wlExtension.setLayoutData(fdlExtension);
wExtension = new TextVar(variables, wFileName, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wExtension);
wExtension.addModifyListener(lsMod);
FormData fdExtension = new FormData();
fdExtension.left = new FormAttachment(middle, 0);
fdExtension.top = new FormAttachment(wFileNameField, margin);
fdExtension.right = new FormAttachment(100, -margin);
wExtension.setLayoutData(fdExtension);
// Create multi-part file?
wlAddTransformNr = new Label(wFileName, SWT.RIGHT);
wlAddTransformNr.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.AddTransformnr.Label"));
props.setLook(wlAddTransformNr);
FormData fdlAddTransformNr = new FormData();
fdlAddTransformNr.left = new FormAttachment(0, 0);
fdlAddTransformNr.top = new FormAttachment(wExtension, 2 * margin);
fdlAddTransformNr.right = new FormAttachment(middle, -margin);
wlAddTransformNr.setLayoutData(fdlAddTransformNr);
wAddTransformNr = new Button(wFileName, SWT.CHECK);
props.setLook(wAddTransformNr);
FormData fdAddTransformNr = new FormData();
fdAddTransformNr.left = new FormAttachment(middle, 0);
fdAddTransformNr.top = new FormAttachment(wlAddTransformNr, 0, SWT.CENTER);
fdAddTransformNr.right = new FormAttachment(100, 0);
wAddTransformNr.setLayoutData(fdAddTransformNr);
wAddTransformNr.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddDate = new Label(wFileName, SWT.RIGHT);
wlAddDate.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.AddDate.Label"));
props.setLook(wlAddDate);
FormData fdlAddDate = new FormData();
fdlAddDate.left = new FormAttachment(0, 0);
fdlAddDate.top = new FormAttachment(wAddTransformNr, margin);
fdlAddDate.right = new FormAttachment(middle, -margin);
wlAddDate.setLayoutData(fdlAddDate);
wAddDate = new Button(wFileName, SWT.CHECK);
props.setLook(wAddDate);
FormData fdAddDate = new FormData();
fdAddDate.left = new FormAttachment(middle, 0);
fdAddDate.top = new FormAttachment(wlAddDate, 0, SWT.CENTER);
fdAddDate.right = new FormAttachment(100, 0);
wAddDate.setLayoutData(fdAddDate);
wAddDate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Create multi-part file?
wlAddTime = new Label(wFileName, SWT.RIGHT);
wlAddTime.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.AddTime.Label"));
props.setLook(wlAddTime);
FormData fdlAddTime = new FormData();
fdlAddTime.left = new FormAttachment(0, 0);
fdlAddTime.top = new FormAttachment(wAddDate, margin);
fdlAddTime.right = new FormAttachment(middle, -margin);
wlAddTime.setLayoutData(fdlAddTime);
wAddTime = new Button(wFileName, SWT.CHECK);
props.setLook(wAddTime);
FormData fdAddTime = new FormData();
fdAddTime.left = new FormAttachment(middle, 0);
fdAddTime.top = new FormAttachment(wlAddTime, 0, SWT.CENTER);
fdAddTime.right = new FormAttachment(100, 0);
wAddTime.setLayoutData(fdAddTime);
wAddTime.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
wbShowFiles = new Button(wFileName, SWT.PUSH | SWT.CENTER);
props.setLook(wbShowFiles);
wbShowFiles.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.ShowFiles.Button"));
FormData fdbShowFiles = new FormData();
fdbShowFiles.left = new FormAttachment(middle, 0);
fdbShowFiles.top = new FormAttachment(wAddTime, margin * 2);
wbShowFiles.setLayoutData(fdbShowFiles);
wbShowFiles.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PropertyOutputMeta tfoi = new PropertyOutputMeta();
getInfo(tfoi);
String[] files = tfoi.getFiles(variables);
if (files != null && files.length > 0) {
EnterSelectionDialog esd = new EnterSelectionDialog(shell, files, BaseMessages.getString(PKG, "PropertyOutputDialog.SelectOutputFiles.DialogTitle"), BaseMessages.getString(PKG, "PropertyOutputDialog.SelectOutputFiles.DialogMessage"));
esd.setViewOnly();
esd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "PropertyOutputDialog.NoFilesFound.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "System.DialogTitle.Error"));
mb.open();
}
}
});
FormData fdFileName = new FormData();
fdFileName.left = new FormAttachment(0, margin);
fdFileName.top = new FormAttachment(wFields, margin);
fdFileName.right = new FormAttachment(100, -margin);
wFileName.setLayoutData(fdFileName);
// ///////////////////////////////////////////////////////////
// / END OF FileName GROUP
// ///////////////////////////////////////////////////////////
// File grouping?
// ////////////////////////
// START OF ResultFile GROUP
//
Group wResultFile = new Group(wContentComp, SWT.SHADOW_NONE);
props.setLook(wResultFile);
wResultFile.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.Group.ResultFile.Label"));
FormLayout groupResultFile = new FormLayout();
groupResultFile.marginWidth = 10;
groupResultFile.marginHeight = 10;
wResultFile.setLayout(groupResultFile);
// Add File to the result files name
Label wlAddToResult = new Label(wResultFile, SWT.RIGHT);
wlAddToResult.setText(BaseMessages.getString(PKG, "PropertyOutputDialog.AddFileToResult.Label"));
props.setLook(wlAddToResult);
FormData fdlAddToResult = new FormData();
fdlAddToResult.left = new FormAttachment(0, 0);
fdlAddToResult.top = new FormAttachment(wFileName, margin);
fdlAddToResult.right = new FormAttachment(middle, -margin);
wlAddToResult.setLayoutData(fdlAddToResult);
wAddToResult = new Button(wResultFile, SWT.CHECK);
wAddToResult.setToolTipText(BaseMessages.getString(PKG, "PropertyOutputDialog.AddFileToResult.Tooltip"));
props.setLook(wAddToResult);
FormData fdAddToResult = new FormData();
fdAddToResult.left = new FormAttachment(middle, 0);
fdAddToResult.top = new FormAttachment(wlAddToResult, 0, SWT.CENTER);
fdAddToResult.right = new FormAttachment(100, 0);
wAddToResult.setLayoutData(fdAddToResult);
SelectionAdapter lsSelAR = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
input.setChanged();
}
};
wAddToResult.addSelectionListener(lsSelAR);
FormData fdResultFile = new FormData();
fdResultFile.left = new FormAttachment(0, margin);
fdResultFile.top = new FormAttachment(wFileName, margin);
fdResultFile.right = new FormAttachment(100, -margin);
wResultFile.setLayoutData(fdResultFile);
// ///////////////////////////////////////////////////////////
// / END OF ResultFile GROUP
// ///////////////////////////////////////////////////////////
FormData 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
// ///////////////////////////////////////////////////////////
FormData fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wTransformName, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(wOk, -2 * margin);
wTabFolder.setLayoutData(fdTabFolder);
// Add listeners
wbFilename.addListener(SWT.Selection, e -> BaseDialog.presentFileDialog(shell, wFilename, variables, new String[] { "*.txt", "*.csv", "*" }, new String[] { BaseMessages.getString(PKG, "System.FileType.TextFiles"), BaseMessages.getString(PKG, "System.FileType.CSVFiles"), BaseMessages.getString(PKG, "System.FileType.AllFiles") }, true));
wTabFolder.setSelection(0);
getData();
activateFilenameInField();
input.setChanged(changed);
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return transformName;
}
use of org.apache.hop.ui.core.dialog.EnterSelectionDialog in project hop by apache.
the class RandomValueDialog method open.
@Override
public String open() {
Shell parent = getParent();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
props.setLook(shell);
setShellImage(shell, input);
ModifyListener lsMod = 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, "RandomValueDialog.DialogTitle"));
int middle = props.getMiddlePct();
int margin = props.getMargin();
// TransformName line
Label wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(BaseMessages.getString(PKG, "System.Label.TransformName"));
props.setLook(wlTransformName);
FormData fdlTransformName = new FormData();
fdlTransformName.left = new FormAttachment(0, 0);
fdlTransformName.right = new FormAttachment(middle, -margin);
fdlTransformName.top = new FormAttachment(0, margin);
wlTransformName.setLayoutData(fdlTransformName);
wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformName.setText(transformName);
props.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
FormData fdTransformName = new FormData();
fdTransformName.left = new FormAttachment(middle, 0);
fdTransformName.top = new FormAttachment(0, margin);
fdTransformName.right = new FormAttachment(100, 0);
wTransformName.setLayoutData(fdTransformName);
// Some buttons
wOk = new Button(shell, SWT.PUSH);
wOk.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOk.addListener(SWT.Selection, e -> ok());
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
wCancel.addListener(SWT.Selection, e -> cancel());
setButtonPositions(new Button[] { wOk, wCancel }, margin, null);
Label wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "RandomValueDialog.Fields.Label"));
props.setLook(wlFields);
FormData fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wTransformName, margin);
wlFields.setLayoutData(fdlFields);
final int FieldsCols = 2;
final int FieldsRows = input.getFieldName().length;
final String[] functionDesc = new String[RandomValueMeta.functions.length - 1];
for (int i = 1; i < RandomValueMeta.functions.length; i++) {
functionDesc[i - 1] = RandomValueMeta.functions[i].getDescription();
}
ColumnInfo[] colinf = new ColumnInfo[FieldsCols];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "RandomValueDialog.NameColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinf[1] = new ColumnInfo(BaseMessages.getString(PKG, "RandomValueDialog.TypeColumn.Column"), ColumnInfo.COLUMN_TYPE_TEXT, false);
colinf[1].setSelectionAdapter(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
EnterSelectionDialog esd = new EnterSelectionDialog(shell, functionDesc, BaseMessages.getString(PKG, "RandomValueDialog.SelectInfoType.DialogTitle"), BaseMessages.getString(PKG, "RandomValueDialog.SelectInfoType.DialogMessage"));
String string = esd.open();
if (string != null) {
TableView tv = (TableView) e.widget;
tv.setText(string, e.x, e.y);
input.setChanged();
}
}
});
wFields = new TableView(variables, shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, FieldsRows, lsMod, props);
FormData 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(wOk, -2 * margin);
wFields.setLayoutData(fdFields);
getData();
input.setChanged(changed);
BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
return transformName;
}
use of org.apache.hop.ui.core.dialog.EnterSelectionDialog in project hop by apache.
the class TestingGuiPlugin method setGoldenDataSet.
/**
* We set an golden data set on the selected unit test
*/
@GuiContextAction(id = ACTION_ID_PIPELINE_GRAPH_TRANSFORM_DEFINE_GOLDEN_DATA_SET, parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Modify, name = "i18n::TestingGuiPlugin.ContextAction.SetGoldenDataset.Name", tooltip = "i18n::TestingGuiPlugin.ContextAction.SetGoldenDataset.Tooltip", image = "set-golden-dataset.svg", category = "i18n::TestingGuiPlugin.Category", categoryOrder = "8")
public void setGoldenDataSet(HopGuiPipelineTransformContext context) {
PipelineMeta sourcePipelineMeta = context.getPipelineMeta();
TransformMeta transformMeta = context.getTransformMeta();
HopGuiPipelineGraph pipelineGraph = context.getPipelineGraph();
IVariables variables = pipelineGraph.getVariables();
HopGui hopGui = HopGui.getInstance();
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
if (checkTestPresent(hopGui, sourcePipelineMeta)) {
return;
}
PipelineUnitTest unitTest = getCurrentUnitTest(sourcePipelineMeta);
try {
// Create a copy and modify the pipeline
// This way we have
PipelineMetaModifier modifier = new PipelineMetaModifier(variables, sourcePipelineMeta, unitTest);
PipelineMeta pipelineMeta = modifier.getTestPipeline(LogChannel.UI, variables, metadataProvider);
IHopMetadataSerializer<DataSet> setSerializer = metadataProvider.getSerializer(DataSet.class);
List<String> setNames = setSerializer.listObjectNames();
Collections.sort(setNames);
EnterSelectionDialog esd = new EnterSelectionDialog(hopGui.getShell(), setNames.toArray(new String[setNames.size()]), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Message"));
String setName = esd.open();
if (setName != null) {
DataSet dataSet = setSerializer.load(setName);
boolean changed = setGoldenDataSetOnTransform(variables, metadataProvider, pipelineMeta, transformMeta, unitTest, dataSet);
if (changed) {
pipelineGraph.updateGui();
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Error.Header"), BaseMessages.getString(PKG, "TestingGuiPlugin.ContextAction.SetGoldenDataset.Error.Message"), e);
}
}
use of org.apache.hop.ui.core.dialog.EnterSelectionDialog in project hop by apache.
the class DataProbeGuiPlugin method addDataProbeForTransform.
@GuiContextAction(id = "pipeline-graph-transform-9000-add-probe", parentId = HopGuiPipelineTransformContext.CONTEXT_ID, type = GuiActionType.Info, name = "Add data probe", tooltip = "Streams the rows to a pipeline defined in a selected pipeline probe", image = "probe.svg", category = "Preview", categoryOrder = "3")
public void addDataProbeForTransform(HopGuiPipelineTransformContext context) {
PipelineMeta pipelineMeta = context.getPipelineMeta();
TransformMeta transformMeta = context.getTransformMeta();
HopGui hopGui = HopGui.getInstance();
try {
// Present the user with a list of pipeline probes...
//
IHopMetadataProvider metadataProvider = hopGui.getMetadataProvider();
IHopMetadataSerializer<PipelineProbe> serializer = metadataProvider.getSerializer(PipelineProbe.class);
MetadataManager<PipelineProbe> manager = new MetadataManager<>(hopGui.getVariables(), metadataProvider, PipelineProbe.class);
PipelineProbe pipelineProbe = null;
List<String> pipelineProbeNames = serializer.listObjectNames();
if (pipelineProbeNames.isEmpty()) {
MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText("No probes available");
box.setMessage("There are no pipeline probe objects defined yet. Do you want to create one?");
int answer = box.open();
if ((answer & SWT.YES) != 0) {
// Create a new pipeline probe...
//
pipelineProbe = new PipelineProbe();
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
manager.newMetadata(pipelineProbe);
return;
} else {
return;
}
} else {
EnterSelectionDialog dialog = new EnterSelectionDialog(hopGui.getShell(), pipelineProbeNames.toArray(new String[0]), "Select pipeline probe", "Select the pipeline probe to add this pipeline transform to");
String pipelineProbeName = dialog.open();
if (pipelineProbeName != null) {
pipelineProbe = serializer.load(pipelineProbeName);
}
}
if (pipelineProbe != null) {
// See if it's open in the metadata perspective...
//
MetadataPerspective perspective = (MetadataPerspective) hopGui.getPerspectiveManager().findPerspective(MetadataPerspective.class);
String key = PipelineProbe.class.getAnnotation(HopMetadata.class).key();
PipelineProbeEditor editor = (PipelineProbeEditor) perspective.findEditor(key, pipelineProbe.getName());
if (editor != null) {
// We're going to change the current metadata and flag it as changed...
//
pipelineProbe = new PipelineProbe();
editor.getWidgetsContent(pipelineProbe);
// Add the location
//
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
// Replace and refresh the dialog
//
editor.setMetadata(pipelineProbe);
editor.setWidgetsContent();
// Set changed...
//
editor.setChanged();
// Switch to the editor...
//
perspective.activate();
perspective.setActiveEditor(editor);
return;
} else {
// Not opened in the perspective, simply add the data probe location...
//
addLocation(hopGui.getVariables(), pipelineProbe, pipelineMeta, transformMeta);
// ... and save the pipeline probe
//
serializer.save(pipelineProbe);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error adding pipeline probe to transform '" + transformMeta.getName() + "'", e);
}
}
use of org.apache.hop.ui.core.dialog.EnterSelectionDialog in project hop by apache.
the class CombinationLookupDialog method getSchemaNames.
private void getSchemaNames() {
DatabaseMeta databaseMeta = pipelineMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, variables, databaseMeta);
try {
database.connect();
String[] schemas = database.getSchemas();
if (null != schemas && schemas.length > 0) {
schemas = Const.sortStrings(schemas);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, schemas, BaseMessages.getString(PKG, "CombinationLookupDialog.AvailableSchemas.Title", wConnection.getText()), BaseMessages.getString(PKG, "CombinationLookupDialog.AvailableSchemas.Message", wConnection.getText()));
String d = dialog.open();
if (d != null) {
wSchema.setText(Const.NVL(d, ""));
setTableFieldCombo();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(BaseMessages.getString(PKG, "CombinationLookupDialog.NoSchema.Error"));
mb.setText(BaseMessages.getString(PKG, "CombinationLookupDialog.GetSchemas.Error"));
mb.open();
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "CombinationLookupDialog.ErrorGettingSchemas"), e);
} finally {
database.disconnect();
}
}
}
Aggregations