From 7f945886dbd3cd0cf5b0e06b481b78ba1e2c9db9 Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Fri, 12 Dec 2014 15:04:27 +0000 Subject: [PATCH] Clean and comments. git-svn-id: https://svn.argeo.org/commons/trunk@7571 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../eclipse/ui/workbench/ErrorFeedback.java | 3 +- .../ui/workbench/WorkbenchUiPlugin.java | 46 ++++++++++-- .../parts/AbstractJcrQueryEditor.java | 5 ++ org.argeo.eclipse.ui/bnd.bnd | 2 +- org.argeo.eclipse.ui/pom.xml | 18 ++--- .../org/argeo/eclipse/ui/EclipseUiUtils.java | 6 +- .../argeo/eclipse/ui/dialogs/SingleValue.java | 8 +-- .../org/argeo/eclipse/ui/jcr/JcrUiUtils.java | 3 +- .../ui/jcr/views/AbstractJcrBrowser.java | 70 ------------------- .../argeo/eclipse/ui/utils/ViewerUtils.java | 6 +- 10 files changed, 63 insertions(+), 104 deletions(-) delete mode 100644 org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/views/AbstractJcrBrowser.java diff --git a/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/ErrorFeedback.java b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/ErrorFeedback.java index 692d8a4b9..9a5482584 100644 --- a/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/ErrorFeedback.java +++ b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/ErrorFeedback.java @@ -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; diff --git a/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/WorkbenchUiPlugin.java b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/WorkbenchUiPlugin.java index 48ed86142..4898e80d7 100644 --- a/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/WorkbenchUiPlugin.java +++ b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/WorkbenchUiPlugin.java @@ -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()); + + } + } diff --git a/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/jcr/internal/parts/AbstractJcrQueryEditor.java b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/jcr/internal/parts/AbstractJcrQueryEditor.java index d16ff06bb..161eb491c 100644 --- a/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/jcr/internal/parts/AbstractJcrQueryEditor.java +++ b/org.argeo.eclipse.ui.workbench/src/org/argeo/eclipse/ui/workbench/jcr/internal/parts/AbstractJcrQueryEditor.java @@ -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) { diff --git a/org.argeo.eclipse.ui/bnd.bnd b/org.argeo.eclipse.ui/bnd.bnd index 1c68f758d..c701568ab 100644 --- a/org.argeo.eclipse.ui/bnd.bnd +++ b/org.argeo.eclipse.ui/bnd.bnd @@ -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 diff --git a/org.argeo.eclipse.ui/pom.xml b/org.argeo.eclipse.ui/pom.xml index b831bf204..26a46c867 100644 --- a/org.argeo.eclipse.ui/pom.xml +++ b/org.argeo.eclipse.ui/pom.xml @@ -11,19 +11,9 @@ org.argeo.eclipse.ui Commons Eclipse UI jar - - - - org.apache.felix - maven-bundle-plugin - - - ${project.artifactId};singleton:=true - - - - - + @@ -48,7 +38,7 @@ 2.1.12-SNAPSHOT - + org.argeo.tp org.springframework.osgi.extender diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java index 8e1c7e632..3455577ce 100644 --- a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java +++ b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java @@ -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) { diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/dialogs/SingleValue.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/dialogs/SingleValue.java index b58f44694..e47a83604 100644 --- a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/dialogs/SingleValue.java +++ b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/dialogs/SingleValue.java @@ -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; diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/JcrUiUtils.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/JcrUiUtils.java index 32ae1a700..dd571ae6e 100644 --- a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/JcrUiUtils.java +++ b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/JcrUiUtils.java @@ -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 index 58f56c281..000000000 --- a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/jcr/views/AbstractJcrBrowser.java +++ /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()); -// } -// } diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/ViewerUtils.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/ViewerUtils.java index 42e9fab99..a726bdb32 100644 --- a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/ViewerUtils.java +++ b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/utils/ViewerUtils.java @@ -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) { -- 2.30.2