use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class MantleTabPanel method closeTab.
public void closeTab(final PentahoTab closeTab, final boolean invokePreTabCloseHook) {
if (closeTab.getContent() instanceof IFrameTabPanel) {
final Element frameElement = ((IFrameTabPanel) closeTab.getContent()).getFrame().getElement();
String frameId = frameElement.getAttribute("id").replaceAll("\"", "\\\"");
// #a"b1494409287116 need to be escaped to #a\"b1494409287116.
if (frameId.indexOf("\"") != -1) {
frameId = frameId.replaceAll("\"", "");
frameElement.setAttribute("id", frameId);
}
final String finalFrameId = frameId;
if (invokePreTabCloseHook && hasUnsavedChanges(frameElement)) {
// prompt user
VerticalPanel vp = new VerticalPanel();
// $NON-NLS-1$
vp.add(new Label(Messages.getString("confirmTabClose")));
final PromptDialogBox confirmDialog = new PromptDialogBox(Messages.getString("confirm"), Messages.getString("yes"), Messages.getString("no"), false, true, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
vp);
confirmDialog.setCallback(new IDialogCallback() {
public void cancelPressed() {
}
public void okPressed() {
fireCloseTab(finalFrameId);
((CustomFrame) ((IFrameTabPanel) closeTab.getContent()).getFrame()).removeEventListeners(frameElement);
clearClosingFrame(frameElement);
MantleTabPanel.super.closeTab(closeTab, invokePreTabCloseHook);
if (getTabCount() == 0) {
allTabsClosed();
Widget selectTabContent = null;
if (getTab(getSelectedTabIndex()) != null) {
selectTabContent = getTab(getSelectedTabIndex()).getContent();
}
List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserCloseEvent(selectTabContent, selectedItems));
}
}
});
confirmDialog.center();
return;
}
fireCloseTab(finalFrameId);
((CustomFrame) ((IFrameTabPanel) closeTab.getContent()).getFrame()).removeEventListeners(frameElement);
clearClosingFrame(frameElement);
}
super.closeTab(closeTab, invokePreTabCloseHook);
// since we can't entirely reclaim the frame resources held, keep some around
// so we can minimize the extra leakage caused by constantly created more
// let's only keep 5 of these guys around so at least some of the resources
// can be cleaned up (maybe just wishful thinking)
Widget w = closeTab.getContent();
if (w instanceof IFrameTabPanel && freeFrames.size() < 5) {
// wipe out any file info so it doesn't impact future usages of this frame
SolutionFileInfo sfi = null;
IFrameTabPanel iFrameTabPanel = (IFrameTabPanel) w;
iFrameTabPanel.setFileInfo(sfi);
freeFrames.add(iFrameTabPanel);
}
if (getTabCount() == 0) {
allTabsClosed();
Widget selectTabContent = null;
if (getTab(getSelectedTabIndex()) != null) {
selectTabContent = getTab(getSelectedTabIndex()).getContent();
}
List<FileItem> selectedItems = SolutionBrowserPanel.getInstance().getFilesListPanel().getSelectedFileItems();
EventBusUtil.EVENT_BUS.fireEvent(new SolutionBrowserCloseEvent(selectTabContent, selectedItems));
}
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class MantleTab method openTabInNewWindow.
public void openTabInNewWindow() {
if (getContent() instanceof IFrameTabPanel) {
VerticalPanel vp = new VerticalPanel();
// $NON-NLS-1$
vp.add(new Label(Messages.getString("openWindowQuestion")));
final MantleDialogBox openNewWindowConfirmDialog = new MantleDialogBox(Messages.getString("openWindowConfirm"), 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() {
openNewWindowConfirmDialog.hide();
}
public void okPressed() {
((IFrameTabPanel) getContent()).openTabInNewWindow();
openNewWindowConfirmDialog.hide();
}
};
openNewWindowConfirmDialog.setCallback(callback);
openNewWindowConfirmDialog.center();
}
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class ContentCleanerPanel method activate.
public void activate() {
clear();
String moduleBaseURL = GWT.getModuleBaseURL();
String moduleName = GWT.getModuleName();
String contextURL = moduleBaseURL.substring(0, moduleBaseURL.lastIndexOf(moduleName));
RequestBuilder scheduleFileRequestBuilder = new RequestBuilder(RequestBuilder.GET, contextURL + "api/scheduler/getContentCleanerJob?cb=" + System.currentTimeMillis());
scheduleFileRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
// $NON-NLS-1$//$NON-NLS-2$
scheduleFileRequestBuilder.setHeader("Content-Type", "application/json");
// $NON-NLS-1$//$NON-NLS-2$
scheduleFileRequestBuilder.setHeader("accept", "application/json");
try {
scheduleFileRequestBuilder.sendRequest("", new RequestCallback() {
public void onError(Request request, Throwable exception) {
}
public void onResponseReceived(Request request, Response response) {
final TextBox nowTextBox = new TextBox();
nowTextBox.setWidth("24px");
nowTextBox.getElement().getStyle().setPadding(5, Unit.PX);
nowTextBox.getElement().getStyle().setMarginLeft(5, Unit.PX);
nowTextBox.getElement().getStyle().setMarginRight(5, Unit.PX);
final TextBox scheduleTextBox = new TextBox();
scheduleTextBox.setVisibleLength(4);
JsJob tmpJsJob = parseJsonJob(JsonUtils.escapeJsonForEval(response.getText()));
boolean fakeJob = false;
if (tmpJsJob == null) {
tmpJsJob = createJsJob();
fakeJob = true;
}
final JsJob jsJob = tmpJsJob;
if (jsJob != null) {
scheduleTextBox.setValue("" + (Long.parseLong(jsJob.getJobParamValue("age")) / 86400L));
} else {
scheduleTextBox.setText("180");
}
scheduleTextBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
if (jsJob != null) {
JsArray<JsJobParam> params = jsJob.getJobParams();
for (int i = 0; i < params.length(); i++) {
if (params.get(i).getName().equals("age")) {
params.get(i).setValue("" + (Long.parseLong(scheduleTextBox.getText()) * 86400L));
break;
}
}
}
}
});
Label settingsLabel = new Label(Messages.getString("settings"));
settingsLabel.setStyleName("pentaho-fieldgroup-major");
add(settingsLabel, DockPanel.NORTH);
VerticalPanel nowPanelWrapper = new VerticalPanel();
Label deleteNowLabel = new Label(Messages.getString("deleteGeneratedFilesNow"));
deleteNowLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
deleteNowLabel.setStyleName("pentaho-fieldgroup-minor");
nowPanelWrapper.add(deleteNowLabel);
HorizontalPanel nowLabelPanel = new HorizontalPanel();
nowLabelPanel.getElement().getStyle().setPaddingTop(10, Unit.PX);
nowLabelPanel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
Label deleteGeneratedFilesOlderThan = new Label(Messages.getString("deleteGeneratedFilesOlderThan"));
deleteGeneratedFilesOlderThan.getElement().getStyle().setPaddingTop(7, Unit.PX);
nowLabelPanel.add(deleteGeneratedFilesOlderThan);
nowLabelPanel.add(nowTextBox);
nowTextBox.setText("180");
Label days = new Label(Messages.getString("daysDot"));
days.getElement().getStyle().setPaddingTop(7, Unit.PX);
nowLabelPanel.add(days);
Button deleteNowButton = new Button(Messages.getString("deleteNow"));
deleteNowButton.setStylePrimaryName("pentaho-button");
deleteNowButton.addStyleName("first");
deleteNowButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
MessageDialogBox warning = new MessageDialogBox(Messages.getString("deleteNow"), Messages.getString("confirmDeleteGeneratedContentNow"), false, false, true, Messages.getString("yes"), null, Messages.getString("no"));
warning.setCallback(new IDialogCallback() {
@Override
public void okPressed() {
deleteContentNow(Long.parseLong(nowTextBox.getValue()) * 86400L);
}
@Override
public void cancelPressed() {
}
});
warning.center();
}
});
nowPanelWrapper.add(nowLabelPanel);
nowPanelWrapper.add(deleteNowButton);
add(nowPanelWrapper, DockPanel.NORTH);
// scheduled
VerticalPanel scheduledPanel = new VerticalPanel();
Label deleteScheduleLabel = new Label(Messages.getString("scheduleDeletionOfGeneratedFiles"));
deleteScheduleLabel.setStyleName("pentaho-fieldgroup-minor");
deleteScheduleLabel.getElement().getStyle().setPaddingTop(15, Unit.PX);
scheduledPanel.add(deleteScheduleLabel);
Label descLabel;
if (!fakeJob) {
String desc = jsJob.getJobTrigger().getDescription();
descLabel = new Label(desc);
scheduledPanel.add(descLabel);
} else {
descLabel = new Label(Messages.getString("generatedFilesAreNotScheduledToBeDeleted"));
scheduledPanel.add(descLabel);
}
descLabel.getElement().getStyle().setPaddingTop(10, Unit.PX);
descLabel.getElement().getStyle().setPaddingBottom(10, Unit.PX);
Button editScheduleButton = new Button(Messages.getString("edit"));
if (fakeJob) {
editScheduleButton.setText(Messages.getString("scheduleDeletion"));
}
Button deleteScheduleButton = new Button(Messages.getString("cancelSchedule"));
deleteScheduleButton.setStylePrimaryName("pentaho-button");
deleteScheduleButton.addStyleName("last");
deleteScheduleButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
deleteContentCleaner(jsJob);
}
});
editScheduleButton.setStylePrimaryName("pentaho-button");
editScheduleButton.addStyleName("first");
editScheduleButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
IDialogCallback callback = new IDialogCallback() {
public void okPressed() {
deleteContentCleaner(jsJob);
}
public void cancelPressed() {
}
};
HorizontalPanel scheduleLabelPanel = new HorizontalPanel();
scheduleLabelPanel.add(new Label(Messages.getString("deleteGeneratedFilesOlderThan"), false));
scheduleLabelPanel.add(scheduleTextBox);
scheduleLabelPanel.add(new Label(Messages.getString("daysUsingTheFollowingRules"), false));
ScheduleRecurrenceDialog editSchedule = new ScheduleRecurrenceDialog(null, jsJob, callback, false, false, AbstractWizardDialog.ScheduleDialogType.SCHEDULER);
editSchedule.setShowSuccessDialog(false);
editSchedule.addCustomPanel(scheduleLabelPanel, DockPanel.NORTH);
editSchedule.center();
}
});
HorizontalPanel scheduleButtonPanel = new HorizontalPanel();
scheduleButtonPanel.add(editScheduleButton);
if (!fakeJob) {
scheduleButtonPanel.add(deleteScheduleButton);
}
scheduledPanel.add(scheduleButtonPanel);
add(scheduledPanel, DockPanel.NORTH);
VerticalPanel fillPanel = new VerticalPanel();
add(fillPanel, DockPanel.NORTH);
fillPanel.getElement().getParentElement().getStyle().setHeight(100, Unit.PCT);
}
});
} catch (RequestException re) {
// ignored
}
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class EmailAdminPanelController method passivate.
public void passivate(final AsyncCallback<Boolean> callback) {
if (isDirty) {
MessageDialogBox messageBox = new MessageDialogBox(Messages.getString("confirm"), Messages.getString("dirtyStateMessage"), false, false, true, Messages.getString("yes"), null, Messages.getString("no"));
messageBox.setCallback(new IDialogCallback() {
@Override
public void okPressed() {
if (isPortValid(portTextBox.getValue())) {
setEmailConfig();
callback.onSuccess(true);
setDirty(false);
} else {
new MessageDialogBox(Messages.getString("error"), Messages.getString("portValidationLength"), false, false, true).center();
}
}
@Override
public void cancelPressed() {
callback.onSuccess(true);
setDirty(false);
}
});
messageBox.center();
} else {
callback.onSuccess(true);
}
}
use of org.pentaho.gwt.widgets.client.dialogs.IDialogCallback in project pentaho-platform by pentaho.
the class DeleteFolderCommand method performOperation.
protected void performOperation(boolean feedback) {
final SolutionFolderActionEvent event = new SolutionFolderActionEvent();
event.setAction(this.getClass().getName());
final String filesList = repositoryFile.getId();
final String folderName = repositoryFile.getTitle() == null ? repositoryFile.getName() : repositoryFile.getTitle();
final HTML messageTextBox = new HTML(Messages.getString("moveToTrashQuestionFolder", escapeHtmlEntities(folderName)));
final PromptDialogBox folderDeleteWarningDialogBox = new PromptDialogBox(Messages.getString("moveToTrash"), Messages.getString("yesMoveToTrash"), Messages.getString("no"), true, true);
folderDeleteWarningDialogBox.setContent(messageTextBox);
final IDialogCallback callback = new IDialogCallback() {
public void cancelPressed() {
folderDeleteWarningDialogBox.hide();
}
public void okPressed() {
// $NON-NLS-1$
String deleteFilesURL = contextURL + "api/repo/files/delete";
RequestBuilder deleteFilesRequestBuilder = new RequestBuilder(RequestBuilder.PUT, deleteFilesURL);
deleteFilesRequestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
// $NON-NLS-1$//$NON-NLS-2$
deleteFilesRequestBuilder.setHeader("Content-Type", "text/plain");
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("couldNotDeleteFolder"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFolder"));
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 {
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("couldNotDeleteFolder"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFolder"));
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("couldNotDeleteFolder"), false, false, true);
dialogBox.center();
event.setMessage(Messages.getString("couldNotDeleteFolder"));
EventBusUtil.EVENT_BUS.fireEvent(event);
}
}
};
folderDeleteWarningDialogBox.setCallback(callback);
folderDeleteWarningDialogBox.center();
}
Aggregations