-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Modernize Code] clean-ups in AbstractEditPartViewer (#287)
- Loading branch information
Showing
1 changed file
with
10 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ | |
import org.eclipse.gef.EditPart; | ||
import org.eclipse.gef.EditPartFactory; | ||
import org.eclipse.gef.EditPartViewer; | ||
import org.eclipse.gef.GraphicalEditPart; | ||
import org.eclipse.gef.KeyHandler; | ||
import org.eclipse.gef.RootEditPart; | ||
import org.eclipse.gef.SelectionManager; | ||
|
@@ -82,7 +83,7 @@ public abstract class AbstractEditPartViewer implements EditPartViewer { | |
* @deprecated | ||
*/ | ||
@Deprecated | ||
protected List selectionListeners = new ArrayList(1); | ||
protected List<ISelectionChangedListener> selectionListeners = new ArrayList<>(1); | ||
|
||
/** | ||
* The editpart specifically set to have focus. Note that if this value is | ||
|
@@ -96,9 +97,9 @@ public abstract class AbstractEditPartViewer implements EditPartViewer { | |
protected EditPart focusPart; | ||
|
||
private EditPartFactory factory; | ||
private final Map mapIDToEditPart = new HashMap(); | ||
private final Map mapVisualToEditPart = new HashMap(); | ||
private Map properties; | ||
private final Map<Object, EditPart> mapIDToEditPart = new HashMap<>(); | ||
private final Map<IFigure, GraphicalEditPart> mapVisualToEditPart = new HashMap<>(); | ||
private Map<String, Object> properties; | ||
private Control control; | ||
private ResourceManager resources; | ||
private EditDomain domain; | ||
|
@@ -254,11 +255,8 @@ public final EditPart findObjectAtExcluding(Point pt, Collection<IFigure> exclud | |
* Fires selection changed to the registered listeners at the time called. | ||
*/ | ||
protected void fireSelectionChanged() { | ||
Object listeners[] = selectionListeners.toArray(); | ||
SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection()); | ||
for (Object listener : listeners) { | ||
((ISelectionChangedListener) listener).selectionChanged(event); | ||
} | ||
selectionListeners.forEach(lst -> lst.selectionChanged(event)); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
merks
Contributor
|
||
} | ||
|
||
/** | ||
|
@@ -497,12 +495,8 @@ protected void init() { | |
} | ||
|
||
private void primDeselectAll() { | ||
EditPart part; | ||
List list = primGetSelectedEditParts(); | ||
for (Object element : list) { | ||
part = (EditPart) element; | ||
part.setSelected(EditPart.SELECTED_NONE); | ||
} | ||
List<? extends EditPart> list = primGetSelectedEditParts(); | ||
list.forEach(part -> part.setSelected(EditPart.SELECTED_NONE)); | ||
list.clear(); | ||
} | ||
|
||
|
@@ -511,7 +505,7 @@ private void primDeselectAll() { | |
* | ||
* @return the internal list of selected editparts | ||
*/ | ||
protected List primGetSelectedEditParts() { | ||
protected List<? extends EditPart> primGetSelectedEditParts() { | ||
return selection; | ||
} | ||
|
||
|
@@ -766,7 +760,7 @@ public void setKeyHandler(KeyHandler handler) { | |
@Override | ||
public void setProperty(String key, Object value) { | ||
if (properties == null) { | ||
properties = new HashMap(); | ||
properties = new HashMap<>(); | ||
} | ||
Object old; | ||
if (value == null) { | ||
|
This change introduced regression. Selection listeners that were removing themselves after selection is changed cause now exception