use of org.pentaho.mantle.client.events.SolutionFileActionEvent in project pentaho-platform by pentaho.
the class DeleteFileCommand method performOperation.
protected void performOperation(boolean feedback) {
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
String temp = "";
String names = "";
// Convert to a comma delimted list for rest call
for (SolutionBrowserFile file : filesToDelete) {
// $NON-NLS-1$
temp += file.getId() + ",";
// $NON-NLS-1$
names += file.getName() + ",";
}
// remove trailing ","
temp = temp.substring(0, temp.length() - 1);
names = names.substring(0, names.length() - 1);
final String filesList = temp;
if (feedback) {
final HTML messageTextBox;
if (filesToDelete.size() > 1) {
messageTextBox = new HTML(Messages.getString("moveAllToTrashQuestionFile"));
} else {
messageTextBox = new HTML(Messages.getString("moveToTrashQuestionFile", names));
}
final PromptDialogBox fileMoveToTrashWarningDialogBox = new PromptDialogBox(Messages.getString("moveToTrash"), Messages.getString("yesMoveToTrash"), Messages.getString("no"), true, true);
fileMoveToTrashWarningDialogBox.setContent(messageTextBox);
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
fileMoveToTrashWarningDialogBox.hide();
}
public void okPressed() {
doDelete(filesList, event);
}
};
fileMoveToTrashWarningDialogBox.setCallback(callback);
fileMoveToTrashWarningDialogBox.center();
} else {
doDelete(filesList, event);
}
}
use of org.pentaho.mantle.client.events.SolutionFileActionEvent in project pentaho-platform by pentaho.
the class ExportFileCommand method performOperation.
protected void performOperation(boolean feedback) {
String path = repositoryFile.getPath();
String moduleBaseURL = GWT.getModuleBaseURL();
String moduleName = GWT.getModuleName();
String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
String exportURL = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(path) + "/download?withManifest=true";
Window.open(exportURL, "_new", "");
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
event.setMessage("Success");
EventBusUtil.EVENT_BUS.fireEvent(event);
}
use of org.pentaho.mantle.client.events.SolutionFileActionEvent in project pentaho-platform by pentaho.
the class RestoreFileCommand method execute.
/*
* (non-Javadoc)
*
* @see com.google.gwt.user.client.Command#execute()
*/
@Override
public void execute() {
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
String temp = "";
if (repositoryFiles != null) {
for (RepositoryFile repoFile : repositoryFiles) {
// $NON-NLS-1$
temp += repoFile.getId() + ",";
}
}
// Add file names from js
temp = temp + fileList;
// remove trailing ","
temp = temp.substring(0, temp.length() - 1);
final String filesList = temp;
// $NON-NLS-1$
String deleteFilesURL = contextURL + "api/repo/files/restore";
RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
// $NON-NLS-1$//$NON-NLS-2$
deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
deleteFilesRequestBuilder.sendRequest(filesList, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
MessageDialogBox dialogBox = new MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("cannotRestore"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotRestoreItem", type), false, false, true);
dialogBox.center();
event.setMessage("cannotRestore");
EventBusUtil.EVENT_BUS.fireEvent(event);
}
@Override
public void onResponseReceived(final Request request, final Response response) {
if (response.getStatusCode() == Response.SC_OK) {
new RefreshRepositoryCommand().execute(false);
event.setMessage("Success");
EventBusUtil.EVENT_BUS.fireEvent(event);
} else if (response.getStatusCode() == Response.SC_CONFLICT || response.getStatusCode() == Response.SC_NOT_ACCEPTABLE) {
final int restoreResponseStatusCode = response.getStatusCode();
final String userHomeDirUrl = GWT.getHostPageBaseURL() + "api/session/userWorkspaceDir";
final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, userHomeDirUrl);
try {
// Get user home folder string
builder.sendRequest("", new RequestCallback() {
@Override
public void onResponseReceived(final Request request, final Response response) {
if (response.getStatusCode() == 200) {
// API returns /user/home_folder/workspace
String userHomeFolderPath = response.getText().replaceAll("/workspace", "");
performRestoreToHomeFolder(filesList, restoreResponseStatusCode, userHomeFolderPath, event);
}
}
@Override
public void onError(Request request, Throwable exception) {
showErrorDialogBox(event);
}
});
} catch (RequestException e) {
showErrorDialogBox(event);
}
} else {
MessageDialogBox dialogBox = new MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("cannotRestore"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotRestoreItem", type), false, false, true, Messages.getString("close"));
dialogBox.center();
event.setMessage("Success");
FileChooserDialog.setIsDirty(Boolean.TRUE);
setBrowseRepoDirty(Boolean.TRUE);
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
});
} catch (RequestException e) {
showErrorDialogBox(event);
}
}
use of org.pentaho.mantle.client.events.SolutionFileActionEvent in project pentaho-platform by pentaho.
the class AbstractFilePropertiesCommand method performOperation.
public void performOperation() {
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
if (getRepositoryFile() != null) {
final RepositoryFile item = getRepositoryFile();
// Checking if the user has access to manage permissions
String url = contextURL + "api/repo/files/" + SolutionBrowserPanel.pathToId(item.getPath()) + "/canAccess?permissions=" + // $NON-NLS-1$ //$NON-NLS-2$
MANAGE_ACLS;
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) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage(exception.getMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
public void onResponseReceived(Request request, Response response) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), Boolean.parseBoolean(response.getText()));
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage("Success");
EventBusUtil.EVENT_BUS.fireEvent(event);
}
});
} catch (RequestException e) {
FilePropertiesDialog dialog = new FilePropertiesDialog(item, new PentahoTabPanel(), null, getActiveTab(), false);
dialog.showTab(getActiveTab());
dialog.center();
event.setMessage(e.getMessage());
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
}
use of org.pentaho.mantle.client.events.SolutionFileActionEvent in project pentaho-platform by pentaho.
the class DeletePermanentFileCommand method performOperation.
/*
* (non-Javadoc)
*
* @see com.google.gwt.user.client.Command#execute()
*/
protected void performOperation(boolean feedback) {
final SolutionFileActionEvent event = new SolutionFileActionEvent();
event.setAction(this.getClass().getName());
VerticalPanel vp = new VerticalPanel();
String deleteMessage;
final PromptDialogBox deleteConfirmDialog;
if (mode.equals("purge")) {
deleteMessage = Messages.getString("deleteAllQuestion");
deleteConfirmDialog = new PromptDialogBox(Messages.getString("emptyTrash"), Messages.getString("yesEmptyTrash"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
} else {
if (MULTIPLE_DELETE_TYPE.equals(type)) {
deleteMessage = Messages.getString("deleteMultiQuestion");
} else {
deleteMessage = Messages.getString("deleteQuestion", type);
}
deleteConfirmDialog = new PromptDialogBox(Messages.getString("permDelete"), Messages.getString("yesPermDelete"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
}
// $NON-NLS-1$
vp.add(new HTML(deleteMessage));
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
deleteConfirmDialog.hide();
}
public void okPressed() {
String temp = "";
// Add js file list
temp = temp + fileList;
// remove trailing ","
temp = temp.substring(0, temp.length() - 1);
final String filesList = temp;
// $NON-NLS-1$
String deleteFilesURL = contextURL + "api/repo/files/deletepermanent";
RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
// $NON-NLS-1$//$NON-NLS-2$
deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
deleteFilesRequestBuilder.sendRequest(filesList, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotDeleteFile"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFile"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
@Override
public void onResponseReceived(Request request, Response response) {
if (response.getStatusCode() == 200) {
new RefreshRepositoryCommand().execute(false);
event.setMessage("Success");
FileChooserDialog.setIsDirty(Boolean.TRUE);
setBrowseRepoDirty(Boolean.TRUE);
EventBusUtil.EVENT_BUS.fireEvent(event);
} else {
event.setMessage(Messages.getString("couldNotDeleteFile"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
});
} catch (RequestException e) {
MessageDialogBox dialogBox = new // $NON-NLS-1$ //$NON-NLS-2$
MessageDialogBox(// $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("error"), // $NON-NLS-1$ //$NON-NLS-2$
Messages.getString("couldNotDeleteFile"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFile"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
};
if (!feedback) {
callback.okPressed();
} else {
deleteConfirmDialog.setCallback(callback);
deleteConfirmDialog.center();
}
}
Aggregations