Search in sources :

Example 6 with Document

use of org.pentaho.ui.xul.dom.Document in project data-access by pentaho.

the class EmbeddedWizard method setUploadPath.

/**
 * Upload path is by necessity relative. as such it will differ where the module is based.
 *
 * @param path
 */
public void setUploadPath(String path) {
    Document rootDocument = mainWizardContainer.getDocumentRoot();
    // $NON-NLS-1$
    XulFileUpload upload = (XulFileUpload) rootDocument.getElementById("fileUpload");
    upload.setAction(path);
}
Also used : XulFileUpload(org.pentaho.ui.xul.components.XulFileUpload) Document(org.pentaho.ui.xul.dom.Document)

Example 7 with Document

use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.

the class FragmentHandlerTest method testRefreshOptions.

@Test
public void testRefreshOptions() throws Exception {
    XulListbox connectionBox = mock(XulListbox.class);
    when(document.getElementById("connection-type-list")).thenReturn(connectionBox);
    when(connectionBox.getSelectedItem()).thenReturn("myDb");
    XulListbox accessBox = mock(XulListbox.class);
    when(document.getElementById("access-type-list")).thenReturn(accessBox);
    when(accessBox.getSelectedItem()).thenReturn("Native");
    DataHandler dataHandler = mock(DataHandler.class);
    when(xulDomContainer.getEventHandler("dataHandler")).thenReturn(dataHandler);
    DatabaseInterface dbInterface = mock(DatabaseInterface.class);
    when(dbInterface.getDefaultDatabasePort()).thenReturn(5309);
    DataHandler.connectionMap.put("myDb", dbInterface);
    XulComponent component = mock(XulComponent.class);
    XulComponent parent = mock(XulComponent.class);
    when(component.getParent()).thenReturn(parent);
    when(document.getElementById("database-options-box")).thenReturn(component);
    XulDomContainer fragmentContainer = mock(XulDomContainer.class);
    Document mockDoc = mock(Document.class);
    XulComponent firstChild = mock(XulComponent.class);
    when(mockDoc.getFirstChild()).thenReturn(firstChild);
    when(fragmentContainer.getDocumentRoot()).thenReturn(mockDoc);
    when(xulDomContainer.loadFragment(anyString(), any(Object.class))).thenReturn(fragmentContainer);
    XulTextbox portBox = mock(XulTextbox.class);
    when(document.getElementById("port-number-text")).thenReturn(portBox);
    fragmentHandler.refreshOptions();
    // Iterate through the other database access types
    when(accessBox.getSelectedItem()).thenReturn("JNDI");
    fragmentHandler.refreshOptions();
    when(accessBox.getSelectedItem()).thenReturn("ODBC");
    fragmentHandler.refreshOptions();
    when(accessBox.getSelectedItem()).thenReturn("OCI");
    fragmentHandler.refreshOptions();
    when(accessBox.getSelectedItem()).thenReturn("Plugin");
    fragmentHandler.refreshOptions();
}
Also used : DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulListbox(org.pentaho.ui.xul.containers.XulListbox) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent) Test(org.junit.Test)

Example 8 with Document

use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.

the class BrowseControllerTest method setUp.

@Before
public void setUp() throws Exception {
    DocumentFactory.registerElementClass(ElementDom4J.class);
    controller = new BrowseController();
    controller.setRepositoryDirectory(mock(UIRepositoryDirectory.class));
    directoryMap = new HashMap<>(8);
    controller.setDirMap(directoryMap);
    document = mock(Document.class);
    XulDomContainer xulDomContainer = mock(XulDomContainer.class);
    when(xulDomContainer.getDocumentRoot()).thenReturn(document);
    controller.setXulDomContainer(xulDomContainer);
    UIRepositoryDirectory someDirectory = mock(UIRepositoryDirectory.class);
    selectedFolder = mock(UIRepositoryDirectory.class);
    when(selectedFolder.createFolder(FOLDER_NAME)).thenReturn(someDirectory);
    XulTree folderTree = mock(XulTree.class);
    when(folderTree.getSelectedItems()).thenReturn(Collections.<Object>singleton(selectedFolder));
    controller.setFolderTree(folderTree);
    directoryBinding = mock(Binding.class);
    controller.setDirectoryBinding(directoryBinding);
    selectedItemsBinding = mock(Binding.class);
    controller.setSelectedItemsBinding(selectedItemsBinding);
}
Also used : UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) Binding(org.pentaho.ui.xul.binding.Binding) XulTree(org.pentaho.ui.xul.containers.XulTree) Document(org.pentaho.ui.xul.dom.Document) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Before(org.junit.Before)

Example 9 with Document

use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.

the class SpoonPerspectiveManager method removePerspective.

public void removePerspective(SpoonPerspective per) {
    perspectives.remove(per);
    orderedPerspectives.remove(per);
    Document document = domContainer.getDocumentRoot();
    XulComponent comp = document.getElementById("perspective-" + per.getId());
    comp.getParent().removeChild(comp);
    comp = document.getElementById("perspective-btn-" + per.getId());
    comp.getParent().removeChild(comp);
    XulToolbar mainToolbar = (XulToolbar) domContainer.getDocumentRoot().getElementById("main-toolbar");
    ((Composite) mainToolbar.getManagedObject()).layout(true, true);
    deck.setSelectedIndex(0);
}
Also used : XulToolbar(org.pentaho.ui.xul.containers.XulToolbar) Composite(org.eclipse.swt.widgets.Composite) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 10 with Document

use of org.pentaho.ui.xul.dom.Document in project pentaho-kettle by pentaho.

the class JobGraph method setMenu.

protected synchronized void setMenu(int x, int y) {
    currentMouseX = x;
    currentMouseY = y;
    final JobEntryCopy jobEntry = jobMeta.getJobEntryCopy(x, y, iconsize);
    setJobEntry(jobEntry);
    Document doc = xulDomContainer.getDocumentRoot();
    if (jobEntry != null) {
        // We clicked on a Job Entry!
        XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-entry");
        if (menu != null) {
            List<JobEntryCopy> selection = jobMeta.getSelectedEntries();
            doRightClickSelection(jobEntry, selection);
            int sels = selection.size();
            XulMenuitem item = (XulMenuitem) doc.getElementById("job-graph-entry-newhop");
            item.setDisabled(sels < 2);
            JfaceMenupopup launchMenu = (JfaceMenupopup) doc.getElementById("job-graph-entry-launch-popup");
            String[] referencedObjects = jobEntry.getEntry().getReferencedObjectDescriptions();
            boolean[] enabledObjects = jobEntry.getEntry().isReferencedObjectEnabled();
            launchMenu.setDisabled(Utils.isEmpty(referencedObjects));
            launchMenu.removeChildren();
            if (!Utils.isEmpty(referencedObjects)) {
                for (int i = 0; i < referencedObjects.length; i++) {
                    final int index = i;
                    String referencedObject = referencedObjects[i];
                    Action action = new Action(referencedObject, Action.AS_DROP_DOWN_MENU) {

                        public void run() {
                            loadReferencedObject(jobEntry, index);
                        }
                    };
                    JfaceMenuitem child = new JfaceMenuitem(null, launchMenu, xulDomContainer, referencedObject, i, action);
                    child.setLabel(referencedObject);
                    child.setDisabled(!enabledObjects[i]);
                }
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-align-snap");
            item.setAcceltext("ALT-HOME");
            item.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.JobEntry.AllignDistribute.SnapToGrid"));
            item.setAccesskey("alt-home");
            XulMenu aMenu = (XulMenu) doc.getElementById("job-graph-entry-align");
            if (aMenu != null) {
                aMenu.setDisabled(sels < 1);
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-detach");
            if (item != null) {
                item.setDisabled(!jobMeta.isEntryUsedInHops(jobEntry));
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-hide");
            if (item != null) {
                item.setDisabled(!(jobEntry.isDrawn() && !jobMeta.isEntryUsedInHops(jobEntry)));
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-delete");
            if (item != null) {
                item.setDisabled(!jobEntry.isDrawn());
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-parallel");
            if (item != null) {
                item.setSelected(jobEntry.isLaunchingInParallel());
            }
            try {
                JobGraphJobEntryMenuExtension extension = new JobGraphJobEntryMenuExtension(xulDomContainer, doc, jobMeta, jobEntry, this);
                ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobGraphJobEntrySetMenu.id, extension);
            } catch (Exception e) {
                log.logError("Error handling menu right click on job entry through extension point", e);
            }
            ConstUI.displayMenu(menu, canvas);
        }
    } else {
        // Clear the menu
        final JobHopMeta hi = findJobHop(x, y);
        setCurrentHop(hi);
        if (hi != null) {
            // We clicked on a HOP!
            XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-hop");
            if (menu != null) {
                XulMenuitem miPopEvalUncond = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-uncond");
                XulMenuitem miPopEvalTrue = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-true");
                XulMenuitem miPopEvalFalse = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-false");
                XulMenuitem miDisHop = (XulMenuitem) doc.getElementById("job-graph-hop-enabled");
                XulMenuitem miFlipHop = (XulMenuitem) doc.getElementById("job-graph-hop-flip");
                // 
                if (miPopEvalUncond != null && miPopEvalTrue != null && miPopEvalFalse != null) {
                    if (hi.isUnconditional()) {
                        miPopEvalUncond.setSelected(true);
                        miPopEvalTrue.setSelected(false);
                        miPopEvalFalse.setSelected(false);
                    } else {
                        if (hi.getEvaluation()) {
                            miPopEvalUncond.setSelected(false);
                            miPopEvalTrue.setSelected(true);
                            miPopEvalFalse.setSelected(false);
                        } else {
                            miPopEvalUncond.setSelected(false);
                            miPopEvalTrue.setSelected(false);
                            miPopEvalFalse.setSelected(true);
                        }
                    }
                    if (!hi.getFromEntry().evaluates()) {
                        miPopEvalTrue.setDisabled(true);
                        miPopEvalFalse.setDisabled(true);
                    } else {
                        miPopEvalTrue.setDisabled(false);
                        miPopEvalFalse.setDisabled(false);
                    }
                    if (!hi.getFromEntry().isUnconditional()) {
                        miPopEvalUncond.setDisabled(true);
                    } else {
                        miPopEvalUncond.setDisabled(false);
                    }
                    if (hi.getFromEntry().isStart()) {
                        miFlipHop.setDisabled(true);
                    } else {
                        miFlipHop.setDisabled(false);
                    }
                }
                if (miDisHop != null) {
                    if (hi.isEnabled()) {
                        miDisHop.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.Hop.Disable"));
                    } else {
                        miDisHop.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.Hop.Enable"));
                    }
                }
                ConstUI.displayMenu(menu, canvas);
            }
        } else {
            // Clicked on the background: maybe we hit a note?
            final NotePadMeta ni = jobMeta.getNote(x, y);
            setCurrentNote(ni);
            if (ni != null) {
                XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-note");
                if (menu != null) {
                    ConstUI.displayMenu(menu, canvas);
                }
            } else {
                XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-background");
                if (menu != null) {
                    final String clipcontent = spoon.fromClipboard();
                    XulMenuitem item = (XulMenuitem) doc.getElementById("job-graph-note-paste");
                    if (item != null) {
                        item.setDisabled(clipcontent == null);
                    }
                    ConstUI.displayMenu(menu, canvas);
                }
            }
        }
    }
}
Also used : Action(org.eclipse.jface.action.Action) JobHopMeta(org.pentaho.di.job.JobHopMeta) JfaceMenuitem(org.pentaho.ui.xul.jface.tags.JfaceMenuitem) Document(org.pentaho.ui.xul.dom.Document) JfaceMenupopup(org.pentaho.ui.xul.jface.tags.JfaceMenupopup) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException) XulMenupopup(org.pentaho.ui.xul.containers.XulMenupopup) XulMenu(org.pentaho.ui.xul.containers.XulMenu) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Aggregations

Document (org.pentaho.ui.xul.dom.Document)17 Test (org.junit.Test)7 KettleException (org.pentaho.di.core.exception.KettleException)7 XulException (org.pentaho.ui.xul.XulException)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)5 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)5 Shell (org.eclipse.swt.widgets.Shell)4 XulComponent (org.pentaho.ui.xul.XulComponent)4 XulRunner (org.pentaho.ui.xul.XulRunner)4 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)4 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 XulLoader (org.pentaho.ui.xul.XulLoader)3 XulMenu (org.pentaho.ui.xul.containers.XulMenu)3 Action (org.eclipse.jface.action.Action)2 Before (org.junit.Before)2 NotePadMeta (org.pentaho.di.core.NotePadMeta)2 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)2 Point (org.pentaho.di.core.gui.Point)2