org.pentaho.di.ui.spoon.Spoon Java Examples

The following examples show how to use org.pentaho.di.ui.spoon.Spoon. 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: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
private void deleteDataSet( Spoon spoon, DataSet dataSet, List<DataSetGroup> groups, MetaStoreFactory<DataSet> setFactory, String setName ) throws MetaStoreException {

    MessageBox box = new MessageBox( Spoon.getInstance().getShell(), SWT.YES | SWT.NO );
    box.setText( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDeleteDataSet.Title" ) );
    box.setMessage( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDeleteDataSet.Message", setName ) );
    int answer = box.open();
    if ( ( answer & SWT.YES ) != 0 ) {
      try {
        FactoriesHierarchy hierarchy = getHierarchy();
        hierarchy.getSetFactory().deleteElement( setName );
      } catch ( Exception exception ) {
        new ErrorDialog( Spoon.getInstance().getShell(),
          BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingDataSet.Title" ),
          BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingDataSet.Message", setName ),
          exception );
      }
    }
  }
 
Example #2
Source File: TransLogDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_LOG_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

      ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
      spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
      swtToolBar.layout( true, true );
    } catch ( Throwable t ) {
      log.logError( Const.getStackTracker( t ) );
      new ErrorDialog( transLogComposite.getShell(),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_LOG_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example #3
Source File: ImportRulesDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {

    try {
      XulLoader loader = new KettleXulLoader();
      loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
      ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
      XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TOOLBAR, bundle );
      xulDomContainer.addEventHandler( this );
      toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "import-rules-toolbar" );

      ToolBar swtToolbar = (ToolBar) toolbar.getManagedObject();
      swtToolbar.layout( true, true );
    } catch ( Throwable t ) {
      LogChannel.GENERAL.logError( Const.getStackTracker( t ) );
      new ErrorDialog( shell,
        BaseMessages.getString( PKG, "ImportRulesDialog.Exception.ErrorReadingXULFile.Title" ),
        BaseMessages.getString( PKG, "ImportRulesDialog.Exception.ErrorReadingXULFile.Message", XUL_FILE_TOOLBAR ),
        new Exception( t ) );
    }
  }
 
Example #4
Source File: DefaultRunConfigurationExecutor.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void sendNow( Repository repository, AbstractMeta meta ) {
  try {
    if ( meta instanceof TransMeta ) {
      Spoon.getInstance().getActiveTransGraph().handleTransMetaChanges( (TransMeta) meta );
    } else {
      Spoon.getInstance().getActiveJobGraph().handleJobMetaChanges( (JobMeta) meta );
    }
  } catch ( Exception e ) {
    // Ignore an exception if occurs
  }

  if ( !meta.hasChanged() ) {
    SchedulerRequest.Builder builder = new SchedulerRequest.Builder();
    builder.repository( repository );
    SchedulerRequest schedulerRequest = builder.build();
    schedulerRequest.submit( meta );
  }
}
 
Example #5
Source File: TransHistoryDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void addToolBar() {
  try {
    KettleXulLoader loader = new KettleXulLoader();
    loader.setIconsSize( 16, 16 );
    loader.setSettingsManager( XulSpoonSettingsManager.getInstance() );
    ResourceBundle bundle = new XulSpoonResourceBundle( Spoon.class );
    XulDomContainer xulDomContainer = loader.loadXul( XUL_FILE_TRANS_GRID_TOOLBAR, bundle );
    xulDomContainer.addEventHandler( this );
    toolbar = (XulToolbar) xulDomContainer.getDocumentRoot().getElementById( "nav-toolbar" );

    refreshButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "refresh-history" );
    fetchNextBatchButton =
      (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "fetch-next-batch-history" );
    fetchAllButton = (XulToolbarbutton) xulDomContainer.getDocumentRoot().getElementById( "fetch-all-history" );

    ToolBar swtToolBar = (ToolBar) toolbar.getManagedObject();
    spoon.props.setLook( swtToolBar, Props.WIDGET_STYLE_TOOLBAR );
    swtToolBar.layout( true, true );
  } catch ( Throwable t ) {
    log.logError( Const.getStackTracker( t ) );
    new ErrorDialog( transHistoryComposite.getShell(),
      BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Title" ),
      BaseMessages.getString( PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_TRANS_GRID_TOOLBAR ),
      new Exception( t ) );
  }
}
 
Example #6
Source File: Neo4jPerspective.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 6 votes vote down vote up
private void newConnection( Event event ) {
  try {
    NeoConnection connection = NeoConnectionUtils.newConnection(
      Spoon.getInstance().getShell(),
      getVariableSpace(),
      NeoConnectionUtils.getConnectionFactory( Spoon.getInstance().getMetaStore() )
    );
    if ( connection != null ) {
      updateConnectionsList();
      wConnections.setSelection( new String[] { connection.getName() } );

    }
  } catch ( Exception e ) {
    new ErrorDialog( Spoon.getInstance().getShell(), "Error", "Unable to create connection", e );
  }
}
 
Example #7
Source File: GoogleDriveKettleLifecycleListener.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void onStart( LifeEventHandler handler ) throws LifecycleException {

    if ( new File( GoogleDriveFileObject.resolveCredentialsPath() + "/" + resourceBundle.getString( "client.secrets" ) )
        .exists() ) {
      /*
      * Registers the UI for the VFS Browser
      * */
      final Spoon spoon = Spoon.getInstance();
      spoon.getDisplay().asyncExec( new Runnable() {
        public void run() {
          VfsFileChooserDialog dialog = spoon.getVfsFileChooserDialog( null, null );
          GoogleDriveFileChooserDialog
              hadoopVfsFileChooserDialog =
              new GoogleDriveFileChooserDialog( GoogleDriveFileProvider.SCHEME, GoogleDriveFileProvider.DISPLAY_NAME,
                  dialog, SWT.NONE );
          dialog.addVFSUIPanel( hadoopVfsFileChooserDialog );
        }
      } );
    }
  }
 
Example #8
Source File: SpoonTransformationDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean isDefaultTransformationName( String name ) {
  if ( !name.startsWith( Spoon.STRING_TRANSFORMATION ) ) {
    return false;
  }

  // see if there are only digits behind the transformation...
  // This will detect:
  // "Transformation"
  // "Transformation "
  // "Transformation 1"
  // "Transformation 2"
  // ...
  for ( int i = Spoon.STRING_TRANSFORMATION.length() + 1; i < name.length(); i++ ) {
    if ( !Character.isDigit( name.charAt( i ) ) ) {
      return false;
    }
  }
  return true;
}
 
Example #9
Source File: OsHelper.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public static void customizeWindow() {

    // allow fullscreen mode on 10.7 macs
    // / ignore errors here
    try {

      if ( isMac() ) {
        // remove about from the original info menu, handled by system menu
        Spoon.getInstance().removeMenuItem( "help-about", true );
        // remove the file/quit menu item, handled by system menu
        Spoon.getInstance().removeMenuItem( "file-quit", true );
        // remove the options menu (preferences), handled by system menu
        Spoon.getInstance().removeMenuItem( "edit-options", true );

      }

      // TODO: add fullscreen support
      // if (isMac() && "10.7.3".equals(System.getProperty("os.version"))) {
      // NSWindow nswindow = Spoon.getInstance().getShell().view.window();
      // Spoon.getInstance().getShell().setFullScreen(false);
      // nswindow.setCollectionBehavior(1 << 7);
      // }
    } catch ( Throwable t ) {
      t.printStackTrace();
    }
  }
 
Example #10
Source File: StarModelerPerspective.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void generateDomainJobButton(StarDomain starDomain) {
  final Spoon spoon = Spoon.getInstance();

  List<DatabaseMeta> sharedDatabases = SharedDatabaseUtil.loadSharedDatabases();

  JobGenerator jobGenerator = new JobGenerator(starDomain, spoon.rep, new RepositoryDirectory(), sharedDatabases, defaultLocale);
  try {
    List<TransMeta> transMetas = jobGenerator.generateDimensionTransformations();
    for (TransMeta transMeta : transMetas) {
      spoon.addTransGraph(transMeta);
    }
    SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
  } catch(Exception e) {
    new ErrorDialog(spoon.getShell(),
        BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Title"),
        BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Message"), e);

  }

}
 
Example #11
Source File: Neo4jPerspective.java    From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 6 votes vote down vote up
private void editConnection( Event event ) {
  String[] selection = wConnections.getSelection();
  if ( selection == null || selection.length < 1 ) {
    return;
  }
  String connectionName = selection[ 0 ];

  try {
    NeoConnectionUtils.editConnection(
      Spoon.getInstance().getShell(),
      getVariableSpace(),
      connectionFactory,
      connectionName
    );
    updateConnectionsList();
    wConnections.setSelection( new String[] { connectionName } );
  } catch ( Exception e ) {
    new ErrorDialog( Spoon.getInstance().getShell(), "Error", "Unable to edit connection", e );
  }

}
 
Example #12
Source File: JobEntryBaseDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public void modifyText( ModifyEvent modifyEvent ) {
  ExecutorService executorService = ExecutorUtil.getExecutor();
  final String runConfiguration = jobMeta.environmentSubstitute( wRunConfiguration.getText() );
  executorService.submit( () -> {
    List<Object> items = Arrays.asList( runConfiguration, false );
    try {
      ExtensionPointHandler.callExtensionPoint( Spoon.getInstance().getLog(), KettleExtensionPoint
              .RunConfigurationSelection.id, items );
    } catch ( KettleException ignored ) {
      // Ignore errors
    }
    display.asyncExec( () -> {
      if ( (Boolean) items.get( IS_PENTAHO ) ) {
        wWaitingToFinish.setSelection( false );
        wWaitingToFinish.setEnabled( false );
      } else {
        wWaitingToFinish.setEnabled( true );
      }
    } );
  } );
}
 
Example #13
Source File: TransHistoryDelegateTest.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Test
public void getColumnMappings() {
  TableView view = mock( TableView.class );
  doReturn( getColumnInfo() ).when( view ).getColumns();

  TransHistoryDelegate.TransHistoryLogTab model = mock( TransHistoryDelegate.TransHistoryLogTab.class );
  setInternalState( model, "logDisplayTableView", view );
  setInternalState( model, "logTableFields", getLogTableFields() );

  TransHistoryDelegate history = new TransHistoryDelegate( mock( Spoon.class ), mock( TransGraph.class ) );
  Map<String, Integer> map = history.getColumnMappings( model );

  assertEquals( 0, (int) map.get( "COLUMN_1" ) );
  assertEquals( 1, (int) map.get( "COLUMN_2" ) );
  assertEquals( 2, (int) map.get( "COLUMN_3" ) );
  assertEquals( 4, (int) map.get( "COLUMN_5" ) );
  assertEquals( 5, (int) map.get( "COLUMN_6" ) );
}
 
Example #14
Source File: StarModelerPerspective.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@Override
public boolean open(Node transNode, String fname, boolean importfile) {
  try {
    String xml = KettleVFS.getTextFileContent(fname, Const.XML_ENCODING);
    Domain domain = new SerializationService().deserializeDomain(xml);
    StarDomain starDomain = new StarDomain();
    starDomain.setDomain(domain);
    starDomain.setFilename(fname);
    createTabForDomain(starDomain);
    PropsUI.getInstance().addLastFile(LastUsedFile.FILE_TYPE_SCHEMA, fname, null, false, null);
    Spoon.getInstance().addMenuLast();
    return true;
  } catch(Exception e) {
    new ErrorDialog(Spoon.getInstance().getShell(), "Error", "There was an error opening model from file '"+fname+"'", e);
  }

  return false;
}
 
Example #15
Source File: JobExecutionConfigurationDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void addRunConfigurationListenerForExpandRemoteOption() {
  wRunConfiguration.addModifyListener( modifyEvent -> {
    List<Object> items = Arrays.asList( wRunConfiguration.getText(), true );
    try {
      ExtensionPointHandler.callExtensionPoint( Spoon.getInstance().getLog(), KettleExtensionPoint
        .RunConfigurationIsRemote.id, items );
    } catch ( KettleException ignored ) {
      // Ignore errors - keep old behavior - expand remote job always enabled
    }
    Boolean isRemote = (Boolean) items.get( 1 );
    getConfiguration().setRunConfiguration( wRunConfiguration.getText() );
    getConfiguration().setExecutingRemotely( isRemote );
    getConfiguration().setExecutingLocally( !isRemote );
    wExpandRemote.setEnabled( isRemote );
    wExpandRemote.setSelection( wExpandRemote.isEnabled() && wExpandRemote.getSelection() );
  } );
}
 
Example #16
Source File: RepositoryConnectController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public void connectToRepository( RepositoryMeta repositoryMeta, String username, String password ) throws KettleException {
  final Repository repository = loadRepositoryObject( repositoryMeta.getId() );
  repository.init( repositoryMeta );
  repositoryConnect( repository, username, password );
  if ( username != null ) {
    getPropsUI().setLastRepositoryLogin( username );
  }
  Spoon spoon = spoonSupplier.get();
  Runnable execute = () -> {
    if ( spoon.getRepository() != null ) {
      spoon.closeRepository();
    } else {
      spoon.closeAllJobsAndTransformations( true );
    }
    spoon.setRepository( repository );
    setConnectedRepository( repositoryMeta );
    fireListeners();
    spoon.updateTreeForActiveAbstractMetas();
  };
  if ( spoon.getShell() != null ) {
    spoon.getShell().getDisplay().asyncExec( execute );
  } else {
    execute.run();
  }
}
 
Example #17
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
private boolean checkTestPresent( Spoon spoon, TransMeta transMeta ) {

    TransUnitTest activeTest = activeTests.get( transMeta );
    if ( activeTest != null ) {
      return false;
    }

    // there is no test defined of selected in the transformation.
    // Show a warning
    //
    MessageBox box = new MessageBox( spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION );
    box.setMessage( "Please create a test-case first by left clicking on the test icon." );
    box.setText( "First create a test-case" );
    box.open();

    return true;
  }
 
Example #18
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
public void addDataSet() {

    Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );

    IMetaStore metaStore = spoon.getMetaStore();

    try {
      MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
      List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );
      groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, databases );
      List<DataSetGroup> groups = groupFactory.getElements();

      MetaStoreFactory<DataSet> setFactory = new MetaStoreFactory<DataSet>( DataSet.class, metaStore, PentahoDefaults.NAMESPACE );
      setFactory.addNameList( DataSetConst.GROUP_LIST_KEY, groups );

      DataSet dataSet = new DataSet();

      editDataSet( spoon, dataSet, groups, setFactory, null );

    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(), "Error", "Error creating a new data set", e );
    }
  }
 
Example #19
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
public void editDataSetGroup() {

    Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );

    IMetaStore metaStore = spoon.getMetaStore();
    MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
    try {

      List<String> groupNames = groupFactory.getElementNames();
      Collections.sort( groupNames );
      EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), groupNames.toArray( new String[ groupNames.size() ] ), "Select the group", "Select the group to edit..." );
      String groupName = esd.open();
      if ( groupName != null ) {
        editDataSetGroup( groupName );
      }
    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(), "Error", "Error retrieving the list of data set groups", e );
    }
  }
 
Example #20
Source File: StarModelerPerspective.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
protected void generateSqlJobButton(StarDomain starDomain) {
  final Spoon spoon = Spoon.getInstance();

  List<DatabaseMeta> sharedDatabases = SharedDatabaseUtil.loadSharedDatabases();

  // TODO: validate presence of repository, repository directory
  //
  JobGenerator jobGenerator = new JobGenerator(starDomain, spoon.rep, new RepositoryDirectory(), sharedDatabases, defaultLocale);
  try {
    JobMeta jobMeta = jobGenerator.generateSqlJob();
    spoon.addJobGraph(jobMeta);
    SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
  } catch(Exception e) {
    new ErrorDialog(spoon.getShell(),
        BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Title"),
        BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Message"), e);

  }


}
 
Example #21
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
public void editUnitTest( Spoon spoon, TransMeta transMeta, String unitTestName ) {

    IMetaStore metaStore = spoon.getMetaStore();
    try {
      FactoriesHierarchy hierarchy = getHierarchy();

      TransUnitTest unitTest = hierarchy.getTestFactory().loadElement( unitTestName );
      if ( unitTest == null ) {
        throw new KettleException( BaseMessages.getString( PKG, "DataSetHelper.ErrorEditingUnitTest.Message", unitTestName ) );
      }
      TransUnitTestDialog dialog = new TransUnitTestDialog( spoon.getShell(), transMeta, metaStore, unitTest );
      if ( dialog.open() ) {
        saveUnitTest( hierarchy.getTestFactory(), unitTest, transMeta );
      }
    } catch ( Exception exception ) {
      new ErrorDialog( Spoon.getInstance().getShell(),
        BaseMessages.getString( PKG, "DataSetHelper.ErrorEditingUnitTest.Title" ),
        BaseMessages.getString( PKG, "DataSetHelper.ErrorEditingUnitTest.Message", unitTestName ),
        exception );
    }
  }
 
Example #22
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
/**
 * List all unit tests which are defined
 * And allow the user to select one to delete
 */
public void deleteUnitTest() {
  try {

    RowMetaAndData selection = selectUnitTestFromAllTests();
    if ( selection != null ) {
      String unitTestName = selection.getString( 0, null );

      if ( StringUtils.isNotEmpty( unitTestName ) ) {
        deleteUnitTest( unitTestName );
      }
    }
  } catch ( Exception e ) {
    new ErrorDialog( Spoon.getInstance().getShell(), "Error", "Error deleting unit test", e );
  }
}
 
Example #23
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 6 votes vote down vote up
public void deleteUnitTest( String unitTestName ) {
  MessageBox box = new MessageBox( Spoon.getInstance().getShell(), SWT.YES | SWT.NO );
  box.setText( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDelete.Title" ) );
  box.setMessage( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDelete.Message", unitTestName ) );
  int answer = box.open();
  if ( ( answer & SWT.YES ) != 0 ) {
    try {
      FactoriesHierarchy hierarchy = getHierarchy();
      hierarchy.getTestFactory().deleteElement( unitTestName );
      DataSetHelper.getInstance().detachUnitTest();
    } catch ( Exception exception ) {
      new ErrorDialog( Spoon.getInstance().getShell(),
        BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingUnitTest.Title" ),
        BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingUnitTest.Message", unitTestName ),
        exception );

    }
  }
}
 
Example #24
Source File: RepositoryConnectController.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean deleteRepository( String name ) {
  RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( name );
  int index = repositoriesMeta.indexOfRepository( repositoryMeta );
  if ( index != -1 ) {
    repositoriesMeta.removeRepository( index );
    save();
    Spoon spoon = spoonSupplier.get();
    Runnable execute = () -> {
      if ( spoon.getRepositoryName() != null && spoon.getRepositoryName().equals( repositoryMeta.getName() ) ) {
        spoon.closeRepository();
        setConnectedRepository( null );
      }
      fireListeners();
    };
    if ( spoon.getShell() != null ) {
      spoon.getShell().getDisplay().asyncExec( execute );
    } else {
      execute.run();
    }
  }
  return true;
}
 
Example #25
Source File: JobEntryJobDialog.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private boolean askToCreateNewJob( String prevName ) {
  MessageBox mb = new MessageBox( shell, SWT.YES | SWT.NO | SWT.ICON_QUESTION );
  mb.setMessage( BaseMessages.getString( PKG, "JobJob.Dialog.CreateJobQuestion.Message" ) );
  mb.setText( BaseMessages.getString( PKG, "JobJob.Dialog.CreateJobQuestion.Title" ) );
  int answer = mb.open();
  if ( answer == SWT.YES ) {
    Spoon spoon = Spoon.getInstance();
    spoon.newJobFile();
    JobMeta newJobMeta = spoon.getActiveJob();
    newJobMeta.initializeVariablesFrom( jobEntry );
    newJobMeta.setFilename( jobMeta.environmentSubstitute( prevName ) );
    wPath.setText( prevName );
    specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
    spoon.saveFile();
    return true;
  }
  return false;
}
 
Example #26
Source File: JobGraph.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public static boolean editProperties( JobMeta jobMeta, Spoon spoon, Repository rep, boolean allowDirectoryChange ) {
  if ( jobMeta == null ) {
    return false;
  }

  JobDialog jd = new JobDialog( spoon.getShell(), SWT.NONE, jobMeta, rep );
  jd.setDirectoryChangeAllowed( allowDirectoryChange );
  JobMeta ji = jd.open();

  // In this case, load shared objects
  //
  if ( jd.isSharedObjectsFileChanged() ) {
    try {
      SharedObjects sharedObjects =
        rep != null ? rep.readJobMetaSharedObjects( jobMeta ) : jobMeta.readSharedObjects();
      spoon.sharedObjectsFileMap.put( sharedObjects.getFilename(), sharedObjects );
    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(),
        BaseMessages.getString( PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title" ),
        BaseMessages.getString( PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", spoon.delegates.tabs.makeTabName( jobMeta, true ) ), e );
    }
  }

  // If we added properties, add them to the variables too, so that they appear in the CTRL-SPACE variable completion.
  //
  spoon.setParametersAsVariablesInUI( jobMeta, jobMeta );

  if ( jd.isSharedObjectsFileChanged() || ji != null ) {
    spoon.refreshTree();
    spoon.delegates.tabs.renameTabs(); // cheap operation, might as will do it anyway
  }

  spoon.setShellText();
  return ji != null;
}
 
Example #27
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
public void clearGoldenDataSet() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  TransGraph transGraph = spoon.getActiveTransGraph();
  TransMeta transMeta = spoon.getActiveTransformation();
  StepMeta stepMeta = transGraph.getCurrentStep();
  if ( transGraph == null || transMeta == null || stepMeta == null ) {
    return;
  }
  if ( checkTestPresent( spoon, transMeta ) ) {
    return;
  }

  try {
    TransUnitTest currentUnitTest = getCurrentUnitTest( transMeta );

    TransUnitTestSetLocation goldenLocation = currentUnitTest.findGoldenLocation( stepMeta.getName() );
    if ( goldenLocation != null ) {
      currentUnitTest.getGoldenDataSets().remove( goldenLocation );
    }

    saveUnitTest( getHierarchy().getTestFactory(), currentUnitTest, transMeta );
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error saving unit test", e );
  }
  transMeta.setChanged();
  transGraph.redraw();
}
 
Example #28
Source File: SpoonTabsDelegate.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public String makeTabName( EngineMetaInterface transMeta, boolean showLocation ) {
  if ( Utils.isEmpty( transMeta.getName() ) && Utils.isEmpty( transMeta.getFilename() ) ) {
    return Spoon.STRING_TRANS_NO_NAME;
  }

  if ( Utils.isEmpty( transMeta.getName() )
    || spoon.delegates.trans.isDefaultTransformationName( transMeta.getName() ) ) {
    transMeta.nameFromFilename();
  }

  String name = "";

  if ( showLocation ) {
    if ( !Utils.isEmpty( transMeta.getFilename() ) ) {
      // Regular file...
      //
      name += transMeta.getFilename() + " : ";
    } else {
      // Repository object...
      //
      name += transMeta.getRepositoryDirectory().getPath() + " : ";
    }
  }

  name += transMeta.getName();
  if ( showLocation ) {
    ObjectRevision version = transMeta.getObjectRevision();
    if ( version != null ) {
      name += " : r" + version.getName();
    }
  }
  return name;
}
 
Example #29
Source File: XulDatabaseDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void setDatabaseMeta( DatabaseMeta dbMeta ) {
  if ( ( Spoon.getInstance() != null )
    && RepositorySecurityUI.verifyOperations( parentShell, Spoon.getInstance().getRepository(), RepositoryOperation.MODIFY_DATABASE ) ) {
    return;
  }

  databaseMeta = dbMeta;
  if ( dbMeta != null ) {
    databaseMetaObjectId = databaseMeta.getObjectId();
    databaseName = databaseMeta.getDisplayName();
  }
}
 
Example #30
Source File: DataSetHelper.java    From pentaho-pdi-dataset with Apache License 2.0 5 votes vote down vote up
public void clearInputDataSet() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  TransGraph transGraph = spoon.getActiveTransGraph();
  TransMeta transMeta = spoon.getActiveTransformation();
  StepMeta stepMeta = transGraph.getCurrentStep();
  if ( transGraph == null || transMeta == null || stepMeta == null ) {
    return;
  }
  if ( checkTestPresent( spoon, transMeta ) ) {
    return;
  }

  try {
    TransUnitTest currentUnitTest = getCurrentUnitTest( transMeta );

    TransUnitTestSetLocation inputLocation = currentUnitTest.findInputLocation( stepMeta.getName() );
    if ( inputLocation != null ) {
      currentUnitTest.getInputDataSets().remove( inputLocation );
    }

    saveUnitTest( getHierarchy().getTestFactory(), currentUnitTest, transMeta );

    transGraph.redraw();
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error saving unit test", e );
  }
}