use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class DeleteFolderCommand method performOperation.
protected void performOperation() {
if (this.getSolutionPath() != null) {
SolutionBrowserPanel sbp = SolutionBrowserPanel.getInstance();
sbp.getFile(this.getSolutionPath(), new SolutionFileHandler() {
@Override
public void handle(RepositoryFile repositoryFile) {
DeleteFolderCommand.this.repositoryFile = repositoryFile;
performOperation(true);
}
});
} else {
performOperation(true);
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile 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();
}
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class SolutionBrowserPanel method getFile.
public void getFile(final String solutionPath, final SolutionFileHandler handler) {
final String moduleBaseURL = GWT.getModuleBaseURL();
final String moduleName = GWT.getModuleName();
final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
// Expecting some encoding here
final String path = solutionPath;
// $NON-NLS-1$
final String url = contextURL + "api/repo/files/" + pathToId(path) + "/properties";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
executableTypesRequestBuilder.setHeader("accept", "application/json");
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == Response.SC_OK) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("repositoryFileDto", (JSONObject) JSONParser.parseLenient(response.getText()));
RepositoryFile repositoryFile = new RepositoryFile(jsonObject);
handler.handle(repositoryFile);
}
}
});
} catch (RequestException e) {
// showError(e);
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class SolutionBrowserPanel method openFile.
public void openFile(final String fileNameWithPath, final FileCommand.COMMAND mode) {
final String moduleBaseURL = GWT.getModuleBaseURL();
final String moduleName = GWT.getModuleName();
final String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
// Expecting some encoding here
final String path = fileNameWithPath;
// $NON-NLS-1$
final String url = contextURL + "api/repo/files/" + pathToId(path) + "/properties";
RequestBuilder executableTypesRequestBuilder = new RequestBuilder(RequestBuilder.GET, url);
executableTypesRequestBuilder.setHeader("accept", "application/json");
executableTypesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
executableTypesRequestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
// showError(exception);
}
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == Response.SC_OK) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("repositoryFileDto", (JSONObject) JSONParser.parseLenient(response.getText()));
RepositoryFile repositoryFile = new RepositoryFile(jsonObject);
openFile(repositoryFile, mode);
}
}
});
} catch (RequestException e) {
// showError(e);
}
}
use of org.pentaho.gwt.widgets.client.filechooser.RepositoryFile in project pentaho-platform by pentaho.
the class FilesListPanel method selectNextItem.
public void selectNextItem(List<FileItem> currentItems) {
if (currentItems == null || currentItems.size() < 1) {
return;
}
FileItem currentItem = currentItems.get(currentItems.size() - 1);
RepositoryFile currentRepositoryFile = currentItem.getRepositoryFile();
int myIndex = -1;
for (int i = 0; i < getFileCount(); i++) {
FileItem fileItem = getFileItem(i);
if (fileItem == currentItem) {
myIndex = i;
}
}
if (myIndex >= 0 && myIndex < getFileCount() - 1) {
if (currentRepositoryFile.isHidden()) {
// $NON-NLS-1$
currentItem.setStyleName("hiddenFileLabel");
} else {
// $NON-NLS-1$
currentItem.setStyleName("fileLabel");
}
FileItem nextItem = getFileItem(myIndex + 1);
RepositoryFile nextRepositoryFile = nextItem.getRepositoryFile();
if (nextRepositoryFile.isHidden()) {
// $NON-NLS-1$
nextItem.setStyleName("hiddenFileLabelSelected");
} else {
// $NON-NLS-1$
nextItem.setStyleName("fileLabelSelected");
}
List<FileItem> fileItems = new ArrayList<FileItem>();
fileItems.add(nextItem);
setSelectedFileItems(fileItems);
nextItem.fireFileSelectionEvent();
}
}
Aggregations