Skip to content

Commit

Permalink
change visibility of category finder methods in ToolManager to public…
Browse files Browse the repository at this point in the history
… and made them final (#335)

* change visibility of category finder methods in ToolManager to public and
made them final to prohibit their subclassing.

Signed-off-by: Nikolaos Pringouris <nprigour@gmail.com>

* pulls up methods to IToolManager Interface

Signed-off-by: Frank Gasdorf <fgdrf@users.sourceforge.net>
  • Loading branch information
nprigour authored and fgdrf committed Mar 7, 2019
1 parent 03d4a69 commit 7593aa6
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.ApplicationGISInternal;
import org.locationtech.udig.project.ui.internal.MapEditorPart;

import org.locationtech.udig.project.ui.tool.IToolManager;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
Expand All @@ -41,7 +41,7 @@ public void setUp() throws Exception {
@Ignore
@Test
public void testSetCurrentEditor() {
ToolManager manager = (ToolManager) ApplicationGIS.getToolManager();
IToolManager manager = ApplicationGIS.getToolManager();
List<ActionToolCategory> categories = manager.getActiveToolCategories();
ToolProxy tool=null;
for( ActionToolCategory category : categories ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected boolean isDefaultItem() {
*/
@Override
protected boolean isActiveItem() {
return getTools().contains( ((ToolManager)manager).getActiveToolProxy());
return getTools().contains(manager.getActiveToolProxy());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,50 +26,6 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import org.locationtech.udig.catalog.IGeoResource;
import org.locationtech.udig.core.filter.AdaptingFilter;
import org.locationtech.udig.core.filter.AdaptingFilterFactory;
import org.locationtech.udig.core.internal.ExtensionPointList;
import org.locationtech.udig.internal.ui.UDIGDNDProcessor;
import org.locationtech.udig.internal.ui.UDIGDropHandler;
import org.locationtech.udig.internal.ui.UDigByteAndLocalTransfer;
import org.locationtech.udig.internal.ui.UiPlugin;
import org.locationtech.udig.internal.ui.operations.OperationCategory;
import org.locationtech.udig.internal.ui.operations.OperationMenuFactory;
import org.locationtech.udig.internal.ui.operations.RunOperationsAction;
import org.locationtech.udig.project.EditManagerEvent;
import org.locationtech.udig.project.IEditManagerListener;
import org.locationtech.udig.project.ILayer;
import org.locationtech.udig.project.IMap;
import org.locationtech.udig.project.internal.Map;
import org.locationtech.udig.project.internal.ProjectPackage;
import org.locationtech.udig.project.internal.commands.CreateMapCommand;
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.ApplicationGISInternal;
import org.locationtech.udig.project.ui.internal.MapEditor;
import org.locationtech.udig.project.ui.internal.MapEditorPart;
import org.locationtech.udig.project.ui.internal.MapEditorWithPalette;
import org.locationtech.udig.project.ui.internal.MapPart;
import org.locationtech.udig.project.ui.internal.Messages;
import org.locationtech.udig.project.ui.internal.ProjectUIPlugin;
import org.locationtech.udig.project.ui.internal.actions.Delete;
import org.locationtech.udig.project.ui.internal.tool.ToolContext;
import org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl;
import org.locationtech.udig.project.ui.tool.IContextMenuContributionTool;
import org.locationtech.udig.project.ui.tool.IToolManager;
import org.locationtech.udig.project.ui.tool.ModalTool;
import org.locationtech.udig.project.ui.tool.Tool;
import org.locationtech.udig.project.ui.tool.ToolConstants;
import org.locationtech.udig.project.ui.tool.options.PreferencesShortcutToolOptionsContributionItem;
import org.locationtech.udig.project.ui.viewers.MapEditDomain;
import org.locationtech.udig.ui.IDropAction;
import org.locationtech.udig.ui.IDropHandlerListener;
import org.locationtech.udig.ui.PlatformGIS;
import org.locationtech.udig.ui.UDIGDragDropUtilities;
import org.locationtech.udig.ui.ViewerDropLocation;
import org.locationtech.udig.ui.operations.LazyOpFilter;
import org.locationtech.udig.ui.operations.OpAction;
import org.locationtech.udig.ui.operations.OpFilter;
import org.eclipse.core.commands.Command;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
Expand Down Expand Up @@ -118,8 +74,50 @@
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.dialogs.PropertyDialogAction;
import org.eclipse.ui.part.EditorPart;
import org.eclipse.ui.part.ViewPart;
import org.locationtech.udig.catalog.IGeoResource;
import org.locationtech.udig.core.filter.AdaptingFilter;
import org.locationtech.udig.core.filter.AdaptingFilterFactory;
import org.locationtech.udig.core.internal.ExtensionPointList;
import org.locationtech.udig.internal.ui.UDIGDNDProcessor;
import org.locationtech.udig.internal.ui.UDIGDropHandler;
import org.locationtech.udig.internal.ui.UDigByteAndLocalTransfer;
import org.locationtech.udig.internal.ui.UiPlugin;
import org.locationtech.udig.internal.ui.operations.OperationCategory;
import org.locationtech.udig.internal.ui.operations.OperationMenuFactory;
import org.locationtech.udig.internal.ui.operations.RunOperationsAction;
import org.locationtech.udig.project.EditManagerEvent;
import org.locationtech.udig.project.IEditManagerListener;
import org.locationtech.udig.project.ILayer;
import org.locationtech.udig.project.IMap;
import org.locationtech.udig.project.internal.Map;
import org.locationtech.udig.project.internal.ProjectPackage;
import org.locationtech.udig.project.internal.commands.CreateMapCommand;
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.ApplicationGISInternal;
import org.locationtech.udig.project.ui.internal.MapEditorPart;
import org.locationtech.udig.project.ui.internal.MapEditorWithPalette;
import org.locationtech.udig.project.ui.internal.MapPart;
import org.locationtech.udig.project.ui.internal.Messages;
import org.locationtech.udig.project.ui.internal.ProjectUIPlugin;
import org.locationtech.udig.project.ui.internal.actions.Delete;
import org.locationtech.udig.project.ui.internal.tool.ToolContext;
import org.locationtech.udig.project.ui.internal.tool.impl.ToolContextImpl;
import org.locationtech.udig.project.ui.tool.IContextMenuContributionTool;
import org.locationtech.udig.project.ui.tool.IToolManager;
import org.locationtech.udig.project.ui.tool.ModalTool;
import org.locationtech.udig.project.ui.tool.Tool;
import org.locationtech.udig.project.ui.tool.ToolConstants;
import org.locationtech.udig.project.ui.tool.options.PreferencesShortcutToolOptionsContributionItem;
import org.locationtech.udig.project.ui.viewers.MapEditDomain;
import org.locationtech.udig.ui.IDropAction;
import org.locationtech.udig.ui.IDropHandlerListener;
import org.locationtech.udig.ui.PlatformGIS;
import org.locationtech.udig.ui.UDIGDragDropUtilities;
import org.locationtech.udig.ui.ViewerDropLocation;
import org.locationtech.udig.ui.operations.LazyOpFilter;
import org.locationtech.udig.ui.operations.OpAction;
import org.locationtech.udig.ui.operations.OpFilter;
import org.opengis.filter.Filter;

/**
Expand Down Expand Up @@ -763,21 +761,25 @@ public void propertyChange( PropertyChangeEvent event ) {
addToolAction(toolAction);
return toolAction;
}
public ActionToolCategory findActionCategory( String id ) {

@Override
public final ActionToolCategory findActionCategory( String id ) {
for( ActionToolCategory category : actionCategories ) {
if (category.getId().equals(id))
return category;
}
return null;
}
MenuToolCategory findMenuCategory( String id ) {
@Override
public final MenuToolCategory findMenuCategory( String id ) {
for( MenuToolCategory category : menuCategories ) {
if (category.getId().equals(id))
return category;
}
return null;
}
protected ModalToolCategory findModalCategory( String id ) {
@Override
public final ModalToolCategory findModalCategory( String id ) {
for( ModalToolCategory category : modalCategories ) {
String id2 = category.getId();
if (id2.equals(id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.locationtech.udig.project.ui.tool.ActionTool;
import org.locationtech.udig.project.ui.tool.IMapEditorSelectionProvider;
import org.locationtech.udig.project.ui.tool.IToolContext;
import org.locationtech.udig.project.ui.tool.IToolManager;
import org.locationtech.udig.project.ui.tool.ModalTool;
import org.locationtech.udig.project.ui.tool.Tool;
import org.locationtech.udig.project.ui.tool.ToolConstants;
Expand Down Expand Up @@ -643,7 +644,7 @@ public IMapEditorSelectionProvider getSelectionProvider() {
if (selectionProviderInstance != null)
return selectionProviderInstance;
}
ToolManager m = (ToolManager) ApplicationGIS.getToolManager();
IToolManager m = ApplicationGIS.getToolManager();
ModalToolCategory cat = m.findModalCategory(getCategoryId());
if (cat != null){
selectionProviderInstance = cat.getSelectionProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

import org.locationtech.udig.project.ui.internal.MapPart;
import org.locationtech.udig.project.ui.internal.tool.display.ActionToolCategory;
import org.locationtech.udig.project.ui.internal.tool.display.MenuToolCategory;
import org.locationtech.udig.project.ui.internal.tool.display.ModalToolCategory;
import org.locationtech.udig.project.ui.internal.tool.display.ToolCategory;

import org.locationtech.udig.project.ui.internal.tool.display.ToolProxy;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
Expand All @@ -29,23 +30,23 @@

public interface IToolManager {

public final String XPID = "org.locationtech.udig.project.ui.toolManagers"; //$NON-NLS-1$
final String XPID = "org.locationtech.udig.project.ui.toolManagers"; //$NON-NLS-1$
/**
* Points to id field of extension point attribute
*/
public final String ATTR_ID = "id"; //$NON-NLS-1$
final String ATTR_ID = "id"; //$NON-NLS-1$

/**
* Points to class field of extension point attribute
*/
public final String ATTR_CLASS = "class"; //$NON-NLS-1$
final String ATTR_CLASS = "class"; //$NON-NLS-1$

/**
* Preference constant that can used to set and look up the default
* IToolManager. This can be set in plugin_customization.ini with the key
* "org.locationtech.udig.project.ui/toolManager".
*/
public final String P_TOOL_MANAGER = "toolManager"; //$NON-NLS-1$
final String P_TOOL_MANAGER = "toolManager"; //$NON-NLS-1$

void setCurrentEditor( MapPart editor );

Expand All @@ -68,8 +69,6 @@ public interface IToolManager {
*/
IAction createToolAction( final String toolID, final String categoryID );

ActionToolCategory findActionCategory( String id );

void contributeToMenu( IMenuManager manager );


Expand Down Expand Up @@ -120,7 +119,7 @@ public interface IToolManager {
*
* @param part
*/
public void unregisterActions( IWorkbenchPart part );
void unregisterActions( IWorkbenchPart part );
/**
* Retrieves the backward navigation action that is used by much of the map components such as
* the MapEditor and the LayersView. Undoes the last Nav command set to the current map.
Expand Down Expand Up @@ -173,7 +172,7 @@ public interface IToolManager {
* @param toolManager
* @param bars
*/
public void contributeActionTools( IToolBarManager toolBarManager, IActionBars bars );
void contributeActionTools( IToolBarManager toolBarManager, IActionBars bars );

/**
* Adds modal tools contribution items to the toolbar.
Expand All @@ -184,7 +183,7 @@ public interface IToolManager {
* @param toolManager
* @param bars
*/
public void contributeModalTools( IToolBarManager toolBarManager, IActionBars bars );
void contributeModalTools( IToolBarManager toolBarManager, IActionBars bars );

/**
* Contributes the common global actions.
Expand Down Expand Up @@ -265,6 +264,39 @@ public interface IToolManager {
* @param cursorID
* @return
*/
public Cursor findToolCursor(String cursorID);
Cursor findToolCursor(String cursorID);

/**
* @param id Category id
* @return ModalToolCategory for given categoryId, null if it doesn't exists
*/
ModalToolCategory findModalCategory(String categoryId);

/**
* @param categoryId Category id
* @return MenuToolCategory for given categoryId, null if it doesn't exists
*/
MenuToolCategory findMenuCategory(String categoryId);

/**
* @param categoryId Category id
* @return ActionToolCategory for given categoryId, null if it doesn't exists
*/
ActionToolCategory findActionCategory(String categoryId);

/**
* @return List of ActiveToolCategories
*/
List<ActionToolCategory> getActiveToolCategories();

/**
* @return active ToolProxy or null if there isn't any
*/
ToolProxy getActiveToolProxy();

/**
* @param toolProxy ToolProxy to set as active ToolProxy
*/
void setActiveModalToolProxy(ToolProxy toolProxy);

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@
*/
package org.locationtech.udig.project.ui.viewers;

import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.MapToolEntry;
import org.locationtech.udig.project.ui.internal.tool.display.ToolManager;
import org.locationtech.udig.project.ui.internal.tool.display.ToolProxy;
import org.locationtech.udig.project.ui.tool.IToolManager;
import org.locationtech.udig.project.ui.tool.ModalTool;

import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.EditDomain;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteEntry;
import org.eclipse.gef.palette.PaletteListener;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gef.ui.palette.PaletteViewer;
import org.eclipse.ui.IEditorPart;
import org.locationtech.udig.project.ui.ApplicationGIS;
import org.locationtech.udig.project.ui.internal.MapToolEntry;
import org.locationtech.udig.project.ui.internal.tool.display.ToolProxy;
import org.locationtech.udig.project.ui.tool.IToolManager;

/**
* Domain responsible for managing the active tool; and advertising the set of
Expand All @@ -42,7 +37,7 @@ public class MapEditDomain extends DefaultEditDomain {

private PaletteListener paletteListener = new PaletteListener() {
public void activeToolChanged(PaletteViewer viewer, ToolEntry tool) {
ToolManager tools = (ToolManager) ApplicationGIS.getToolManager();
IToolManager tools = ApplicationGIS.getToolManager();
if (viewer != null) {
ToolEntry entry = viewer.getActiveTool();
if (entry instanceof MapToolEntry) {
Expand Down
Loading

0 comments on commit 7593aa6

Please sign in to comment.