Search in sources :

Example 6 with IFrameTabPanel

use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.

the class MantleTabPanel method closeTab.

public void closeTab(final PentahoTab closeTab, final boolean invokePreTabCloseHook) {
    if (closeTab.getContent() instanceof IFrameTabPanel) {
        final Element frameElement = ((IFrameTabPanel) closeTab.getContent()).getFrame().getElement();
        String frameId = frameElement.getAttribute("id").replaceAll("\"", "\\\"");
        // #a"b1494409287116 need to be escaped to #a\"b1494409287116.
        if (frameId.indexOf("\"") != -1) {
            frameId = frameId.replaceAll("\"", "");
            frameElement.setAttribute("id", frameId);
        }
        final String finalFrameId = frameId;
        if (invokePreTabCloseHook && hasUnsavedChanges(frameElement)) {
            // prompt user
            VerticalPanel vp = new VerticalPanel();
            // $NON-NLS-1$
            vp.add(new Label(Messages.getString("confirmTabClose")));
            final PromptDialogBox confirmDialog = new PromptDialogBox(Messages.getString("confirm"), Messages.getString("yes"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            vp);
            confirmDialog.setCallback(new IDialogCallback() {

                public void cancelPressed() {
                }

                public void okPressed() {
                    fireCloseTab(finalFrameId);
                    ((CustomFrame) ((IFrameTabPanel) closeTab.getContent()).getFrame()).removeEventListeners(frameElement);
                    clearClosingFrame(frameElement);
                    MantleTabPanel.super.closeTab(closeTab, invokePreTabCloseHook);
                    if (getTabCount() == 0) {
                        allTabsClosed();
                        Widget selectTabContent = null;
                        if (getTab(getSelectedTabIndex()) != null) {
                            selectTabContent = getTab(getSelectedTabIndex()).getContent();
                        }
                        List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
                        EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserCloseEvent(selectTabContent, selectedItems));
                    }
                }
            });
            confirmDialog.center();
            return;
        }
        fireCloseTab(finalFrameId);
        ((CustomFrame) ((IFrameTabPanel) closeTab.getContent()).getFrame()).removeEventListeners(frameElement);
        clearClosingFrame(frameElement);
    }
    super.closeTab(closeTab, invokePreTabCloseHook);
    // since we can't entirely reclaim the frame resources held, keep some around
    // so we can minimize the extra leakage caused by constantly created more
    // let's only keep 5 of these guys around so at least some of the resources
    // can be cleaned up (maybe just wishful thinking)
    Widget w = closeTab.getContent();
    if (w instanceof IFrameTabPanel && freeFrames.size() < 5) {
        // wipe out any file info so it doesn't impact future usages of this frame
        SolutionFileInfo sfi = null;
        IFrameTabPanel iFrameTabPanel = (IFrameTabPanel) w;
        iFrameTabPanel.setFileInfo(sfi);
        freeFrames.add(iFrameTabPanel);
    }
    if (getTabCount() == 0) {
        allTabsClosed();
        Widget selectTabContent = null;
        if (getTab(getSelectedTabIndex()) != null) {
            selectTabContent = getTab(getSelectedTabIndex()).getContent();
        }
        List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
        EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserCloseEvent(selectTabContent, selectedItems));
    }
}
Also used : PromptDialogBox(org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox) Element(com.google.gwt.user.client.Element) Label(com.google.gwt.user.client.ui.Label) Widget(com.google.gwt.user.client.ui.Widget) SolutionFileInfo(org.pentaho.mantle.client.objects.SolutionFileInfo) CustomFrame(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel.CustomFrame) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback) FileItem(org.pentaho.mantle.client.solutionbrowser.filelist.FileItem) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) SolutionBrowserCloseEvent(org.pentaho.mantle.client.events.SolutionBrowserCloseEvent) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) ArrayList(java.util.ArrayList) NodeList(com.google.gwt.dom.client.NodeList) List(java.util.List)

Example 7 with IFrameTabPanel

use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.

the class MantleTabPanel method enableContentEdit.

public void enableContentEdit(boolean enable) {
    IFrameTabPanel panel = getCurrentFrame();
    if (panel != null) {
        panel.setEditEnabled(enable);
        Widget selectTabContent = null;
        if (getTab(getSelectedTabIndex()) != null) {
            selectTabContent = getTab(getSelectedTabIndex()).getContent();
        }
        List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
        EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserUndefinedEvent(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) SolutionBrowserUndefinedEvent(org.pentaho.mantle.client.events.SolutionBrowserUndefinedEvent)

Example 8 with IFrameTabPanel

use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.

the class MantleTabPanel method closeTab.

/**
 * Called by JSNI call from parameterized xaction prompt pages to "cancel". The only 'key' to pass up is the URL. To
 * handle the possibility of multiple tabs with the same url, this method first checks the assumption that the current
 * active tab initiates the call. Otherwise it checks from tail up for the first tab with a matching url and closes
 * that one. *
 *
 * @param url
 */
private void closeTab(String url) {
    int curpos = getSelectedTabIndex();
    if (StringUtils.isEmpty(url)) {
        // and then remove
        if (curpos >= 0 && getTabCount() > 0) {
            closeTab(curpos, true);
        }
    }
    PentahoTab pt = getTab(curpos);
    if (pt != null && pt.getContent() != null) {
        IFrameTabPanel curPanel = (IFrameTabPanel) getTab(curpos).getContent();
        if (url.contains(curPanel.getUrl())) {
            closeTab(curpos, true);
        }
        for (int i = getTabCount() - 1; i >= 0; i--) {
            curPanel = (IFrameTabPanel) getTab(i).getContent();
            if (url.contains(curPanel.getUrl())) {
                closeTab(i, true);
                break;
            }
        }
    }
    if (getTabCount() == 0) {
        allTabsClosed();
    }
}
Also used : PentahoTab(org.pentaho.gwt.widgets.client.tabs.PentahoTab) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)

Example 9 with IFrameTabPanel

use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.

the class MantleModel method handleSolutionBrowserEvent.

private void handleSolutionBrowserEvent(Widget panel, FileItem selectedFileItem) {
    this.selectedFileItem = selectedFileItem;
    setPropertiesEnabled(selectedFileItem != null && selectedFileItem.getRepositoryFile() != null);
    setSaveEnabled(selectedFileItem != null && selectedFileItem.getRepositoryFile() != null);
    setSaveAsEnabled(selectedFileItem != null && selectedFileItem.getRepositoryFile() != null);
    boolean saveEnabled = false;
    boolean editIsEnabled = false;
    boolean editSelected = false;
    boolean printVisible = false;
    JavaScriptObject callback = null;
    if (panel != null && panel instanceof IFrameTabPanel) {
        IFrameTabPanel tbp = (IFrameTabPanel) panel;
        saveEnabled = tbp.isSaveEnabled();
        editIsEnabled = tbp.isEditEnabled();
        editSelected = tbp.isEditSelected();
        printVisible = tbp.isPrintVisible();
    }
    setSaveEnabled(saveEnabled);
    setSaveAsEnabled(saveEnabled);
    setContentEditEnabled(editIsEnabled);
    setContentEditSelected(editSelected);
    setPrintVisible(printVisible);
    setCallback(callback);
    this.showNavigatorSelected = SolutionBrowserPanel.getInstance().isNavigatorShowing();
    setShowBrowserSelected(this.showNavigatorSelected);
}
Also used : JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)

Example 10 with IFrameTabPanel

use of org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel in project pentaho-platform by pentaho.

the class MantleTab method openTabInNewWindow.

public void openTabInNewWindow() {
    if (getContent() instanceof IFrameTabPanel) {
        VerticalPanel vp = new VerticalPanel();
        // $NON-NLS-1$
        vp.add(new Label(Messages.getString("openWindowQuestion")));
        final MantleDialogBox openNewWindowConfirmDialog = new MantleDialogBox(Messages.getString("openWindowConfirm"), Messages.getString("yes"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        vp);
        final IDialogCallback callback = new IDialogCallback() {

            public void cancelPressed() {
                openNewWindowConfirmDialog.hide();
            }

            public void okPressed() {
                ((IFrameTabPanel) getContent()).openTabInNewWindow();
                openNewWindowConfirmDialog.hide();
            }
        };
        openNewWindowConfirmDialog.setCallback(callback);
        openNewWindowConfirmDialog.center();
    }
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) Label(com.google.gwt.user.client.ui.Label) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) IDialogCallback(org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)

Aggregations

IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)22 Widget (com.google.gwt.user.client.ui.Widget)9 FileItem (org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)7 Frame (com.google.gwt.user.client.ui.Frame)5 Element (com.google.gwt.user.client.Element)3 Label (com.google.gwt.user.client.ui.Label)3 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)3 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)3 PentahoTab (org.pentaho.gwt.widgets.client.tabs.PentahoTab)3 SolutionBrowserSelectEvent (org.pentaho.mantle.client.events.SolutionBrowserSelectEvent)3 JsArrayString (com.google.gwt.core.client.JsArrayString)2 ArrayList (java.util.ArrayList)2 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)2 SolutionBrowserOpenEvent (org.pentaho.mantle.client.events.SolutionBrowserOpenEvent)2 SolutionBrowserUndefinedEvent (org.pentaho.mantle.client.events.SolutionBrowserUndefinedEvent)2 SolutionFileInfo (org.pentaho.mantle.client.objects.SolutionFileInfo)2 ContentTypePlugin (org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 Node (com.google.gwt.dom.client.Node)1 NodeList (com.google.gwt.dom.client.NodeList)1