Redesign change screen on new REST API
The new screen exists at #/c2/<id> as it is missing a large number of features. The proposal is to include the screen as-is and iterate in tree, similar to the CodeMirror work. This allows power users to start trying the screen out by editing the URL. Missing features: - Add reviewer(s) - Remove reviewer(s) - Edit commit message - Diff files in two patch sets - Dependencies and dependents - Download links by URL and action (cherry-pick, checkout, etc.) Change-Id: Ie957fb85c873d044c947000f0f0207a66f87c784
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
// 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.change;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.KeyCodes;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.logical.shared.CloseEvent;
|
||||
import com.google.gwt.event.logical.shared.CloseHandler;
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.PopupPanel;
|
||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||
import com.google.gwtexpui.globalkey.client.NpTextArea;
|
||||
import com.google.gwtexpui.user.client.PluginSafePopupPanel;
|
||||
|
||||
abstract class ActionMessageBox extends Composite {
|
||||
interface Binder extends UiBinder<HTMLPanel, ActionMessageBox> {}
|
||||
private static Binder uiBinder = GWT.create(Binder.class);
|
||||
|
||||
static interface Style extends CssResource {
|
||||
String popup();
|
||||
}
|
||||
|
||||
private final Button activatingButton;
|
||||
private PluginSafePopupPanel popup;
|
||||
|
||||
@UiField Style style;
|
||||
@UiField NpTextArea message;
|
||||
@UiField Button send;
|
||||
|
||||
ActionMessageBox(Button button) {
|
||||
this.activatingButton = button;
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
send.setText(button.getText());
|
||||
}
|
||||
|
||||
abstract void send(String message);
|
||||
|
||||
void show() {
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
popup = null;
|
||||
return;
|
||||
}
|
||||
|
||||
final PluginSafePopupPanel p = new PluginSafePopupPanel(true);
|
||||
p.setStyleName(style.popup());
|
||||
p.addAutoHidePartner(activatingButton.getElement());
|
||||
p.addCloseHandler(new CloseHandler<PopupPanel>() {
|
||||
@Override
|
||||
public void onClose(CloseEvent<PopupPanel> event) {
|
||||
if (popup == p) {
|
||||
popup = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
p.add(this);
|
||||
p.showRelativeTo(activatingButton);
|
||||
GlobalKey.dialog(p);
|
||||
message.setFocus(true);
|
||||
popup = p;
|
||||
}
|
||||
|
||||
void hide() {
|
||||
if (popup != null) {
|
||||
popup.hide();
|
||||
popup = null;
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("message")
|
||||
void onMessageKey(KeyPressEvent event) {
|
||||
if ((event.getCharCode() == '\n' || event.getCharCode() == KeyCodes.KEY_ENTER)
|
||||
&& event.isControlKeyDown()) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
onSend(null);
|
||||
}
|
||||
}
|
||||
|
||||
@UiHandler("send")
|
||||
void onSend(ClickEvent e) {
|
||||
send(message.getValue().trim());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user