use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback 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();
}
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class MantleTab method reloadTab.
public void reloadTab() {
if (getContent() instanceof IFrameTabPanel) {
VerticalPanel vp = new VerticalPanel();
// $NON-NLS-1$
vp.add(new Label(Messages.getString("reloadQuestion")));
final MantleDialogBox reloadConfirmDialog = new MantleDialogBox(Messages.getString("reloadConfirm"), Messages.getString("yes"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
reloadConfirmDialog.hide();
}
public void okPressed() {
((IFrameTabPanel) getContent()).reload();
reloadConfirmDialog.hide();
}
};
reloadConfirmDialog.setCallback(callback);
reloadConfirmDialog.center();
}
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class ScheduleCallback method okPressed.
@Override
public void okPressed() {
// $NON-NLS-1$
String extension = "";
if (repositoryFile.getPath().lastIndexOf(".") > 0) {
// $NON-NLS-1$
// $NON-NLS-1$
extension = repositoryFile.getPath().substring(repositoryFile.getPath().lastIndexOf(".") + 1);
}
if (SolutionBrowserPanel.getInstance().getExecutableFileExtensions().contains(extension)) {
IDialogCallback callback = new IDialogCallback() {
@Override
public void okPressed() {
ScheduleCreateStatusDialog dialog = new ScheduleCreateStatusDialog();
dialog.center();
}
@Override
public void cancelPressed() {
}
};
ScheduleHelper.showScheduleDialog(repositoryFile.getPath(), callback);
} else {
final MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("open"), Messages.getString("scheduleInvalidFileType", repositoryFile.getPath()), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.setCallback(new IDialogCallback() {
public void cancelPressed() {
}
public void okPressed() {
dialogBox.hide();
}
});
dialogBox.center();
return;
}
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class SaveCommand method performOperation.
protected void performOperation(boolean feedback) {
final SolutionBrowserPanel navigatorPerspective = SolutionBrowserPanel.getInstance();
retrieveCachedValues(navigatorPerspective.getContentTabPanel().getCurrentFrame());
boolean forceReload = false;
if (FileChooserDialog.getIsDirty()) {
forceReload = true;
WaitPopup.getInstance().setVisibleById(true, spinnerId);
FileChooserDialog.setIsDirty(Boolean.FALSE);
}
RepositoryFileTreeManager.getInstance().fetchRepositoryFileTree(new AsyncCallback<RepositoryFileTree>() {
public void onFailure(Throwable caught) {
}
public void onSuccess(RepositoryFileTree tree) {
retrieveCachedValues(navigatorPerspective.getContentTabPanel().getCurrentFrame());
if (isSaveAs || name == null) {
String fileDir = "";
if (path != null && !StringUtils.isEmpty(path)) {
// If has extension
if (path.endsWith(name)) {
fileDir = path.substring(0, path.lastIndexOf("/"));
} else {
fileDir = path;
}
}
WaitPopup.getInstance().setVisibleById(false, spinnerId);
final FileChooserDialog dialog = new FileChooserDialog(FileChooserMode.SAVE, fileDir, tree, false, true, Messages.getString("save"), Messages.getString("save"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
navigatorPerspective.getSolutionTree().isShowHiddenFiles());
dialog.setSubmitOnEnter(MantleApplication.submitOnEnter);
if (isSaveAs) {
// $NON-NLS-1$
dialog.setTitle(Messages.getString("saveAs"));
// $NON-NLS-1$
dialog.setText(Messages.getString("saveAs"));
} else {
// $NON-NLS-1$
dialog.setTitle(Messages.getString("save"));
// $NON-NLS-1$
dialog.setText(Messages.getString("save"));
}
// TODO Uncomment the line below and delete the line after that once gwtwidets have been branched
dialog.addFileChooserListener(new FileChooserListener() {
public void dialogCanceled() {
}
@Override
public void fileSelected(final RepositoryFile file, String filePath, String fileName, String title) {
SaveCommand.this.type = SolutionFileInfo.Type.XACTION;
SaveCommand.this.name = fileName;
SaveCommand.this.path = filePath;
tabName = name;
if (tabName.indexOf("analysisview.xaction") != -1) {
// trim off the analysisview.xaction from the localized-name
tabName = tabName.substring(0, tabName.indexOf("analysisview.xaction") - 1);
}
JsArrayString extensions = getPossibleExtensions(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId());
final String fileExtension = extensions.length() == 1 ? extensions.get(0) : null;
if (dialog.doesSelectedFileExist(fileExtension)) {
dialog.hide();
PromptDialogBox overWriteDialog = new PromptDialogBox(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("question"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("yes"), // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Messages.getString("no"), false, true);
// $NON-NLS-1$
overWriteDialog.setContent(new Label(Messages.getString("fileExistsOverwrite"), false));
overWriteDialog.setCallback(new IDialogCallback() {
public void okPressed() {
if (fileExtension != null && tabName.endsWith(fileExtension)) {
tabName = tabName.substring(0, tabName.lastIndexOf(fileExtension));
}
doSaveAs(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId(), name, path, type, true);
// $NON-NLS-1$ //$NON-NLS-2$
Window.setTitle(Messages.getString("productName") + " - " + name);
FileChooserDialog.setIsDirty(Boolean.TRUE);
persistFileInfoInFrame();
}
public void cancelPressed() {
dialog.show();
}
});
overWriteDialog.center();
} else {
// [Fix for PIR-833]
if (file != null && !file.isFolder() && !fileName.equals(title) && filePath.endsWith(file.getName())) {
SaveCommand.this.path = filePath.substring(0, filePath.lastIndexOf("/" + file.getName()));
}
doSaveAs(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId(), name, path, type, true);
// $NON-NLS-1$ //$NON-NLS-2$
Window.setTitle(Messages.getString("productName") + " - " + name);
persistFileInfoInFrame();
// navigatorPerspective.addRecent(fullPathWithName, name);
clearValues();
}
}
@Override
public void fileSelectionChanged(RepositoryFile file, String filePath, String fileName, String title) {
// TODO Auto-generated method stub
}
});
dialog.center();
} else {
doSaveAs(navigatorPerspective.getContentTabPanel().getCurrentFrameElementId(), name, path, type, true);
clearValues();
}
WaitPopup.getInstance().setVisibleById(false, spinnerId);
}
}, forceReload, null, null, SolutionBrowserPanel.getInstance().getSolutionTree().isShowHiddenFiles());
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class OpenURLCommand method performOperation.
protected void performOperation(boolean feedback) {
final TextBox textBox = new TextBox();
// $NON-NLS-1$
textBox.setText("http://");
// $NON-NLS-1$
textBox.setWidth("500px");
textBox.setVisibleLength(72);
IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
}
public void okPressed() {
SolutionBrowserPanel.getInstance().getContentTabPanel().showNewURLTab(textBox.getText(), textBox.getText(), textBox.getText(), false);
}
};
IDialogValidatorCallback validatorCallback = new IDialogValidatorCallback() {
public boolean validate() {
// $NON-NLS-1$
boolean isValid = !"".equals(textBox.getText()) && textBox.getText() != null;
if (!isValid) {
MessageDialogBox dialogBox = new MessageDialogBox(Messages.getString("error"), Messages.getString("urlNotSpecified"), false, false, // $NON-NLS-1$ //$NON-NLS-2$
true);
dialogBox.center();
}
return isValid;
}
};
PromptDialogBox promptDialog = new PromptDialogBox(Messages.getString("enterURL"), Messages.getString("ok"), Messages.getString("cancel"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
textBox);
promptDialog.setValidatorCallback(validatorCallback);
promptDialog.setCallback(callback);
// $NON-NLS-1$
promptDialog.setWidth("500px");
promptDialog.center();
}
Aggregations