Skip to content

Commit

Permalink
converted anonymous classes to lambdas in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Dec 12, 2022
1 parent ed1fc78 commit 4e293aa
Showing 1 changed file with 24 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,7 @@ public void notifyChanged(Notification notification) {
*
* @generated
*/
protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
@Override
public void resourceChanged(IResourceChangeEvent event) {
handleIResourceChangeEvent(event);
}
};
protected IResourceChangeListener resourceChangeListener = EmfAbstractEditor.this::handleIResourceChangeEvent;

@Inject
protected ViewerFactory viewerFactory;
Expand Down Expand Up @@ -520,16 +515,13 @@ public void setSelectionToViewer(Collection<?> collection) {
// Make sure it's okay.
//
if (theSelection != null && !theSelection.isEmpty()) {
Runnable runnable = new Runnable() {
@Override
public void run() {
// Try to select the items in the current content viewer of
// the editor.
//
if (selectionViewer != null) {
selectionViewer.setSelection(new StructuredSelection(
theSelection.toArray()), true);
}
Runnable runnable = () -> {
// Try to select the items in the current content viewer of
// the editor.
//
if (selectionViewer != null) {
selectionViewer.setSelection(new StructuredSelection(
theSelection.toArray()), true);
}
};
getSite().getShell().getDisplay().asyncExec(runnable);
Expand All @@ -551,15 +543,8 @@ public AdapterFactoryEditingDomain getEditingDomain() {
}

protected ISelectionChangedListener createSelectionChangedListener() {
return new ISelectionChangedListener() {
// This just notifies those things that are affected by the section.
//
@Override
public void selectionChanged(
SelectionChangedEvent selectionChangedEvent) {
setSelection(selectionChangedEvent.getSelection());
}
};
// This just notifies those things that are affected by the section.
return selectionChangedEvent -> setSelection(selectionChangedEvent.getSelection());
}

public void createContextMenuFor(StructuredViewer viewer) {
Expand Down Expand Up @@ -680,14 +665,9 @@ public IContentOutlinePage getContentOutlinePage() {

// Listen to selection so that we can handle it is a special way.
contentOutlinePage
.addSelectionChangedListener(new ISelectionChangedListener() {
.addSelectionChangedListener(
// This ensures that we handle selections correctly.
//
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleContentOutlineSelection(event.getSelection());
}
});
event -> handleContentOutlineSelection(event.getSelection()));
}

return contentOutlinePage;
Expand Down Expand Up @@ -1117,12 +1097,7 @@ protected void handleResourceDiagnostic(Resource resource) {
}

if (updateProblemIndication) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
updateProblemIndication();
}
});
getSite().getShell().getDisplay().asyncExec(() -> updateProblemIndication());
}
}

Expand All @@ -1134,28 +1109,22 @@ protected void handleIResourceChangeEvent(IResourceChangeEvent event) {
delta.accept(visitor);

if (!visitor.getRemovedResources().isEmpty()) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
removedResources.addAll(visitor
.getRemovedResources());
if (!isDirty()) {
getSite().getPage().closeEditor(
EmfAbstractEditor.this, false);
}
getSite().getShell().getDisplay().asyncExec(() -> {
removedResources.addAll(visitor
.getRemovedResources());
if (!isDirty()) {
getSite().getPage().closeEditor(
EmfAbstractEditor.this, false);
}
});
}

if (!visitor.getChangedResources().isEmpty()) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
changedResources.addAll(visitor
.getChangedResources());
if (getSite().getPage().getActiveEditor() == EmfAbstractEditor.this) {
handleActivate();
}
getSite().getShell().getDisplay().asyncExec(() -> {
changedResources.addAll(visitor
.getChangedResources());
if (getSite().getPage().getActiveEditor() == EmfAbstractEditor.this) {
handleActivate();
}
});
}
Expand Down

0 comments on commit 4e293aa

Please sign in to comment.