From 86643c0b8be9a53a0c29011e5199202e68a92aa1 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 26 Jan 2018 21:30:17 +0200 Subject: Bug 530396 - Move UI code to lambdas Change-Id: I92c7b5c6cbde04280da91a9ee617495ff0381a73 Signed-off-by: Alexander Kurtakov --- .../internal/p2/ui/admin/dialogs/ProfileGroup.java | 39 ++- .../p2/ui/discovery/util/ControlListItem.java | 25 +- .../p2/ui/discovery/util/ControlListViewer.java | 10 +- .../p2/ui/discovery/util/FilteredViewer.java | 23 +- .../p2/ui/discovery/util/TextSearchControl.java | 33 +-- .../p2/ui/discovery/wizards/CatalogViewer.java | 12 +- .../p2/ui/discovery/wizards/DiscoveryItem.java | 22 +- .../internal/wizard/AbstractImportPage.java | 23 +- .../importexport/internal/wizard/AbstractPage.java | 87 +++--- .../p2/ui/sdk/scheduler/AutomaticUpdatesPopup.java | 37 +-- .../scheduler/AutomaticUpdatesPreferencePage.java | 54 +--- .../ui/sdk/scheduler/migration/MigrationPage.java | 65 ++--- .../internal/p2/ui/ColocatedRepositoryTracker.java | 72 ++--- .../p2/ui/ProvisioningOperationRunner.java | 21 +- .../internal/p2/ui/QueryableRepositoryManager.java | 12 +- .../internal/p2/ui/ValidationDialogServiceUI.java | 118 +++----- .../p2/ui/actions/ProfileModificationAction.java | 11 +- .../internal/p2/ui/actions/RefreshAction.java | 11 +- .../internal/p2/ui/actions/UpdateAction.java | 18 +- .../p2/ui/dialogs/AddRepositoryDialog.java | 53 ++-- .../internal/p2/ui/dialogs/AvailableIUGroup.java | 140 ++++------ .../internal/p2/ui/dialogs/AvailableIUsPage.java | 16 +- .../p2/ui/dialogs/ComboAutoCompleteField.java | 85 +++--- .../p2/ui/dialogs/ContainerCheckedTreeViewer.java | 9 +- .../p2/ui/dialogs/DelayedFilterCheckboxTree.java | 210 ++++++-------- .../p2/ui/dialogs/IUCopyrightPropertyPage.java | 20 +- .../p2/ui/dialogs/IUGeneralInfoPropertyPage.java | 12 +- .../p2/ui/dialogs/IULicensePropertyPage.java | 20 +- .../internal/p2/ui/dialogs/InstallWizard.java | 20 +- .../internal/p2/ui/dialogs/InstalledIUGroup.java | 11 +- .../p2/ui/dialogs/ProvisioningOperationWizard.java | 54 +--- .../internal/p2/ui/dialogs/RemediationGroup.java | 66 ++--- .../dialogs/RepositoryNameAndLocationDialog.java | 18 +- .../p2/ui/dialogs/RepositorySelectionGroup.java | 193 +++++-------- .../p2/ui/dialogs/ResolutionResultsWizardPage.java | 35 +-- .../internal/p2/ui/dialogs/SelectableIUsPage.java | 78 ++---- .../p2/ui/dialogs/SizeComputingWizardPage.java | 9 +- .../p2/ui/viewers/IUDetailsLabelProvider.java | 15 +- .../p2/ui/viewers/ProvElementContentProvider.java | 45 +-- .../StructuredViewerProvisioningListener.java | 30 +- .../equinox/p2/ui/AcceptLicensesWizardPage.java | 35 +-- .../equinox/p2/ui/InstalledSoftwarePage.java | 12 +- .../equinox/p2/ui/RepositoryManipulationPage.java | 311 +++++++-------------- .../eclipse/equinox/p2/ui/RevertProfilePage.java | 40 +-- 44 files changed, 795 insertions(+), 1435 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/ProfileGroup.java b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/ProfileGroup.java index 784c78f37..3f00b59bf 100644 --- a/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/ProfileGroup.java +++ b/bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/ProfileGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,7 +19,8 @@ import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.ui.admin.*; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -73,17 +74,14 @@ public class ProfileGroup { Button locationButton = new Button(composite, SWT.PUSH); locationButton.setText(ProvAdminUIMessages.ProfileGroup_Browse); - locationButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL); - dialog.setMessage(ProvAdminUIMessages.ProfileGroup_SelectProfileMessage); - String dir = dialog.open(); - if (dir != null) { - location.setText(dir); - } + locationButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> { + DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL); + dialog.setMessage(ProvAdminUIMessages.ProfileGroup_SelectProfileMessage); + String dir = dialog.open(); + if (dir != null) { + location.setText(dir); } - }); + })); setEditable(locationButton, profile == null, listener); label = new Label(composite, SWT.NONE); @@ -94,17 +92,14 @@ public class ProfileGroup { locationButton = new Button(composite, SWT.PUSH); locationButton.setText(ProvAdminUIMessages.ProfileGroup_Browse2); - locationButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL); - dialog.setMessage(ProvAdminUIMessages.ProfileGroup_SelectBundlePoolCache); - String dir = dialog.open(); - if (dir != null) { - cache.setText(dir); - } + locationButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> { + DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.APPLICATION_MODAL); + dialog.setMessage(ProvAdminUIMessages.ProfileGroup_SelectBundlePoolCache); + String dir = dialog.open(); + if (dir != null) { + cache.setText(dir); } - }); + })); setEditable(locationButton, profile == null, listener); label = new Label(composite, SWT.NONE); diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java index 9c1040218..a3e220f28 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2017 IBM Corporation and others. + * Copyright (c) 2005, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,8 +25,6 @@ import org.eclipse.ui.PlatformUI; /** * Based on {@link org.eclipse.ui.internal.progress.ProgressInfoItem}. - * - * @author Steffen Pingel */ @SuppressWarnings("restriction") public abstract class ControlListItem extends Composite { @@ -60,7 +58,7 @@ public abstract class ControlListItem extends Composite { private boolean selected; - private final MouseAdapter mouseListener; + private final MouseListener mouseListener; private boolean isShowing = true; @@ -146,19 +144,16 @@ public abstract class ControlListItem extends Composite { }; } - private MouseAdapter doCreateMouseListener() { - return new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - if (indexListener != null) { - if (e.count == 2) { - indexListener.open(); - } else { - indexListener.select(); - } + private MouseListener doCreateMouseListener() { + return MouseListener.mouseDownAdapter(e -> { + if (indexListener != null) { + if (e.count == 2) { + indexListener.open(); + } else { + indexListener.select(); } } - }; + }); } public boolean isHot() { diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java index d794a6d35..a870e3292 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2017 IBM Corporation and others. + * Copyright (c) 2005, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,7 +27,6 @@ import org.eclipse.swt.widgets.*; /** * Based on {@link org.eclipse.ui.internal.progress.DetailedProgressViewer}. * - * @author Steffen Pingel */ @SuppressWarnings("restriction") public abstract class ControlListViewer extends StructuredViewer { @@ -98,12 +97,7 @@ public abstract class ControlListViewer extends StructuredViewer { scrolled.setExpandHorizontal(true); scrolled.setExpandVertical(true); - scrolled.addControlListener(new ControlAdapter() { - @Override - public void controlResized(ControlEvent e) { - updateSize(scrolled.getContent()); - } - }); + scrolled.addControlListener(ControlListener.controlResizedAdapter(e -> updateSize(scrolled.getContent()))); control.addTraverseListener(new TraverseListener() { private boolean handleEvent = true; diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java index 790ffa9f0..3e1ae020f 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,8 +21,7 @@ import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; import org.eclipse.ui.progress.WorkbenchJob; @@ -107,18 +106,16 @@ public abstract class FilteredViewer { } }); } - filterText.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetDefaultSelected(SelectionEvent e) { - if (e.detail == SWT.ICON_CANCEL) { - clearFilterText(); - } else { - // search icon and enter - filterTextChanged(); - } + filterText.addSelectionListener(SelectionListener.widgetDefaultSelectedAdapter(e -> { + if (e.detail == SWT.ICON_CANCEL) { + clearFilterText(); + } else { + // search icon and enter + filterTextChanged(); } - }); + })); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(filterText); + } private void doCreateHeader() { diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java index efd8c88a3..ab0c939df 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2017 Tasktop Technologies and others. + * Copyright (c) 2010, 2018 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -132,25 +132,17 @@ public class TextSearchControl extends Composite { } private void registerListeners() { - addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - if (textControl != null && !textControl.isDisposed()) { - addToSearchHistory(textControl.getText()); - } - + addSelectionListener(SelectionListener.widgetDefaultSelectedAdapter(e -> { + if (textControl != null && !textControl.isDisposed()) { + addToSearchHistory(textControl.getText()); } - }); - textControl.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - if (textControl != null && !textControl.isDisposed()) { - addToSearchHistory(textControl.getText()); - } + })); + textControl.addFocusListener(FocusListener.focusLostAdapter(e -> { + if (textControl != null && !textControl.isDisposed()) { + addToSearchHistory(textControl.getText()); } - }); + })); } private static int getCompositeStyle(boolean automaticFind, Composite parent) { @@ -268,12 +260,7 @@ public class TextSearchControl extends Composite { }); - labelButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = accessibilityText; - } - }); + labelButton.getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> e.result = accessibilityText)); labelButton.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() { @Override public void getRole(AccessibleControlEvent e) { diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java index 01ecd0696..2316de2d7 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2017 Tasktop Technologies and others. + * Copyright (c) 2009, 2018 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -345,7 +345,7 @@ public class CatalogViewer extends FilteredViewer { contentProvider = doCreateContentProvider(); contentProvider.setHasCategories(isShowCategories()); _viewer.setContentProvider(contentProvider); - _viewer.setSorter(new ViewerSorter() { + _viewer.setComparator(new ViewerComparator() { CatalogCategoryComparator categoryComparator = new CatalogCategoryComparator(); CatalogItemComparator itemComparator = new CatalogItemComparator(); @@ -378,14 +378,6 @@ public class CatalogViewer extends FilteredViewer { return i; } - // private int compare(Comparator comparator, Object key1, Object key2) { - // if (key1 == null) { - // return (key2 != null) ? 1 : 0; - // } else if (key2 == null) { - // return -1; - // } - // return comparator.compare(key1, key2); - // } private CatalogCategory getCategory(Object o) { if (o instanceof CatalogCategory) { return (CatalogCategory) o; diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java index d2ef6a726..ade305bbd 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2017 Tasktop Technologies and others. + * Copyright (c) 2010, 2018 Tasktop Technologies and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -141,12 +141,7 @@ public class DiscoveryItem extends AbstractDiscoveryItem< if (item.getCertification() != null) { providerLabel.setText(NLS.bind(Messages.DiscoveryViewer_Certification_Label0, new String[] {item.getProvider(), item.getLicense(), item.getCertification().getName()})); if (item.getCertification().getUrl() != null) { - providerLabel.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - WorkbenchUtil.openUrl(item.getCertification().getUrl(), IWorkbenchBrowserSupport.AS_EXTERNAL); - } - }); + providerLabel.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> WorkbenchUtil.openUrl(item.getCertification().getUrl(), IWorkbenchBrowserSupport.AS_EXTERNAL))); } Overview overview = new Overview(); overview.setSummary(item.getCertification().getDescription()); @@ -177,15 +172,12 @@ public class DiscoveryItem extends AbstractDiscoveryItem< maybeModifySelection(selected); } }); - MouseListener connectorItemMouseListener = new MouseAdapter() { - @Override - public void mouseUp(MouseEvent e) { - boolean selected = !checkbox.getSelection(); - if (maybeModifySelection(selected)) { - checkbox.setSelection(selected); - } + MouseListener connectorItemMouseListener = MouseListener.mouseUpAdapter(e -> { + boolean selected = !checkbox.getSelection(); + if (maybeModifySelection(selected)) { + checkbox.setSelection(selected); } - }; + }); checkboxContainer.addMouseListener(connectorItemMouseListener); this.addMouseListener(connectorItemMouseListener); iconLabel.addMouseListener(connectorItemMouseListener); diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java index 0699ef819..03c4e925c 100644 --- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java +++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 WindRiver Corporation and others. + * Copyright (c) 2011, 2018 WindRiver Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,7 +24,8 @@ import org.eclipse.equinox.p2.ui.ProvisioningUI; import org.eclipse.jface.viewers.ICheckStateProvider; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TreeItem; public abstract class AbstractImportPage extends AbstractPage { @@ -50,19 +51,15 @@ public abstract class AbstractImportPage extends AbstractPage { @Override protected void createInstallationTable(Composite parent) { super.createInstallationTable(parent); - viewer.getTree().addListener(SWT.Selection, new Listener() { - - @Override - public void handleEvent(Event event) { - if (event.detail == SWT.CHECK) { - if (hasInstalled(ProvUI.getAdapter(event.item.getData(), IInstallableUnit.class))) { - viewer.getTree().setRedraw(false); - ((TreeItem) event.item).setChecked(false); - viewer.getTree().setRedraw(true); - } + viewer.getTree().addListener(SWT.Selection, event -> { + if (event.detail == SWT.CHECK) { + if (hasInstalled(ProvUI.getAdapter(event.item.getData(), IInstallableUnit.class))) { + viewer.getTree().setRedraw(false); + ((TreeItem) event.item).setChecked(false); + viewer.getTree().setRedraw(true); } - updatePageCompletion(); } + updatePageCompletion(); }); } diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java index 2c5324686..469fd18d9 100644 --- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java +++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 WindRiver Corporation and others. + * Copyright (c) 2011, 2018 WindRiver Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -245,12 +245,7 @@ public abstract class AbstractPage extends WizardPage implements Listener { if (Messages.Column_Name.equals(titles[i])) updateTableSorting(i); final int columnIndex = i; - column.getColumn().addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateTableSorting(columnIndex); - } - }); + column.getColumn().addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> updateTableSorting(columnIndex))); } } @@ -306,35 +301,23 @@ public abstract class AbstractPage extends WizardPage implements Listener { restoreWidgetValues(); GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); destinationNameField.setLayoutData(data); - destinationNameField.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { + destinationNameField.addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> handleDestinationChanged(getDestinationValue()))); + destinationNameField.addKeyListener(KeyListener.keyPressedAdapter(e -> { + if (e.character == SWT.CR) { + entryChanged = false; + modifyDestinationValue(getDestinationValue()); handleDestinationChanged(getDestinationValue()); } - }); - destinationNameField.addKeyListener(new KeyAdapter() { - - @Override - public void keyPressed(KeyEvent e) { - if (e.character == SWT.CR) { - entryChanged = false; - modifyDestinationValue(getDestinationValue()); - handleDestinationChanged(getDestinationValue()); - } - } - }); + })); destinationNameField.addModifyListener(e -> entryChanged = true); - destinationNameField.addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - //Clear the flag to prevent constant update - if (entryChanged) { - entryChanged = false; - handleDestinationChanged(getDestinationValue()); - } - + destinationNameField.addFocusListener(FocusListener.focusLostAdapter(e -> { + //Clear the flag to prevent constant update + if (entryChanged) { + entryChanged = false; + handleDestinationChanged(getDestinationValue()); } - }); + + })); destinationBrowseButton = new Button(composite, SWT.PUSH); destinationBrowseButton.setText(Messages.Page_BUTTON_BROWSER); @@ -465,34 +448,28 @@ public abstract class AbstractPage extends WizardPage implements Listener { buttons.setLayout(new RowLayout(SWT.HORIZONTAL)); Button selectAll = new Button(buttons, SWT.PUSH); selectAll.setText(Messages.AbstractPage_ButtonSelectAll); - selectAll.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - for (TreeItem item : viewer.getTree().getItems()) { - if (!item.getChecked()) { - item.setChecked(true); - Event event = new Event(); - event.widget = item.getParent(); - event.detail = SWT.CHECK; - event.item = item; - event.type = SWT.Selection; - viewer.getTree().notifyListeners(SWT.Selection, event); - } + selectAll.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + for (TreeItem item : viewer.getTree().getItems()) { + if (!item.getChecked()) { + item.setChecked(true); + Event event = new Event(); + event.widget = item.getParent(); + event.detail = SWT.CHECK; + event.item = item; + event.type = SWT.Selection; + viewer.getTree().notifyListeners(SWT.Selection, event); } - updatePageCompletion(); } - }); + updatePageCompletion(); + })); Button deselectAll = new Button(buttons, SWT.PUSH); deselectAll.setText(Messages.AbstractPage_ButtonDeselectAll); - deselectAll.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - for (TreeItem item : viewer.getTree().getItems()) { - viewer.setSubtreeChecked(item.getData(), false); - } - updatePageCompletion(); + deselectAll.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + for (TreeItem item : viewer.getTree().getItems()) { + viewer.setSubtreeChecked(item.getData(), false); } - }); + updatePageCompletion(); + })); } protected PatternFilter getPatternFilter() { diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPopup.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPopup.java index 66b2971b4..b434edc57 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPopup.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPopup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,7 +22,8 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; @@ -59,12 +60,7 @@ public class AutomaticUpdatesPopup extends PopupDialog { downloaded = alreadyDownloaded; this.prefs = prefs; remindDelay = computeRemindDelay(); - clickListener = new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - AutomaticUpdatePlugin.getDefault().getAutomaticUpdater().launchUpdate(); - } - }; + clickListener = MouseListener.mouseDownAdapter(e -> AutomaticUpdatePlugin.getDefault().getAutomaticUpdater().launchUpdate()); } @Override @@ -94,14 +90,11 @@ public class AutomaticUpdatesPopup extends PopupDialog { private void createRemindSection(Composite parent) { remindLink = new Link(parent, SWT.MULTI | SWT.WRAP | SWT.RIGHT); updateRemindText(); - remindLink.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), PreferenceConstants.PREF_PAGE_AUTO_UPDATES, null, null); - dialog.open(); + remindLink.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getShell(), PreferenceConstants.PREF_PAGE_AUTO_UPDATES, null, null); + dialog.open(); - } - }); + })); remindLink.setLayoutData(new GridData(GridData.FILL_BOTH)); } @@ -265,19 +258,9 @@ public class AutomaticUpdatesPopup extends PopupDialog { GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).applyTo(toolBar); closeButton.setImage(AutomaticUpdatePlugin.getDefault().getImageRegistry().get((AutomaticUpdatePlugin.IMG_TOOL_CLOSE))); closeButton.setHotImage(AutomaticUpdatePlugin.getDefault().getImageRegistry().get((AutomaticUpdatePlugin.IMG_TOOL_CLOSE_HOT))); - closeButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - close(); - } - }); + closeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> close())); // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=177183 - toolBar.addMouseListener(new MouseAdapter() { - @Override - public void mouseDown(MouseEvent e) { - close(); - } - }); + toolBar.addMouseListener(MouseListener.mouseDownAdapter(e -> close())); return titleComposite; } diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPreferencePage.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPreferencePage.java index b419d774a..17ae16b41 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPreferencePage.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2017 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,8 +25,7 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -83,24 +82,14 @@ public class AutomaticUpdatesPreferencePage extends PreferencePage implements IW gd = new GridData(); gd.horizontalSpan = 3; onStartupRadio.setLayoutData(gd); - onStartupRadio.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - pageChanged(); - } - }); + onStartupRadio.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> pageChanged())); onFuzzyScheduleRadio = new Button(updateScheduleGroup, SWT.RADIO); onFuzzyScheduleRadio.setText(AutomaticUpdateMessages.AutomaticUpdatesPreferencePage_findOnSchedule); gd = new GridData(); gd.horizontalSpan = 3; onFuzzyScheduleRadio.setLayoutData(gd); - onFuzzyScheduleRadio.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - pageChanged(); - } - }); + onFuzzyScheduleRadio.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> pageChanged())); fuzzyRecurrenceCombo = new Combo(updateScheduleGroup, SWT.READ_ONLY); fuzzyRecurrenceCombo.setItems(AutomaticUpdateScheduler.FUZZY_RECURRENCE); @@ -125,24 +114,14 @@ public class AutomaticUpdatesPreferencePage extends PreferencePage implements IW gd = new GridData(); gd.horizontalSpan = 3; searchOnlyRadio.setLayoutData(gd); - searchOnlyRadio.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - pageChanged(); - } - }); + searchOnlyRadio.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> pageChanged())); searchAndDownloadRadio = new Button(downloadGroup, SWT.RADIO); searchAndDownloadRadio.setText(AutomaticUpdateMessages.AutomaticUpdatesPreferencePage_downloadAndNotify); gd = new GridData(); gd.horizontalSpan = 3; searchAndDownloadRadio.setLayoutData(gd); - searchAndDownloadRadio.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - pageChanged(); - } - }); + searchAndDownloadRadio.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> pageChanged())); createSpacer(container, 1); @@ -159,24 +138,14 @@ public class AutomaticUpdatesPreferencePage extends PreferencePage implements IW gd = new GridData(); gd.horizontalSpan = 3; remindOnceRadio.setLayoutData(gd); - remindOnceRadio.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - pageChanged(); - } - }); + remindOnceRadio.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> pageChanged())); remindScheduleRadio = new Button(remindGroup, SWT.RADIO); remindScheduleRadio.setText(AutomaticUpdateMessages.AutomaticUpdatesPreferencePage_RemindSchedule); gd = new GridData(); gd.horizontalSpan = 3; remindScheduleRadio.setLayoutData(gd); - remindScheduleRadio.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - pageChanged(); - } - }); + remindScheduleRadio.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> pageChanged())); remindElapseCombo = new Combo(remindGroup, SWT.READ_ONLY); remindElapseCombo.setItems(AutomaticUpdatesPopup.ELAPSED_LOCALIZED_STRINGS); @@ -193,12 +162,7 @@ public class AutomaticUpdatesPreferencePage extends PreferencePage implements IW initialize(); - enabledCheck.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - pageChanged(); - } - }); + enabledCheck.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> pageChanged())); Dialog.applyDialogFont(container); return container; diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java index ccaecb392..89357667f 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2017 WindRiver Corporation and others. + * Copyright (c) 2011, 2018 WindRiver Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -277,12 +277,7 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis } final int columnIndex = i; - column.getColumn().addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateTableSorting(columnIndex); - } - }); + column.getColumn().addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> updateTableSorting(columnIndex))); } } @@ -465,43 +460,37 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis buttons.setLayout(new RowLayout(SWT.HORIZONTAL)); Button selectAll = new Button(buttons, SWT.PUSH); selectAll.setText(ProvUIMessages.AbstractPage_ButtonSelectAll); - selectAll.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - for (TreeItem item : viewer.getTree().getItems()) { - if (!item.getChecked()) { - item.setChecked(true); - Event event = new Event(); - event.widget = item.getParent(); - event.detail = SWT.CHECK; - event.item = item; - event.type = SWT.Selection; - viewer.getTree().notifyListeners(SWT.Selection, event); - } + selectAll.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + for (TreeItem item : viewer.getTree().getItems()) { + if (!item.getChecked()) { + item.setChecked(true); + Event event = new Event(); + event.widget = item.getParent(); + event.detail = SWT.CHECK; + event.item = item; + event.type = SWT.Selection; + viewer.getTree().notifyListeners(SWT.Selection, event); } - updatePageCompletion(); } - }); + updatePageCompletion(); + })); Button deselectAll = new Button(buttons, SWT.PUSH); deselectAll.setText(ProvUIMessages.AbstractPage_ButtonDeselectAll); - deselectAll.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - for (TreeItem item : viewer.getTree().getItems()) { - if (item.getChecked()) { - item.setChecked(false); - Event event = new Event(); - event.widget = item.getParent(); - event.detail = SWT.CHECK; - event.item = item; - event.type = SWT.Selection; - viewer.getTree().notifyListeners(SWT.Selection, event); - } - viewer.setSubtreeChecked(item.getData(), false); + deselectAll.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + for (TreeItem item : viewer.getTree().getItems()) { + if (item.getChecked()) { + item.setChecked(false); + Event event = new Event(); + event.widget = item.getParent(); + event.detail = SWT.CHECK; + event.item = item; + event.type = SWT.Selection; + viewer.getTree().notifyListeners(SWT.Selection, event); } - updatePageCompletion(); + viewer.setSubtreeChecked(item.getData(), false); } - }); + updatePageCompletion(); + })); } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java index 9a997674e..cecb63d5b 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 IBM Corporation and others. + * Copyright (c) 2008, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -51,10 +51,6 @@ public class ColocatedRepositoryTracker extends RepositoryTracker { setMetadataRepositoryFlags(IRepositoryManager.REPOSITORIES_NON_SYSTEM); } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.ui.policy.RepositoryManipulator#getKnownRepositories() - */ @Override public URI[] getKnownRepositories(ProvisioningSession session) { return getMetadataRepositoryManager().getKnownRepositories(getMetadataRepositoryFlags()); @@ -79,9 +75,6 @@ public class ColocatedRepositoryTracker extends RepositoryTracker { } } - /* (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.RepositoryTracker#removeRepositories(java.net.URI[], org.eclipse.equinox.p2.operations.ProvisioningSession) - */ @Override public void removeRepositories(URI[] repoLocations, ProvisioningSession session) { ui.signalRepositoryOperationStart(); @@ -95,10 +88,6 @@ public class ColocatedRepositoryTracker extends RepositoryTracker { } } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.p2.operations.RepositoryTracker#refreshRepositories(java.net.URI[], org.eclipse.equinox.p2.operations.ProvisioningSession, org.eclipse.core.runtime.IProgressMonitor) - */ @Override public void refreshRepositories(URI[] locations, ProvisioningSession session, IProgressMonitor monitor) { ui.signalRepositoryOperationStart(); @@ -130,38 +119,35 @@ public class ColocatedRepositoryTracker extends RepositoryTracker { if (code == ProvisionException.REPOSITORY_NOT_FOUND || code == ProvisionException.REPOSITORY_INVALID_LOCATION) { if (!hasNotFoundStatusBeenReported(location)) { addNotFound(location); - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench.isClosing()) - return; - Shell shell = ProvUI.getDefaultParentShell(); - int result = MessageDialog.open(MessageDialog.QUESTION, shell, ProvUIMessages.ColocatedRepositoryTracker_SiteNotFoundTitle, NLS.bind(ProvUIMessages.ColocatedRepositoryTracker_PromptForSiteLocationEdit, URIUtil.toUnencodedString(location)), SWT.NONE, ProvUIMessages.ColocatedRepositoryTracker_SiteNotFound_EditButtonLabel, IDialogConstants.NO_LABEL); - if (result == 0) { - RepositoryNameAndLocationDialog dialog = new RepositoryNameAndLocationDialog(shell, ui) { - @Override - protected String getInitialLocationText() { - return URIUtil.toUnencodedString(location); - } + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { + IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench.isClosing()) + return; + Shell shell = ProvUI.getDefaultParentShell(); + int result = MessageDialog.open(MessageDialog.QUESTION, shell, ProvUIMessages.ColocatedRepositoryTracker_SiteNotFoundTitle, NLS.bind(ProvUIMessages.ColocatedRepositoryTracker_PromptForSiteLocationEdit, URIUtil.toUnencodedString(location)), SWT.NONE, ProvUIMessages.ColocatedRepositoryTracker_SiteNotFound_EditButtonLabel, IDialogConstants.NO_LABEL); + if (result == 0) { + RepositoryNameAndLocationDialog dialog = new RepositoryNameAndLocationDialog(shell, ui) { + @Override + protected String getInitialLocationText() { + return URIUtil.toUnencodedString(location); + } - @Override - protected String getInitialNameText() { - String nickname = getMetadataRepositoryManager().getRepositoryProperty(location, IRepository.PROP_NICKNAME); - return nickname == null ? "" : nickname; //$NON-NLS-1$ - } - }; - int ret = dialog.open(); - if (ret == Window.OK) { - URI correctedLocation = dialog.getLocation(); - if (correctedLocation != null) { - ui.signalRepositoryOperationStart(); - try { - removeRepositories(new URI[] {location}, ui.getSession()); - addRepository(correctedLocation, dialog.getName(), ui.getSession()); - } finally { - ui.signalRepositoryOperationComplete(null, true); - } + @Override + protected String getInitialNameText() { + String nickname = getMetadataRepositoryManager().getRepositoryProperty(location, IRepository.PROP_NICKNAME); + return nickname == null ? "" : nickname; //$NON-NLS-1$ + } + }; + int ret = dialog.open(); + if (ret == Window.OK) { + URI correctedLocation = dialog.getLocation(); + if (correctedLocation != null) { + ui.signalRepositoryOperationStart(); + try { + removeRepositories(new URI[] {location}, ui.getSession()); + addRepository(correctedLocation, dialog.getName(), ui.getSession()); + } finally { + ui.signalRepositoryOperationComplete(null, true); } } } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java index c9c7b10f3..4ebece2a6 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -81,17 +81,14 @@ public class ProvisioningOperationRunner { return; } - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (PlatformUI.getWorkbench().isClosing()) - return; - int retCode = ApplyProfileChangesDialog.promptForRestart(ProvUI.getDefaultParentShell(), restartPolicy == Policy.RESTART_POLICY_PROMPT); - if (retCode == ApplyProfileChangesDialog.PROFILE_APPLYCHANGES) { - applyProfileChanges(); - } else if (retCode == ApplyProfileChangesDialog.PROFILE_RESTART) { - PlatformUI.getWorkbench().restart(true); - } + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { + if (PlatformUI.getWorkbench().isClosing()) + return; + int retCode = ApplyProfileChangesDialog.promptForRestart(ProvUI.getDefaultParentShell(), restartPolicy == Policy.RESTART_POLICY_PROMPT); + if (retCode == ApplyProfileChangesDialog.PROFILE_APPLYCHANGES) { + applyProfileChanges(); + } else if (retCode == ApplyProfileChangesDialog.PROFILE_RESTART) { + PlatformUI.getWorkbench().restart(true); } }); } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java index b02fe5d94..8fd617c2f 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui; -import org.eclipse.equinox.p2.query.QueryUtil; - import java.net.URI; import java.util.*; import org.eclipse.core.runtime.*; @@ -74,13 +72,7 @@ public abstract class QueryableRepositoryManager implements IQueryable { } public IQueryable locationsQueriable() { - return new IQueryable() { - - @Override - public IQueryResult query(IQuery query, IProgressMonitor monitor) { - return query.perform(getRepoLocations(getRepositoryManager()).iterator()); - } - }; + return (query, monitor) -> query.perform(getRepoLocations(getRepositoryManager()).iterator()); } protected Collection getRepoLocations(IRepositoryManager manager) { diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java index 4e67a776b..445e74f51 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2014 IBM Corporation and others. + * Copyright (c) 2008, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,8 +25,7 @@ import org.eclipse.jface.viewers.*; import org.eclipse.jface.window.Window; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.*; import org.eclipse.ui.PlatformUI; @@ -53,18 +52,15 @@ public class ValidationDialogServiceUI extends UIServices { Link link = new Link(parent, SWT.NONE); link.setText(linkText); - link.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - try { - URL url = new URL(e.text); - PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(url); - } catch (Exception x) { - ProvUIActivator.getDefault().getLog().log(// - new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, x.getMessage(), x)); - } + link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + try { + URL url = new URL(e.text); + PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(url); + } catch (Exception x) { + ProvUIActivator.getDefault().getLog().log(// + new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, x.getMessage(), x)); } - }); + })); return link; } } @@ -87,29 +83,21 @@ public class ValidationDialogServiceUI extends UIServices { } } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.core.IServiceUI#getUsernamePassword(java.lang.String) - */ @Override public AuthenticationInfo getUsernamePassword(final String location) { final AuthenticationInfo[] result = new AuthenticationInfo[1]; if (!suppressAuthentication() && !isHeadless()) { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - @Override - public void run() { - Shell shell = ProvUI.getDefaultParentShell(); - String message = NLS.bind(ProvUIMessages.ServiceUI_LoginDetails, location); - UserValidationDialog dialog = new UserValidationDialog(shell, ProvUIMessages.ServiceUI_LoginRequired, null, message); - int dialogCode = dialog.open(); - if (dialogCode == Window.OK) { - result[0] = dialog.getResult(); - } else if (dialogCode == Window.CANCEL) { - result[0] = AUTHENTICATION_PROMPT_CANCELED; - } + PlatformUI.getWorkbench().getDisplay().syncExec(() -> { + Shell shell = ProvUI.getDefaultParentShell(); + String message = NLS.bind(ProvUIMessages.ServiceUI_LoginDetails, location); + UserValidationDialog dialog = new UserValidationDialog(shell, ProvUIMessages.ServiceUI_LoginRequired, null, message); + int dialogCode = dialog.open(); + if (dialogCode == Window.OK) { + result[0] = dialog.getResult(); + } else if (dialogCode == Window.CANCEL) { + result[0] = AUTHENTICATION_PROMPT_CANCELED; } - }); } return result[0]; @@ -123,10 +111,6 @@ public class ValidationDialogServiceUI extends UIServices { return false; } - /* - * (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.core.IServiceUI#showCertificates(java.lang.Object) - */ @Override public TrustInfo getTrustInfo(Certificate[][] untrustedChains, final String[] unsignedDetail) { boolean trustUnsigned = true; @@ -164,20 +148,17 @@ public class ValidationDialogServiceUI extends UIServices { final Object[] result = new Object[1]; final TreeNode[] input = createTreeNodes(untrustedChains); - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - @Override - public void run() { - Shell shell = ProvUI.getDefaultParentShell(); - ILabelProvider labelProvider = new CertificateLabelProvider(); - TreeNodeContentProvider contentProvider = new TreeNodeContentProvider(); - TrustCertificateDialog trustCertificateDialog = new TrustCertificateDialog(shell, input, labelProvider, contentProvider); - trustCertificateDialog.open(); - Certificate[] values = new Certificate[trustCertificateDialog.getResult() == null ? 0 : trustCertificateDialog.getResult().length]; - for (int i = 0; i < values.length; i++) { - values[i] = (Certificate) ((TreeNode) trustCertificateDialog.getResult()[i]).getValue(); - } - result[0] = values; + PlatformUI.getWorkbench().getDisplay().syncExec(() -> { + Shell shell = ProvUI.getDefaultParentShell(); + ILabelProvider labelProvider = new CertificateLabelProvider(); + TreeNodeContentProvider contentProvider = new TreeNodeContentProvider(); + TrustCertificateDialog trustCertificateDialog = new TrustCertificateDialog(shell, input, labelProvider, contentProvider); + trustCertificateDialog.open(); + Certificate[] values = new Certificate[trustCertificateDialog.getResult() == null ? 0 : trustCertificateDialog.getResult().length]; + for (int i = 0; i < values.length; i++) { + values[i] = (Certificate) ((TreeNode) trustCertificateDialog.getResult()[i]).getValue(); } + result[0] = values; }); persistTrust = true; trusted = (Certificate[]) result[0]; @@ -205,25 +186,21 @@ public class ValidationDialogServiceUI extends UIServices { public AuthenticationInfo getUsernamePassword(final String location, final AuthenticationInfo previousInfo) { final AuthenticationInfo[] result = new AuthenticationInfo[1]; if (!suppressAuthentication() && !isHeadless()) { - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - @Override - public void run() { - Shell shell = ProvUI.getDefaultParentShell(); - String message = null; - if (previousInfo.saveResult()) - message = NLS.bind(ProvUIMessages.ProvUIMessages_SavedNotAccepted_EnterFor_0, location); - else - message = NLS.bind(ProvUIMessages.ProvUIMessages_NotAccepted_EnterFor_0, location); - - UserValidationDialog dialog = new UserValidationDialog(previousInfo, shell, ProvUIMessages.ServiceUI_LoginRequired, null, message); - int dialogCode = dialog.open(); - if (dialogCode == Window.OK) { - result[0] = dialog.getResult(); - } else if (dialogCode == Window.CANCEL) { - result[0] = AUTHENTICATION_PROMPT_CANCELED; - } + PlatformUI.getWorkbench().getDisplay().syncExec(() -> { + Shell shell = ProvUI.getDefaultParentShell(); + String message = null; + if (previousInfo.saveResult()) + message = NLS.bind(ProvUIMessages.ProvUIMessages_SavedNotAccepted_EnterFor_0, location); + else + message = NLS.bind(ProvUIMessages.ProvUIMessages_NotAccepted_EnterFor_0, location); + + UserValidationDialog dialog = new UserValidationDialog(previousInfo, shell, ProvUIMessages.ServiceUI_LoginRequired, null, message); + int dialogCode = dialog.open(); + if (dialogCode == Window.OK) { + result[0] = dialog.getResult(); + } else if (dialogCode == Window.CANCEL) { + result[0] = AUTHENTICATION_PROMPT_CANCELED; } - }); } return result[0]; @@ -235,12 +212,9 @@ public class ValidationDialogServiceUI extends UIServices { super.showInformationMessage(title, text, linkText); return; } - PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { - @Override - public void run() { - MessageDialog dialog = new MessageDialogWithLink(ProvUI.getDefaultParentShell(), title, null, text, MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0, linkText); - dialog.open(); - } + PlatformUI.getWorkbench().getDisplay().syncExec(() -> { + MessageDialog dialog = new MessageDialogWithLink(ProvUI.getDefaultParentShell(), title, null, text, MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0, linkText); + dialog.open(); }); } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java index 2a70fb1b5..1380f14de 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -82,12 +82,9 @@ public abstract class ProfileModificationAction extends ProvisioningAction { public void done(IJobChangeEvent event) { if (PlatformUI.isWorkbenchRunning()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (validateOperation(operation)) - performAction(operation, ius); - } + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { + if (validateOperation(operation)) + performAction(operation, ius); }); } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/RefreshAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/RefreshAction.java index 8f4772d03..93b3b238c 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/RefreshAction.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/RefreshAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,8 +15,8 @@ import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; import org.eclipse.equinox.p2.ui.ProvisioningUI; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.widgets.Control; /** @@ -35,12 +35,7 @@ public abstract class RefreshAction extends ProvisioningAction { } private void hookKeyListener(Control control) { - control.addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - handleKeyReleased(e); - } - }); + control.addKeyListener(KeyListener.keyReleasedAdapter(e -> handleKeyReleased(e))); } @Override diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/UpdateAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/UpdateAction.java index 859a69cbd..3be23b56b 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/UpdateAction.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/UpdateAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -54,25 +54,16 @@ public class UpdateAction extends ExistingIUInProfileAction { return resolveIsVisible; } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.provisional.p2.ui.actions.AlterExistingProfileIUAction#getLockConstant() - */ @Override protected int getLockConstant() { return IProfile.LOCK_UPDATE; } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.p2.ui.actions.ProfileModificationAction#getProfileChangeOperation(org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit[]) - */ @Override protected ProfileChangeOperation getProfileChangeOperation(Collection ius) { return ui.getUpdateOperation(ius, null); } - /* (non-Javadoc) - * @see org.eclipse.equinox.internal.p2.ui.actions.ProfileModificationAction#performAction(org.eclipse.equinox.p2.operations.ProfileChangeOperation, org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit[]) - */ @Override protected int performAction(final ProfileChangeOperation operation, Collection ius) { if (operation.getResolutionResult() == Status.OK_STATUS) @@ -93,12 +84,7 @@ public class UpdateAction extends ExistingIUInProfileAction { @Override public void done(IJobChangeEvent event) { if (PlatformUI.isWorkbenchRunning()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - ui.openUpdateWizard(skipSelectionPage, (UpdateOperation) operation, remediationOperation, null); - } - }); + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> ui.openUpdateWizard(skipSelectionPage, (UpdateOperation) operation, remediationOperation, null)); } } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AddRepositoryDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AddRepositoryDialog.java index 13e436cbf..23442a787 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AddRepositoryDialog.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AddRepositoryDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,8 +22,7 @@ import org.eclipse.equinox.p2.ui.ProvisioningUI; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -68,20 +67,17 @@ public abstract class AddRepositoryDialog extends RepositoryNameAndLocationDialo Button localButton = new Button(comp, SWT.PUSH); localButton.setText(ProvUIMessages.RepositoryGroup_LocalRepoBrowseButton); - localButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.APPLICATION_MODAL); - dialog.setMessage(ProvUIMessages.RepositoryGroup_SelectRepositoryDirectory); - dialog.setFilterPath(lastLocalLocation); - String path = dialog.open(); - if (path != null) { - lastLocalLocation = path; - url.setText(makeLocalURIString(path)); - validateRepositoryURL(false); - } + localButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> { + DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.APPLICATION_MODAL); + dialog.setMessage(ProvUIMessages.RepositoryGroup_SelectRepositoryDirectory); + dialog.setFilterPath(lastLocalLocation); + String path = dialog.open(); + if (path != null) { + lastLocalLocation = path; + url.setText(makeLocalURIString(path)); + validateRepositoryURL(false); } - }); + })); setButtonLayoutData(localButton); // Location: [] @@ -89,21 +85,18 @@ public abstract class AddRepositoryDialog extends RepositoryNameAndLocationDialo Button archiveButton = new Button(comp, SWT.PUSH); archiveButton.setText(ProvUIMessages.RepositoryGroup_ArchivedRepoBrowseButton); - archiveButton.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - FileDialog dialog = new FileDialog(getShell(), SWT.APPLICATION_MODAL); - dialog.setText(ProvUIMessages.RepositoryGroup_RepositoryFile); - dialog.setFilterExtensions(ARCHIVE_EXTENSIONS); - dialog.setFileName(lastArchiveLocation); - String path = dialog.open(); - if (path != null) { - lastArchiveLocation = path; - url.setText(makeLocalURIString(path)); - validateRepositoryURL(false); - } + archiveButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(event -> { + FileDialog dialog = new FileDialog(getShell(), SWT.APPLICATION_MODAL); + dialog.setText(ProvUIMessages.RepositoryGroup_RepositoryFile); + dialog.setFilterExtensions(ARCHIVE_EXTENSIONS); + dialog.setFileName(lastArchiveLocation); + String path = dialog.open(); + if (path != null) { + lastArchiveLocation = path; + url.setText(makeLocalURIString(path)); + validateRepositoryURL(false); } - }); + })); setButtonLayoutData(archiveButton); comp.setTabList(new Control[] {nickname, url, localButton, archiveButton}); Dialog.applyDialogFont(comp); diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java index 62ee88dd8..16262a0d2 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2016 IBM Corporation and others. + * Copyright (c) 2008, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,7 +29,8 @@ import org.eclipse.jface.viewers.*; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.TreeEvent; +import org.eclipse.swt.events.TreeListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; @@ -195,12 +196,7 @@ public class AvailableIUGroup extends StructuredIUGroup { }; ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).addListener(listener); - availableIUViewer.getControl().addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).removeListener(listener); - } - }); + availableIUViewer.getControl().addDisposeListener(e -> ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).removeListener(listener)); updateAvailableViewState(); return availableIUViewer; } @@ -340,28 +336,20 @@ public class AvailableIUGroup extends StructuredIUGroup { // to make a repo visible. if (!(queryContext.getViewType() == IUViewQueryContext.AVAILABLE_VIEW_BY_REPO)) { if (Display.getCurrent() == null) - display.asyncExec(new Runnable() { - @Override - public void run() { - updateAvailableViewState(); - } - }); + display.asyncExec(() -> updateAvailableViewState()); else updateAvailableViewState(); return; } // First reset the input so that the new repo shows up - Runnable runnable = new Runnable() { - @Override - public void run() { - final TreeViewer treeViewer = filteredTree.getViewer(); - final Tree tree = treeViewer.getTree(); - IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench.isClosing()) - return; - if (tree != null && !tree.isDisposed()) { - updateAvailableViewState(); - } + Runnable runnable = () -> { + final TreeViewer treeViewer = filteredTree.getViewer(); + final Tree tree = treeViewer.getTree(); + IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench.isClosing()) + return; + if (tree != null && !tree.isDisposed()) { + updateAvailableViewState(); } }; if (Display.getCurrent() == null) @@ -391,27 +379,23 @@ public class AvailableIUGroup extends StructuredIUGroup { @Override public void done(final IJobChangeEvent event) { if (event.getResult().isOK()) - display.asyncExec(new Runnable() { - @Override - @SuppressWarnings("rawtypes") - public void run() { - final TreeViewer treeViewer = filteredTree.getViewer(); - IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench.isClosing()) - return; - // Expand only if there have been no other jobs started for other repos. - if (event.getJob() == lastRequestedLoadJob) { - final Tree tree = treeViewer.getTree(); - if (tree != null && !tree.isDisposed()) { - TreeItem[] items = tree.getItems(); - for (int i = 0; i < items.length; i++) { - if (items[i].getData() instanceof IRepositoryElement) { - URI url = ((IRepositoryElement) items[i].getData()).getLocation(); - if (url.equals(location)) { - treeViewer.expandToLevel(items[i].getData(), AbstractTreeViewer.ALL_LEVELS); - tree.select(items[i]); - return; - } + display.asyncExec(() -> { + final TreeViewer treeViewer = filteredTree.getViewer(); + IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench.isClosing()) + return; + // Expand only if there have been no other jobs started for other repos. + if (event.getJob() == lastRequestedLoadJob) { + final Tree tree = treeViewer.getTree(); + if (tree != null && !tree.isDisposed()) { + TreeItem[] items = tree.getItems(); + for (int i = 0; i < items.length; i++) { + if (items[i].getData() instanceof IRepositoryElement) { + URI url = ((IRepositoryElement) items[i].getData()).getLocation(); + if (url.equals(location)) { + treeViewer.expandToLevel(items[i].getData(), AbstractTreeViewer.ALL_LEVELS); + tree.select(items[i]); + return; } } } @@ -430,14 +414,11 @@ public class AvailableIUGroup extends StructuredIUGroup { final Composite parent = getComposite().getParent(); setUseBoldFontForFilteredItems(queryContext.getViewType() != IUViewQueryContext.AVAILABLE_VIEW_FLAT); - BusyIndicator.showWhile(display, new Runnable() { - @Override - public void run() { - parent.setRedraw(false); - getCheckboxTreeViewer().setInput(getNewInput()); - parent.layout(true); - parent.setRedraw(true); - } + BusyIndicator.showWhile(display, () -> { + parent.setRedraw(false); + getCheckboxTreeViewer().setInput(getNewInput()); + parent.layout(true); + parent.setRedraw(true); }); } @@ -506,38 +487,33 @@ public class AvailableIUGroup extends StructuredIUGroup { } private IPreFilterJobProvider getPreFilterJobProvider() { - return new IPreFilterJobProvider() { - - @Override - public Job getPreFilterJob() { - switch (filterConstant) { - case AVAILABLE_ALL : - Job preFilterJob = new LoadMetadataRepositoryJob(getProvisioningUI()); - preFilterJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true)); - return preFilterJob; - case AVAILABLE_NONE : - case AVAILABLE_LOCAL : + return () -> { + switch (filterConstant) { + case AVAILABLE_ALL : + Job preFilterJob = new LoadMetadataRepositoryJob(getProvisioningUI()); + preFilterJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true)); + return preFilterJob; + case AVAILABLE_NONE : + case AVAILABLE_LOCAL : + return null; + default : + if (repositoryFilter == null) return null; - default : - if (repositoryFilter == null) - return null; - Job job = new Job("Repository Load Job") { //$NON-NLS-1$ - @Override - protected IStatus run(IProgressMonitor monitor) { - try { - getProvisioningUI().loadMetadataRepository(repositoryFilter, false, monitor); - return Status.OK_STATUS; - } catch (ProvisionException e) { - return e.getStatus(); - } + Job job = new Job("Repository Load Job") { //$NON-NLS-1$ + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + getProvisioningUI().loadMetadataRepository(repositoryFilter, false, monitor); + return Status.OK_STATUS; + } catch (ProvisionException e) { + return e.getStatus(); } + } - }; - job.setPriority(Job.SHORT); - return job; - } + }; + job.setPriority(Job.SHORT); + return job; } - }; } } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java index 3242115cc..1e4117256 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -146,18 +146,8 @@ public class AvailableIUsPage extends ProvisioningWizardPage implements ISelecta // Details area iuDetailsGroup = new IUDetailsGroup(sashForm, availableIUGroup.getStructuredViewer(), SWT.DEFAULT, true); // Clear highlighted text pattern - availableIUGroup.getCheckboxTreeViewer().getTree().addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - iuDetailsGroup.setDetailHighlight(null); - } - }); - availableIUGroup.getDefaultFocusControl().addFocusListener(new FocusAdapter() { - @Override - public void focusGained(FocusEvent e) { - iuDetailsGroup.setDetailHighlight(null); - } - }); + availableIUGroup.getCheckboxTreeViewer().getTree().addFocusListener(FocusListener.focusLostAdapter(e -> iuDetailsGroup.setDetailHighlight(null))); + availableIUGroup.getDefaultFocusControl().addFocusListener(FocusListener.focusLostAdapter(e -> iuDetailsGroup.setDetailHighlight(null))); sashForm.setWeights(getSashWeights()); diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ComboAutoCompleteField.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ComboAutoCompleteField.java index 2dff508a1..e9c44d9c2 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ComboAutoCompleteField.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ComboAutoCompleteField.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 IBM Corporation and others. + * Copyright (c) 2009, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -48,57 +48,54 @@ public class ComboAutoCompleteField { } IContentProposalProvider getProposalProvider() { - return new IContentProposalProvider() { - @Override - public IContentProposal[] getProposals(String contents, int position) { - String[] items = getStringItems(); - if (contents.length() == 0 || items.length == 0) - return new IContentProposal[0]; - StringMatcher matcher = new StringMatcher("*" + contents + "*", true, false); //$NON-NLS-1$ //$NON-NLS-2$ - ArrayList matches = new ArrayList<>(); - for (int i = 0; i < items.length; i++) - if (matcher.match(items[i])) - matches.add(items[i]); + return (contents, position) -> { + String[] items = getStringItems(); + if (contents.length() == 0 || items.length == 0) + return new IContentProposal[0]; + StringMatcher matcher = new StringMatcher("*" + contents + "*", true, false); //$NON-NLS-1$ //$NON-NLS-2$ + ArrayList matches = new ArrayList<>(); + for (int i1 = 0; i1 < items.length; i1++) + if (matcher.match(items[i1])) + matches.add(items[i1]); - // We don't want to autoactivate if the only proposal exactly matches - // what is in the combo. This prevents the popup from - // opening when the user is merely scrolling through the combo values or - // has accepted a combo value. - if (matches.size() == 1 && matches.get(0).equals(combo.getText())) - return new IContentProposal[0]; + // We don't want to autoactivate if the only proposal exactly matches + // what is in the combo. This prevents the popup from + // opening when the user is merely scrolling through the combo values or + // has accepted a combo value. + if (matches.size() == 1 && matches.get(0).equals(combo.getText())) + return new IContentProposal[0]; - if (matches.isEmpty()) - return new IContentProposal[0]; + if (matches.isEmpty()) + return new IContentProposal[0]; - // Make the proposals - IContentProposal[] proposals = new IContentProposal[matches.size()]; - for (int i = 0; i < matches.size(); i++) { - final String proposal = matches.get(i); - proposals[i] = new IContentProposal() { + // Make the proposals + IContentProposal[] proposals = new IContentProposal[matches.size()]; + for (int i2 = 0; i2 < matches.size(); i2++) { + final String proposal = matches.get(i2); + proposals[i2] = new IContentProposal() { - @Override - public String getContent() { - return proposal; - } + @Override + public String getContent() { + return proposal; + } - @Override - public int getCursorPosition() { - return proposal.length(); - } + @Override + public int getCursorPosition() { + return proposal.length(); + } - @Override - public String getDescription() { - return null; - } + @Override + public String getDescription() { + return null; + } - @Override - public String getLabel() { - return null; - } - }; - } - return proposals; + @Override + public String getLabel() { + return null; + } + }; } + return proposals; }; } } \ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ContainerCheckedTreeViewer.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ContainerCheckedTreeViewer.java index 0e4f36aec..304e68497 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ContainerCheckedTreeViewer.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ContainerCheckedTreeViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -83,12 +83,7 @@ public class ContainerCheckedTreeViewer extends CheckboxTreeViewer { private void initViewer() { setUseHashlookup(true); - addCheckStateListener(new ICheckStateListener() { - @Override - public void checkStateChanged(CheckStateChangedEvent event) { - doCheckStateChanged(event.getElement()); - } - }); + addCheckStateListener(event -> doCheckStateChanged(event.getElement())); addTreeListener(new ITreeViewerListener() { @Override public void treeCollapsed(TreeExpansionEvent event) { diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java index 5e2cef597..d1527c546 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2016 IBM Corporation and others. + * Copyright (c) 2008, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,10 +13,7 @@ package org.eclipse.equinox.internal.p2.ui.dialogs; import java.util.*; import org.eclipse.core.runtime.jobs.*; import org.eclipse.equinox.internal.p2.ui.viewers.DeferredQueryContentProvider; -import org.eclipse.equinox.internal.p2.ui.viewers.IInputChangeListener; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.widgets.*; import org.eclipse.ui.dialogs.FilteredTree; import org.eclipse.ui.dialogs.PatternFilter; @@ -62,48 +59,45 @@ public class DelayedFilterCheckboxTree extends FilteredTree { @Override protected TreeViewer doCreateTreeViewer(Composite composite, int style) { checkboxViewer = new ContainerCheckedTreeViewer(composite, style); - checkboxViewer.addCheckStateListener(new ICheckStateListener() { - @Override - public void checkStateChanged(CheckStateChangedEvent event) { - // We use an additive check state cache so we need to remove - // previously checked items if the user unchecked them. - if (!event.getChecked() && checkState != null) { - if (event.getElement() == ALL_ITEMS_HACK) { - clearCheckStateCache(); - } else { - ArrayList toRemove = new ArrayList<>(1); - // See bug 258117. Ideally we would get check state changes - // for children when the parent state changed, but we aren't, so - // we need to remove all children from the additive check state - // cache. - if (contentProvider.hasChildren(event.getElement())) { - Set unchecked = new HashSet<>(); - Object[] children = contentProvider.getChildren(event.getElement()); - for (Object element : children) { - unchecked.add(element); - } - Iterator iter = checkState.iterator(); - while (iter.hasNext()) { - Object current = iter.next(); - if (current != null && unchecked.contains(current)) { - toRemove.add(current); - } + checkboxViewer.addCheckStateListener(event -> { + // We use an additive check state cache so we need to remove + // previously checked items if the user unchecked them. + if (!event.getChecked() && checkState != null) { + if (event.getElement() == ALL_ITEMS_HACK) { + clearCheckStateCache(); + } else { + ArrayList toRemove = new ArrayList<>(1); + // See bug 258117. Ideally we would get check state changes + // for children when the parent state changed, but we aren't, so + // we need to remove all children from the additive check state + // cache. + if (contentProvider.hasChildren(event.getElement())) { + Set unchecked = new HashSet<>(); + Object[] children = contentProvider.getChildren(event.getElement()); + for (Object element1 : children) { + unchecked.add(element1); + } + Iterator iter = checkState.iterator(); + while (iter.hasNext()) { + Object current = iter.next(); + if (current != null && unchecked.contains(current)) { + toRemove.add(current); } - } else { - for (Object element : checkState) { - if (checkboxViewer.getComparer().equals(element, event.getElement())) { - toRemove.add(element); - // Do not break out of the loop. We may have duplicate equal - // elements in the cache. Since the cache is additive, we want - // to be sure we've gotten everything. - } + } + } else { + for (Object element2 : checkState) { + if (checkboxViewer.getComparer().equals(element2, event.getElement())) { + toRemove.add(element2); + // Do not break out of the loop. We may have duplicate equal + // elements in the cache. Since the cache is additive, we want + // to be sure we've gotten everything. } } - checkState.removeAll(toRemove); } - } else if (event.getChecked()) { - rememberLeafCheckState(); + checkState.removeAll(toRemove); } + } else if (event.getChecked()) { + rememberLeafCheckState(); } }); return checkboxViewer; @@ -112,52 +106,41 @@ public class DelayedFilterCheckboxTree extends FilteredTree { @Override protected Composite createFilterControls(Composite filterParent) { super.createFilterControls(filterParent); - filterParent.addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - cancelPreFilterJob(); - } - }); + filterParent.addDisposeListener(e -> cancelPreFilterJob()); return filterParent; } public void contentProviderSet(final DeferredQueryContentProvider deferredProvider) { this.contentProvider = deferredProvider; - deferredProvider.addListener(new IInputChangeListener() { - @Override - public void inputChanged(Viewer v, Object oldInput, Object newInput) { - if (newInput == null) { + deferredProvider.addListener((v, oldInput, newInput) -> { + if (newInput == null) { + return; + } + // Store the input because it's not reset in the viewer until + // after this listener is run. + viewerInput = newInput; + + // If we were loading repos, we want to cancel because there may be more. + cancelPreFilterJob(); + // Cancel any filtering + cancelAndResetFilterJob(); + contentProvider.setSynchronous(false); + // Remember any previous expansions + rememberExpansions(); + // If there are remembered check states, try to restore them. + // Must be done in an async because we are in the middle of a buggy + // selection preserving viewer refresh. + checkboxViewer.getTree().setRedraw(false); + display.asyncExec(() -> { + if (checkboxViewer.getTree().isDisposed()) { return; } - // Store the input because it's not reset in the viewer until - // after this listener is run. - viewerInput = newInput; - - // If we were loading repos, we want to cancel because there may be more. - cancelPreFilterJob(); - // Cancel any filtering - cancelAndResetFilterJob(); - contentProvider.setSynchronous(false); - // Remember any previous expansions rememberExpansions(); - // If there are remembered check states, try to restore them. - // Must be done in an async because we are in the middle of a buggy - // selection preserving viewer refresh. - checkboxViewer.getTree().setRedraw(false); - display.asyncExec(new Runnable() { - @Override - public void run() { - if (checkboxViewer.getTree().isDisposed()) { - return; - } - rememberExpansions(); - restoreLeafCheckState(); - rememberExpansions(); - restoreExpansions(); - checkboxViewer.getTree().setRedraw(true); - } - }); - } + restoreLeafCheckState(); + rememberExpansions(); + restoreExpansions(); + checkboxViewer.getTree().setRedraw(true); + }); }); } @@ -183,22 +166,19 @@ public class DelayedFilterCheckboxTree extends FilteredTree { } final boolean[] shouldPreFilter = new boolean[1]; shouldPreFilter[0] = false; - display.syncExec(new Runnable() { - @Override - public void run() { - if (filterText != null && !filterText.isDisposed()) { - String text = getFilterString(); - // If we are about to filter and there is - // actually filtering to do, check for a prefilter - // job and the content provider to synchronous mode. - // We want the prefilter job to complete before continuing with filtering. - if (text == null || (initialText != null && initialText.equals(text))) { - return; - } - if (!contentProvider.getSynchronous() && preFilterJob == null) { - if (filterText != null && !filterText.isDisposed()) { - shouldPreFilter[0] = true; - } + display.syncExec(() -> { + if (filterText != null && !filterText.isDisposed()) { + String text = getFilterString(); + // If we are about to filter and there is + // actually filtering to do, check for a prefilter + // job and the content provider to synchronous mode. + // We want the prefilter job to complete before continuing with filtering. + if (text == null || (initialText != null && initialText.equals(text))) { + return; + } + if (!contentProvider.getSynchronous() && preFilterJob == null) { + if (filterText != null && !filterText.isDisposed()) { + shouldPreFilter[0] = true; } } } @@ -217,33 +197,25 @@ public class DelayedFilterCheckboxTree extends FilteredTree { @Override public void running(IJobChangeEvent event) { - display.syncExec(new Runnable() { - @Override - public void run() { - rememberLeafCheckState(); - } - }); + display.syncExec(() -> rememberLeafCheckState()); } @Override public void done(IJobChangeEvent event) { if (event.getResult().isOK()) { - display.asyncExec(new Runnable() { - @Override - public void run() { - if (checkboxViewer.getTree().isDisposed()) { - return; - } - - checkboxViewer.getTree().setRedraw(false); - // remember things expanded by the filter - rememberExpansions(); - restoreLeafCheckState(); - // now restore expansions because we may have - // had others - restoreExpansions(); - checkboxViewer.getTree().setRedraw(true); + display.asyncExec(() -> { + if (checkboxViewer.getTree().isDisposed()) { + return; } + + checkboxViewer.getTree().setRedraw(false); + // remember things expanded by the filter + rememberExpansions(); + restoreLeafCheckState(); + // now restore expansions because we may have + // had others + restoreExpansions(); + checkboxViewer.getTree().setRedraw(true); }); } } @@ -350,10 +322,6 @@ public class DelayedFilterCheckboxTree extends FilteredTree { return checkboxViewer; } - /* - * (non-Javadoc) - * @see org.eclipse.ui.dialogs.FilteredTree#getRefreshJobDelay() - */ @Override protected long getRefreshJobDelay() { return FILTER_DELAY; diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java index b749caf55..a6a64d6e8 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,8 +17,7 @@ import org.eclipse.equinox.p2.metadata.ICopyright; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -60,16 +59,13 @@ public class IUCopyrightPropertyPage extends IUPropertyPage { gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = computeWidthLimit(link, 80); link.setLayoutData(gd); - link.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - try { - showURL(copyright.getLocation().toURL()); - } catch (MalformedURLException e1) { - //cannot show this URL - } + link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + try { + showURL(copyright.getLocation().toURL()); + } catch (MalformedURLException e1) { + //cannot show this URL } - }); + })); } return composite; diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java index 3af6f1e30..5aaa80660 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,8 +16,7 @@ import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -102,12 +101,7 @@ public class IUGeneralInfoPropertyPage extends IUPropertyPage { GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = computeWidthLimit(link, 80); link.setLayoutData(gd); - link.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - showURL(url); - } - }); + link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> showURL(url))); } } } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java index 797d60dac..b46465261 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,8 +17,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.ILicense; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.*; @@ -62,16 +61,13 @@ public class IULicensePropertyPage extends IUPropertyPage { gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); gd.widthHint = computeWidthLimit(link, 80); link.setLayoutData(gd); - link.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - try { - showURL(license.getLocation().toURL()); - } catch (Exception e1) { - //can't browse invalid location - } + link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> { + try { + showURL(license.getLocation().toURL()); + } catch (Exception e1) { + //can't browse invalid location } - }); + })); } return composite; diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java index 21c5794ba..1e8ea5064 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2015 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -212,19 +212,11 @@ public class InstallWizard extends WizardWithLicenses { // Is the update manager installer present? If so, offer to open it. // In either case, the failure will be reported in this wizard. if (ProvUI.isUpdateManagerInstallerPresent()) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - Shell shell = ProvUI.getDefaultParentShell(); - MessageDialog dialog = new MessageDialog(shell, ProvUIMessages.Policy_RequiresUpdateManagerTitle, null, ProvUIMessages.Policy_RequiresUpdateManagerMessage, MessageDialog.WARNING, new String[] {ProvUIMessages.LaunchUpdateManagerButton, IDialogConstants.CANCEL_LABEL}, 0); - if (dialog.open() == 0) - BusyIndicator.showWhile(shell.getDisplay(), new Runnable() { - @Override - public void run() { - UpdateManagerCompatibility.openInstaller(); - } - }); - } + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { + Shell shell = ProvUI.getDefaultParentShell(); + MessageDialog dialog = new MessageDialog(shell, ProvUIMessages.Policy_RequiresUpdateManagerTitle, null, ProvUIMessages.Policy_RequiresUpdateManagerMessage, MessageDialog.WARNING, new String[] {ProvUIMessages.LaunchUpdateManagerButton, IDialogConstants.CANCEL_LABEL}, 0); + if (dialog.open() == 0) + BusyIndicator.showWhile(shell.getDisplay(), () -> UpdateManagerCompatibility.openInstaller()); }); } return installHandlerStatus; diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java index da6dec0a5..c2aec62ed 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,8 +18,6 @@ import org.eclipse.equinox.p2.ui.ProvisioningUI; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.*; import org.eclipse.ui.dialogs.FilteredTree; @@ -78,12 +76,7 @@ public class InstalledIUGroup extends StructuredIUGroup { final StructuredViewerProvisioningListener listener = new StructuredViewerProvisioningListener(getClass().getName(), installedIUViewer, ProvUIProvisioningListener.PROV_EVENT_IU | ProvUIProvisioningListener.PROV_EVENT_PROFILE, getProvisioningUI().getOperationRunner()); ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).addListener(listener); - installedIUViewer.getControl().addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).removeListener(listener); - } - }); + installedIUViewer.getControl().addDisposeListener(e -> ProvUI.getProvisioningEventBus(getProvisioningUI().getSession()).removeListener(listener)); return installedIUViewer; } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java index da5937ef3..961b5ddf6 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 IBM Corporation and others. + * Copyright (c) 2008, 2018 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -25,7 +25,6 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.operations.*; import org.eclipse.equinox.p2.ui.*; import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.*; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; @@ -76,10 +75,6 @@ public abstract class ProvisioningOperationWizard extends Wizard { return remediationOperation; } - /* - * (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#addPages() - */ @Override public void addPages() { mainPage = createMainPage(root, planSelections); @@ -111,11 +106,6 @@ public abstract class ProvisioningOperationWizard extends Wizard { return repoPreloadJob; } - /* - * (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#getPreviousPage(org.eclipse.jface.wizard.IWizardPage) - * - */ @Override public IWizardPage getPreviousPage(IWizardPage page) { if (page == errorPage) { @@ -124,11 +114,6 @@ public abstract class ProvisioningOperationWizard extends Wizard { return super.getPreviousPage(page); } - /* - * (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage) - * - */ @Override public IWizardPage getNextPage(IWizardPage page) { // If we are moving from the main page or error page, we may need to resolve before @@ -136,12 +121,9 @@ public abstract class ProvisioningOperationWizard extends Wizard { if (page == remediationPage) { try { - getContainer().run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) { - remediationOperation.setCurrentRemedy(remediationPage.getRemediationGroup().getCurrentRemedy()); - remediationOperation.resolveModal(monitor); - } + getContainer().run(true, true, monitor -> { + remediationOperation.setCurrentRemedy(remediationPage.getRemediationGroup().getCurrentRemedy()); + remediationOperation.resolveModal(monitor); }); } catch (InterruptedException e) { // Nothing to report if thread was interrupted @@ -289,15 +271,12 @@ public abstract class ProvisioningOperationWizard extends Wizard { operation = getProfileChangeOperation(planSelections); operation.setProvisioningContext(provisioningContext); try { - runnableContext.run(true, true, new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) { - operation.resolveModal(monitor); - if (withRemediation) { - IStatus status = operation.getResolutionResult(); - if (remediationPage != null && shouldRemediate(status)) { - computeRemediationOperation(operation, ui, monitor); - } + runnableContext.run(true, true, monitor -> { + operation.resolveModal(monitor); + if (withRemediation) { + IStatus status = operation.getResolutionResult(); + if (remediationPage != null && shouldRemediate(status)) { + computeRemediationOperation(operation, ui, monitor); } } }); @@ -421,10 +400,6 @@ public abstract class ProvisioningOperationWizard extends Wizard { } } - /* - * (non-Javadoc) - * @see org.eclipse.jface.wizard.Wizard#dispose() - */ @Override public void dispose() { ui.signalRepositoryOperationComplete(null, false); @@ -433,12 +408,9 @@ public abstract class ProvisioningOperationWizard extends Wizard { void asyncReportLoadFailures() { if (repoPreloadJob != null && getShell() != null && !getShell().isDisposed()) { - getShell().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (PlatformUI.isWorkbenchRunning() && getShell() != null && !getShell().isDisposed()) - repoPreloadJob.reportAccumulatedStatus(); - } + getShell().getDisplay().asyncExec(() -> { + if (PlatformUI.isWorkbenchRunning() && getShell() != null && !getShell().isDisposed()) + repoPreloadJob.reportAccumulatedStatus(); }); } } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java index e460acef9..1288341c1 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 Red Hat, Inc. and others + * Copyright (c) 2013, 2018 Red Hat, Inc. and others * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,8 +22,7 @@ import org.eclipse.jface.viewers.*; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StackLayout; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -120,30 +119,27 @@ public class RemediationGroup { Label descriptionLabel = new Label(remediationComposite, SWT.NONE); descriptionLabel.setText(ProvUIMessages.RemediationPage_SubDescription); - solutionslistener = new Listener() { - @Override - public void handleEvent(Event e) { - Button btn = (Button) e.widget; - Remedy remedy = (btn.getData() == null ? null : (Remedy) btn.getData()); - checkboxes.get(ALLOWPARTIALINSTALL_INDEX).setSelection(remedy != null && remedy.getConfig().allowPartialInstall); - checkboxes.get(ALLOWDIFFERENTVERSION_INDEX).setSelection(remedy != null && remedy.getConfig().allowDifferentVersion); - checkboxes.get(ALLOWINSTALLEDUPDATE_INDEX).setSelection(remedy != null && remedy.getConfig().allowInstalledUpdate); - checkboxes.get(ALLOWINSTALLEDREMOVAL_INDEX).setSelection(remedy != null && remedy.getConfig().allowInstalledRemoval); - for (Iterator