Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-01-26 19:30:17 +0000
committerAlexander Kurtakov2018-01-26 19:30:17 +0000
commit86643c0b8be9a53a0c29011e5199202e68a92aa1 (patch)
tree9bad080a2a278c4134d7aabaa4285226b66ef809
parent631cdd4b4d83bc5cd89e9d8d9118dc9faa420588 (diff)
downloadrt.equinox.p2-86643c0b8be9a53a0c29011e5199202e68a92aa1.tar.gz
rt.equinox.p2-86643c0b8be9a53a0c29011e5199202e68a92aa1.tar.xz
rt.equinox.p2-86643c0b8be9a53a0c29011e5199202e68a92aa1.zip
Bug 530396 - Move UI code to lambdas
Change-Id: I92c7b5c6cbde04280da91a9ee617495ff0381a73 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.admin/src/org/eclipse/equinox/internal/p2/ui/admin/dialogs/ProfileGroup.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractImportPage.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java87
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPopup.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdatesPreferencePage.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java65
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ColocatedRepositoryTracker.java72
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java118
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ProfileModificationAction.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/RefreshAction.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/UpdateAction.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AddRepositoryDialog.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUGroup.java140
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/AvailableIUsPage.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ComboAutoCompleteField.java85
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ContainerCheckedTreeViewer.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/DelayedFilterCheckboxTree.java210
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUCopyrightPropertyPage.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IUGeneralInfoPropertyPage.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/IULicensePropertyPage.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstallWizard.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/InstalledIUGroup.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RemediationGroup.java66
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java193
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/ProvElementContentProvider.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java311
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java40
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<T> extends Composite {
@@ -60,7 +58,7 @@ public abstract class ControlListItem<T> 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<T> 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<Object> 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<T extends CatalogItem> 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<T extends CatalogItem> 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<T> implements IQueryable<T> {
}
public IQueryable<URI> locationsQueriable() {
- return new IQueryable<URI>() {
-
- @Override
- public IQueryResult<URI> query(IQuery<URI> query, IProgressMonitor monitor) {
- return query.perform(getRepoLocations(getRepositoryManager()).iterator());
- }
- };
+ return (query, monitor) -> query.perform(getRepoLocations(getRepositoryManager()).iterator());
}
protected Collection<URI> getRepoLocations(IRepositoryManager<T> 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<IInstallableUnit> 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<IInstallableUnit> 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<String> 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<String> 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<Object> 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<Object> unchecked = new HashSet<>();
- Object[] children = contentProvider.getChildren(event.getElement());
- for (Object element : children) {
- unchecked.add(element);
- }
- Iterator<Object> 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<Object> 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<Object> unchecked = new HashSet<>();
+ Object[] children = contentProvider.getChildren(event.getElement());
+ for (Object element1 : children) {
+ unchecked.add(element1);
+ }
+ Iterator<Object> 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<Button> iterator = checkboxes.iterator(); iterator.hasNext();) {
- Button btn1 = iterator.next();
- btn1.setVisible(true);
- }
- if (btn == buildMyOwnSolution && btn.getSelection()) {
- checkBoxesComposite.setVisible(true);
- ((GridData) checkBoxesComposite.getLayoutData()).exclude = false;
- } else {
- checkBoxesComposite.setVisible(false);
- ((GridData) checkBoxesComposite.getLayoutData()).exclude = true;
- }
- currentRemedy = searchRemedyMatchingUserChoices();
- refreshResultComposite();
- remediationComposite.layout(false);
+ solutionslistener = 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<Button> iterator = checkboxes.iterator(); iterator.hasNext();) {
+ Button btn1 = iterator.next();
+ btn1.setVisible(true);
+ }
+ if (btn == buildMyOwnSolution && btn.getSelection()) {
+ checkBoxesComposite.setVisible(true);
+ ((GridData) checkBoxesComposite.getLayoutData()).exclude = false;
+ } else {
+ checkBoxesComposite.setVisible(false);
+ ((GridData) checkBoxesComposite.getLayoutData()).exclude = true;
}
+ currentRemedy = searchRemedyMatchingUserChoices();
+ refreshResultComposite();
+ remediationComposite.layout(false);
};
bestBeingInstalledRelaxedButton = new Button(remediationComposite, SWT.RADIO);
@@ -158,12 +154,9 @@ public class RemediationGroup {
buildMyOwnSolution.setText(ProvUIMessages.RemediationPage_BestSolutionBuilt);
buildMyOwnSolution.addListener(SWT.Selection, solutionslistener);
- Listener checkboxListener = new Listener() {
- @Override
- public void handleEvent(Event e) {
- currentRemedy = searchRemedyMatchingUserChoices();
- refreshResultComposite();
- }
+ Listener checkboxListener = e -> {
+ currentRemedy = searchRemedyMatchingUserChoices();
+ refreshResultComposite();
};
checkBoxesComposite = new Composite(remediationComposite, SWT.NONE);
checkBoxesComposite.setLayout(new GridLayout(1, false));
@@ -484,13 +477,8 @@ public class RemediationGroup {
}
}
- private SelectionAdapter columnChangeListener(final int index) {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateTableSorting(index);
- }
- };
+ private SelectionListener columnChangeListener(final int index) {
+ return SelectionListener.widgetSelectedAdapter(e -> updateTableSorting(index));
}
private void updateTableSorting(int columnIndex) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java
index 9c0d3a5b6..0bd06723f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositoryNameAndLocationDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 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
@@ -23,8 +23,6 @@ import org.eclipse.jface.dialogs.StatusDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.dnd.*;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
@@ -151,12 +149,7 @@ public class RepositoryNameAndLocationDialog extends StatusDialog {
// the location is reverted to the original one that has not been saved
status[0] = Status.OK_STATUS;
else
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- @Override
- public void run() {
- status[0] = getRepositoryTracker().validateRepositoryLocation(ui.getSession(), userLocation, contactRepositories, null);
- }
- });
+ BusyIndicator.showWhile(getShell().getDisplay(), () -> status[0] = getRepositoryTracker().validateRepositoryLocation(ui.getSession(), userLocation, contactRepositories, null));
}
// At this point the subclasses may have decided to opt out of
// this dialog.
@@ -220,12 +213,7 @@ public class RepositoryNameAndLocationDialog extends StatusDialog {
DropTarget target = new DropTarget(url, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
target.setTransfer(new Transfer[] {URLTransfer.getInstance(), FileTransfer.getInstance()});
target.addDropListener(new TextURLDropAdapter(url, true));
- url.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- validateRepositoryURL(false);
- }
- });
+ url.addModifyListener(e -> validateRepositoryURL(false));
initialURL = getInitialLocationText();
url.setText(initialURL);
url.setSelection(0, url.getText().length());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
index dd485c42c..e6eef8c39 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/RepositorySelectionGroup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2016 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
@@ -31,7 +31,6 @@ import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.osgi.util.NLS;
@@ -133,23 +132,16 @@ public class RepositorySelectionGroup {
// Auto complete - install before our own key listeners, so that auto complete gets first shot.
repoAutoComplete = new ComboAutoCompleteField(repoCombo);
repoCombo.setVisibleItemCount(COUNT_VISIBLE_ITEMS);
- repoCombo.addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)
- addRepository(false);
- }
- });
+ repoCombo.addKeyListener(KeyListener.keyPressedAdapter(e -> {
+ if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR)
+ addRepository(false);
+ }));
// We don't ever want this to be interpreted as a default
// button event
- repoCombo.addTraverseListener(new TraverseListener() {
- @Override
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_RETURN) {
- e.doit = false;
- }
+ repoCombo.addTraverseListener(e -> {
+ if (e.detail == SWT.TRAVERSE_RETURN) {
+ e.doit = false;
}
});
@@ -158,27 +150,24 @@ public class RepositorySelectionGroup {
gd.horizontalIndent = DEC_MARGIN_WIDTH * 2;
repoCombo.setLayoutData(gd);
repoCombo.setFont(comboComposite.getFont());
- repoCombo.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent event) {
- URI location = null;
- IStatus status = null;
- String text = repoCombo.getText().trim();
- int index = getComboIndex(text);
- // only validate text that doesn't match existing text in combo
- if (index < 0) {
- location = tracker.locationFromString(repoCombo.getText());
- if (location == null) {
- status = tracker.getInvalidLocationStatus(repoCombo.getText());
- } else {
- status = tracker.validateRepositoryLocation(ui.getSession(), location, false, new NullProgressMonitor());
- }
+ repoCombo.addModifyListener(event -> {
+ URI location = null;
+ IStatus status = null;
+ String text = repoCombo.getText().trim();
+ int index = getComboIndex(text);
+ // only validate text that doesn't match existing text in combo
+ if (index < 0) {
+ location = tracker.locationFromString(repoCombo.getText());
+ if (location == null) {
+ status = tracker.getInvalidLocationStatus(repoCombo.getText());
} else {
- // user typed or pasted an existing location. Select it.
- repoComboSelectionChanged();
+ status = tracker.validateRepositoryLocation(ui.getSession(), location, false, new NullProgressMonitor());
}
- setRepoComboDecoration(status);
+ } else {
+ // user typed or pasted an existing location. Select it.
+ repoComboSelectionChanged();
}
+ setRepoComboDecoration(status);
});
repoDec = new ControlDecoration(repoCombo, SWT.LEFT | SWT.TOP);
@@ -187,9 +176,6 @@ public class RepositorySelectionGroup {
DropTarget target = new DropTarget(repoCombo, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
target.setTransfer(new Transfer[] {URLTransfer.getInstance(), FileTransfer.getInstance()});
target.addDropListener(new URLDropAdapter(true) {
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.p2.ui.dialogs.URLDropAdapter#handleURLString(java.lang.String, org.eclipse.swt.dnd.DropTargetEvent)
- */
@Override
protected void handleDrop(String urlText, DropTargetEvent event) {
repoCombo.setText(urlText);
@@ -217,13 +203,7 @@ public class RepositorySelectionGroup {
createRepoManipulatorButton(comboComposite);
addComboProvisioningListeners();
- parent.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- removeProvisioningListeners();
- }
-
- });
+ parent.addDisposeListener(e -> removeProvisioningListeners());
}
private void createRepoManipulatorButton(Composite comboComposite) {
@@ -305,12 +285,9 @@ public class RepositorySelectionGroup {
repoDec.setShowOnlyOnFocus(false);
// use a delay to show the validation method because the very next
// selection or keystroke might fix it
- repoCombo.getDisplay().timerExec(500, new Runnable() {
- @Override
- public void run() {
- if (repoDec != null && repoDec.getImage() != info)
- repoDec.showHoverText(status.getMessage());
- }
+ repoCombo.getDisplay().timerExec(500, () -> {
+ if (repoDec != null && repoDec.getImage() != info)
+ repoDec.showHoverText(status.getMessage());
});
}
@@ -344,39 +321,36 @@ public class RepositorySelectionGroup {
items[items.length - 1] = SITE_LOCAL;
if (sites.length > 0)
sortRepoItems(items, comboRepos, hasLocalSites);
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- if (repoCombo == null || repoCombo.isDisposed())
- return;
- String repoToSelect = selection;
- if (repoToSelect == null) {
- // If the combo is open and something is selected, use that index if we
- // weren't given a string to select.
- int selIndex = repoCombo.getSelectionIndex();
- if (selIndex >= 0)
- repoToSelect = repoCombo.getItem(selIndex);
- else
- repoToSelect = repoCombo.getText();
- }
- repoCombo.setItems(items);
- repoAutoComplete.setProposalStrings(getComboProposals());
- boolean selected = false;
- for (int i = 0; i < items.length; i++)
- if (items[i].equals(repoToSelect)) {
- selected = true;
- if (repoCombo.getListVisible())
- repoCombo.select(i);
- repoCombo.setText(repoToSelect);
- break;
- }
- if (!selected) {
+ Runnable runnable = () -> {
+ if (repoCombo == null || repoCombo.isDisposed())
+ return;
+ String repoToSelect = selection;
+ if (repoToSelect == null) {
+ // If the combo is open and something is selected, use that index if we
+ // weren't given a string to select.
+ int selIndex = repoCombo.getSelectionIndex();
+ if (selIndex >= 0)
+ repoToSelect = repoCombo.getItem(selIndex);
+ else
+ repoToSelect = repoCombo.getText();
+ }
+ repoCombo.setItems(items);
+ repoAutoComplete.setProposalStrings(getComboProposals());
+ boolean selected = false;
+ for (int i = 0; i < items.length; i++)
+ if (items[i].equals(repoToSelect)) {
+ selected = true;
if (repoCombo.getListVisible())
- repoCombo.select(INDEX_SITE_NONE);
- repoCombo.setText(SITE_NONE);
+ repoCombo.select(i);
+ repoCombo.setText(repoToSelect);
+ break;
}
- repoComboSelectionChanged();
+ if (!selected) {
+ if (repoCombo.getListVisible())
+ repoCombo.select(INDEX_SITE_NONE);
+ repoCombo.setText(SITE_NONE);
}
+ repoComboSelectionChanged();
};
if (Display.getCurrent() == null)
repoCombo.getDisplay().asyncExec(runnable);
@@ -409,18 +383,8 @@ public class RepositorySelectionGroup {
uriToString.put(locations[i], strings[i]);
}
final Collator collator = Collator.getInstance(Locale.getDefault());
- Comparator<String> stringComparator = new Comparator<String>() {
- @Override
- public int compare(String a, String b) {
- return collator.compare(a, b);
- }
- };
- Comparator<URI> uriComparator = new Comparator<URI>() {
- @Override
- public int compare(URI a, URI b) {
- return collator.compare(uriToString.get(a), uriToString.get(b));
- }
- };
+ Comparator<String> stringComparator = (a, b) -> collator.compare(a, b);
+ Comparator<URI> uriComparator = (a, b) -> collator.compare(uriToString.get(a), uriToString.get(b));
Arrays.sort(strings, sortStart, sortEnd, stringComparator);
Arrays.sort(locations, sortStart, sortEnd, uriComparator);
@@ -563,32 +527,29 @@ public class RepositorySelectionGroup {
fillRepoCombo(getSiteString(location));
} else if (isNewText) {
try {
- container.run(false, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) {
- URI location;
- IStatus status;
- // This might be a disabled repo. If so, no need to validate further.
- if (disabledRepoProposals.containsKey(selectedRepo)) {
- location = disabledRepoProposals.get(selectedRepo);
- status = Status.OK_STATUS;
- } else {
- location = manipulator.locationFromString(selectedRepo);
- if (location == null)
- status = manipulator.getInvalidLocationStatus(selectedRepo);
- else {
- status = manipulator.validateRepositoryLocation(ui.getSession(), location, false, monitor);
- }
- }
- if (status.isOK() && location != null) {
- String nick = null;
- if (manipulator instanceof ColocatedRepositoryTracker)
- nick = ((ColocatedRepositoryTracker) manipulator).getParsedNickname(location);
- manipulator.addRepository(location, nick, ui.getSession());
- fillRepoCombo(getSiteString(location));
+ container.run(false, false, monitor -> {
+ URI location;
+ IStatus status;
+ // This might be a disabled repo. If so, no need to validate further.
+ if (disabledRepoProposals.containsKey(selectedRepo)) {
+ location = disabledRepoProposals.get(selectedRepo);
+ status = Status.OK_STATUS;
+ } else {
+ location = manipulator.locationFromString(selectedRepo);
+ if (location == null)
+ status = manipulator.getInvalidLocationStatus(selectedRepo);
+ else {
+ status = manipulator.validateRepositoryLocation(ui.getSession(), location, false, monitor);
}
- setRepoComboDecoration(status);
}
+ if (status.isOK() && location != null) {
+ String nick = null;
+ if (manipulator instanceof ColocatedRepositoryTracker)
+ nick = ((ColocatedRepositoryTracker) manipulator).getParsedNickname(location);
+ manipulator.addRepository(location, nick, ui.getSession());
+ fillRepoCombo(getSiteString(location));
+ }
+ setRepoComboDecoration(status);
});
} catch (InvocationTargetException e) {
// ignore
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java
index ba7b09334..5bb486d83 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ResolutionResultsWizardPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 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
@@ -14,7 +14,8 @@
package org.eclipse.equinox.internal.p2.ui.dialogs;
import java.util.Collection;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.ui.*;
import org.eclipse.equinox.internal.p2.ui.model.*;
import org.eclipse.equinox.internal.p2.ui.viewers.*;
@@ -26,7 +27,6 @@ import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -64,10 +64,6 @@ public abstract class ResolutionResultsWizardPage extends ResolutionStatusPage {
this.input = input;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
@Override
public void createControl(Composite parent) {
display = parent.getDisplay();
@@ -182,28 +178,17 @@ public abstract class ResolutionResultsWizardPage extends ResolutionStatusPage {
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
controlsComposite.setLayoutData(gd);
- final Runnable runnable = new Runnable() {
- @Override
- public void run() {
- treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- setDetailText(resolvedOperation);
- }
- });
- setDrilldownElements(input, resolvedOperation);
- treeViewer.setInput(input);
- }
+ final Runnable runnable = () -> {
+ treeViewer.addSelectionChangedListener(event -> setDetailText(resolvedOperation));
+ setDrilldownElements(input, resolvedOperation);
+ treeViewer.setInput(input);
};
if (resolvedOperation != null && !resolvedOperation.hasResolved()) {
try {
- getContainer().run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) {
- resolvedOperation.resolveModal(monitor);
- display.asyncExec(runnable);
- }
+ getContainer().run(true, false, monitor -> {
+ resolvedOperation.resolveModal(monitor);
+ display.asyncExec(runnable);
});
} catch (Exception e) {
StatusManager.getManager().handle(new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, e.getMessage(), e));
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java
index 227fff909..d1934c698 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SelectableIUsPage.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
@@ -24,7 +24,8 @@ import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -67,10 +68,6 @@ public class SelectableIUsPage extends ResolutionStatusPage implements IResoluti
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
@Override
public void createControl(Composite parent) {
display = parent.getDisplay();
@@ -103,36 +100,28 @@ public class SelectableIUsPage extends ResolutionStatusPage implements IResoluti
tc.setWidth(columns[i].getWidthInPixels(table));
}
- tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- setDetailText(resolvedOperation);
- }
- });
-
- tableViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- // If the checkEvent is on a locked update element, uncheck it and select it.
- if (event.getElement() instanceof AvailableUpdateElement) {
- AvailableUpdateElement checkedElement = (AvailableUpdateElement) event.getElement();
- if (checkedElement.isLockedForUpdate()) {
- event.getCheckable().setChecked(checkedElement, false);
- // Select the element so that the locked description is displayed
- CheckboxTableViewer viewer = ((CheckboxTableViewer) event.getSource());
- int itemCount = viewer.getTable().getItemCount();
- for (int i = 0; i < itemCount; i++) {
- if (viewer.getElementAt(i).equals(checkedElement)) {
- viewer.getTable().deselectAll();
- viewer.getTable().select(i);
- setDetailText(resolvedOperation);
- break;
- }
+ tableViewer.addSelectionChangedListener(event -> setDetailText(resolvedOperation));
+
+ tableViewer.addCheckStateListener(event -> {
+ // If the checkEvent is on a locked update element, uncheck it and select it.
+ if (event.getElement() instanceof AvailableUpdateElement) {
+ AvailableUpdateElement checkedElement = (AvailableUpdateElement) event.getElement();
+ if (checkedElement.isLockedForUpdate()) {
+ event.getCheckable().setChecked(checkedElement, false);
+ // Select the element so that the locked description is displayed
+ CheckboxTableViewer viewer = ((CheckboxTableViewer) event.getSource());
+ int itemCount = viewer.getTable().getItemCount();
+ for (int i = 0; i < itemCount; i++) {
+ if (viewer.getElementAt(i).equals(checkedElement)) {
+ viewer.getTable().deselectAll();
+ viewer.getTable().select(i);
+ setDetailText(resolvedOperation);
+ break;
}
}
}
- updateSelection();
}
+ updateSelection();
});
// Filters and sorters before establishing content, so we don't refresh unnecessarily.
@@ -185,23 +174,17 @@ public class SelectableIUsPage extends ResolutionStatusPage implements IResoluti
Button selectAll = new Button(buttonParent, SWT.PUSH);
selectAll.setText(ProvUIMessages.SelectableIUsPage_Select_All);
setButtonLayoutData(selectAll);
- selectAll.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- tableViewer.setAllChecked(true);
- updateSelection();
- }
+ selectAll.addListener(SWT.Selection, event -> {
+ tableViewer.setAllChecked(true);
+ updateSelection();
});
Button deselectAll = new Button(buttonParent, SWT.PUSH);
deselectAll.setText(ProvUIMessages.SelectableIUsPage_Deselect_All);
setButtonLayoutData(deselectAll);
- deselectAll.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- tableViewer.setAllChecked(false);
- updateSelection();
- }
+ deselectAll.addListener(SWT.Selection, event -> {
+ tableViewer.setAllChecked(false);
+ updateSelection();
});
// dummy to take extra space
@@ -323,10 +306,6 @@ public class SelectableIUsPage extends ResolutionStatusPage implements IResoluti
return tableViewer != null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.equinox.internal.p2.ui.dialogs.ResolutionStatusPage#updateCaches(org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot, org.eclipse.equinox.p2.operations.ProfileChangeOperation)
- */
@Override
protected void updateCaches(IUElementListRoot newRoot, ProfileChangeOperation op) {
resolvedOperation = op;
@@ -338,9 +317,6 @@ public class SelectableIUsPage extends ResolutionStatusPage implements IResoluti
}
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.p2.ui.dialogs.ISelectableIUsPage#setCheckedElements(java.lang.Object[])
- */
@Override
public void setCheckedElements(Object[] elements) {
if (tableViewer == null)
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java
index 62ef390ea..5066f9003 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.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
@@ -65,12 +65,7 @@ public abstract class SizeComputingWizardPage extends ResolutionResultsWizardPag
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
if (display != null) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- updateSizingInfo();
- }
- });
+ display.asyncExec(() -> updateSizingInfo());
}
return Status.OK_STATUS;
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
index 1e6223a5b..cf0c41dc6 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.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
@@ -168,13 +168,9 @@ public class IUDetailsLabelProvider extends ColumnLabelProvider implements ITabl
if (shell == null || shell.isDisposed())
return Status.CANCEL_STATUS;
- shell.getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- if (shell != null && !shell.isDisposed())
- fireLabelProviderChanged(new LabelProviderChangedEvent(IUDetailsLabelProvider.this, element));
- }
+ shell.getDisplay().asyncExec(() -> {
+ if (shell != null && !shell.isDisposed())
+ fireLabelProviderChanged(new LabelProviderChangedEvent(IUDetailsLabelProvider.this, element));
});
return Status.OK_STATUS;
@@ -229,9 +225,6 @@ public class IUDetailsLabelProvider extends ColumnLabelProvider implements ITabl
return iu.getProperty(toolTipProperty, null);
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
- */
@Override
public Font getFont(Object element) {
if (filteredTree != null && useBoldFont) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/ProvElementContentProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/ProvElementContentProvider.java
index d26850ffb..ed0511cdb 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/ProvElementContentProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/ProvElementContentProvider.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
@@ -41,10 +41,6 @@ public class ProvElementContentProvider implements ITreeContentProvider {
// Default constructor
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
@Override
public Object[] getElements(final Object input) {
// Simple deferred fetch handling for table viewers
@@ -80,18 +76,15 @@ public class ProvElementContentProvider implements ITreeContentProvider {
}, monitor);
if (!monitor.isCanceled()) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- AbstractTableViewer tableViewer = (AbstractTableViewer) viewer;
- if (monitor.isCanceled() || tableViewer == null || tableViewer.getControl().isDisposed())
- return;
- tableViewer.getControl().setRedraw(false);
- tableViewer.remove(pending);
- tableViewer.add(children.toArray());
- finishedFetchingElements(input);
- tableViewer.getControl().setRedraw(true);
- }
+ display.asyncExec(() -> {
+ AbstractTableViewer tableViewer = (AbstractTableViewer) viewer;
+ if (monitor.isCanceled() || tableViewer == null || tableViewer.getControl().isDisposed())
+ return;
+ tableViewer.getControl().setRedraw(false);
+ tableViewer.remove(pending);
+ tableViewer.add(children.toArray());
+ finishedFetchingElements(input);
+ tableViewer.getControl().setRedraw(true);
});
}
return Status.OK_STATUS;
@@ -111,10 +104,6 @@ public class ProvElementContentProvider implements ITreeContentProvider {
return elements;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
@Override
public Object getParent(Object child) {
if (child instanceof ProvElement) {
@@ -123,10 +112,6 @@ public class ProvElementContentProvider implements ITreeContentProvider {
return null;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
@Override
public boolean hasChildren(Object element) {
if (element instanceof ProvElement)
@@ -134,10 +119,6 @@ public class ProvElementContentProvider implements ITreeContentProvider {
return false;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
@Override
public Object[] getChildren(final Object parent) {
if (parent instanceof ProvElement) {
@@ -146,9 +127,6 @@ public class ProvElementContentProvider implements ITreeContentProvider {
return new Object[0];
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
@Override
public void dispose() {
viewer = null;
@@ -158,9 +136,6 @@ public class ProvElementContentProvider implements ITreeContentProvider {
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
@Override
public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) {
this.viewer = aViewer;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java
index 64b208144..98dbf4440 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/StructuredViewerProvisioningListener.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
@@ -97,16 +97,13 @@ public class StructuredViewerProvisioningListener extends ProvUIProvisioningList
*/
@Override
protected void profileChanged(final String profileId) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (isClosing())
- return;
- // We want to refresh the affected profile, so we
- // construct a profile element on this profile.
- ProfileElement element = new ProfileElement(null, profileId);
- viewer.refresh(element);
- }
+ display.asyncExec(() -> {
+ if (isClosing())
+ return;
+ // We want to refresh the affected profile, so we
+ // construct a profile element on this profile.
+ ProfileElement element = new ProfileElement(null, profileId);
+ viewer.refresh(element);
});
}
@@ -140,13 +137,10 @@ public class StructuredViewerProvisioningListener extends ProvUIProvisioningList
return;
}
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (isClosing())
- return;
- refreshViewer();
- }
+ display.asyncExec(() -> {
+ if (isClosing())
+ return;
+ refreshViewer();
});
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
index a3375d40a..48c3bba1e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.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
@@ -30,8 +30,7 @@ import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
-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;
@@ -178,10 +177,6 @@ public class AcceptLicensesWizardPage extends WizardPage {
update(ius, operation);
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
@@ -222,13 +217,7 @@ public class AcceptLicensesWizardPage extends WizardPage {
iuViewer.setComparator(new ViewerComparator());
iuViewer.setInput(licensesToIUs);
- iuViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChanged((IStructuredSelection) event.getSelection());
- }
-
- });
+ iuViewer.addSelectionChangedListener(event -> handleSelectionChanged((IStructuredSelection) event.getSelection()));
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = convertWidthInCharsToPixels(ILayoutConstants.DEFAULT_PRIMARY_COLUMN_WIDTH);
gd.heightHint = convertHeightInCharsToPixels(ILayoutConstants.DEFAULT_TABLE_HEIGHT);
@@ -248,23 +237,13 @@ public class AcceptLicensesWizardPage extends WizardPage {
else
acceptButton.setText(ProvUIMessages.AcceptLicensesWizardPage_AcceptSingle);
- acceptButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setPageComplete(acceptButton.getSelection());
- }
- });
+ acceptButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setPageComplete(acceptButton.getSelection())));
declineButton = new Button(buttonContainer, SWT.RADIO);
if (multiple)
declineButton.setText(ProvUIMessages.AcceptLicensesWizardPage_RejectMultiple);
else
declineButton.setText(ProvUIMessages.AcceptLicensesWizardPage_RejectSingle);
- declineButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setPageComplete(!declineButton.getSelection());
- }
- });
+ declineButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> setPageComplete(!declineButton.getSelection())));
acceptButton.setSelection(false);
declineButton.setSelection(true);
@@ -500,10 +479,6 @@ public class AcceptLicensesWizardPage extends WizardPage {
return new int[] {55, 45};
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
index 0010542f8..a23ffc52c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.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
@@ -177,13 +177,9 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable
// We rely on the actions getting selection events before we do, because
// we rely on the enablement state of the action. So we don't hook
// the selection listener on our table until after actions are created.
- installedIUGroup.getStructuredViewer().addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- updateDetailsArea();
- updateEnablement();
- }
-
+ installedIUGroup.getStructuredViewer().addSelectionChangedListener(event -> {
+ updateDetailsArea();
+ updateEnablement();
});
final IUPatternFilter searchFilter = new IUPatternFilter(getColumnConfig());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
index 4cc1686b1..38532af82 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 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
@@ -28,14 +28,12 @@ import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.jface.dialogs.*;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.*;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.PreferencePage;
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.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.accessibility.AccessibleListener;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
@@ -214,49 +212,30 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
// Filter box
pattern = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.CANCEL);
- pattern.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- @Override
- public void getName(AccessibleEvent e) {
- e.result = DEFAULT_FILTER_TEXT;
- }
- });
+ pattern.getAccessible().addAccessibleListener(AccessibleListener.getNameAdapter(e -> e.result = DEFAULT_FILTER_TEXT));
pattern.setText(DEFAULT_FILTER_TEXT);
pattern.selectAll();
- pattern.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- applyFilter();
- }
- });
-
- pattern.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.ARROW_DOWN) {
- if (table.getItemCount() > 0) {
- table.setFocus();
- } else if (e.character == SWT.CR) {
- return;
- }
+ pattern.addModifyListener(e -> applyFilter());
+
+ pattern.addKeyListener(KeyListener.keyPressedAdapter(e -> {
+ if (e.keyCode == SWT.ARROW_DOWN) {
+ if (table.getItemCount() > 0) {
+ table.setFocus();
+ } else if (e.character == SWT.CR) {
+ return;
}
}
- });
+ }));
- pattern.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!pattern.isDisposed()) {
- if (DEFAULT_FILTER_TEXT.equals(pattern.getText().trim())) {
- pattern.selectAll();
- }
- }
+ pattern.addFocusListener(FocusListener.focusGainedAdapter(e -> {
+ display.asyncExec(() -> {
+ if (!pattern.isDisposed()) {
+ if (DEFAULT_FILTER_TEXT.equals(pattern.getText().trim())) {
+ pattern.selectAll();
}
- });
- }
- });
+ }
+ });
+ }));
// spacer to fill other column
if (policy.getRepositoriesVisible())
@@ -267,14 +246,11 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
repositoryViewer = new CheckboxTableViewer(table);
// Key listener for delete
- table.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.keyCode == SWT.DEL) {
- removeRepositories();
- }
+ table.addKeyListener(KeyListener.keyPressedAdapter(e -> {
+ if (e.keyCode == SWT.DEL) {
+ removeRepositories();
}
- });
+ }));
setTableColumns();
CopyUtils.activateCopy(this, table);
@@ -327,13 +303,10 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
repositoryViewer.setColumnProperties(new String[] {"nickname"}); //$NON-NLS-1$
repositoryViewer.setCellEditors(new CellEditor[] {new TextCellEditor(repositoryViewer.getTable())});
- repositoryViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- if (policy.getRepositoriesVisible())
- validateButtons();
- setDetails();
- }
+ repositoryViewer.addSelectionChangedListener(event -> {
+ if (policy.getRepositoriesVisible())
+ validateButtons();
+ setDetails();
});
repositoryViewer.setCheckStateProvider(new ICheckStateProvider() {
@@ -348,17 +321,14 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
}
});
- repositoryViewer.addCheckStateListener(new ICheckStateListener() {
- @Override
- public void checkStateChanged(CheckStateChangedEvent event) {
- MetadataRepositoryElement element = (MetadataRepositoryElement) event.getElement();
- element.setEnabled(event.getChecked());
- // paranoid that an equal but not identical element was passed in as the selection.
- // update the cache map just in case.
- getInput().put(element);
- // update the viewer to show the change
- updateForEnablementChange(new MetadataRepositoryElement[] {element});
- }
+ repositoryViewer.addCheckStateListener(event -> {
+ MetadataRepositoryElement element = (MetadataRepositoryElement) event.getElement();
+ element.setEnabled(event.getChecked());
+ // paranoid that an equal but not identical element was passed in as the selection.
+ // update the cache map just in case.
+ getInput().put(element);
+ // update the viewer to show the change
+ updateForEnablementChange(new MetadataRepositoryElement[] {element});
});
// Input last
@@ -376,12 +346,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
listener = getViewerProvisioningListener();
ProvUI.getProvisioningEventBus(ui.getSession()).addListener(listener);
- composite.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent event) {
- ProvUI.getProvisioningEventBus(ui.getSession()).removeListener(listener);
- }
- });
+ composite.addDisposeListener(event -> ProvUI.getProvisioningEventBus(ui.getSession()).removeListener(listener));
validateButtons();
}
@@ -394,11 +359,7 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
details.setLayoutData(data);
- GridLayoutFactory.fillDefaults()
- .numColumns(policy.getRepositoriesVisible() ? 2 : 1)
- .margins(LayoutConstants.getMargins())
- .spacing(LayoutConstants.getSpacing())
- .generateLayout(composite);
+ GridLayoutFactory.fillDefaults().numColumns(policy.getRepositoriesVisible() ? 2 : 1).margins(LayoutConstants.getMargins()).spacing(LayoutConstants.getSpacing()).generateLayout(composite);
Dialog.applyDialogFont(composite);
return composite;
@@ -490,60 +451,25 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
private void createVerticalButtons(Composite parent) {
addButton = createVerticalButton(parent, ProvUIMessages.RepositoryManipulationPage_Add, false);
- addButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- addRepository();
- }
- });
+ addButton.addListener(SWT.Selection, event -> addRepository());
editButton = createVerticalButton(parent, ProvUIMessages.RepositoryManipulationPage_Edit, false);
- editButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- changeRepositoryProperties();
- }
- });
+ editButton.addListener(SWT.Selection, event -> changeRepositoryProperties());
removeButton = createVerticalButton(parent, ProvUIMessages.RepositoryManipulationPage_Remove, false);
- removeButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- removeRepositories();
- }
- });
+ removeButton.addListener(SWT.Selection, event -> removeRepositories());
refreshButton = createVerticalButton(parent, ProvUIMessages.RepositoryManipulationPage_RefreshConnection, false);
- refreshButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- refreshRepository();
- }
- });
+ refreshButton.addListener(SWT.Selection, event -> refreshRepository());
disableButton = createVerticalButton(parent, ProvUIMessages.RepositoryManipulationPage_DisableButton, false);
- disableButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- toggleRepositoryEnablement();
- }
- });
+ disableButton.addListener(SWT.Selection, event -> toggleRepositoryEnablement());
Button button = createVerticalButton(parent, ProvUIMessages.RepositoryManipulationPage_Import, false);
- button.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- importRepositories();
- }
- });
+ button.addListener(SWT.Selection, event -> importRepositories());
exportButton = createVerticalButton(parent, ProvUIMessages.RepositoryManipulationPage_Export, false);
- exportButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- exportRepositories();
- }
- });
+ exportButton.addListener(SWT.Selection, event -> exportRepositories());
}
CachedMetadataRepositories getInput() {
@@ -552,10 +478,6 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
return input;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performOk()
- */
@Override
public boolean performOk() {
if (changed)
@@ -632,57 +554,54 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
final URI location = selected[0].getLocation();
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
try {
- dialog.run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) {
- monitor.beginTask(NLS.bind(ProvUIMessages.RepositoryManipulationPage_ContactingSiteMessage, location), 100);
+ dialog.run(true, true, monitor -> {
+ monitor.beginTask(NLS.bind(ProvUIMessages.RepositoryManipulationPage_ContactingSiteMessage, location), 100);
+ try {
+ // Batch the events for this operation so that any events on reload (discovery, etc.) will be ignored
+ // in the UI as they happen.
+ ui.signalRepositoryOperationStart();
+ tracker.clearRepositoryNotFound(location);
+ // If the managers don't know this repo, refreshing it will not work.
+ // We temporarily add it, but we must remove it in case the user cancels out of this page.
+ if (!includesRepo(tracker.getKnownRepositories(ui.getSession()), location)) {
+ remove[0] = true;
+ // We don't want to use the tracker here because it ensures that additions are
+ // reported as user events to be responded to. We don't want, for example, the
+ // install wizard to change combo selections based on what is done here.
+ ProvUI.getMetadataRepositoryManager(ui.getSession()).addRepository(location);
+ ProvUI.getArtifactRepositoryManager(ui.getSession()).addRepository(location);
+ }
+ // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=312332
+ // We assume repository colocation here. Ideally we should not do this, but the
+ // RepositoryTracker API is swallowing the refresh errors.
+ SubMonitor sub = SubMonitor.convert(monitor, 200);
try {
- // Batch the events for this operation so that any events on reload (discovery, etc.) will be ignored
- // in the UI as they happen.
- ui.signalRepositoryOperationStart();
- tracker.clearRepositoryNotFound(location);
- // If the managers don't know this repo, refreshing it will not work.
- // We temporarily add it, but we must remove it in case the user cancels out of this page.
- if (!includesRepo(tracker.getKnownRepositories(ui.getSession()), location)) {
- remove[0] = true;
- // We don't want to use the tracker here because it ensures that additions are
- // reported as user events to be responded to. We don't want, for example, the
- // install wizard to change combo selections based on what is done here.
- ProvUI.getMetadataRepositoryManager(ui.getSession()).addRepository(location);
- ProvUI.getArtifactRepositoryManager(ui.getSession()).addRepository(location);
- }
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=312332
- // We assume repository colocation here. Ideally we should not do this, but the
- // RepositoryTracker API is swallowing the refresh errors.
- SubMonitor sub = SubMonitor.convert(monitor, 200);
- try {
- ProvUI.getMetadataRepositoryManager(ui.getSession()).refreshRepository(location, sub.newChild(100));
- } catch (ProvisionException e) {
- fail[0] = e;
- }
- try {
- ProvUI.getArtifactRepositoryManager(ui.getSession()).refreshRepository(location, sub.newChild(100));
- } catch (ProvisionException e) {
- // Failure in the artifact repository. We will not report this because the user has no separate visibility
- // of the artifact repository. We should log the error. If this repository fails during a download, the error
- // will be reported at that time to the user, when it matters. This also prevents false error reporting when
- // a metadata repository didn't actually have a colocated artifact repository.
- LogHelper.log(e);
- }
- } catch (OperationCanceledException e) {
- // Catch canceled login attempts
- fail[0] = new ProvisionException(new Status(IStatus.CANCEL, ProvUIActivator.PLUGIN_ID, ProvUIMessages.RepositoryManipulationPage_RefreshOperationCanceled, e));
- } finally {
- // Check if the monitor was canceled
- if (fail[0] == null && monitor.isCanceled())
- fail[0] = new ProvisionException(new Status(IStatus.CANCEL, ProvUIActivator.PLUGIN_ID, ProvUIMessages.RepositoryManipulationPage_RefreshOperationCanceled));
- // If we temporarily added a repo so we could read it, remove it.
- if (remove[0]) {
- ProvUI.getMetadataRepositoryManager(ui.getSession()).removeRepository(location);
- ProvUI.getArtifactRepositoryManager(ui.getSession()).removeRepository(location);
- }
- ui.signalRepositoryOperationComplete(null, false);
+ ProvUI.getMetadataRepositoryManager(ui.getSession()).refreshRepository(location, sub.newChild(100));
+ } catch (ProvisionException e1) {
+ fail[0] = e1;
+ }
+ try {
+ ProvUI.getArtifactRepositoryManager(ui.getSession()).refreshRepository(location, sub.newChild(100));
+ } catch (ProvisionException e2) {
+ // Failure in the artifact repository. We will not report this because the user has no separate visibility
+ // of the artifact repository. We should log the error. If this repository fails during a download, the error
+ // will be reported at that time to the user, when it matters. This also prevents false error reporting when
+ // a metadata repository didn't actually have a colocated artifact repository.
+ LogHelper.log(e2);
}
+ } catch (OperationCanceledException e3) {
+ // Catch canceled login attempts
+ fail[0] = new ProvisionException(new Status(IStatus.CANCEL, ProvUIActivator.PLUGIN_ID, ProvUIMessages.RepositoryManipulationPage_RefreshOperationCanceled, e3));
+ } finally {
+ // Check if the monitor was canceled
+ if (fail[0] == null && monitor.isCanceled())
+ fail[0] = new ProvisionException(new Status(IStatus.CANCEL, ProvUIActivator.PLUGIN_ID, ProvUIMessages.RepositoryManipulationPage_RefreshOperationCanceled));
+ // If we temporarily added a repo so we could read it, remove it.
+ if (remove[0]) {
+ ProvUI.getMetadataRepositoryManager(ui.getSession()).removeRepository(location);
+ ProvUI.getArtifactRepositoryManager(ui.getSession()).removeRepository(location);
+ }
+ ui.signalRepositoryOperationComplete(null, false);
}
});
} catch (InvocationTargetException e) {
@@ -739,29 +658,23 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
}
void importRepositories() {
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- @Override
- public void run() {
- MetadataRepositoryElement[] imported = UpdateManagerCompatibility.importSites(getShell());
- if (imported.length > 0) {
- changed = true;
- for (int i = 0; i < imported.length; i++)
- getInput().put(imported[i]);
- safeRefresh(null);
- }
+ BusyIndicator.showWhile(getShell().getDisplay(), () -> {
+ MetadataRepositoryElement[] imported = UpdateManagerCompatibility.importSites(getShell());
+ if (imported.length > 0) {
+ changed = true;
+ for (int i = 0; i < imported.length; i++)
+ getInput().put(imported[i]);
+ safeRefresh(null);
}
});
}
void exportRepositories() {
- BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {
- @Override
- public void run() {
- MetadataRepositoryElement[] elements = getSelectedElements();
- if (elements.length == 0)
- elements = getElements();
- UpdateManagerCompatibility.exportSites(getShell(), elements);
- }
+ BusyIndicator.showWhile(getShell().getDisplay(), () -> {
+ MetadataRepositoryElement[] elements = getSelectedElements();
+ if (elements.length == 0)
+ elements = getElements();
+ UpdateManagerCompatibility.exportSites(getShell(), elements);
});
}
@@ -846,13 +759,10 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
}
void safeRefresh(final MetadataRepositoryElement elementToSelect) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- repositoryViewer.refresh();
- if (elementToSelect != null)
- repositoryViewer.setSelection(new StructuredSelection(elementToSelect), true);
- }
+ Runnable runnable = () -> {
+ repositoryViewer.refresh();
+ if (elementToSelect != null)
+ repositoryViewer.setSelection(new StructuredSelection(elementToSelect), true);
};
if (Display.getCurrent() == null)
display.asyncExec(runnable);
@@ -894,9 +804,6 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
}
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
@Override
public void init(IWorkbench workbench) {
noDefaultAndApplyButton();
@@ -977,10 +884,6 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb
return localCacheRepoManipulator;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.equinox.p2.ui.ICopyable#copyToClipboard(org.eclipse.swt.widgets.Control)
- */
@Override
public void copyToClipboard(Control activeControl) {
MetadataRepositoryElement[] elements = getSelectedElements();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
index d204af443..ef058c3ab 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.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
@@ -13,7 +13,8 @@ package org.eclipse.equinox.p2.ui;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.Iterator;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.*;
import org.eclipse.equinox.internal.p2.ui.dialogs.CopyUtils;
import org.eclipse.equinox.internal.p2.ui.dialogs.InstalledIUGroup;
@@ -118,10 +119,6 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
}
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.about.InstallationPage#createPageButtons(org.eclipse.swt.widgets.Composite)
- */
@Override
public void createPageButtons(Composite parent) {
if (profileId == null)
@@ -134,10 +131,6 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
revertButton.setEnabled(revertAction.isEnabled());
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
@Override
public void createControl(Composite parent) {
profileId = getProvisioningUI().getProfileId();
@@ -214,13 +207,7 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
});
configsViewer.setInput(getInput());
- configsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChanged((IStructuredSelection) event.getSelection());
- }
-
- });
+ configsViewer.addSelectionChangedListener(event -> handleSelectionChanged((IStructuredSelection) event.getSelection()));
CopyUtils.activateCopy(this, configsViewer.getControl());
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
configsViewer.getControl().setLayoutData(gd);
@@ -382,15 +369,12 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
if (snapshot == null)
return false;
final IProvisioningPlan[] plan = new IProvisioningPlan[1];
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) {
- IProfile currentProfile;
- IProfileRegistry registry = ProvUI.getProfileRegistry(getSession());
- IPlanner planner = (IPlanner) getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
- currentProfile = registry.getProfile(profileId);
- plan[0] = planner.getDiffPlan(currentProfile, snapshot, monitor);
- }
+ IRunnableWithProgress runnable = monitor -> {
+ IProfile currentProfile;
+ IProfileRegistry registry = ProvUI.getProfileRegistry(getSession());
+ IPlanner planner = (IPlanner) getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
+ currentProfile = registry.getProfile(profileId);
+ plan[0] = planner.getDiffPlan(currentProfile, snapshot, monitor);
};
ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
try {
@@ -424,10 +408,6 @@ public class RevertProfilePage extends InstallationPage implements ICopyable {
return reverted;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.equinox.p2.ui.ICopyable#copyToClipboard(org.eclipse.swt.widgets.Control)
- */
@Override
public void copyToClipboard(Control activeControl) {
String text = ""; //$NON-NLS-1$

Back to the top