use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project cubrid-manager by CUBRID.
the class ApplicationWorkbenchWindowAdvisor method preWindowShellClose.
/**
* Performs arbitrary actions as the window's shell is being closed
* directly, and possibly veto the close.
*
* @return <code>true</code> to allow the window to close, and
* <code>false</code> to prevent the window from closing
* @see org.eclipse.ui.IWorkbenchWindow#close
* @see WorkbenchAdvisor#preShutdown()
*/
public boolean preWindowShellClose() {
Shell shell = getWindowConfigurer().getWindow().getShell();
GeneralPreference.setMaximizeWindowOnStartUp(shell.getMaximized());
if (timer != null) {
timer.cancel();
HeartBeatTaskManager.getInstance().cancel();
}
/*Close the information window*/
InfoWindowManager.dispose();
/*All opened queryEditor*/
List<QueryEditorPart> editorPartList = QueryEditorUtil.getAllQueryEditorPart();
boolean isNeedSaveQueryEditor = isNeedSaveQueryEditor(editorPartList);
boolean hasJobRunning = false;
final JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(JobFamily.ALL_SERVER);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
hasJobRunning = true;
}
boolean isExit = false;
if (hasJobRunning) {
isExit = CommonUITool.openConfirmBox(getWindowConfigurer().getWindow().getShell(), Messages.msgExistConfirmWithJob);
if (isExit) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
Job.getJobManager().cancel(jobFamily);
} catch (Exception e) {
LOGGER.error("Stopping background jobs was failed.", e);
}
}
});
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
}
}
} else {
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
return true;
} else {
if (GeneralPreference.isAlwaysExit()) {
return true;
}
MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(getWindowConfigurer().getWindow().getShell(), com.cubrid.common.ui.common.Messages.titleExitConfirm, Messages.msgExistConfirm, com.cubrid.common.ui.common.Messages.msgToggleExitConfirm, false, CommonUIPlugin.getDefault().getPreferenceStore(), GeneralPreference.IS_ALWAYS_EXIT);
isExit = dialog.getReturnCode() == 0 ? true : false;
}
}
if (isExit) {
for (List<IEditorReference> list : perspectiveEditorMap.values()) {
IEditorReference[] references = new IEditorReference[list.size()];
list.toArray(references);
getWindowConfigurer().getWindow().getActivePage().closeEditors(references, false);
}
}
return isExit;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project cubrid-manager by CUBRID.
the class ApplicationWorkbenchWindowAdvisor method preWindowShellClose.
/**
* Performs arbitrary actions as the window's shell is being closed
* directly, and possibly veto the close.
*
* @return <code>true</code> to allow the window to close, and
* <code>false</code> to prevent the window from closing
* @see org.eclipse.ui.IWorkbenchWindow#close
* @see WorkbenchAdvisor#preShutdown()
*/
public boolean preWindowShellClose() {
Shell shell = getWindowConfigurer().getWindow().getShell();
GeneralPreference.setMaximizeWindowOnStartUp(shell.getMaximized());
if (timer != null) {
timer.cancel();
HeartBeatTaskManager.getInstance().cancel();
}
/*Close the information window*/
InfoWindowManager.dispose();
/*All opened queryEditor*/
List<QueryEditorPart> editorPartList = QueryEditorUtil.getAllQueryEditorPart();
boolean isNeedSaveQueryEditor = isNeedSaveQueryEditor(editorPartList);
boolean hasJobRunning = false;
final JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(JobFamily.ALL_SERVER);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
hasJobRunning = true;
}
boolean isExit = false;
if (hasJobRunning) {
isExit = CommonUITool.openConfirmBox(getWindowConfigurer().getWindow().getShell(), Messages.msgExistConfirmWithJob);
if (isExit) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
Job.getJobManager().cancel(jobFamily);
} catch (Exception e) {
LOGGER.error("Stopping background jobs was failed.", e);
}
}
});
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
}
}
} else {
if (isNeedSaveQueryEditor) {
processSaveQueryEditor();
return true;
} else {
if (GeneralPreference.isAlwaysExit()) {
return true;
}
MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(getWindowConfigurer().getWindow().getShell(), com.cubrid.common.ui.common.Messages.titleExitConfirm, Messages.msgExistConfirm, com.cubrid.common.ui.common.Messages.msgToggleExitConfirm, false, CommonUIPlugin.getDefault().getPreferenceStore(), GeneralPreference.IS_ALWAYS_EXIT);
isExit = dialog.getReturnCode() == 0 ? true : false;
}
}
return isExit;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method validateEditorInputDerived.
/**
* Validates the editor input for derived state.
* If the given input is derived then this method
* can show a dialog asking whether to edit the
* derived file.
*
* @return <code>true</code> if the input is OK for editing, <code>false</code> otherwise
* @since 3.3
*/
private boolean validateEditorInputDerived() {
if (fIsDerivedStateValidated)
return fIsEditingDerivedFileAllowed;
if (getDocumentProvider() instanceof IDocumentProviderExtension) {
IDocumentProviderExtension extension = (IDocumentProviderExtension) getDocumentProvider();
IStatus status = extension.getStatus(getEditorInput());
String pluginId = status.getPlugin();
boolean isDerivedStatus = status.getCode() == IFileBufferStatusCodes.DERIVED_FILE && (FileBuffers.PLUGIN_ID.equals(pluginId) || EditorsUI.PLUGIN_ID.equals(pluginId));
if (!isDerivedStatus)
return true;
}
final String warnKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
IPreferenceStore store = getPreferenceStore();
if (!store.getBoolean(warnKey))
return true;
MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openYesNoQuestion(getSite().getShell(), TextEditorMessages.AbstractDecoratedTextEditor_warning_derived_title, TextEditorMessages.AbstractDecoratedTextEditor_warning_derived_message, TextEditorMessages.AbstractDecoratedTextEditor_warning_derived_dontShowAgain, false, null, null);
EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState());
fIsDerivedStateValidated = true;
return fIsEditingDerivedFileAllowed = toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.
the class LoadWorkflowRunnable method postLoadCheckForMetaNodeUpdates.
static void postLoadCheckForMetaNodeUpdates(final WorkflowEditor editor, final WorkflowManager parent, final List<NodeID> links) {
StringBuilder m = new StringBuilder("The workflow contains ");
if (links.size() == 1) {
m.append("one metanode link (\"");
m.append(parent.findNodeContainer(links.get(0)).getNameWithID());
m.append("\").");
} else {
m.append(links.size()).append(" metanode links.");
}
m.append("\n\n").append("Do you want to check for updates now?");
final String message = m.toString();
final AtomicBoolean result = new AtomicBoolean(false);
final IPreferenceStore corePrefStore = KNIMEUIPlugin.getDefault().getPreferenceStore();
final String pKey = PreferenceConstants.P_META_NODE_LINK_UPDATE_ON_LOAD;
String pref = corePrefStore.getString(pKey);
boolean showInfoMsg = true;
if (MessageDialogWithToggle.ALWAYS.equals(pref)) {
result.set(true);
showInfoMsg = false;
} else if (MessageDialogWithToggle.NEVER.equals(pref)) {
result.set(false);
} else {
final Display display = Display.getDefault();
display.syncExec(new Runnable() {
@Override
public void run() {
Shell activeShell = display.getActiveShell();
MessageDialogWithToggle dlg = MessageDialogWithToggle.openYesNoCancelQuestion(activeShell, "Metanode Link Update", message, "Remember my decision", false, corePrefStore, pKey);
switch(dlg.getReturnCode()) {
case IDialogConstants.YES_ID:
result.set(true);
break;
default:
result.set(false);
}
}
});
}
if (result.get()) {
new CheckUpdateMetaNodeLinkAllAction(editor, showInfoMsg).run();
}
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.
the class VerifyingCompoundCommand method execute.
/**
* Overrides the execute method of <code>CompoundCommand</code> to add a
* verification dialog with the given message.
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
// before showing the confirmation dialog, mark the node part figures
for (NodeContainerEditPart nodePart : m_nodeParts) {
nodePart.mark();
}
try {
// the following code has mainly been copied from
// IDEWorkbenchWindowAdvisor#preWindowShellClose
IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
if (!store.contains(PreferenceConstants.P_CONFIRM_DELETE) || store.getBoolean(PreferenceConstants.P_CONFIRM_DELETE)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm(Display.getDefault().getActiveShell(), "Confirm ...", m_dialogDisplayText, "Do not ask again", false, null, null);
if (dialog.getReturnCode() != IDialogConstants.OK_ID) {
return;
}
if (dialog.getToggleState()) {
store.setValue(PreferenceConstants.P_CONFIRM_DELETE, false);
KNIMEUIPlugin.getDefault().savePluginPreferences();
}
}
// in all other cases execute the commands
LOGGER.debug("Executing <" + size() + "> commands.");
super.execute();
} finally {
for (NodeContainerEditPart nodePart : m_nodeParts) {
nodePart.unmark();
}
}
}
Aggregations