Reorganize some classes after CS1 was removed

Some of these were shared between CS1 and the unified screen or
CS2. Now that CS1 is gone the "changes" package is mostly about
listing one or more changes in dashboards or search results.

Move code to "patches" (for unified) or "change" (for CS2).

Change-Id: Ia87183e1e8d105ea3894bb426432b10153205a6f
This commit is contained in:
Shawn Pearce
2015-01-15 10:10:25 -08:00
parent da634143aa
commit a386fb3035
13 changed files with 52 additions and 62 deletions

View File

@@ -25,10 +25,8 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.PopupPanel;
class CherryPickAction {
static void call(final Button b, final ChangeInfo info, final String revision,
String project, final String commitMessage) {

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.client.change;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.SubmitFailureDialog;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.reviewdb.client.Change;

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.client.change;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.SubmitFailureDialog;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.reviewdb.client.Change;

View File

@@ -19,7 +19,6 @@ import com.google.gerrit.client.api.ChangeGlue;
import com.google.gerrit.client.changes.ChangeApi;
import com.google.gerrit.client.changes.ChangeInfo;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.changes.SubmitFailureDialog;
import com.google.gerrit.client.changes.SubmitInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.common.PageLinks;

View File

@@ -12,19 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.changes;
package com.google.gerrit.client.change;
import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.changes.Util;
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
import com.google.gwtjsonrpc.client.RemoteJsonException;
public class SubmitFailureDialog extends ErrorDialog {
public static boolean isConflict(Throwable err) {
class SubmitFailureDialog extends ErrorDialog {
static boolean isConflict(Throwable err) {
return err instanceof RemoteJsonException
&& 409 == ((RemoteJsonException) err).getCode();
}
public SubmitFailureDialog(String msg) {
SubmitFailureDialog(String msg) {
super(new SafeHtmlBuilder().append(msg.trim()).wikify());
setText(Util.C.submitFailed());
}

View File

@@ -19,7 +19,6 @@ import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gerrit.client.changes.CommentApi;
import com.google.gerrit.client.changes.CommentInfo;
import com.google.gerrit.client.changes.PatchTable;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.CommentLinkProcessor;
import com.google.gerrit.client.ui.CommentPanel;

View File

@@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.changes;
package com.google.gerrit.client.patches;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.StarredChanges;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.CommentLinkProcessor;
import com.google.gerrit.reviewdb.client.Change;
@@ -33,10 +35,8 @@ import com.google.gwtexpui.globalkey.client.KeyCommandSet;
import com.google.gwtexpui.safehtml.client.SafeHtml;
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
public class CommitMessageBlock extends Composite {
interface Binder extends UiBinder<HTMLPanel, CommitMessageBlock> {
}
class CommitMessageBlock extends Composite {
interface Binder extends UiBinder<HTMLPanel, CommitMessageBlock> {}
private static final Binder uiBinder = GWT.create(Binder.class);
private KeyCommandSet keysAction;
@@ -50,21 +50,21 @@ public class CommitMessageBlock extends Composite {
@UiField
PreElement commitBodyPre;
public CommitMessageBlock() {
CommitMessageBlock() {
initWidget(uiBinder.createAndBindUi(this));
}
public CommitMessageBlock(KeyCommandSet keysAction) {
CommitMessageBlock(KeyCommandSet keysAction) {
this.keysAction = keysAction;
initWidget(uiBinder.createAndBindUi(this));
}
public void display(String commitMessage,
void display(String commitMessage,
CommentLinkProcessor commentLinkProcessor) {
display(null, null, null, commitMessage, commentLinkProcessor);
}
public void display(final PatchSet.Id patchSetId, final String revision,
void display(final PatchSet.Id patchSetId, final String revision,
Boolean starred, final String commitMessage,
CommentLinkProcessor commentLinkProcessor) {
starPanel.clear();

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.client.patches;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.WebLinkInfo;
import com.google.gerrit.client.changes.PatchTable;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.InlineHyperlink;

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.client.patches;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.PatchTable;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.reviewdb.client.Patch;
import com.google.gwt.event.logical.shared.ResizeEvent;

View File

@@ -12,10 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.changes;
package com.google.gerrit.client.patches;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.ui.InlineHyperlink;
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
import com.google.gerrit.client.ui.NavigationTable;
@@ -51,8 +52,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class PatchTable extends Composite {
public interface PatchValidator {
class PatchTable extends Composite {
interface PatchValidator {
/**
* @param patch
* @return true if patch is valid.
@@ -60,7 +61,7 @@ public class PatchTable extends Composite {
boolean isValid(Patch patch);
}
public final PatchValidator PREFERENCE_VALIDATOR =
final PatchValidator PREFERENCE_VALIDATOR =
new PatchValidator() {
@Override
public boolean isValid(Patch patch) {
@@ -86,17 +87,17 @@ public class PatchTable extends Composite {
private boolean active;
private boolean registerKeys;
public PatchTable(ListenableAccountDiffPreference prefs) {
PatchTable(ListenableAccountDiffPreference prefs) {
listenablePrefs = prefs;
myBody = new FlowPanel();
initWidget(myBody);
}
public PatchTable() {
PatchTable() {
this(new ListenableAccountDiffPreference());
}
public int indexOf(Patch.Key patch) {
int indexOf(Patch.Key patch) {
Integer i = patchMap().get(patch);
return i != null ? i : -1;
}
@@ -111,7 +112,7 @@ public class PatchTable extends Composite {
return patchMap;
}
public void display(PatchSet.Id base, PatchSetDetail detail) {
void display(PatchSet.Id base, PatchSetDetail detail) {
this.base = base;
this.detail = detail;
this.patchList = detail.getPatches();
@@ -127,19 +128,19 @@ public class PatchTable extends Composite {
}
}
public PatchSet.Id getBase() {
PatchSet.Id getBase() {
return base;
}
public void setSavePointerId(final String id) {
void setSavePointerId(final String id) {
savePointerId = id;
}
public boolean isLoaded() {
boolean isLoaded() {
return myTable != null;
}
public void onTableLoaded(final Command cmd) {
void onTableLoaded(final Command cmd) {
if (myTable != null) {
cmd.execute();
} else {
@@ -147,7 +148,7 @@ public class PatchTable extends Composite {
}
}
public void addClickHandler(final ClickHandler clickHandler) {
void addClickHandler(final ClickHandler clickHandler) {
if (myTable != null) {
myTable.addClickHandler(clickHandler);
} else {
@@ -158,27 +159,27 @@ public class PatchTable extends Composite {
}
}
public void setRegisterKeys(final boolean on) {
void setRegisterKeys(final boolean on) {
registerKeys = on;
if (myTable != null) {
myTable.setRegisterKeys(on);
}
}
public void movePointerTo(final Patch.Key k) {
void movePointerTo(final Patch.Key k) {
if (myTable != null) {
myTable.movePointerTo(k);
}
}
public void setActive(boolean active) {
void setActive(boolean active) {
this.active = active;
if (myTable != null) {
myTable.setActive(active);
}
}
public void notifyDraftDelta(final Patch.Key k, final int delta) {
void notifyDraftDelta(final Patch.Key k, final int delta) {
if (myTable != null) {
myTable.notifyDraftDelta(k, delta);
}
@@ -212,7 +213,7 @@ public class PatchTable extends Composite {
/**
* @return a link to the previous file in this patch set, or null.
*/
public InlineHyperlink getPreviousPatchLink(int index) {
InlineHyperlink getPreviousPatchLink(int index) {
int previousPatchIndex = getPreviousPatch(index, PREFERENCE_VALIDATOR);
if (previousPatchIndex < 0) {
return null;
@@ -224,7 +225,7 @@ public class PatchTable extends Composite {
/**
* @return a link to the next file in this patch set, or null.
*/
public InlineHyperlink getNextPatchLink(int index) {
InlineHyperlink getNextPatchLink(int index) {
int nextPatchIndex = getNextPatch(index, false, PREFERENCE_VALIDATOR);
if (nextPatchIndex < 0) {
return null;
@@ -239,7 +240,7 @@ public class PatchTable extends Composite {
* @param before A string to display at the beginning of the href text
* @param after A string to display at the end of the href text
*/
public PatchLink createLink(int index, SafeHtml before, SafeHtml after) {
PatchLink createLink(int index, SafeHtml before, SafeHtml after) {
Patch patch = patchList.get(index);
Patch.Key thisKey = patch.getKey();
PatchLink link;
@@ -276,11 +277,11 @@ public class PatchTable extends Composite {
return fileName;
}
public static String getDisplayFileName(Patch patch) {
static String getDisplayFileName(Patch patch) {
return getDisplayFileName(patch.getKey());
}
public static String getDisplayFileName(Patch.Key patchKey) {
static String getDisplayFileName(Patch.Key patchKey) {
if (Patch.COMMIT_MSG.equals(patchKey.get())) {
return Util.C.commitMessage();
}
@@ -290,13 +291,13 @@ public class PatchTable extends Composite {
/**
* Update the reviewed status for the given patch.
*/
public void updateReviewedStatus(Patch.Key patchKey, boolean reviewed) {
void updateReviewedStatus(Patch.Key patchKey, boolean reviewed) {
if (myTable != null) {
myTable.updateReviewedStatus(patchKey, reviewed);
}
}
public ListenableAccountDiffPreference getPreferences() {
ListenableAccountDiffPreference getPreferences() {
return listenablePrefs;
}
@@ -374,7 +375,7 @@ public class PatchTable extends Composite {
}
/** Activates / Deactivates the key navigation and the highlighting of the current row for this table */
public void setActive(boolean active) {
void setActive(boolean active) {
if (active) {
if(activeRow > 0 && getCurrentRow() != activeRow) {
super.movePointerTo(activeRow);
@@ -832,7 +833,7 @@ public class PatchTable extends Composite {
* true
* @return index of next valid patch, or -1 if no valid patches
*/
public int getNextPatch(int currentIndex, boolean loopAround,
int getNextPatch(int currentIndex, boolean loopAround,
PatchValidator... validators) {
return getNextPatchHelper(currentIndex, loopAround, detail.getPatches()
.size(), validators);
@@ -866,7 +867,7 @@ public class PatchTable extends Composite {
/**
* @return the index to the previous patch
*/
public int getPreviousPatch(int currentIndex, PatchValidator... validators) {
int getPreviousPatch(int currentIndex, PatchValidator... validators) {
for (int i = currentIndex - 1; i >= 0; i--) {
Patch patch = detail.getPatches().get(i);
if (patch != null && patchIsValid(patch, validators)) {

View File

@@ -16,9 +16,8 @@ package com.google.gerrit.client.patches;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.VoidResult;
import com.google.gerrit.client.changes.PatchTable;
import com.google.gerrit.client.changes.PatchTable.PatchValidator;
import com.google.gerrit.client.changes.Util;
import com.google.gerrit.client.patches.PatchTable.PatchValidator;
import com.google.gerrit.client.rpc.RestApi;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.InlineHyperlink;
@@ -35,10 +34,9 @@ import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwtexpui.safehtml.client.SafeHtml;
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
public class ReviewedPanels {
public final FlowPanel top;
public final FlowPanel bottom;
class ReviewedPanels {
final FlowPanel top;
final FlowPanel bottom;
private Patch.Key patchKey;
private PatchTable fileList;
@@ -46,13 +44,13 @@ public class ReviewedPanels {
private CheckBox checkBoxTop;
private CheckBox checkBoxBottom;
public ReviewedPanels() {
ReviewedPanels() {
this.top = new FlowPanel();
this.bottom = new FlowPanel();
this.bottom.setStyleName(Gerrit.RESOURCES.css().reviewedPanelBottom());
}
public void populate(Patch.Key pk, PatchTable pt, int patchIndex) {
void populate(Patch.Key pk, PatchTable pt, int patchIndex) {
patchKey = pk;
fileList = pt;
reviewedLink = createReviewedLink(patchIndex);
@@ -86,16 +84,16 @@ public class ReviewedPanels {
return checkBox;
}
public boolean getValue() {
boolean getValue() {
return checkBoxTop.getValue();
}
public void setValue(final boolean value) {
void setValue(final boolean value) {
checkBoxTop.setValue(value);
checkBoxBottom.setValue(value);
}
public void setReviewedByCurrentUser(boolean reviewed) {
void setReviewedByCurrentUser(boolean reviewed) {
if (fileList != null) {
fileList.updateReviewedStatus(patchKey, reviewed);
}
@@ -124,7 +122,7 @@ public class ReviewedPanels {
}
}
public void go() {
void go() {
if (reviewedLink != null) {
setReviewedByCurrentUser(true);
reviewedLink.go();

View File

@@ -19,8 +19,6 @@ import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.RpcStatus;
import com.google.gerrit.client.WebLinkInfo;
import com.google.gerrit.client.changes.CommitMessageBlock;
import com.google.gerrit.client.changes.PatchTable;
import com.google.gerrit.client.diff.DiffApi;
import com.google.gerrit.client.diff.DiffInfo;
import com.google.gerrit.client.projects.ConfigInfoCache;