Search in sources :

Example 6 with XulDomContainer

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

the class FragmentHandlerTest method testLoadDatabaseOptionsFragment.

@Test
public void testLoadDatabaseOptionsFragment() throws Exception {
    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);
    fragmentHandler.loadDatabaseOptionsFragment(null);
}
Also used : XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent) Test(org.junit.Test)

Example 7 with XulDomContainer

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

the class SpoonLockController method init.

protected void init() {
    try {
        if ((Spoon.getInstance().getRepository() != null) && (Spoon.getInstance().getRepository().hasService(IAbsSecurityProvider.class))) {
            IAbsSecurityProvider securityService = (IAbsSecurityProvider) Spoon.getInstance().getRepository().getService(IAbsSecurityProvider.class);
            setCreateAllowed(allowedActionsContains(securityService, IAbsSecurityProvider.CREATE_CONTENT_ACTION));
        }
        shell = (((Spoon) SpoonFactory.getInstance()).getShell());
        XulDomContainer container = getXulDomContainer();
        bindingFactory = new DefaultBindingFactory();
        bindingFactory.setDocument(container.getDocumentRoot());
        bindingFactory.setBindingType(Type.ONE_WAY);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        bindingFactory.createBinding(this, "activeMetaUnlocked", "lock-context-locknotes", "disabled");
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        bindingFactory.createBinding(this, "lockingNotAllowed", "lock-context-lock", "disabled");
        // Try transformation
        if (container.getEventHandlers().containsKey("transgraph")) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            workingMeta = ((TransGraph) container.getEventHandler("transgraph")).getMeta();
        } else if (container.getEventHandlers().containsKey("jobgraph")) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            workingMeta = ((JobGraph) container.getEventHandler("jobgraph")).getMeta();
        }
        RepositoryLock repoLock = fetchRepositoryLock(workingMeta);
        if (repoLock != null) {
            // $NON-NLS-1$
            XulMenuitem lockMenuItem = (XulMenuitem) container.getDocumentRoot().getElementById("lock-context-lock");
            lockMenuItem.setSelected(true);
            // Permit locking/unlocking if the user owns the lock
            if (Spoon.getInstance().getRepository() instanceof PurRepository) {
                setLockingAllowed(new UnifiedRepositoryLockService(((PurRepository) Spoon.getInstance().getRepository()).getUnderlyingRepository()).canUnlockFileById(workingMeta.getObjectId()));
            } else {
                setLockingAllowed(repoLock.getLogin().equalsIgnoreCase(Spoon.getInstance().getRepository().getUserInfo().getLogin()));
            }
        } else {
            setLockingAllowed(true);
        }
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        firePropertyChange("activeMetaUnlocked", null, repoLock == null);
    } catch (Exception e) {
        // $NON-NLS-1$
        log.error(BaseMessages.getString(PKG, "LockController.NoLockingSupport"), e);
        new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(PKG, "Dialog.Error"), e.getMessage(), // $NON-NLS-1$
        e);
    }
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) DefaultBindingFactory(org.pentaho.ui.xul.binding.DefaultBindingFactory) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) PurRepository(org.pentaho.di.repository.pur.PurRepository) UnifiedRepositoryLockService(org.pentaho.di.repository.pur.UnifiedRepositoryLockService) Spoon(org.pentaho.di.ui.spoon.Spoon) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 8 with XulDomContainer

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

the class FileOverwriteDialogController method getInstance.

public static FileOverwriteDialogController getInstance(Shell shell, List<UIRepositoryObject> objects) {
    try {
        KettleXulLoader swtLoader = new KettleXulLoader();
        swtLoader.setOuterContext(shell);
        swtLoader.setSettingsManager(XulSpoonSettingsManager.getInstance());
        XulDomContainer container = swtLoader.loadXul("org/pentaho/di/ui/repository/repositoryexplorer/xul/file-overwrite-dialog.xul", resourceBundle);
        final XulRunner runner = new SwtXulRunner();
        runner.addContainer(container);
        FileOverwriteDialogController dialogController = new FileOverwriteDialogController(container, objects);
        container.addEventHandler(dialogController);
        runner.initialize();
        return dialogController;
    } catch (Exception e) {
        return null;
    }
}
Also used : KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 9 with XulDomContainer

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

the class DatabaseDialogHarness method showDialog.

private void showDialog() {
    XulDomContainer container = null;
    try {
        DatabaseConnectionDialog dcDialog = new DatabaseConnectionDialog();
        container = dcDialog.getSwtInstance(new Shell(SWT.NONE));
        if (database != null) {
            container.getEventHandler("dataHandler").setData(database);
        }
    } catch (XulException e) {
        e.printStackTrace();
    }
    XulRoot root = (XulRoot) container.getDocumentRoot().getRootElement();
    if (root instanceof XulDialog) {
        ((XulDialog) root).show();
    }
    if (root instanceof XulWindow) {
        ((XulWindow) root).open();
    }
    try {
        database = (DatabaseMeta) container.getEventHandler("dataHandler").getData();
    } catch (Exception e) {
        e.printStackTrace();
    }
    String message = DatabaseDialogHarness.setMessage(database);
    Shell shell = new Shell(SWT.DIALOG_TRIM);
    shell.setLayout(new RowLayout());
    Label label = new Label(shell, SWT.NONE);
    label.setText(message);
    Button button = new Button(shell, SWT.NONE);
    button.setText("Edit Database ...");
    button.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            try {
                showDialog();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!shell.getDisplay().readAndDispatch()) {
            shell.getDisplay().sleep();
        }
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DatabaseConnectionDialog(org.pentaho.ui.database.DatabaseConnectionDialog) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) XulRoot(org.pentaho.ui.xul.containers.XulRoot) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) XulDialog(org.pentaho.ui.xul.containers.XulDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) XulWindow(org.pentaho.ui.xul.containers.XulWindow)

Example 10 with XulDomContainer

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

the class SwingTest method showDialog.

private void showDialog(final Document doc) {
    XulDomContainer container = null;
    try {
        container = new SwingXulLoader().loadXul(DatabaseConnectionDialog.DIALOG_DEFINITION_FILE, Messages.getBundle());
        if (database != null) {
            container.getEventHandler("dataHandler").setData(database);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    XulDialog dialog = (XulDialog) container.getDocumentRoot().getRootElement();
    container.initialize();
    dialog.show();
    try {
        @SuppressWarnings("unused") Object data = container.getEventHandler("dataHandler").getData();
    } catch (XulException e) {
        System.out.println("Error getting data");
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulDialog(org.pentaho.ui.xul.containers.XulDialog) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) SwingXulLoader(org.pentaho.ui.xul.swing.SwingXulLoader) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

XulDomContainer (org.pentaho.ui.xul.XulDomContainer)33 ResourceBundle (java.util.ResourceBundle)14 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)12 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)11 XulLoader (org.pentaho.ui.xul.XulLoader)11 ToolBar (org.eclipse.swt.widgets.ToolBar)8 Test (org.junit.Test)8 KettleException (org.pentaho.di.core.exception.KettleException)8 XulException (org.pentaho.ui.xul.XulException)8 XulRunner (org.pentaho.ui.xul.XulRunner)7 Shell (org.eclipse.swt.widgets.Shell)6 XulComponent (org.pentaho.ui.xul.XulComponent)6 XulSpoonResourceBundle (org.pentaho.di.ui.spoon.XulSpoonResourceBundle)5 Document (org.pentaho.ui.xul.dom.Document)5 Before (org.junit.Before)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 TransMeta (org.pentaho.di.trans.TransMeta)2 Spoon (org.pentaho.di.ui.spoon.Spoon)2 DatabaseConnectionDialog (org.pentaho.ui.database.DatabaseConnectionDialog)2 XulDialog (org.pentaho.ui.xul.containers.XulDialog)2