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");
}
}
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);
}
}
Aggregations