Search in sources :

Example 1 with ContentTypePlugin

use of org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method editFile.

public void editFile() {
    if (filesListPanel.getSelectedFileItems() == null || filesListPanel.getSelectedFileItems().size() != 1) {
        return;
    }
    RepositoryFile file = filesListPanel.getSelectedFileItems().get(0).getRepositoryFile();
    if (file.getName().endsWith(".analysisview.xaction")) {
        // $NON-NLS-1$
        openFile(file, COMMAND.RUN);
    } else {
        // check to see if a plugin supports editing
        ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(file.getName());
        if (plugin != null && plugin.hasCommand(COMMAND.EDIT)) {
            // load the editor for this plugin
            String editUrl = getPath() + "api/repos/" + pathToId(file.getPath()) + "/" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            (plugin != null && (plugin.getCommandPerspective(COMMAND.EDIT) != null) ? plugin.getCommandPerspective(COMMAND.EDIT) : "editor");
            // See if it's already loaded
            for (int i = 0; i < contentTabPanel.getTabCount(); i++) {
                Widget w = contentTabPanel.getTab(i).getContent();
                if (w instanceof IFrameTabPanel && ((IFrameTabPanel) w).getUrl().endsWith(editUrl)) {
                    // Already up, select and exit
                    contentTabPanel.selectTab(i);
                    return;
                }
            }
            contentTabPanel.showNewURLTab(Messages.getString("editingColon") + file.getTitle(), Messages.getString("editingColon") + file.getTitle(), editUrl, // $NON-NLS-1$ //$NON-NLS-2$
            true);
        } else {
            MessageDialogBox dialogBox = new // $NON-NLS-1$
            MessageDialogBox(// $NON-NLS-1$
            Messages.getString("error"), // $NON-NLS-1$
            Messages.getString("cannotEditFileType"), true, false, true);
            dialogBox.center();
        }
    }
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) Widget(com.google.gwt.user.client.ui.Widget) RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) JsArrayString(com.google.gwt.core.client.JsArrayString) ContentTypePlugin(org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)

Example 2 with ContentTypePlugin

use of org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method setDeepLinkUrl.

public void setDeepLinkUrl(String fileNameWithPath) {
    ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(fileNameWithPath);
    if (plugin != null && plugin.hasCommand(COMMAND.RUN)) {
        String url = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        getPath() + "api/repos/" + pathToId(fileNameWithPath) + "/" + plugin.getCommandPerspective(COMMAND.RUN);
        contentTabPanel.getCurrentFrame().setDeepLinkUrl(url);
    }
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) ContentTypePlugin(org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)

Example 3 with ContentTypePlugin

use of org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin 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 ContentTypePlugin

use of org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin in project pentaho-platform by pentaho.

the class SolutionBrowserPanel method editFile.

public void editFile(final RepositoryFile file) {
    if (file.getName().endsWith(".analysisview.xaction")) {
        // $NON-NLS-1$
        openFile(file, COMMAND.RUN);
    } else {
        // check to see if a plugin supports editing
        ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(file.getName());
        if (plugin != null && plugin.hasCommand(COMMAND.EDIT)) {
            // load the editor for this plugin
            String editUrl = getPath() + "api/repos/" + pathToId(file.getPath()) + "/" + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            (plugin != null && (plugin.getCommandPerspective(COMMAND.EDIT) != null) ? plugin.getCommandPerspective(COMMAND.EDIT) : "editor");
            // See if it's already loaded
            for (int i = 0; i < contentTabPanel.getTabCount(); i++) {
                Widget w = contentTabPanel.getTab(i).getContent();
                if (w instanceof IFrameTabPanel && ((IFrameTabPanel) w).getUrl().endsWith(editUrl)) {
                    // Already up, select and exit
                    contentTabPanel.selectTab(i);
                    return;
                }
            }
            contentTabPanel.showNewURLTab(Messages.getString("editingColon") + file.getTitle(), Messages.getString("editingColon") + file.getTitle(), editUrl, // $NON-NLS-1$ //$NON-NLS-2$
            true);
        } else {
            MessageDialogBox dialogBox = new // $NON-NLS-1$
            MessageDialogBox(// $NON-NLS-1$
            Messages.getString("error"), // $NON-NLS-1$
            Messages.getString("cannotEditFileType"), true, false, true);
            dialogBox.center();
        }
    }
}
Also used : MessageDialogBox(org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox) Widget(com.google.gwt.user.client.ui.Widget) IFrameTabPanel(org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel) JsArrayString(com.google.gwt.core.client.JsArrayString) ContentTypePlugin(org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)

Example 5 with ContentTypePlugin

use of org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin in project pentaho-platform by pentaho.

the class FilesListPanel method populateFilesList.

public void populateFilesList(SolutionBrowserPanel perspective, SolutionTree solutionTree, TreeItem item, JsArrayString filters) {
    filesList.clear();
    List<RepositoryFile> files;
    if (item == solutionTree.getTrashItem()) {
        // If we're populating from the trash then
        files = solutionTree.getTrashItems();
    } else {
        files = new ArrayList<RepositoryFile>();
        // Get the user object.
        RepositoryFileTree tree = (RepositoryFileTree) item.getUserObject();
        // Since we are only listing the files here. Get to each item of the tree and get the file from it
        for (RepositoryFileTree treeItem : tree.getChildren()) {
            String fileName = treeItem.getFile().getName();
            if (filters != null) {
                for (int i = 0; i < filters.length(); i++) {
                    if (fileName.endsWith(filters.get(i))) {
                        files.add(treeItem.getFile());
                    }
                }
            }
        }
    }
    // let's sort this list based on localized name
    // BISERVER-9599 - Custom Sort
    Collections.sort(files, new RepositoryFileComparator());
    if (files != null) {
        int rowCounter = 0;
        for (RepositoryFile file : files) {
            if ((item == solutionTree.getTrashItem()) || (!file.isFolder() && (isShowHiddenFiles() || !file.isHidden()))) {
                // TODO Currently Old solution repository stores url type files. New repository does not have that
                // concept. What do we need to do here
                // String url = fileElement.getAttribute("url"); //$NON-NLS-1$
                ContentTypePlugin plugin = PluginOptionsHelper.getContentTypePlugin(file.getName());
                String icon = null;
                if (plugin != null) {
                    icon = plugin.getFileIcon();
                }
                if (item == solutionTree.getTrashItem() && file.isFolder()) {
                    // $NON-NLS-1$
                    icon = "mantle/images/folderIcon.png";
                }
                final FileItem fileLabel = new FileItem(file, this, PluginOptionsHelper.getEnabledOptions(file.getName()), true, icon);
                // BISERVER-2317: Request for more IDs for Mantle UI elements
                // set element id as the filename
                // $NON-NLS-1$
                fileLabel.getElement().setId(file.getPath());
                fileLabel.addFileSelectionChangedListener(toolbar);
                // $NON-NLS-1$
                fileLabel.setWidth("100%");
                try {
                    perspective.getDragController().makeDraggable(fileLabel);
                } catch (Throwable e) {
                    Throwable throwable = e;
                    String text = "Uncaught exception: ";
                    while (throwable != null) {
                        StackTraceElement[] stackTraceElements = throwable.getStackTrace();
                        text += throwable.toString() + "\n";
                        for (int ii = 0; ii < stackTraceElements.length; ii++) {
                            text += "    at " + stackTraceElements[ii] + "\n";
                        }
                        throwable = throwable.getCause();
                        if (throwable != null) {
                            text += "Caused by: ";
                        }
                    }
                    DialogBox dialogBox = new DialogBox(true);
                    DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF");
                    System.err.print(text);
                    text = text.replaceAll(" ", "&nbsp;");
                    dialogBox.setHTML("<pre>" + text + "</pre>");
                    dialogBox.center();
                }
                fileLabel.setRepositoryFile(file);
                filesList.setWidget(rowCounter++, 0, fileLabel);
                if (selectedFileItems != null && selectedFileItems.size() > 0) {
                    for (FileItem fileItem : selectedFileItems) {
                        if (fileItem.getRepositoryFile().equals(fileLabel.getRepositoryFile())) {
                            if (file.isHidden()) {
                                fileLabel.setStyleName("hiddenFileLabelSelected");
                            } else {
                                // $NON-NLS-1$
                                fileLabel.setStyleName("fileLabelSelected");
                            }
                            selectedFileItems.add(fileLabel);
                            // if we do not break this loop, it will go forever! (we added an item)
                            break;
                        }
                    }
                } else {
                    if (file.isHidden()) {
                        // $NON-NLS-1$
                        fileLabel.setStyleName("hiddenFileLabel");
                    } else {
                        // $NON-NLS-1$
                        fileLabel.setStyleName("fileLabel");
                    }
                }
            }
        }
    }
}
Also used : RepositoryFile(org.pentaho.gwt.widgets.client.filechooser.RepositoryFile) JsArrayString(com.google.gwt.core.client.JsArrayString) RepositoryFileTree(org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree) ContentTypePlugin(org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin) DialogBox(com.google.gwt.user.client.ui.DialogBox)

Aggregations

JsArrayString (com.google.gwt.core.client.JsArrayString)5 ContentTypePlugin (org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)5 Widget (com.google.gwt.user.client.ui.Widget)2 MessageDialogBox (org.pentaho.gwt.widgets.client.dialogs.MessageDialogBox)2 RepositoryFile (org.pentaho.gwt.widgets.client.filechooser.RepositoryFile)2 IFrameTabPanel (org.pentaho.mantle.client.solutionbrowser.tabs.IFrameTabPanel)2 DialogBox (com.google.gwt.user.client.ui.DialogBox)1 RepositoryFileTree (org.pentaho.gwt.widgets.client.filechooser.RepositoryFileTree)1 ShareFileCommand (org.pentaho.mantle.client.commands.ShareFileCommand)1 SolutionFileInfo (org.pentaho.mantle.client.objects.SolutionFileInfo)1