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

The following examples show how to use org.pentaho.di.ui.spoon.Spoon. These examples are extracted from open source projects. 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 Project: pentaho-kettle   Source File: StarModelerPerspective.java    License: 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 2
Source Project: pentaho-kettle   Source File: OsHelper.java    License: 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 3
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 4
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 5
Source Project: pentaho-kettle   Source File: TransHistoryDelegate.java    License: 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 Project: pentaho-kettle   Source File: TransHistoryDelegateTest.java    License: 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 7
Source Project: pentaho-kettle   Source File: StarModelerPerspective.java    License: 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 8
Source Project: pentaho-kettle   Source File: StarModelerPerspective.java    License: 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 9
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: 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 10
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: 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 11
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 12
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: 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 13
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: 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 14
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: 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 15
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: 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 16
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: 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 17
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 18
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 19
Source Project: pentaho-kettle   Source File: JobEntryJobDialog.java    License: 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 20
Source Project: pentaho-kettle   Source File: JobEntryBaseDialog.java    License: 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 21
Source Project: pentaho-kettle   Source File: ImportRulesDialog.java    License: 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 22
Source Project: pentaho-kettle   Source File: TransLogDelegate.java    License: 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 23
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 24
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 25
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 26
Source Project: pentaho-kettle   Source File: SpoonTabsDelegate.java    License: 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 27
private void openConnection( Event event ) {
  String[] selection = wConnections.getSelection();
  if ( selection == null || selection.length < 1 ) {
    return;
  }
  String connectionName = selection[ 0 ];

  try {
    openConnection( connectionName );
  } catch ( Exception e ) {
    new ErrorDialog( Spoon.getInstance().getShell(), "Error", "Unable to open Neo4j Browser to connection '" + connectionName + "'", e );
  }
}
 
Example 28
Source Project: pentaho-kettle   Source File: SpoonDelegates.java    License: Apache License 2.0 5 votes vote down vote up
public SpoonDelegates( Spoon spoon ) {
  tabs = new SpoonTabsDelegate( spoon );
  tree = new SpoonTreeDelegate( spoon );
  slaves = new SpoonSlaveDelegate( spoon );
  steps = new SpoonStepsDelegate( spoon );
  db = new SpoonDBDelegate( spoon );
  clusters = new SpoonClustersDelegate( spoon );
  partitions = new SpoonPartitionsDelegate( spoon );
  update( spoon );
}
 
Example 29
private void newGraphModel( Event event ) {
  try {
    GraphModel graphModel = new GraphModel();
    editGraphModel(graphModel);
  } catch ( Exception e ) {
    new ErrorDialog( Spoon.getInstance().getShell(), "Error", "Unable to create graph model", e );
  }
}
 
Example 30
Source Project: pentaho-kettle   Source File: ModelerHelper.java    License: Apache License 2.0 5 votes vote down vote up
public void createEmptyModel() {
  try {
    StarDomain starDomain = new StarDomain();
    starDomain.getDomain().setName(new LocalizedString(defaultLocale, "Star model domain"));
    starDomain.getDomain().setDescription(new LocalizedString(defaultLocale, "This star model domain contains multiple star models for the same subject domain"));
    StarModelerPerspective.getInstance().createTabForDomain(starDomain);
    SpoonPerspectiveManager.getInstance().activatePerspective(StarModelerPerspective.class);
  } catch (Exception e) {
    new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), "Error", "Error creating visualization", e);
  }
}