Search in sources :

Example 1 with XulVbox

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

the class SpoonPerspectiveManager method initialize.

public void initialize() {
    XulToolbar mainToolbar = (XulToolbar) domContainer.getDocumentRoot().getElementById("main-toolbar");
    SwtDeck deck = (SwtDeck) domContainer.getDocumentRoot().getElementById("canvas-deck");
    int y = 0;
    int perspectiveIdx = 0;
    Class<? extends SpoonPerspective> perClass = null;
    List<SpoonPerspective> perspectives = getPerspectives();
    if (this.startupPerspective != null) {
        for (int i = 0; i < perspectives.size(); i++) {
            if (perspectives.get(i).getId().equals(this.startupPerspective)) {
                perspectiveIdx = i;
                break;
            }
        }
    }
    final List<PerspectiveData> perspectiveList = new ArrayList<>();
    final ToolBar swtToolbar = (ToolBar) mainToolbar.getManagedObject();
    final Shell shell = swtToolbar.getShell();
    final ToolItem perspectiveButton = new ToolItem(swtToolbar, SWT.DROP_DOWN, 7);
    perspectiveButton.setImage(GUIResource.getInstance().getImage("ui/images/perspective_changer.svg"));
    perspectiveButton.setToolTipText(BaseMessages.getString(PKG, "Spoon.Menu.View.Perspectives"));
    perspectiveButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            Menu menu = new Menu(shell);
            for (final PerspectiveData perspectiveData : perspectiveList) {
                MenuItem item = new MenuItem(menu, SWT.CHECK);
                if (perspectiveData.isHidden()) {
                    item.setEnabled(false);
                }
                if (activePerspective.getId().equals(perspectiveData.getId())) {
                    item.setSelection(true);
                }
                item.setText(perspectiveData.getName());
                item.addSelectionListener(new SelectionAdapter() {

                    @Override
                    public void widgetSelected(SelectionEvent selectionEvent) {
                        Spoon.getInstance().loadPerspective(perspectiveData.getId());
                        swtToolbar.forceFocus();
                    }
                });
            }
            ToolItem item = (ToolItem) e.widget;
            Rectangle rect = item.getBounds();
            Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y + rect.height));
            menu.setLocation(pt.x, pt.y);
            menu.setVisible(true);
        }
    });
    for (final SpoonPerspective per : getPerspectives()) {
        if (installedPerspectives.contains(per)) {
            y++;
            continue;
        }
        String name = per.getDisplayName(LanguageChoice.getInstance().getDefaultLocale());
        PerspectiveData perspectiveData = new PerspectiveData(name, per.getId());
        if (Arrays.asList(defaultDisabled).contains(per.getId())) {
            perspectiveData.setHidden(true);
        }
        perspectiveList.add(perspectiveData);
        XulVbox box = deck.createVBoxCard();
        box.setId("perspective-" + per.getId());
        box.setFlex(1);
        deck.addChild(box);
        PerspectiveManager perspectiveManager = new PerspectiveManager(per, box, mainToolbar, perspectiveList, name);
        perspectiveManagerMap.put(per, perspectiveManager);
        // Need to force init for main perspective even if it won't be shown
        if (perspectiveIdx == y || y == 0) {
            if (perspectiveIdx == y) {
                // we have a startup perspective. Hold onto the class
                perClass = per.getClass();
            }
            // force init
            perspectiveManager.initializeIfNeeded();
        }
        y++;
        installedPerspectives.add(per);
    }
    deck.setSelectedIndex(perspectiveIdx);
    if (perClass != null) {
        // activate the startup perspective
        try {
            activatePerspective(perClass);
            // stop other perspectives from opening
            SpoonPerspectiveManager.getInstance().setForcePerspective(true);
        } catch (KettleException e) {
        // TODO Auto-generated catch block
        }
    }
}
Also used : SwtDeck(org.pentaho.ui.xul.swt.tags.SwtDeck) XulVbox(org.pentaho.ui.xul.containers.XulVbox) KettleException(org.pentaho.di.core.exception.KettleException) XulToolbar(org.pentaho.ui.xul.containers.XulToolbar) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) Rectangle(org.eclipse.swt.graphics.Rectangle) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) Shell(org.eclipse.swt.widgets.Shell) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 2 with XulVbox

use of org.pentaho.ui.xul.containers.XulVbox in project data-access by pentaho.

the class MultiTableDatasource method activating.

@Override
public void activating() throws XulException {
    this.connectionSelectionStep.activating();
    this.tablesSelectionStep.activating();
    this.joinDefinitionsStep.activating();
    XulVbox queryVbox = (XulVbox) document.getElementById("queryBox");
    queryVbox.setVisible(false);
    XulVbox metadataVbox = (XulVbox) document.getElementById("metadata");
    metadataVbox.setVisible(true);
    XulVbox connectionsVbox = (XulVbox) document.getElementById("connectionsLbl");
    connectionsVbox.setVisible(true);
    XulListbox connections = (XulListbox) document.getElementById("connectionList");
    connections.setWidth(568);
    connections.setHeight(275);
    try {
        // RPB: BISERVER-9258.
        // conditionally hiding the selection of reporting vs reporting+olap in the case where reporting only makes no
        // sense.
        // bf.createBinding(wizardModel, "reportingOnlyValid", "metadata", "visible").fireSourceChanged();
        // Use a binding to keep the radio buttons in sync
        bf.setBindingType(Type.BI_DIRECTIONAL);
        XulRadio olapRadio = (XulRadio) document.getElementById("reporting_analysis");
        bf.createBinding(olapRadio, "checked", joinGuiModel, "doOlap");
        bf.setBindingType(Type.ONE_WAY);
        XulRadio reportingRadio = (XulRadio) document.getElementById("reporting");
        bf.createBinding(wizardModel, "reportingOnlyValid", reportingRadio, "checked").fireSourceChanged();
    } catch (Exception e) {
        e.printStackTrace();
    }
    this.errorDialog = (XulDialog) document.getElementById("errorDialog");
    this.errorLabel = (XulLabel) document.getElementById("errorLabel");
    this.connectionSelectionStep.setValid(true);
    this.setConnection(connectionSelectionStep.getConnection());
}
Also used : XulVbox(org.pentaho.ui.xul.containers.XulVbox) XulRadio(org.pentaho.ui.xul.components.XulRadio) XulListbox(org.pentaho.ui.xul.containers.XulListbox) XulException(org.pentaho.ui.xul.XulException)

Example 3 with XulVbox

use of org.pentaho.ui.xul.containers.XulVbox in project data-access by pentaho.

the class QueryPhysicalStep method activating.

@Override
public void activating() {
    XulVbox queryVbox = (XulVbox) document.getElementById("queryBox");
    queryVbox.setVisible(true);
    XulVbox metadataVbox = (XulVbox) document.getElementById("metadata");
    metadataVbox.setVisible(false);
    XulVbox connectionsVbox = (XulVbox) document.getElementById("connectionsLbl");
    connectionsVbox.setVisible(false);
    XulListbox connections = (XulListbox) document.getElementById("connectionList");
    connections.setWidth(180);
    connections.setHeight(325);
}
Also used : XulVbox(org.pentaho.ui.xul.containers.XulVbox) XulListbox(org.pentaho.ui.xul.containers.XulListbox)

Aggregations

XulVbox (org.pentaho.ui.xul.containers.XulVbox)3 XulListbox (org.pentaho.ui.xul.containers.XulListbox)2 ArrayList (java.util.ArrayList)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Menu (org.eclipse.swt.widgets.Menu)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 Shell (org.eclipse.swt.widgets.Shell)1 ToolBar (org.eclipse.swt.widgets.ToolBar)1 ToolItem (org.eclipse.swt.widgets.ToolItem)1 KettleException (org.pentaho.di.core.exception.KettleException)1 XulException (org.pentaho.ui.xul.XulException)1 XulRadio (org.pentaho.ui.xul.components.XulRadio)1 XulToolbar (org.pentaho.ui.xul.containers.XulToolbar)1 SwtDeck (org.pentaho.ui.xul.swt.tags.SwtDeck)1