diff --git a/org.fortiss.tooling.ext.reuse.ui/icons/af3_icon64.png b/org.fortiss.tooling.ext.reuse.ui/icons/af3_icon64.png new file mode 100644 index 0000000000000000000000000000000000000000..28744fdefd36c21e7c7d835fac44506fcde83008 Binary files /dev/null and b/org.fortiss.tooling.ext.reuse.ui/icons/af3_icon64.png differ diff --git a/org.fortiss.tooling.ext.reuse.ui/icons/af3_logo.png b/org.fortiss.tooling.ext.reuse.ui/icons/af3_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..1c08d006b36f6bad28696e7d0378dde8d8687273 Binary files /dev/null and b/org.fortiss.tooling.ext.reuse.ui/icons/af3_logo.png differ diff --git a/org.fortiss.tooling.ext.reuse.ui/icons/af3_logo_square.png b/org.fortiss.tooling.ext.reuse.ui/icons/af3_logo_square.png new file mode 100644 index 0000000000000000000000000000000000000000..40852c78044208854fa19912ce4e5e0157dab913 Binary files /dev/null and b/org.fortiss.tooling.ext.reuse.ui/icons/af3_logo_square.png differ diff --git a/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/.ratings b/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/.ratings index e08f52db16363c4dcdf413ab400ee0a67c03c424..e057b2fb5a0d78886b8f9ca83ae197146e330326 100644 --- a/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/.ratings +++ b/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/.ratings @@ -1,2 +1,2 @@ -ReuseLibraryUIUtils.java 0f8d233c725d9dbd39ff6613a69c997786264054 GREEN +ReuseLibraryUIUtils.java fed62784975bf8e6fc1625505636e247dfb6c86e GREEN ReuseLibraryViewUtils.java 34a852dc692ec56cb3e9fd8dcea99d64f31503b3 GREEN diff --git a/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/ReuseLibraryUIUtils.java b/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/ReuseLibraryUIUtils.java index 0f8d233c725d9dbd39ff6613a69c997786264054..fed62784975bf8e6fc1625505636e247dfb6c86e 100644 --- a/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/ReuseLibraryUIUtils.java +++ b/org.fortiss.tooling.ext.reuse.ui/src/org/fortiss/tooling/ext/reuse/ui/utils/ReuseLibraryUIUtils.java @@ -16,10 +16,12 @@ package org.fortiss.tooling.ext.reuse.ui.utils; import static java.lang.String.join; +import static javafx.scene.control.Alert.AlertType.INFORMATION; import static org.conqat.ide.commons.ui.dialog.MessageUtils.askQuestion; import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo; import static org.conqat.ide.commons.ui.dialog.MessageUtils.showWarning; import static org.conqat.ide.commons.ui.ui.WorkbenchUtils.getActiveWorkbenchWindow; +import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImage; import static org.fortiss.tooling.ext.reuse.storage.ReuseLibraryStorageManager.REUSE_PROJECT_DIR; import static org.fortiss.tooling.ext.reuse.utils.ReuseLibraryUtilsBasics.getAllReuseSpecs; import static org.fortiss.tooling.ext.reuse.utils.ReuseLibraryUtilsBasics.getElementInsideLibrary; @@ -35,8 +37,16 @@ import org.eclipse.swt.widgets.Shell; import org.fortiss.tooling.base.model.element.IModelElement; import org.fortiss.tooling.ext.reuse.model.ReuseElementSpec; import org.fortiss.tooling.ext.reuse.model.ReuseLibrary; +import org.fortiss.tooling.ext.reuse.ui.ToolingReuseUIActivator; import org.fortiss.tooling.ext.reuse.ui.dialog.SelectLibDialog; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.DialogPane; +import javafx.scene.control.TextArea; +import javafx.scene.image.Image; +import javafx.stage.Stage; + /** * Utility methods for {@link ReuseLibrary}s' UI. * @@ -44,6 +54,12 @@ import org.fortiss.tooling.ext.reuse.ui.dialog.SelectLibDialog; */ public class ReuseLibraryUIUtils { + /** Standard width preference for dialog windows used in the reuse context. */ + private final static Double DIALOG_WINDOW_WIDTH_PREF = 700.0; + + /** Standard height preference for dialog windows used in the reuse context. */ + private final static Double DIALOG_WINDOW_HEIGHT_PREF = 500.0; + /** * Returns the selected {@link ReuseElementSpec} by user from all * {@link ReuseElementSpec}s of the given element. Returns null if no @@ -231,18 +247,84 @@ public class ReuseLibraryUIUtils { List<EObject> externalRefs = getExternalReferencesOfElement(reuseElement); if (!externalRefs.isEmpty()) { - String infoMessage = "The following elements were found as references inside the reuse element you " + String headerText = "The following elements were found as references inside the reuse element you " + actionText + ".\n\nIn case of reusing this element" + currentReuseTest + ", these referenced elements will be needed in the new environment, too. " + "Therefore, you might want to add/update these reference elements as well (if not already done).\n"; + String bodyText = ""; for (EObject externalRef : externalRefs) { - infoMessage += "\n- " + getReuseElementName(externalRef) + " (" + externalRef.getClass().getSimpleName() + bodyText += "\n- " + getReuseElementName(externalRef) + " (" + externalRef.getClass().getSimpleName() + ")"; if (getReuseElementName(externalRef).equals(getReuseElementName(reuseElement))) { - infoMessage += " [ignore this if it is actually " + sourceText + "]"; + bodyText += " [ignore this if it is actually " + sourceText + "]"; } } - showInfo(infoTitle, infoMessage); + + showBasicScrollableInformation(shellTitle, headerText, bodyText); } } + + /** + * Creates and displays a information box with only an OK button. Everything is + * already set except the text for the title, the header and the body. + * + * @param windowTitle The title of the dialog window + * @param headerText The text of the header between title and body + * @param bodyText The actual text body + */ + public static void showBasicScrollableInformation(String windowTitle, String headerText, String bodyText) { + boolean showSymbol = true; + showCustomScrollableAlert(INFORMATION, windowTitle, headerText, bodyText, showSymbol, DIALOG_WINDOW_WIDTH_PREF, + DIALOG_WINDOW_HEIGHT_PREF); + } + + /** + * Creates and displays a dialog/alert message box depending on the given + * {@link AlertType}. You can customize the title, the text in the header, if + * the symbol besides the header should be displayed, the actual text body and + * the preferred size of the window (null if nothing is preferred). + * + * @param alertType The alert type like Information, Error, etc. + * @param windowTitle The title of the dialog window + * @param headerText The text of the header between title and body + * @param bodyText The actual text body + * @param showSymbol Whether the symbol besides the header text should be + * displayed + * @param windowPrefWidth Preferred width of the window + * @param windowPrefHeight Preferred height of the window + */ + public static void showCustomScrollableAlert(AlertType alertType, String windowTitle, String headerText, + String bodyText, boolean showSymbol, Double windowPrefWidth, Double windowPrefHeight) { + + Alert alert = new Alert(alertType); + + if (!showSymbol) { + alert.setGraphic(null); + } + alert.setTitle(windowTitle); + alert.setHeaderText(headerText); + alert.setResizable(true); + + TextArea area = new TextArea(bodyText); + area.setWrapText(true); + area.setEditable(false); + + DialogPane dialogPane = alert.getDialogPane(); + Image taskbarIcon = getFXImage(ToolingReuseUIActivator.PLUGIN_ID, "icons/af3_icon64.png"); + Stage stage = (Stage) dialogPane.getScene().getWindow(); + stage.getIcons().add(taskbarIcon); + + // use setExpandableContent(area) if the scrollable text should be first hidden + // under "Show details". Then, alert.setContentText() can be used to show a + // short message before + dialogPane.setContent(area); + if (windowPrefWidth != null && windowPrefWidth > 0.0) { + dialogPane.setPrefWidth(windowPrefWidth); + } + if (windowPrefHeight != null && windowPrefHeight > 0.0) { + dialogPane.setPrefHeight(windowPrefHeight); + } + + alert.showAndWait(); + } } diff --git a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings index ac907e8c919296c5fbdf81aec49bdfaffa8ce14f..0037e17bc479904365d87a17f6aebae128fcc1e4 100644 --- a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings +++ b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/.ratings @@ -1,3 +1,3 @@ ReuseLibraryModelElementFactory.java 4ee3eb7449e212643992a3dec6cfb8f4278efb70 GREEN -ReuseLibraryUtilsBasics.java 9aa543630acf9555721821519d96d4356a07f341 GREEN +ReuseLibraryUtilsBasics.java b651b31f6d94ff98a8f965440d662bfc4655c31b GREEN ReuseLibraryUtilsManipulation.java 77a646db5a63ba7c61664dbcaf34a9036003fde5 GREEN diff --git a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java index 9aa543630acf9555721821519d96d4356a07f341..b651b31f6d94ff98a8f965440d662bfc4655c31b 100644 --- a/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java +++ b/org.fortiss.tooling.ext.reuse/src/org/fortiss/tooling/ext/reuse/utils/ReuseLibraryUtilsBasics.java @@ -45,10 +45,10 @@ import org.fortiss.tooling.kernel.model.INamedElement; public class ReuseLibraryUtilsBasics { /** Standard internal date format used for reuse (e.g. for hash dates) */ - public static DateTimeFormatter internalReuseDateFormatter = ISO_DATE_TIME; + public final static DateTimeFormatter INTERNAL_REUSE_DATE_FORMATTER = ISO_DATE_TIME; /** Standard date format used for reuse (easier readable) */ - public static DateTimeFormatter displayReuseDateFormatter = RFC_1123_DATE_TIME; + public final static DateTimeFormatter DISPLAY_REUSE_DATE_FORMATTER = RFC_1123_DATE_TIME; /** * Returns whether the given element can be used as reuse element. @@ -343,9 +343,9 @@ public class ReuseLibraryUtilsBasics { public static String getDateAsString(ZonedDateTime date, boolean forDisplay) { if (date != null) { if (forDisplay) { - return displayReuseDateFormatter.format(date); + return DISPLAY_REUSE_DATE_FORMATTER.format(date); } else { - return internalReuseDateFormatter.format(date); + return INTERNAL_REUSE_DATE_FORMATTER.format(date); } } return "";