Search in sources :

Example 26 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class SpoonSlaveDelegate method addSpoonSlave.

public void addSpoonSlave(SlaveServer slaveServer) {
    TabSet tabfolder = spoon.tabfolder;
    // See if there is a SpoonSlave for this slaveServer...
    String tabName = spoon.delegates.tabs.makeSlaveTabName(slaveServer);
    TabMapEntry tabMapEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.SLAVE_SERVER);
    if (tabMapEntry == null) {
        SpoonSlave spoonSlave = new SpoonSlave(tabfolder.getSwtTabset(), SWT.NONE, spoon, slaveServer);
        PropsUI props = PropsUI.getInstance();
        TabItem tabItem = new TabItem(tabfolder, tabName, tabName, props.getSashWeights());
        tabItem.setToolTipText("Status of slave server : " + slaveServer.getName() + " : " + slaveServer.getServerAndPort());
        tabItem.setControl(spoonSlave);
        tabMapEntry = new TabMapEntry(tabItem, null, tabName, null, null, spoonSlave, ObjectType.SLAVE_SERVER);
        spoon.delegates.tabs.addTab(tabMapEntry);
    }
    int idx = tabfolder.indexOf(tabMapEntry.getTabItem());
    tabfolder.setSelected(idx);
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) TabSet(org.pentaho.xul.swt.tab.TabSet) SpoonSlave(org.pentaho.di.ui.spoon.SpoonSlave) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) PropsUI(org.pentaho.di.ui.core.PropsUI)

Example 27 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class SpoonTabsDelegate method addSpoonBrowser.

public boolean addSpoonBrowser(String name, String urlString, boolean isURL, LocationListener listener, Map<String, Runnable> functions, boolean showControls) {
    TabSet tabfolder = spoon.tabfolder;
    try {
        // OK, now we have the HTML, create a new browser tab.
        // See if there already is a tab for this browser
        // If no, add it
        // If yes, select that tab
        // 
        TabMapEntry tabMapEntry = findTabMapEntry(name, ObjectType.BROWSER);
        if (tabMapEntry == null) {
            CTabFolder cTabFolder = tabfolder.getSwtTabset();
            final SpoonBrowser browser = new SpoonBrowser(cTabFolder, spoon, urlString, isURL, showControls, listener);
            browser.getBrowser().addOpenWindowListener(new OpenWindowListener() {

                @Override
                public void open(WindowEvent event) {
                    if (event.required) {
                        event.browser = browser.getBrowser();
                    }
                }
            });
            if (functions != null) {
                for (String functionName : functions.keySet()) {
                    new BrowserFunction(browser.getBrowser(), functionName) {

                        public Object function(Object[] arguments) {
                            functions.get(functionName).run();
                            return null;
                        }
                    };
                }
            }
            new BrowserFunction(browser.getBrowser(), "genericFunction") {

                public Object function(Object[] arguments) {
                    try {
                        ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonBrowserFunction.id, arguments);
                    } catch (KettleException ignored) {
                    }
                    return null;
                }
            };
            new BrowserFunction(browser.getBrowser(), "openURL") {

                public Object function(Object[] arguments) {
                    Program.launch(arguments[0].toString());
                    return null;
                }
            };
            PropsUI props = PropsUI.getInstance();
            TabItem tabItem = new TabItem(tabfolder, name, name, props.getSashWeights());
            tabItem.setImage(GUIResource.getInstance().getImageLogoSmall());
            tabItem.setControl(browser.getComposite());
            tabMapEntry = new TabMapEntry(tabItem, isURL ? urlString : null, name, null, null, browser, ObjectType.BROWSER);
            tabMap.add(tabMapEntry);
        }
        int idx = tabfolder.indexOf(tabMapEntry.getTabItem());
        // keep the focus on the graph
        tabfolder.setSelected(idx);
        return true;
    } catch (Throwable e) {
        boolean ok = false;
        if (isURL) {
            // Retry to show the welcome page in an external browser.
            // 
            Status status = Launch.openURL(urlString);
            ok = status.equals(Status.Success);
        }
        if (!ok) {
            // Log an error
            // 
            log.logError("Unable to open browser tab", e);
            return false;
        } else {
            return true;
        }
    }
}
Also used : Status(org.pentaho.ui.util.Launch.Status) KettleException(org.pentaho.di.core.exception.KettleException) CTabFolder(org.eclipse.swt.custom.CTabFolder) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) PropsUI(org.pentaho.di.ui.core.PropsUI) TabItem(org.pentaho.xul.swt.tab.TabItem) BrowserFunction(org.eclipse.swt.browser.BrowserFunction) SpoonBrowser(org.pentaho.di.ui.spoon.SpoonBrowser) TabSet(org.pentaho.xul.swt.tab.TabSet) WindowEvent(org.eclipse.swt.browser.WindowEvent) OpenWindowListener(org.eclipse.swt.browser.OpenWindowListener)

Example 28 with PropsUI

use of org.pentaho.di.ui.core.PropsUI in project pentaho-kettle by pentaho.

the class PaloCellInputDialog method showPaloLibWarningDialog.

public static void showPaloLibWarningDialog(Shell shell) {
    PropsUI props = PropsUI.getInstance();
    if ("Y".equalsIgnoreCase(props.getCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, "Y"))) {
        MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogTitle"), null, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option1") }, 0, BaseMessages.getString(PKG, "PaloCellInputDialog.PaloLibWarningDialog.Option2"), "N".equalsIgnoreCase(props.getCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, "Y")));
        MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
        md.open();
        props.setCustomParameter(STRING_PALO_LIB_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
        props.saveProps();
    }
}
Also used : MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) PropsUI(org.pentaho.di.ui.core.PropsUI)

Aggregations

PropsUI (org.pentaho.di.ui.core.PropsUI)28 Label (org.eclipse.swt.widgets.Label)9 FormLayout (org.eclipse.swt.layout.FormLayout)6 Composite (org.eclipse.swt.widgets.Composite)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)5 FormData (org.eclipse.swt.layout.FormData)5 Text (org.eclipse.swt.widgets.Text)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 Button (org.eclipse.swt.widgets.Button)4 KettleException (org.pentaho.di.core.exception.KettleException)4 Field (java.lang.reflect.Field)3 Group (org.eclipse.swt.widgets.Group)3 Monitor (org.eclipse.swt.widgets.Monitor)3 BeforeClass (org.junit.BeforeClass)3 TabMapEntry (org.pentaho.di.ui.spoon.TabMapEntry)3 TabItem (org.pentaho.xul.swt.tab.TabItem)3 WindowEvent (org.eclipse.swt.browser.WindowEvent)2