Search in sources :

Example 1 with SolutionBrowserSelectEvent

use of org.pentaho.mantle.client.events.SolutionBrowserSelectEvent in project pentaho-platform by pentaho.

the class MantleTabPanel method selectTab.

public void selectTab(final PentahoTab selectedTab) {
    // Save previous tab's solution browser panel navigator state
    PentahoTab prevTab = getSelectedTab();
    if (prevTab != null && prevTab instanceof MantleTab) {
        MantleTab mantlePrevTab = (MantleTab) prevTab;
        boolean prevState = SolutionBrowserPanel.getInstance().isNavigatorShowing();
        if (mantlePrevTab != null) {
            mantlePrevTab.setSolutionBrowserShowing(prevState);
        }
    }
    super.selectTab(selectedTab);
    if (selectedTab == null) {
        return;
    }
    if (selectedTab instanceof MantleTab) {
        // restore previous state of solution browser panel navigator
        MantleTab mantleTab = (MantleTab) selectedTab;
        SolutionBrowserPanel.getInstance().setNavigatorShowing(mantleTab.isSolutionBrowserShowing());
    }
    Widget selectTabContent = null;
    if (getTab(getSelectedTabIndex()) != null) {
        selectTabContent = getTab(getSelectedTabIndex()).getContent();
    }
    List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
    EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserSelectEvent(selectTabContent, selectedItems));
    // $NON-NLS-1$ //$NON-NLS-2$
    Window.setTitle(Messages.getString("productName") + " - " + selectedTab.getLabelText());
    // first turn off all tabs that should be
    for (int i = 0; i < getTabCount(); i++) {
        final PentahoTab tab = getTab(i);
        if (tab.getContent() instanceof IFrameTabPanel) {
            if (tab.getContent() != selectedTab.getContent()) {
                FrameUtils.setEmbedVisibility(((IFrameTabPanel) tab.getContent()).getFrame(), false);
            }
        }
    }
    // now turn on the select tab
    if (selectedTab.getContent() instanceof IFrameTabPanel) {
        FrameUtils.setEmbedVisibility(((IFrameTabPanel) selectedTab.getContent()).getFrame(), true);
        // fix for BISERVER-6027 - on selection, set the focus into a textbox
        // element to allow IE mouse access in these elements
        // this was made native due to BISERVER-7400
        ieFix(((IFrameTabPanel) selectedTab.getContent()).getFrame().getElement());
        IFrameTabPanel tabPanel = (IFrameTabPanel) selectedTab.getContent();
        if (tabPanel.getUrl() != null) {
            onTabSelect(getFrameElement(selectedTab));
        }
    }
}
Also used : FileItem(org.pentaho.mantle.client.solutionbrowser.filelist.FileItem) PentahoTab(org.pentaho.gwt.widgets.client.tabs.PentahoTab) Widget(com.google.gwt.user.client.ui.Widget) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) SolutionBrowserSelectEvent(org.pentaho.mantle.client.events.SolutionBrowserSelectEvent)

Example 2 with SolutionBrowserSelectEvent

use of org.pentaho.mantle.client.events.SolutionBrowserSelectEvent in project pentaho-platform by pentaho.

the class MantleTabPanel method setTabSaveEnabled.

public void setTabSaveEnabled(PentahoTab tab, boolean enabled) {
    IFrameTabPanel panel = null;
    if (tab != null) {
        panel = getFrame(tab);
    }
    if (panel != null) {
        panel.setSaveEnabled(enabled);
        Widget selectTabContent = null;
        if (getTab(getSelectedTabIndex()) != null) {
            selectTabContent = getTab(getSelectedTabIndex()).getContent();
        }
        List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
        EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserSelectEvent(selectTabContent, selectedItems));
    }
}
Also used : FileItem(org.pentaho.mantle.client.solutionbrowser.filelist.FileItem) Widget(com.google.gwt.user.client.ui.Widget) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) SolutionBrowserSelectEvent(org.pentaho.mantle.client.events.SolutionBrowserSelectEvent)

Example 3 with SolutionBrowserSelectEvent

use of org.pentaho.mantle.client.events.SolutionBrowserSelectEvent in project pentaho-platform by pentaho.

the class MantleTabPanel method showNewURLTab.

public void showNewURLTab(String tabName, String tabTooltip, String url, boolean setFileInfoInFrame, String frameName) {
    showLoadingIndicator();
    PerspectiveManager.getInstance().setPerspective(PerspectiveManager.OPENED_PERSPECTIVE);
    // than if set with the src attribute. This detects the relative paths are prepends them appropriately.
    if (url.indexOf("http") != 0 && url.indexOf("/") != 0) {
        url = GWT.getHostPageBaseURL() + url;
    }
    if (!url.contains("?")) {
        url = url + "?ts=" + System.currentTimeMillis();
    } else {
        url = url + "&ts=" + System.currentTimeMillis();
    }
    final int elementId = getTabCount();
    if (frameName == null || "".equals(frameName.trim())) {
        frameName = getUniqueFrameName();
    }
    // check for other tabs with this name
    if (existingTabMatchesName(tabName)) {
        int counter = 2;
        while (true) {
            // name
            if (existingTabMatchesName(tabName + " (" + counter + ")")) {
                // unique //$NON-NLS-1$ //$NON-NLS-2$
                counter++;
                continue;
            } else {
                // $NON-NLS-1$ //$NON-NLS-2$
                tabName = tabName + " (" + counter + ")";
                // $NON-NLS-1$ //$NON-NLS-2$
                tabTooltip = tabTooltip + " (" + counter + ")";
                break;
            }
        }
    }
    IFrameTabPanel panel = null;
    if (freeFrames.size() > 0) {
        panel = freeFrames.iterator().next();
        panel.setName(frameName);
        // mark as no longer free by removing from set
        freeFrames.remove(panel);
    } else {
        panel = new IFrameTabPanel(frameName);
    }
    addTab(tabName, tabTooltip, true, panel);
    selectTab(elementId);
    // wants to change or remove the color
    if (url.indexOf("/content") > -1 || url.indexOf("/generatedContent") > -1) {
        // white background
        panel.getElement().addClassName("mantle-white-tab-background");
    } else {
        // transparent background
        panel.getElement().addClassName("mantle-default-tab-background");
    }
    final ArrayList<com.google.gwt.dom.client.Element> parentList = new ArrayList<com.google.gwt.dom.client.Element>();
    com.google.gwt.dom.client.Element parent = panel.getFrame().getElement();
    while (parent != getElement()) {
        parentList.add(parent);
        parent = parent.getParentElement();
    }
    Collections.reverse(parentList);
    for (int i = 1; i < parentList.size(); i++) {
        // $NON-NLS-1$ //$NON-NLS-2$
        parentList.get(i).getStyle().setProperty("height", "100%");
    }
    Widget selectTabContent = null;
    if (getTab(getSelectedTabIndex()) != null) {
        selectTabContent = getTab(getSelectedTabIndex()).getContent();
    }
    List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
    EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserOpenEvent(selectTabContent, selectedItems));
    // if showContent is the thing that turns on our first tab, which is entirely possible, then we
    // would encounter the same timing issue as before
    panel.setUrl(url);
    EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserSelectEvent(selectTabContent, selectedItems));
    if (setFileInfoInFrame && SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems().size() > 0) {
        setFileInfoInFrame(SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems().get(0));
    }
    // create a timer to check the readyState
    Timer t = new Timer() {

        public void run() {
            Element frameElement = getFrameElement(getSelectedTab());
            if (supportsReadyFeedback(frameElement)) {
                // cancel the timer, the content will hide the loading indicator itself
                cancel();
            } else {
                if ("complete".equalsIgnoreCase(getReadyState(frameElement))) {
                    // the content is not capable of giving us feedback so when the
                    // readyState is "complete" we hide/cancel
                    hideLoadingIndicator();
                    cancel();
                } else if (StringUtils.isEmpty(getReadyState(frameElement)) || "undefined".equals(getReadyState(frameElement))) {
                    hideLoadingIndicator();
                    cancel();
                }
            }
        }
    };
    t.scheduleRepeating(1000);
}
Also used : Element(com.google.gwt.user.client.Element) ArrayList(java.util.ArrayList) Widget(com.google.gwt.user.client.ui.Widget) FileItem(org.pentaho.mantle.client.solutionbrowser.filelist.FileItem) Timer(com.google.gwt.user.client.Timer) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) SolutionBrowserOpenEvent(org.pentaho.mantle.client.events.SolutionBrowserOpenEvent) SolutionBrowserSelectEvent(org.pentaho.mantle.client.events.SolutionBrowserSelectEvent)

Aggregations

Widget (com.google.gwt.user.client.ui.Widget)3 SolutionBrowserSelectEvent (org.pentaho.mantle.client.events.SolutionBrowserSelectEvent)3 FileItem (org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)3 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)3 Element (com.google.gwt.user.client.Element)1 Timer (com.google.gwt.user.client.Timer)1 ArrayList (java.util.ArrayList)1 PentahoTab (org.pentaho.gwt.widgets.client.tabs.PentahoTab)1 SolutionBrowserOpenEvent (org.pentaho.mantle.client.events.SolutionBrowserOpenEvent)1