List of usage examples for org.eclipse.jface.dialogs IDialogConstants YES_LABEL
String YES_LABEL
To view the source code for org.eclipse.jface.dialogs IDialogConstants YES_LABEL.
Click Source Link
From source file:org.eclipse.sirius.tests.swtbot.RepairTest.java
License:Open Source License
/** * Scenario 4 : repair with multiple opened sessions (at least one changed), * and backup/* ww w .ja va2s . c om*/ * <UL> * <LI>Close all the opened sessions</LI> * <LI>Open a session on a simple aird file, sc4-1.aird</LI> * <LI>The session is opened and not dirty (if it's dirty, save it)</LI> * <LI>Open a session on another simple aird file, sc4-2.aird</LI> * <LI>Modify one of the diagram of the second session to have this one in * dirty mode</LI> * <LI>Launch the action Repair model on an sc3-1.aird</LI> * <LI>A popup warns the user that the session will be close</LI> * <LI>Click OK on the popup</LI> * <LI>Check that the session are closed</LI> * <LI>Check that a backup was done</LI> * <LI>Check that the modification done in the diagram of the second session * (sc4-2.aird) is always here.</LI> * </UL> * * @throws Exception * in case of problem */ public void testRepairWithMultipleSessionsOpenedWithOneDirtyAndSave() throws Exception { // Check that there is no session opened assertEquals("0 session should be opened.", 0, SessionManager.INSTANCE.getSessions().size()); String nameOfPackageToRename = "pc"; String newNameOfPackage = "pcNew"; IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName()); assertEquals("It should be no backup file before repair.", 0, getNumberOfBackupFiles(project, SESSION_FILE4_1)); // Open the session final UIResource sessionAirdResource1 = new UIResource(designerProject, SESSION_FILE4_1); final UILocalSession localSession1 = designerPerspective.openSessionFromFile(sessionAirdResource1); // Open a diagram of this session openRepresentation(localSession1.getOpenedSession(), REPRESENTATION_NAME_DIAGRAM, REPRESENTATION_INSTANCE_NAME_DIAGRAM4_1, DDiagram.class); // Check that the session is not dirty (if dirty, save it) if (localSession1.getOpenedSession().getStatus() == SessionStatus.DIRTY) { localSession1.save(); } // Open the session final UIResource sessionAirdResource2 = new UIResource(designerProject, SESSION_FILE4_2); UILocalSession localSession2 = designerPerspective.openSessionFromFile(sessionAirdResource2); // Open a diagram of this session SWTBotSiriusDiagramEditor editor = (SWTBotSiriusDiagramEditor) openRepresentation( localSession2.getOpenedSession(), REPRESENTATION_NAME_DIAGRAM, REPRESENTATION_INSTANCE_NAME_DIAGRAM4_2, DDiagram.class); changeNameOfPCPackage(editor, nameOfPackageToRename, newNameOfPackage); // Check that the session is dirty assertTrue("The session \"" + sessionAirdResource2.getName() + "\" must be dirty.", localSession2.getOpenedSession().getStatus() == SessionStatus.DIRTY); // Launch the repair action String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource1, repairActionLabel); // bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); message.setFocus(); bot.button(IDialogConstants.YES_LABEL).click(); // Wait the end of repair SWTBotUtils.waitProgressMonitorClose("Progress Information"); assertNoProblemsLogged(); // Check that two sessions are open assertEquals("No session should be opened.", 0, SessionManager.INSTANCE.getSessions().size()); // Check that there is a backup assertEquals("It should be one backup file after repair.", 1, getNumberOfBackupFiles(project, SESSION_FILE4_1)); localSession2 = designerPerspective.openSessionFromFile(sessionAirdResource2); editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession2.getOpenedSession(), REPRESENTATION_NAME_DIAGRAM, REPRESENTATION_INSTANCE_NAME_DIAGRAM4_2, DDiagram.class); assertNotNull("The modification made in the second editor was lost.", editor.getEditPart(newNameOfPackage)); // Check if there is problem logged during this test assertNoProblemsLogged(); }
From source file:org.eclipse.sirius.ui.tools.internal.actions.repair.RepresentationFilesRepairValidator.java
License:Open Source License
/** * @param dirtySessionsName/* ww w . j ava 2 s. c o m*/ * The dirty sessions names * @return true if the dirty sessions must be saved, false otherwise * @throws CoreException * If the user cancel the process */ private boolean userValidation(Collection<String> dirtySessionsName) throws CoreException { // Get the active shell Shell shell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); if (shell == null) { shell = new Shell(); } boolean saveSessions = false; String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); StringBuffer message = new StringBuffer("It's impossible to launch the \"" + repairActionLabel + "\" action with opened representations file. So they will be closed before the repair process."); if (dirtySessionsName.size() > 0) { message.append(" The following representations file"); if (dirtySessionsName.size() == 1) { message.append(" has"); } else { message.append("s have"); } message.append(" been modified : "); for (String dirtySessionName : dirtySessionsName) { message.append("\n\t- '"); message.append(dirtySessionName); message.append("'"); message.append(", "); } message.delete(message.length() - 2, message.length() - 1); message.append("\n\nSave changes?"); String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; final MessageDialog dialog = new MessageDialog(shell, MESSAGE_TITLE, null, message.toString(), MessageDialog.QUESTION, buttons, 0); int result = dialog.open(); if (result == SWT.DEFAULT || buttons[result].equals(IDialogConstants.CANCEL_LABEL)) { throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID, RepresentationFilesRepairValidator.OPERATION_CANCELED, "Migration canceled by user.", null)); } if (buttons[result].equals(IDialogConstants.YES_LABEL)) { saveSessions = true; } } else { message.append("\nDo you want to continue?"); if (!MessageDialog.openConfirm(shell, MESSAGE_TITLE, message.toString())) { throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID, RepresentationFilesRepairValidator.OPERATION_CANCELED, "Migration canceled by user.", null)); } } return saveSessions; }
From source file:org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog.java
License:Open Source License
/** * Opens a question dialog with YES, NO and CANCEL. * * @param parentShell/*from w w w . j a v a 2s . com*/ * The shell. * @param title * The title for the message dialog. * @param message * The dialog message text. * @param buttonLabel * An string array listing the labels of the message dialog buttons. If <code>null</code>, the default * labeling, typically "OK" for a single button message dialog, will be applied. * @param key * The unique key for the stored result value (e.g. "<PluginName>.<ActionOrDialogName>"). * @param contextHelpId * The optional help context id. If <code>null</code>, no help * button will be shown. * @return The stored or selected result. */ public static int openYesNoCancelDialog(Shell parentShell, String title, String message, String[] buttonLabel, String key, String contextHelpId) { if (buttonLabel == null) buttonLabel = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; OptionalMessageDialog dialog = new OptionalMessageDialog(parentShell, title, null, message, QUESTION, buttonLabel, 0, key, contextHelpId); return dialog.open(); }
From source file:org.eclipse.tcf.te.ui.jface.dialogs.OptionalMessageDialog.java
License:Open Source License
/** * Opens a question dialog with YES and NO. * * @param parentShell/*from w ww . ja v a 2 s .c o m*/ * The shell. * @param title * The title for the message dialog. * @param message * The dialog message text. * @param buttonLabel * An string array listing the labels of the message dialog buttons. If <code>null</code>, the default * labeling, typically "OK" for a single button message dialog, will be applied. * @param key * The unique key for the stored result value (e.g. "<PluginName>.<ActionOrDialogName>"). * @param contextHelpId * The optional help context id. If <code>null</code>, no help * button will be shown. * @return The stored or selected result. */ public static int openYesNoDialog(Shell parentShell, String title, String message, String[] buttonLabel, String key, String contextHelpId) { if (buttonLabel == null) buttonLabel = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; OptionalMessageDialog dialog = new OptionalMessageDialog(parentShell, title, null, message, QUESTION, buttonLabel, 0, key, contextHelpId); return dialog.open(); }
From source file:org.eclipse.team.internal.ccvs.ui.AddToVersionControlDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); super.createButtonsForButtonBar(parent); }
From source file:org.eclipse.team.internal.ccvs.ui.CVSHistoryPage.java
License:Open Source License
private boolean confirmOverwrite() { if (file != null && file.getIResource().exists()) { try {//from ww w . j a va2 s.c om if (file.isModified(null)) { String title = CVSUIMessages.HistoryView_overwriteTitle; String msg = CVSUIMessages.HistoryView_overwriteMsg; IHistoryPageSite parentSite = getHistoryPageSite(); final MessageDialog dialog = new MessageDialog(parentSite.getShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); final int[] result = new int[1]; parentSite.getShell().getDisplay().syncExec(new Runnable() { public void run() { result[0] = dialog.open(); } }); if (result[0] != 0) { // cancel return false; } } } catch (CVSException e) { CVSUIPlugin.log(e); } } return true; }
From source file:org.eclipse.team.internal.ccvs.ui.CVSProjectSetSerializer.java
License:Open Source License
private int confirmOverwrite(IProject project, boolean yesToAll, Shell shell) { if (yesToAll) return 2; if (!project.exists()) return 0; final MessageDialog dialog = new MessageDialog(shell, CVSUIMessages.CVSProjectSetSerializer_Confirm_Overwrite_Project_8, null, NLS.bind(// ww w . j a va 2 s . c o m CVSUIMessages.CVSProjectSetSerializer_The_project__0__already_exists__Do_you_wish_to_overwrite_it__9, new String[] { project.getName() }), MessageDialog.QUESTION, // new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0); final int[] result = new int[1]; shell.getDisplay().syncExec(new Runnable() { public void run() { result[0] = dialog.open(); } }); return result[0]; }
From source file:org.eclipse.team.internal.ccvs.ui.DateTagDialog.java
License:Open Source License
protected void buttonPressed(int buttonId) { if (buttonId == IDialogConstants.OK_ID) { dateEntered = privateGetDate();//from w w w . j av a2s. co m if (dateEntered.after(Calendar.getInstance().getTime())) { MessageDialog dialog = new MessageDialog(getShell(), CVSUIMessages.DateTagDialog_6, null, CVSUIMessages.DateTagDialog_7, MessageDialog.WARNING, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, }, 1); if (dialog.open() == 1) return; } } super.buttonPressed(buttonId); }
From source file:org.eclipse.team.internal.ccvs.ui.operations.DiffOperation.java
License:Open Source License
protected boolean shouldRun() { if (super.shouldRun() == false) { return false; }/* w w w . j a va 2s.com*/ Job[] jobs = Job.getJobManager().find(destination); if (jobs.length != 0) { MessageDialog question = new MessageDialog(getShell(), CVSUIMessages.DiffOperation_CreatePatchConflictTitle, null, NLS.bind(CVSUIMessages.DiffOperation_CreatePatchConflictMessage, destination.toString()), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); if (question.open() == 0) { Job.getJobManager().cancel(destination); } else { return false; } } return true; }
From source file:org.eclipse.team.internal.ccvs.ui.subscriber.UpdateDialog.java
License:Open Source License
protected void createButtonsForButtonBar(Composite parent) { createButton(parent, YES, IDialogConstants.YES_LABEL, false); createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, true); super.createButtonsForButtonBar(parent); }