Search in sources :

Example 1 with SolutionFileInfo

use of org.pentaho.mantle.client.objects.SolutionFileInfo in project pentaho-platform by pentaho.

the class MantleTabPanel method setFileInfoInFrame.

/**
 * Store representation of file in the frame for reference later when save is called
 *
 * @param selectedFileItem
 */
public void setFileInfoInFrame(FileItem selectedFileItem) {
    IFrameTabPanel tp = getCurrentFrame();
    if (tp != null && selectedFileItem != null) {
        SolutionFileInfo fileInfo = new SolutionFileInfo();
        fileInfo.setName(selectedFileItem.getName());
        fileInfo.setPath(selectedFileItem.getPath());
        tp.setFileInfo(fileInfo);
    }
}
Also used : SolutionFileInfo(org.pentaho.mantle.client.objects.SolutionFileInfo) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)

Example 2 with SolutionFileInfo

use of org.pentaho.mantle.client.objects.SolutionFileInfo 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 3 with SolutionFileInfo

use of org.pentaho.mantle.client.objects.SolutionFileInfo in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method openFile.

public void openFile(final RepositoryFile repositoryFile, final FileCommand.COMMAND mode) {
    String fileNameWithPath = repositoryFile.getPath();
    if (mode == FileCommand.COMMAND.EDIT) {
        PerspectiveManager.getInstance().setPerspective(PerspectiveManager.OPENED_PERSPECTIVE);
        editFile(repositoryFile);
    } else if (mode == FileCommand.COMMAND.SCHEDULE_NEW) {
        ScheduleHelper.createSchedule(repositoryFile, new ScheduleCallback(repositoryFile));
        return;
    } else if (mode == FileCommand.COMMAND.SHARE) {
        ShareFileCommand sfc = new ShareFileCommand();
        sfc.setSolutionPath(fileNameWithPath);
        sfc.execute();
    } else {
        String url = null;
        // $NON-NLS-1$
        String extension = "";
        if (fileNameWithPath.lastIndexOf(FILE_EXTENSION_DELIMETER) > 0) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            extension = fileNameWithPath.substring(fileNameWithPath.lastIndexOf(FILE_EXTENSION_DELIMETER) + 1);
        }
        if (!executableFileExtensions.contains(extension)) {
            // $NON-NLS-1$ //$NON-NLS-2$
            url = getPath() + "api/repos/" + pathToId(fileNameWithPath) + "/content";
        } else {
            ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(fileNameWithPath);
            url = getPath() + "api/repos/" + pathToId(fileNameWithPath) + "/" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            (plugin != null && (plugin.getCommandPerspective(mode) != null) ? plugin.getCommandPerspective(mode) : "generatedContent");
        }
        // force to open pdf files in another window due to issues with pdf readers in IE browsers
        // via class added on themeResources for IE browsers
        boolean pdfReaderEmbeded = RootPanel.getBodyElement().getClassName().contains("pdfReaderEmbeded");
        if (mode == FileCommand.COMMAND.NEWWINDOW || (extension.equals("pdf") && pdfReaderEmbeded)) {
            // $NON-NLS-1$ //$NON-NLS-2$
            Window.open(url, "_blank", "menubar=yes,location=no,resizable=yes,scrollbars=yes,status=no");
        } else {
            PerspectiveManager.getInstance().setPerspective(PerspectiveManager.OPENED_PERSPECTIVE);
            contentTabPanel.showNewURLTab(repositoryFile.getTitle(), repositoryFile.getTitle(), url, true);
            addRecent(fileNameWithPath, repositoryFile.getTitle());
        }
    }
    // Store representation of file in the frame for reference later when
    // save is called
    String fileName = repositoryFile.getName();
    if (fileName.contains(FILE_EXTENSION_DELIMETER)) {
        fileName = fileName.substring(0, fileName.lastIndexOf(FILE_EXTENSION_DELIMETER));
    }
    String filePath = repositoryFile.getPath();
    if (filePath.endsWith(repositoryFile.getName())) {
        filePath = filePath.substring(0, filePath.lastIndexOf(repositoryFile.getName()) - 1);
    }
    SolutionFileInfo fileInfo = new SolutionFileInfo();
    fileInfo.setName(fileName);
    fileInfo.setPath(filePath);
    fileInfo.setType(SolutionFileInfo.Type.XACTION);
    if (contentTabPanel != null && contentTabPanel.getCurrentFrame() != null) {
        contentTabPanel.getCurrentFrame().setFileInfo(fileInfo);
    }
}
Also used : ShareFileCommand(org.pentaho.mantle.client.commands.ShareFileCommand) SolutionFileInfo(org.pentaho.mantle.client.objects.SolutionFileInfo) JsArrayString(com.google.gwt.core.client.JsArrayString) ContentTypePlugin(org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)

Example 4 with SolutionFileInfo

use of org.pentaho.mantle.client.objects.SolutionFileInfo in project pentaho-platform by pentaho.

the class IFrameTabPanel method setFileInfo.

public void setFileInfo(FileItem item) {
    SolutionFileInfo fileInfo = new SolutionFileInfo();
    fileInfo.setName(item.getName());
    fileInfo.setPath(item.getPath());
    setFileInfo(fileInfo);
}
Also used : SolutionFileInfo(org.pentaho.mantle.client.objects.SolutionFileInfo)

Example 5 with SolutionFileInfo

use of org.pentaho.mantle.client.objects.SolutionFileInfo in project pentaho-platform by pentaho.

the class SaveCommand method retrieveCachedValues.

private void retrieveCachedValues(IFrameTabPanel tabPanel) {
    clearValues();
    SolutionFileInfo info = tabPanel.getFileInfo();
    if (info != null) {
        this.name = info.getName();
        this.path = info.getPath();
        this.type = info.getType();
    }
}
Also used : SolutionFileInfo(org.pentaho.mantle.client.objects.SolutionFileInfo)

Aggregations

SolutionFileInfo (org.pentaho.mantle.client.objects.SolutionFileInfo)6 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 NodeList (com.google.gwt.dom.client.NodeList)1 Element (com.google.gwt.user.client.Element)1 Label (com.google.gwt.user.client.ui.Label)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 Widget (com.google.gwt.user.client.ui.Widget)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IDialogCallback (org.pentaho.gwt.widgets.client.dialogs.IDialogCallback)1 PromptDialogBox (org.pentaho.gwt.widgets.client.dialogs.PromptDialogBox)1 ShareFileCommand (org.pentaho.mantle.client.commands.ShareFileCommand)1 SolutionBrowserCloseEvent (org.pentaho.mantle.client.events.SolutionBrowserCloseEvent)1 ContentTypePlugin (org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)1 FileItem (org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)1 CustomFrame (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel.CustomFrame)1