Search in sources :

Example 46 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-platform by pentaho.

the class MantleXul method xulLoaded.

/**
 * Callback method for the MantleXulLoader. This is called when the Xul file has been processed.
 *
 * @param runner
 *          GwtXulRunner instance ready for event handlers and initializing.
 */
public void xulLoaded(GwtXulRunner runner) {
    // handlers need to be wrapped generically in GWT, create one and pass it our reference.
    // instantiate our Model and Controller
    controller = new MantleController(new MantleModel(this));
    // Add handler to container
    container = (GwtXulDomContainer) runner.getXulDomContainers().get(0);
    container.addEventHandler(controller);
    try {
        runner.initialize();
    } catch (XulException e) {
        // $NON-NLS-1$
        Window.alert("Error initializing XUL runner: " + e.getMessage());
        e.printStackTrace();
        return;
    }
    // Get the toolbar from the XUL doc
    // $NON-NLS-1$
    Widget bar = (Widget) container.getDocumentRoot().getElementById("mainToolbarWrapper").getManagedObject();
    // $NON-NLS-1$
    Widget xultoolbar = (Widget) container.getDocumentRoot().getElementById("mainToolbar").getManagedObject();
    xultoolbar.getElement().removeClassName("toolbar");
    toolbar.setStylePrimaryName("mainToolbar-Wrapper");
    toolbar.setWidget(bar);
    // Get the menubar from the XUL doc
    // $NON-NLS-1$
    Widget menu = (Widget) container.getDocumentRoot().getElementById("mainMenubar").getManagedObject();
    menubar.setWidget(menu);
    // check based on user permissions
    final String moduleBaseURL = GWT.getModuleBaseURL();
    final String moduleName = GWT.getModuleName();
    final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
    // $NON-NLS-1$
    final String url = contextURL + "api/repo/files/canCreate";
    RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    executableTypesRequestBuilder.setHeader("accept", "text/plain");
    executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
            // showError(exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    Boolean visible = new Boolean(response.getText());
                    controller.setMenuBarEnabled("newmenu", visible);
                    controller.setToolBarButtonEnabled("newButton", visible);
                }
            }
        });
    } catch (RequestException e) {
    // showError(e);
    }
    // get the admin perspective from the XUL doc
    // $NON-NLS-1$
    Widget admin = (Widget) container.getDocumentRoot().getElementById("adminPerspective").getManagedObject();
    admin.setStyleName("admin-perspective");
    admin.getElement().getStyle().clearHeight();
    admin.getElement().getStyle().clearWidth();
    adminPerspective.setWidget(admin);
    Panel adminContentPanel = (Panel) container.getDocumentRoot().getElementById("adminContentPanel").getManagedObject();
    adminContentPanel.add(adminContentDeck);
    adminContentDeck.setHeight("100%");
    adminContentDeck.getElement().getStyle().setProperty("height", "100%");
    fetchPluginOverlays();
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) Widget(com.google.gwt.user.client.ui.Widget) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) Panel(com.google.gwt.user.client.ui.Panel) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) DeckPanel(com.google.gwt.user.client.ui.DeckPanel) XulException(org.pentaho.ui.xul.XulException) RequestCallback(com.google.gwt.http.client.RequestCallback)

Example 47 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-platform by pentaho.

the class MantleXul method removeOverlay.

public void removeOverlay(final String id) {
    if (container != null) {
        try {
            container.removeOverlay(id);
        } catch (XulException e) {
        // ignored
        }
    } else {
        Timer t = new Timer() {

            public void run() {
                try {
                    if (container != null) {
                        cancel();
                        container.removeOverlay(id);
                    }
                } catch (XulException e) {
                // ignored
                }
            }
        };
        t.scheduleRepeating(250);
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) Timer(com.google.gwt.user.client.Timer)

Example 48 with XulException

use of org.pentaho.ui.xul.XulException in project pentaho-platform by pentaho.

the class MantleXul method applyOverlay.

public void applyOverlay(final String id) {
    if (container != null) {
        try {
            container.loadOverlay(id);
        } catch (XulException e) {
        // ignored
        }
    } else {
        Timer t = new Timer() {

            public void run() {
                try {
                    if (container != null) {
                        cancel();
                        container.loadOverlay(id);
                    }
                } catch (XulException e) {
                // ignored
                }
            }
        };
        t.scheduleRepeating(250);
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) Timer(com.google.gwt.user.client.Timer)

Example 49 with XulException

use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRemapConfirmationDialog method open.

void open() throws KettleException {
    Document xulDocument;
    try {
        xulDocument = initXul(parent, new KettleXulLoader(), new SwtXulRunner());
    } catch (XulException e) {
        throw new KettleException("Failed to create data service remap confirmation dialog", e);
    }
    ((SwtDialog) xulDocument.getElementById(XUL_DIALOG_ID)).show();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) Document(org.pentaho.ui.xul.dom.Document) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 50 with XulException

use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceTestDialog method initXul.

private Document initXul(Composite parent) throws KettleException {
    try {
        SwtXulLoader swtLoader = new KettleXulLoader();
        swtLoader.setOuterContext(parent);
        swtLoader.registerClassLoader(getClass().getClassLoader());
        XulDomContainer container = swtLoader.loadXul(XUL_PATH, resourceBundle);
        container.addEventHandler(dataServiceTestController);
        final XulRunner runner = new SwtXulRunner();
        runner.addContainer(container);
        runner.initialize();
        return container.getDocumentRoot();
    } catch (XulException xulException) {
        throw new KettleException("Failed to initialize DataServicesTestDialog.", xulException);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) SwtXulLoader(org.pentaho.ui.xul.swt.SwtXulLoader) 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)

Aggregations

XulException (org.pentaho.ui.xul.XulException)60 KettleException (org.pentaho.di.core.exception.KettleException)20 Test (org.junit.Test)11 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)10 XulComponent (org.pentaho.ui.xul.XulComponent)9 Shell (org.eclipse.swt.widgets.Shell)7 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)7 SwtXulRunner (org.pentaho.ui.xul.swt.SwtXulRunner)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)6 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)6 XulRunner (org.pentaho.ui.xul.XulRunner)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Document (org.pentaho.ui.xul.dom.Document)4 ResourceBundle (java.util.ResourceBundle)3 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 SwtBindingFactory (org.pentaho.ui.xul.swt.SwtBindingFactory)3