Search in sources :

Example 1 with ShareFileCommand

use of org.pentaho.mantle.client.commands.ShareFileCommand in project pentaho-platform by pentaho.

the class FileCommand method execute.

public void execute() {
    if (popupMenu != null) {
        popupMenu.hide();
    }
    SolutionBrowserPanel sbp = SolutionBrowserPanel.getInstance();
    FilesListPanel flp = sbp.getFilesListPanel();
    if (flp.getSelectedFileItems() == null || flp.getSelectedFileItems().size() < 1) {
        return;
    }
    List<FileItem> selectedItems = flp.getSelectedFileItems();
    FileItem selectedItem = selectedItems.get(0);
    if (mode == COMMAND.RUN || mode == COMMAND.NEWWINDOW) {
        if (selectedItem != null) {
            sbp.openFile(selectedItem.getRepositoryFile(), mode);
        }
    } else if (mode == COMMAND.PROPERTIES) {
        new FilePropertiesCommand(fileSummary == null ? fileSummaryProvider.getRepositoryFiles().get(0) : fileSummary).execute();
    } else if (mode == COMMAND.EDIT) {
        sbp.editFile();
    } else if (mode == COMMAND.CREATE_FOLDER) {
        new NewFolderCommand(fileSummary).execute();
    } else if (mode == COMMAND.BACKGROUND) {
        new RunInBackgroundCommand(selectedItem).execute(true);
    } else if (mode == COMMAND.SCHEDULE_NEW) {
        ScheduleHelper.createSchedule(selectedItem.getRepositoryFile(), new ScheduleCallback(selectedItem.getRepositoryFile()));
    } else if (mode == COMMAND.SHARE) {
        new ShareFileCommand().execute();
    } else if (mode == COMMAND.IMPORT) {
        new ImportFileCommand(fileSummary == null ? fileSummaryProvider.getRepositoryFiles().get(0) : fileSummary).execute();
    } else if (mode == COMMAND.EXPORT) {
        new ExportFileCommand(fileSummary == null ? fileSummaryProvider.getRepositoryFiles().get(0) : fileSummary).execute();
    } else if (mode == COMMAND.FAVORITE) {
        sbp.addFavorite(selectedItem.getRepositoryFile().getPath(), selectedItem.getRepositoryFile().getTitle());
        FavoritePickList.getInstance().save("favorites");
    } else if (mode == COMMAND.FAVORITE_REMOVE) {
        sbp.removeFavorite(selectedItem.getRepositoryFile().getPath());
        FavoritePickList.getInstance().save("favorites");
    }
}
Also used : ScheduleCallback(org.pentaho.mantle.client.solutionbrowser.ScheduleCallback) ShareFileCommand(org.pentaho.mantle.client.commands.ShareFileCommand) ImportFileCommand(org.pentaho.mantle.client.commands.ImportFileCommand) FilePropertiesCommand(org.pentaho.mantle.client.commands.FilePropertiesCommand) NewFolderCommand(org.pentaho.mantle.client.commands.NewFolderCommand) SolutionBrowserPanel(org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel) RunInBackgroundCommand(org.pentaho.mantle.client.commands.RunInBackgroundCommand) ExportFileCommand(org.pentaho.mantle.client.commands.ExportFileCommand)

Example 2 with ShareFileCommand

use of org.pentaho.mantle.client.commands.ShareFileCommand 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)

Aggregations

ShareFileCommand (org.pentaho.mantle.client.commands.ShareFileCommand)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ExportFileCommand (org.pentaho.mantle.client.commands.ExportFileCommand)1 FilePropertiesCommand (org.pentaho.mantle.client.commands.FilePropertiesCommand)1 ImportFileCommand (org.pentaho.mantle.client.commands.ImportFileCommand)1 NewFolderCommand (org.pentaho.mantle.client.commands.NewFolderCommand)1 RunInBackgroundCommand (org.pentaho.mantle.client.commands.RunInBackgroundCommand)1 SolutionFileInfo (org.pentaho.mantle.client.objects.SolutionFileInfo)1 ContentTypePlugin (org.pentaho.mantle.client.solutionbrowser.PluginOptionsHelper.ContentTypePlugin)1 ScheduleCallback (org.pentaho.mantle.client.solutionbrowser.ScheduleCallback)1 SolutionBrowserPanel (org.pentaho.mantle.client.solutionbrowser.SolutionBrowserPanel)1