Skip to content
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2012, Refractions Research Inc.
/**
* 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
Expand All @@ -10,58 +10,41 @@
*/
package org.locationtech.udig.catalog.ui;


import org.locationtech.udig.catalog.ui.search.SearchView;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.locationtech.udig.catalog.ui.search.SearchView;

public class AOIViewActionDelegate extends Action implements IViewActionDelegate {
public class AOIViewActionDelegate extends Action implements IViewActionDelegate {

private SearchView view;
private IStructuredSelection selection;

/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run( IAction action ) {
public void run(IAction action) {
filterTable(action.isChecked());
}

/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged( IAction action, ISelection selection ) {
try {
this.selection = (IStructuredSelection) selection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a functional changes, why are selection events ignored?

Copy link
Contributor Author

@sschulz92 sschulz92 Oct 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eclipse showed a warnings that the variable selection was never used. As the member variable was private, it could not be accessed from outside. Therefore I removed the variable.

grafik

So no sub-classes available in the current codebase ;)

} catch (Exception e) { // do nothing
}
public void selectionChanged(IAction action, ISelection selection) {

}


/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
@Override
public void init( IViewPart view ) {
public void init(IViewPart view) {
if (view != null && view instanceof SearchView) {
this.view = (SearchView) view;
}
}
public void setActivePart( IAction action, IWorkbenchPart targetPart ) {

public void setActivePart(IAction action, IWorkbenchPart targetPart) {
if (targetPart != null && targetPart instanceof SearchView) {
view = (SearchView) targetPart;
}
}

private void filterTable(boolean filter) {
if (view != null) {
view.setAOIFilter(filter);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2012, Refractions Research Inc.
/**
* 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
Expand All @@ -16,18 +16,16 @@
import java.util.List;
import java.util.Map;

import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.PlatformUI;
import org.locationtech.udig.catalog.CatalogPlugin;
import org.locationtech.udig.catalog.ICatalog;
import org.locationtech.udig.catalog.IResolve;
import org.locationtech.udig.catalog.IResolveChangeEvent;
import org.locationtech.udig.catalog.IResolveChangeListener;
import org.locationtech.udig.ui.PlatformGIS;

import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.PlatformUI;


/**
* Provides a threaded Tree content provider for IResolve.
* <p>
Expand All @@ -53,20 +51,24 @@ public class AbstractResolveContentProvider implements IResolveChangeListener {
* enough in the object to correctly deal with multilevel services.
* </p>
*/
Map<IResolve, Thread> threadFarm = new IdentityHashMap<IResolve, Thread>();
Map<IResolve, Thread> threadFarm = new IdentityHashMap<>();

/**
* Captures parent child relationships.
* <p>
* Here an {@link IdentityHashMap} is used because the containsKey otherwise doesn't look deep
* enough in the object to correctly deal with multilevel services.
* </p>
*/
protected final Map<IResolve, List<IResolve>> structure = new IdentityHashMap<IResolve, List<IResolve>>();
protected final Map<IResolve, List<IResolve>> structure = new IdentityHashMap<>();

/**
* Root of this tree, often a ICatalog.
*/
protected ICatalog catalog;

protected List<IResolve> list;

protected Viewer viewer;

public AbstractResolveContentProvider() {
Expand All @@ -88,15 +90,16 @@ public AbstractResolveContentProvider() {
*
* @param event
*/
public void changed( IResolveChangeEvent event ) {
if( threadFarm==null ){
// we are disposed
if( catalog!=null ){
catalog.removeCatalogListener(this);
}
return;
}
if ( event.getType() != IResolveChangeEvent.Type.POST_CHANGE) {
@Override
public void changed(IResolveChangeEvent event) {
if (threadFarm == null) {
// we are disposed
if (catalog != null) {
catalog.removeCatalogListener(this);
}
return;
}
if (event.getType() != IResolveChangeEvent.Type.POST_CHANGE) {
return;
}
IResolve resolve = event.getResolve();
Expand All @@ -113,18 +116,19 @@ public void changed( IResolveChangeEvent event ) {
*
* @param resolve
*/
public void refresh( final IResolve resolve ) {
if( PlatformUI.getWorkbench().isClosing() )
public void refresh(final IResolve resolve) {
if (PlatformUI.getWorkbench().isClosing())
return;
Runnable object = new Runnable(){
public void run() {
if (viewer instanceof TreeViewer) {
TreeViewer treeViewer = (TreeViewer) viewer;
treeViewer.refresh(resolve, true);
}else{
viewer.refresh();
}
}
Runnable object = new Runnable() {
@Override
public void run() {
if (viewer instanceof TreeViewer) {
TreeViewer treeViewer = (TreeViewer) viewer;
treeViewer.refresh(resolve, true);
} else {
viewer.refresh();
}
}
};

PlatformGIS.asyncInDisplayThread(object, true);
Expand All @@ -138,7 +142,7 @@ public void run() {
*
* @param resolve
*/
public void update( final IResolve resolve ) {
public void update(final IResolve resolve) {
if (resolve == null) {
// go away
return;
Expand Down Expand Up @@ -194,13 +198,13 @@ public void update( final IResolve resolve ) {
* </p>
*
* @param viewer the viewer
* @param oldInput the old input element, or <code>null</code> if the viewer did not
* previously have an input
* @param oldInput the old input element, or <code>null</code> if the viewer did not previously
* have an input
* @param newInput the new input element, or <code>null</code> if the viewer does not have an
* input
*/
@SuppressWarnings("unchecked")
public void inputChanged( Viewer newViewer, Object oldInput, Object newInput ) {
public void inputChanged(Viewer newViewer, Object oldInput, Object newInput) {
if (oldInput == newInput) {
return;
}
Expand All @@ -218,50 +222,49 @@ public void inputChanged( Viewer newViewer, Object oldInput, Object newInput ) {

public void dispose() {
if (threadFarm != null) {
for( IResolve resolve : threadFarm.keySet() ) {
for (IResolve resolve : threadFarm.keySet()) {
Thread thread = threadFarm.get(resolve);
if (thread!=null && thread.isAlive()) {
if (thread != null && thread.isAlive()) {
thread.interrupt();
}
}
if(catalog!=null)
catalog.removeCatalogListener(this);
if (catalog != null)
catalog.removeCatalogListener(this);

CatalogPlugin.getDefault().getLocalCatalog().removeCatalogListener(this);
threadFarm.clear();
threadFarm = null;
}
if (structure != null) {
for( IResolve resolve : structure.keySet() ) {
for (IResolve resolve : structure.keySet()) {
List<IResolve> children = structure.get(resolve);
if( children!=null )
if (children != null)
children.clear();
}
structure.clear();
}
}


/**
* Thread for updating structure
* <p>
* Note: thread notify the system that the element has requires an update
*/
class Update implements Runnable {
IResolve resolve;
Update( IResolve target ) {

Update(IResolve target) {
resolve = target;
}

/**
* Update strucuture, Thread will be notified if more updates are required.
* <p>
* Update structure, Thread will be notified if more updates are required.
* Note: We also need to let ourselves be interrupted
*/
@SuppressWarnings("unchecked")
@Override
public void run() {
try {
try {
List<IResolve> members = new ArrayList<IResolve>(resolve.members(null));
List<IResolve> members = new ArrayList<>(resolve.members(null));
structure.put(resolve, members);
} catch (IOException io) {
// could not get children
Expand All @@ -272,10 +275,9 @@ public void run() {
}
refresh(resolve);
} catch (Throwable t) {
CatalogUIPlugin.trace( resolve.getIdentifier()+": "+t, t );
CatalogUIPlugin.trace(resolve.getIdentifier() + ": " + t, t); //$NON-NLS-1$
}
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected boolean canProcess(ServiceExtension2 serviceExtension,
* extension
*
* @param serviceExtension
* @param url url created from {@link AbstractUDIGConnectionFactory#canProcess(Object)}
* @param url URL created from {@link AbstractUDIGConnectionFactory#canProcess(Object)}
* @return true if can process parameters
*/
protected boolean canProcess(ServiceExtension2 serviceExtension, URL url) {
Expand All @@ -125,7 +125,7 @@ protected boolean canProcess(ServiceExtension2 serviceExtension, URL url) {
* the service extension
*
* @param serviceExtension
* @param id id from {@link AbstractUDIGConnectionFactory#canProcess(Object)}
* @param id ID from {@link AbstractUDIGConnectionFactory#canProcess(Object)}
* @return true if can process parameters
*/
protected boolean canProcess(ServiceExtension2 serviceExtension, ID id) {
Expand Down
Loading