Split the description area of a change into a reusable block
This makes it easier to reuse this body within other screens, such as when publishing comments or viewing a patch. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
// Copyright 2008 Google Inc.
|
||||||
|
//
|
||||||
|
// 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.changes;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.data.ChangeDetail;
|
||||||
|
import com.google.gerrit.client.ui.DomUtil;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.DisclosurePanel;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
|
||||||
|
public class ChangeDescriptionBlock extends Composite {
|
||||||
|
private final DisclosurePanel descriptionPanel;
|
||||||
|
private final ChangeInfoBlock infoBlock;
|
||||||
|
private final HTML description;
|
||||||
|
|
||||||
|
public ChangeDescriptionBlock() {
|
||||||
|
infoBlock = new ChangeInfoBlock();
|
||||||
|
description = new HTML();
|
||||||
|
description.setStyleName("gerrit-ChangeScreen-Description");
|
||||||
|
descriptionPanel = new DisclosurePanel(Util.C.changeScreenDescription());
|
||||||
|
{
|
||||||
|
final Label glue = new Label();
|
||||||
|
final HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
hp.add(description);
|
||||||
|
hp.add(glue);
|
||||||
|
hp.add(infoBlock);
|
||||||
|
hp.setCellWidth(glue, "15px;");
|
||||||
|
descriptionPanel.setContent(hp);
|
||||||
|
descriptionPanel.setWidth("100%");
|
||||||
|
}
|
||||||
|
initWidget(descriptionPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void display(final ChangeDetail detail) {
|
||||||
|
infoBlock.display(detail);
|
||||||
|
description.setHTML(DomUtil
|
||||||
|
.linkify(DomUtil.escape(detail.getDescription())));
|
||||||
|
descriptionPanel.setOpen(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,7 +25,6 @@ import com.google.gerrit.client.reviewdb.PatchSet;
|
|||||||
import com.google.gerrit.client.rpc.Common;
|
import com.google.gerrit.client.rpc.Common;
|
||||||
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
||||||
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
|
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
|
||||||
import com.google.gerrit.client.ui.DomUtil;
|
|
||||||
import com.google.gerrit.client.ui.ExpandAllCommand;
|
import com.google.gerrit.client.ui.ExpandAllCommand;
|
||||||
import com.google.gerrit.client.ui.LinkMenuBar;
|
import com.google.gerrit.client.ui.LinkMenuBar;
|
||||||
import com.google.gerrit.client.ui.RefreshListener;
|
import com.google.gerrit.client.ui.RefreshListener;
|
||||||
@@ -34,10 +33,7 @@ import com.google.gwt.i18n.client.LocaleInfo;
|
|||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.DisclosurePanel;
|
import com.google.gwt.user.client.ui.DisclosurePanel;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
|
||||||
import com.google.gwt.user.client.ui.InlineLabel;
|
import com.google.gwt.user.client.ui.InlineLabel;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
|
||||||
import com.google.gwt.user.client.ui.Panel;
|
import com.google.gwt.user.client.ui.Panel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
@@ -50,10 +46,7 @@ public class ChangeScreen extends Screen {
|
|||||||
private ChangeInfo changeInfo;
|
private ChangeInfo changeInfo;
|
||||||
private boolean refreshOnSignIn;
|
private boolean refreshOnSignIn;
|
||||||
|
|
||||||
private ChangeInfoBlock infoBlock;
|
private ChangeDescriptionBlock descriptionBlock;
|
||||||
private DisclosurePanel descriptionPanel;
|
|
||||||
private HTML description;
|
|
||||||
|
|
||||||
private DisclosurePanel dependenciesPanel;
|
private DisclosurePanel dependenciesPanel;
|
||||||
private ChangeTable dependencies;
|
private ChangeTable dependencies;
|
||||||
private ChangeTable.Section dependsOn;
|
private ChangeTable.Section dependsOn;
|
||||||
@@ -102,7 +95,7 @@ public class ChangeScreen extends Screen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
if (descriptionPanel == null) {
|
if (descriptionBlock == null) {
|
||||||
initUI();
|
initUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,23 +120,8 @@ public class ChangeScreen extends Screen {
|
|||||||
private void initUI() {
|
private void initUI() {
|
||||||
addStyleName("gerrit-ChangeScreen");
|
addStyleName("gerrit-ChangeScreen");
|
||||||
|
|
||||||
infoBlock = new ChangeInfoBlock();
|
descriptionBlock = new ChangeDescriptionBlock();
|
||||||
|
add(descriptionBlock);
|
||||||
description = newDescriptionLabel();
|
|
||||||
|
|
||||||
descriptionPanel = new DisclosurePanel(Util.C.changeScreenDescription());
|
|
||||||
{
|
|
||||||
final Label glue = new Label();
|
|
||||||
final HorizontalPanel hp = new HorizontalPanel();
|
|
||||||
hp.add(description);
|
|
||||||
hp.add(glue);
|
|
||||||
hp.add(infoBlock);
|
|
||||||
hp.setCellWidth(glue, "100%");
|
|
||||||
add(hp);
|
|
||||||
descriptionPanel.setContent(hp);
|
|
||||||
descriptionPanel.setWidth("100%");
|
|
||||||
add(descriptionPanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies = new ChangeTable();
|
dependencies = new ChangeTable();
|
||||||
dependsOn = new ChangeTable.Section(Util.C.changeScreenDependsOn());
|
dependsOn = new ChangeTable.Section(Util.C.changeScreenDependsOn());
|
||||||
@@ -198,9 +176,7 @@ public class ChangeScreen extends Screen {
|
|||||||
dependencies.setAccountInfoCache(detail.getAccounts());
|
dependencies.setAccountInfoCache(detail.getAccounts());
|
||||||
approvals.setAccountInfoCache(detail.getAccounts());
|
approvals.setAccountInfoCache(detail.getAccounts());
|
||||||
|
|
||||||
infoBlock.display(detail);
|
descriptionBlock.display(detail);
|
||||||
description.setHTML(DomUtil
|
|
||||||
.linkify(DomUtil.escape(detail.getDescription())));
|
|
||||||
dependsOn.display(detail.getDependsOn());
|
dependsOn.display(detail.getDependsOn());
|
||||||
neededBy.display(detail.getNeededBy());
|
neededBy.display(detail.getNeededBy());
|
||||||
approvals.display(detail.getMissingApprovals(), detail.getApprovals());
|
approvals.display(detail.getMissingApprovals(), detail.getApprovals());
|
||||||
@@ -221,7 +197,6 @@ public class ChangeScreen extends Screen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptionPanel.setOpen(true);
|
|
||||||
dependenciesPanel.setOpen(depsOpen);
|
dependenciesPanel.setOpen(depsOpen);
|
||||||
approvalsPanel.setOpen(true);
|
approvalsPanel.setOpen(true);
|
||||||
}
|
}
|
||||||
@@ -329,10 +304,4 @@ public class ChangeScreen extends Screen {
|
|||||||
p.add(w);
|
p.add(w);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static HTML newDescriptionLabel() {
|
|
||||||
final HTML d = new HTML();
|
|
||||||
d.setStyleName("gerrit-ChangeScreen-Description");
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user