Search in sources :

Example 1 with SolutionBrowserOpenEvent

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

the class MantleTabPanel method registerContentOverlay.

/*
   * registerContentOverlay - register the overlay with the panel. Once the registration is done it fires a soultion
   * browser event passing the current tab index and the type of event
   */
public void registerContentOverlay(String id) {
    IFrameTabPanel panel = getCurrentFrame();
    if (panel != null) {
        panel.addOverlay(id);
        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));
    }
}
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) SolutionBrowserOpenEvent(org.pentaho.mantle.client.events.SolutionBrowserOpenEvent)

Example 2 with SolutionBrowserOpenEvent

use of org.pentaho.mantle.client.events.SolutionBrowserOpenEvent 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)2 SolutionBrowserOpenEvent (org.pentaho.mantle.client.events.SolutionBrowserOpenEvent)2 FileItem (org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)2 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)2 Element (com.google.gwt.user.client.Element)1 Timer (com.google.gwt.user.client.Timer)1 ArrayList (java.util.ArrayList)1 SolutionBrowserSelectEvent (org.pentaho.mantle.client.events.SolutionBrowserSelectEvent)1