Clean and comments.
authorBruno Sinou <bsinou@argeo.org>
Fri, 12 Dec 2014 15:04:27 +0000 (15:04 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 12 Dec 2014 15:04:27 +0000 (15:04 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@7571 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/ErrorFeedback.java
org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/WorkbenchUiPlugin.java
org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/jcr/internal/parts/AbstractJcrQueryEditor.java
org.argeo.eclipse.ui/bnd.bnd
org.argeo.eclipse.ui/pom.xml
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/dialogs/SingleValue.java
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/JcrUiUtils.java
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/views/AbstractJcrBrowser.java [deleted file]
org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/ViewerUtils.java

index 692d8a4b9f3ae7b1a3388de4813d8aec3f9aecc4..9a5482584b5e7576f37adbac5e3470da59f3ed74 100644 (file)
@@ -34,8 +34,9 @@ import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.PlatformUI;
 
 /** Generic error dialog to be used in try/catch blocks */
-@SuppressWarnings("serial")
 public class ErrorFeedback extends TitleAreaDialog {
+       private static final long serialVersionUID = -8918084784628179044L;
+
        private final static Log log = LogFactory.getLog(ErrorFeedback.class);
 
        private final String message;
index 48ed86142fab608a6ae066a46e16b2eae0c1040a..4898e80d73f6a9df2d1c44f0e5062a7cce4db1d0 100644 (file)
@@ -19,6 +19,9 @@ import java.util.ResourceBundle;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.eclipse.core.runtime.ILogListener;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -26,7 +29,7 @@ import org.osgi.framework.BundleContext;
 /**
  * The activator class controls the plug-in life cycle
  */
-public class WorkbenchUiPlugin extends AbstractUIPlugin {
+public class WorkbenchUiPlugin extends AbstractUIPlugin implements ILogListener {
        private final static Log log = LogFactory.getLog(WorkbenchUiPlugin.class);
        private ResourceBundle messages;
 
@@ -51,9 +54,15 @@ public class WorkbenchUiPlugin extends AbstractUIPlugin {
         */
        public void start(BundleContext context) throws Exception {
                super.start(context);
-               plugin = this;
-               messages = ResourceBundle.getBundle(ID + ".messages");
-
+               // weirdly, the start method is called twice...
+               // TODO check if it is still the case.
+               if (plugin == null) {
+                       plugin = this;
+                       messages = ResourceBundle.getBundle(ID + ".messages");
+                       Platform.addLogListener(this);
+                       log.debug("Eclipse logging now directed to standard logging");
+               } else
+                       log.warn("Trying to start an already started plugin.");
        }
 
        /*
@@ -64,8 +73,18 @@ public class WorkbenchUiPlugin extends AbstractUIPlugin {
         * )
         */
        public void stop(BundleContext context) throws Exception {
-               plugin = null;
-               super.stop(context);
+               try {
+                       // weirdly, the stop method is called twice...
+                       // TODO check if it is still the case.
+                       if (plugin != null) {
+                               Platform.removeLogListener(this);
+                               log.debug("Eclipse logging not directed anymore to standard logging");
+                               plugin = null;
+                       } else
+                               log.warn("Trying to stop an already stopped plugin.");
+               } finally {
+                       super.stop(context);
+               }
        }
 
        /**
@@ -103,4 +122,19 @@ public class WorkbenchUiPlugin extends AbstractUIPlugin {
                        return null;
        }
 
+       public void logging(IStatus status, String plugin) {
+               Log pluginLog = LogFactory.getLog(plugin);
+               Integer severity = status.getSeverity();
+               if (severity == IStatus.ERROR)
+                       pluginLog.error(status.getMessage(), status.getException());
+               else if (severity == IStatus.WARNING)
+                       pluginLog.warn(status.getMessage(), status.getException());
+               else if (severity == IStatus.INFO)
+                       pluginLog.info(status.getMessage(), status.getException());
+               else if (severity == IStatus.CANCEL)
+                       if (pluginLog.isDebugEnabled())
+                               pluginLog.debug(status.getMessage(), status.getException());
+
+       }
+
 }
index d16ff06bb5fd5c4bdac1b79ed0719ac789fceb25..161eb491c6ac7835fbbbd4e69ecdb1c51730fdb9 100644 (file)
@@ -202,6 +202,8 @@ public abstract class AbstractJcrQueryEditor extends EditorPart {
         */
        protected ColumnLabelProvider getLabelProvider(final String columnName) {
                return new ColumnLabelProvider() {
+                       private static final long serialVersionUID = -3539689333250152606L;
+
                        public String getText(Object element) {
                                Row row = (Row) element;
                                try {
@@ -240,6 +242,7 @@ public abstract class AbstractJcrQueryEditor extends EditorPart {
 
        private class QueryResultContentProvider implements
                        IStructuredContentProvider {
+               private static final long serialVersionUID = -5421095459600554741L;
 
                public void dispose() {
                }
@@ -292,6 +295,8 @@ public abstract class AbstractJcrQueryEditor extends EditorPart {
                        return null;
 
                SelectionAdapter selectionAdapter = new SelectionAdapter() {
+                       private static final long serialVersionUID = 239829307927778349L;
+
                        @Override
                        public void widgetSelected(SelectionEvent e) {
 
index 1c68f758debe5c2ed749b58bb320d8f42266974e..c701568ab6c483b57c8cc9e9fcfd912393f759fc 100644 (file)
@@ -1,5 +1,6 @@
 Require-Bundle: org.eclipse.core.runtime
 Import-Package: org.eclipse.core.commands,\
+                               org.eclipse.jface.window,
                                org.eclipse.swt,\
                                org.eclipse.swt.widgets;version="[0,1)",\
                                org.osgi.framework;version="[1.5,2)",\
@@ -8,7 +9,6 @@ Import-Package: org.eclipse.core.commands,\
                                org.springframework.core.io.support,\
                                *
 
-                               
 # Was: 
 #Bundle-ActivationPolicy: lazy
 #Bundle-SymbolicName: org.argeo.eclipse.ui;singleton:=true
index b831bf204f0e4b004510da20c4211c62e24b0804..26a46c8674df5ca83951c1c0631e45d251858b2c 100644 (file)
        <artifactId>org.argeo.eclipse.ui</artifactId>
        <name>Commons Eclipse UI</name>
        <packaging>jar</packaging>
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.felix</groupId>
-                               <artifactId>maven-bundle-plugin</artifactId>
-                               <configuration>
-                                       <instructions>
-                                               <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
-                                       </instructions>
-                               </configuration>
-                       </plugin>
-               </plugins>
-       </build>
+       <!-- <build> <plugins> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> 
+               <configuration> <instructions> <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName> 
+               </instructions> </configuration> </plugin> </plugins> </build> -->
        <dependencies>
                <!-- We build against RAP -->
                <dependency>
@@ -48,7 +38,7 @@
                        <version>2.1.12-SNAPSHOT</version>
                </dependency>
 
-               <!--  Bridge Spring and OSGi -->
+               <!-- Bridge Spring and OSGi -->
                <dependency>
                        <groupId>org.argeo.tp</groupId>
                        <artifactId>org.springframework.osgi.extender</artifactId>
index 8e1c7e63210cd34b75caff9b901d6f9bdf0585ec..3455577ceac63e7679071eb1acf994850b27e759 100644 (file)
@@ -27,13 +27,13 @@ import org.eclipse.swt.widgets.Text;
 /** Utilities to simplify UI development. */
 public class EclipseUiUtils {
        /**
-        * Create a label and a text field for a grid layout, the text field grabing
+        * Create a label and a text field for a grid layout, the text field grabbing
         * excess horizontal
         * 
         * @param parent
         *            the parent composite
         * @param label
-        *            the lable to display
+        *            the label to display
         * @param modifyListener
         *            a {@link ModifyListener} to listen on events on the text, can
         *            be null
@@ -64,7 +64,7 @@ public class EclipseUiUtils {
        }
 
        /**
-        * Creates one label and a text field not editable with background color of
+        * Creates one label and a text field not editable with background colour of
         * the parent (like a label but with selectable text)
         */
        public static Text createGridLL(Composite parent, String label, String text) {
index b58f44694e18f084290c191b74fb34f777c0fd5d..e47a8360480e4bececf10aeeade3b67bad9bbc81 100644 (file)
@@ -15,9 +15,9 @@
  */
 package org.argeo.eclipse.ui.dialogs;
 
-import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.window.Window;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.layout.GridData;
@@ -40,7 +40,7 @@ public class SingleValue extends TitleAreaDialog {
 
        public static String ask(String label, String message) {
                SingleValue svd = new SingleValue(label, message);
-               if (svd.open() == Dialog.OK)
+               if (svd.open() == Window.OK)
                        return svd.getString();
                else
                        return null;
@@ -48,7 +48,7 @@ public class SingleValue extends TitleAreaDialog {
 
        public static Long askLong(String label, String message) {
                SingleValue svd = new SingleValue(label, message);
-               if (svd.open() == Dialog.OK)
+               if (svd.open() == Window.OK)
                        return svd.getLong();
                else
                        return null;
@@ -56,7 +56,7 @@ public class SingleValue extends TitleAreaDialog {
 
        public static Double askDouble(String label, String message) {
                SingleValue svd = new SingleValue(label, message);
-               if (svd.open() == Dialog.OK)
+               if (svd.open() == Window.OK)
                        return svd.getDouble();
                else
                        return null;
index 32ae1a7005ecd0d3e488c568abf6e77eef6c80a7..dd571ae6e75dd44437618029d949d879670f392f 100644 (file)
@@ -28,7 +28,6 @@ public class JcrUiUtils {
        public static boolean setJcrProperty(Node node, String propName,
                        int propertyType, Object value) {
                try {
-                       // int propertyType = getPic().getProperty(propName).getType();
                        switch (propertyType) {
                        case PropertyType.STRING:
                                if ("".equals((String) value)
@@ -93,7 +92,7 @@ public class JcrUiUtils {
 
        /**
         * Creates a new selection adapter in order to provide sorting abitily on a
-        * swt table that display a row list
+        * SWT Table that display a row list
         **/
        public static SelectionAdapter getRowSelectionAdapter(final int index,
                        final int propertyType, final String selectorName,
diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/views/AbstractJcrBrowser.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/views/AbstractJcrBrowser.java
deleted file mode 100644 (file)
index 58f56c2..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.jcr.views;
-
-
-@ Deprecated 
-public abstract class AbstractJcrBrowser {}
-
-// public abstract class AbstractJcrBrowser extends ViewPart {
-//
-// @Override
-// public abstract void createPartControl(Composite parent);
-//
-// /**
-// * To be overridden to adapt size of form and result frames.
-// */
-// abstract protected int[] getWeights();
-//
-// /**
-// * To be overridden to provide an adapted size nodeViewer
-// */
-// abstract protected TreeViewer createNodeViewer(Composite parent,
-// ITreeContentProvider nodeContentProvider);
-//
-// /**
-// * To be overridden to retrieve the current nodeViewer
-// */
-// abstract protected TreeViewer getNodeViewer();
-//
-// /*
-// * Enables the refresh of the tree.
-// */
-// @Override
-// public void setFocus() {
-// getNodeViewer().getTree().setFocus();
-// }
-//
-// public void refresh(Object obj) {
-// // getNodeViewer().update(obj, null);
-// getNodeViewer().refresh(obj);
-// // getNodeViewer().expandToLevel(obj, 1);
-// }
-//
-// public void nodeAdded(Node parentNode, Node newNode) {
-// getNodeViewer().refresh(parentNode);
-// getNodeViewer().expandToLevel(newNode, 0);
-// }
-//
-// public void nodeRemoved(Node parentNode) {
-// IStructuredSelection newSel = new StructuredSelection(parentNode);
-// getNodeViewer().setSelection(newSel, true);
-// // Force refresh
-// IStructuredSelection tmpSel = (IStructuredSelection) getNodeViewer()
-// .getSelection();
-// getNodeViewer().refresh(tmpSel.getFirstElement());
-// }
-// }
index 42e9fab991a16d988ab34400461b1803294b1c00..a726bdb321dae1af2db78fc0c36ac9dd58c7c651 100644 (file)
@@ -31,7 +31,7 @@ public class ViewerUtils {
 
        /**
         * Creates a basic column for the given table. For the time being, we do not
-        * support moveable columns.
+        * support movable columns.
         */
        public static TableColumn createColumn(Table parent, String name,
                        int style, int width) {
@@ -44,7 +44,7 @@ public class ViewerUtils {
 
        /**
         * Creates a TableViewerColumn for the given viewer. For the time being, we
-        * do not support moveable columns.
+        * do not support movable columns.
         */
        public static TableViewerColumn createTableViewerColumn(TableViewer parent,
                        String name, int style, int width) {
@@ -58,7 +58,7 @@ public class ViewerUtils {
 
        /**
         * Creates a TreeViewerColumn for the given viewer. For the time being, we
-        * do not support moveable columns.
+        * do not support movable columns.
         */
        public static TreeViewerColumn createTreeViewerColumn(TreeViewer parent,
                        String name, int style, int width) {