From ae6be546d7e9f29e68bc0b0a635615544a216dd5 Mon Sep 17 00:00:00 2001 From: Pierre-Yves B. Date: Sat, 22 Feb 2020 16:16:23 +0000 Subject: Bug 281164 - [ui] Install new software dialog 'Work with' 'type or select a site' should not be a selection Change-Id: Ia39dab46133219e7060e15ab520b8dec07678c06 Signed-off-by: Pierre-Yves B. --- .../org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF | 2 +- bundles/org.eclipse.equinox.p2.ui/pom.xml | 2 +- .../p2/ui/dialogs/RepositorySelectionGroup.java | 37 +++++++++++++++------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF index d272eb16b..f358cfa16 100644 --- a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.equinox.p2.ui;singleton:=true -Bundle-Version: 2.5.800.qualifier +Bundle-Version: 2.5.900.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.ui.ProvUIActivator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.ui/pom.xml b/bundles/org.eclipse.equinox.p2.ui/pom.xml index 41c992572..116bfab03 100644 --- a/bundles/org.eclipse.equinox.p2.ui/pom.xml +++ b/bundles/org.eclipse.equinox.p2.ui/pom.xml @@ -19,6 +19,6 @@ org.eclipse.equinox org.eclipse.equinox.p2.ui - 2.5.800-SNAPSHOT + 2.5.900-SNAPSHOT eclipse-plugin 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 d07be5d43..bd9047a9a 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, 2018 IBM Corporation and others. + * Copyright (c) 2009, 2020 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Yury Chernikov - Bug 271447 [ui] Bad layout in 'Install available software' dialog + * Pierre-Yves B. - Bug 281164 - [ui] Install new software dialog 'Work with' 'type or select a site' should not be a selection *******************************************************************************/ package org.eclipse.equinox.internal.p2.ui.dialogs; @@ -157,22 +158,36 @@ public class RepositorySelectionGroup { 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()); + if (!text.isEmpty()) { + 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()); + } } else { - status = tracker.validateRepositoryLocation(ui.getSession(), location, false, new NullProgressMonitor()); + // user typed or pasted an existing location. Select it. + repoComboSelectionChanged(); } - } else { - // user typed or pasted an existing location. Select it. - repoComboSelectionChanged(); } setRepoComboDecoration(status); }); + // Clear default text when user clicks in the combo box. + repoCombo.addMouseListener(MouseListener.mouseDownAdapter(e -> { + if (repoCombo.getText().equals(SITE_NONE)) + repoCombo.setText(""); //$NON-NLS-1$ + })); + + // Restore default text when focus is lost from the combo box. + repoCombo.addFocusListener(FocusListener.focusLostAdapter(e -> { + if (repoCombo.getText().isEmpty()) + fillRepoCombo(SITE_NONE); + })); + repoDec = new ControlDecoration(repoCombo, SWT.LEFT | SWT.TOP); repoDec.setMarginWidth(DEC_MARGIN_WIDTH); -- cgit v1.2.3