use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project tdi-studio-se by Talend.
the class GEFDeleteAction method createDeleteCommand.
@Override
public Command createDeleteCommand(List objects) {
objects = filterSameObject(objectsToDelete);
if (objects.isEmpty()) {
return null;
}
if (!(objects.get(0) instanceof EditPart)) {
return null;
}
EditPart object = (EditPart) objects.get(0);
// for TUP-1015
boolean isConnAttachedJLTriggerComp = false;
ConnectionPart connectionPart = null;
if (object instanceof ConnectionPart) {
connectionPart = (ConnectionPart) object;
} else if (object instanceof ConnLabelEditPart) {
connectionPart = (ConnectionPart) object.getParent();
}
if (connectionPart != null) {
Node srcNode = null;
Object srcModel = connectionPart.getSource().getModel();
if (srcModel instanceof Node) {
srcNode = (Node) srcModel;
}
Node tarNode = null;
Object tarModel = connectionPart.getTarget().getModel();
if (tarModel instanceof Node) {
tarNode = (Node) tarModel;
}
if (srcNode == null || tarNode == null) {
return null;
}
IProcess process = srcNode.getProcess();
if (AbstractProcessProvider.isExtensionProcessForJoblet(process)) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && (service.isTriggerNode(srcNode) || service.isTriggerNode(tarNode))) {
isConnAttachedJLTriggerComp = true;
}
}
}
IPreferenceStore preferenceStore = DesignerPlugin.getDefault().getPreferenceStore();
String preKey = TalendDesignerPrefConstants.NOT_SHOW_WARNING_WHEN_DELETE_LINK_WITH_JOBLETTRIGGERLINKCOMPONENT;
if (isConnAttachedJLTriggerComp && !preferenceStore.getBoolean(preKey)) {
MessageDialogWithToggle jlTriggerConfirmDialog = new MessageDialogWithToggle(null, //$NON-NLS-1$
Messages.getString("GEFDeleteAction.deleteConnectionDialog.title"), // accept the default window icon
null, Messages.getString("GEFDeleteAction.deleteConnectionDialog.msg"), MessageDialog.WARNING, new String[] { //$NON-NLS-1$
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0, //$NON-NLS-1$
Messages.getString("GEFDeleteAction.deleteConnectionDialog.toggleMsg"), preferenceStore.getDefaultBoolean(preKey));
jlTriggerConfirmDialog.setPrefStore(preferenceStore);
jlTriggerConfirmDialog.setPrefKey(preKey);
if (jlTriggerConfirmDialog.open() != IDialogConstants.YES_ID) {
return null;
}
preferenceStore.setValue(preKey, jlTriggerConfirmDialog.getToggleState());
}
List nodeParts = new ArrayList();
List noteParts = new ArrayList();
List others = new ArrayList(objects);
for (Object o : objects) {
if (o instanceof NodePart) {
others.remove(o);
Node model = (Node) ((NodePart) o).getModel();
if (model.getJobletNode() != null) {
continue;
}
if (model.getJunitNode() != null) {
continue;
}
nodeParts.add(o);
} else if (o instanceof NoteEditPart) {
noteParts.add(o);
others.remove(o);
} else if (o instanceof SubjobContainerPart) {
others.remove(o);
SubjobContainerPart subjob = (SubjobContainerPart) o;
for (Iterator iterator = subjob.getChildren().iterator(); iterator.hasNext(); ) {
NodeContainerPart nodeContainerPart = (NodeContainerPart) iterator.next();
if (nodeContainerPart instanceof JobletContainerPart) {
JobletContainer jobletCon = (JobletContainer) ((JobletContainerPart) nodeContainerPart).getModel();
JobletContainerFigure jobletFigure = (JobletContainerFigure) ((JobletContainerPart) nodeContainerPart).getFigure();
if (!jobletCon.isCollapsed()) {
jobletFigure.doCollapse();
}
}
NodePart nodePart = nodeContainerPart.getNodePart();
if (nodePart != null) {
Node model = (Node) nodePart.getModel();
if (model.getJunitNode() != null) {
continue;
}
nodeParts.add(nodePart);
}
}
}
}
if (others.size() == 0) {
// so notes & nodes only
CompoundCommand cpdCmd = new CompoundCommand();
//$NON-NLS-1$
cpdCmd.setLabel(Messages.getString("GEFDeleteAction.DeleteItems"));
if (nodeParts.size() != 0) {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(nodeParts);
cpdCmd.add(((NodePart) nodeParts.get(0)).getCommand(deleteReq));
}
if (noteParts.size() != 0) {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(noteParts);
cpdCmd.add(((NoteEditPart) noteParts.get(0)).getCommand(deleteReq));
}
return cpdCmd;
} else {
GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
deleteReq.setEditParts(objects);
Command cmd = object.getCommand(deleteReq);
return cmd;
}
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project tdi-studio-se by Talend.
the class ApplicationWorkbenchWindowAdvisor method preWindowShellClose.
public boolean preWindowShellClose() {
if (PlatformUI.getWorkbench().getWorkbenchWindowCount() > 1) {
return true;
}
// the user has asked to close the last window, while will cause the
// workbench to close in due course - prompt the user for confirmation
IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
boolean promptOnExit = store.getBoolean(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW);
if (promptOnExit) {
String message;
// String productName = null;
//
// if (productName == null) {
// // message = IDEWorkbenchMessages.PromptOnExitDialog_message0;
// message = Messages.getString("ApplicationWorkbenchWindowAdvisor.PromptOnExitDialog_message0");
// }
// else {
// // message = NLS.bind(IDEWorkbenchMessages.PromptOnExitDialog_message1, productName);
// message = Messages.getString("ApplicationWorkbenchWindowAdvisor.PromptOnExitDialog_message1",
// new Object[] { productName });
// }
//$NON-NLS-1$
message = Messages.getString("ApplicationWorkbenchWindowAdvisor.PromptOnExitDialog_message0");
MessageDialogWithToggle dlg = MessageDialogWithToggle.openOkCancelConfirm(getWindowConfigurer().getWindow().getShell(), //$NON-NLS-1$
Messages.getString("ApplicationWorkbenchWindowAdvisor.PromptOnExitDialog_shellTitle"), //$NON-NLS-1$
message, Messages.getString("ApplicationWorkbenchWindowAdvisor.PromptOnExitDialog_choice"), false, null, //$NON-NLS-1$
null);
if (dlg.getReturnCode() != IDialogConstants.OK_ID) {
return false;
}
if (dlg.getToggleState()) {
store.setValue(IDEInternalPreferences.EXIT_PROMPT_ON_CLOSE_LAST_WINDOW, false);
IDEWorkbenchPlugin.getDefault().savePluginPreferences();
}
}
return true;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project eclipse.platform.text by eclipse.
the class LineNumberColumn method ensureQuickDiffProvider.
/**
* Ensures that quick diff information is displayed and the quick diff provider is the one with
* the specified id. If a different quick diff provider is in use, the user may be asked whether
* he wants to switch.
*
* @param diffProviderId the quick diff provider id to use
* @return <code>true</code> if quick diff could be enabled for the given id,
* <code>false</code> otherwise
*/
private boolean ensureQuickDiffProvider(String diffProviderId) {
if (!isShowingChangeInformation())
// FIXME pass provider id
installChangeRulerModel(fDelegate);
IAnnotationModel annotationModel = fViewer.getAnnotationModel();
IAnnotationModel oldDiffer = getDiffer();
if (oldDiffer == null && annotationModel != null)
// quick diff is enabled, but no differ? not working for whatever reason
return false;
if (annotationModel == null)
annotationModel = new AnnotationModel();
if (!(annotationModel instanceof IAnnotationModelExtension))
return false;
QuickDiff util = new QuickDiff();
Object oldDifferId = util.getConfiguredQuickDiffProvider(oldDiffer);
if (oldDifferId.equals(diffProviderId)) {
if (oldDiffer instanceof ILineDifferExtension)
((ILineDifferExtension) oldDiffer).resume();
return true;
}
// Check whether the desired provider is available at all
IAnnotationModel newDiffer = util.createQuickDiffAnnotationModel(getEditor(), diffProviderId);
if (util.getConfiguredQuickDiffProvider(newDiffer).equals(oldDifferId)) {
if (oldDiffer instanceof ILineDifferExtension)
((ILineDifferExtension) oldDiffer).resume();
return true;
}
// quick diff is showing with the wrong provider - ask the user whether he wants to switch
IPreferenceStore store = EditorsUI.getPreferenceStore();
if (oldDiffer != null && !store.getString(REVISION_ASK_BEFORE_QUICKDIFF_SWITCH_KEY).equals(MessageDialogWithToggle.ALWAYS)) {
MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openOkCancelConfirm(fViewer.getTextWidget().getShell(), RulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_title, RulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_message, RulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_rememberquestion, true, store, REVISION_ASK_BEFORE_QUICKDIFF_SWITCH_KEY);
if (toggleDialog.getReturnCode() != Window.OK)
return false;
}
IAnnotationModelExtension modelExtension = (IAnnotationModelExtension) annotationModel;
modelExtension.removeAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
modelExtension.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, newDiffer);
if (fDelegate instanceof IChangeRulerColumn)
// picks up the new model attachment
((IChangeRulerColumn) fDelegate).setModel(annotationModel);
return true;
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.
the class IntroPage method showMissingBrowserWarning.
private void showMissingBrowserWarning(final IWebBrowser browser) {
IPersistentPreferenceStore prefStore = (IPersistentPreferenceStore) KNIMEUIPlugin.getDefault().getPreferenceStore();
boolean omitWarnings = prefStore.getBoolean(PreferenceConstants.P_OMIT_MISSING_BROWSER_WARNING);
if (!omitWarnings) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openWarning(Display.getDefault().getActiveShell(), "Missing browser integration", "KNIME is unable to display web pages in an internal browser. This may be caused by missing " + "system libraries. Please visit https://www.knime.com/faq#q6 for details.\n" + "Some web pages may open in an external browser.", "Do not show again", false, prefStore, PreferenceConstants.P_OMIT_MISSING_BROWSER_WARNING);
if (dialog.getToggleState()) {
prefStore.setValue(PreferenceConstants.P_OMIT_MISSING_BROWSER_WARNING, true);
try {
prefStore.save();
} catch (IOException ex) {
// too bad, ignore it
}
}
}
}
use of org.eclipse.jface.dialogs.MessageDialogWithToggle in project knime-core by knime.
the class GUIWorkflowLoadHelper method shouldLoadNightlyBuildWorkflow.
/**
* Called from {@link #getUnknownKNIMEVersionLoadPolicy(LoadVersion, Version, boolean)} when loading a
* workflow created by a current or old nightly build version. Requires special treatment as per AP-8642.
*/
private UnknownKNIMEVersionLoadPolicy shouldLoadNightlyBuildWorkflow(final LoadVersion workflowKNIMEVersion, final Version createdByKNIMEVersion) {
final IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
boolean confirmLoadNightlyBuild = store.getBoolean(PreferenceConstants.P_CONFIRM_LOAD_NIGHTLY_BUILD_WORKFLOW);
if (!confirmLoadNightlyBuild) {
return UnknownKNIMEVersionLoadPolicy.Try;
}
StringBuilder e = new StringBuilder("You are attempting to load a workflow created with a nightly build (");
if (createdByKNIMEVersion != null) {
e.append(createdByKNIMEVersion);
} else {
e.append("<unknown>");
}
e.append("-nightly). This can lead to issues with the officially released version of some nodes.\n\n");
e.append(LOAD_FUTURE_FLOW_TEXT);
// must not change to something else than this as MessageDialogWithToggle has some special magic to re-index
// buttons -- see org.eclipse.jface.dialogs.MessageDialogWithToggle.createButtonsForButtonBar(Composite)
// must use jface button label as per org.eclipse.jface.dialogs.MessageDialogWithToggle.mapButtonLabelToButtonID
// (this is very different to the behavior of MessageDialog(NoToggle))
String cancel = IDialogConstants.CANCEL_LABEL;
String loadAnyway = "&Load Anyway";
final String[] labels = new String[] { cancel, loadAnyway };
final AtomicReference<UnknownKNIMEVersionLoadPolicy> result = new AtomicReference<>(UnknownKNIMEVersionLoadPolicy.Abort);
m_display.syncExec(new Runnable() {
@Override
public void run() {
MessageDialogWithToggle dialog = new MessageDialogWithToggle(m_display.getActiveShell(), "Loading Workflow created by a Nightly Build", null, e.toString(), MessageDialog.WARNING, labels, 0, "Always load workflows created by a Nightly Build", false);
switch(dialog.open()) {
// Cancel button
case IDialogConstants.CANCEL_ID:
case // cancel by 'esc'
SWT.DEFAULT:
result.set(UnknownKNIMEVersionLoadPolicy.Abort);
break;
default:
result.set(UnknownKNIMEVersionLoadPolicy.Try);
if (dialog.getToggleState()) {
store.setValue(PreferenceConstants.P_CONFIRM_LOAD_NIGHTLY_BUILD_WORKFLOW, false);
KNIMEUIPlugin.getDefault().savePluginPreferences();
}
}
}
});
return result.get();
}
Aggregations