diff --git a/plugins/org.locationtech.udig.core.tests/META-INF/MANIFEST.MF b/plugins/org.locationtech.udig.core.tests/META-INF/MANIFEST.MF
index fdf561a34d..d45d81f3bb 100644
--- a/plugins/org.locationtech.udig.core.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.locationtech.udig.core.tests/META-INF/MANIFEST.MF
@@ -6,8 +6,12 @@ Bundle-Version: 2.3.0.qualifier
Bundle-Vendor: udig.refractions.net
Eclipse-BuddyPolicy: ext
Require-Bundle: org.eclipse.core.runtime,
- org.junit,
- org.locationtech.udig.libs
+ org.junit;bundle-version="4.12.0",
+ org.locationtech.udig.libs,
+ org.mockito;bundle-version="2.23.0",
+ org.objenesis;bundle-version="2.6.0",
+ net.bytebuddy.byte-buddy;bundle-version="1.9.0",
+ net.bytebuddy.byte-buddy-agent;bundle-version="1.9.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Fragment-Host: org.locationtech.udig.core
diff --git a/plugins/org.locationtech.udig.core.tests/build.properties b/plugins/org.locationtech.udig.core.tests/build.properties
index 868644f3a3..735bfbe639 100644
--- a/plugins/org.locationtech.udig.core.tests/build.properties
+++ b/plugins/org.locationtech.udig.core.tests/build.properties
@@ -5,5 +5,6 @@ bin.includes = META-INF/,\
.,\
bsd3-v10.html,\
epl-v10.html,\
- about.html
+ about.html,\
+ src/mockito-extensions/
src.includes = LICENSE.txt
diff --git a/plugins/org.locationtech.udig.core.tests/src/mockito-extensions/org.mockito.plugins.MockMaker b/plugins/org.locationtech.udig.core.tests/src/mockito-extensions/org.mockito.plugins.MockMaker
new file mode 100644
index 0000000000..ca6ee9cea8
--- /dev/null
+++ b/plugins/org.locationtech.udig.core.tests/src/mockito-extensions/org.mockito.plugins.MockMaker
@@ -0,0 +1 @@
+mock-maker-inline
\ No newline at end of file
diff --git a/plugins/org.locationtech.udig.core.tests/src/org/locationtech/udig/core/logging/LoggingSupportTest.java b/plugins/org.locationtech.udig.core.tests/src/org/locationtech/udig/core/logging/LoggingSupportTest.java
new file mode 100644
index 0000000000..40bb1bb2eb
--- /dev/null
+++ b/plugins/org.locationtech.udig.core.tests/src/org/locationtech/udig/core/logging/LoggingSupportTest.java
@@ -0,0 +1,107 @@
+/**
+ * uDig - User Friendly Desktop Internet GIS client
+ * https://locationtech.org/projects/technology.udig
+ * (C) 2021, Eclipse Foundation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ */
+package org.locationtech.udig.core.logging;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.osgi.framework.Bundle;
+
+@RunWith(MockitoJUnitRunner.class)
+public class LoggingSupportTest {
+
+ private static final String BUNDLE_NAME = "test.bundle";
+
+ @Mock
+ Plugin plugin;
+
+ @Mock
+ ILog log;
+
+ @Mock
+ Bundle bundle;
+
+ @Captor
+ ArgumentCaptor
* This should be used for user level messages.
*
- * It is much prefered to do this:
+ * It is much preferred to do this:
*
- *
@@ -192,7 +187,7 @@ public static void trace( String message, Throwable e ) {
*
* @param trace currently only RENDER is defined
*/
- public static boolean isDebugging( final String trace ) {
+ public static boolean isDebugging(final String trace) {
return getDefault().isDebugging()
&& "true".equalsIgnoreCase(Platform.getDebugOption(trace)); //$NON-NLS-1$
}
diff --git a/plugins/org.locationtech.udig.core/src/org/locationtech/udig/core/logging/LoggingSupport.java b/plugins/org.locationtech.udig.core/src/org/locationtech/udig/core/logging/LoggingSupport.java
new file mode 100644
index 0000000000..08237b30e2
--- /dev/null
+++ b/plugins/org.locationtech.udig.core/src/org/locationtech/udig/core/logging/LoggingSupport.java
@@ -0,0 +1,175 @@
+/**
+ * uDig - User Friendly Desktop Internet GIS client
+ * https://locationtech.org/projects/technology.udig
+ * (C) 2021, Eclipse Foundation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ */
+package org.locationtech.udig.core.logging;
+
+import java.text.MessageFormat;
+
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.locationtech.udig.core.internal.CorePlugin;
+
+/**
+ * To allow logging in the same way and with the same behaviour overall modules this provides access
+ * to Plug-In Logging capability.
+ *
+ * In addition for developer purposes it allows you to trace messages, in case of Debugging-Mode for
+ * Plug-In is enabled (see {@link Plugin#isDebugging()}).
+ *
+ * @author Frank Gasdorf (fgdrf)
+ *
+ */
+public class LoggingSupport {
+
+ /**
+ * @param plugin Plug-In to create log messages for
+ * @param status Status to log
+ */
+ public static void log(Plugin plugin, IStatus status) {
+ if (plugin != null) {
+ plugin.getLog().log(status);
+ }
+ }
+
+ /**
+ * Writes an info log in the plugin's log.
+ *
+ * This should be used for user level messages.
+ *
+ * @param plugin Plug-In to create log messages for
+ * @param logMessage message or just null, in case of Just logging throwable/exception
+ * @param e {@link Throwable} will be logged as {@link IStatus#WARNING}, {@link Exception} is
+ * logged as {@link IStatus#ERROR}, if
+ * It is much preferred to do this:
+ *
+ *
+ * Note:
- * This should be used for user level messages.
- *
* This should be used for user level messages.
*
- * It is much prefered to do this:
- *
- * ID
field */
- public static final String ID = "org.locationtech.udig.core"; //$NON-NLS-1$
private static CorePlugin plugin;
-
-
/**
- * A url stream handler that delegates to the default one but if it doesn't work then it returns null as the stream.
+ * A url stream handler that delegates to the default one but if it doesn't work then it returns
+ * null as the stream.
*/
- public static final URLStreamHandler RELAXED_HANDLER=new URLStreamHandler(){
+ public static final URLStreamHandler RELAXED_HANDLER = new URLStreamHandler() {
@Override
- protected URLConnection openConnection( URL u ) throws IOException {
- try{
- URL url=new URL(u.toString());
+ protected URLConnection openConnection(URL u) throws IOException {
+ try {
+ URL url = new URL(u.toString());
return url.openConnection();
- }catch (MalformedURLException e){
+ } catch (MalformedURLException e) {
return null;
}
}
@@ -67,40 +64,40 @@ public CorePlugin() {
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
- public void start( BundleContext context ) throws Exception {
+ @Override
+ public void start(BundleContext context) throws Exception {
super.start(context);
}
/**
- * Create a URL from the provided spec; willing to create
- * a URL even if the spec does not have a registered handler.
- * Can be used to create "jdbc" URLs for example.
+ * Create a URL from the provided spec; willing to create a URL even if the spec does not have a
+ * registered handler. Can be used to create "jdbc" URLs for example.
*
* @param spec
* @return URL if possible
* @throws RuntimeException of a MalformedURLException resulted
*/
- public static URL createSafeURL( String spec ) {
+ public static URL createSafeURL(String spec) {
try {
return new URL(null, spec, RELAXED_HANDLER);
} catch (MalformedURLException e) {
- throw (RuntimeException) new RuntimeException( e );
+ throw new RuntimeException(e);
}
}
+
/**
- * Create a URI from the provided spec; willing to create
- * a URI even if the spec does not have a registered handler.
- * Can be used to create "jdbc" URLs for example.
+ * Create a URI from the provided spec; willing to create a URI even if the spec does not have a
+ * registered handler. Can be used to create "jdbc" URLs for example.
*
* @param spec
* @return URI if possible
* @throws RuntimeException of a URISyntaxException resulted
*/
- public static URI createSafeURI( String spec ){
+ public static URI createSafeURI(String spec) {
try {
- return new URI( spec );
+ return new URI(spec);
} catch (URISyntaxException e) {
- throw (RuntimeException) new RuntimeException( e );
+ throw new RuntimeException(e);
}
}
@@ -116,7 +113,7 @@ public static CorePlugin getDefault() {
/**
* Takes a string, and splits it on '\n' and calls stringsToURLs(String[])
*/
- public static List
- * private static final String RENDERING = "org.locationtech.udig.project/render/trace";
- * if (ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase(RENDERING)) {
- * System.out.println("your message here");
- * }
+ *
+ *
private static final String RENDERING =
+ * "org.locationtech.udig.project/render/trace"; if
+ * (ProjectUIPlugin.getDefault().isDebugging() &&
+ * "true".equalsIgnoreCase(RENDERING)) { System.out.println("your message
+ * here"); }
*
+ * @deprecated Use {@link LoggingSupport#trace(Plugin, String, Throwable)} instead.
*/
- public static void trace( String message, Throwable e ) {
- if (getDefault().isDebugging()) {
- if (message != null)
- System.out.println(message);
- if (e != null)
- e.printStackTrace();
- }
+ public static void trace(String message, Throwable e) {
+ LoggingSupport.trace(getDefault(), message, e);
}
+
/**
* Performs the Platform.getDebugOption true check on the provided trace
*
null
that just {@link IStatus#INFO}
+ */
+ public static void log(Plugin plugin, String logMessage, Throwable e) {
+ String message = logMessage;
+
+ Plugin logPlugin = (plugin == null ? CorePlugin.getDefault() : plugin);
+
+ int status = (e == null ? IStatus.INFO
+ : (e instanceof Exception ? IStatus.ERROR : IStatus.WARNING));
+
+ if (!(status == IStatus.INFO && StringUtils.isEmpty(message))) {
+ log(logPlugin, new Status(status, logPlugin.getBundle().getSymbolicName(), message, e));
+ }
+ }
+
+ /**
+ * See {@link #log(Plugin, String, Throwable)} just without an explicit logMessage.
+ */
+ public static void log(Plugin plugin, Throwable e) {
+ log(plugin, null, e);
+ }
+
+ /**
+ * See {@link #log(Plugin, String, Throwable)} just without an explicit {@link Throwable}
+ */
+ public static void log(Plugin plugin, String logMessage) {
+ log(plugin, logMessage, null);
+ }
+
+ /**
+ * Logs the given throwable to the platform log, indicating the class and
+ * method from where it is being logged (this is not necessarily where it
+ * occurred).
+ *
+ * This convenience method is for internal use by the Workbench only and
+ * must not be called outside the Workbench.
+ *
+ * @param plugin Plug-In to create log messages for
+ * @param clazz
+ * The calling class.
+ * @param methodName
+ * The calling method name.
+ * @param t
+ * The throwable from where the problem actually occurred.
+ */
+ public static void log(Plugin plugin, Class> clazz, String methodName, Throwable t) {
+ final String msg = MessageFormat.format("Exception in {0}.{1}: {2}", //$NON-NLS-1$
+ new Object[] { clazz.getName(), methodName, t });
+ log(plugin, msg, t);
+ }
+
+ /**
+ * Messages that only engage if is debugging is enabled for the given Plug-In.
+ *
+ *
+ * private static final String RENDERING = "org.locationtech.udig.project/render/trace";
+ * if (ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase(RENDERING)) {
+ * System.out.println("your message here");
+ * }
+ *
+ *
+ * @param plugin
+ */
+ public static void trace(Plugin plugin, String message, Throwable e) {
+ if (plugin != null && plugin.isDebugging()) {
+ if (message != null)
+ System.out.println(message);
+ if (e != null)
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Adds the name of the caller class to the message.
+ *
+ * @param plugin Plug-In to create log messages for
+ * @param caller class of the object doing the trace.
+ * @param message tracing message, may be null.
+ * @param e exception, may be null.
+ */
+ public static void trace(Plugin plugin, Class< ? > caller, String message, Throwable e ) {
+ if (caller != null) {
+ trace(plugin, caller.getSimpleName() + ": " + message, e); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Messages that only engage if getDefault().isDebugging() and the trace option traceID is true.
+ * Available trace options can be found in the Trace class. (They must also be part of the .options file)
+ *
+ * @param plugin Plug-In to create log messages for
+ * @param traceID
+ * @param caller class of the object doing the trace.
+ * @param message tracing message, may be null.
+ * @param e exception, may be null.
+
+ * @param default1
+ * @param caller
+ * @param message
+ * @param e
+ */
+ public static void trace(Plugin plugin, String traceID, Class> caller, String message,
+ Throwable e) {
+ if (isDebugging(plugin, traceID)) {
+ trace(plugin, traceID, caller, message, e);
+ }
+ }
+
+ /**
+ * Performs the Platform.getDebugOption true check on the provided trace
+ * plugin.isDebugging()
must also be on.
+ *
- * private static final String RENDERING = "org.locationtech.udig.project/render/trace";
- * if( ProjectUIPlugin.getDefault().isDebugging() && "true".equalsIgnoreCase( RENDERING ) ){
- * System.out.println( "your message here" );
- * }
+ *
+ * @deprecated Use
+ * {@link LoggingSupport#trace(org.eclipse.core.runtime.Plugin, String, Throwable)}
+ * instead.
*/
public static void trace(String message, Throwable e) {
- if (getDefault().isDebugging()) {
- if (message != null)
- System.out.println(message);
- if (e != null)
- e.printStackTrace();
- }
+ LoggingSupport.trace(getDefault(), message, e);
}
/**
@@ -101,11 +95,11 @@ public static void trace(String message, Throwable e) {
*
- * InfoTool makes use its ModalTool superclass to access RenderManager; - * getInfo is a first class request supported by the API. You can however trace through - * this code as an example for creating your own tools. + * InfoTool makes use its ModalTool superclass to access RenderManager; getInfo is a first class + * request supported by the API. You can however trace through this code as an example for creating + * your own tools. *
** Workflow: @@ -46,108 +45,119 @@ *
* See class description for intended workflow. *
+ * * @see org.locationtech.udig.project.ui.tool.AbstractTool#mouseReleased(MapMouseEvent) */ + @Override public void mouseReleased(MapMouseEvent e) { - try { - - ReferencedEnvelope bbox = context.getBoundingBox( e.getPoint(), 5 ); - + try { + + ReferencedEnvelope bbox = context.getBoundingBox(e.getPoint(), 5); + final InfoView2.InfoRequest request = new InfoView2.InfoRequest(); request.bbox = bbox; request.layers = context.getMapLayers(); - - Display.getDefault().asyncExec(new Runnable(){ + + Display.getDefault().asyncExec(new Runnable() { + @Override public void run() { - InfoView2 infoView=(InfoView2) ApplicationGIS.getView(true, InfoView2.VIEW_ID); - - // JONES: deselect current feature so it won't flash when view is activated (it won't be valid - // one the new search passes. - if( infoView!=null) - if( infoView.getSite().getSelectionProvider()!=null ) - infoView.getSite().getSelectionProvider().setSelection(new StructuredSelection()); - - //JONES: activate view now that there is no current selection. - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - if (!page.isPartVisible(infoView)) page.bringToTop(infoView); - + InfoView2 infoView = (InfoView2) ApplicationGIS.getView(true, + InfoView2.VIEW_ID); + + // JONES: deselect current feature so it won't flash when view is activated (it + // won't be valid + // one the new search passes. + if (infoView != null) + if (infoView.getSite().getSelectionProvider() != null) + infoView.getSite().getSelectionProvider() + .setSelection(new StructuredSelection()); + + // JONES: activate view now that there is no current selection. + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getActivePage(); + if (!page.isPartVisible(infoView)) + page.bringToTop(infoView); + // we got here and info was null? Don't want to fail on first attempt - infoView=(InfoView2) ApplicationGIS.getView(false, InfoView2.VIEW_ID); - infoView.search( request ); + infoView = (InfoView2) ApplicationGIS.getView(false, InfoView2.VIEW_ID); + infoView.search(request); } - }); - } catch ( Throwable e1) { - // Should log problem .. - InfoPlugin.log( "Could not display information", e1 ); //$NON-NLS-1$ - } - finally { - draw.setValid( false ); // get us off the draw stack for context.getViewportPane().repaint(); + }); + } catch (Throwable e1) { + LoggingSupport.log(InfoPlugin.getDefault(), "Could not display information", e1); //$NON-NLS-1$ + } finally { + draw.setValid(false); // get us off the draw stack for + // context.getViewportPane().repaint(); context.getViewportPane().repaint(); } } - + /** * @see org.locationtech.udig.project.ui.tool.Tool#dispose() */ + @Override public void dispose() { super.dispose(); } diff --git a/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/InfoView2.java b/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/InfoView2.java index 9ce8758430..e03fcfe99c 100644 --- a/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/InfoView2.java +++ b/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/InfoView2.java @@ -56,6 +56,7 @@ import org.geotools.util.factory.GeoTools; import org.locationtech.udig.catalog.IGeoResource; import org.locationtech.udig.core.internal.FeatureUtils; +import org.locationtech.udig.core.logging.LoggingSupport; import org.locationtech.udig.project.AdaptableFeature; import org.locationtech.udig.project.ILayer; import org.locationtech.udig.project.ILayerListener; @@ -352,7 +353,8 @@ protected void showDetail(Object selection) { StructuredSelection sel = new StructuredSelection(src); featureDisplay.selectionChanged(null, sel); } catch (IOException ex) { - InfoPlugin.log("GML value could not be acquired.", ex); //$NON-NLS-1$ + LoggingSupport.log(InfoPlugin.getDefault(), "GML value could not be acquired.", //$NON-NLS-1$ + ex); } // featureDisplay.setInfo(info); } else if (info.getRequestURL() != null @@ -430,7 +432,7 @@ protected void searchImplementation(Object filter, IProgressMonitor monitor, Res set.addAll(more); } } catch (Throwable t) { - InfoPlugin.log("Information request " + layer.getName() + " failed " + t, t); //$NON-NLS-1$ //$NON-NLS-2$ + LoggingSupport.log(InfoPlugin.getDefault(), "Information request " + layer.getName() + " failed " + t, t); //$NON-NLS-1$ //$NON-NLS-2$ } continue; } diff --git a/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/WMSDescribeLayer.java b/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/WMSDescribeLayer.java index b259dc4654..b68655659c 100644 --- a/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/WMSDescribeLayer.java +++ b/plugins/org.locationtech.udig.info/src/org/locationtech/udig/tool/info/internal/WMSDescribeLayer.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.Set; +import org.locationtech.udig.core.logging.LoggingSupport; import org.locationtech.udig.project.ILayer; import org.locationtech.udig.project.IMap; import org.locationtech.udig.project.render.ICompositeRenderContext; @@ -42,7 +43,6 @@ import org.geotools.ows.wms.response.GetFeatureInfoResponse; import org.geotools.geometry.jts.ReferencedEnvelope; import org.geotools.referencing.CRS; -import org.geotools.referencing.crs.DefaultGeographicCRS; import org.opengis.metadata.Identifier; import org.opengis.referencing.FactoryException; import org.opengis.referencing.NoSuchAuthorityCodeException; @@ -52,53 +52,53 @@ import org.locationtech.jts.geom.Envelope; public class WMSDescribeLayer { - + /** Figures out the mapping from wms layers to udig layers */ private Mapbrowser
field */
protected Browser browser;
-
+
private Action backAction = new Action("Back") { //$NON-NLS-1$
+ @Override
public void run() {
browser.back();
}
- };
+ };
private Action forwardAction = new Action("Forward") { //$NON-NLS-1$
+ @Override
public void run() {
browser.forward();
}
};
private Action stopAction = new Action("Stop") { //$NON-NLS-1$
+ @Override
public void run() {
browser.stop();
// cancel any partial progress.
@@ -63,6 +67,7 @@ public void run() {
};
private Action refreshAction = new Action("Refresh") { //$NON-NLS-1$
+ @Override
public void run() {
browser.refresh();
}
@@ -71,38 +76,41 @@ public void run() {
static final protected boolean DEBUG = false;
//private CLabel label;
private ViewForm viewForm;
-
+
/*
- * Nested viewForm containing browser, locationbar and toolbar
+ * Nested viewForm containing browser, locationbar and toolbar
* @return embded browser
*/
+ @Override
public Control getControl() {
return viewForm;
}
/*
* Set up w/ an embeded brower.
*/
+ @Override
public void createDisplay( Composite parent ) {
viewForm= new ViewForm( parent, SWT.NONE);
-
+
//label= new CLabel( viewForm, SWT.NONE);
//viewForm.setTopLeft( label );
-
+
ToolBar toolBar= new ToolBar( viewForm, SWT.FLAT | SWT.WRAP);
viewForm.setTopCenter(toolBar);
-
- browser = createBrowser( viewForm, toolBar );
+
+ browser = createBrowser( viewForm, toolBar );
browser.setUrl( "about:blank" ); //$NON-NLS-1$
-
+
viewForm.setContent( browser );
}
-
+
/**
* Focus the browser onto LayerPointInfo.getRequestURL.
- *
+ *
* @see org.locationtech.udig.tool.info.InfoDisplay#setInfo(org.locationtech.udig.project.render.LayerPointInfo)
* @param info
*/
+ @Override
public void setInfo( LayerPointInfo info ) {
if( info == null || info.getRequestURL() == null ) {
browser.setVisible( false );
@@ -112,21 +120,21 @@ public void setInfo( LayerPointInfo info ) {
try {
browser.setText((String) info.acquireValue());
} catch (IOException e) {
- InfoPlugin.trace("Could not acquire info value", e);
+ LoggingSupport.trace(InfoPlugin.getDefault(), "Could not acquire info value", e);
}
}
}
-
-
- private Browser createBrowser(Composite parent, final ToolBar toolbar) {
+
+ private Browser createBrowser(Composite parent, final ToolBar toolbar) {
try{
browser = new Browser(parent, SWT.NONE);
}catch(Exception e){
- InfoPlugin.log( "Could not create browser", e); //$NON-NLS-1$
+ LoggingSupport.log(InfoPlugin.getDefault(), "Could not create browser", e); //$NON-NLS-1$
}
-
+
browser.addStatusTextListener(new StatusTextListener() {
- // IStatusLineManager status = toolbar.getStatusLineManager();
+ // IStatusLineManager status = toolbar.getStatusLineManager();
+ @Override
public void changed(StatusTextEvent event) {
/*
if (DEBUG) {
@@ -134,29 +142,31 @@ public void changed(StatusTextEvent event) {
}
status.setMessage(event.text);
*/
- }
+ }
});
browser.addLocationListener(new LocationAdapter() {
+ @Override
public void changed(LocationEvent event) {
if (event.top){
- //label.setToolTipText( browser.getUrl() );
+ //label.setToolTipText( browser.getUrl() );
}
}
});
browser.addTitleListener(new TitleListener() {
+ @Override
public void changed(TitleEvent event) {
//label.setText( event.title );
}
});
-
+
// Hook the navigation actons as handlers for the retargetable actions
// defined in BrowserActionBuilder.
- ToolBarManager tbmanager= new ToolBarManager( toolbar );
+ ToolBarManager tbmanager= new ToolBarManager( toolbar );
tbmanager.add( backAction );
tbmanager.add( forwardAction );
tbmanager.add( stopAction) ;
tbmanager.add( refreshAction );
-
+
return browser;
}
}
diff --git a/plugins/org.locationtech.udig.issues.tests/META-INF/MANIFEST.MF b/plugins/org.locationtech.udig.issues.tests/META-INF/MANIFEST.MF
index 714ee123b5..703c69547d 100644
--- a/plugins/org.locationtech.udig.issues.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.locationtech.udig.issues.tests/META-INF/MANIFEST.MF
@@ -8,6 +8,8 @@ Bundle-Vendor: udig.refractions.net
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.locationtech.udig.issues,
- org.locationtech.udig.project.ui.tests
+ org.locationtech.udig.project.ui.tests,
+ org.locationtech.udig.project;bundle-version="2.3.0",
+ org.locationtech.udig.ui
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/org.locationtech.udig.issues/META-INF/MANIFEST.MF b/plugins/org.locationtech.udig.issues/META-INF/MANIFEST.MF
index bcb6a94c93..79443f2b5f 100644
--- a/plugins/org.locationtech.udig.issues/META-INF/MANIFEST.MF
+++ b/plugins/org.locationtech.udig.issues/META-INF/MANIFEST.MF
@@ -8,10 +8,12 @@ Bundle-Vendor: udig.refractions.net
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.locationtech.udig.project.ui;visibility:=reexport,
org.locationtech.udig.catalog.postgis,
org.eclipse.ui.cheatsheets,
- org.locationtech.udig.libs
+ org.locationtech.udig.libs,
+ org.locationtech.udig.core,
+ org.locationtech.udig.project,
+ org.locationtech.udig.project.ui
Bundle-ActivationPolicy: lazy
Export-Package: org.locationtech.udig.issues,
org.locationtech.udig.issues.internal;x-friends:="org.locationtech.udig.issues.tests",
diff --git a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AbstractFixableIssue.java b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AbstractFixableIssue.java
index f53f59df41..9b2ae0edec 100644
--- a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AbstractFixableIssue.java
+++ b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AbstractFixableIssue.java
@@ -15,6 +15,7 @@
import org.locationtech.udig.core.IFixer;
import org.locationtech.udig.core.enums.Resolution;
import org.locationtech.udig.core.internal.ExtensionPointList;
+import org.locationtech.udig.core.logging.LoggingSupport;
import org.locationtech.udig.issues.internal.IssuesActivator;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -28,7 +29,7 @@
* Base implementation of IIssue which persists a fixerMemento (for use with an IssueFixer).
* *
- * + * * @author chorner * @since 1.1.0 */ @@ -42,9 +43,10 @@ public abstract class AbstractFixableIssue extends AbstractIssue { public static final String KEY_FIXERMEMENTO = "fixerMemento"; //$NON-NLS-1$ public static final String XPID_ISSUEFIXER = "org.locationtech.udig.issues.issueFixer"; //$NON-NLS-1$ - + IMemento fixerMemento = null; - + + @Override public void fixIssue( IViewPart part, IEditorPart editor ) { IFixer fixer = findIssueFixer(fixerMemento); if (fixer == null) { @@ -77,7 +79,7 @@ protected IFixer findIssueFixer( IMemento fixerMemento ) { break; } } - if (isValid) { //check the target class + if (isValid) { //check the target class String targetClass = element.getAttribute(ATT_TARGET); //first ensure that this class name and target name are not identical if (targetClass != null && this.getClass().getCanonicalName() != targetClass) { @@ -90,7 +92,7 @@ protected IFixer findIssueFixer( IMemento fixerMemento ) { } catch (ClassNotFoundException e) { //can't instantiate isValid = false; - IssuesActivator.log("couldn't create class " + targetClass, e); //$NON-NLS-1$ + LoggingSupport.log(IssuesActivator.getDefault(), "couldn't create class " + targetClass, e); //$NON-NLS-1$ } } } @@ -100,8 +102,7 @@ protected IFixer findIssueFixer( IMemento fixerMemento ) { try { fixer = (IFixer) element.createExecutableExtension(ATT_CLASS); } catch (Exception e) { - e.printStackTrace(); - IssuesActivator.log("Could not instantiate IssueFixer extension", e); //$NON-NLS-1$ + LoggingSupport.log(IssuesActivator.getDefault(), "Could not instantiate IssueFixer extension", e); //$NON-NLS-1$ } if (fixer != null && fixer.canFix(this, fixerMemento)) { return fixer; @@ -111,6 +112,7 @@ protected IFixer findIssueFixer( IMemento fixerMemento ) { return null; } + @Override public void init( IMemento memento, IMemento viewMemento, String issueId, String groupId, ReferencedEnvelope bounds ) { setViewMemento(viewMemento); @@ -125,16 +127,17 @@ public void init( IMemento memento, IMemento viewMemento, String issueId, String } /** - * Subclasses should override and call super.save(). + * Subclasses should override and call super.save(). */ + @Override public void save( IMemento memento ) { memento.putMemento(fixerMemento); } - + /** * Obtains the fixer memento, which contains issue state and initialization data for the * IssueFixer. - * + * * @return fixerMemento */ public IMemento getFixerMemento() { diff --git a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AddIssueOperation.java b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AddIssueOperation.java index 782825c739..29382baaea 100644 --- a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AddIssueOperation.java +++ b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/AddIssueOperation.java @@ -16,6 +16,7 @@ import java.util.HashSet; import org.locationtech.udig.core.enums.Priority; +import org.locationtech.udig.core.logging.LoggingSupport; import org.locationtech.udig.issues.internal.IssuesActivator; import org.locationtech.udig.issues.internal.Messages; import org.locationtech.udig.issues.internal.view.IssuesView; @@ -55,12 +56,13 @@ /** * Adds selected features as issues to the issues list - * + * * @author Jesse * @since 1.1.0 */ public class AddIssueOperation implements IOp { + @Override public void op( Display display, Object target, IProgressMonitor monitor ) throws Exception { Object[] array = (Object[]) target; @@ -88,7 +90,8 @@ public void op( Display display, Object target, IProgressMonitor monitor ) throw private void select(Display display, final Collection* Notifies listeners when issues are added or removed from list. *
- * + * * @author jones * @since 1.0.0 */ public class IssuesList extends AbstractSequentialList- * This should be used for user level messages. - *
- */ - public static void log(String message2, Throwable e) { - String message = message2; - if (message == null) - message = "Error in Issues plugin:" + e; //$NON-NLS-1$ - getDefault().getLog().log(new Status(IStatus.INFO, PLUGIN_ID, IStatus.OK, message, e)); - } - public static IssuesActivator getDefault() { return INSTANCE; } /* * (non-Javadoc) - * + * * @see org.locationtech.udig.core.AbstractUdigUIPlugin#getIconPath() */ + @Override public IPath getIconPath() { return new Path(ICONS_PATH); } diff --git a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/internal/IssuesManager.java b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/internal/IssuesManager.java index b8feb84e57..001cd5c9d7 100644 --- a/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/internal/IssuesManager.java +++ b/plugins/org.locationtech.udig.issues/src/org/locationtech/udig/issues/internal/IssuesManager.java @@ -21,6 +21,7 @@ import java.util.concurrent.CopyOnWriteArraySet; import org.locationtech.udig.core.internal.ExtensionPointList; +import org.locationtech.udig.core.logging.LoggingSupport; import org.locationtech.udig.issues.IIssue; import org.locationtech.udig.issues.IIssuesList; import org.locationtech.udig.issues.IIssuesManager; @@ -52,10 +53,13 @@ */ public class IssuesManager extends Object implements IIssuesManager { - private volatile IIssuesList issuesList; + private volatile IIssuesList issuesList; + private volatile DirtyIssueList dirtyListener; - private Collection- * In order to be the active map the MapEditor for the map must be the last map editor that was activated. Being - * visible or opened is not sufficient. However if the active map is closed or hidden then the active map is the new - * Map Editor that is visible. + * In order to be the active map the MapEditor for the map must be the last map editor that was + * activated. Being visible or opened is not sufficient. However if the active map is closed or + * hidden then the active map is the new Map Editor that is visible. *
- * + * * @author Jesse */ public class ListenToActiveMap { - private IPartListener2 activeMapListener=new IPartListener2(){ - - public void partActivated(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // ok this is a map and the map is actually activated (focus has been given to the editor. - // could also use the following check instead of comparing IDs: - // partRef.getPart(false) instanceof MapEditor - } - - } - - public void partBroughtToTop(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // The "active" map editor has changed. The "top" editor is the active one. - // coud also use the following check instead of comparing IDs: - // partRef.getPart(false) instanceof MapEditor - } - - } - - public void partClosed(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // a map editor has closed it is not necessarilly the active one. You - // need to do your own checks for that. - } - - } - - public void partDeactivated(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // This doesn't necessarily mean that the active map has changed - // Just that the editor no longer has focus. - } - - - } - - public void partHidden(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // The "active" map has been hidden there is now a new active map - // the method partBroughtToTop will be called so wait for that method before actually - // changing current map. - } - - - } - - public void partInputChanged(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // This should never be called - } - - } - - public void partOpened(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // A map has been openned and will probably be the active map. - } - - - - } - - public void partVisible(IWorkbenchPartReference partRef) { - if( partRef.getId().equals(MapEditorWithPalette.ID) ){ - // a map is visible but not necessarily the active map. - } - - - - } - - }; - - /** - * This assumes that the caller has acces to a site. Usually can be obtained by getSite() from a view or editor. - * - * @param site - */ - public void addActiveMapListener(IWorkbenchPartSite site){ - IWorkbenchPage page = site.getPage(); - page.addPartListener(activeMapListener); - } + private IPartListener2 activeMapListener = new IPartListener2() { + + @Override + public void partActivated(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // ok this is a map and the map is actually activated (focus has been given to the + // editor. + // could also use the following check instead of comparing IDs: + // partRef.getPart(false) instanceof MapEditor + } + + } + + @Override + public void partBroughtToTop(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // The "active" map editor has changed. The "top" editor is the active one. + // coud also use the following check instead of comparing IDs: + // partRef.getPart(false) instanceof MapEditor + } + + } + + @Override + public void partClosed(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // a map editor has closed it is not necessarilly the active one. You + // need to do your own checks for that. + } + + } + + @Override + public void partDeactivated(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // This doesn't necessarily mean that the active map has changed + // Just that the editor no longer has focus. + } + + } + + @Override + public void partHidden(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // The "active" map has been hidden there is now a new active map + // the method partBroughtToTop will be called so wait for that method before + // actually + // changing current map. + } + + } + + @Override + public void partInputChanged(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // This should never be called + } + + } + + @Override + public void partOpened(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // A map has been openned and will probably be the active map. + } + + } + + @Override + public void partVisible(IWorkbenchPartReference partRef) { + if (partRef.getId().equals(MapEditorWithPalette.ID)) { + // a map is visible but not necessarily the active map. + } + + } + + }; + + /** + * This assumes that the caller has acces to a site. Usually can be obtained by getSite() from a + * view or editor. + * + * @param site + */ + public void addActiveMapListener(IWorkbenchPartSite site) { + IWorkbenchPage page = site.getPage(); + page.addPartListener(activeMapListener); + } } diff --git a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/aoi/IAOIStrategy.java b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/aoi/IAOIStrategy.java index 59d8a34628..6fd6a08943 100644 --- a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/aoi/IAOIStrategy.java +++ b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/aoi/IAOIStrategy.java @@ -1,127 +1,126 @@ -/* uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2011, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - */ -package org.locationtech.udig.aoi; - -import java.util.Set; -import java.util.concurrent.CopyOnWriteArraySet; - -import org.locationtech.udig.internal.ui.UiPlugin; - -import org.eclipse.ui.part.IPageBookViewPage; -import org.geotools.geometry.jts.ReferencedEnvelope; -import org.opengis.referencing.crs.CoordinateReferenceSystem; - -import org.locationtech.jts.geom.Geometry; - -/** - * Defines the changing functionality of the AOI (Area of Interest) service. - * - * @author paul.pfeiffer - */ -public abstract class IAOIStrategy { - - /** - * Returns the extent of the current AOI. - * Should return null for an "All" extent - * - * @return ReferencedEnvelope - */ - public abstract ReferencedEnvelope getExtent(); - - /** - * Returns a geometry of the current AOI selected. - * Returning a null geometry specifies no AOI and by default will - * be treated as a world extent - * - * @return Geometry - */ - public abstract Geometry getGeometry(); - - /** - * Returns the CRS of the current AOI selected - * - * @return - */ - public abstract CoordinateReferenceSystem getCrs(); - - /** - * Returns the name of the AOI strategy. This is used when adding to the combo to select - * from. - * - * @return String - */ - public abstract String getName(); - - /** - * A list of listeners to be notified when the Strategy changes - */ - protected Set- * The AOIServiceImpl will register a single listener in order - * to track what is going on. - * - * @param listener - */ - public void addListener( AOIListener listener ) { - if( listener == null ){ - throw new NullPointerException("AOIService listener required to be non null"); - } - if( !listeners.contains(listener)){ - listeners.add(listener); - } - } - /** - * Remove a listener for AOI chages. - * - * @param listener - */ - public void removeListener( AOIListener listener ) { - listeners.remove(listener); - } - - /** - * Notifies listener that the value of the filter has changed. - *
- * - * @param data Geometry supplied to listeners using event.data - */ - protected void notifyListeners(AOIListener.Event event) { - for( AOIListener listener : listeners ) { - if( event == null ){ - event = new AOIListener.Event(this); - } - try { - if( listener != null ){ - listener.handleEvent( event ); - } - } catch (Exception e) { - UiPlugin.trace(UiPlugin.ID, listener.getClass(), e.getMessage(), e ); - } - } - } - - /** - * Creates a Page (used for extra selection like the bookmark strategy). - *
- * Please note this is provided by the extension point information via AOIProxy.
- * As such this method is expected to return null.
- *
- * @return Page if it exists otherwise null
- */
- public IPageBookViewPage createPage() {
- return null;
- }
-}
+/* uDig - User Friendly Desktop Internet GIS client
+ * http://udig.refractions.net
+ * (C) 2011, Refractions Research Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD
+ * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html).
+ */
+package org.locationtech.udig.aoi;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+import org.eclipse.ui.part.IPageBookViewPage;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.udig.core.logging.LoggingSupport;
+import org.locationtech.udig.internal.ui.UiPlugin;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
+/**
+ * Defines the changing functionality of the AOI (Area of Interest) service.
+ *
+ * @author paul.pfeiffer
+ */
+public abstract class IAOIStrategy {
+
+ /**
+ * Returns the extent of the current AOI.
+ * Should return null for an "All" extent
+ *
+ * @return ReferencedEnvelope
+ */
+ public abstract ReferencedEnvelope getExtent();
+
+ /**
+ * Returns a geometry of the current AOI selected.
+ * Returning a null geometry specifies no AOI and by default will
+ * be treated as a world extent
+ *
+ * @return Geometry
+ */
+ public abstract Geometry getGeometry();
+
+ /**
+ * Returns the CRS of the current AOI selected
+ *
+ * @return
+ */
+ public abstract CoordinateReferenceSystem getCrs();
+
+ /**
+ * Returns the name of the AOI strategy. This is used when adding to the combo to select
+ * from.
+ *
+ * @return String
+ */
+ public abstract String getName();
+
+ /**
+ * A list of listeners to be notified when the Strategy changes
+ */
+ protected Set
+ * The AOIServiceImpl will register a single listener in order
+ * to track what is going on.
+ *
+ * @param listener
+ */
+ public void addListener( AOIListener listener ) {
+ if( listener == null ){
+ throw new NullPointerException("AOIService listener required to be non null");
+ }
+ if( !listeners.contains(listener)){
+ listeners.add(listener);
+ }
+ }
+ /**
+ * Remove a listener for AOI chages.
+ *
+ * @param listener
+ */
+ public void removeListener( AOIListener listener ) {
+ listeners.remove(listener);
+ }
+
+ /**
+ * Notifies listener that the value of the filter has changed.
+ *
+ *
+ * @param data Geometry supplied to listeners using event.data
+ */
+ protected void notifyListeners(AOIListener.Event event) {
+ for( AOIListener listener : listeners ) {
+ if( event == null ){
+ event = new AOIListener.Event(this);
+ }
+ try {
+ if( listener != null ){
+ listener.handleEvent( event );
+ }
+ } catch (Exception e) {
+ LoggingSupport.trace(UiPlugin.getDefault(), UiPlugin.ID, listener.getClass(), e.getMessage(), e );
+ }
+ }
+ }
+
+ /**
+ * Creates a Page (used for extra selection like the bookmark strategy).
+ *
+ * Please note this is provided by the extension point information via AOIProxy.
+ * As such this method is expected to return null.
+ *
+ * @return Page if it exists otherwise null
+ */
+ public IPageBookViewPage createPage() {
+ return null;
+ }
+}
diff --git a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/aoi/AOIServiceImpl.java b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/aoi/AOIServiceImpl.java
index 079c22f226..fd4a3796df 100644
--- a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/aoi/AOIServiceImpl.java
+++ b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/aoi/AOIServiceImpl.java
@@ -1,174 +1,175 @@
-/* uDig - User Friendly Desktop Internet GIS client
- * http://udig.refractions.net
- * (C) 2011, Refractions Research Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD
- * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html).
- */
-package org.locationtech.udig.internal.aoi;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import org.locationtech.udig.aoi.AOIListener;
-import org.locationtech.udig.aoi.AOIProxy;
-import org.locationtech.udig.aoi.IAOIService;
-import org.locationtech.udig.core.internal.ExtensionPointProcessor;
-import org.locationtech.udig.core.internal.ExtensionPointUtil;
-import org.locationtech.udig.internal.ui.UiPlugin;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-import org.locationtech.jts.geom.Geometry;
-
-/**
- * This is the default implementation of AOIService; it delegates to the internal strategy
- * object.
- *
- * @author pfeiffp
- */
-public class AOIServiceImpl implements IAOIService {
-
- /** This is the AOI extension point processed to get AOIStrategy entries */
- private static final String EXT_ID = "org.locationtech.udig.ui.aoi";
-
- /**
- * the id of the all strategy (ie the default)
- */
- public static final String STRATEGY_ALL_ID = "org.locationtech.udig.ui.aoiAll";
-
- /*
- * A list of all the strategies
- */
- protected List
- * For UDIG 1.1: An application should leave this alone; and use the *org.eclipse.ui.menu* extension
- * point to slot commands into menus as needed. This ActionBarAdvisor provides the following basic
- * menus that should be applicable to all UDIG based applications:
- *
- * For UDIG 1.0: An application should declare a subclass of
- * The following advisor methods are called at strategic points in the
- * workbench's lifecycle (all occur within the dynamic scope of the call
- * to {@link PlatformUI#createAndRunWorkbench PlatformUI.createAndRunWorkbench}):
- *
- * The uDig navigate menu is a mash up between the traditional functionality
- * such as "showIn" to open views; along side commands to navigate around the
- * current map (complete with back / forward history like a web browser).
- *
- * We are focused on providing the usual "group markers" so that menu paths for action sets,
- * tools, operations or menus will work out okay (for this or *any* RCP application).
- *
- *
- * Most of the "custom" here is recorded as part of IWorkbenchActionsConstants; we are doing the
- * bare minimum here; only positioning the "group markers" in the correct spot so the relative
- * menu path goodness will work for later plugin contributions (using org.eclipse.ui.menu
- * extensions).
- *
- *
- * The window menu is mostly concerned with the care and feeding of application wide
- * customisations and settings; from access to application preferences to opening up views and
- * switching perspectives.
- *
- * window/wbStart window/... window/additions window/wbEnd
- *
- * @param windowMenu
- */
- protected void fillWindowMenu( IMenuManager windowMenu ) {
- IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow();
-
- windowMenu.add(new GroupMarker(IWorkbenchActionConstants.WB_START));
-
- //IAction openNewWindow = ActionFactory.OPEN_NEW_WINDOW.create(window);
- //openNewWindow.setText(Messages.UDIGWorkbenchAdvisor_newWindow_text);
- //windowMenu.add(openNewWindow);
-
- //windowMenu.add( new Separator());
-
- IMenuManager perspectiveMenu = new MenuManager(
- Messages.UDIGWorkbenchAdvisor_open_perspective,
- ContributionItemFactory.PERSPECTIVES_SHORTLIST.getId());
- perspectiveMenu.add(ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window));
- windowMenu.add(perspectiveMenu);
-
- IMenuManager viewMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_show_view,
- ContributionItemFactory.VIEWS_SHORTLIST.getId());
- viewMenu.add(ContributionItemFactory.VIEWS_SHORTLIST.create(window));
- windowMenu.add(viewMenu);
- windowMenu.add( new Separator());
-
- IAction resetPerspective = ActionFactory.RESET_PERSPECTIVE.create(window);
- resetPerspective.setText(Messages.UDIGWorkbenchAdvisor_resetPerspective_text);
- windowMenu.add(resetPerspective);
-
- IAction closePerspective = ActionFactory.CLOSE_PERSPECTIVE.create(window);
- closePerspective.setText(Messages.UDIGWorkbenchAdvisor_closePerspective_text);
- windowMenu.add(closePerspective);
-
- IAction closeAllPerspectives = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window);
- closeAllPerspectives.setText(Messages.UDIGWorkbenchAdvisor_closeAllPerspectives_text);
- windowMenu.add(closeAllPerspectives);
-
- windowMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
-
- windowMenu.add( new Separator());
-
- IAction preferences = ActionFactory.PREFERENCES.create(window);
- preferences.setText(Messages.UDIGWorkbenchAdvisor_preferences_text);
- IContributionItem item = new ActionContributionItem(preferences);
- item.setVisible(!Platform.OS_MACOSX.equals(Platform.getOS()));
-
- windowMenu.add(item);
-
- windowMenu.add(ContributionItemFactory.OPEN_WINDOWS.create(window));
-
- windowMenu.add(new GroupMarker(IWorkbenchActionConstants.WB_END));
- }
-
- protected void fillHelpMenu( IMenuManager helpMenu ) {
- IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow();
-
- boolean hasIntro = window
- .getWorkbench().getIntroManager().hasIntro();
- if (hasIntro) {
- if (helpMenu.findUsingPath(ActionFactory.INTRO.getId()) == null) {
- IAction welcome = ActionFactory.INTRO.create(window);
- welcome.setText(Messages.UDIGWorkbenchAdvisor_welcome_text);
- if (helpMenu.getItems().length > 0) {
- helpMenu.insertBefore(helpMenu.getItems()[0].getId(), welcome);
- } else {
- helpMenu.add(welcome);
- }
- }
- } else {
- Separator welcome = new Separator(ActionFactory.INTRO.getId());
- if (helpMenu.getItems().length > 0) {
- helpMenu.insertBefore(helpMenu.getItems()[0].getId(), welcome);
- } else {
- helpMenu.add(welcome);
- }
- }
-
- if (helpMenu.findUsingPath(Constants.HELP_START) == null) {
- helpMenu
- .insertAfter(ActionFactory.INTRO.getId(), new GroupMarker(Constants.HELP_START));
- }
-
- if (helpMenu.findUsingPath(ActionFactory.HELP_CONTENTS.getId()) == null) {
- IAction helpContents = ActionFactory.HELP_CONTENTS.create(window);
- helpContents.setText(Messages.UDIGWorkbenchAdvisor_helpContents_text);
- helpMenu.insertBefore(Constants.HELP_START, helpContents);
- }
-
- if (helpMenu.findUsingPath(Constants.HELP_END) == null) {
- helpMenu.insertAfter(Constants.HELP_START, new GroupMarker(Constants.HELP_END));
- }
-
- // Tips and tricks page would go after HELP_START
-
- if (helpMenu.findUsingPath(IWorkbenchActionConstants.MB_ADDITIONS) == null) {
- helpMenu.insertAfter(Constants.HELP_END, new GroupMarker(
- IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- // Add the separators
- helpMenu.insertAfter(ActionFactory.INTRO.getId(), new Separator());
- helpMenu.insertBefore(Constants.HELP_START, new Separator());
- helpMenu.insertAfter(Constants.HELP_END, new Separator());
- // helpMenu.insertAfter(, new Separator());
-
- addAboutItem(helpMenu, window);
- }
-
- private void addAboutItem( IMenuManager helpMenu, IWorkbenchWindow window ) {
- if (helpMenu.findUsingPath(ActionFactory.ABOUT.getId()) == null) {
- IAction about = ActionFactory.ABOUT.create(window);
- String pattern = Messages.UDIGWorkbenchAdvisor_aboutUDig_text;
- IProduct product = Platform.getProduct();
- String productName;
- if( product == null ){
- UiPlugin.log("there is no product so default to uDig", null);
- productName = "uDig";
- }else{
- productName = product.getName();
- }
- about.setText(MessageFormat.format(pattern, productName));
- // About should always be at the bottom, so just append it to the menu
- IContributionItem item = new ActionContributionItem(about);
- item.setVisible(!Platform.OS_MACOSX.equals(Platform.getOS()));
-
- helpMenu.add(item);
- }
- }
-}
+/**
+ * uDig - User Friendly Desktop Internet GIS client
+ * http://udig.refractions.net
+ * (C) 2012, Refractions Research Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD
+ * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html).
+ */
+package org.locationtech.udig.internal.ui;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IProduct;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.ICoolBarManager;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
+import org.eclipse.ui.actions.ContributionItemFactory;
+import org.eclipse.ui.application.ActionBarAdvisor;
+import org.eclipse.ui.application.IActionBarConfigurer;
+import org.eclipse.ui.application.WorkbenchWindowAdvisor;
+import org.locationtech.udig.core.internal.ExtensionPointList;
+import org.locationtech.udig.core.logging.LoggingSupport;
+import org.locationtech.udig.ui.Constants;
+import org.locationtech.udig.ui.MenuBuilder;
+import org.locationtech.udig.ui.UDIGMenuBuilder;
+import org.locationtech.udig.ui.action.NewObjectContribution;
+import org.locationtech.udig.ui.action.NewObjectDelegate;
+import org.locationtech.udig.ui.action.NewObjectDelegateComparator;
+import org.locationtech.udig.ui.internal.Messages;
+import org.locationtech.udig.ui.preferences.PreferenceConstants;
+
+/**
+ * Public base class for configuring the action bars of a workbench window.
+ *
+ * For UDIG 1.1: An application should leave this alone; and use the *org.eclipse.ui.menu* extension
+ * point to slot commands into menus as needed. This ActionBarAdvisor provides the following basic
+ * menus that should be applicable to all UDIG based applications:
+ *
+ * For UDIG 1.0: An application should declare a subclass of
+ * The following advisor methods are called at strategic points in the
+ * workbench's lifecycle (all occur within the dynamic scope of the call
+ * to {@link PlatformUI#createAndRunWorkbench PlatformUI.createAndRunWorkbench}):
+ *
- *
- * If you are wondering about the Navigate, Layer and Data menus please go check out the
- * net.refractions.catalog.ui and net.refractions.project.ui.
- * ActionBarAdvisor
and
- * override methods to configure a window's action bars to suit the needs of the particular
- * application.
- *
- *
- * fillActionBars
- called after WorkbenchWindowAdvisor.preWindowOpen
- * to configure a window's action bars
- * navigate
- * navigate/navStart
- * navigate/zoom.ext
- * navigate/additions
- * navigate/bottom
- * navigate/navEnd
- *
- *
- * @param menu
- */
- protected void fillNavigateMenu( IMenuManager menu ) {
- // menu.add(ActionFactory.BACKWARD_HISTORY.create(window));
- // menu.add(ActionFactory.FORWARD_HISTORY.create(window));
- menu.add(new GroupMarker(Constants.NAV_START));
- menu.add(new Separator());
- menu.add(new GroupMarker(Constants.NAV_ZOOM_EXT));
-
- menu.add(new Separator());
- menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
-
- menu.add(new Separator());
- menu.add(new GroupMarker(Constants.NAV_BOTTOM));
- menu.add(new GroupMarker(Constants.NAV_END));
- menu.setVisible(true);
- }
-
- /**
- * Set up Tool menu, used to interact with Map Editor.
- *
- * tools
- * tools/wbStart
- * tools/zoom.ext
- * tools/additions
- * tools/wbEnd
- *
- * @param menu
- */
- protected void fillToolMenu( IMenuManager menu) {
- menu.add(new GroupMarker(IWorkbenchActionConstants.WB_START));
- menu.add(new GroupMarker(Constants.TOOL_ACTION));
- menu.add(new Separator());
- menu.add(new GroupMarker(Constants.TOOL_MODAL));
- menu.add(new Separator());
- menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new GroupMarker(IWorkbenchActionConstants.WB_END));
- }
-
- /**
- * Set up customary File menu structure as defined by IWorkBenchActionConstants.
- *
- * file/fileStart
- * file/new.ext
- * file/new
- * file/project.ext
- * file/close.ext
- * file/close
- * file/save.ext
- * file/save
- * file/additions
- * file/print.ext
- * file/import.ext
- * file/import
- * file/export
- * file/mru
- * file/fileEnd
- * file/quit
- *
- *
- * @param window
- * @param fileMenu
- */
- protected void fillFileMenu( IMenuManager fileMenu ) {
- IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow();
-
- fileMenu.add(new GroupMarker(Constants.FILE_START));
-
- IMenuManager newMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_new, ActionFactory.NEW
- .getId());
- newMenu.add(new GroupMarker(Constants.NEW_START));
- List
- * edit/editStart
- * edit/undo.ext
- * edit/cut.ext
- * edit/add.ext
- * edit/additions
- * edit/other
- * edit/commit.ext
- * edit/editEnd
- *
- *
- * @param window
- * @param editMenu
- */
- protected void fillEditMenu( IMenuManager editMenu ) {
- IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow();
-
- editMenu.add(new GroupMarker(Constants.EDIT_START));
-
- editMenu.add(new GroupMarker(Constants.UNDO_EXT));
- editMenu.add(ActionFactory.UNDO.create(window));
- editMenu.add(ActionFactory.REDO.create(window));
- editMenu.add(new Separator());
-
- editMenu.add(new GroupMarker(Constants.CUT_EXT));
- editMenu.add(ActionFactory.CUT.create(window));
- editMenu.add(ActionFactory.COPY.create(window));
- editMenu.add(ActionFactory.PASTE.create(window));
- editMenu.add(new Separator());
-
- editMenu.add(ActionFactory.DELETE.create(window));
- editMenu.add(ActionFactory.SELECT_ALL.create(window));
- editMenu.add(new GroupMarker(Constants.ADD_EXT));
- editMenu.add(new Separator());
-
- editMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- editMenu.add(new GroupMarker(Constants.OTHER));
- editMenu.add(new Separator());
-
- editMenu.add(new GroupMarker(Constants.COMMIT_EXT));
- editMenu.add(new GroupMarker(Constants.EDIT_END));
- }
-
- private void fillLayerMenu( IMenuManager menu) {
- menu.add(new GroupMarker(IWorkbenchActionConstants.WB_START));
- menu.add(new GroupMarker(Constants.LAYER_ADD_EXT));
- menu.add(new Separator());
- menu.add(new GroupMarker(Constants.LAYER_MAPGRAPHIC_EXT));
- menu.add(new GroupMarker(Constants.LAYER_MAPGRAPHIC_OTHER));
- menu.add(new Separator());
- menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new GroupMarker(Constants.LAYER_EDIT_EXT));
- menu.add(new GroupMarker(IWorkbenchActionConstants.WB_END));
- }
-
- /**
- * Define the Window Menu according to RCP "custom".
- *
+ *
+ * If you are wondering about the Navigate, Layer and Data menus please go check out the
+ * net.refractions.catalog.ui and net.refractions.project.ui.
+ * ActionBarAdvisor
and
+ * override methods to configure a window's action bars to suit the needs of the particular
+ * application.
+ *
+ *
+ * fillActionBars
- called after WorkbenchWindowAdvisor.preWindowOpen
+ * to configure a window's action bars
+ * The uDig navigate menu is a mash up between the traditional functionality + * such as "showIn" to open views; along side commands to navigate around the + * current map (complete with back / forward history like a web browser). + *
+ * navigate + * navigate/navStart + * navigate/zoom.ext + * navigate/additions + * navigate/bottom + * navigate/navEnd + *+ * + * @param menu + */ + protected void fillNavigateMenu( IMenuManager menu ) { + // menu.add(ActionFactory.BACKWARD_HISTORY.create(window)); + // menu.add(ActionFactory.FORWARD_HISTORY.create(window)); + menu.add(new GroupMarker(Constants.NAV_START)); + menu.add(new Separator()); + menu.add(new GroupMarker(Constants.NAV_ZOOM_EXT)); + + menu.add(new Separator()); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + + menu.add(new Separator()); + menu.add(new GroupMarker(Constants.NAV_BOTTOM)); + menu.add(new GroupMarker(Constants.NAV_END)); + menu.setVisible(true); + } + + /** + * Set up Tool menu, used to interact with Map Editor. + *
+ * tools + * tools/wbStart + * tools/zoom.ext + * tools/additions + * tools/wbEnd + *+ * @param menu + */ + protected void fillToolMenu( IMenuManager menu) { + menu.add(new GroupMarker(IWorkbenchActionConstants.WB_START)); + menu.add(new GroupMarker(Constants.TOOL_ACTION)); + menu.add(new Separator()); + menu.add(new GroupMarker(Constants.TOOL_MODAL)); + menu.add(new Separator()); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menu.add(new GroupMarker(IWorkbenchActionConstants.WB_END)); + } + + /** + * Set up customary File menu structure as defined by IWorkBenchActionConstants. + *
+ * We are focused on providing the usual "group markers" so that menu paths for action sets, + * tools, operations or menus will work out okay (for this or *any* RCP application). + * + *
+ * file/fileStart + * file/new.ext + * file/new + * file/project.ext + * file/close.ext + * file/close + * file/save.ext + * file/save + * file/additions + * file/print.ext + * file/import.ext + * file/import + * file/export + * file/mru + * file/fileEnd + * file/quit + *+ * + * @param window + * @param fileMenu + */ + protected void fillFileMenu( IMenuManager fileMenu ) { + IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow(); + + fileMenu.add(new GroupMarker(Constants.FILE_START)); + + IMenuManager newMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_new, ActionFactory.NEW + .getId()); + newMenu.add(new GroupMarker(Constants.NEW_START)); + List
+ * Most of the "custom" here is recorded as part of IWorkbenchActionsConstants; we are doing the + * bare minimum here; only positioning the "group markers" in the correct spot so the relative + * menu path goodness will work for later plugin contributions (using org.eclipse.ui.menu + * extensions). + * + *
+ * edit/editStart + * edit/undo.ext + * edit/cut.ext + * edit/add.ext + * edit/additions + * edit/other + * edit/commit.ext + * edit/editEnd + *+ * + * @param window + * @param editMenu + */ + protected void fillEditMenu( IMenuManager editMenu ) { + IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow(); + + editMenu.add(new GroupMarker(Constants.EDIT_START)); + + editMenu.add(new GroupMarker(Constants.UNDO_EXT)); + editMenu.add(ActionFactory.UNDO.create(window)); + editMenu.add(ActionFactory.REDO.create(window)); + editMenu.add(new Separator()); + + editMenu.add(new GroupMarker(Constants.CUT_EXT)); + editMenu.add(ActionFactory.CUT.create(window)); + editMenu.add(ActionFactory.COPY.create(window)); + editMenu.add(ActionFactory.PASTE.create(window)); + editMenu.add(new Separator()); + + editMenu.add(ActionFactory.DELETE.create(window)); + editMenu.add(ActionFactory.SELECT_ALL.create(window)); + editMenu.add(new GroupMarker(Constants.ADD_EXT)); + editMenu.add(new Separator()); + + editMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + editMenu.add(new GroupMarker(Constants.OTHER)); + editMenu.add(new Separator()); + + editMenu.add(new GroupMarker(Constants.COMMIT_EXT)); + editMenu.add(new GroupMarker(Constants.EDIT_END)); + } + + private void fillLayerMenu( IMenuManager menu) { + menu.add(new GroupMarker(IWorkbenchActionConstants.WB_START)); + menu.add(new GroupMarker(Constants.LAYER_ADD_EXT)); + menu.add(new Separator()); + menu.add(new GroupMarker(Constants.LAYER_MAPGRAPHIC_EXT)); + menu.add(new GroupMarker(Constants.LAYER_MAPGRAPHIC_OTHER)); + menu.add(new Separator()); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menu.add(new GroupMarker(Constants.LAYER_EDIT_EXT)); + menu.add(new GroupMarker(IWorkbenchActionConstants.WB_END)); + } + + /** + * Define the Window Menu according to RCP "custom". + *
+ * The window menu is mostly concerned with the care and feeding of application wide + * customisations and settings; from access to application preferences to opening up views and + * switching perspectives. + *
+ * window/wbStart window/... window/additions window/wbEnd + * + * @param windowMenu + */ + protected void fillWindowMenu( IMenuManager windowMenu ) { + IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow(); + + windowMenu.add(new GroupMarker(IWorkbenchActionConstants.WB_START)); + + //IAction openNewWindow = ActionFactory.OPEN_NEW_WINDOW.create(window); + //openNewWindow.setText(Messages.UDIGWorkbenchAdvisor_newWindow_text); + //windowMenu.add(openNewWindow); + + //windowMenu.add( new Separator()); + + IMenuManager perspectiveMenu = new MenuManager( + Messages.UDIGWorkbenchAdvisor_open_perspective, + ContributionItemFactory.PERSPECTIVES_SHORTLIST.getId()); + perspectiveMenu.add(ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window)); + windowMenu.add(perspectiveMenu); + + IMenuManager viewMenu = new MenuManager(Messages.UDIGWorkbenchAdvisor_show_view, + ContributionItemFactory.VIEWS_SHORTLIST.getId()); + viewMenu.add(ContributionItemFactory.VIEWS_SHORTLIST.create(window)); + windowMenu.add(viewMenu); + windowMenu.add( new Separator()); + + IAction resetPerspective = ActionFactory.RESET_PERSPECTIVE.create(window); + resetPerspective.setText(Messages.UDIGWorkbenchAdvisor_resetPerspective_text); + windowMenu.add(resetPerspective); + + IAction closePerspective = ActionFactory.CLOSE_PERSPECTIVE.create(window); + closePerspective.setText(Messages.UDIGWorkbenchAdvisor_closePerspective_text); + windowMenu.add(closePerspective); + + IAction closeAllPerspectives = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window); + closeAllPerspectives.setText(Messages.UDIGWorkbenchAdvisor_closeAllPerspectives_text); + windowMenu.add(closeAllPerspectives); + + windowMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + + windowMenu.add( new Separator()); + + IAction preferences = ActionFactory.PREFERENCES.create(window); + preferences.setText(Messages.UDIGWorkbenchAdvisor_preferences_text); + IContributionItem item = new ActionContributionItem(preferences); + item.setVisible(!Platform.OS_MACOSX.equals(Platform.getOS())); + + windowMenu.add(item); + + windowMenu.add(ContributionItemFactory.OPEN_WINDOWS.create(window)); + + windowMenu.add(new GroupMarker(IWorkbenchActionConstants.WB_END)); + } + + protected void fillHelpMenu( IMenuManager helpMenu ) { + IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow(); + + boolean hasIntro = window + .getWorkbench().getIntroManager().hasIntro(); + if (hasIntro) { + if (helpMenu.findUsingPath(ActionFactory.INTRO.getId()) == null) { + IAction welcome = ActionFactory.INTRO.create(window); + welcome.setText(Messages.UDIGWorkbenchAdvisor_welcome_text); + if (helpMenu.getItems().length > 0) { + helpMenu.insertBefore(helpMenu.getItems()[0].getId(), welcome); + } else { + helpMenu.add(welcome); + } + } + } else { + Separator welcome = new Separator(ActionFactory.INTRO.getId()); + if (helpMenu.getItems().length > 0) { + helpMenu.insertBefore(helpMenu.getItems()[0].getId(), welcome); + } else { + helpMenu.add(welcome); + } + } + + if (helpMenu.findUsingPath(Constants.HELP_START) == null) { + helpMenu + .insertAfter(ActionFactory.INTRO.getId(), new GroupMarker(Constants.HELP_START)); + } + + if (helpMenu.findUsingPath(ActionFactory.HELP_CONTENTS.getId()) == null) { + IAction helpContents = ActionFactory.HELP_CONTENTS.create(window); + helpContents.setText(Messages.UDIGWorkbenchAdvisor_helpContents_text); + helpMenu.insertBefore(Constants.HELP_START, helpContents); + } + + if (helpMenu.findUsingPath(Constants.HELP_END) == null) { + helpMenu.insertAfter(Constants.HELP_START, new GroupMarker(Constants.HELP_END)); + } + + // Tips and tricks page would go after HELP_START + + if (helpMenu.findUsingPath(IWorkbenchActionConstants.MB_ADDITIONS) == null) { + helpMenu.insertAfter(Constants.HELP_END, new GroupMarker( + IWorkbenchActionConstants.MB_ADDITIONS)); + } + + // Add the separators + helpMenu.insertAfter(ActionFactory.INTRO.getId(), new Separator()); + helpMenu.insertBefore(Constants.HELP_START, new Separator()); + helpMenu.insertAfter(Constants.HELP_END, new Separator()); + // helpMenu.insertAfter(, new Separator()); + + addAboutItem(helpMenu, window); + } + + private void addAboutItem(IMenuManager helpMenu, IWorkbenchWindow window) { + if (helpMenu.findUsingPath(ActionFactory.ABOUT.getId()) == null) { + IAction about = ActionFactory.ABOUT.create(window); + String pattern = Messages.UDIGWorkbenchAdvisor_aboutUDig_text; + IProduct product = Platform.getProduct(); + String productName; + if (product == null) { + LoggingSupport.log(UiPlugin.getDefault(), "there is no product so default to uDig"); //$NON-NLS-1$ + productName = "uDig"; + } else { + productName = product.getName(); + } + about.setText(MessageFormat.format(pattern, productName)); + // About should always be at the bottom, so just append it to the menu + IContributionItem item = new ActionContributionItem(about); + item.setVisible(!Platform.OS_MACOSX.equals(Platform.getOS())); + + helpMenu.add(item); + } + } +} diff --git a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGApplication.java b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGApplication.java index 6e796f7b0b..2f6414f5bc 100644 --- a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGApplication.java +++ b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGApplication.java @@ -32,6 +32,7 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.application.WorkbenchAdvisor; +import org.locationtech.udig.core.logging.LoggingSupport; import org.locationtech.udig.libs.internal.Activator; import org.locationtech.udig.ui.internal.Messages; import org.osgi.framework.Bundle; @@ -134,7 +135,7 @@ public Object start(IApplicationContext context) throws Exception { try { returnCode = PlatformUI.createAndRunWorkbench(display, workbenchAdvisor); } catch (Throwable t) { - UiPlugin.log(Messages.UDIGApplication_error, t); + LoggingSupport.log(UiPlugin.getDefault(), Messages.UDIGApplication_error, t); } finally { context.applicationRunning(); display.dispose(); diff --git a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGAuthenticator.java b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGAuthenticator.java index 09f53c8506..6129e8c9a2 100644 --- a/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGAuthenticator.java +++ b/plugins/org.locationtech.udig.ui/src/org/locationtech/udig/internal/ui/UDIGAuthenticator.java @@ -1,163 +1,165 @@ -/* - * uDig - User Friendly Desktop Internet GIS client - * http://udig.refractions.net - * (C) 2004, Refractions Research Inc. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD - * License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). - * - */ -package org.locationtech.udig.internal.ui; - -import java.io.UnsupportedEncodingException; -import java.net.Authenticator; -import java.net.PasswordAuthentication; -import java.net.URLEncoder; -import java.util.HashSet; -import java.util.Set; - -import org.locationtech.udig.ui.PlatformGIS; - -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.osgi.service.prefs.Preferences; - -/** - * This is an Authenticator used when URL connection negotiation - * needs to ask for the users credentials. - *
- * This implementation is written to prompt the user with SWT; and - * to store the username/password if possible. - *
- * @since 1.0.0 - */ -public class UDIGAuthenticator extends Authenticator { - private static final String NAME = "NAME"; //$NON-NLS-1$ - private static final String PASSWORD = "PASSWORD"; //$NON-NLS-1$ - private static final String URL_AUTHENTICATION = "URL_AUTHENTICATION"; //$NON-NLS-1$ - private String username; - private String password; - private boolean storePassword; - - /** - * The {@link Set} of nodeKeys that this authenticator has tried the stored username/password - * pair for. This is to make sure that the user is asked to reenter username/password instead of - * reusing the old invalid username/password. - */ - private Set+ * This implementation is written to prompt the user with SWT; and + * to store the username/password if possible. + *
+ * @since 1.0.0 + */ +public class UDIGAuthenticator extends Authenticator { + private static final String NAME = "NAME"; //$NON-NLS-1$ + private static final String PASSWORD = "PASSWORD"; //$NON-NLS-1$ + private static final String URL_AUTHENTICATION = "URL_AUTHENTICATION"; //$NON-NLS-1$ + private String username; + private String password; + private boolean storePassword; + + /** + * The {@link Set} of nodeKeys that this authenticator has tried the stored username/password + * pair for. This is to make sure that the user is asked to reenter username/password instead of + * reusing the old invalid username/password. + */ + private Set- * The workbench window advisor object is created in response to a workbench window being created - * (one per window), and is used to configure the window. - *
- *
- * An application should declare a subclass of WorkbenchWindowAdvisor
and override
- * methods to configure workbench windows to suit the needs of the particular application.
- *
- * The following advisor methods are called at strategic points in the workbench window's lifecycle - * (as with the workbench advisor, all occur within the dynamic scope of the call to - * {@link PlatformUI#createAndRunWorkbench PlatformUI.createAndRunWorkbench}): - *
preWindowOpen
- called as the window is being opened; use to configure
- * aspects of the window other than actions barspostWindowRestore
- called after the window has been recreated from a
- * previously saved state; use to adjust the restored windowpostWindowCreate
- called after the window has been created, either from an
- * initial state or from a restored state; used to adjust the windowopenIntro
- called immediately before the window is opened in order to create
- * the introduction component, if anypostWindowOpen
- called after the window has been opened; use to hook window
- * listeners, etc.preWindowShellClose
- called when the window's shell is closed by the user;
- * use to pre-screen window closings+ * The workbench window advisor object is created in response to a workbench window being created + * (one per window), and is used to configure the window. + *
+ *
+ * An application should declare a subclass of WorkbenchWindowAdvisor
and override
+ * methods to configure workbench windows to suit the needs of the particular application.
+ *
+ * The following advisor methods are called at strategic points in the workbench window's lifecycle + * (as with the workbench advisor, all occur within the dynamic scope of the call to + * {@link PlatformUI#createAndRunWorkbench PlatformUI.createAndRunWorkbench}): + *
preWindowOpen
- called as the window is being opened; use to configure
+ * aspects of the window other than actions barspostWindowRestore
- called after the window has been recreated from a
+ * previously saved state; use to adjust the restored windowpostWindowCreate
- called after the window has been created, either from an
+ * initial state or from a restored state; used to adjust the windowopenIntro
- called immediately before the window is opened in order to create
+ * the introduction component, if anypostWindowOpen
- called after the window has been opened; use to hook window
+ * listeners, etc.preWindowShellClose
- called when the window's shell is closed by the user;
+ * use to pre-screen window closings- * The internals of this class appear to duplicate URLTransfer; so this may - * be a cut and paste of the URLTransfer type prior to it being added to - * Eclipse 3.4? - *
- */ -public class UDigByteAndLocalTransfer extends ByteArrayTransfer implements UDIGTransfer{ - private static UDigByteAndLocalTransfer _instance = new UDigByteAndLocalTransfer(); - - static final String CFSTR_INETURL = "InternalObject"; //$NON-NLS-1$ - - private static final int CFSTR_INETURLID = Transfer - .registerType(CFSTR_INETURL); - - private long startTime; - - public Object object; - - @Override - public boolean isSupportedType( TransferData transferData ) { - return super.isSupportedType(transferData); - } - - public UDigByteAndLocalTransfer() { - - // do nothing. - } - - public static UDigByteAndLocalTransfer getInstance() { - - return _instance; - } - - protected int[] getTypeIds() { - - return new int[] { CFSTR_INETURLID }; - } - - public String[] getTypeNames() { - - return new String[] { CFSTR_INETURL }; - } - - @Override - public TransferData[] getSupportedTypes() { - return super.getSupportedTypes(); - } - - @SuppressWarnings("unchecked") - @Override - public void javaToNative(Object object, TransferData transferData) { - - startTime = System.currentTimeMillis(); - if( object instanceof IStructuredSelection){ - IStructuredSelection selection=(IStructuredSelection) object; - List