Refactor UiAction specific code out of change specific code

To support UiActions on more screens, i. e. Project Info Screen, refactor the
code from the change specific code to its own actions package.

Change-Id: I628c4c99c1a1e1ccaba0a11f27ed5acdabc6e37c
This commit is contained in:
David Ostrovsky
2013-08-30 07:51:12 +02:00
parent 3fc62772f4
commit 513659c490
12 changed files with 76 additions and 39 deletions

View File

@@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.change;
package com.google.gerrit.client.actions;
import com.google.gerrit.client.api.ActionContext;
import com.google.gerrit.client.api.ChangeGlue;
import com.google.gerrit.client.api.RevisionGlue;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@@ -31,11 +30,11 @@ public class ActionButton extends Button implements ClickHandler {
private final ActionInfo action;
private ActionContext ctx;
ActionButton(ChangeInfo change, ActionInfo action) {
public ActionButton(ChangeInfo change, ActionInfo action) {
this(change, null, action);
}
ActionButton(ChangeInfo change, RevisionInfo revision, ActionInfo action) {
public ActionButton(ChangeInfo change, RevisionInfo revision, ActionInfo action) {
super(new SafeHtmlBuilder()
.openDiv()
.append(action.label())

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2013 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.actions;
import com.google.gwt.core.client.JavaScriptObject;
public class ActionInfo extends JavaScriptObject {
public final native String id() /*-{ return this.id; }-*/;
public final native String method() /*-{ return this.method; }-*/;
public final native String label() /*-{ return this.label; }-*/;
public final native String title() /*-{ return this.title; }-*/;
public final native boolean enabled() /*-{ return this.enabled || false; }-*/;
protected ActionInfo() {
}
}

View File

@@ -14,9 +14,9 @@
package com.google.gerrit.client.api;
import com.google.gerrit.client.change.ActionButton;
import com.google.gerrit.client.actions.ActionButton;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.NativeString;

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.client.api;
import com.google.gerrit.client.change.ActionButton;
import com.google.gerrit.client.actions.ActionButton;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.ActionInfo;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gwt.core.client.JavaScriptObject;

View File

@@ -15,8 +15,8 @@
package com.google.gerrit.client.api;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.ActionInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.NativeString;
import com.google.gerrit.client.rpc.RestApi;

View File

@@ -14,7 +14,7 @@
package com.google.gerrit.client.api;
import com.google.gerrit.client.change.ActionButton;
import com.google.gerrit.client.actions.ActionButton;
import com.google.gerrit.client.change.Resources;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.CloseEvent;

View File

@@ -14,10 +14,10 @@
package com.google.gerrit.client.api;
import com.google.gerrit.client.change.ActionButton;
import com.google.gerrit.client.actions.ActionButton;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gwt.core.client.JavaScriptObject;

View File

@@ -15,8 +15,9 @@
package com.google.gerrit.client.change;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.actions.ActionButton;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.rpc.NativeMap;

View File

@@ -17,9 +17,9 @@ package com.google.gerrit.client.change;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.ActionInfo;
import com.google.gerrit.client.changes.ChangeInfo.ApprovalInfo;
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
import com.google.gerrit.client.changes.ChangeInfo.LabelInfo;

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.client.changes;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gerrit.client.actions.ActionInfo;
import com.google.gerrit.client.diff.FileInfo;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.NativeString;
@@ -260,17 +261,6 @@ public class ChangeInfo extends JavaScriptObject {
}
}
public static class ActionInfo extends JavaScriptObject {
public final native String id() /*-{ return this.id; }-*/;
public final native String method() /*-{ return this.method; }-*/;
public final native String label() /*-{ return this.label; }-*/;
public final native String title() /*-{ return this.title; }-*/;
public final native boolean enabled() /*-{ return this.enabled || false; }-*/;
protected ActionInfo() {
}
}
public static class MessageInfo extends JavaScriptObject {
public final native AccountInfo author() /*-{ return this.author; }-*/;
public final native String message() /*-{ return this.message; }-*/;

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2013 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.server.actions;
import com.google.gerrit.extensions.webui.UiAction;
public class ActionInfo {
String method;
String label;
String title;
Boolean enabled;
public ActionInfo(UiAction.Description d) {
method = d.getMethod();
label = d.getLabel();
title = d.getTitle();
enabled = d.isEnabled() ? true : null;
}
}

View File

@@ -64,6 +64,7 @@ import com.google.gerrit.server.AnonymousUser;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountInfo;
import com.google.gerrit.server.actions.ActionInfo;
import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.extensions.webui.UiActions;
@@ -954,18 +955,4 @@ public class ChangeJson {
String message;
Integer _revisionNumber;
}
static class ActionInfo {
String method;
String label;
String title;
Boolean enabled;
ActionInfo(UiAction.Description d) {
method = d.getMethod();
label = d.getLabel();
title = d.getTitle();
enabled = d.isEnabled() ? true : null;
}
}
}