Java Code Examples for org.pentaho.di.ui.spoon.Spoon#getShell()
The following examples show how to use
org.pentaho.di.ui.spoon.Spoon#getShell() .
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: StarModelerPerspective.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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 File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
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 3
Source File: RepositoryConnectController.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public String browse() { Spoon spoon = spoonSupplier.get(); CompletableFuture<String> name = new CompletableFuture<>(); Runnable execute = () -> { DirectoryDialog directoryDialog = new DirectoryDialog( spoonSupplier.get().getShell() ); name.complete( directoryDialog.open() ); }; if ( spoon.getShell() != null ) { spoon.getShell().getDisplay().asyncExec( execute ); } else { execute.run(); } try { return name.get(); } catch ( Exception e ) { return "/"; } }
Example 4
Source File: RepositoryConnectController.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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 5
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
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 6
Source File: StarModelerPerspective.java From pentaho-kettle with Apache License 2.0 | 6 votes |
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 7
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
private void editDataSet( Spoon spoon, DataSet dataSet, List<DataSetGroup> groups, MetaStoreFactory<DataSet> setFactory, String setName ) throws MetaStoreException { try { DataSetDialog setDialog = new DataSetDialog( spoon.getShell(), setFactory.getMetaStore(), dataSet, groups, getAvailableDatabases( spoon.getRepository() ) ); while ( setDialog.open() ) { String message = validateDataSet( dataSet, setName, setFactory.getElementNames() ); // Save the data set... // if ( message == null ) { setFactory.saveElement( dataSet ); break; } else { MessageBox box = new MessageBox( spoon.getShell(), SWT.OK ); box.setText( "Error" ); box.setMessage( message ); box.open(); } } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Unable to edit data set", e ); } }
Example 8
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
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 9
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
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 10
Source File: JobGraph.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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 11
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
public void selectUnitTest() { Spoon spoon = ( (Spoon) SpoonFactory.getInstance() ); try { TransGraph transGraph = spoon.getActiveTransGraph(); IMetaStore metaStore = spoon.getMetaStore(); if ( transGraph == null ) { return; } TransMeta transMeta = spoon.getActiveTransformation(); if ( transMeta == null ) { return; } FactoriesHierarchy hierarchy = getHierarchy(); List<String> testNames = hierarchy.getTestFactory().getElementNames(); String[] names = testNames.toArray( new String[ testNames.size() ] ); Arrays.sort( names ); EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), names, "Select a unit test", "Select the unit test to use" ); String testName = esd.open(); if ( testName != null ) { TransUnitTest unitTest = hierarchy.getTestFactory().loadElement( testName ); if ( unitTest == null ) { throw new KettleException( "Unit test '" + testName + "' could not be found (deleted)?" ); } selectUnitTest( transMeta, unitTest ); Spoon.getInstance().refreshGraph(); } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error selecting a new transformation unit test", e ); } }
Example 12
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
public void createUnitTest( Spoon spoon, TransMeta transMeta ) { try { TransUnitTest unitTest = new TransUnitTest(); unitTest.setName( transMeta.getName() + " Test" ); unitTest.setTransFilename( transMeta.getFilename() ); if ( spoon.getRepository() != null ) { unitTest.setTransObjectId( transMeta.getObjectId() == null ? null : transMeta.getObjectId().getId() ); String path = transMeta.getRepositoryDirectory().getPath(); if ( !path.endsWith( "/" ) ) { path += "/"; } path += transMeta.getName(); unitTest.setTransRepositoryPath( path ); } FactoriesHierarchy hierarchy = getHierarchy(); TransUnitTestDialog dialog = new TransUnitTestDialog( spoon.getShell(), transMeta, spoon.getMetaStore(), unitTest ); if ( dialog.open() ) { saveUnitTest( hierarchy.getTestFactory(), unitTest, transMeta ); activeTests.put( transMeta, unitTest ); spoon.refreshGraph(); } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error creating a new transformation unit test", e ); } }
Example 13
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
/** * List all unit tests which are defined * And allow the user to select one */ public RowMetaAndData selectUnitTestFromAllTests() { Spoon spoon = Spoon.getInstance(); RowMetaInterface rowMeta = new RowMeta(); rowMeta.addValueMeta( new ValueMetaString( "Unit test" ) ); rowMeta.addValueMeta( new ValueMetaString( "Description" ) ); rowMeta.addValueMeta( new ValueMetaString( "Filename" ) ); List<RowMetaAndData> rows = new ArrayList<>(); try { FactoriesHierarchy hierarchy = getHierarchy(); List<String> testNames = hierarchy.getTestFactory().getElementNames(); for ( String testName : testNames ) { TransUnitTest unitTest = hierarchy.getTestFactory().loadElement( testName ); Object[] row = RowDataUtil.allocateRowData( rowMeta.size() ); row[ 0 ] = testName; row[ 1 ] = unitTest.getDescription(); row[ 2 ] = unitTest.getTransFilename(); rows.add( new RowMetaAndData( rowMeta, row ) ); } // Now show a selection dialog... // SelectRowDialog dialog = new SelectRowDialog( spoon.getShell(), new Variables(), SWT.DIALOG_TRIM | SWT.MAX | SWT.RESIZE, rows ); RowMetaAndData selection = dialog.open(); if ( selection != null ) { return selection; } return null; } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error listing/deleting unit test(s)", e ); return null; } }
Example 14
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
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 15
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
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 ); } }
Example 16
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
public void deleteDataSet() { 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 ); List<String> setNames = setFactory.getElementNames(); Collections.sort( setNames ); EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), setNames.toArray( new String[ setNames.size() ] ), "Select the data set", "Select the data set to delete..." ); String setName = esd.open(); if ( setName != null ) { DataSet dataSet = setFactory.loadElement( setName ); deleteDataSet( spoon, dataSet, groups, setFactory, setName ); } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error retrieving the list of data set groups", e ); } }
Example 17
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
public void editDataSet() { 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 ); List<String> setNames = setFactory.getElementNames(); Collections.sort( setNames ); EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), setNames.toArray( new String[ setNames.size() ] ), "Select the set", "Select the data set to edit..." ); String setName = esd.open(); if ( setName != null ) { DataSet dataSet = setFactory.loadElement( setName ); editDataSet( spoon, dataSet, groups, setFactory, setName ); } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error retrieving the list of data set groups", e ); } }
Example 18
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
public void addDataSetGroup() { Spoon spoon = ( (Spoon) SpoonFactory.getInstance() ); IMetaStore metaStore = spoon.getMetaStore(); MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE ); try { DataSetGroup dataSetGroup = new DataSetGroup(); List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() ); DataSetGroupDialog groupDialog = new DataSetGroupDialog( spoon.getShell(), dataSetGroup, databases ); while ( groupDialog.open() ) { // Verify empty name, existing name... // String message = validateDataSetGroup( dataSetGroup, null, groupFactory.getElementNames() ); // Save the group again... // if ( message == null ) { groupFactory.saveElement( dataSetGroup ); break; } else { MessageBox box = new MessageBox( spoon.getShell(), SWT.OK ); box.setText( "Error" ); box.setMessage( message ); box.open(); } } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error creating a new data set group", e ); } }
Example 19
Source File: RepositoryConnectController.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean updateRepository( String id, Map<String, Object> items ) { RepositoryMeta repositoryMeta = repositoriesMeta.findRepository( (String) items.get( ORIGINAL_NAME ) ); boolean isConnected = repositoryMeta == connectedRepository; repositoryMeta.populate( items, repositoriesMeta ); save(); if ( isConnected ) { Spoon spoon = spoonSupplier.get(); Runnable execute = () -> { spoon.setRepositoryName( repositoryMeta.getName() ); fireListeners(); }; if ( spoon.getShell() != null ) { spoon.getShell().getDisplay().asyncExec( execute ); } else { execute.run(); } } try { Repository repository = pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ); repository.init( repositoryMeta ); if ( !testRepository( repository ) ) { return false; } } catch ( KettleException e ) { return false; } currentRepository = repositoryMeta; return true; }
Example 20
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 4 votes |
/** * Create a new data set with the output from */ public void createDataSetFromStep() { Spoon spoon = ( (Spoon) SpoonFactory.getInstance() ); TransGraph transGraph = spoon.getActiveTransGraph(); IMetaStore metaStore = spoon.getMetaStore(); if ( transGraph == null ) { return; } StepMeta stepMeta = transGraph.getCurrentStep(); TransMeta transMeta = spoon.getActiveTransformation(); if ( stepMeta == null || transMeta == null ) { return; } try { FactoriesHierarchy hierarchy = getHierarchy(); MetaStoreFactory<DataSetGroup> groupFactory = hierarchy.getGroupFactory(); List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() ); groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, databases ); List<DataSetGroup> groups = groupFactory.getElements(); MetaStoreFactory<DataSet> setFactory = hierarchy.getSetFactory(); setFactory.addNameList( DataSetConst.GROUP_LIST_KEY, groups ); DataSet dataSet = new DataSet(); RowMetaInterface rowMeta = transMeta.getStepFields( stepMeta ); for ( int i = 0; i < rowMeta.size(); i++ ) { ValueMetaInterface valueMeta = rowMeta.getValueMeta( i ); String setFieldname = valueMeta.getName(); String columnName = "field" + i; DataSetField field = new DataSetField( setFieldname, columnName, valueMeta.getType(), valueMeta.getLength(), valueMeta.getPrecision(), valueMeta.getComments(), valueMeta.getFormatMask() ); dataSet.getFields().add( field ); } editDataSet( spoon, dataSet, groups, setFactory, null ); } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Error creating a new data set", e ); } }