DownloadUrlLink: Kill KnownScheme enum
After the previous cleanups, this was a glorified map of scheme name
("anonymous http") to display name ("anonymous HTTP"), which required
a hand-written enum as well as a set of UI messages. It was only used
in the project info screen, not even from the much more commonly used
scheme dropdown on the change screen.
Change-Id: I1608971b50c75cb6957e01d558d54e48e22616dc
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadMessages.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadMessages.java
deleted file mode 100644
index a0313ad..0000000
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadMessages.java
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (C) 2008 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.client.download;
-
-import com.google.gwt.i18n.client.Messages;
-
-public interface DownloadMessages extends Messages {
- String anonymousDownload(String protocol);
-}
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadMessages.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadMessages.properties
deleted file mode 100644
index 3e34da2..0000000
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadMessages.properties
+++ /dev/null
@@ -1 +0,0 @@
-anonymousDownload = Anonymous {0}
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlLink.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlLink.java
index a2dbffb..2a3ca5e 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlLink.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlLink.java
@@ -18,7 +18,6 @@
import com.google.gerrit.client.account.AccountApi;
import com.google.gerrit.client.info.AccountPreferencesInfo;
import com.google.gerrit.client.info.DownloadInfo.DownloadSchemeInfo;
-import com.google.gerrit.reviewdb.client.CoreDownloadSchemes;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -31,30 +30,6 @@
import java.util.List;
public class DownloadUrlLink extends Anchor implements ClickHandler {
- private enum KnownScheme {
- ANON_GIT(CoreDownloadSchemes.ANON_GIT, Util.M.anonymousDownload("Git")),
- ANON_HTTP(CoreDownloadSchemes.ANON_HTTP, Util.M.anonymousDownload("HTTP")),
- SSH(CoreDownloadSchemes.SSH, "SSH"),
- HTTP(CoreDownloadSchemes.HTTP, "HTTP");
-
- public final String name;
- public final String text;
-
- private KnownScheme(String name, String text) {
- this.name = name;
- this.text = text;
- }
-
- static KnownScheme get(String name) {
- for (KnownScheme s : values()) {
- if (s.name.equals(name)) {
- return s;
- }
- }
- return null;
- }
- }
-
public static List<DownloadUrlLink> createDownloadUrlLinks(
boolean allowAnonymous, DownloadPanel downloadPanel) {
List<DownloadUrlLink> urls = new ArrayList<>();
@@ -63,36 +38,29 @@
if (scheme.isAuthRequired() && !allowAnonymous) {
continue;
}
-
- KnownScheme knownScheme = KnownScheme.get(s);
- if (knownScheme != null) {
- urls.add(new DownloadUrlLink(downloadPanel, scheme,
- knownScheme.name, knownScheme.text));
- } else {
- urls.add(new DownloadUrlLink(downloadPanel, scheme, s, s));
- }
+ urls.add(new DownloadUrlLink(downloadPanel, scheme, s));
}
return urls;
}
private final DownloadPanel downloadPanel;
private final DownloadSchemeInfo schemeInfo;
- private final String scheme;
+ private final String schemeName;
public DownloadUrlLink(DownloadPanel downloadPanel,
- DownloadSchemeInfo schemeInfo, String urlType, String text) {
- super(text);
+ DownloadSchemeInfo schemeInfo, String schemeName) {
+ super(schemeName);
setStyleName(Gerrit.RESOURCES.css().downloadLink());
Roles.getTabRole().set(getElement());
addClickHandler(this);
this.downloadPanel = downloadPanel;
this.schemeInfo = schemeInfo;
- this.scheme = urlType;
+ this.schemeName = schemeName;
}
- public String getUrlType() {
- return scheme;
+ public String getSchemeName() {
+ return schemeName;
}
@Override
@@ -103,10 +71,10 @@
select();
AccountPreferencesInfo prefs = Gerrit.getUserPreferences();
- if (Gerrit.isSignedIn() && !scheme.equals(prefs.downloadScheme())) {
- prefs.downloadScheme(scheme);
+ if (Gerrit.isSignedIn() && !schemeName.equals(prefs.downloadScheme())) {
+ prefs.downloadScheme(schemeName);
AccountPreferencesInfo in = AccountPreferencesInfo.create();
- in.downloadScheme(scheme);
+ in.downloadScheme(schemeName);
AccountApi.self().view("preferences")
.put(in, new AsyncCallback<JavaScriptObject>() {
@Override
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlPanel.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlPanel.java
index 5e941b6..541c6f3 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlPanel.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/DownloadUrlPanel.java
@@ -32,7 +32,7 @@
return getWidgetCount() == 0;
}
- public void select(String urlType) {
+ public void select(String schemeName) {
DownloadUrlLink first = null;
for (Widget w : this) {
@@ -41,7 +41,7 @@
if (first == null) {
first = d;
}
- if (d.getUrlType().equals(urlType)) {
+ if (d.getSchemeName().equals(schemeName)) {
d.select();
return;
}
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/Util.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/Util.java
deleted file mode 100644
index 510361b..0000000
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/download/Util.java
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (C) 2008 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.google.gerrit.client.download;
-
-import com.google.gwt.core.client.GWT;
-
-public class Util {
- public static final DownloadMessages M = GWT.create(DownloadMessages.class);
-}