Improve dialogs.
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui / src / org / argeo / eclipse / ui / dialogs / ErrorFeedback.java
index 183468402a7393e45c95746711472bdeffe6595e..f3d0531e18bef4c619b12bac1779b336d3cf4a62 100644 (file)
@@ -1,18 +1,3 @@
-/*
- * Copyright (C) 2007-2012 Argeo 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.argeo.eclipse.ui.dialogs;
 
 import java.io.PrintWriter;
@@ -32,7 +17,12 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 
-/** Generic error dialog to be used in try/catch blocks */
+/**
+ * Generic error dialog to be used in try/catch blocks.
+ * 
+ * @deprecated Use CMS dialogs instead.
+ */
+@Deprecated
 public class ErrorFeedback extends TitleAreaDialog {
        private static final long serialVersionUID = -8918084784628179044L;
 
@@ -47,11 +37,15 @@ public class ErrorFeedback extends TitleAreaDialog {
                if (e instanceof ThreadDeath)
                        throw (ThreadDeath) e;
 
-               new ErrorFeedback(getDisplay().getActiveShell(), message, e).open();
+               new ErrorFeedback(newShell(), message, e).open();
        }
 
        public static void show(String message) {
-               new ErrorFeedback(getDisplay().getActiveShell(), message, null).open();
+               new ErrorFeedback(newShell(), message, null).open();
+       }
+
+       private static Shell newShell() {
+               return new Shell(getDisplay(), SWT.NO_TRIM);
        }
 
        /** Tries to find a display */
@@ -69,6 +63,7 @@ public class ErrorFeedback extends TitleAreaDialog {
 
        public ErrorFeedback(Shell parentShell, String message, Throwable e) {
                super(parentShell);
+               setShellStyle(SWT.NO_TRIM);
                this.message = message;
                this.exception = e;
                log.error(message, e);
@@ -89,14 +84,11 @@ public class ErrorFeedback extends TitleAreaDialog {
                composite.setLayout(new GridLayout(2, false));
                composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
-               setMessage(message != null ? message
-                               + (exception != null ? ": " + exception.getMessage() : "")
-                               : exception != null ? exception.getMessage() : "Unkown Error",
-                               IMessageProvider.ERROR);
+               setMessage(message != null ? message + (exception != null ? ": " + exception.getMessage() : "")
+                               : exception != null ? exception.getMessage() : "Unkown Error", IMessageProvider.ERROR);
 
                if (exception != null) {
-                       Text stack = new Text(composite, SWT.MULTI | SWT.LEAD | SWT.BORDER
-                                       | SWT.V_SCROLL | SWT.H_SCROLL);
+                       Text stack = new Text(composite, SWT.MULTI | SWT.LEAD | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
                        stack.setEditable(false);
                        stack.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
                        StringWriter sw = new StringWriter();