Search in sources :

Example 1 with Bindable

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

the class MantleController method init.

/**
 * Called when the Xul Dom is ready, grab all Xul references here.
 */
@Bindable
public void init() {
    // $NON-NLS-1$
    openBtn = (XulToolbarbutton) document.getElementById("openButton");
    // $NON-NLS-1$
    newBtn = (XulToolbarbutton) document.getElementById("newButton");
    // $NON-NLS-1$
    saveBtn = (XulToolbarbutton) document.getElementById("saveButton");
    // $NON-NLS-1$
    saveAsBtn = (XulToolbarbutton) document.getElementById("saveAsButton");
    printBtn = (XulToolbarbutton) document.getElementById("printButton");
    // $NON-NLS-1$
    contentEditBtn = (XulToolbarbutton) document.getElementById("editContentButton");
    bf = new GwtBindingFactory(document);
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(model, "saveEnabled", saveBtn, "visible");
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(model, "saveAsEnabled", saveAsBtn, "visible");
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(model, "contentEditEnabled", contentEditBtn, "visible");
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(model, "contentEditSelected", this, "editContentSelected");
    bf.createBinding(model, "printVisible", printBtn, "visible");
    // $NON-NLS-1$
    saveMenuItem = (XulMenuitem) document.getElementById("saveMenuItem");
    // $NON-NLS-1$
    saveAsMenuItem = (XulMenuitem) document.getElementById("saveAsMenuItem");
    // $NON-NLS-1$
    useDescriptionsMenuItem = (XulMenuitem) document.getElementById("useDescriptionsMenuItem");
    // $NON-NLS-1$
    showHiddenFilesMenuItem = (XulMenuitem) document.getElementById("showHiddenFilesMenuItem");
    // $NON-NLS-1$
    languageMenu = (XulMenubar) document.getElementById("languagemenu");
    // $NON-NLS-1$
    themesMenu = (XulMenubar) document.getElementById("themesmenu");
    // $NON-NLS-1$
    toolsMenu = (XulMenubar) document.getElementById("toolsmenu");
    // $NON-NLS-1$
    recentMenu = (XulMenubar) document.getElementById("recentmenu");
    // $NON-NLS-1$
    favoriteMenu = (XulMenubar) document.getElementById("favoritesmenu");
    if (PerspectiveManager.getInstance().isLoaded()) {
        PerspectiveManager.getInstance().enablePerspective(PerspectiveManager.OPENED_PERSPECTIVE, false);
    } else {
        EventBusUtil.EVENT_BUS.addHandler(PerspectivesLoadedEvent.TYPE, new PerspectivesLoadedEventHandler() {

            public void onPerspectivesLoaded(PerspectivesLoadedEvent event) {
                PerspectiveManager.getInstance().enablePerspective(PerspectiveManager.OPENED_PERSPECTIVE, false);
            }
        });
    }
    // install language sub-menus
    Map<String, String> supportedLanguages = Messages.getResourceBundle().getSupportedLanguages();
    if (supportedLanguages != null && supportedLanguages.keySet() != null && !supportedLanguages.isEmpty()) {
        MenuBar langMenu = (MenuBar) languageMenu.getManagedObject();
        langMenu.insertSeparator(0);
        for (String lang : supportedLanguages.keySet()) {
            MenuItem langMenuItem = new MenuItem(supportedLanguages.get(lang), new SwitchLocaleCommand(lang));
            // $NON-NLS-1$
            langMenuItem.getElement().setId(supportedLanguages.get(lang) + "_menu_item");
            langMenu.insertItem(langMenuItem, 0);
        }
    }
    buildFavoritesAndRecent(false);
    UserSettingsManager.getInstance().getUserSettings(new AsyncCallback<JsArray<JsSetting>>() {

        public void onSuccess(JsArray<JsSetting> settings) {
            processSettings(settings);
        }

        public void onFailure(Throwable caught) {
        }
    }, false);
    EventBusUtil.EVENT_BUS.addHandler(UserSettingsLoadedEvent.TYPE, new UserSettingsLoadedEventHandler() {

        public void onUserSettingsLoaded(UserSettingsLoadedEvent event) {
            processSettings(event.getSettings());
        }
    });
    // install themes
    RequestBuilder getActiveThemeRequestBuilder = // $NON-NLS-1$
    new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/theme/active");
    try {
        getActiveThemeRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
        getActiveThemeRequestBuilder.sendRequest(null, new RequestCallback() {

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

            public void onResponseReceived(Request request, Response response) {
                final String activeTheme = response.getText();
                RequestBuilder getThemesRequestBuilder = // $NON-NLS-1$
                new RequestBuilder(RequestBuilder.GET, GWT.getHostPageBaseURL() + "api/theme/list");
                getThemesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                // $NON-NLS-1$ //$NON-NLS-2$
                getThemesRequestBuilder.setHeader("accept", "application/json");
                try {
                    getThemesRequestBuilder.sendRequest(null, new RequestCallback() {

                        public void onError(Request arg0, Throwable arg1) {
                        }

                        public void onResponseReceived(Request request, Response response) {
                            try {
                                // $NON-NLS-1$
                                final String url = GWT.getHostPageBaseURL() + "api/repo/files/canAdminister";
                                RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
                                requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                                // $NON-NLS-1$ //$NON-NLS-2$
                                requestBuilder.setHeader("accept", "text/plain");
                                requestBuilder.sendRequest(null, new RequestCallback() {

                                    public void onError(Request request, Throwable caught) {
                                    }

                                    public void onResponseReceived(Request request, Response response) {
                                        // $NON-NLS-1$
                                        toolsMenu.setVisible("true".equalsIgnoreCase(response.getText()));
                                        // $NON-NLS-1$
                                        showHiddenFilesMenuItem.setVisible("true".equalsIgnoreCase(response.getText()));
                                    }
                                });
                            } catch (RequestException e) {
                                Window.alert(e.getMessage());
                            }
                            JsArray<JsTheme> themes = JsTheme.getThemes(JsonUtils.escapeJsonForEval(response.getText()));
                            for (int i = 0; i < themes.length(); i++) {
                                JsTheme theme = themes.get(i);
                                PentahoMenuItem themeMenuItem = new PentahoMenuItem(theme.getName(), new SwitchThemeCommand(theme.getId()));
                                // $NON-NLS-1$
                                themeMenuItem.getElement().setId(theme.getId() + "_menu_item");
                                themeMenuItem.setChecked(theme.getId().equals(activeTheme));
                                ((MenuBar) themesMenu.getManagedObject()).addItem(themeMenuItem);
                            }
                            // $NON-NLS-1$ //$NON-NLS-2$
                            bf.createBinding(model, "saveEnabled", saveMenuItem, "!disabled");
                            // $NON-NLS-1$ //$NON-NLS-2$
                            bf.createBinding(model, "saveAsEnabled", saveAsMenuItem, "!disabled");
                            if (PerspectiveManager.getInstance().isLoaded()) {
                                executeAdminContent();
                            } else {
                                EventBusUtil.EVENT_BUS.addHandler(PerspectivesLoadedEvent.TYPE, new PerspectivesLoadedEventHandler() {

                                    public void onPerspectivesLoaded(PerspectivesLoadedEvent event) {
                                        executeAdminContent();
                                    }
                                });
                            }
                            setupNativeHooks(MantleController.this);
                        }
                    });
                } catch (RequestException e) {
                // showError(e);
                }
            }
        });
    } catch (RequestException e) {
        Window.alert(e.getMessage());
    // showError(e);
    }
}
Also used : PentahoMenuItem(org.pentaho.gwt.widgets.client.menuitem.PentahoMenuItem) RequestBuilder(com.google.gwt.http.client.RequestBuilder) UserSettingsLoadedEvent(org.pentaho.mantle.client.events.UserSettingsLoadedEvent) MenuBar(com.google.gwt.user.client.ui.MenuBar) RequestException(com.google.gwt.http.client.RequestException) SwitchLocaleCommand(org.pentaho.mantle.client.commands.SwitchLocaleCommand) UserSettingsLoadedEventHandler(org.pentaho.mantle.client.events.UserSettingsLoadedEventHandler) JsSetting(org.pentaho.mantle.client.usersettings.JsSetting) JsArray(com.google.gwt.core.client.JsArray) PerspectivesLoadedEventHandler(org.pentaho.mantle.client.events.PerspectivesLoadedEventHandler) Request(com.google.gwt.http.client.Request) MenuItem(com.google.gwt.user.client.ui.MenuItem) PentahoMenuItem(org.pentaho.gwt.widgets.client.menuitem.PentahoMenuItem) Response(com.google.gwt.http.client.Response) SwitchThemeCommand(org.pentaho.mantle.client.commands.SwitchThemeCommand) PerspectivesLoadedEvent(org.pentaho.mantle.client.events.PerspectivesLoadedEvent) RequestCallback(com.google.gwt.http.client.RequestCallback) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 2 with Bindable

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

the class MantleModel method executeSaveAsCommand.

@Bindable
public void executeSaveAsCommand() {
    SaveCommand saveAsCommand = new SaveCommand(true);
    saveAsCommand.execute();
}
Also used : SaveCommand(org.pentaho.mantle.client.commands.SaveCommand) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 3 with Bindable

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

the class MantleModel method openDocumentation.

@Bindable
public void openDocumentation() {
    OpenDocCommand cmd = new OpenDocCommand();
    cmd.execute();
}
Also used : OpenDocCommand(org.pentaho.mantle.client.commands.OpenDocCommand) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 4 with Bindable

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

the class MantleModel method refreshContent.

@Bindable
public void refreshContent() {
    if (PerspectiveManager.SCHEDULES_PERSPECTIVE.equals(PerspectiveManager.getInstance().getActivePerspective().getId())) {
        Command cmd = new RefreshSchedulesCommand();
        cmd.execute();
    } else {
        Command cmd = new RefreshRepositoryCommand();
        cmd.execute();
    }
}
Also used : RefreshSchedulesCommand(org.pentaho.mantle.client.commands.RefreshSchedulesCommand) RefreshRepositoryCommand(org.pentaho.mantle.client.commands.RefreshRepositoryCommand) OpenKettleStatusCommand(org.pentaho.mantle.client.commands.OpenKettleStatusCommand) FilePropertiesCommand(org.pentaho.mantle.client.commands.FilePropertiesCommand) OpenFileCommand(org.pentaho.mantle.client.commands.OpenFileCommand) NewDropdownCommand(org.pentaho.mantle.client.commands.NewDropdownCommand) Command(com.google.gwt.user.client.Command) PrintCommand(org.pentaho.mantle.client.commands.PrintCommand) OpenDocCommand(org.pentaho.mantle.client.commands.OpenDocCommand) RefreshSchedulesCommand(org.pentaho.mantle.client.commands.RefreshSchedulesCommand) RefreshRepositoryCommand(org.pentaho.mantle.client.commands.RefreshRepositoryCommand) SaveCommand(org.pentaho.mantle.client.commands.SaveCommand) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 5 with Bindable

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

the class MantleModel method executePropertiesCommand.

@Bindable
public void executePropertiesCommand() {
    FilePropertiesCommand propertiesCommand = new FilePropertiesCommand(selectedFileItem.getRepositoryFile());
    propertiesCommand.execute();
}
Also used : FilePropertiesCommand(org.pentaho.mantle.client.commands.FilePropertiesCommand) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Aggregations

Bindable (org.pentaho.ui.xul.stereotype.Bindable)71 Request (com.google.gwt.http.client.Request)15 RequestBuilder (com.google.gwt.http.client.RequestBuilder)15 RequestCallback (com.google.gwt.http.client.RequestCallback)15 RequestException (com.google.gwt.http.client.RequestException)15 Response (com.google.gwt.http.client.Response)15 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)15 ArrayList (java.util.ArrayList)10 List (java.util.List)7 OpenFileCommand (org.pentaho.mantle.client.commands.OpenFileCommand)5 IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)5 XulHbox (org.pentaho.ui.xul.containers.XulHbox)4 SaveCommand (org.pentaho.mantle.client.commands.SaveCommand)3 XulComponent (org.pentaho.ui.xul.XulComponent)3 XulException (org.pentaho.ui.xul.XulException)3 XulLabel (org.pentaho.ui.xul.components.XulLabel)3 IDatabaseType (org.pentaho.database.model.IDatabaseType)2 DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)2 FilePropertiesCommand (org.pentaho.mantle.client.commands.FilePropertiesCommand)2 NewDropdownCommand (org.pentaho.mantle.client.commands.NewDropdownCommand)2