diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/TMModelManager.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/TMModelManager.java index 919e522c3..6587b349e 100644 --- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/TMModelManager.java +++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/model/TMModelManager.java @@ -11,7 +11,7 @@ */ package org.eclipse.tm4e.ui.internal.model; -import static org.eclipse.tm4e.core.internal.utils.NullSafetyHelper.*; +import static org.eclipse.tm4e.core.internal.utils.NullSafetyHelper.castNullable; import java.util.HashMap; import java.util.Map; @@ -34,7 +34,7 @@ private TMModelManager() { @Override public TMDocumentModel connect(final IDocument document) { - return models.computeIfAbsent(document, doc -> new TMDocumentModel(doc)); + return models.computeIfAbsent(document, TMDocumentModel::new); } @Override diff --git a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java index 09b1c64ac..a3ba2f71f 100644 --- a/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java +++ b/org.eclipse.tm4e.ui/src/main/java/org/eclipse/tm4e/ui/internal/preferences/GrammarPreferencePage.java @@ -14,7 +14,7 @@ *******************************************************************************/ package org.eclipse.tm4e.ui.internal.preferences; -import static org.eclipse.tm4e.core.internal.utils.NullSafetyHelper.*; +import static org.eclipse.tm4e.core.internal.utils.NullSafetyHelper.lazyNonNull; import java.util.Arrays; @@ -41,7 +41,6 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Table; @@ -326,44 +325,28 @@ private void fillPreview(final String scopeName, @Nullable final IThemeAssociati final var grammarNewButton = new Button(buttons, SWT.PUSH); grammarNewButton.setText(TMUIMessages.Button_new); grammarNewButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - grammarNewButton.addListener(SWT.Selection, new Listener() { - - @Override - public void handleEvent(@Nullable final Event e) { - add(); - } - - private void add() { - // Open import wizard for TextMate grammar. - final var wizard = new TextMateGrammarImportWizard(false); - wizard.setGrammarRegistryManager(grammarRegistryManager); - final var dialog = new WizardDialog(getShell(), wizard); - if (dialog.open() == Window.OK) { - // User grammar was saved, refresh the list of grammar and - // select the created grammar. - final IGrammarDefinition created = wizard.getCreatedDefinition(); - grammarViewer.refresh(); - grammarViewer.setSelection(new StructuredSelection(created)); - } + grammarNewButton.addListener(SWT.Selection, (@Nullable final Event e) -> { + // Open import wizard for TextMate grammar. + final var wizard = new TextMateGrammarImportWizard(false); + wizard.setGrammarRegistryManager(grammarRegistryManager); + final var dialog = new WizardDialog(getShell(), wizard); + if (dialog.open() == Window.OK) { + // User grammar was saved, refresh the list of grammar and + // select the created grammar. + final IGrammarDefinition created = wizard.getCreatedDefinition(); + grammarViewer.refresh(); + grammarViewer.setSelection(new StructuredSelection(created)); } }); grammarRemoveButton = new Button(buttons, SWT.PUSH); grammarRemoveButton.setText(TMUIMessages.Button_remove); grammarRemoveButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - grammarRemoveButton.addListener(SWT.Selection, new Listener() { - - @Override - public void handleEvent(@Nullable final Event e) { - remove(); - } - - private void remove() { - final var definition = (IGrammarDefinition) ((IStructuredSelection) grammarViewer - .getSelection()).getFirstElement(); - grammarRegistryManager.unregisterGrammarDefinition(definition); - grammarViewer.refresh(); - } + grammarRemoveButton.addListener(SWT.Selection, (@Nullable final Event e) -> { + final var definition = (IGrammarDefinition) ((IStructuredSelection) grammarViewer + .getSelection()).getFirstElement(); + grammarRegistryManager.unregisterGrammarDefinition(definition); + grammarViewer.refresh(); }); }