Java Code Examples for org.pentaho.di.ui.spoon.Spoon#getInstance()
The following examples show how to use
org.pentaho.di.ui.spoon.Spoon#getInstance() .
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: JobGenerator.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private TransMeta generateTimeTransformation(DatabaseMeta databaseMeta, LogicalTable logicalTable) throws KettleException { // We actually load the transformation from a template and then slightly modify it. // String filename = "/org/pentaho/di/resources/Generate time dimension.ktr"; InputStream inputStream = getClass().getResourceAsStream(filename); TransMeta transMeta = new TransMeta(inputStream, Spoon.getInstance().rep, true, new Variables(), null); // Find the table output step and inject the target table name and database... // StepMeta stepMeta = transMeta.findStep("TARGET"); if (stepMeta!=null) { TableOutputMeta meta = (TableOutputMeta) stepMeta.getStepMetaInterface(); meta.setDatabaseMeta(databaseMeta); String phTable = ConceptUtil.getString(logicalTable, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME); meta.setTableName(phTable); } return transMeta; }
Example 2
Source File: JobGenerator.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private TransMeta generateDateTransformation(DatabaseMeta databaseMeta, LogicalTable logicalTable) throws KettleException { // We actually load the transformation from a template and then slightly modify it. // String filename = "/org/pentaho/di/resources/Generate date dimension.ktr"; InputStream inputStream = getClass().getResourceAsStream(filename); TransMeta transMeta = new TransMeta(inputStream, Spoon.getInstance().rep, true, new Variables(), null); // Find the table output step and inject the target table name and database... // StepMeta stepMeta = transMeta.findStep("TARGET"); if (stepMeta!=null) { TableOutputMeta meta = (TableOutputMeta) stepMeta.getStepMetaInterface(); meta.setDatabaseMeta(databaseMeta); String phTable = ConceptUtil.getString(logicalTable, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME); meta.setTableName(phTable); } return transMeta; }
Example 3
Source File: CustomAuthorizationCodeInstalledApp.java From pentaho-kettle with Apache License 2.0 | 6 votes |
protected void onAuthorization( AuthorizationCodeRequestUrl authorizationUrl ) throws IOException { String url = authorizationUrl.build(); Spoon spoon = Spoon.getInstance(); if ( spoon != null ) { Display.getDefault().syncExec( new Runnable() { public void run() { Shell shell = spoon.getShell(); GoogleAuthorizationDialog authorizationDialog = new GoogleAuthorizationDialog( shell, getReceiver() ); authorizationDialog.open( url ); } } ); } else { browse( url ); } }
Example 4
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 5
Source File: XulDatabaseDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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 6
Source File: EnterSelectionDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
protected void addDataSource() { Spoon theSpoon = Spoon.getInstance(); SpoonDBDelegate theDelegate = new SpoonDBDelegate( theSpoon ); theDelegate.newConnection( this.databasesInterface ); ArrayList<DatabaseMeta> theDatabases = new ArrayList<DatabaseMeta>(); theDatabases.addAll( this.databasesInterface.getDatabases() ); String[] theNames = new String[theDatabases.size()]; for ( int i = 0; i < theDatabases.size(); i++ ) { theNames[i] = theDatabases.get( i ).getName(); } this.choices = theNames; refresh(); }
Example 7
Source File: RepositoryVfsProvider.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private void registerRepoVFS() { FileSystemManager fsm = KettleVFS.getInstance().getFileSystemManager(); if ( fsm instanceof DefaultFileSystemManager ) { try { ( (DefaultFileSystemManager) fsm ).addProvider( SCHEME, this ); final Spoon spoon = Spoon.getInstance(); System.out.println( ); } catch ( Exception ex ) { throw new RuntimeException( "Error initialize repo:// VFS", ex ); } } }
Example 8
Source File: SpoonMenuLockController.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public void updateMenu( Document doc ) { try { Spoon spoon = Spoon.getInstance(); // If we are working with an Enterprise Repository if ( ( spoon != null ) && ( spoon.getRepository() != null ) && ( spoon.getRepository() instanceof PurRepository ) ) { ILockService service = getService( spoon.getRepository() ); EngineMetaInterface meta = spoon.getActiveMeta(); // If (meta is not null) and (meta is either a Transformation or Job) if ( ( meta != null ) && ( meta instanceof ILockable ) ) { RepositoryLock repoLock = null; if ( service != null && meta.getObjectId() != null ) { if ( meta instanceof EEJobMeta ) { repoLock = service.getJobLock( meta.getObjectId() ); } else { repoLock = service.getTransformationLock( meta.getObjectId() ); } } // If (there is a lock on this item) and (the UserInfo does not have permission to unlock this file) if ( repoLock != null ) { if ( !service.canUnlockFileById( meta.getObjectId() ) ) { // User does not have modify permissions on this file ( (XulToolbarbutton) doc.getElementById( "toolbar-file-save" ) ).setDisabled( true ); //$NON-NLS-1$ ( (XulMenuitem) doc.getElementById( "file-save" ) ).setDisabled( true ); //$NON-NLS-1$ } } } } } catch ( Exception e ) { throw new RuntimeException( e ); } }
Example 9
Source File: RepositorySpoonPlugin.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void applyToContainer( String category, XulDomContainer container ) throws XulException { if ( category.equals( SPOON_CATEGORY ) ) { XulToolbar toolbar = (XulToolbar) container.getDocumentRoot().getElementById( "main-toolbar" ); RepositoryConnectMenu repoConnectMenu = new RepositoryConnectMenu( Spoon.getInstance(), (ToolBar) toolbar.getManagedObject(), repositoryConnectController ); repoConnectMenu.render(); } }
Example 10
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
public void openUnitTestTransformation() { try { Spoon spoon = Spoon.getInstance(); FactoriesHierarchy hierarchy = getHierarchy(); RowMetaAndData selection = selectUnitTestFromAllTests(); if ( selection != null ) { String filename = selection.getString( 2, null ); if ( StringUtils.isNotEmpty( filename ) ) { // Load the unit test... // String unitTestName = selection.getString( 0, null ); TransUnitTest targetTest = hierarchy.getTestFactory().loadElement( unitTestName ); if ( targetTest != null ) { String completeFilename = targetTest.calculateCompleteFilename( Variables.getADefaultVariableSpace() ); spoon.openFile( completeFilename, false ); TransMeta transMeta = spoon.getActiveTransformation(); if ( transMeta != null ) { switchUnitTest( targetTest, transMeta ); } } } else { throw new KettleException( "No filename found: repositories not supported yet for this feature" ); } } } catch ( Exception e ) { new ErrorDialog( Spoon.getInstance().getShell(), "Error", "Error opening unit test transformation", e ); } }
Example 11
Source File: RepositoryVfsKettleLifecycleListener.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public RepositoryVfsKettleLifecycleListener() { this( new Supplier<Spoon>() { @Override public Spoon get() { return Spoon.getInstance(); } } ); }
Example 12
Source File: LocationMouseDoubleClickExtensionPoint.java From pentaho-pdi-dataset with Apache License 2.0 | 5 votes |
private void openDataSet( String dataSetName ) { Spoon spoon = Spoon.getInstance(); List<DatabaseMeta> databases = spoon.getActiveDatabases(); IMetaStore metaStore = spoon.getMetaStore(); try { FactoriesHierarchy factoriesHierarchy = new FactoriesHierarchy( metaStore, databases ); MetaStoreFactory<DataSet> setFactory = factoriesHierarchy.getSetFactory(); MetaStoreFactory<DataSetGroup> groupFactory = factoriesHierarchy.getGroupFactory(); List<DataSetGroup> groups = groupFactory.getElements(); DataSet dataSet = factoriesHierarchy.getSetFactory().loadElement( dataSetName ); DataSetDialog dataSetDialog = new DataSetDialog( spoon.getShell(), metaStore, dataSet, groups, databases ); while ( dataSetDialog.open() ) { String message = DataSetHelper.validateDataSet( dataSet, dataSetName, 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", "Error editing data set '" + dataSetName + "'", e ); } }
Example 13
Source File: VfsFileChooserControls.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private Spoon getSpoon() { return Spoon.getInstance(); }
Example 14
Source File: SessionTimeoutHandler.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private Spoon getSpoon() { return Spoon.getInstance(); }
Example 15
Source File: ShowUnitTestMenuExtensionPoint.java From pentaho-pdi-dataset with Apache License 2.0 | 4 votes |
protected void editUnitTest( String unitTestName, TransMeta transMeta ) { Spoon spoon = Spoon.getInstance(); DataSetHelper.getInstance().editUnitTest( spoon, transMeta, unitTestName ); }
Example 16
Source File: KettleDialog.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override protected Shell getParentShell( XulComponent parent ) { if ( parent == null && Spoon.getInstance() != null ) { return Spoon.getInstance().getShell(); } return super.getParentShell( parent ); }
Example 17
Source File: PartitionsFolderProvider.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public PartitionsFolderProvider() { this( GUIResource.getInstance(), Spoon.getInstance() ); }
Example 18
Source File: RequestLoginToRepositoryExtensionPoint.java From pentaho-kettle with Apache License 2.0 | 4 votes |
private Spoon getSpoon() { return Spoon.getInstance(); }
Example 19
Source File: Neo4jHelper.java From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 | 4 votes |
public void showMetaStoreBrowser() { Spoon spoon = Spoon.getInstance(); new MetaStoreExplorerDialog( spoon.getShell(), spoon.getMetaStore() ).open(); }
Example 20
Source File: Neo4jHelper.java From knowbi-pentaho-pdi-neo4j-output with Apache License 2.0 | 4 votes |
private Neo4jHelper() { spoon = Spoon.getInstance(); }