Search in sources :

Example 1 with Spoon

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();
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Spoon(org.pentaho.di.ui.spoon.Spoon) TransMeta(org.pentaho.di.trans.TransMeta) StepErrorMeta(org.pentaho.di.trans.step.StepErrorMeta) List(java.util.List) Document(org.pentaho.ui.xul.dom.Document) StepMeta(org.pentaho.di.trans.step.StepMeta) XulMenu(org.pentaho.ui.xul.containers.XulMenu) Test(org.junit.Test)

Example 2 with Spoon

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();
}
Also used : Spoon(org.pentaho.di.ui.spoon.Spoon) ArrayList(java.util.ArrayList) SpoonDBDelegate(org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 3 with Spoon

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Spoon(org.pentaho.di.ui.spoon.Spoon) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MissingEntryDialog(org.pentaho.di.ui.job.entries.missing.MissingEntryDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 4 with Spoon

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 "/";
    }
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Spoon(org.pentaho.di.ui.spoon.Spoon) KettleException(org.pentaho.di.core.exception.KettleException) ExecutionException(java.util.concurrent.ExecutionException) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 5 with Spoon

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;
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) Spoon(org.pentaho.di.ui.spoon.Spoon)

Aggregations

Spoon (org.pentaho.di.ui.spoon.Spoon)26 KettleException (org.pentaho.di.core.exception.KettleException)11 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)8 TransMeta (org.pentaho.di.trans.TransMeta)6 JobMeta (org.pentaho.di.job.JobMeta)5 XulException (org.pentaho.ui.xul.XulException)5 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)5 File (java.io.File)3 Shell (org.eclipse.swt.widgets.Shell)3 Test (org.junit.Test)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)3 PurRepository (org.pentaho.di.repository.pur.PurRepository)3 RepositoryLock (org.pentaho.di.repository.pur.model.RepositoryLock)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 FileDialog (org.eclipse.swt.widgets.FileDialog)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)2