use of org.pentaho.di.ui.spoon.Spoon in project pentaho-kettle by pentaho.
the class TransGraphTest method testInitializeXulMenu.
@SuppressWarnings("unchecked")
@Test
public void testInitializeXulMenu() throws KettleException {
StepMeta stepMeta = mock(StepMeta.class);
TransGraph transGraph = mock(TransGraph.class);
TransMeta transMeta = mock(TransMeta.class);
Document document = mock(Document.class);
XulMenuitem xulItem = mock(XulMenuitem.class);
XulMenu xulMenu = mock(XulMenu.class);
StepErrorMeta stepErrorMeta = mock(StepErrorMeta.class);
Spoon spoon = mock(Spoon.class);
List<StepMeta> selection = Arrays.asList(new StepMeta(), stepMeta, new StepMeta());
doCallRealMethod().when(transGraph).setTransMeta(any(TransMeta.class));
doCallRealMethod().when(transGraph).setSpoon(any(Spoon.class));
transGraph.setTransMeta(transMeta);
transGraph.setSpoon(spoon);
when(stepMeta.getStepErrorMeta()).thenReturn(stepErrorMeta);
when(stepMeta.isDrawn()).thenReturn(true);
when(document.getElementById(any(String.class))).thenReturn(xulItem);
when(document.getElementById(TransGraph.TRANS_GRAPH_ENTRY_AGAIN)).thenReturn(xulMenu);
when(document.getElementById(TransGraph.TRANS_GRAPH_ENTRY_SNIFF)).thenReturn(xulMenu);
doCallRealMethod().when(transGraph).initializeXulMenu(any(Document.class), any(List.class), any(StepMeta.class));
transGraph.initializeXulMenu(document, selection, stepMeta);
verify(transMeta).isAnySelectedStepUsedInTransHops();
}
use of org.pentaho.di.ui.spoon.Spoon in project pentaho-kettle by pentaho.
the class EnterSelectionDialog method addDataSource.
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();
}
use of org.pentaho.di.ui.spoon.Spoon in project pentaho-kettle by pentaho.
the class JobLoadProgressDialog method open.
public JobMeta open() {
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Spoon spoon = Spoon.getInstance();
try {
// Call extension point(s) before the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobBeforeOpen.id, (objectId == null) ? jobname : objectId.toString());
if (objectId != null) {
jobInfo = rep.loadJob(objectId, versionLabel);
} else {
jobInfo = rep.loadJob(jobname, repdir, new ProgressMonitorAdapter(monitor), versionLabel);
}
// Call extension point(s) now that the file has been opened
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterOpen.id, jobInfo);
if (jobInfo.hasMissingPlugins()) {
MissingEntryDialog missingDialog = new MissingEntryDialog(shell, jobInfo.getMissingEntries());
if (missingDialog.open() == null) {
jobInfo = null;
}
}
} catch (KettleException e) {
throw new InvocationTargetException(e, "Error loading job");
}
}
};
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
pmd.run(true, false, op);
} catch (InvocationTargetException e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, "Error loading job", "An error occured loading the job!", e);
jobInfo = null;
} catch (InterruptedException e) {
new ErrorDialog(shell, "Error loading job", "An error occured loading the job!", e);
jobInfo = null;
}
return jobInfo;
}
use of org.pentaho.di.ui.spoon.Spoon in project pentaho-kettle by pentaho.
the class RepositoryConnectController method browse.
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 "/";
}
}
use of org.pentaho.di.ui.spoon.Spoon in project pentaho-kettle by pentaho.
the class RepositoryConnectController method deleteRepository.
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;
}
Aggregations