Search in sources :

Example 1 with Status

use of org.pentaho.ui.util.Launch.Status in project pentaho-kettle by pentaho.

the class DataHandler method getOptionHelp.

public void getOptionHelp() {
    String message = null;
    DatabaseMeta database = new DatabaseMeta();
    getInfo(database);
    String url = database.getExtraOptionsHelpText();
    if ((url == null) || (url.trim().length() == 0)) {
        message = Messages.getString("DataHandler.USER_NO_HELP_AVAILABLE");
        showMessage(message, false);
        return;
    }
    Status status = Launch.openURL(url);
    if (status.equals(Status.Failed)) {
        message = Messages.getString("DataHandler.USER_UNABLE_TO_LAUNCH_BROWSER", url);
        showMessage(message, false);
    }
}
Also used : Status(org.pentaho.ui.util.Launch.Status) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) MSSQLServerNativeDatabaseMeta(org.pentaho.di.core.database.MSSQLServerNativeDatabaseMeta) PartitionDatabaseMeta(org.pentaho.di.core.database.PartitionDatabaseMeta) GenericDatabaseMeta(org.pentaho.di.core.database.GenericDatabaseMeta) OracleDatabaseMeta(org.pentaho.di.core.database.OracleDatabaseMeta) BaseDatabaseMeta(org.pentaho.di.core.database.BaseDatabaseMeta)

Example 2 with Status

use of org.pentaho.ui.util.Launch.Status 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)

Aggregations

Status (org.pentaho.ui.util.Launch.Status)2 BrowserFunction (org.eclipse.swt.browser.BrowserFunction)1 OpenWindowListener (org.eclipse.swt.browser.OpenWindowListener)1 WindowEvent (org.eclipse.swt.browser.WindowEvent)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 BaseDatabaseMeta (org.pentaho.di.core.database.BaseDatabaseMeta)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 GenericDatabaseMeta (org.pentaho.di.core.database.GenericDatabaseMeta)1 MSSQLServerNativeDatabaseMeta (org.pentaho.di.core.database.MSSQLServerNativeDatabaseMeta)1 OracleDatabaseMeta (org.pentaho.di.core.database.OracleDatabaseMeta)1 PartitionDatabaseMeta (org.pentaho.di.core.database.PartitionDatabaseMeta)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1 PropsUI (org.pentaho.di.ui.core.PropsUI)1 SpoonBrowser (org.pentaho.di.ui.spoon.SpoonBrowser)1 TabMapEntry (org.pentaho.di.ui.spoon.TabMapEntry)1 TabItem (org.pentaho.xul.swt.tab.TabItem)1 TabSet (org.pentaho.xul.swt.tab.TabSet)1