Commit 11d6ddd0 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Implement a default dialog for the logging service.

* Add a default dialog and handler class.
* Move the main parts of the service from the base plugin to the kernel.
* Introduce a severity enum since using int "codes" is flawed and we do
  not use underlying eclipse methods like the logging methods in the
  LoggingUtils class.

Issue-Ref: 3574
Issue-Url: https://af3-developer.fortiss.org/issues/3574

Signed-off-by: Alexander Diewald's avatarAlexander Diewald <diewald@fortiss.org>
parent 140ba327
......@@ -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 YELLOW
MultiFieldInputDialog.java 780e7a2aaab687666325b69d51d8df02646d723a GREEN
MultiRootTreeContentProvider.java 279ed5c5bcc5f000bf4e8f0fa3c131ba0411221b GREEN
......@@ -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;
......
......@@ -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>
ConstraintUIBases.java 3676a600e0866091db9798763c6eee97eec5b55b GREEN
ContextMenuSubMenuContributorBase.java 6275d96fe8690d9d4744bcbaef3c7d14ba8e30ff GREEN
DialogMessageHandler.java 173625e14ace15c4bfc32aa338e1da7247d7081c YELLOW
EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN
EReferencePropertySectionBase.java 3347e99b2fc135dd4b3117407179900ef757092c GREEN
EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN
......
/*-------------------------------------------------------------------------+
| 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 warning dialogs of
* {@link ModelElementWithRefCopyMessage}
* s which are emitted when a user copies elements which reference
* {@link IModelElementSpecification}s.
*
* @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;
}
}
}
}
......@@ -6,6 +6,7 @@ DragAndDropUtils.java 7aab91518aa12d76533a345bf6ed0be9ac7ff0e5 GREEN
EObjectSelectionUtils.java 128cf8f96c6b9478171dff3deda662d5934f5f44 GREEN
HierarchicalNameViewerComparator.java 199d82e392d4e437810cc65c0fc521dab52038e0 GREEN
KernelUIUtils.java 46d3279ef3523b104f89a6c526109f72d36f72f2 GREEN
MessageUtilsExtended.java fa3202e682a4573275fbb9c0db887ec701eeade3 YELLOW
ObservableUtils.java 34abfd1dfaf9c0acbb31caf1f525e7b39416c116 GREEN
PropertiesConstantUtils.java 59b1a1e4d594bb98db3aa396f2ff6474ba405920 GREEN
SelectionUtils.java 33aec7cccccb28e5568140cf8e5443ce0f9f59f7 GREEN
......
......@@ -13,7 +13,7 @@
| 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 org.conqat.ide.commons.ui.dialog.MessageUtils;
import org.eclipse.swt.widgets.Display;
......@@ -39,6 +39,11 @@ public class MessageUtilsExtended {
return tempQuestionResult;
}
/** Opens a error dialog in the UI thread. */
public static void showErrorInUIThread(final String title, final String message) {
syncExec(() -> MessageUtils.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));
......
ConstraintBases.java 93b4743cc1f5e2677635e644663ba934ef7f7f4e GREEN
ConstraintCheckerBase.java 92de33f1a3071dc6d66a55d8c10f5d5cc967a4fc GREEN
ConstraintViolationBase.java ec66973ab2183623f0cd4a85c59c886dddad6cf6 GREEN
DialogMessage.java 167f45ffe175f2654d3a0ac10d46890987450a47 YELLOW
ElementCompositorBase.java 7a445e5adde11878fe0515baca8b915287149b28 GREEN
MultiViolationConstraintCheckerBase.java 30886a94c99cf8948f64401b1db821abe06e1e6c GREEN
PrototypeProviderBase.java ebcd1794c3798b9899a620b01fd5aa0402129423 GREEN
......
/*-------------------------------------------------------------------------+
| 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;
/** 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;
}
}
......@@ -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 YELLOW
PrototypesUtils.java ec75bed75cfc5103f1f38e3a29df86f729428775 GREEN
ResourceUtils.java 698c7db34acb4f1a258a1953e6afcca9823763a8 GREEN
TransformationUtils.java 495891fae79b99c103cf61f607792dd1e48a5307 GREEN
......
......@@ -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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment