Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Modernize Code] clean-ups in AbstractEditPartViewer #287

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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));
}

/**
Expand Down Expand Up @@ -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();
}

Expand All @@ -511,7 +505,7 @@ private void primDeselectAll() {
*
* @return the internal list of selected editparts
*/
protected List primGetSelectedEditParts() {
protected List<? extends EditPart> primGetSelectedEditParts() {
return selection;
}

Expand Down Expand Up @@ -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) {
Expand Down
Loading