Skip to content
Snippets Groups Projects
Commit e26aba06 authored by Sebastian Bergemann's avatar Sebastian Bergemann
Browse files

YELLOW (2 of 3 fixes)

Issue-ref: 4149
Issue-URL: af3#4149



Signed-off-by: default avatarSebastian Bergemann <bergemann@fortiss.org>
parent d7ae054e
No related branches found
No related tags found
1 merge request!181Added correct hash creation in reuse (+ update detection)
Pipeline #36086 failed
This commit is part of merge request !181. Comments created here will be created in the context of that merge request.
AddElementContextMenu.java 1b5436d37bd93fe9106a3f21cf3d5a2b3656490e GREEN
GetUpdatedOriginsContextMenu.java 6d79cfc4c9c033f74b1786a4f97124dd1131daf7 GREEN
UpdateFromLibContextMenu.java 54c880be61967125f25d1b66afa34772d480ccae RED
UpdateInLibContextMenu.java 159faa83b7fde57bd13e4e75d66f3db8b9eb0d65 RED
GetUpdatedOriginsContextMenu.java 672ee49ed98a2b2f046c06e42f541e650b67772f GREEN
UpdateFromLibContextMenu.java f37c4165011ffd5d4bbf07c70effd187dc8d4cfd YELLOW
UpdateInLibContextMenu.java 3e3055b24ee32f467a7c3a11a075eabb28832c1c YELLOW
......@@ -17,7 +17,7 @@ package org.fortiss.tooling.ext.reuse.ui.commands;
import static java.util.Collections.emptyList;
import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo;
import static org.fortiss.tooling.ext.reuse.ui.commands.UpdateFromLibContextMenu.updateFromContextMenuString;
import static org.fortiss.tooling.ext.reuse.ui.commands.UpdateFromLibContextMenu.UPDATE_FROM_CONTEXT_MENU_STRING;
import static org.fortiss.tooling.ext.reuse.utils.ReuseLibraryUtils.getFirstSourceLibraryOfElement;
import static org.fortiss.tooling.ext.reuse.utils.ReuseLibraryUtils.getLibraryIDName;
import static org.fortiss.tooling.ext.reuse.utils.ReuseLibraryUtils.getReuseElementLastUpdateString;
......@@ -110,7 +110,7 @@ public class GetUpdatedOriginsContextMenu implements IContextMenuContributor {
infoMessage += "Within library: '" + libraryName + "'\n";
infoMessage += "Last updated: " + lastUpdate + "\n";
}
infoMessage += "\nIf you want to get one of these updates, please use the '" + updateFromContextMenuString
infoMessage += "\nIf you want to get one of these updates, please use the '" + UPDATE_FROM_CONTEXT_MENU_STRING
+ "' context menu entry.";
}
showInfo(shellTitle, infoMessage);
......
......@@ -63,11 +63,10 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
public class UpdateFromLibContextMenu implements IContextMenuContributor {
/** The title of the dialog shell(s). */
private /*FIXME (AB) static?*/ final String shellTitle = "Update Element From Reuse Library";
private static final String SHELL_TITLE = "Update Element From Reuse Library";
// FIXME(AB) Constants like this should be named with ALL_CAPITAL_LETTERS
/** The string of the context menu entry. */
public static final String updateFromContextMenuString = "Update from Reuse Library";
public static final String UPDATE_FROM_CONTEXT_MENU_STRING = "Update from Reuse Library";
/** {@inheritDoc} */
@Override
......@@ -107,7 +106,7 @@ public class UpdateFromLibContextMenu implements IContextMenuContributor {
}
// find original element inside the library
EObject originalLibraryElement = checkForElementInLibrary(library, referencingSpec, shellTitle);
EObject originalLibraryElement = checkForElementInLibrary(library, referencingSpec, SHELL_TITLE);
if (originalLibraryElement == null) {
return;
}
......@@ -115,7 +114,7 @@ public class UpdateFromLibContextMenu implements IContextMenuContributor {
EObject updatedElement = replaceElementInProject(elementToBeUpdated, originalLibraryElement, newName,
keepAdditionalReferences);
if (updatedElement == null) {
String infoTitle = shellTitle + " - Replacement Failed";
String infoTitle = SHELL_TITLE + " - Replacement Failed";
String infoMessage = "The replacement of '" + getReuseElementName(elementToBeUpdated) + "' with '"
+ getReuseElementName(originalLibraryElement) + "' has failed.";
showInfo(infoTitle, infoMessage);
......@@ -125,7 +124,7 @@ public class UpdateFromLibContextMenu implements IContextMenuContributor {
fixIds(updatedElement);
String currentActionType = "updateFromLibrary";
manageExternalReferencesOfReuseElement(originalLibraryElement, currentActionType, shellTitle);
manageExternalReferencesOfReuseElement(originalLibraryElement, currentActionType, SHELL_TITLE);
}
/** The action "update element from {@link ReuseLibrary}". */
......@@ -136,21 +135,22 @@ public class UpdateFromLibContextMenu implements IContextMenuContributor {
/** Constructor. Takes the selected element as input. */
UpdateFromLibAction(EObject element) {
super(updateFromContextMenuString, ToolingReuseUIActivator.getImageDescriptor("icons/update_from_library.png"));
super(UPDATE_FROM_CONTEXT_MENU_STRING,
ToolingReuseUIActivator.getImageDescriptor("icons/update_from_library.png"));
selectedElement = element;
}
/** {@inheritDoc} */
@Override
public void run() {
ReuseElementSpec correctLibrarySpec = selectCorrectReuseSpec(selectedElement, shellTitle);
ReuseElementSpec correctLibrarySpec = selectCorrectReuseSpec(selectedElement, SHELL_TITLE);
if (correctLibrarySpec == null) {
return;
}
ReuseLibrary correctLibrary = getLocalReuseLibraryByID(correctLibrarySpec.getSourceLibUUID());
if (correctLibrary == null) {
warnOfMissingLib(correctLibrarySpec, shellTitle);
warnOfMissingLib(correctLibrarySpec, SHELL_TITLE);
return;
}
......@@ -165,7 +165,7 @@ public class UpdateFromLibContextMenu implements IContextMenuContributor {
}
// find original element inside the library
EObject originalLibraryElement = checkForElementInLibrary(correctLibrary, correctLibrarySpec, shellTitle);
EObject originalLibraryElement = checkForElementInLibrary(correctLibrary, correctLibrarySpec, SHELL_TITLE);
if (originalLibraryElement == null) {
return;
}
......@@ -174,7 +174,7 @@ public class UpdateFromLibContextMenu implements IContextMenuContributor {
// they should be kept or if all should be overridden/replaced by the library
// reference of the current update
boolean keepAdditionalReferences = isKeepingAdditionalReferencesRequested(selectedElement,
correctLibrarySpec, shellTitle);
correctLibrarySpec, SHELL_TITLE);
// confirm the update
String currentNameInLibrary = getReuseElementName(originalLibraryElement);
......@@ -195,14 +195,14 @@ public class UpdateFromLibContextMenu implements IContextMenuContributor {
"\nAfter this step, the element will only contain the current update reference and all (old) additional library references will be removed.");
}
}
boolean confirmed = confirm(shellTitle, join("\n", textLines));
boolean confirmed = confirm(SHELL_TITLE, join("\n", textLines));
if (!confirmed) {
return;
}
// ask for element name (when updating element in project)
final InputDialog updateDialog = new InputDialog(Display.getCurrent().getActiveShell(), shellTitle,
final InputDialog updateDialog = new InputDialog(Display.getCurrent().getActiveShell(), SHELL_TITLE,
"Enter the name with which the element should be updated in the project:\n(Current name in project: "
+ currentNameInProject + ")\n ",
currentNameInProject, new UpdatedNameValidator());
......
......@@ -64,11 +64,10 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
public class UpdateInLibContextMenu implements IContextMenuContributor {
/** The title of the dialog shell(s). */
private /*FIXME (AB) static!?*/ final String shellTitle = "Update Element In Reuse Library";
private static final String SHELL_TITLE = "Update Element In Reuse Library";
/** The string of the context menu entry. */
// FIXME(AB) Constants like this should be named with ALL_CAPITAL_LETTERS
public static final String updateInContextMenuString = "Update in Reuse Library";
public static final String UPDATE_IN_CONTEXT_MENU_STRING = "Update in Reuse Library";
/** {@inheritDoc} */
@Override
......@@ -108,7 +107,7 @@ public class UpdateInLibContextMenu implements IContextMenuContributor {
return;
}
EObject originalLibraryElement = checkForElementInLibrary(library, referencingSpec, shellTitle);
EObject originalLibraryElement = checkForElementInLibrary(library, referencingSpec, SHELL_TITLE);
if (originalLibraryElement == null) {
return;
}
......@@ -117,13 +116,13 @@ public class UpdateInLibContextMenu implements IContextMenuContributor {
try {
saveReuseLibrary(library);
} catch (Exception e) {
openError(getActiveWorkbenchWindow().getShell(), "Error in '" + shellTitle + "'", e.getMessage());
openError(getActiveWorkbenchWindow().getShell(), "Error in '" + SHELL_TITLE + "'", e.getMessage());
}
PrototypeService.getInstance().updatePrototypes();
String currentActionType = "updateInLibrary";
manageExternalReferencesOfReuseElement(newElement, currentActionType, shellTitle);
manageExternalReferencesOfReuseElement(newElement, currentActionType, SHELL_TITLE);
}
/** The action "update element in {@link ReuseLibrary}". */
......@@ -137,26 +136,27 @@ public class UpdateInLibContextMenu implements IContextMenuContributor {
/** Constructor. Takes the selected element as input. */
UpdateInLibAction(EObject element) {
super(updateInContextMenuString, ToolingReuseUIActivator.getImageDescriptor("icons/update_in_library.png"));
super(UPDATE_IN_CONTEXT_MENU_STRING,
ToolingReuseUIActivator.getImageDescriptor("icons/update_in_library.png"));
selectedElement = element;
}
/** {@inheritDoc} */
@Override
public void run() {
ReuseElementSpec correctLibrarySpec = selectCorrectReuseSpec(selectedElement, shellTitle);
ReuseElementSpec correctLibrarySpec = selectCorrectReuseSpec(selectedElement, SHELL_TITLE);
if (correctLibrarySpec == null) {
return;
}
ReuseLibrary correctLibrary = getLocalReuseLibraryByID(correctLibrarySpec.getSourceLibUUID());
if (correctLibrary == null) {
warnOfMissingLib(correctLibrarySpec, shellTitle);
warnOfMissingLib(correctLibrarySpec, SHELL_TITLE);
return;
}
// find original element inside the library
EObject originalLibraryElement = checkForElementInLibrary(correctLibrary, correctLibrarySpec, shellTitle);
EObject originalLibraryElement = checkForElementInLibrary(correctLibrary, correctLibrarySpec, SHELL_TITLE);
if (originalLibraryElement == null) {
return;
}
......@@ -179,7 +179,7 @@ public class UpdateInLibContextMenu implements IContextMenuContributor {
textLines.add("\n- Update target: element in library");
textLines.add(" > element name: " + currentNameInLibrary);
textLines.add(" > in library: " + getLibraryIDName(correctLibrary));
boolean confirmed = confirm(shellTitle, join("\n", textLines));
boolean confirmed = confirm(SHELL_TITLE, join("\n", textLines));
if (!confirmed) {
return;
......@@ -196,7 +196,7 @@ public class UpdateInLibContextMenu implements IContextMenuContributor {
}
// ask for element name (when updating element in library)
final InputDialog updateDialog = new InputDialog(Display.getCurrent().getActiveShell(), shellTitle,
final InputDialog updateDialog = new InputDialog(Display.getCurrent().getActiveShell(), SHELL_TITLE,
"Enter the name with which the element should be updated in the library '"
+ getReuseElementName(correctLibrary) + "':\n(Current name in library: "
+ currentNameInLibrary + ")\n ",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment