Search in sources :

Example 1 with FileItem

use of org.pentaho.mantle.client.solutionbrowser.filelist.FileItem in project pentaho-platform by pentaho.

the class SolutionBrowserDragController method dragEnd.

@Override
public void dragEnd() {
    if (currentFrameAcceptsDrops() == false) {
        return;
    }
    FileItem item = (FileItem) context.draggable;
    context.vetoException = new Exception();
    super.dragEnd();
    preview.removeFromParent();
    preview = null;
    MantleApplication.overlayPanel.setVisible(false);
    notifyContentDragEnd(item.getPath(), item.getName(), item.getLocalizedName());
    currentDragItem = null;
}
Also used : FileItem(org.pentaho.mantle.client.solutionbrowser.filelist.FileItem) VetoDragException(com.allen_sauer.gwt.dnd.client.VetoDragException)

Example 2 with FileItem

use of org.pentaho.mantle.client.solutionbrowser.filelist.FileItem in project pentaho-platform by pentaho.

the class SolutionBrowserDragController method newDragProxy.

@Override
protected Widget newDragProxy(DragContext context) {
    FileItem item = (FileItem) context.draggable;
    FileItem newItem = item.makeDragProxy();
    preview = newItem;
    return newItem;
}
Also used : FileItem(org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)

Example 3 with FileItem

use of org.pentaho.mantle.client.solutionbrowser.filelist.FileItem in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method executeActionSequence.

public void executeActionSequence(final FileCommand.COMMAND mode) {
    if (filesListPanel.getSelectedFileItems() == null || filesListPanel.getSelectedFileItems().size() != 1) {
        return;
    }
    // open in content panel
    AbstractCommand authCmd = new AbstractCommand() {

        protected void performOperation() {
            performOperation(false);
        }

        protected void performOperation(boolean feedback) {
            final FileItem selectedFileItem = filesListPanel.getSelectedFileItems().get(0);
            String url = null;
            url = // $NON-NLS-1$ //$NON-NLS-2$
            "api/repo/files/" + SolutionBrowserPanel.pathToId(filesListPanel.getSelectedFileItems().get(0).getRepositoryFile().getPath()) + "/generatedContent";
            url = getPath() + url;
            if (mode == FileCommand.COMMAND.BACKGROUND) {
                MessageDialogBox dialogBox = new // $NON-NLS-1$
                MessageDialogBox(// $NON-NLS-1$
                Messages.getString("info"), // $NON-NLS-1$
                Messages.getString("backgroundExecutionWarning"), true, false, true);
                dialogBox.center();
                // $NON-NLS-1$
                url += "&background=true";
                RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
                try {
                    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
                    builder.sendRequest(null, new RequestCallback() {

                        public void onError(Request request, Throwable exception) {
                            MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("couldNotBackgroundExecute"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
                            true);
                            dialogBox.center();
                        }

                        public void onResponseReceived(Request request, Response response) {
                        }
                    });
                } catch (RequestException e) {
                // ignored
                }
            } else if (mode == FileCommand.COMMAND.NEWWINDOW) {
                // popup blockers might attack this
                // $NON-NLS-1$ //$NON-NLS-2$
                Window.open(url, "_blank", "menubar=yes,location=no,resizable=yes,scrollbars=yes,status=no");
            } else if (mode == FileCommand.COMMAND.SUBSCRIBE) {
                // $NON-NLS-1$
                final String myurl = url + "&subscribepage=yes";
                contentTabPanel.showNewURLTab(selectedFileItem.getLocalizedName(), selectedFileItem.getLocalizedName(), myurl, true);
            } else {
                contentTabPanel.showNewURLTab(selectedFileItem.getLocalizedName(), selectedFileItem.getLocalizedName(), url, true);
            }
        }
    };
    authCmd.execute();
}
Also used : Response(com.google.gwt.http.client.Response) FileItem(org.pentaho.mantle.client.solutionbrowser.filelist.FileItem) MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) RequestBuilder(com.google.gwt.http.client.RequestBuilder) EmptyRequestCallback(org.pentaho.mantle.client.EmptyRequestCallback) RequestCallback(com.google.gwt.http.client.RequestCallback) AbstractCommand(org.pentaho.mantle.client.commands.AbstractCommand) Request(com.google.gwt.http.client.Request) JsArrayString(com.google.gwt.core.client.JsArrayString) RequestException(com.google.gwt.http.client.RequestException)

Example 4 with FileItem

use of org.pentaho.mantle.client.solutionbrowser.filelist.FileItem in project pentaho-platform by pentaho.

the class MantleTabPanel method setContentEditSelected.

public void setContentEditSelected(boolean selected) {
    IFrameTabPanel panel = getCurrentFrame();
    if (panel != null) {
        panel.setEditSelected(selected);
        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 5 with FileItem

use of org.pentaho.mantle.client.solutionbrowser.filelist.FileItem 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)

Aggregations

FileItem (org.pentaho.mantle.client.solutionbrowser.filelist.FileItem)10 Widget (com.google.gwt.user.client.ui.Widget)7 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)7 SolutionBrowserSelectEvent (org.pentaho.mantle.client.events.SolutionBrowserSelectEvent)3 Element (com.google.gwt.user.client.Element)2 ArrayList (java.util.ArrayList)2 SolutionBrowserOpenEvent (org.pentaho.mantle.client.events.SolutionBrowserOpenEvent)2 SolutionBrowserUndefinedEvent (org.pentaho.mantle.client.events.SolutionBrowserUndefinedEvent)2 VetoDragException (com.allen_sauer.gwt.dnd.client.VetoDragException)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 NodeList (com.google.gwt.dom.client.NodeList)1 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 Timer (com.google.gwt.user.client.Timer)1 Label (com.google.gwt.user.client.ui.Label)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 List (java.util.List)1