Java Code Examples for org.eclipse.jface.wizard.WizardDialog#updateSize()

The following examples show how to use org.eclipse.jface.wizard.WizardDialog#updateSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextFileInputDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
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 );
  }
}
 
Example 2
Source File: TextFileInputDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
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 ( ITextFileInputField 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 );
  }
}
 
Example 3
Source File: TextFileInputDialog.java    From hop with Apache License 2.0 4 votes vote down vote up
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 ( ITextFileInputField 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 );
  }
}
 
Example 4
Source File: TextFileInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
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 );
  }
}
 
Example 5
Source File: TextFileInputDialog.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
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 );
  }
}
 
Example 6
Source File: SpoonJobDelegate.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Create a job that extracts tables & data from a database.
 * <p>
 * <p>
 *
 * 0) Select the database to rip
 * <p>
 * 1) Select the tables in the database to rip
 * <p>
 * 2) Select the database to dump to
 * <p>
 * 3) Select the repository directory in which it will end up
 * <p>
 * 4) Select a name for the new job
 * <p>
 * 5) Create an empty job with the selected name.
 * <p>
 * 6) Create 1 transformation for every selected table
 * <p>
 * 7) add every created transformation to the job & evaluate
 * <p>
 *
 */
public void ripDBWizard() {
  final List<DatabaseMeta> databases = spoon.getActiveDatabases();
  if ( databases.size() == 0 ) {
    return; // Nothing to do here
  }

  final RipDatabaseWizardPage1 page1 = new RipDatabaseWizardPage1( "1", databases );
  final RipDatabaseWizardPage2 page2 = new RipDatabaseWizardPage2( "2" );
  final RipDatabaseWizardPage3 page3 = new RipDatabaseWizardPage3( "3", spoon.getRepository() );

  Wizard wizard = new Wizard() {
    public boolean performFinish() {
      try {
        JobMeta jobMeta =
          ripDB( databases, page3.getJobname(), page3.getRepositoryDirectory(), page3.getDirectory(), page1
            .getSourceDatabase(), page1.getTargetDatabase(), page2.getSelection() );
        if ( jobMeta == null ) {
          return false;
        }

        if ( page3.getRepositoryDirectory() != null ) {
          spoon.saveToRepository( jobMeta, false );
        } else {
          spoon.saveToFile( jobMeta );
        }

        addJobGraph( jobMeta );
        return true;
      } catch ( Exception e ) {
        new ErrorDialog( spoon.getShell(), "Error", "An unexpected error occurred!", e );
        return false;
      }
    }

    /**
     * @see org.eclipse.jface.wizard.Wizard#canFinish()
     */
    public boolean canFinish() {
      return page3.canFinish();
    }
  };

  wizard.addPage( page1 );
  wizard.addPage( page2 );
  wizard.addPage( page3 );

  WizardDialog wd = new WizardDialog( spoon.getShell(), wizard );
  WizardDialog.setDefaultImage( GUIResource.getInstance().getImageWizard() );
  wd.setMinimumPageSize( 700, 400 );
  wd.updateSize();
  wd.open();
}
 
Example 7
Source File: CreateDatabaseWizard.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * 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
    }
  }

  wizardFinished = false; // set to false for safety only

  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;
}