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

Merge branch 'master' of https://git.fortiss.org/af3/kernel.git into 4305

parents c55d165d 69ed4b18
No related branches found
No related tags found
1 merge request!2004305: Introduce IContextMenuContributor::hiddenInNonExpertView()
Pipeline #37403 failed
org.fortiss.tooling.ext.reuse.ui/icons/af3_icon64.png

6.11 KiB

org.fortiss.tooling.ext.reuse.ui/icons/af3_logo.png

22.2 KiB

org.fortiss.tooling.ext.reuse.ui/icons/af3_logo_square.png

33.5 KiB

ReuseLibraryUIUtils.java 0f8d233c725d9dbd39ff6613a69c997786264054 GREEN
ReuseLibraryUIUtils.java fed62784975bf8e6fc1625505636e247dfb6c86e GREEN
ReuseLibraryViewUtils.java 34a852dc692ec56cb3e9fd8dcea99d64f31503b3 GREEN
......@@ -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();
}
}
ReuseLibraryModelElementFactory.java 4ee3eb7449e212643992a3dec6cfb8f4278efb70 GREEN
ReuseLibraryUtilsBasics.java 9aa543630acf9555721821519d96d4356a07f341 GREEN
ReuseLibraryUtilsBasics.java b651b31f6d94ff98a8f965440d662bfc4655c31b GREEN
ReuseLibraryUtilsManipulation.java 77a646db5a63ba7c61664dbcaf34a9036003fde5 GREEN
......@@ -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 "";
......
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