diff options
author | Pawel Pogorzelski | 2009-07-07 11:38:29 +0000 |
---|---|---|
committer | Pawel Pogorzelski | 2009-07-07 11:38:29 +0000 |
commit | 30d6618dcd1bc37e1b262b88d5080236eaf9c425 (patch) | |
tree | aacc55524ad5c76611ba00d51f12aa01b2c76807 /bundles/org.eclipse.ui.net | |
parent | c4d2616c210f941723e25f9deccba41aa983653d (diff) | |
download | eclipse.platform.team-30d6618dcd1bc37e1b262b88d5080236eaf9c425.tar.gz eclipse.platform.team-30d6618dcd1bc37e1b262b88d5080236eaf9c425.tar.xz eclipse.platform.team-30d6618dcd1bc37e1b262b88d5080236eaf9c425.zip |
Bug 281628 - [Net] Should be impossible to edit native proxy setting by double-clicking the entry
Diffstat (limited to 'bundles/org.eclipse.ui.net')
-rw-r--r-- | bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java | 29 | ||||
-rw-r--r-- | bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java | 40 |
2 files changed, 44 insertions, 25 deletions
diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java index 780bbddaa..23cac73a0 100644 --- a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java +++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NonProxyHostsComposite.java @@ -142,17 +142,7 @@ public class NonProxyHostsComposite extends Composite { protected void enableButtons() { boolean enabled = getEnabled(); if (enabled) { - IStructuredSelection selection = (IStructuredSelection) hostsViewer - .getSelection(); - Iterator iterator = selection.iterator(); - boolean editable = iterator.hasNext(); - while (iterator.hasNext()) { - String provider = ((ProxyBypassData) iterator.next()) - .getSource(); - if (!ProxySelector.canSetBypassHosts(provider)) { - editable = false; - } - } + boolean editable = isSelectionEditable(); addButton.setEnabled(true); editButton.setEnabled(editable); removeButton.setEnabled(editable); @@ -163,6 +153,20 @@ public class NonProxyHostsComposite extends Composite { } } + private boolean isSelectionEditable() { + IStructuredSelection selection = (IStructuredSelection) hostsViewer + .getSelection(); + Iterator iterator = selection.iterator(); + boolean editable = iterator.hasNext(); + while (iterator.hasNext()) { + String provider = ((ProxyBypassData) iterator.next()).getSource(); + if (!ProxySelector.canSetBypassHosts(provider)) { + editable = false; + } + } + return editable; + } + protected void addHost() { String hosts[] = promptForHost(null); if (hosts != null) { @@ -197,6 +201,9 @@ public class NonProxyHostsComposite extends Composite { } protected void editSelection() { + if (!isSelectionEditable()) { + return; + } IStructuredSelection selection = (IStructuredSelection) hostsViewer .getSelection(); String selectedHosts = getStringList(selection.iterator()); diff --git a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java index a6cfdcdcb..927850437 100644 --- a/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java +++ b/bundles/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyEntriesComposite.java @@ -134,19 +134,9 @@ public class ProxyEntriesComposite extends Composite { protected void enableButtons() { boolean enabled = getEnabled(); if (enabled) { - IStructuredSelection selection = (IStructuredSelection) entriesViewer - .getSelection(); - Iterator iterator = selection.iterator(); - boolean editable = iterator.hasNext(); - while (iterator.hasNext()) { - String provider = ((ProxyData) iterator.next()).getSource(); - if (!ProxySelector.canSetProxyData(provider)) { - editable = false; - } - } // addButton.setEnabled(true); - editButton.setEnabled(editable && selection.size() == 1); - removeButton.setEnabled(editable); + editButton.setEnabled(isSelectionEditable()); + removeButton.setEnabled(isSelectionRemovable()); } else { // addButton.setEnabled(false); editButton.setEnabled(false); @@ -154,6 +144,26 @@ public class ProxyEntriesComposite extends Composite { } } + private boolean isSelectionEditable() { + IStructuredSelection selection = (IStructuredSelection) entriesViewer + .getSelection(); + return isSelectionRemovable() && selection.size() == 1; + } + + private boolean isSelectionRemovable() { + IStructuredSelection selection = (IStructuredSelection) entriesViewer + .getSelection(); + Iterator iterator = selection.iterator(); + boolean editable = iterator.hasNext(); + while (iterator.hasNext()) { + String provider = ((ProxyData) iterator.next()).getSource(); + if (!ProxySelector.canSetProxyData(provider)) { + editable = false; + } + } + return editable; + } + protected void addEntry() { Iterator it = proxyEntries.iterator(); ArrayList added = new ArrayList(); @@ -196,8 +206,10 @@ public class ProxyEntriesComposite extends Composite { } protected void editSelection() { - Iterator itsel = ((IStructuredSelection) entriesViewer.getSelection()) - .iterator(); + if (!isSelectionRemovable()) { + return; + } + Iterator itsel = ((IStructuredSelection) entriesViewer.getSelection()).iterator(); ProxyData toEdit = null; if (itsel.hasNext()) { toEdit = ((ProxyData) itsel.next()); |