use of org.pentaho.di.ui.core.widget.LabelTextVar in project pentaho-kettle by pentaho.
the class JobEntryExportRepositoryDialog 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, "JobExportRepository.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Repositoryname line
wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "JobExportRepository.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);
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "JobExportRepository.Tab.General.Label"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// ////////////////////////
// START OF Repository Infos GROUP///
// /
wRepositoryInfos = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wRepositoryInfos);
wRepositoryInfos.setText(BaseMessages.getString(PKG, "JobExportRepository.RepositoryInfos.Group.Label"));
FormLayout RepositoryInfosgroupLayout = new FormLayout();
RepositoryInfosgroupLayout.marginWidth = 10;
RepositoryInfosgroupLayout.marginHeight = 10;
wRepositoryInfos.setLayout(RepositoryInfosgroupLayout);
// Repositoryname line
wlRepositoryname = new Label(wRepositoryInfos, SWT.RIGHT);
wlRepositoryname.setText(BaseMessages.getString(PKG, "JobExportRepository.Repositoryname.Label"));
props.setLook(wlRepositoryname);
fdlRepositoryname = new FormData();
fdlRepositoryname.left = new FormAttachment(0, margin);
fdlRepositoryname.top = new FormAttachment(wName, margin);
fdlRepositoryname.right = new FormAttachment(middle, -margin);
wlRepositoryname.setLayoutData(fdlRepositoryname);
wbRepositoryname = new Button(wRepositoryInfos, SWT.PUSH | SWT.CENTER);
props.setLook(wbRepositoryname);
wbRepositoryname.setText(BaseMessages.getString(PKG, "JobExportRepository.ListRepositories.Label"));
wbRepositoryname.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.ListRepositories.Tooltip"));
fdbRepositoryname = new FormData();
fdbRepositoryname.right = new FormAttachment(100, 0);
fdbRepositoryname.top = new FormAttachment(wName, 0);
wbRepositoryname.setLayoutData(fdbRepositoryname);
wbRepositoryname.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
getListRepositories();
}
});
wRepositoryname = new TextVar(jobMeta, wRepositoryInfos, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wRepositoryname);
wRepositoryname.addModifyListener(lsMod);
fdRepositoryname = new FormData();
fdRepositoryname.left = new FormAttachment(middle, margin);
fdRepositoryname.top = new FormAttachment(wName, margin);
fdRepositoryname.right = new FormAttachment(wbRepositoryname, -margin);
wRepositoryname.setLayoutData(fdRepositoryname);
// Whenever something changes, set the tooltip to the expanded version:
wRepositoryname.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
wRepositoryname.setToolTipText(jobMeta.environmentSubstitute(wRepositoryname.getText()));
}
});
// UserName line
wUserName = new LabelTextVar(jobMeta, wRepositoryInfos, BaseMessages.getString(PKG, "JobExportRepository.User.Label"), BaseMessages.getString(PKG, "JobExportRepository.User.Tooltip"));
props.setLook(wUserName);
wUserName.addModifyListener(lsMod);
fdUserName = new FormData();
fdUserName.left = new FormAttachment(0, 0);
fdUserName.top = new FormAttachment(wRepositoryname, margin);
fdUserName.right = new FormAttachment(100, 0);
wUserName.setLayoutData(fdUserName);
// Password line
wPassword = new LabelTextVar(jobMeta, wRepositoryInfos, BaseMessages.getString(PKG, "JobExportRepository.Password.Label"), BaseMessages.getString(PKG, "JobExportRepository.Password.Tooltip"), true);
props.setLook(wPassword);
wPassword.addModifyListener(lsMod);
fdPassword = new FormData();
fdPassword.left = new FormAttachment(0, 0);
fdPassword.top = new FormAttachment(wUserName, margin);
fdPassword.right = new FormAttachment(100, 0);
wPassword.setLayoutData(fdPassword);
// Test connection button
wTest = new Button(wRepositoryInfos, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "JobExportRepository.TestConnection.Label"));
props.setLook(wTest);
fdTest = new FormData();
wTest.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.TestConnection.Tooltip"));
// fdTest.left = new FormAttachment(middle, 0);
fdTest.top = new FormAttachment(wPassword, 2 * margin);
fdTest.right = new FormAttachment(100, 0);
wTest.setLayoutData(fdTest);
fdRepositoryInfos = new FormData();
fdRepositoryInfos.left = new FormAttachment(0, margin);
fdRepositoryInfos.top = new FormAttachment(wName, margin);
fdRepositoryInfos.right = new FormAttachment(100, -margin);
wRepositoryInfos.setLayoutData(fdRepositoryInfos);
// ///////////////////////////////////////////////////////////
// / END OF Repository Infos GROUP
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF Settings GROUP///
// //////////////////////////////
wSettings = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wSettings);
wSettings.setText(BaseMessages.getString(PKG, "JobExportRepository.Settings.Group.Label"));
FormLayout SettingsgroupLayout = new FormLayout();
SettingsgroupLayout.marginWidth = 10;
SettingsgroupLayout.marginHeight = 10;
wSettings.setLayout(SettingsgroupLayout);
wlExportType = new Label(wSettings, SWT.RIGHT);
wlExportType.setText(BaseMessages.getString(PKG, "JobExportRepository.ExportType.Label"));
props.setLook(wlExportType);
fdlExportType = new FormData();
fdlExportType.left = new FormAttachment(0, 0);
fdlExportType.right = new FormAttachment(middle, 0);
fdlExportType.top = new FormAttachment(wRepositoryInfos, margin);
wlExportType.setLayoutData(fdlExportType);
wExportType = new CCombo(wSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wExportType.add(BaseMessages.getString(PKG, "JobExportRepository.Export_All.Label"));
wExportType.add(BaseMessages.getString(PKG, "JobExportRepository.Export_Jobs.Label"));
wExportType.add(BaseMessages.getString(PKG, "JobExportRepository.Export_Trans.Label"));
wExportType.add(BaseMessages.getString(PKG, "JobExportRepository.Export_By_Folder.Label"));
wExportType.add(BaseMessages.getString(PKG, "JobExportRepository.Export_One_Folder.Label"));
// +1: starts at -1
wExportType.select(0);
props.setLook(wExportType);
fdExportType = new FormData();
fdExportType.left = new FormAttachment(middle, margin);
fdExportType.top = new FormAttachment(wTargetFilename, margin);
fdExportType.right = new FormAttachment(100, 0);
wExportType.setLayoutData(fdExportType);
wExportType.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
activeOneFolder();
}
});
// Foldername line
wlFoldername = new Label(wSettings, SWT.RIGHT);
wlFoldername.setText(BaseMessages.getString(PKG, "JobExportRepository.Foldername.Label"));
props.setLook(wlFoldername);
fdlFoldername = new FormData();
fdlFoldername.left = new FormAttachment(0, margin);
fdlFoldername.top = new FormAttachment(wExportType, margin);
fdlFoldername.right = new FormAttachment(middle, -margin);
wlFoldername.setLayoutData(fdlFoldername);
wbFoldername = new Button(wSettings, SWT.PUSH | SWT.CENTER);
props.setLook(wbFoldername);
// wbFoldername.setText(BaseMessages.getString(PKG, "JobExportRepository.ListFolders.Label"));
wbFoldername.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.ListFolders.Tooltip"));
wbFoldername.setImage(GUIResource.getInstance().getImageBol());
fdbFoldername = new FormData();
fdbFoldername.right = new FormAttachment(100, 0);
fdbFoldername.top = new FormAttachment(wExportType, 0);
wbFoldername.setLayoutData(fdbFoldername);
wbFoldername.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
displaydirectoryList();
}
});
wFoldername = new TextVar(jobMeta, wSettings, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFoldername);
wFoldername.addModifyListener(lsMod);
fdFoldername = new FormData();
fdFoldername.left = new FormAttachment(middle, margin);
fdFoldername.top = new FormAttachment(wExportType, margin);
fdFoldername.right = new FormAttachment(wbFoldername, -margin);
wFoldername.setLayoutData(fdFoldername);
// Whenever something changes, set the tooltip to the expanded version:
wFoldername.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
wFoldername.setToolTipText(jobMeta.environmentSubstitute(wFoldername.getText()));
}
});
// export each directory to a new folder?
wlNewFolder = new Label(wSettings, SWT.RIGHT);
wlNewFolder.setText(BaseMessages.getString(PKG, "JobExportRepository.NewFolder.Label"));
props.setLook(wlNewFolder);
fdlNewFolder = new FormData();
fdlNewFolder.left = new FormAttachment(0, 0);
fdlNewFolder.top = new FormAttachment(wFoldername, margin);
fdlNewFolder.right = new FormAttachment(middle, -margin);
wlNewFolder.setLayoutData(fdlNewFolder);
wNewFolder = new Button(wSettings, SWT.CHECK);
props.setLook(wNewFolder);
wNewFolder.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.NewFolder.Tooltip"));
fdNewFolder = new FormData();
fdNewFolder.left = new FormAttachment(middle, margin);
fdNewFolder.top = new FormAttachment(wFoldername, margin);
fdNewFolder.right = new FormAttachment(100, 0);
wNewFolder.setLayoutData(fdNewFolder);
wNewFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
fdSettings = new FormData();
fdSettings.left = new FormAttachment(0, margin);
fdSettings.top = new FormAttachment(wRepositoryInfos, margin);
fdSettings.right = new FormAttachment(100, -margin);
wSettings.setLayoutData(fdSettings);
// ///////////////////////////////////////////////////////////
// / END OF Settings GROUP
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF Target Filename GROUP///
// //////////////////////////////
wTarget = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wTarget);
wTarget.setText(BaseMessages.getString(PKG, "JobExportRepository.Target.Group.Label"));
FormLayout TargetgroupLayout = new FormLayout();
TargetgroupLayout.marginWidth = 10;
TargetgroupLayout.marginHeight = 10;
wTarget.setLayout(TargetgroupLayout);
// Target filename line
wlTargetFilename = new Label(wTarget, SWT.RIGHT);
wlTargetFilename.setText(BaseMessages.getString(PKG, "JobExportRepository.TargetFilename.Label"));
props.setLook(wlTargetFilename);
fdlTargetFilename = new FormData();
fdlTargetFilename.left = new FormAttachment(0, 0);
fdlTargetFilename.top = new FormAttachment(wSettings, margin);
fdlTargetFilename.right = new FormAttachment(middle, -margin);
wlTargetFilename.setLayoutData(fdlTargetFilename);
// Browse Source folders button ...
wbTargetFilename = new Button(wTarget, SWT.PUSH | SWT.CENTER);
props.setLook(wbTargetFilename);
wbTargetFilename.setText(BaseMessages.getString(PKG, "JobExportRepository.BrowseFolders.Label"));
fdbTargetFilename = new FormData();
fdbTargetFilename.right = new FormAttachment(100, 0);
fdbTargetFilename.top = new FormAttachment(wSettings, margin);
wbTargetFilename.setLayoutData(fdbTargetFilename);
wbTargetFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog ddialog = new DirectoryDialog(shell, SWT.OPEN);
if (wTargetFilename.getText() != null) {
ddialog.setFilterPath(jobMeta.environmentSubstitute(wTargetFilename.getText()));
}
// Calling open() will open and run the dialog.
// It will return the selected directory, or
// null if user cancels
String dir = ddialog.open();
if (dir != null) {
// Set the text box to the new selection
wTargetFilename.setText(dir);
}
}
});
// Browse Source files button ...
wbTargetFoldername = new Button(wTarget, SWT.PUSH | SWT.CENTER);
props.setLook(wbTargetFoldername);
wbTargetFoldername.setText(BaseMessages.getString(PKG, "JobExportRepository.BrowseFiles.Label"));
fdbTargetFoldername = new FormData();
fdbTargetFoldername.right = new FormAttachment(wbTargetFilename, -margin);
fdbTargetFoldername.top = new FormAttachment(wSettings, margin);
wbTargetFoldername.setLayoutData(fdbTargetFoldername);
wbTargetFoldername.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.xml", ".*" });
if (wTargetFilename.getText() != null) {
dialog.setFileName(jobMeta.environmentSubstitute(wTargetFilename.getText()));
}
dialog.setFilterNames(FILETYPES);
if (dialog.open() != null) {
wTargetFilename.setText(dialog.getFilterPath() + Const.FILE_SEPARATOR + dialog.getFileName());
}
}
});
// Target filename line
wTargetFilename = new TextVar(jobMeta, wTarget, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTargetFilename);
wTargetFilename.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.TargetFilename.Tooltip"));
wTargetFilename.addModifyListener(lsMod);
fdTargetFilename = new FormData();
fdTargetFilename.left = new FormAttachment(middle, margin);
fdTargetFilename.top = new FormAttachment(wSettings, margin);
fdTargetFilename.right = new FormAttachment(wbTargetFoldername, -margin);
wTargetFilename.setLayoutData(fdTargetFilename);
// create folder or parent folder?
wlcreateFolder = new Label(wTarget, SWT.RIGHT);
wlcreateFolder.setText(BaseMessages.getString(PKG, "JobExportRepository.createFolder.Label"));
props.setLook(wlcreateFolder);
fdlcreateFolder = new FormData();
fdlcreateFolder.left = new FormAttachment(0, 0);
fdlcreateFolder.top = new FormAttachment(wTargetFilename, margin);
fdlcreateFolder.right = new FormAttachment(middle, -margin);
wlcreateFolder.setLayoutData(fdlcreateFolder);
wcreateFolder = new Button(wTarget, SWT.CHECK);
props.setLook(wcreateFolder);
wcreateFolder.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.createFolder.Tooltip"));
fdcreateFolder = new FormData();
fdcreateFolder.left = new FormAttachment(middle, margin);
fdcreateFolder.top = new FormAttachment(wTargetFilename, margin);
fdcreateFolder.right = new FormAttachment(100, 0);
wcreateFolder.setLayoutData(fdcreateFolder);
wcreateFolder.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// Create multi-part file?
wlAddDate = new Label(wTarget, SWT.RIGHT);
wlAddDate.setText(BaseMessages.getString(PKG, "JobExportRepository.AddDate.Label"));
props.setLook(wlAddDate);
fdlAddDate = new FormData();
fdlAddDate.left = new FormAttachment(0, 0);
fdlAddDate.top = new FormAttachment(wcreateFolder, margin);
fdlAddDate.right = new FormAttachment(middle, -margin);
wlAddDate.setLayoutData(fdlAddDate);
wAddDate = new Button(wTarget, SWT.CHECK);
props.setLook(wAddDate);
wAddDate.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.AddDate.Tooltip"));
fdAddDate = new FormData();
fdAddDate.left = new FormAttachment(middle, margin);
fdAddDate.top = new FormAttachment(wcreateFolder, margin);
fdAddDate.right = new FormAttachment(100, 0);
wAddDate.setLayoutData(fdAddDate);
wAddDate.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// Create multi-part file?
wlAddTime = new Label(wTarget, SWT.RIGHT);
wlAddTime.setText(BaseMessages.getString(PKG, "JobExportRepository.AddTime.Label"));
props.setLook(wlAddTime);
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(wTarget, SWT.CHECK);
props.setLook(wAddTime);
wAddTime.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.AddTime.Tooltip"));
fdAddTime = new FormData();
fdAddTime.left = new FormAttachment(middle, margin);
fdAddTime.top = new FormAttachment(wAddDate, margin);
fdAddTime.right = new FormAttachment(100, 0);
wAddTime.setLayoutData(fdAddTime);
wAddTime.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
// Specify date time format?
wlSpecifyFormat = new Label(wTarget, SWT.RIGHT);
wlSpecifyFormat.setText(BaseMessages.getString(PKG, "JobExportRepository.SpecifyFormat.Label"));
props.setLook(wlSpecifyFormat);
fdlSpecifyFormat = new FormData();
fdlSpecifyFormat.left = new FormAttachment(0, 0);
fdlSpecifyFormat.top = new FormAttachment(wAddTime, margin);
fdlSpecifyFormat.right = new FormAttachment(middle, -margin);
wlSpecifyFormat.setLayoutData(fdlSpecifyFormat);
wSpecifyFormat = new Button(wTarget, SWT.CHECK);
props.setLook(wSpecifyFormat);
wSpecifyFormat.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.SpecifyFormat.Tooltip"));
fdSpecifyFormat = new FormData();
fdSpecifyFormat.left = new FormAttachment(middle, margin);
fdSpecifyFormat.top = new FormAttachment(wAddTime, margin);
fdSpecifyFormat.right = new FormAttachment(100, 0);
wSpecifyFormat.setLayoutData(fdSpecifyFormat);
wSpecifyFormat.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
setDateTimeFormat();
}
});
// DateTimeFormat
wlDateTimeFormat = new Label(wTarget, SWT.RIGHT);
wlDateTimeFormat.setText(BaseMessages.getString(PKG, "JobExportRepository.DateTimeFormat.Label"));
props.setLook(wlDateTimeFormat);
fdlDateTimeFormat = new FormData();
fdlDateTimeFormat.left = new FormAttachment(0, 0);
fdlDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
fdlDateTimeFormat.right = new FormAttachment(middle, -margin);
wlDateTimeFormat.setLayoutData(fdlDateTimeFormat);
wDateTimeFormat = new CCombo(wTarget, SWT.BORDER | SWT.READ_ONLY);
wDateTimeFormat.setEditable(true);
props.setLook(wDateTimeFormat);
wDateTimeFormat.addModifyListener(lsMod);
fdDateTimeFormat = new FormData();
fdDateTimeFormat.left = new FormAttachment(middle, margin);
fdDateTimeFormat.top = new FormAttachment(wSpecifyFormat, margin);
fdDateTimeFormat.right = new FormAttachment(100, 0);
wDateTimeFormat.setLayoutData(fdDateTimeFormat);
// Prepare a list of possible DateTimeFormats...
String[] dats = Const.getDateFormats();
for (int x = 0; x < dats.length; x++) {
wDateTimeFormat.add(dats[x]);
}
// If File Exists
wlIfFileExists = new Label(wTarget, SWT.RIGHT);
wlIfFileExists.setText(BaseMessages.getString(PKG, "JobExportRepository.IfFileExists.Label"));
props.setLook(wlIfFileExists);
fdlIfFileExists = new FormData();
fdlIfFileExists.left = new FormAttachment(0, 0);
fdlIfFileExists.right = new FormAttachment(middle, 0);
fdlIfFileExists.top = new FormAttachment(wDateTimeFormat, margin);
wlIfFileExists.setLayoutData(fdlIfFileExists);
wIfFileExists = new CCombo(wTarget, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wIfFileExists.add(BaseMessages.getString(PKG, "JobExportRepository.Do_Nothing_IfFileExists.Label"));
wIfFileExists.add(BaseMessages.getString(PKG, "JobExportRepository.Overwrite_File_IfFileExists.Label"));
wIfFileExists.add(BaseMessages.getString(PKG, "JobExportRepository.Unique_Name_IfFileExists.Label"));
wIfFileExists.add(BaseMessages.getString(PKG, "JobExportRepository.Fail_IfFileExists.Label"));
// +1: starts at -1
wIfFileExists.select(0);
props.setLook(wIfFileExists);
fdIfFileExists = new FormData();
fdIfFileExists.left = new FormAttachment(middle, margin);
fdIfFileExists.top = new FormAttachment(wDateTimeFormat, margin);
fdIfFileExists.right = new FormAttachment(100, 0);
wIfFileExists.setLayoutData(fdIfFileExists);
// Add file to result
wlAddFileToResult = new Label(wTarget, SWT.RIGHT);
wlAddFileToResult.setText(BaseMessages.getString(PKG, "JobExportRepository.AddFileToResult.Label"));
props.setLook(wlAddFileToResult);
fdlAddFileToResult = new FormData();
fdlAddFileToResult.left = new FormAttachment(0, 0);
fdlAddFileToResult.top = new FormAttachment(wIfFileExists, margin);
fdlAddFileToResult.right = new FormAttachment(middle, -margin);
wlAddFileToResult.setLayoutData(fdlAddFileToResult);
wAddFileToResult = new Button(wTarget, SWT.CHECK);
props.setLook(wAddFileToResult);
wAddFileToResult.setToolTipText(BaseMessages.getString(PKG, "JobExportRepository.AddFileToResult.Tooltip"));
fdAddFileToResult = new FormData();
fdAddFileToResult.left = new FormAttachment(middle, margin);
fdAddFileToResult.top = new FormAttachment(wIfFileExists, margin);
fdAddFileToResult.right = new FormAttachment(100, 0);
wAddFileToResult.setLayoutData(fdAddFileToResult);
wAddFileToResult.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
jobEntry.setChanged();
}
});
fdTarget = new FormData();
fdTarget.left = new FormAttachment(0, margin);
fdTarget.top = new FormAttachment(wSettings, margin);
fdTarget.right = new FormAttachment(100, -margin);
wTarget.setLayoutData(fdTarget);
// ///////////////////////////////////////////////////////////
// / END OF Target GROUP
// ///////////////////////////////////////////////////////////
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 ADVANCED TAB ///
// ///////////////////////////////////
wAdvancedTab = new CTabItem(wTabFolder, SWT.NONE);
wAdvancedTab.setText(BaseMessages.getString(PKG, "JobExportRepository.Tab.Advanced.Label"));
FormLayout contentLayout = new FormLayout();
contentLayout.marginWidth = 3;
contentLayout.marginHeight = 3;
wAdvancedComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wAdvancedComp);
wAdvancedComp.setLayout(contentLayout);
// SuccessOngrouping?
// ////////////////////////
// START OF SUCCESS ON GROUP///
// /
wSuccessOn = new Group(wAdvancedComp, SWT.SHADOW_NONE);
props.setLook(wSuccessOn);
wSuccessOn.setText(BaseMessages.getString(PKG, "JobExportRepository.SuccessOn.Group.Label"));
FormLayout successongroupLayout = new FormLayout();
successongroupLayout.marginWidth = 10;
successongroupLayout.marginHeight = 10;
wSuccessOn.setLayout(successongroupLayout);
// Success Condition
wlSuccessCondition = new Label(wSuccessOn, SWT.RIGHT);
wlSuccessCondition.setText(BaseMessages.getString(PKG, "JobExportRepository.SuccessCondition.Label"));
props.setLook(wlSuccessCondition);
fdlSuccessCondition = new FormData();
fdlSuccessCondition.left = new FormAttachment(0, 0);
fdlSuccessCondition.right = new FormAttachment(middle, 0);
fdlSuccessCondition.top = new FormAttachment(0, margin);
wlSuccessCondition.setLayoutData(fdlSuccessCondition);
wSuccessCondition = new CCombo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wSuccessCondition.add(BaseMessages.getString(PKG, "JobExportRepository.SuccessWhenAllWorksFine.Label"));
wSuccessCondition.add(BaseMessages.getString(PKG, "JobExportRepository.SuccessWhenErrorsLessThan.Label"));
// +1: starts at -1
wSuccessCondition.select(0);
props.setLook(wSuccessCondition);
fdSuccessCondition = new FormData();
fdSuccessCondition.left = new FormAttachment(middle, 0);
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
wlLimit = new Label(wSuccessOn, SWT.RIGHT);
wlLimit.setText(BaseMessages.getString(PKG, "JobExportRepository.Limit.Label"));
props.setLook(wlLimit);
fdlLimit = new FormData();
fdlLimit.left = new FormAttachment(0, 0);
fdlLimit.top = new FormAttachment(wSuccessCondition, margin);
fdlLimit.right = new FormAttachment(middle, -margin);
wlLimit.setLayoutData(fdlLimit);
wLimit = new TextVar(jobMeta, wSuccessOn, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "JobExportRepository.NrLimit.Tooltip"));
props.setLook(wLimit);
wLimit.addModifyListener(lsMod);
fdLimit = new FormData();
fdLimit.left = new FormAttachment(middle, 0);
fdLimit.top = new FormAttachment(wSuccessCondition, margin);
fdLimit.right = new FormAttachment(100, -margin);
wLimit.setLayoutData(fdLimit);
fdSuccessOn = new FormData();
fdSuccessOn.left = new FormAttachment(0, margin);
fdSuccessOn.top = new FormAttachment(0, margin);
fdSuccessOn.right = new FormAttachment(100, -margin);
wSuccessOn.setLayoutData(fdSuccessOn);
// ///////////////////////////////////////////////////////////
// / END OF Success ON GROUP
// ///////////////////////////////////////////////////////////
fdAdvancedComp = new FormData();
fdAdvancedComp.left = new FormAttachment(0, 0);
fdAdvancedComp.top = new FormAttachment(0, 0);
fdAdvancedComp.right = new FormAttachment(100, 0);
fdAdvancedComp.bottom = new FormAttachment(100, 0);
wAdvancedComp.setLayoutData(wAdvancedComp);
wAdvancedComp.layout();
wAdvancedTab.setControl(wAdvancedComp);
// ///////////////////////////////////////////////////////////
// / END OF ADVANCED TAB
// ///////////////////////////////////////////////////////////
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(wName, margin);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
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"));
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wTabFolder);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsTest = new Listener() {
public void handleEvent(Event e) {
repConnect(true);
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
wTest.addListener(SWT.Selection, lsTest);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wName.addSelectionListener(lsDef);
wRepositoryname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
getData();
activeOneFolder();
setDateTimeFormat();
activeSuccessCondition();
wTabFolder.setSelection(0);
BaseStepDialog.setSize(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobEntry;
}
use of org.pentaho.di.ui.core.widget.LabelTextVar in project pentaho-kettle by pentaho.
the class JobEntryDelayDialog 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, "JobEntryDelay.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Name line
wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "JobEntryDelay.Name.Label"));
props.setLook(wlName);
fdlName = new FormData();
fdlName.left = new FormAttachment(0, -margin);
fdlName.right = new FormAttachment(middle, 0);
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, margin);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
// MaximumTimeout line
wMaximumTimeout = new LabelTextVar(jobMeta, shell, BaseMessages.getString(PKG, "JobEntryDelay.MaximumTimeout.Label"), BaseMessages.getString(PKG, "JobEntryDelay.MaximumTimeout.Tooltip"));
props.setLook(wMaximumTimeout);
wMaximumTimeout.addModifyListener(lsMod);
fdMaximumTimeout = new FormData();
fdMaximumTimeout.left = new FormAttachment(0, -margin);
fdMaximumTimeout.top = new FormAttachment(wName, margin);
fdMaximumTimeout.right = new FormAttachment(100, 0);
wMaximumTimeout.setLayoutData(fdMaximumTimeout);
// Whenever something changes, set the tooltip to the expanded version:
wMaximumTimeout.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
wMaximumTimeout.setToolTipText(jobMeta.environmentSubstitute(wMaximumTimeout.getText()));
}
});
// Scale time
wScaleTime = new CCombo(shell, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wScaleTime.add(BaseMessages.getString(PKG, "JobEntryDelay.SScaleTime.Label"));
wScaleTime.add(BaseMessages.getString(PKG, "JobEntryDelay.MnScaleTime.Label"));
wScaleTime.add(BaseMessages.getString(PKG, "JobEntryDelay.HrScaleTime.Label"));
// +1: starts at -1
wScaleTime.select(0);
props.setLook(wScaleTime);
fdScaleTime = new FormData();
fdScaleTime.left = new FormAttachment(middle, 0);
fdScaleTime.top = new FormAttachment(wMaximumTimeout, margin);
fdScaleTime.right = new FormAttachment(100, 0);
wScaleTime.setLayoutData(fdScaleTime);
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"));
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wCancel }, margin, wScaleTime);
// 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();
}
};
wName.addSelectionListener(lsDef);
wMaximumTimeout.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
getData();
BaseStepDialog.setSize(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobEntry;
}
use of org.pentaho.di.ui.core.widget.LabelTextVar in project pentaho-kettle by pentaho.
the class ExecProcessDialog method open.
@Override
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() {
@Override
public void modifyText(ModifyEvent 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, "ExecProcessDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "ExecProcessDialog.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);
// The Tab Folders
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ///////////////////////
// START OF GENERAL TAB //
// ///////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "ExecProcessDialog.GeneralTab.TabItem"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = margin;
generalLayout.marginHeight = margin;
wGeneralComp.setLayout(generalLayout);
// filename field
wlProcess = new Label(wGeneralComp, SWT.RIGHT);
wlProcess.setText(BaseMessages.getString(PKG, "ExecProcessDialog.Process.Label"));
props.setLook(wlProcess);
fdlProcess = new FormData();
fdlProcess.left = new FormAttachment(0, 0);
fdlProcess.right = new FormAttachment(middle, -margin);
fdlProcess.top = new FormAttachment(wStepname, margin);
wlProcess.setLayoutData(fdlProcess);
wProcess = new CCombo(wGeneralComp, SWT.BORDER | SWT.READ_ONLY);
wProcess.setEditable(true);
props.setLook(wProcess);
wProcess.addModifyListener(lsMod);
fdProcess = new FormData();
fdProcess.left = new FormAttachment(middle, 0);
fdProcess.top = new FormAttachment(wStepname, margin);
fdProcess.right = new FormAttachment(100, -margin);
wProcess.setLayoutData(fdProcess);
wProcess.addFocusListener(new FocusListener() {
@Override
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
@Override
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
Cursor busy = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
shell.setCursor(busy);
get();
shell.setCursor(null);
busy.dispose();
}
});
// Command Arguments are in separate fields
wlArgumentsInFields = new Label(wGeneralComp, SWT.RIGHT);
wlArgumentsInFields.setText(BaseMessages.getString(PKG, "ExecProcessDialog.ArgumentInFields.Label"));
props.setLook(wlArgumentsInFields);
fdlArgumentsInFields = new FormData();
fdlArgumentsInFields.left = new FormAttachment(0, 0);
fdlArgumentsInFields.top = new FormAttachment(wProcess, margin);
fdlArgumentsInFields.right = new FormAttachment(middle, -margin);
wlArgumentsInFields.setLayoutData(fdlArgumentsInFields);
wArgumentsInFields = new Button(wGeneralComp, SWT.CHECK);
wArgumentsInFields.setToolTipText(BaseMessages.getString(PKG, "ExecProcessDialog.ArgumentInFields.Tooltip"));
props.setLook(wArgumentsInFields);
fdArgumentsInFields = new FormData();
fdArgumentsInFields.left = new FormAttachment(middle, 0);
fdArgumentsInFields.top = new FormAttachment(wProcess, margin);
fdArgumentsInFields.right = new FormAttachment(100, 0);
wArgumentsInFields.setLayoutData(fdArgumentsInFields);
wArgumentsInFields.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
enableFields();
input.setChanged();
}
});
// Fail when status is different than 0
wlFailWhenNotSuccess = new Label(wGeneralComp, SWT.RIGHT);
wlFailWhenNotSuccess.setText(BaseMessages.getString(PKG, "ExecProcessDialog.FailWhenNotSuccess.Label"));
props.setLook(wlFailWhenNotSuccess);
fdlFailWhenNotSuccess = new FormData();
fdlFailWhenNotSuccess.left = new FormAttachment(0, 0);
fdlFailWhenNotSuccess.top = new FormAttachment(wArgumentsInFields, margin);
fdlFailWhenNotSuccess.right = new FormAttachment(middle, -margin);
wlFailWhenNotSuccess.setLayoutData(fdlFailWhenNotSuccess);
wFailWhenNotSuccess = new Button(wGeneralComp, SWT.CHECK);
wFailWhenNotSuccess.setToolTipText(BaseMessages.getString(PKG, "ExecProcessDialog.FailWhenNotSuccess.Tooltip"));
props.setLook(wFailWhenNotSuccess);
fdFailWhenNotSuccess = new FormData();
fdFailWhenNotSuccess.left = new FormAttachment(middle, 0);
fdFailWhenNotSuccess.top = new FormAttachment(wArgumentsInFields, margin);
fdFailWhenNotSuccess.right = new FormAttachment(100, 0);
wFailWhenNotSuccess.setLayoutData(fdFailWhenNotSuccess);
wFailWhenNotSuccess.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// List of Argument Fields when ArgumentsInFields is enabled
wlArgumentFields = new Label(wGeneralComp, SWT.LEFT);
wlArgumentFields.setText(BaseMessages.getString(PKG, "ExecProcessDialog.ArgumentFields.Label"));
props.setLook(wlArgumentFields);
fdlArgumentFields = new FormData();
fdlArgumentFields.left = new FormAttachment(0, 0);
fdlArgumentFields.top = new FormAttachment(wFailWhenNotSuccess, margin);
fdlArgumentFields.right = new FormAttachment(middle, -margin);
wlArgumentFields.setLayoutData(fdlArgumentFields);
ColumnInfo[] colinf = new ColumnInfo[1];
colinf[0] = new ColumnInfo(BaseMessages.getString(PKG, "ExecProcessDialog.ArgumentField.Label"), ColumnInfo.COLUMN_TYPE_CCOMBO, new String[] { "" }, false);
colinf[0].setToolTip(BaseMessages.getString(PKG, "ExecProcessDialog.ArgumentField.Tooltip"));
wArgumentFields = new TableView(null, wGeneralComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI, colinf, 1, lsMod, props);
fdArgumentFields = new FormData();
fdArgumentFields.left = new FormAttachment(0, 0);
fdArgumentFields.top = new FormAttachment(wlArgumentFields, margin);
fdArgumentFields.right = new FormAttachment(100, 0);
fdArgumentFields.bottom = new FormAttachment(100, -margin);
wArgumentFields.setLayoutData(fdArgumentFields);
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);
// /////////////////////
// END OF GENERAL TAB //
// /////////////////////
// //////////////////////
// START OF OUTPUT TAB //
// //////////////////////
wOutputTab = new CTabItem(wTabFolder, SWT.NONE);
wOutputTab.setText(BaseMessages.getString(PKG, "ExecProcessDialog.Output.TabItem"));
wOutputComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wOutputComp);
FormLayout fdOutputCompLayout = new FormLayout();
fdOutputCompLayout.marginWidth = margin;
fdOutputCompLayout.marginHeight = margin;
wOutputComp.setLayout(fdOutputCompLayout);
// Output Line Delimiter
wOutputDelim = new LabelTextVar(transMeta, wOutputComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "ExecProcessDialog.OutputDelimiterField.Label"), BaseMessages.getString(PKG, "ExecProcessDialog.OutputDelimiterField.Tooltip"));
wOutputDelim.addModifyListener(lsMod);
fdOutputDelim = new FormData();
fdOutputDelim.left = new FormAttachment(0, 0);
fdOutputDelim.top = new FormAttachment(0, margin);
fdOutputDelim.right = new FormAttachment(100, 0);
wOutputDelim.setLayoutData(fdOutputDelim);
// Result fieldname ...
wResult = new LabelTextVar(transMeta, wOutputComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "ExecProcessDialog.ResultField.Label"), BaseMessages.getString(PKG, "ExecProcessDialog.ResultField.Tooltip"));
wResult.addModifyListener(lsMod);
fdResult = new FormData();
fdResult.left = new FormAttachment(0, 0);
fdResult.top = new FormAttachment(wOutputDelim, margin);
fdResult.right = new FormAttachment(100, 0);
wResult.setLayoutData(fdResult);
// Error fieldname ...
wError = new LabelTextVar(transMeta, wOutputComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "ExecProcessDialog.ErrorField.Label"), BaseMessages.getString(PKG, "ExecProcessDialog.ErrorField.Tooltip"));
wError.addModifyListener(lsMod);
fdError = new FormData();
fdError.left = new FormAttachment(0, 0);
fdError.top = new FormAttachment(wResult, margin);
fdError.right = new FormAttachment(100, 0);
wError.setLayoutData(fdError);
// ExitValue fieldname ...
wExitValue = new LabelTextVar(transMeta, wOutputComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER, BaseMessages.getString(PKG, "ExecProcessDialog.ExitValueField.Label"), BaseMessages.getString(PKG, "ExecProcessDialog.ExitValueField.Tooltip"));
wExitValue.addModifyListener(lsMod);
fdExitValue = new FormData();
fdExitValue.left = new FormAttachment(0, 0);
fdExitValue.top = new FormAttachment(wError, margin);
fdExitValue.right = new FormAttachment(100, 0);
wExitValue.setLayoutData(fdExitValue);
FormData fdOutputComp = new FormData();
fdOutputComp.left = new FormAttachment(0, 0);
fdOutputComp.top = new FormAttachment(0, 0);
fdOutputComp.right = new FormAttachment(100, 0);
fdOutputComp.bottom = new FormAttachment(100, 0);
wOutputComp.setLayoutData(fdOutputComp);
wOutputComp.layout();
wOutputTab.setControl(wOutputComp);
// ////////////////////
// END OF OUTPUT TAB //
// ////////////////////
FormData 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);
wTabFolder.setSelection(0);
// ////////////////////
// END OF TAB FOLDER //
// ////////////////////
// THE BUTTONS
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, wTabFolder);
// Add listeners
lsOK = new Listener() {
@Override
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
@Override
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
RowMetaInterface r = null;
try {
r = transMeta.getPrevStepFields(stepname);
if (r != null) {
wArgumentFields.getColumns()[0].setComboValues(r.getFieldNames());
}
} catch (KettleStepException ignore) {
// Do nothing
}
getData();
enableFields();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.LabelTextVar in project pentaho-kettle by pentaho.
the class XsdValidatorDialog 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();
}
};
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, "XsdValidatorDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Filename line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.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);
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
// ////////////////////////
// START OF GENERAL TAB ///
// ////////////////////////
wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.GeneralTab.TabTitle"));
wGeneralComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wGeneralComp);
FormLayout generalLayout = new FormLayout();
generalLayout.marginWidth = 3;
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
// ////////////////////////
// START OF XML GROUP
//
wXML = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wXML);
wXML.setText("XML source");
FormLayout groupXML = new FormLayout();
groupXML.marginWidth = 10;
groupXML.marginHeight = 10;
wXML.setLayout(groupXML);
// XML Source = file ?
wlXMLSourceFile = new Label(wXML, SWT.RIGHT);
wlXMLSourceFile.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.XMLSourceFile.Label"));
props.setLook(wlXMLSourceFile);
fdlXMLSourceFile = new FormData();
fdlXMLSourceFile.left = new FormAttachment(0, 0);
fdlXMLSourceFile.top = new FormAttachment(wStepname, 2 * margin);
fdlXMLSourceFile.right = new FormAttachment(middle, -margin);
wlXMLSourceFile.setLayoutData(fdlXMLSourceFile);
wXMLSourceFile = new Button(wXML, SWT.CHECK);
props.setLook(wXMLSourceFile);
wXMLSourceFile.setToolTipText(BaseMessages.getString(PKG, "XsdValidatorDialog.XMLSourceFile.Tooltip"));
fdXMLSourceFile = new FormData();
fdXMLSourceFile.left = new FormAttachment(middle, margin);
fdXMLSourceFile.top = new FormAttachment(wStepname, 2 * margin);
wXMLSourceFile.setLayoutData(fdXMLSourceFile);
wXMLSourceFile.addSelectionListener(new ComponentSelectionListener(input));
// XML Stream Field
wlXMLStream = new Label(wXML, SWT.RIGHT);
wlXMLStream.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.XMLStream.Label"));
props.setLook(wlXMLStream);
fdlXMLStream = new FormData();
fdlXMLStream.left = new FormAttachment(0, 0);
fdlXMLStream.top = new FormAttachment(wXMLSourceFile, margin);
fdlXMLStream.right = new FormAttachment(middle, -margin);
wlXMLStream.setLayoutData(fdlXMLStream);
wXMLStream = new CCombo(wXML, SWT.BORDER | SWT.READ_ONLY);
wXMLStream.setEditable(true);
props.setLook(wXMLStream);
wXMLStream.addModifyListener(lsMod);
fdXMLStream = new FormData();
fdXMLStream.left = new FormAttachment(middle, margin);
fdXMLStream.top = new FormAttachment(wXMLSourceFile, margin);
fdXMLStream.right = new FormAttachment(100, -margin);
wXMLStream.setLayoutData(fdXMLStream);
wXMLStream.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);
PopulateFields();
shell.setCursor(null);
busy.dispose();
}
});
fdXML = new FormData();
fdXML.left = new FormAttachment(0, margin);
fdXML.top = new FormAttachment(wStepname, margin);
fdXML.right = new FormAttachment(100, -margin);
wXML.setLayoutData(fdXML);
// ///////////////////////////////////////////////////////////
// / END OF XML GROUP
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF OutputFields GROUP
//
wOutputFields = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wOutputFields);
wOutputFields.setText("Output Fields");
FormLayout groupLayout = new FormLayout();
groupLayout.marginWidth = 10;
groupLayout.marginHeight = 10;
wOutputFields.setLayout(groupLayout);
// Output Fieldame
wResultField = new LabelTextVar(transMeta, wOutputFields, BaseMessages.getString(PKG, "XsdValidatorDialog.ResultField.Label"), BaseMessages.getString(PKG, "XsdValidatorDialog.ResultField.Tooltip"));
props.setLook(wResultField);
wResultField.addModifyListener(lsMod);
fdResultField = new FormData();
fdResultField.left = new FormAttachment(0, 0);
fdResultField.top = new FormAttachment(wXML, margin);
fdResultField.right = new FormAttachment(100, 0);
wResultField.setLayoutData(fdResultField);
// Output String Field ?
wlOutputStringField = new Label(wOutputFields, SWT.RIGHT);
wlOutputStringField.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.OutputStringField.Label"));
props.setLook(wlOutputStringField);
fdlOutputStringField = new FormData();
fdlOutputStringField.left = new FormAttachment(0, 0);
fdlOutputStringField.top = new FormAttachment(wResultField, 2 * margin);
fdlOutputStringField.right = new FormAttachment(middle, -margin);
wlOutputStringField.setLayoutData(fdlOutputStringField);
wOutputStringField = new Button(wOutputFields, SWT.CHECK);
props.setLook(wOutputStringField);
wOutputStringField.setToolTipText(BaseMessages.getString(PKG, "XsdValidatorDialog.OutputStringField.Tooltip"));
fdOutputStringField = new FormData();
fdOutputStringField.left = new FormAttachment(middle, margin);
fdOutputStringField.top = new FormAttachment(wResultField, 2 * margin);
wOutputStringField.setLayoutData(fdOutputStringField);
wOutputStringField.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
activeOutputStringField();
input.setChanged();
}
});
// Output if XML is valid field
wIfXMLValid = new LabelTextVar(transMeta, wOutputFields, BaseMessages.getString(PKG, "XsdValidatorDialog.IfXMLValid.Label"), BaseMessages.getString(PKG, "XsdValidatorDialog.IfXMLValid.Tooltip"));
props.setLook(wIfXMLValid);
wIfXMLValid.addModifyListener(lsMod);
fdIfXMLValid = new FormData();
fdIfXMLValid.left = new FormAttachment(0, 0);
fdIfXMLValid.top = new FormAttachment(wOutputStringField, margin);
fdIfXMLValid.right = new FormAttachment(100, 0);
wIfXMLValid.setLayoutData(fdIfXMLValid);
// Output if XML is not valid field
wIfXMLUnValid = new LabelTextVar(transMeta, wOutputFields, BaseMessages.getString(PKG, "XsdValidatorDialog.IfXMLUnValid.Label"), BaseMessages.getString(PKG, "XsdValidatorDialog.IfXMLUnValid.Tooltip"));
props.setLook(wIfXMLUnValid);
wIfXMLUnValid.addModifyListener(lsMod);
fdIfXMLUnValid = new FormData();
fdIfXMLUnValid.left = new FormAttachment(0, 0);
fdIfXMLUnValid.top = new FormAttachment(wIfXMLValid, margin);
fdIfXMLUnValid.right = new FormAttachment(100, 0);
wIfXMLUnValid.setLayoutData(fdIfXMLUnValid);
// Add validation message ?
wlAddValidationMsg = new Label(wOutputFields, SWT.RIGHT);
wlAddValidationMsg.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.AddValidationMsg.Label"));
props.setLook(wlAddValidationMsg);
fdlAddValidationMsg = new FormData();
fdlAddValidationMsg.left = new FormAttachment(0, 0);
fdlAddValidationMsg.top = new FormAttachment(wIfXMLUnValid, 2 * margin);
fdlAddValidationMsg.right = new FormAttachment(middle, -margin);
wlAddValidationMsg.setLayoutData(fdlAddValidationMsg);
wAddValidationMsg = new Button(wOutputFields, SWT.CHECK);
props.setLook(wAddValidationMsg);
wAddValidationMsg.setToolTipText(BaseMessages.getString(PKG, "XsdValidatorDialog.AddValidationMsg.Tooltip"));
fdAddValidationMsg = new FormData();
fdAddValidationMsg.left = new FormAttachment(middle, margin);
fdAddValidationMsg.top = new FormAttachment(wIfXMLUnValid, 2 * margin);
wAddValidationMsg.setLayoutData(fdAddValidationMsg);
wAddValidationMsg.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
activeValidationMsg();
input.setChanged();
}
});
// Validation Msg Fieldame
wValidationMsg = new LabelTextVar(transMeta, wOutputFields, BaseMessages.getString(PKG, "XsdValidatorDialog.ValidationMsg.Label"), BaseMessages.getString(PKG, "XsdValidatorDialog.ValidationMsg.Tooltip"));
props.setLook(wValidationMsg);
wValidationMsg.addModifyListener(lsMod);
fdValidationMsg = new FormData();
fdValidationMsg.left = new FormAttachment(0, 0);
fdValidationMsg.top = new FormAttachment(wAddValidationMsg, margin);
fdValidationMsg.right = new FormAttachment(100, 0);
wValidationMsg.setLayoutData(fdValidationMsg);
fdOutputFields = new FormData();
fdOutputFields.left = new FormAttachment(0, margin);
fdOutputFields.top = new FormAttachment(wXML, margin);
fdOutputFields.right = new FormAttachment(100, -margin);
wOutputFields.setLayoutData(fdOutputFields);
// ///////////////////////////////////////////////////////////
// / END OF OUTPUT FIELDS GROUP
// ///////////////////////////////////////////////////////////
// ////////////////////////
// START OF XSD GROUP
//
wXSD = new Group(wGeneralComp, SWT.SHADOW_NONE);
props.setLook(wXSD);
wXSD.setText("XML Schema Definition");
FormLayout groupXSD = new FormLayout();
groupXSD.marginWidth = 10;
groupXSD.marginHeight = 10;
wXSD.setLayout(groupLayout);
// Enable/Disable external entity for XSD validation.
wlAllowExternalEntities = new Label(wXSD, SWT.RIGHT);
wlAllowExternalEntities.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.AllowExternalEntities.Label"));
props.setLook(wlAllowExternalEntities);
fdlAllowExternalEntities = new FormData();
fdlAllowExternalEntities.left = new FormAttachment(0, 0);
fdlAllowExternalEntities.right = new FormAttachment(middle, -margin);
fdlAllowExternalEntities.top = new FormAttachment(wStepname, margin);
wlAllowExternalEntities.setLayoutData(fdlAllowExternalEntities);
wAllowExternalEntities = new Button(wXSD, SWT.CHECK);
props.setLook(wAllowExternalEntities);
fdAllowExternalEntities = new FormData();
fdAllowExternalEntities.left = new FormAttachment(middle, margin);
fdAllowExternalEntities.top = new FormAttachment(wStepname, margin);
fdAllowExternalEntities.right = new FormAttachment(100, -margin);
wAllowExternalEntities.setLayoutData(fdAllowExternalEntities);
wAllowExternalEntities.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// XSD Source?
wlXSDSource = new Label(wXSD, SWT.RIGHT);
wlXSDSource.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.XSDSource.Label"));
props.setLook(wlXSDSource);
fdlXSDSource = new FormData();
fdlXSDSource.left = new FormAttachment(0, 0);
fdlXSDSource.top = new FormAttachment(wAllowExternalEntities, margin);
fdlXSDSource.right = new FormAttachment(middle, -margin);
wlXSDSource.setLayoutData(fdlXSDSource);
wXSDSource = new CCombo(wXSD, SWT.BORDER | SWT.READ_ONLY);
wXSDSource.setEditable(true);
props.setLook(wXSDSource);
wXSDSource.addModifyListener(lsMod);
fdXSDSource = new FormData();
fdXSDSource.left = new FormAttachment(middle, margin);
fdXSDSource.top = new FormAttachment(wAllowExternalEntities, margin);
fdXSDSource.right = new FormAttachment(100, -margin);
wXSDSource.setLayoutData(fdXSDSource);
wXSDSource.add(BaseMessages.getString(PKG, "XsdValidatorDialog.XSDSource.IS_A_FILE"));
wXSDSource.add(BaseMessages.getString(PKG, "XsdValidatorDialog.XSDSource.IS_A_FIELD"));
wXSDSource.add(BaseMessages.getString(PKG, "XsdValidatorDialog.XSDSource.NO_NEED"));
wXSDSource.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
setXSDSource();
}
});
// XSD Filename
wlFilename = new Label(wXSD, SWT.RIGHT);
wlFilename.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.XSDFilename.Label"));
props.setLook(wlFilename);
fdlFilename = new FormData();
fdlFilename.left = new FormAttachment(0, 0);
fdlFilename.top = new FormAttachment(wXSDSource, margin);
fdlFilename.right = new FormAttachment(middle, -margin);
wlFilename.setLayoutData(fdlFilename);
wbbFilename = new Button(wXSD, SWT.PUSH | SWT.CENTER);
props.setLook(wbbFilename);
wbbFilename.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.FilenameBrowse.Button"));
wbbFilename.setToolTipText(BaseMessages.getString(PKG, "System.Tooltip.BrowseForFileOrDirAndAdd"));
fdbFilename = new FormData();
fdbFilename.right = new FormAttachment(100, 0);
fdbFilename.top = new FormAttachment(wXSDSource, margin);
wbbFilename.setLayoutData(fdbFilename);
wFilename = new TextVar(transMeta, wXSD, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wFilename);
wFilename.addModifyListener(lsMod);
fdFilename = new FormData();
fdFilename.left = new FormAttachment(middle, margin);
fdFilename.right = new FormAttachment(wbbFilename, -margin);
fdFilename.top = new FormAttachment(wXSDSource, margin);
wFilename.setLayoutData(fdFilename);
// XSD file defined in a column
wlXSDDefinedColumn = new Label(wXSD, SWT.RIGHT);
wlXSDDefinedColumn.setText(BaseMessages.getString(PKG, "XsdValidatorDialog.XSDDefinedColumn.Label"));
props.setLook(wlXSDDefinedColumn);
fdlXSDDefinedColumn = new FormData();
fdlXSDDefinedColumn.left = new FormAttachment(0, 0);
fdlXSDDefinedColumn.top = new FormAttachment(wFilename, 2 * margin);
fdlXSDDefinedColumn.right = new FormAttachment(middle, -margin);
wlXSDDefinedColumn.setLayoutData(fdlXSDDefinedColumn);
wXSDDefinedColumn = new CCombo(wXSD, SWT.BORDER | SWT.READ_ONLY);
wXSDDefinedColumn.setEditable(true);
props.setLook(wXSDDefinedColumn);
wXSDDefinedColumn.addModifyListener(lsMod);
fdXSDDefinedColumn = new FormData();
fdXSDDefinedColumn.left = new FormAttachment(middle, margin);
fdXSDDefinedColumn.top = new FormAttachment(wFilename, 2 * margin);
fdXSDDefinedColumn.right = new FormAttachment(100, -margin);
wXSDDefinedColumn.setLayoutData(fdXSDDefinedColumn);
wXSDDefinedColumn.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);
PopulateFields();
shell.setCursor(null);
busy.dispose();
}
});
fdXSD = new FormData();
fdXSD.left = new FormAttachment(0, margin);
fdXSD.top = new FormAttachment(wOutputFields, margin);
fdXSD.right = new FormAttachment(100, -margin);
wXSD.setLayoutData(fdXSD);
// ///////////////////////////////////////////////////////////
// / END OF XSD GROUP
// ///////////////////////////////////////////////////////////
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
// ///////////////////////////////////////////////////////////
// ///////////////////////////////////////////////////////////
// / END OF GENERAL 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);
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, wTabFolder);
// 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);
// Whenever something changes, set the tooltip to the expanded version
// of the filename:
wFilename.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
wFilename.setToolTipText(transMeta.environmentSubstitute(wFilename.getText()));
}
});
// Listen to the Browse... button
wbbFilename.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*xsd;*.XSD", "*" });
if (wFilename.getText() != null) {
String fname = transMeta.environmentSubstitute(wFilename.getText());
dialog.setFileName(fname);
}
dialog.setFilterNames(new String[] { BaseMessages.getString(PKG, "XsdValidatorDialog.FileType"), BaseMessages.getString(PKG, "System.FileType.AllFiles") });
if (dialog.open() != null) {
String str = dialog.getFilterPath() + System.getProperty("file.separator") + dialog.getFileName();
wFilename.setText(str);
}
}
});
wTabFolder.setSelection(0);
// Set the shell size, based upon previous time...
setSize();
getData();
activeValidationMsg();
activeOutputStringField();
setXSDSource();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.ui.core.widget.LabelTextVar in project pentaho-kettle by pentaho.
the class SyslogMessageDialog 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();
}
};
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, "SyslogMessageDialog.Shell.Title"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Stepname line
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.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);
// ///////////////////////////////
// START OF Settings GROUP //
// ///////////////////////////////
wSettingsGroup = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wSettingsGroup);
wSettingsGroup.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.wSettingsGroup.Label"));
FormLayout settingGroupLayout = new FormLayout();
settingGroupLayout.marginWidth = 10;
settingGroupLayout.marginHeight = 10;
wSettingsGroup.setLayout(settingGroupLayout);
// Server port line
wServerName = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SyslogMessageDialog.Server.Label"), BaseMessages.getString(PKG, "SyslogMessageDialog.Server.Tooltip"));
props.setLook(wServerName);
wServerName.addModifyListener(lsMod);
fdServerName = new FormData();
fdServerName.left = new FormAttachment(0, 0);
fdServerName.top = new FormAttachment(wStepname, margin);
fdServerName.right = new FormAttachment(100, 0);
wServerName.setLayoutData(fdServerName);
// Server port line
wPort = new LabelTextVar(transMeta, wSettingsGroup, BaseMessages.getString(PKG, "SyslogMessageDialog.Port.Label"), BaseMessages.getString(PKG, "SyslogMessageDialog.Port.Tooltip"));
props.setLook(wPort);
wPort.addModifyListener(lsMod);
fdPort = new FormData();
fdPort.left = new FormAttachment(0, 0);
fdPort.top = new FormAttachment(wServerName, margin);
fdPort.right = new FormAttachment(100, 0);
wPort.setLayoutData(fdPort);
// Test connection button
wTest = new Button(wSettingsGroup, SWT.PUSH);
wTest.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.TestConnection.Label"));
props.setLook(wTest);
fdTest = new FormData();
wTest.setToolTipText(BaseMessages.getString(PKG, "SyslogMessageDialog.TestConnection.Tooltip"));
fdTest.top = new FormAttachment(wPort, 2 * margin);
fdTest.right = new FormAttachment(100, 0);
wTest.setLayoutData(fdTest);
fdSettingsGroup = new FormData();
fdSettingsGroup.left = new FormAttachment(0, margin);
fdSettingsGroup.top = new FormAttachment(wStepname, margin);
fdSettingsGroup.right = new FormAttachment(100, -margin);
wSettingsGroup.setLayoutData(fdSettingsGroup);
// ///////////////////////////////
// END OF Settings Fields GROUP //
// ////////////////////////
// START OF Log SETTINGS GROUP///
// /
wLogSettings = new Group(shell, SWT.SHADOW_NONE);
props.setLook(wLogSettings);
wLogSettings.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.LogSettings.Group.Label"));
FormLayout LogSettingsgroupLayout = new FormLayout();
LogSettingsgroupLayout.marginWidth = 10;
LogSettingsgroupLayout.marginHeight = 10;
wLogSettings.setLayout(LogSettingsgroupLayout);
// Facility type
wlFacility = new Label(wLogSettings, SWT.RIGHT);
wlFacility.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.Facility.Label"));
props.setLook(wlFacility);
fdlFacility = new FormData();
fdlFacility.left = new FormAttachment(0, margin);
fdlFacility.right = new FormAttachment(middle, -margin);
fdlFacility.top = new FormAttachment(wSettingsGroup, margin);
wlFacility.setLayoutData(fdlFacility);
wFacility = new CCombo(wLogSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wFacility.setItems(SyslogDefs.FACILITYS);
props.setLook(wFacility);
fdFacility = new FormData();
fdFacility.left = new FormAttachment(middle, margin);
fdFacility.top = new FormAttachment(wSettingsGroup, margin);
fdFacility.right = new FormAttachment(100, 0);
wFacility.setLayoutData(fdFacility);
wFacility.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
}
});
// Priority type
wlPriority = new Label(wLogSettings, SWT.RIGHT);
wlPriority.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.Priority.Label"));
props.setLook(wlPriority);
fdlPriority = new FormData();
fdlPriority.left = new FormAttachment(0, margin);
fdlPriority.right = new FormAttachment(middle, -margin);
fdlPriority.top = new FormAttachment(wFacility, margin);
wlPriority.setLayoutData(fdlPriority);
wPriority = new CCombo(wLogSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wPriority.setItems(SyslogDefs.PRIORITYS);
props.setLook(wPriority);
fdPriority = new FormData();
fdPriority.left = new FormAttachment(middle, margin);
fdPriority.top = new FormAttachment(wFacility, margin);
fdPriority.right = new FormAttachment(100, 0);
wPriority.setLayoutData(fdPriority);
wPriority.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
}
});
// Add HostName?
wlAddHostName = new Label(wLogSettings, SWT.RIGHT);
wlAddHostName.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.AddHostName.Label"));
props.setLook(wlAddHostName);
fdlAddHostName = new FormData();
fdlAddHostName.left = new FormAttachment(0, 0);
fdlAddHostName.top = new FormAttachment(wPriority, margin);
fdlAddHostName.right = new FormAttachment(middle, -margin);
wlAddHostName.setLayoutData(fdlAddHostName);
wAddHostName = new Button(wLogSettings, SWT.CHECK);
props.setLook(wAddHostName);
wAddHostName.setToolTipText(BaseMessages.getString(PKG, "SyslogMessageDialog.AddHostName.Tooltip"));
fdAddHostName = new FormData();
fdAddHostName.left = new FormAttachment(middle, margin);
fdAddHostName.top = new FormAttachment(wPriority, margin);
fdAddHostName.right = new FormAttachment(100, 0);
wAddHostName.setLayoutData(fdAddHostName);
wAddHostName.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
input.setChanged();
}
});
// Add timestamp?
wlAddTimestamp = new Label(wLogSettings, SWT.RIGHT);
wlAddTimestamp.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.AddTimestamp.Label"));
props.setLook(wlAddTimestamp);
fdlAddTimestamp = new FormData();
fdlAddTimestamp.left = new FormAttachment(0, 0);
fdlAddTimestamp.top = new FormAttachment(wAddHostName, margin);
fdlAddTimestamp.right = new FormAttachment(middle, -margin);
wlAddTimestamp.setLayoutData(fdlAddTimestamp);
wAddTimestamp = new Button(wLogSettings, SWT.CHECK);
props.setLook(wAddTimestamp);
wAddTimestamp.setToolTipText(BaseMessages.getString(PKG, "SyslogMessageDialog.AddTimestamp.Tooltip"));
fdAddTimestamp = new FormData();
fdAddTimestamp.left = new FormAttachment(middle, margin);
fdAddTimestamp.top = new FormAttachment(wAddHostName, margin);
fdAddTimestamp.right = new FormAttachment(100, 0);
wAddTimestamp.setLayoutData(fdAddTimestamp);
wAddTimestamp.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
activeAddTimestamp();
input.setChanged();
}
});
// DatePattern type
wlDatePattern = new Label(wLogSettings, SWT.RIGHT);
wlDatePattern.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.DatePattern.Label"));
props.setLook(wlDatePattern);
fdlDatePattern = new FormData();
fdlDatePattern.left = new FormAttachment(0, margin);
fdlDatePattern.right = new FormAttachment(middle, -margin);
fdlDatePattern.top = new FormAttachment(wAddTimestamp, margin);
wlDatePattern.setLayoutData(fdlDatePattern);
wDatePattern = new ComboVar(transMeta, wLogSettings, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
wDatePattern.setItems(Const.getDateFormats());
props.setLook(wDatePattern);
fdDatePattern = new FormData();
fdDatePattern.left = new FormAttachment(middle, margin);
fdDatePattern.top = new FormAttachment(wAddTimestamp, margin);
fdDatePattern.right = new FormAttachment(100, 0);
wDatePattern.setLayoutData(fdDatePattern);
wDatePattern.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
}
});
// MessageField field
wlMessageField = new Label(wLogSettings, SWT.RIGHT);
wlMessageField.setText(BaseMessages.getString(PKG, "SyslogMessageDialog.MessageNameField.Label"));
props.setLook(wlMessageField);
fdlMessageField = new FormData();
fdlMessageField.left = new FormAttachment(0, margin);
fdlMessageField.right = new FormAttachment(middle, -margin);
fdlMessageField.top = new FormAttachment(wDatePattern, margin);
wlMessageField.setLayoutData(fdlMessageField);
wMessageField = new CCombo(wLogSettings, SWT.BORDER | SWT.READ_ONLY);
props.setLook(wMessageField);
wMessageField.setEditable(true);
wMessageField.addModifyListener(lsMod);
fdMessageField = new FormData();
fdMessageField.left = new FormAttachment(middle, margin);
fdMessageField.top = new FormAttachment(wDatePattern, margin);
fdMessageField.right = new FormAttachment(100, 0);
wMessageField.setLayoutData(fdMessageField);
wMessageField.addFocusListener(new FocusListener() {
public void focusLost(org.eclipse.swt.events.FocusEvent e) {
}
public void focusGained(org.eclipse.swt.events.FocusEvent e) {
get();
}
});
fdLogSettings = new FormData();
fdLogSettings.left = new FormAttachment(0, margin);
fdLogSettings.top = new FormAttachment(wSettingsGroup, margin);
fdLogSettings.right = new FormAttachment(100, -margin);
wLogSettings.setLayoutData(fdLogSettings);
// ///////////////////////////////////////////////////////////
// / END OF Log SETTINGS GROUP
// ///////////////////////////////////////////////////////////
// THE BUTTONS
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, wLogSettings);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsTest = new Listener() {
public void handleEvent(Event e) {
test();
}
};
wOK.addListener(SWT.Selection, lsOK);
wCancel.addListener(SWT.Selection, lsCancel);
wTest.addListener(SWT.Selection, lsTest);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.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();
activeAddTimestamp();
input.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
Aggregations