Change GWT plugin archetype to implement screen instead of dialog

We are now able to display a GWT screen when clicking on a menu item.
The GWT plugin archetype should create an example screen. So far it
was only showing a dialog.

Change-Id: I8b599542ae92e01195ce0402ae085615e86a1b62
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin 2014-01-28 20:46:14 +01:00
parent 6601f2db97
commit 66091fc02d
7 changed files with 85 additions and 154 deletions

View File

@ -25,7 +25,7 @@ limitations under the License.
<name>${pluginName}</name>
<properties>
<Gerrit-ApiType>extension</Gerrit-ApiType>
<Gerrit-ApiType>plugin</Gerrit-ApiType>
<Gerrit-ApiVersion>${gerritApiVersion}</Gerrit-ApiVersion>
</properties>
@ -42,6 +42,8 @@ limitations under the License.
<archive>
<manifestEntries>
<Gerrit-PluginName>${pluginName}</Gerrit-PluginName>
<Gerrit-Module>${package}.Module</Gerrit-Module>
<Gerrit-HttpModule>${package}.HttpModule</Gerrit-HttpModule>
<Implementation-Vendor>${Implementation-Vendor}</Implementation-Vendor>
<Implementation-URL>${Implementation-Url}</Implementation-URL>

View File

@ -14,22 +14,22 @@
package ${package};
import com.google.gerrit.extensions.annotations.Listen;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Listen
public class HelloMenu implements TopMenu {
public final static String MENU_ID = "hello_open-dialog-box";
private final List<MenuEntry> menuEntries;
public HelloMenu() {
@Inject
public HelloMenu(@PluginName String pluginName) {
menuEntries = new ArrayList<TopMenu.MenuEntry>();
menuEntries.add(new MenuEntry("Hello", Collections
.singletonList(new MenuItem("Open Dialog Box", "", "", MENU_ID))));
.singletonList(new MenuItem("Hello Screen", "#/x/" + pluginName, ""))));
}
@Override

View File

@ -0,0 +1,29 @@
// Copyright (C) 2014 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 ${package};
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.webui.GwtPlugin;
import com.google.gerrit.extensions.webui.WebUiPlugin;
import com.google.gerrit.httpd.plugins.HttpPluginModule;
public class HttpModule extends HttpPluginModule {
@Override
protected void configureServlets() {
DynamicSet.bind(binder(), WebUiPlugin.class)
.toInstance(new GwtPlugin("hello_gwt_plugin"));
}
}

View File

@ -14,12 +14,14 @@
package ${package};
import com.google.gerrit.extensions.webui.GwtPlugin;
import com.google.gerrit.extensions.annotations.Listen;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.webui.TopMenu;
import com.google.inject.AbstractModule;
@Listen
public class MyExtension extends GwtPlugin {
public MyExtension() {
super("hello_gwt_plugin");
public class Module extends AbstractModule {
@Override
protected void configure() {
DynamicSet.bind(binder(), TopMenu.class).to(HelloMenu.class);
}
}

View File

@ -14,15 +14,10 @@
package ${package}.client;
import com.google.gerrit.plugin.client.Plugin;
import com.google.gerrit.plugin.client.PluginEntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import ${package}.HelloMenu;
import ${package}.client.HelloScreen;
/**
* HelloWorld Plugin.
@ -31,35 +26,6 @@ public class HelloPlugin extends PluginEntryPoint {
@Override
public void onPluginLoad() {
// Create the dialog box
final DialogBox dialogBox = new DialogBox();
// The content of the dialog comes from a User specified Preference
dialogBox.setText("Hello from GWT Gerrit UI plugin");
dialogBox.setAnimationEnabled(true);
Button closeButton = new Button("Close");
VerticalPanel dialogVPanel = new VerticalPanel();
dialogVPanel.setWidth("100%");
dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
dialogVPanel.add(closeButton);
closeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dialogBox.hide();
}
});
// Set the contents of the Widget
dialogBox.setWidget(dialogVPanel);
RootPanel rootPanel = RootPanel.get(HelloMenu.MENU_ID);
rootPanel.getElement().removeAttribute("href");
rootPanel.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
dialogBox.center();
dialogBox.show();
}
}, ClickEvent.getType());
Plugin.get().screen("", new HelloScreen.Factory());
}
}

View File

@ -0,0 +1,35 @@
// Copyright (C) 2014 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 ${package}.client;
import com.google.gerrit.plugin.client.screen.Screen;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
public class HelloScreen extends VerticalPanel {
static class Factory implements Screen.EntryPoint {
@Override
public void onLoad(Screen screen) {
screen.setPageTitle("Hello");
screen.show(new HelloScreen());
}
}
HelloScreen() {
setStyleName("hello-panel");
add(new Label("Hello World Screen"));
}
}

View File

@ -1,106 +1,3 @@
/**
* The file contains styles for a sample plugin derived from the
* GWT standard theme.
* Images in the stylesheet have been removed, as well as styles for widgets
* not currently in use.
*/
body, table td, select {
font-family: sans-serif;
font-size: small;
}
pre {
font-family: "courier new", courier;
font-size: small;
}
body {
color: black;
margin: 0px;
border: 0px;
padding: 0px;
background: #fff;
direction: ltr;
}
a, a:visited, a:hover {
color: #0000AA;
}
/**
* The reference theme can be used to determine when this style sheet has
* loaded. Create a hidden div element with absolute position, assign the style
* name below, and attach it to the DOM. Use a timer to detect when the
* element's height and width are set to 5px.
*/
.gwt-Reference-standard {
height: 5px;
width: 5px;
zoom: 1;
}
.gwt-Button {
margin: 0;
padding: 3px 5px;
text-decoration: none;
font-size: small;
cursor: pointer;
cursor: hand;
border: 1px outset #ccc;
}
.gwt-Button:active {
border: 1px inset #ccc;
}
.gwt-Button:hover {
border-color: #9cf #69e #69e #7af;
}
.gwt-Button[disabled] {
cursor: default;
color: #888;
}
.gwt-Button[disabled]:hover {
border: 1px outset #ccc;
}
.gwt-DialogBox .Caption {
background: #e3e8f3;
padding: 4px 4px 4px 8px;
cursor: default;
border-bottom: 1px solid #bbbbbb;
border-top: 5px solid #d0e4f6;
border-left: 5px solid #d0e4f6;
border-right: 5px solid #d0e4f6;
}
.gwt-DialogBox .dialogContent {
}
.gwt-DialogBox .dialogMiddleCenter {
padding: 3px;
background: white;
border-left: 5px solid #d0e4f6;
border-right: 5px solid #d0e4f6;
border-bottom: 5px solid #d0e4f6;
}
.gwt-DialogBox .dialogTopLeftInner {
width: 5px;
zoom: 1;
}
.gwt-DialogBox .dialogTopRightInner {
width: 8px;
zoom: 1;
}
.gwt-DialogBox .dialogBottomLeftInner {
width: 5px;
height: 8px;
zoom: 1;
}
.gwt-DialogBox .dialogBottomRightInner {
width: 5px;
height: 8px;
zoom: 1;
}
#hello_open-dialog-box {
cursor: pointer;
.hello-panel {
border-spacing: 0px 5px;
}