diff options
| author | Florian Barbin | 2017-07-13 09:54:41 +0000 |
|---|---|---|
| committer | Florian Barbin | 2017-07-20 13:23:25 +0000 |
| commit | c0db050727c5c1113c2803976147ac419f30748c (patch) | |
| tree | 539b876f4a68ba6e890436926806d2847b6a6470 | |
| parent | 937506018a1ca8bdf97710cd03be387742454b96 (diff) | |
| download | org.eclipse.sirius-c0db050727c5c1113c2803976147ac419f30748c.tar.gz org.eclipse.sirius-c0db050727c5c1113c2803976147ac419f30748c.tar.xz org.eclipse.sirius-c0db050727c5c1113c2803976147ac419f30748c.zip | |
[516669] Modifies the RepFilesRepairValidator to be more generic
* This validator will be used to validate the action that execute the
split of existing aird files.
Bug: 516669
Change-Id: Iea87f6d66483daec0e9c1185281703c892094a6a
Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
| -rw-r--r-- | plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RepairTest.java | 95 | ||||
| -rw-r--r-- | plugins/org.eclipse.sirius.ui/plugin.properties | 4 | ||||
| -rw-r--r-- | plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesNeedCloseSessionValidator.java (renamed from plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairValidator.java) | 54 | ||||
| -rw-r--r-- | plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairAction.java | 12 |
4 files changed, 86 insertions, 79 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RepairTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RepairTest.java index f4d8e07df3..ad33ea3fd5 100644 --- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RepairTest.java +++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/RepairTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2017 THALES GLOBAL SERVICES. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -31,7 +31,8 @@ import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource; import org.eclipse.sirius.tests.swtbot.support.api.condition.OperationDoneCondition; import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor; import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils; -import org.eclipse.sirius.ui.tools.internal.actions.repair.RepresentationFilesRepairValidator; +import org.eclipse.sirius.ui.tools.internal.actions.repair.RepresentationFilesNeedCloseSessionValidator; +import org.eclipse.sirius.ui.tools.internal.actions.repair.RepresentationFilesRepairAction; import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin; import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.SWTBot; @@ -48,8 +49,8 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; */ public class RepairTest extends AbstractScenarioTestCase { /** - * Cannot use mocks here because {@link #logging(IStatus, String)} is called - * asynchronously. Thrown exception is lost and doesn't stop + * Cannot use mocks here because {@link #logging(IStatus, String)} is called asynchronously. Thrown exception is + * lost and doesn't stop * * @author dlecan */ @@ -272,8 +273,8 @@ public class RepairTest extends AbstractScenarioTestCase { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource, repairActionLabel); // - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); bot.button("Cancel").click(); // Check that the session is always opened @@ -323,8 +324,8 @@ public class RepairTest extends AbstractScenarioTestCase { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource, repairActionLabel); // - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); // Close the popup with the cross bot.activeShell().close(); @@ -439,8 +440,8 @@ public class RepairTest extends AbstractScenarioTestCase { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource1, repairActionLabel); // - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); bot.button("Cancel").click(); // Check that the sessions are always opened @@ -455,22 +456,19 @@ public class RepairTest extends AbstractScenarioTestCase { } /** - * Scenario 4 : repair with multiple opened sessions (at least one changed), - * and backup + * Scenario 4 : repair with multiple opened sessions (at least one changed), and backup * <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>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> + * <LI>Check that the modification done in the diagram of the second session (sc4-2.aird) is always here.</LI> * </UL> * * @throws Exception @@ -506,8 +504,8 @@ public class RepairTest extends AbstractScenarioTestCase { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource1, repairActionLabel); // - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); bot.button(IDialogConstants.YES_LABEL).click(); // Wait the end of repair @@ -526,22 +524,20 @@ public class RepairTest extends AbstractScenarioTestCase { } /** - * Scenario 4 bis : repair with multiple opened sessions (at least one - * changed), and without backup + * Scenario 4 bis : repair with multiple opened sessions (at least one changed), and without backup * <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>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 NO 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 still longer here and that the second session is dirty</LI> + * <LI>Check that the modification done in the diagram of the second session (sc4-2.aird) is still longer here and + * that the second session is dirty</LI> * </UL> * * @throws Exception @@ -574,8 +570,8 @@ public class RepairTest extends AbstractScenarioTestCase { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource1, repairActionLabel); // - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); bot.button(IDialogConstants.NO_LABEL).click(); // Wait the end of repair @@ -595,15 +591,13 @@ public class RepairTest extends AbstractScenarioTestCase { } /** - * Scenario 4 ter : repair with multiple opened sessions (at least one - * changed), and cancel + * Scenario 4 ter : repair with multiple opened sessions (at least one changed), and cancel * <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>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 Cancel on the popup</LI> @@ -645,8 +639,8 @@ public class RepairTest extends AbstractScenarioTestCase { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource1, repairActionLabel); // - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); bot.button(IDialogConstants.CANCEL_LABEL).click(); // Check that the sessions are always opened @@ -662,15 +656,14 @@ public class RepairTest extends AbstractScenarioTestCase { } /** - * Scenario 4 ter : repair with multiple opened sessions (at least one - * changed), and cancel with the cross of the popup + * Scenario 4 ter : repair with multiple opened sessions (at least one changed), and cancel with the cross of the + * popup * <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>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 Cancel on the popup</LI> @@ -712,8 +705,8 @@ public class RepairTest extends AbstractScenarioTestCase { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource1, repairActionLabel); // - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); // Close the popup with the cross bot.activeShell().close(); @@ -733,10 +726,8 @@ public class RepairTest extends AbstractScenarioTestCase { * Contexte : * <UL> * <LI>sc5.aird file use the sc5.ecore as semantic resource</LI> - * <LI>sc5-1.aird is a fragmented file (controlled from sc5.aird) and use - * sc5-1.ecore as semantic resource</LI> - * <LI>sc5-2.aird is a fragmented file (controlled from sc5.aird) and use - * sc5-2.ecore as semantic resource</LI> + * <LI>sc5-1.aird is a fragmented file (controlled from sc5.aird) and use sc5-1.ecore as semantic resource</LI> + * <LI>sc5-2.aird is a fragmented file (controlled from sc5.aird) and use sc5-2.ecore as semantic resource</LI> * </UL> * Steps : * <UL> @@ -747,8 +738,7 @@ public class RepairTest extends AbstractScenarioTestCase { * <LI>A popup warns the user that the sessions 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 for the three files - * (sc5-timestamp.aird.old, sc5-1-timestamp.aird.old and + * <LI>Check that a backup was done for the three files (sc5-timestamp.aird.old, sc5-1-timestamp.aird.old and * sc5-2-timestamp.aird.old)</LI> * <LI>Check that the representations are OK in the repaired files</LI> * </UL> @@ -801,20 +791,19 @@ public class RepairTest extends AbstractScenarioTestCase { } /** - * Launch the repair action from the context menu of the specified aird - * resource. + * Launch the repair action from the context menu of the specified aird resource. */ private void launchRepairAction(UIResource sessionAirdResource) { String repairActionLabel = SiriusEditPlugin.getPlugin().getString("repairActionLabel"); designerProject.mouseRigthClickOnResource(sessionAirdResource, repairActionLabel); - bot.waitUntil(Conditions.shellIsActive(RepresentationFilesRepairValidator.MESSAGE_TITLE)); - SWTBotShell message = bot.shell(RepresentationFilesRepairValidator.MESSAGE_TITLE); + bot.waitUntil(Conditions.shellIsActive(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL))); + SWTBotShell message = bot.shell(RepresentationFilesNeedCloseSessionValidator.getMessageTitle(RepresentationFilesRepairAction.REPAIR_ACTION_LABEL)); message.setFocus(); bot.button("OK").click(); SWTBotUtils.waitProgressMonitorClose("Progress Information"); assertNoProblemsLogged(); } - + /** * Check there is no log message. */ @@ -830,8 +819,7 @@ public class RepairTest extends AbstractScenarioTestCase { } /** - * Check that we have the expected number of backup files for the specified - * aird + * Check that we have the expected number of backup files for the specified aird */ private void assertNumberOfBackupFiles(int expected, IProject project, String airdFileName) { assertEquals("It should be no backup file before repair.", expected, getNumberOfBackupFiles(project, airdFileName)); @@ -858,9 +846,8 @@ public class RepairTest extends AbstractScenarioTestCase { } /** - * Compute the number of backup files corresponding to this aird file in - * this project. A backup file starts with the name of the original file and - * ends with "aird.old". + * Compute the number of backup files corresponding to this aird file in this project. A backup file starts with the + * name of the original file and ends with "aird.old". * * @param project * The project containg the aird file diff --git a/plugins/org.eclipse.sirius.ui/plugin.properties b/plugins/org.eclipse.sirius.ui/plugin.properties index ca29e449d8..6438d87eb2 100644 --- a/plugins/org.eclipse.sirius.ui/plugin.properties +++ b/plugins/org.eclipse.sirius.ui/plugin.properties @@ -253,8 +253,8 @@ RepresentationFilesRepairAction_repairFailed = Could not run repair process. RepresentationFilesRepairAction_repairInterrupted = Repair interrupted RepresentationFilesRepairValidator_askContinue = Do you want to continue? RepresentationFilesRepairValidator_askSave = Save changes? -RepresentationFilesRepairValidator_confirmationDialogTitle = Repair confirmation -RepresentationFilesRepairValidator_launchImpossibleRepresentationsOpened = It''s impossible to launch the "{0}" action with opened representations file. So they will be closed before the repair process. +RepresentationFilesRepairValidator_confirmationDialogTitle = {0} confirmation +RepresentationFilesRepairValidator_launchImpossibleRepresentationsOpened = It''s impossible to launch the "{0}" action with opened representations file. So they will be closed before the "{0}" process. RepresentationFilesRepairValidator_migrationCanceled = Migration canceled by user. RepresentationFilesRepairValidator_repairActionLabel = Repair RepresentationFilesRepairValidator_representationFileModified = The following representations file has been modified: diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairValidator.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesNeedCloseSessionValidator.java index ad995280eb..7cb67d9b55 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairValidator.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesNeedCloseSessionValidator.java @@ -34,21 +34,40 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; /** - * Validator to validate the environment before launching the repair action and - * eventually ask questions to the user to passed in valid environment. + * Validator to validate the environment before launching the repair action and eventually ask questions to the user to + * passed in valid environment. * * A valid environment is an environment with no session open. * * @author <a href="mailto:laurent.redor@obeo.fr">Laurent Redor</a> */ -public class RepresentationFilesRepairValidator { +public class RepresentationFilesNeedCloseSessionValidator { + + private static final int OPERATION_CANCELED = 0; + + private String actionName; /** - * The name of the dialog which ask question. + * Default constructor. + * + * @param actionName + * the name of the action that needs to close opened sessions. */ - public static final String MESSAGE_TITLE = Messages.RepresentationFilesRepairValidator_confirmationDialogTitle; + public RepresentationFilesNeedCloseSessionValidator(String actionName) { + this.actionName = actionName; + } - private static final int OPERATION_CANCELED = 0; + /** + * Get the name of the dialog which ask question. + * + * @param actionName + * the name of the action. + * + * @return the title. + */ + public static String getMessageTitle(String actionName) { + return MessageFormat.format(Messages.RepresentationFilesRepairValidator_confirmationDialogTitle, actionName); + } /** * Validates the environment for launching a repair action. @@ -63,11 +82,9 @@ public class RepresentationFilesRepairValidator { * @param currentFileToMigrate * File to repair. * - * @return the status of validation. The {@link IStatus#getSeverity - * severity} of the result indicates whether validation passed or - * (how badly it) failed. Normally, the result is a - * {@link IStatus#isMultiStatus multi-status} whose children are the - * results of individual constraint evaluations + * @return the status of validation. The {@link IStatus#getSeverity severity} of the result indicates whether + * validation passed or (how badly it) failed. Normally, the result is a {@link IStatus#isMultiStatus + * multi-status} whose children are the results of individual constraint evaluations */ public IStatus validate(IFile currentFileToMigrate) { IStatus resultStatus = null; @@ -110,8 +127,7 @@ public class RepresentationFilesRepairValidator { } boolean saveSessions = false; - String repairActionLabel = Messages.RepresentationFilesRepairValidator_repairActionLabel; - StringBuffer message = new StringBuffer(MessageFormat.format(Messages.RepresentationFilesRepairValidator_launchImpossibleRepresentationsOpened, repairActionLabel)); + StringBuffer message = new StringBuffer(MessageFormat.format(Messages.RepresentationFilesRepairValidator_launchImpossibleRepresentationsOpened, actionName)); if (dirtySessionsName.size() > 0) { if (dirtySessionsName.size() == 1) { message.append(" ").append(Messages.RepresentationFilesRepairValidator_representationFileModified); //$NON-NLS-1$ @@ -124,18 +140,19 @@ public class RepresentationFilesRepairValidator { message.delete(message.length() - 2, message.length() - 1); message.append("\n\n").append(Messages.RepresentationFilesRepairValidator_askSave); //$NON-NLS-1$ 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); + final MessageDialog dialog = new MessageDialog(shell, getMessageTitle(actionName), 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, Messages.RepresentationFilesRepairValidator_migrationCanceled, null)); + throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID, RepresentationFilesNeedCloseSessionValidator.OPERATION_CANCELED, + Messages.RepresentationFilesRepairValidator_migrationCanceled, null)); } if (buttons[result].equals(IDialogConstants.YES_LABEL)) { saveSessions = true; } } else { message.append("\n").append(Messages.RepresentationFilesRepairValidator_askContinue); //$NON-NLS-1$ - if (!MessageDialog.openConfirm(shell, MESSAGE_TITLE, message.toString())) { - throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID, RepresentationFilesRepairValidator.OPERATION_CANCELED, Messages.RepresentationFilesRepairValidator_migrationCanceled, null)); + if (!MessageDialog.openConfirm(shell, getMessageTitle(actionName), message.toString())) { + throw new CoreException(new Status(IStatus.CANCEL, SiriusEditPlugin.ID, OPERATION_CANCELED, Messages.RepresentationFilesRepairValidator_migrationCanceled, null)); } } return saveSessions; @@ -145,8 +162,7 @@ public class RepresentationFilesRepairValidator { * Close all the opened sessions. * * @param saveSessions - * true to save the session before closing, false to close - * without saving + * true to save the session before closing, false to close without saving */ private void closeSessions(boolean saveSessions) { Collection<IEditingSession> editingSessions = SessionUIManager.INSTANCE.getUISessions(); diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairAction.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairAction.java index ee66153c6b..8570beee77 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairAction.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/actions/repair/RepresentationFilesRepairAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 THALES GLOBAL SERVICES and others. + * Copyright (c) 2007, 2017 THALES GLOBAL SERVICES and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,14 +32,18 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionDelegate; /** - * This action will be called when the user needs to repair a representations - * file. + * This action will be called when the user needs to repair a representations file. * * @author <a href="mailto:laurent.goubet@obeo.fr">Laurent Goubet</a> * @author mchauvin */ public class RepresentationFilesRepairAction extends ActionDelegate { + /** + * The repair action label. + */ + public static final String REPAIR_ACTION_LABEL = Messages.RepresentationFilesRepairValidator_repairActionLabel; + /** The file selected in the workspace. */ protected IFile file; @@ -54,7 +58,7 @@ public class RepresentationFilesRepairAction extends ActionDelegate { public void run(final IAction action) { if (file != null) { try { - IStatus validationStatus = new RepresentationFilesRepairValidator().validate(file); + IStatus validationStatus = new RepresentationFilesNeedCloseSessionValidator(REPAIR_ACTION_LABEL).validate(file); if (validationStatus.isOK()) { PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() { |
