use of org.eclipse.jface.wizard.Wizard in project pentaho-kettle by pentaho.
the class CreateDatabaseWizard method createAndRunDatabaseWizard.
/**
* Shows a wizard that creates a new database connection...
*
* @param shell
* @param props
* @param databases
* @return DatabaseMeta when finished or null when canceled
*/
public DatabaseMeta createAndRunDatabaseWizard(Shell shell, PropsUI props, List<DatabaseMeta> databases) {
DatabaseMeta newDBInfo = new DatabaseMeta();
final CreateDatabaseWizardPage1 page1 = new CreateDatabaseWizardPage1("1", props, newDBInfo, databases);
final CreateDatabaseWizardPageInformix pageifx = new CreateDatabaseWizardPageInformix("ifx", props, newDBInfo);
final CreateDatabaseWizardPageJDBC pagejdbc = new CreateDatabaseWizardPageJDBC("jdbc", props, newDBInfo);
final CreateDatabaseWizardPageOCI pageoci = new CreateDatabaseWizardPageOCI("oci", props, newDBInfo);
final CreateDatabaseWizardPageODBC pageodbc = new CreateDatabaseWizardPageODBC("odbc", props, newDBInfo);
final CreateDatabaseWizardPageOracle pageoracle = new CreateDatabaseWizardPageOracle("oracle", props, newDBInfo);
final CreateDatabaseWizardPageGeneric pageGeneric = new CreateDatabaseWizardPageGeneric("generic", props, newDBInfo);
final CreateDatabaseWizardPage2 page2 = new CreateDatabaseWizardPage2("2", props, newDBInfo);
for (PluginInterface pluginInterface : PluginRegistry.getInstance().getPlugins(DatabasePluginType.class)) {
try {
Object plugin = PluginRegistry.getInstance().loadClass(pluginInterface);
if (plugin instanceof WizardPageFactory) {
WizardPageFactory factory = (WizardPageFactory) plugin;
additionalPages.add(factory.createWizardPage(props, newDBInfo));
}
} catch (KettlePluginException kpe) {
// Don't do anything
}
}
// set to false for safety only
wizardFinished = false;
Wizard wizard = new Wizard() {
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
wizardFinished = true;
return true;
}
/**
* @see org.eclipse.jface.wizard.Wizard#canFinish()
*/
public boolean canFinish() {
return page2.canFinish();
}
};
wizard.addPage(page1);
wizard.addPage(pageoci);
wizard.addPage(pageodbc);
wizard.addPage(pagejdbc);
wizard.addPage(pageoracle);
wizard.addPage(pageifx);
wizard.addPage(pageGeneric);
for (WizardPage page : additionalPages) {
wizard.addPage(page);
}
wizard.addPage(page2);
WizardDialog wd = new WizardDialog(shell, wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 400);
wd.updateSize();
wd.open();
if (!wizardFinished) {
newDBInfo = null;
}
return newDBInfo;
}
use of org.eclipse.jface.wizard.Wizard in project pentaho-kettle by pentaho.
the class TextFileInputDialog method getFixed.
private void getFixed() {
TextFileInputMeta info = new TextFileInputMeta();
getInfo(info, true);
Shell sh = new Shell(shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
try {
List<String> rows = getFirst(50, false);
fields = getFields(info, rows);
final TextFileImportWizardPage1 page1 = new TextFileImportWizardPage1("1", props, rows, fields);
page1.createControl(sh);
final TextFileImportWizardPage2 page2 = new TextFileImportWizardPage2("2", props, rows, fields);
page2.createControl(sh);
Wizard wizard = new Wizard() {
public boolean performFinish() {
wFields.clearAll(false);
for (TextFileInputFieldInterface field1 : fields) {
BaseFileField field = (BaseFileField) field1;
if (!field.isIgnored() && field.getLength() > 0) {
TableItem item = new TableItem(wFields.table, SWT.NONE);
item.setText(1, field.getName());
item.setText(2, "" + field.getTypeDesc());
item.setText(3, "" + field.getFormat());
item.setText(4, "" + field.getPosition());
item.setText(5, field.getLength() < 0 ? "" : "" + field.getLength());
item.setText(6, field.getPrecision() < 0 ? "" : "" + field.getPrecision());
item.setText(7, "" + field.getCurrencySymbol());
item.setText(8, "" + field.getDecimalSymbol());
item.setText(9, "" + field.getGroupSymbol());
item.setText(10, "" + field.getNullString());
item.setText(11, "" + field.getIfNullValue());
item.setText(12, "" + field.getTrimTypeDesc());
item.setText(13, field.isRepeated() ? BaseMessages.getString(PKG, "System.Combo.Yes") : BaseMessages.getString(PKG, "System.Combo.No"));
}
}
int size = wFields.table.getItemCount();
if (size == 0) {
new TableItem(wFields.table, SWT.NONE);
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
input.setChanged();
return true;
}
};
wizard.addPage(page1);
wizard.addPage(page2);
WizardDialog wd = new WizardDialog(shell, wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 375);
wd.updateSize();
wd.open();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TextFileInputDialog.ErrorShowingFixedWizard.DialogTitle"), BaseMessages.getString(PKG, "TextFileInputDialog.ErrorShowingFixedWizard.DialogMessage"), e);
}
}
use of org.eclipse.jface.wizard.Wizard in project pentaho-kettle by pentaho.
the class FixedInputDialog method getFixed.
private void getFixed() {
final FixedInputMeta info = new FixedInputMeta();
getInfo(info);
Shell sh = new Shell(shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
try {
List<String> rows = getFirst(info, 50);
fields = new ArrayList<FixedFileInputField>();
fields.addAll(Arrays.asList(info.getFieldDefinition()));
if (fields.isEmpty()) {
FixedFileInputField field = new FixedFileInputField();
// TODO: i18n, see also FixedTableDraw class for other references of this String
field.setName("Field" + 1);
// --> getNewFieldname() method
field.setType(ValueMetaInterface.TYPE_STRING);
field.setTrimType(ValueMetaInterface.TRIM_TYPE_NONE);
field.setWidth(Const.toInt(info.getLineWidth(), 80));
field.setLength(-1);
field.setPrecision(-1);
fields.add(field);
} else if (info.hasChanged()) {
// try to reuse the field mappings already set up.
int width = 0;
List<FixedFileInputField> reuse = new ArrayList<FixedFileInputField>();
for (FixedFileInputField field : fields) {
width += field.getWidth();
// does this field fit on the line given the line width?
if (width <= Const.toInt(info.getLineWidth(), width)) {
// yes, reuse it
reuse.add(field);
} else {
// no, remove its width from the total reused width then quit looking for more
width -= field.getWidth();
continue;
}
}
int lineWidth = Const.toInt(info.getLineWidth(), width);
// set the last reused field to take up the rest of the line.
FixedFileInputField lastField = reuse.get(reuse.size() - 1);
// don't let the width be grater than the line width
if (width > lineWidth) {
width = lineWidth;
}
// determine width of last field : lineWidth - (totalWidthOfFieldsReused - lastFieldWidth)
int lastWidth = Const.toInt(info.getLineWidth(), width) - (width - lastField.getWidth());
// make the last field occupy the remaining space
lastField.setWidth(lastWidth);
// reuse the fields...
fields = reuse;
}
final FixedFileImportWizardPage1 page1 = new FixedFileImportWizardPage1("1", props, rows, fields);
page1.createControl(sh);
final FixedFileImportWizardPage2 page2 = new FixedFileImportWizardPage2("2", props, rows, fields);
page2.createControl(sh);
Wizard wizard = new Wizard() {
public boolean performFinish() {
wFields.clearAll(false);
for (int i = 0; i < fields.size(); i++) {
FixedFileInputField field = fields.get(i);
if (field.getWidth() > 0) {
TableItem item = new TableItem(wFields.table, SWT.NONE);
item.setText(1, field.getName());
item.setText(2, "" + ValueMetaFactory.getValueMetaName(field.getType()));
item.setText(3, "" + field.getFormat());
item.setText(4, "" + field.getWidth());
item.setText(5, field.getLength() < 0 ? "" : "" + field.getLength());
item.setText(6, field.getPrecision() < 0 ? "" : "" + field.getPrecision());
item.setText(7, "" + field.getCurrency());
item.setText(8, "" + field.getDecimal());
item.setText(9, "" + field.getGrouping());
}
}
int size = wFields.table.getItemCount();
if (size == 0) {
new TableItem(wFields.table, SWT.NONE);
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
inputMeta.setChanged();
return true;
}
};
wizard.addPage(page1);
wizard.addPage(page2);
WizardDialog wd = new WizardDialog(shell, wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 375);
wd.updateSize();
wd.open();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "FixedInputDialog.ErrorShowingFixedWizard.DialogTitle"), BaseMessages.getString(PKG, "FixedInputDialog.ErrorShowingFixedWizard.DialogMessage"), e);
}
}
use of org.eclipse.jface.wizard.Wizard in project pentaho-kettle by pentaho.
the class TextFileInputDialog method getFixed.
private void getFixed() {
TextFileInputMeta info = new TextFileInputMeta();
getInfo(info);
Shell sh = new Shell(shell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN);
try {
List<String> rows = getFirst(50, false);
fields = getFields(info, rows);
final TextFileImportWizardPage1 page1 = new TextFileImportWizardPage1("1", props, rows, fields);
page1.createControl(sh);
final TextFileImportWizardPage2 page2 = new TextFileImportWizardPage2("2", props, rows, fields);
page2.createControl(sh);
Wizard wizard = new Wizard() {
public boolean performFinish() {
wFields.clearAll(false);
for (TextFileInputFieldInterface field1 : fields) {
TextFileInputField field = (TextFileInputField) field1;
if (!field.isIgnored() && field.getLength() > 0) {
TableItem item = new TableItem(wFields.table, SWT.NONE);
item.setText(1, field.getName());
item.setText(2, "" + field.getTypeDesc());
item.setText(3, "" + field.getFormat());
item.setText(4, "" + field.getPosition());
item.setText(5, field.getLength() < 0 ? "" : "" + field.getLength());
item.setText(6, field.getPrecision() < 0 ? "" : "" + field.getPrecision());
item.setText(7, "" + field.getCurrencySymbol());
item.setText(8, "" + field.getDecimalSymbol());
item.setText(9, "" + field.getGroupSymbol());
item.setText(10, "" + field.getNullString());
item.setText(11, "" + field.getIfNullValue());
item.setText(12, "" + field.getTrimTypeDesc());
item.setText(13, field.isRepeated() ? BaseMessages.getString(PKG, "System.Combo.Yes") : BaseMessages.getString(PKG, "System.Combo.No"));
}
}
int size = wFields.table.getItemCount();
if (size == 0) {
new TableItem(wFields.table, SWT.NONE);
}
wFields.removeEmptyRows();
wFields.setRowNums();
wFields.optWidth(true);
input.setChanged();
return true;
}
};
wizard.addPage(page1);
wizard.addPage(page2);
WizardDialog wd = new WizardDialog(shell, wizard);
WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
wd.setMinimumPageSize(700, 375);
wd.updateSize();
wd.open();
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "TextFileInputDialog.ErrorShowingFixedWizard.DialogTitle"), BaseMessages.getString(PKG, "TextFileInputDialog.ErrorShowingFixedWizard.DialogMessage"), e);
}
}
use of org.eclipse.jface.wizard.Wizard in project erlide_eclipse by erlang.
the class ErlangFileWizard method performFinish.
/**
* This method is called when 'Finish' button is pressed in the wizard. We will create
* an operation and run it using wizard as execution context.
*/
@Override
public boolean performFinish() {
final String containerName = fPage.getContainerName();
final String fileName = fPage.getFileName();
final String skeleton = fPage.getSkeleton();
final IRunnableWithProgress op = monitor -> {
try {
doFinish(containerName, fileName, skeleton, monitor);
} catch (final CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
};
try {
getContainer().run(true, false, op);
} catch (final InterruptedException e) {
return false;
} catch (final InvocationTargetException e) {
final Throwable realException = e.getTargetException();
MessageDialog.openError(getShell(), "Error", realException.getMessage());
return false;
}
return true;
}
Aggregations