Reuse code that was moved to gwtexpui

All of this code has been refactored into the non-application specific
package gwtexpui.  Instead of keeping our own copies lets use the more
common package version of it.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-02-27 13:15:41 -08:00
parent 01a89f7d04
commit 57d1e3947c
19 changed files with 31 additions and 592 deletions

View File

@@ -441,6 +441,13 @@ limitations under the License.
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>gwtexpui</groupId>
<artifactId>gwtexpui</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>gerrit</groupId> <groupId>gerrit</groupId>
<artifactId>executablewar</artifactId> <artifactId>executablewar</artifactId>

View File

@@ -2,6 +2,10 @@
<inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwtjsonrpc.GWTJSONRPC'/> <inherits name='com.google.gwtjsonrpc.GWTJSONRPC'/>
<inherits name='com.google.gwtorm.GWTORM'/> <inherits name='com.google.gwtorm.GWTORM'/>
<inherits name='com.google.gwtexpui.clippy.Clippy'/>
<inherits name='com.google.gwtexpui.progress.Progress'/>
<inherits name='com.google.gwtexpui.safehtml.SafeHtml'/>
<inherits name='com.google.gwt.user.theme.chrome.Chrome'/> <inherits name='com.google.gwt.user.theme.chrome.Chrome'/>
<inherits name='com.google.gerrit.UserAgent'/> <inherits name='com.google.gerrit.UserAgent'/>
<extend-property name="locale" values="en"/> <extend-property name="locale" values="en"/>

View File

@@ -15,12 +15,12 @@
package com.google.gerrit.client; package com.google.gerrit.client;
import com.google.gerrit.client.rpc.Common; import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.ui.AutoCenterDialogBox;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener; import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
import com.google.gwtjsonrpc.client.RemoteJsonException; import com.google.gwtjsonrpc.client.RemoteJsonException;
/** A dialog box showing an error message, when bad things happen. */ /** A dialog box showing an error message, when bad things happen. */

View File

@@ -20,7 +20,6 @@ import com.google.gerrit.client.openid.OpenIdLoginPanel;
import com.google.gerrit.client.reviewdb.Account; import com.google.gerrit.client.reviewdb.Account;
import com.google.gerrit.client.rpc.Common; import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AutoCenterDialogBox;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.DeferredCommand;
@@ -29,6 +28,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
import com.google.gwtjsonrpc.client.CallbackHandle; import com.google.gwtjsonrpc.client.CallbackHandle;
/** /**

View File

@@ -20,7 +20,6 @@ import com.google.gerrit.client.reviewdb.AccountExternalId;
import com.google.gerrit.client.reviewdb.ContactInformation; import com.google.gerrit.client.reviewdb.ContactInformation;
import com.google.gerrit.client.rpc.Common; import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AutoCenterDialogBox;
import com.google.gerrit.client.ui.TextSaveButtonListener; import com.google.gerrit.client.ui.TextSaveButtonListener;
import com.google.gwt.i18n.client.LocaleInfo; import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.Button;
@@ -40,6 +39,7 @@ import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox; import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import com.google.gwtexpui.user.client.AutoCenterDialogBox;
import com.google.gwtjsonrpc.client.VoidResult; import com.google.gwtjsonrpc.client.VoidResult;
import java.sql.Timestamp; import java.sql.Timestamp;

View File

@@ -21,12 +21,12 @@ import com.google.gerrit.client.reviewdb.Branch;
import com.google.gerrit.client.reviewdb.Change; import com.google.gerrit.client.reviewdb.Change;
import com.google.gerrit.client.ui.AccountDashboardLink; import com.google.gerrit.client.ui.AccountDashboardLink;
import com.google.gerrit.client.ui.ChangeLink; import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.CopyableText;
import com.google.gerrit.client.ui.ProjectOpenLink; import com.google.gerrit.client.ui.ProjectOpenLink;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwtexpui.clippy.client.CopyableLabel;
public class ChangeInfoBlock extends Composite { public class ChangeInfoBlock extends Composite {
private static final int R_OWNER = 0; private static final int R_OWNER = 0;
@@ -84,7 +84,7 @@ public class ChangeInfoBlock extends Composite {
final FlowPanel fp = new FlowPanel(); final FlowPanel fp = new FlowPanel();
fp.add(new ChangeLink(Util.C.changePermalink(), chg.getId())); fp.add(new ChangeLink(Util.C.changePermalink(), chg.getId()));
fp.add(new CopyableText(ChangeLink.permalink(chg.getId()), false)); fp.add(new CopyableLabel(ChangeLink.permalink(chg.getId()), false));
table.setWidget(R_PERMALINK, 1, fp); table.setWidget(R_PERMALINK, 1, fp);
} }
} }

View File

@@ -31,7 +31,6 @@ import com.google.gerrit.client.reviewdb.Project;
import com.google.gerrit.client.reviewdb.UserIdentity; import com.google.gerrit.client.reviewdb.UserIdentity;
import com.google.gerrit.client.rpc.Common; import com.google.gerrit.client.rpc.Common;
import com.google.gerrit.client.rpc.GerritCallback; import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.CopyableText;
import com.google.gerrit.client.ui.DomUtil; import com.google.gerrit.client.ui.DomUtil;
import com.google.gerrit.client.ui.RefreshListener; import com.google.gerrit.client.ui.RefreshListener;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
@@ -45,6 +44,7 @@ import com.google.gwt.user.client.ui.Grid;
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;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter; import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwtexpui.clippy.client.CopyableLabel;
import com.google.gwtjsonrpc.client.VoidResult; import com.google.gwtjsonrpc.client.VoidResult;
import java.util.ArrayList; import java.util.ArrayList;
@@ -181,7 +181,7 @@ class PatchSetPanel extends Composite implements DisclosureHandler {
r.append(changeDetail.getChange().getChangeId()); r.append(changeDetail.getChange().getChangeId());
r.append("/"); r.append("/");
r.append(patchSet.getPatchSetId()); r.append(patchSet.getPatchSetId());
downloads.add(new CopyableText(r.toString())); downloads.add(new CopyableLabel(r.toString()));
} }
if (changeDetail.isAllowsAnonymous() if (changeDetail.isAllowsAnonymous()
@@ -196,7 +196,7 @@ class PatchSetPanel extends Composite implements DisclosureHandler {
r.append(projectName); r.append(projectName);
r.append(" "); r.append(" ");
r.append(patchSet.getRefName()); r.append(patchSet.getRefName());
downloads.add(new CopyableText(r.toString())); downloads.add(new CopyableLabel(r.toString()));
} else if (Gerrit.isSignedIn() && Gerrit.getUserAccount() != null } else if (Gerrit.isSignedIn() && Gerrit.getUserAccount() != null
&& Gerrit.getUserAccount().getSshUserName() != null && Gerrit.getUserAccount().getSshUserName() != null
@@ -216,7 +216,7 @@ class PatchSetPanel extends Composite implements DisclosureHandler {
r.append(projectName); r.append(projectName);
r.append(" "); r.append(" ");
r.append(patchSet.getRefName()); r.append(patchSet.getRefName());
downloads.add(new CopyableText(r.toString())); downloads.add(new CopyableLabel(r.toString()));
} }
infoTable.setWidget(R_DOWNLOAD, 1, downloads); infoTable.setWidget(R_DOWNLOAD, 1, downloads);

View File

@@ -19,12 +19,12 @@ import com.google.gerrit.client.reviewdb.Patch;
import com.google.gerrit.client.reviewdb.PatchSet; import com.google.gerrit.client.reviewdb.PatchSet;
import com.google.gerrit.client.ui.DomUtil; import com.google.gerrit.client.ui.DomUtil;
import com.google.gerrit.client.ui.FancyFlexTable; import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.client.ui.ProgressMeter;
import com.google.gwt.user.client.DeferredCommand; import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.History; import com.google.gwt.user.client.History;
import com.google.gwt.user.client.IncrementalCommand; import com.google.gwt.user.client.IncrementalCommand;
import com.google.gwt.user.client.ui.SourcesTableEvents; import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener; import com.google.gwt.user.client.ui.TableListener;
import com.google.gwtexpui.progress.client.ProgressBar;
import java.util.List; import java.util.List;
@@ -160,7 +160,7 @@ public class PatchTable extends FancyFlexTable<Patch> {
private int stage; private int stage;
private int row; private int row;
private double start; private double start;
private ProgressMeter meter; private ProgressBar meter;
private DisplayCommand(final List<Patch> list) { private DisplayCommand(final List<Patch> list) {
this.list = list; this.list = list;
@@ -216,7 +216,7 @@ public class PatchTable extends FancyFlexTable<Patch> {
void initMeter() { void initMeter() {
if (meter == null) { if (meter == null) {
resetHtml("<tr><td></td></tr>"); resetHtml("<tr><td></td></tr>");
meter = new ProgressMeter(Util.M.loadingPatchSet(psid.get())); meter = new ProgressBar(Util.M.loadingPatchSet(psid.get()));
table.setWidget(0, 0, meter); table.setWidget(0, 0, meter);
} }
updateMeter(); updateMeter();

View File

@@ -1,63 +0,0 @@
// 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.ui;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.WindowResizeListener;
import com.google.gwt.user.client.ui.DialogBox;
/** A DialogBox that automatically re-centers itself if the window changes */
public class AutoCenterDialogBox extends DialogBox {
private WindowResizeListener recenter;
public AutoCenterDialogBox() {
}
public AutoCenterDialogBox(final boolean autoHide) {
super(autoHide);
}
public AutoCenterDialogBox(final boolean autoHide, final boolean modal) {
super(autoHide, modal);
}
@Override
public void show() {
if (recenter == null) {
recenter = new WindowResizeListener() {
public void onWindowResized(final int width, final int height) {
onResize(width, height);
}
};
Window.addWindowResizeListener(recenter);
}
super.show();
}
@Override
protected void onUnload() {
if (recenter != null) {
Window.removeWindowResizeListener(recenter);
recenter = null;
}
super.onUnload();
}
protected void onResize(final int width, final int height) {
if (isAttached()) {
center();
}
}
}

View File

@@ -1,121 +0,0 @@
// Copyright 2009 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.ui;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusListener;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.KeyboardListenerAdapter;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
public class CopyableText extends Composite implements ClickListener {
private static final CopyableTextImpl impl;
static {
if (UserAgent.hasFlash) {
impl = new CopyableTextImplFlash();
} else {
impl = new CopyableTextImpl();
}
}
private final FlowPanel content;
private final String text;
private Label textLabel;
private TextBox textBox;
public CopyableText(final String str) {
this(str, true);
}
public CopyableText(final String str, final boolean showLabel) {
content = new FlowPanel();
content.setStyleName("gerrit-CopyableText");
initWidget(content);
text = str;
if (showLabel) {
textLabel = new InlineLabel(getText());
textLabel.setStyleName("gerrit-CopyableText-Label");
textLabel.addClickListener(this);
content.add(textLabel);
}
impl.inject(this);
}
public String getText() {
return text;
}
public void onClick(final Widget source) {
if (textLabel == source) {
showTextBox();
}
}
private void showTextBox() {
if (textBox == null) {
textBox = new TextBox();
textBox.setText(getText());
textBox.setVisibleLength(getText().length());
textBox.addKeyboardListener(new KeyboardListenerAdapter() {
@Override
public void onKeyPress(final Widget sender, final char kc, final int mod) {
if ((mod & MODIFIER_CTRL) == MODIFIER_CTRL
|| (mod & MODIFIER_META) == MODIFIER_META) {
switch (kc) {
case 'c':
case 'x':
DeferredCommand.addCommand(new Command() {
public void execute() {
hideTextBox();
}
});
break;
}
}
}
});
textBox.addFocusListener(new FocusListener() {
public void onFocus(Widget arg0) {
}
public void onLostFocus(Widget arg0) {
hideTextBox();
}
});
content.insert(textBox, 1);
}
textLabel.setVisible(false);
textBox.setVisible(true);
textBox.selectAll();
textBox.setFocus(true);
}
private void hideTextBox() {
if (textBox != null) {
textBox.removeFromParent();
textBox = null;
}
textLabel.setVisible(true);
}
}

View File

@@ -1,20 +0,0 @@
// Copyright 2009 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.ui;
class CopyableTextImpl {
void inject(final CopyableText widget) {
}
}

View File

@@ -1,71 +0,0 @@
// Copyright 2009 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.ui;
import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
class CopyableTextImplFlash extends CopyableTextImpl {
private static final int SWF_WIDTH = 110;
private static final int SWF_HEIGHT = 14;
private static final String swfUrl =
GWT.getModuleBaseURL() + "clippy1.cache.swf";
@Override
void inject(final CopyableText widget) {
final String flashVars = "text=" + URL.encodeComponent(widget.getText());
final StringBuilder html = new StringBuilder();
final Element span = DOM.createSpan();
DOM.setElementProperty(span, "className", "gerrit-CopyableText-SWF");
html.append("<object");
html.append(" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"");
html.append(" width=\"" + SWF_WIDTH + "\"");
html.append(" height=\"" + SWF_HEIGHT + "\"");
html.append(">");
param(html, "movie", swfUrl);
param(html, "FlashVars", flashVars);
html.append("<embed ");
html.append(" type=\"application/x-shockwave-flash\"");
html.append(" width=\"" + SWF_WIDTH + "\"");
html.append(" height=\"" + SWF_HEIGHT + "\"");
attribute(html, "src", swfUrl);
attribute(html, "FlashVars", flashVars);
html.append("/>");
html.append("</object>");
DOM.setInnerHTML(span, html.toString());
DOM.appendChild(widget.getElement(), span);
}
private static void param(StringBuilder html, String name, String value) {
html.append("<param");
attribute(html, "name", name);
attribute(html, "value", value);
html.append("/>");
}
private static void attribute(StringBuilder html, String name, String value) {
html.append(" ");
html.append(name);
html.append("=\"");
html.append(DomUtil.escape(value));
html.append("\"");
}
}

View File

@@ -14,92 +14,29 @@
package com.google.gerrit.client.ui; package com.google.gerrit.client.ui;
import com.google.gwt.core.client.GWT; import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
/** Utilities for dealing with the DOM. */ /** Utilities for dealing with the DOM. */
public abstract class DomUtil { public abstract class DomUtil {
private static final Impl INSTANCE;
static {
if (GWT.isClient())
INSTANCE = new ClientImpl();
else
INSTANCE = new JavaImpl();
}
/** Escape XML/HTML special characters in the input string. */ /** Escape XML/HTML special characters in the input string. */
public static String escape(final String in) { public static String escape(final String in) {
return INSTANCE.escape(in); return new SafeHtmlBuilder().append(in).asString();
} }
/** Convert bare URLs into &lt;a href&gt; tags. */ /** Convert bare URLs into &lt;a href&gt; tags. */
public static String linkify(final String in) { public static String linkify(final String in) {
return INSTANCE.linkify(in); return in.replaceAll("(https?://[^ \n\r\t]*)", "<a href=\"$1\">$1</a>");
} }
/** Do wiki style formatting to make it pretty */ /** Do wiki style formatting to make it pretty */
public static String wikify(String in) { public static String wikify(String in) {
in = INSTANCE.escape(in); in = escape(in);
in = INSTANCE.linkify(in); in = linkify(in);
in = INSTANCE.wikify(in); in = in.replaceAll("(^|\n)([ \t][^\n]*)", "$1<span class=\"gerrit-preformat\">$2</span><br />");
in = in.replaceAll("\n\n", "<p>\n");
return in; return in;
} }
private DomUtil() { private DomUtil() {
} }
private static abstract class Impl {
abstract String escape(String in);
String wikify(String s) {
s = s.replaceAll("(^|\n)([ \t][^\n]*)", "$1<span class=\"gerrit-preformat\">$2</span><br />");
s = s.replaceAll("\n\n", "<p>\n");
return s;
}
String linkify(String in) {
return in.replaceAll("(https?://[^ \n\r\t]*)", "<a href=\"$1\">$1</a>");
}
}
private static class ClientImpl extends Impl {
@Override
native String escape(String src)
/*-{ return src.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;')
; }-*/;
}
private static class JavaImpl extends Impl {
@Override
String escape(final String in) {
final StringBuilder r = new StringBuilder(in.length());
for (int i = 0; i < in.length(); i++) {
final char c = in.charAt(i);
switch (c) {
case '&':
r.append("&amp;");
break;
case '>':
r.append("&gt;");
break;
case '<':
r.append("&lt;");
break;
case '"':
r.append("&quot;");
break;
case '\'':
r.append("&#39;");
break;
default:
r.append(c);
}
}
return r.toString();
}
}
} }

View File

@@ -1,55 +0,0 @@
// Copyright 2009 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.ui;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
public class ProgressMeter extends Composite {
private final String callerText;
private final Label bar;
private final Label msg;
public ProgressMeter() {
this("");
}
public ProgressMeter(final String text) {
if (text == null || text.length() == 0) {
callerText = "";
} else {
callerText = text + " ";
}
final FlowPanel body = new FlowPanel();
body.setStyleName("gerrit-ProgressMeter");
msg = new Label(callerText);
msg.setStyleName("gerrit-ProgressMeterText");
body.add(msg);
bar = new Label("");
bar.setStyleName("gerrit-ProgressMeterBar");
body.add(bar);
initWidget(body);
}
public void setValue(final int v) {
bar.setWidth("" + (2 * v) + "px");
msg.setText(callerText + v + "%");
}
}

View File

@@ -1,50 +0,0 @@
// Copyright 2009 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.ui;
/**
* User agent feature tests we don't create permutations for.
* <p>
* Some features aren't worth creating full permutations in GWT for, as it each
* new boolean permutation (only two settings) doubles the compile time
* required. If the setting only affects a couple of lines of JavaScript code,
* the slightly larger cache files for user agents that lack the functionality
* requested is trivial compared to the time developers lose building Gerrit.
*/
public class UserAgent {
/** Does the browser have ShockwaveFlash plugin enabled? */
public static final boolean hasFlash = hasFlash();
private static native boolean hasFlash()
/*-{
if (navigator.plugins && navigator.plugins.length) {
if (navigator.plugins['Shockwave Flash']) return true;
if (navigator.plugins['Shockwave Flash 2.0']) return true;
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
if (mimeType && mimeType.enabledPlugin) return true;
} else {
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.7'); return true; } catch (e) {}
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); return true; } catch (e) {}
try { new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); return true; } catch (e) {}
}
return false;
}-*/;
private UserAgent() {
}
}

View File

@@ -72,42 +72,6 @@
font-weight: bold; font-weight: bold;
} }
.gerrit-ProgressMeter {
position: relative;
border: 1px solid #6B90DA;
height: 20px;
width: 200px;
}
.gerrit-ProgressMeterText {
position: absolute;
bottom: 0;
left: 0;
z-index: 2;
width: 200px;
padding-bottom: 3px;
text-align: center;
font-weight: bold;
font-style: italic;
font-size: smaller;
}
.gerrit-ProgressMeterBar {
background: #F0F7F9;
border-right: 1px solid #D0D7D9;
position: absolute;
top: 0;
left: 0;
height: 20px;
}
.gerrit-CopyableText {
}
.gerrit-CopyableText-Label {
vertical-align: top;
}
.gerrit-CopyableText-SWF {
margin-left: 5px;
}
/** Menu **/ /** Menu **/
.gwt-MenuItem a, .gwt-MenuItem a,

View File

@@ -1,93 +0,0 @@
// 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.server;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Forces GWT resources to cache for a very long time.
* <p>
* GWT compiled JavaScript and ImageBundles can be cached indefinitely by a
* browser and/or an edge proxy, as they never contain user-specific data and
* are named by a unique checksum. If their content is ever modified then the
* URL changes, so user agents would request a different resource. We force
* these resources to have very long expiration times.
*/
public class CacheControlFilter implements Filter {
public void init(final FilterConfig config) {
}
public void destroy() {
}
public void doFilter(final ServletRequest sreq, final ServletResponse srsp,
final FilterChain chain) throws IOException, ServletException {
final HttpServletRequest req = (HttpServletRequest) sreq;
final HttpServletResponse rsp = (HttpServletResponse) srsp;
final String pathInfo = pathInfo(req);
if (cacheForever(pathInfo)) {
rsp.setHeader("Cache-Control", "max-age=31536000,public");
rsp.setDateHeader("Expires", System.currentTimeMillis() + 31536000000L);
} else if (nocache(pathInfo)) {
rsp.setHeader("Expires", "Fri, 01 Jan 1980 00:00:00 GMT");
rsp.setHeader("Pragma", "no-cache");
rsp.setHeader("Cache-Control", "no-cache, must-revalidate");
}
chain.doFilter(req, rsp);
}
private static boolean cacheForever(final String pathInfo) {
if (pathInfo.endsWith(".cache.gif")) {
return true;
}
if (pathInfo.endsWith(".cache.html")) {
return true;
}
if (pathInfo.endsWith(".cache.png")) {
return true;
}
if (pathInfo.endsWith(".cache.jar")) {
return true;
}
if (pathInfo.endsWith(".cache.swf")) {
return true;
}
return false;
}
private static boolean nocache(final String pathInfo) {
if (pathInfo.endsWith(".nocache.js")) {
return true;
}
return false;
}
private static String pathInfo(final HttpServletRequest req) {
final String uri = req.getRequestURI();
final String ctx = req.getContextPath();
return uri.startsWith(ctx) ? uri.substring(ctx.length()) : uri;
}
}

View File

@@ -23,7 +23,7 @@
<filter> <filter>
<filter-name>CacheControl</filter-name> <filter-name>CacheControl</filter-name>
<filter-class>com.google.gerrit.server.CacheControlFilter</filter-class> <filter-class>com.google.gwtexpui.server.CacheControlFilter</filter-class>
</filter> </filter>
<filter-mapping> <filter-mapping>
<filter-name>CacheControl</filter-name> <filter-name>CacheControl</filter-name>