diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/.ratings index 34a264372b1a3fe7e05f8268afcb3d44d4c7310d..42d5b355b5307ccb5ce3688f0d6c8e910634c708 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/.ratings @@ -3,8 +3,7 @@ CheckBoxTreeDialog.java 2737a18ff8dda511466ba0f467d777a3a56e99a3 GREEN ElementTreeMultiSelectDialog.java 3b2ba4afc337e35175ce2e7d28e248f9d853ee32 GREEN ElementTreeSingleSelectDialog.java af76db0d43752b8a7af6ecdd6963f80c446f5b39 GREEN IDialogEditSupport.java 3c66b23d66cffaaf9bb4848b025a3fdb1a5b86dc GREEN -MessageUtilsExtended.java 930a54539160f6a214b6c0d98b0e3b3459c0740c GREEN ModelElementTreeContentProvider.java ac8da7ee7adf800850c528aa35e139b76a7d0318 GREEN -ModelElementWithRefCopyMessageHandler.java b03a5e82d540750852b3619ad9aeb5cf5f5b0617 GREEN +ModelElementWithRefCopyMessageHandler.java 1eb24195dbc9d5e3c019a841c312370e676c70fa GREEN MultiFieldInputDialog.java 780e7a2aaab687666325b69d51d8df02646d723a GREEN MultiRootTreeContentProvider.java 279ed5c5bcc5f000bf4e8f0fa3c131ba0411221b GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/ModelElementWithRefCopyMessageHandler.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/ModelElementWithRefCopyMessageHandler.java index b03a5e82d540750852b3619ad9aeb5cf5f5b0617..1eb24195dbc9d5e3c019a841c312370e676c70fa 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/ModelElementWithRefCopyMessageHandler.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/ModelElementWithRefCopyMessageHandler.java @@ -15,7 +15,7 @@ +--------------------------------------------------------------------------*/ package org.fortiss.tooling.base.ui.dialog; -import static org.fortiss.tooling.base.ui.dialog.MessageUtilsExtended.showWarningInUIThread; +import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showWarningInUIThread; import org.fortiss.tooling.base.compose.ModelElementWithRefCopyMessage; import org.fortiss.tooling.base.model.element.IModelElementSpecification; diff --git a/org.fortiss.tooling.kernel.ui/plugin.xml b/org.fortiss.tooling.kernel.ui/plugin.xml index bfab63e7e4ff9cb5849c1f5f5f8a098f5c3b7009..8f76e8c6d6cd0bad21b7a515806f273ba7cd679a 100644 --- a/org.fortiss.tooling.kernel.ui/plugin.xml +++ b/org.fortiss.tooling.kernel.ui/plugin.xml @@ -159,4 +159,12 @@ </modelElementClass> </modelElementHandler> </extension> + <extension point="org.fortiss.tooling.kernel.uiMessageHandler"> + <uiMessageHandler + handler="org.fortiss.tooling.kernel.ui.extension.base.DialogMessageHandler"> + <objectClass + objectClass="org.fortiss.tooling.kernel.extension.base.DialogMessage"> + </objectClass> + </uiMessageHandler> + </extension> </plugin> diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings index 4828120adfdcc4e629d83cb02b847d6380b49f64..8e8f81b7146f6308e0916dc488de67d8c51a00e7 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/.ratings @@ -1,5 +1,6 @@ ConstraintUIBases.java 3676a600e0866091db9798763c6eee97eec5b55b GREEN ContextMenuSubMenuContributorBase.java 6275d96fe8690d9d4744bcbaef3c7d14ba8e30ff GREEN +DialogMessageHandler.java 8714da09a777c8557de0a5c48ff68c340f9fa91d GREEN EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN EReferencePropertySectionBase.java 3347e99b2fc135dd4b3117407179900ef757092c GREEN EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/DialogMessageHandler.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/DialogMessageHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..8714da09a777c8557de0a5c48ff68c340f9fa91d --- /dev/null +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/extension/base/DialogMessageHandler.java @@ -0,0 +1,51 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2015 fortiss GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.ui.extension.base; + +import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showErrorInUIThread; +import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showInfoInUIThread; +import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showWarningInUIThread; + +import org.fortiss.tooling.kernel.extension.ILogMessageHandler; +import org.fortiss.tooling.kernel.extension.base.DialogMessage; +import org.fortiss.tooling.kernel.extension.data.ILogMessageContext; + +/** + * {@link ILogMessageHandler} that displays messages to a user in a dialog. It is used by backend + * plugins that may not have dependencies on UI plugins. + * + * @author diewald + */ +public class DialogMessageHandler implements ILogMessageHandler<DialogMessage> { + + /** {@inheritDoc} */ + @Override + public void showMessage(DialogMessage message, ILogMessageContext context) { + if(message != null) { + switch(message.getSeverity()) { + case ERROR: + showErrorInUIThread("Error", message.getMessage()); + break; + case WARNING: + showWarningInUIThread("Warning", message.getMessage()); + break; + case INFORMATION: + showInfoInUIThread("Information", message.getMessage()); + break; + } + } + } +} diff --git a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings index 5fc05483d0dd0ef2199071ef2e556e06f801f25d..2ad7bb4a775a6ccaa88be301ade63be2e6d55e51 100644 --- a/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/.ratings @@ -6,6 +6,7 @@ DragAndDropUtils.java 7aab91518aa12d76533a345bf6ed0be9ac7ff0e5 GREEN EObjectSelectionUtils.java 128cf8f96c6b9478171dff3deda662d5934f5f44 GREEN HierarchicalNameViewerComparator.java 199d82e392d4e437810cc65c0fc521dab52038e0 GREEN KernelUIUtils.java 46d3279ef3523b104f89a6c526109f72d36f72f2 GREEN +MessageUtilsExtended.java 67693ff5473d0b85081d273fc5f00612fdc8bfee GREEN ObservableUtils.java 34abfd1dfaf9c0acbb31caf1f525e7b39416c116 GREEN PropertiesConstantUtils.java 59b1a1e4d594bb98db3aa396f2ff6474ba405920 GREEN SelectionUtils.java 33aec7cccccb28e5568140cf8e5443ce0f9f59f7 GREEN diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/MessageUtilsExtended.java b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/MessageUtilsExtended.java similarity index 78% rename from org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/MessageUtilsExtended.java rename to org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/MessageUtilsExtended.java index 930a54539160f6a214b6c0d98b0e3b3459c0740c..67693ff5473d0b85081d273fc5f00612fdc8bfee 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/dialog/MessageUtilsExtended.java +++ b/org.fortiss.tooling.kernel.ui/src/org/fortiss/tooling/kernel/ui/util/MessageUtilsExtended.java @@ -13,7 +13,11 @@ | See the License for the specific language governing permissions and | | limitations under the License. | +--------------------------------------------------------------------------*/ -package org.fortiss.tooling.base.ui.dialog; +package org.fortiss.tooling.kernel.ui.util; + +import static org.conqat.ide.commons.ui.dialog.MessageUtils.showError; +import static org.conqat.ide.commons.ui.dialog.MessageUtils.showInfo; +import static org.conqat.ide.commons.ui.dialog.MessageUtils.showWarning; import org.conqat.ide.commons.ui.dialog.MessageUtils; import org.eclipse.swt.widgets.Display; @@ -33,20 +37,25 @@ public class MessageUtilsExtended { syncExec(new Runnable() { @Override public void run() { - tempQuestionResult = MessageUtils.askQuestion(title, message); + tempQuestionResult = askQuestion(title, message); } }); return tempQuestionResult; } + /** Opens a error dialog in the UI thread. */ + public static void showErrorInUIThread(final String title, final String message) { + syncExec(() -> showError(title, message)); + } + /** Opens a warning dialog in the UI thread. */ public static void showWarningInUIThread(final String title, final String message) { - syncExec(() -> MessageUtils.showWarning(title, message)); + syncExec(() -> showWarning(title, message)); } /** Opens an info dialog in the UI thread. */ public static void showInfoInUIThread(final String title, final String message) { - syncExec(() -> MessageUtils.showInfo(title, message)); + syncExec(() -> showInfo(title, message)); } /** Execute runnable in the UI thread */ diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings index 45fccf20e7273dcd4c56fd277f12dd19d9834c9f..0a29d0c1e0c82d128da5a762830cba25b5bcc927 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/.ratings @@ -1,6 +1,7 @@ ConstraintBases.java 93b4743cc1f5e2677635e644663ba934ef7f7f4e GREEN ConstraintCheckerBase.java 92de33f1a3071dc6d66a55d8c10f5d5cc967a4fc GREEN ConstraintViolationBase.java ec66973ab2183623f0cd4a85c59c886dddad6cf6 GREEN +DialogMessage.java 8420640e999e4fb15fa644333e5d71e1d16c2559 GREEN ElementCompositorBase.java 7a445e5adde11878fe0515baca8b915287149b28 GREEN MultiViolationConstraintCheckerBase.java 30886a94c99cf8948f64401b1db821abe06e1e6c GREEN PrototypeProviderBase.java ebcd1794c3798b9899a620b01fd5aa0402129423 GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/DialogMessage.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/DialogMessage.java new file mode 100644 index 0000000000000000000000000000000000000000..8420640e999e4fb15fa644333e5d71e1d16c2559 --- /dev/null +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/base/DialogMessage.java @@ -0,0 +1,53 @@ +/*-------------------------------------------------------------------------+ +| Copyright 2015 fortiss GmbH | +| | +| Licensed under the Apache License, Version 2.0 (the "License"); | +| you may not use this file except in compliance with the License. | +| You may obtain a copy of the License at | +| | +| http://www.apache.org/licenses/LICENSE-2.0 | +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | +| See the License for the specific language governing permissions and | +| limitations under the License. | ++--------------------------------------------------------------------------*/ +package org.fortiss.tooling.kernel.extension.base; + +import org.fortiss.tooling.kernel.extension.data.LogMessage; +import org.fortiss.tooling.kernel.service.ILoggingService; + +/** + * {@link LogMessage} that presents a defined string in a dialog to the user. It uses the + * {@link ILoggingService} to emit messages from non-UI plugins. + * + * @author diewald + */ +public class DialogMessage extends LogMessage { + + /** Denotes the type of message for presenting the correct dialog type. */ + @SuppressWarnings("javadoc") + public enum MSG_TYPE { + INFORMATION, WARNING, ERROR + } + + /** Holds the severity of the message. */ + private MSG_TYPE severity = MSG_TYPE.INFORMATION; + + /** Constructor. Default severity: {@link MSG_TYPE#INFORMATION}. */ + public DialogMessage(String dialogMsg) { + super(dialogMsg); + } + + /** Constructor. Allows defining the severity. */ + public DialogMessage(String dialogMsg, MSG_TYPE severity) { + super(dialogMsg); + this.severity = severity; + } + + /** Returns the severity of the message. */ + public MSG_TYPE getSeverity() { + return severity; + } +} diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings index 961ee852ef0cc60d17d8d47b0d1f73a1e5f2fb33..15d2467ff578f5cb0df6d463319d9b0a64056479 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/.ratings @@ -8,7 +8,7 @@ HierarchicalNameComparator.java 6face1b673126701a0721af48ead2f9766c17d46 GREEN IdentifierUtils.java fff43dc4e84cdd89c3ece4f5d9d89aec4b0749c2 GREEN JavaUtils.java 65cdadfb9137a240ad59992eacf53a15b7f20804 GREEN KernelModelElementUtils.java 56c86fe9afb23053f50d7279809afd2a5bb10eba GREEN -LoggingUtils.java a982f7c3371e72feb8658510b5b0358876281a12 GREEN +LoggingUtils.java 0e0aa5d466d80ea29cfc7e91178b23a5cdd4ddf7 GREEN PrototypesUtils.java ec75bed75cfc5103f1f38e3a29df86f729428775 GREEN ResourceUtils.java 698c7db34acb4f1a258a1953e6afcca9823763a8 GREEN TransformationUtils.java 495891fae79b99c103cf61f607792dd1e48a5307 GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/LoggingUtils.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/LoggingUtils.java index a982f7c3371e72feb8658510b5b0358876281a12..0e0aa5d466d80ea29cfc7e91178b23a5cdd4ddf7 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/LoggingUtils.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/utils/LoggingUtils.java @@ -18,6 +18,9 @@ package org.fortiss.tooling.kernel.utils; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Plugin; import org.eclipse.core.runtime.Status; +import org.fortiss.tooling.kernel.extension.base.DialogMessage; +import org.fortiss.tooling.kernel.extension.base.DialogMessage.MSG_TYPE; +import org.fortiss.tooling.kernel.service.ILoggingService; /** * Utility code for performing logging. @@ -126,4 +129,37 @@ public class LoggingUtils { public static void info(Plugin plugin, String message) { info(plugin, message, null); } + + /** + * Presents an error dialog to the user. + * + * @param message + * to be displayed. + */ + public static void showError(String message) { + ILoggingService.getInstance().processMessage(new DialogMessage(message, MSG_TYPE.ERROR), + null); + } + + /** + * Presents a warning dialog to the user. + * + * @param message + * to be displayed. + */ + public static void showWarning(String message) { + ILoggingService.getInstance().processMessage(new DialogMessage(message, MSG_TYPE.WARNING), + null); + } + + /** + * Presents a warning dialog to the user. + * + * @param message + * to be displayed. + */ + public static void showInfo(String message) { + ILoggingService.getInstance() + .processMessage(new DialogMessage(message, MSG_TYPE.INFORMATION), null); + } }