Switch all CSS to use CssResource
Change-Id: I72600495e15c094afcd9bbb10b11469a2c096ece Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<module>
|
||||
<inherits name='com.google.gwt.resources.Resources'/>
|
||||
<inherits name="com.google.gwtexpui.safehtml.SafeHtml"/>
|
||||
<inherits name="com.google.gwtexpui.user.User"/>
|
||||
<stylesheet src='gwtexpui_clippy1.cache.css' />
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2009 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.gwtexpui.clippy.client;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
public interface ClippyCss extends CssResource {
|
||||
String label();
|
||||
String control();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2009 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.gwtexpui.clippy.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
|
||||
public interface ClippyResources extends ClientBundle {
|
||||
public static final ClippyResources I = GWT.create(ClippyResources.class);
|
||||
|
||||
@Source("clippy.css")
|
||||
ClippyCss css();
|
||||
}
|
||||
@@ -43,8 +43,6 @@ import com.google.gwtexpui.user.client.UserAgent;
|
||||
* one-click copying of the content onto the system clipboard. The label (if
|
||||
* visible) can also be clicked, switching from a label to an input box,
|
||||
* allowing the user to copy the text with a keyboard shortcut.
|
||||
* <p>
|
||||
* Style name: <code>gwtexpui-Clippy</code>
|
||||
*/
|
||||
public class CopyableLabel extends Composite implements HasText {
|
||||
private static final int SWF_WIDTH = 110;
|
||||
@@ -52,6 +50,10 @@ public class CopyableLabel extends Composite implements HasText {
|
||||
private static String swfUrl;
|
||||
private static boolean flashEnabled = true;
|
||||
|
||||
static {
|
||||
ClippyResources.I.css().ensureInjected();
|
||||
}
|
||||
|
||||
public static boolean isFlashEnabled() {
|
||||
return flashEnabled;
|
||||
}
|
||||
@@ -91,13 +93,12 @@ public class CopyableLabel extends Composite implements HasText {
|
||||
*/
|
||||
public CopyableLabel(final String str, final boolean showLabel) {
|
||||
content = new FlowPanel();
|
||||
content.setStyleName("gwtexpui-Clippy");
|
||||
initWidget(content);
|
||||
|
||||
text = str;
|
||||
if (showLabel) {
|
||||
textLabel = new InlineLabel(getText());
|
||||
textLabel.setStyleName("gwtexpui-Clippy-Label");
|
||||
textLabel.setStyleName(ClippyResources.I.css().label());
|
||||
textLabel.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(final ClickEvent event) {
|
||||
@@ -115,7 +116,7 @@ public class CopyableLabel extends Composite implements HasText {
|
||||
final SafeHtmlBuilder h = new SafeHtmlBuilder();
|
||||
|
||||
h.openElement("span");
|
||||
h.setStyleName("gwtexpui-Clippy-Control");
|
||||
h.setStyleName(ClippyResources.I.css().control());
|
||||
|
||||
h.openElement("object");
|
||||
h.setWidth(SWF_WIDTH);
|
||||
|
||||
21
src/main/java/com/google/gwtexpui/clippy/client/clippy.css
Normal file
21
src/main/java/com/google/gwtexpui/clippy/client/clippy.css
Normal file
@@ -0,0 +1,21 @@
|
||||
/* Copyright (C) 2009 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.
|
||||
*/
|
||||
|
||||
.label {
|
||||
vertical-align: top;
|
||||
}
|
||||
.control {
|
||||
margin-left: 5px;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
.gwtexpui-Clippy {
|
||||
}
|
||||
.gwtexpui-Clippy-Label {
|
||||
vertical-align: top;
|
||||
}
|
||||
.gwtexpui-Clippy-Control {
|
||||
margin-left: 5px;
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<module>
|
||||
<inherits name='com.google.gwt.resources.Resources'/>
|
||||
<inherits name='com.google.gwtexpui.user.User'/>
|
||||
<inherits name='com.google.gwtexpui.safehtml.SafeHtml'/>
|
||||
<stylesheet src='gwtexpui_globalkey1.cache.css' />
|
||||
</module>
|
||||
|
||||
@@ -38,6 +38,10 @@ public class GlobalKey {
|
||||
private static CloseHandler<PopupPanel> restoreGlobal;
|
||||
private static Timer restoreTimer;
|
||||
|
||||
static {
|
||||
KeyResources.I.css().ensureInjected();
|
||||
}
|
||||
|
||||
private static void initEvents() {
|
||||
if (active == null) {
|
||||
DocWidget.get().addKeyPressHandler(new KeyPressHandler() {
|
||||
@@ -145,7 +149,7 @@ public class GlobalKey {
|
||||
State(final Widget r) {
|
||||
root = r;
|
||||
|
||||
app = new KeyCommandSet(Util.C.applicationSection());
|
||||
app = new KeyCommandSet(KeyConstants.I.applicationSection());
|
||||
app.add(ShowHelpCommand.INSTANCE);
|
||||
|
||||
all = new KeyCommandSet();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class HidePopupPanelCommand extends KeyCommand {
|
||||
private final PopupPanel panel;
|
||||
|
||||
public HidePopupPanelCommand(int mask, int key, PopupPanel panel) {
|
||||
super(mask, key, Util.C.closeCurrentDialog());
|
||||
super(mask, key, KeyConstants.I.closeCurrentDialog());
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ public abstract class KeyCommand implements KeyPressHandler {
|
||||
public static final int M_CTRL = 1 << 16;
|
||||
public static final int M_ALT = 2 << 16;
|
||||
public static final int M_META = 4 << 16;
|
||||
private static final String KS = "gwtexpui-globalkey-KeyboardShortcuts-Key";
|
||||
|
||||
public static boolean same(final KeyCommand a, final KeyCommand b) {
|
||||
return a.getClass() == b.getClass() && a.helpText.equals(b.helpText);
|
||||
@@ -51,26 +50,26 @@ public abstract class KeyCommand implements KeyPressHandler {
|
||||
final SafeHtmlBuilder b = new SafeHtmlBuilder();
|
||||
|
||||
if ((keyMask & M_CTRL) == M_CTRL) {
|
||||
modifier(b, Util.C.keyCtrl());
|
||||
modifier(b, KeyConstants.I.keyCtrl());
|
||||
}
|
||||
if ((keyMask & M_ALT) == M_ALT) {
|
||||
modifier(b, Util.C.keyAlt());
|
||||
modifier(b, KeyConstants.I.keyAlt());
|
||||
}
|
||||
if ((keyMask & M_META) == M_META) {
|
||||
modifier(b, Util.C.keyMeta());
|
||||
modifier(b, KeyConstants.I.keyMeta());
|
||||
}
|
||||
|
||||
final char c = (char) (keyMask & 0xffff);
|
||||
switch (c) {
|
||||
case KeyCodes.KEY_ENTER:
|
||||
namedKey(b, Util.C.keyEnter());
|
||||
namedKey(b, KeyConstants.I.keyEnter());
|
||||
break;
|
||||
case KeyCodes.KEY_ESCAPE:
|
||||
namedKey(b, Util.C.keyEsc());
|
||||
namedKey(b, KeyConstants.I.keyEsc());
|
||||
break;
|
||||
default:
|
||||
b.openSpan();
|
||||
b.setStyleName(KS);
|
||||
b.setStyleName(KeyResources.I.css().helpKey());
|
||||
b.append(String.valueOf(c));
|
||||
b.closeSpan();
|
||||
break;
|
||||
@@ -87,7 +86,7 @@ public abstract class KeyCommand implements KeyPressHandler {
|
||||
private void namedKey(final SafeHtmlBuilder b, final String name) {
|
||||
b.append('<');
|
||||
b.openSpan();
|
||||
b.setStyleName(KS);
|
||||
b.setStyleName(KeyResources.I.css().helpKey());
|
||||
b.append(name);
|
||||
b.closeSpan();
|
||||
b.append(">");
|
||||
|
||||
@@ -14,9 +14,12 @@
|
||||
|
||||
package com.google.gwtexpui.globalkey.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.i18n.client.Constants;
|
||||
|
||||
public interface KeyConstants extends Constants {
|
||||
public static final KeyConstants I = GWT.create(KeyConstants.class);
|
||||
|
||||
String applicationSection();
|
||||
String showHelp();
|
||||
String closeCurrentDialog();
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2009 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.gwtexpui.globalkey.client;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
public interface KeyCss extends CssResource {
|
||||
String helpPopup();
|
||||
String helpHeader();
|
||||
String helpHeaderGlue();
|
||||
String helpTable();
|
||||
String helpTableGlue();
|
||||
String helpGroup();
|
||||
String helpKeyStroke();
|
||||
String helpSeparator();
|
||||
String helpKey();
|
||||
}
|
||||
@@ -39,15 +39,13 @@ import java.util.List;
|
||||
|
||||
public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
KeyPressHandler {
|
||||
private static final String S = "gwtexpui-globalkey-KeyboardShortcuts";
|
||||
|
||||
private final FocusPanel focus;
|
||||
|
||||
public KeyHelpPopup() {
|
||||
super(true/* autohide */, true/* modal */);
|
||||
setStyleName(S);
|
||||
setStyleName(KeyResources.I.css().helpPopup());
|
||||
|
||||
final Anchor closer = new Anchor(Util.C.closeButton());
|
||||
final Anchor closer = new Anchor(KeyConstants.I.closeButton());
|
||||
closer.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(final ClickEvent event) {
|
||||
@@ -56,18 +54,19 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
});
|
||||
|
||||
final Grid header = new Grid(1, 3);
|
||||
header.setStyleName(S + "-Header");
|
||||
header.setText(0, 0, Util.C.keyboardShortcuts());
|
||||
header.setStyleName(KeyResources.I.css().helpHeader());
|
||||
header.setText(0, 0, KeyConstants.I.keyboardShortcuts());
|
||||
header.setWidget(0, 2, closer);
|
||||
|
||||
final CellFormatter fmt = header.getCellFormatter();
|
||||
fmt.addStyleName(0, 1, S + "-HeaderGlue");
|
||||
fmt.addStyleName(0, 1, KeyResources.I.css().helpHeaderGlue());
|
||||
fmt.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT);
|
||||
|
||||
final Grid lists = new Grid(0, 7);
|
||||
lists.setStyleName(S + "-Table");
|
||||
lists.setStyleName(KeyResources.I.css().helpTable());
|
||||
populate(lists);
|
||||
lists.getCellFormatter().addStyleName(0, 3, S + "-TableGlue");
|
||||
lists.getCellFormatter().addStyleName(0, 3,
|
||||
KeyResources.I.css().helpTableGlue());
|
||||
|
||||
final FlowPanel body = new FlowPanel();
|
||||
body.add(header);
|
||||
@@ -144,7 +143,8 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
lists.resizeRows(row + 1);
|
||||
}
|
||||
lists.setText(row, col + 2, set.getName());
|
||||
lists.getCellFormatter().addStyleName(row, col + 2, S + "-GroupTitle");
|
||||
lists.getCellFormatter().addStyleName(row, col + 2,
|
||||
KeyResources.I.css().helpGroup());
|
||||
row++;
|
||||
|
||||
return formatKeys(lists, row, col, set, null);
|
||||
@@ -173,12 +173,12 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
final SafeHtmlBuilder b = new SafeHtmlBuilder();
|
||||
b.append(SafeHtml.get(lists, r, col + 0));
|
||||
b.append(" ");
|
||||
b.append(Util.C.orOtherKey());
|
||||
b.append(KeyConstants.I.orOtherKey());
|
||||
b.append(" ");
|
||||
if (prefix != null) {
|
||||
b.append(prefix);
|
||||
b.append(" ");
|
||||
b.append(Util.C.thenOtherKey());
|
||||
b.append(KeyConstants.I.thenOtherKey());
|
||||
b.append(" ");
|
||||
}
|
||||
b.append(k.describeKeyStroke());
|
||||
@@ -191,7 +191,7 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
final SafeHtmlBuilder b = new SafeHtmlBuilder();
|
||||
b.append(prefix);
|
||||
b.append(" ");
|
||||
b.append(Util.C.thenOtherKey());
|
||||
b.append(KeyConstants.I.thenOtherKey());
|
||||
b.append(" ");
|
||||
b.append(k.describeKeyStroke());
|
||||
SafeHtml.set(lists, row, col + 0, b);
|
||||
@@ -201,8 +201,8 @@ public class KeyHelpPopup extends PluginSafePopupPanel implements
|
||||
lists.setText(row, col + 1, ":");
|
||||
lists.setText(row, col + 2, k.getHelpText());
|
||||
|
||||
fmt.addStyleName(row, col + 0, S + "-TableKeyStroke");
|
||||
fmt.addStyleName(row, col + 1, S + "-TableSeparator");
|
||||
fmt.addStyleName(row, col + 0, KeyResources.I.css().helpKeyStroke());
|
||||
fmt.addStyleName(row, col + 1, KeyResources.I.css().helpSeparator());
|
||||
row++;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
package com.google.gwtexpui.globalkey.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
|
||||
public class Util {
|
||||
public static final KeyConstants C = GWT.create(KeyConstants.class);
|
||||
public interface KeyResources extends ClientBundle {
|
||||
public static final KeyResources I = GWT.create(KeyResources.class);
|
||||
|
||||
private Util() {
|
||||
}
|
||||
@Source("key.css")
|
||||
KeyCss css();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class ShowHelpCommand extends KeyCommand {
|
||||
private static KeyHelpPopup current;
|
||||
|
||||
public ShowHelpCommand() {
|
||||
super(0, '?', Util.C.showHelp());
|
||||
super(0, '?', KeyConstants.I.showHelp());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
99
src/main/java/com/google/gwtexpui/globalkey/client/key.css
Normal file
99
src/main/java/com/google/gwtexpui/globalkey/client/key.css
Normal file
@@ -0,0 +1,99 @@
|
||||
/* Copyright (C) 2009 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.
|
||||
*/
|
||||
|
||||
@external .popupContent;
|
||||
|
||||
.helpPopup {
|
||||
background: #000000 none repeat scroll 0 50%;
|
||||
color: #ffffff;
|
||||
font-family: arial,sans-serif;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
text-shadow: 1px 1px 7px #000000;
|
||||
width: 92%;
|
||||
z-index: 1002;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
@if user.agent safari {
|
||||
.helpPopup {
|
||||
\-webkit-border-radius: 10px;
|
||||
}
|
||||
}
|
||||
@if user.agent gecko1_8 {
|
||||
.helpPopup {
|
||||
\-moz-border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.helpPopup .popupContent {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.helpPopup hr {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.helpHeader {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.helpHeader td {
|
||||
white-space: nowrap;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.helpHeader a,
|
||||
.helpHeader a:visited,
|
||||
.helpHeader a:hover {
|
||||
color: #dddd00;
|
||||
}
|
||||
|
||||
.helpHeaderGlue {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.helpTable {
|
||||
width: 90%;
|
||||
}
|
||||
.helpTable td {
|
||||
vertical-align: top;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.helpTableGlue {
|
||||
width: 25px;
|
||||
}
|
||||
|
||||
.helpGroup {
|
||||
color: #dddd00;
|
||||
padding-top: 0.8em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.helpKeyStroke {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.helpSeparator {
|
||||
width: 0.5em;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.helpKey {
|
||||
color: #dddd00;
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
.gwtexpui-globalkey-KeyboardShortcuts {
|
||||
background: #000000 none repeat scroll 0 50%;
|
||||
color: #ffffff;
|
||||
font-family: arial,sans-serif;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
text-shadow: 1px 1px 7px #000000;
|
||||
width: 92%;
|
||||
z-index: 1002;
|
||||
opacity: 0.85;
|
||||
-moz-border-radius-bottomleft: 10px;
|
||||
-moz-border-radius-bottomright: 10px;
|
||||
-moz-border-radius-topleft: 10px;
|
||||
-moz-border-radius-topright: 10px;
|
||||
}
|
||||
|
||||
.gwtexpui-globalkey-KeyboardShortcuts .popupContent {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.gwtexpui-globalkey-KeyboardShortcuts hr {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Header {
|
||||
width: 100%;
|
||||
}
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Header td {
|
||||
white-space: nowrap;
|
||||
color: #ffffff;
|
||||
}
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Header a,
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Header a:visited,
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Header a:hover {
|
||||
color: #dddd00;
|
||||
}
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-HeaderGlue {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-GroupTitle {
|
||||
color: #dddd00;
|
||||
padding-top: 0.8em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Table {
|
||||
width: 90%;
|
||||
}
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Table td {
|
||||
vertical-align: top;
|
||||
white-space: nowrap;
|
||||
}
|
||||
td.gwtexpui-globalkey-KeyboardShortcuts-TableKeyStroke {
|
||||
text-align: right;
|
||||
}
|
||||
td.gwtexpui-globalkey-KeyboardShortcuts-TableSeparator {
|
||||
width: 0.5em;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-TableGlue {
|
||||
width: 25px;
|
||||
}
|
||||
.gwtexpui-globalkey-KeyboardShortcuts-Key {
|
||||
color: #dddd00;
|
||||
}
|
||||
@@ -14,6 +14,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<module>
|
||||
<inherits name="com.google.gwtexpui.user.User"/>
|
||||
<stylesheet src='gwtexpui_progress1.cache.css' />
|
||||
<inherits name='com.google.gwt.resources.Resources'/>
|
||||
<inherits name="com.google.gwt.user.User"/>
|
||||
</module>
|
||||
|
||||
@@ -24,10 +24,12 @@ import com.google.gwt.user.client.ui.Label;
|
||||
* The bar is 200 pixels wide and 20 pixels high. To keep the implementation
|
||||
* simple and lightweight this dimensions are fixed and shouldn't be modified by
|
||||
* style overrides in client code or CSS.
|
||||
* <p>
|
||||
* Style name: <code>gwtexpui-ProgressMeter</code>
|
||||
*/
|
||||
public class ProgressBar extends Composite {
|
||||
static {
|
||||
ProgressResources.I.css().ensureInjected();
|
||||
}
|
||||
|
||||
private final String callerText;
|
||||
private final Label bar;
|
||||
private final Label msg;
|
||||
@@ -47,14 +49,14 @@ public class ProgressBar extends Composite {
|
||||
}
|
||||
|
||||
final FlowPanel body = new FlowPanel();
|
||||
body.setStyleName("gwtexpui-ProgressBar");
|
||||
body.setStyleName(ProgressResources.I.css().container());
|
||||
|
||||
msg = new Label(callerText);
|
||||
msg.setStyleName("gwtexpui-ProgressBar-Text");
|
||||
msg.setStyleName(ProgressResources.I.css().text());
|
||||
body.add(msg);
|
||||
|
||||
bar = new Label("");
|
||||
bar.setStyleName("gwtexpui-ProgressBar-Bar");
|
||||
bar.setStyleName(ProgressResources.I.css().bar());
|
||||
body.add(bar);
|
||||
|
||||
initWidget(body);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2009 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.gwtexpui.progress.client;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
public interface ProgressCss extends CssResource {
|
||||
String container();
|
||||
String text();
|
||||
String bar();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2009 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.gwtexpui.progress.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
|
||||
public interface ProgressResources extends ClientBundle {
|
||||
public static final ProgressResources I = GWT.create(ProgressResources.class);
|
||||
|
||||
@Source("progress.css")
|
||||
ProgressCss css();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* Copyright (C) 2009 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.
|
||||
*/
|
||||
|
||||
.container {
|
||||
position: relative;
|
||||
border: 1px solid #6B90DA;
|
||||
height: 20px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.text {
|
||||
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;
|
||||
}
|
||||
|
||||
.bar {
|
||||
background: #F0F7F9;
|
||||
border-right: 1px solid #D0D7D9;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 20px;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
.gwtexpui-ProgressBar {
|
||||
position: relative;
|
||||
border: 1px solid #6B90DA;
|
||||
height: 20px;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.gwtexpui-ProgressBar-Text {
|
||||
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;
|
||||
}
|
||||
|
||||
.gwtexpui-ProgressBar-Bar {
|
||||
background: #F0F7F9;
|
||||
border-right: 1px solid #D0D7D9;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 20px;
|
||||
}
|
||||
@@ -14,6 +14,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<module>
|
||||
<inherits name='com.google.gwt.resources.Resources'/>
|
||||
<inherits name="com.google.gwt.user.User"/>
|
||||
<stylesheet src="gwtexpui_safehtml1.cache.css" />
|
||||
</module>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gwtexpui.safehtml.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.DOM;
|
||||
import com.google.gwt.user.client.Element;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
@@ -26,6 +27,43 @@ import java.util.List;
|
||||
|
||||
/** Immutable string safely placed as HTML without further escaping. */
|
||||
public abstract class SafeHtml {
|
||||
public static final SafeHtmlResources RESOURCES;
|
||||
|
||||
static {
|
||||
if (GWT.isClient()) {
|
||||
RESOURCES = GWT.create(SafeHtmlResources.class);
|
||||
RESOURCES.css().ensureInjected();
|
||||
|
||||
} else {
|
||||
RESOURCES = new SafeHtmlResources() {
|
||||
@Override
|
||||
public SafeHtmlCss css() {
|
||||
return new SafeHtmlCss() {
|
||||
public String wikiList() {
|
||||
return "wikiList";
|
||||
}
|
||||
|
||||
public String wikiPreFormat() {
|
||||
return "wikiPreFormat";
|
||||
}
|
||||
|
||||
public boolean ensureInjected() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/** @return the existing HTML property of a widget. */
|
||||
public static SafeHtml get(final HasHTML t) {
|
||||
return new SafeHtmlString(t.getHTML());
|
||||
@@ -89,13 +127,7 @@ public abstract class SafeHtml {
|
||||
* Apply {@link #linkify()}, and "\n\n" to <p>.
|
||||
* <p>
|
||||
* Lines that start with whitespace are assumed to be preformatted, and are
|
||||
* formatted by the <code>gwtexpui-SafeHtml-WikiPreFormat</code> CSS class. By
|
||||
* default this class is:
|
||||
*
|
||||
* <pre>
|
||||
* white-space: pre;
|
||||
* font-family: monospace;
|
||||
* </pre>
|
||||
* formatted by the {@link SafeHtmlCss#wikiPreFormat()} CSS class.
|
||||
*/
|
||||
public SafeHtml wikify() {
|
||||
final SafeHtmlBuilder r = new SafeHtmlBuilder();
|
||||
@@ -104,7 +136,7 @@ public abstract class SafeHtml {
|
||||
r.openElement("p");
|
||||
for (final String line : p.split("\n")) {
|
||||
r.openSpan();
|
||||
r.setStyleName("gwtexpui-SafeHtml-WikiPreFormat");
|
||||
r.setStyleName(RESOURCES.css().wikiPreFormat());
|
||||
r.append(asis(line));
|
||||
r.closeSpan();
|
||||
r.br();
|
||||
@@ -136,7 +168,7 @@ public abstract class SafeHtml {
|
||||
|
||||
in_ul = true;
|
||||
r.openElement("ul");
|
||||
r.setStyleName("gwtexpui-SafeHtml-WikiList");
|
||||
r.setStyleName(RESOURCES.css().wikiList());
|
||||
}
|
||||
line = line.substring(1).trim();
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2009 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.gwtexpui.safehtml.client;
|
||||
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
|
||||
public interface SafeHtmlCss extends CssResource {
|
||||
String wikiPreFormat();
|
||||
String wikiList();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2009 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.gwtexpui.safehtml.client;
|
||||
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
|
||||
public interface SafeHtmlResources extends ClientBundle {
|
||||
@Source("safehtml.css")
|
||||
SafeHtmlCss css();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/* Copyright (C) 2009 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.
|
||||
*/
|
||||
|
||||
.wikiPreFormat {
|
||||
white-space: pre;
|
||||
font-family: monospace;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.wikiList {
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
.gwtexpui-SafeHtml-WikiPreFormat {
|
||||
white-space: pre;
|
||||
font-family: monospace;
|
||||
font-size: small;
|
||||
}
|
||||
@@ -17,7 +17,7 @@ package com.google.gwtexpui.safehtml.client;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SafeHtml_WikifyListTest extends TestCase {
|
||||
private static final String BEGIN_LIST = "<ul class=\"gwtexpui-SafeHtml-WikiList\">";
|
||||
private static final String BEGIN_LIST = "<ul class=\"wikiList\">";
|
||||
private static final String END_LIST = "</ul>";
|
||||
|
||||
private static String item(String raw) {
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.google.gwtexpui.safehtml.client;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SafeHtml_WikifyPreformatTest extends TestCase {
|
||||
private static final String B = "<span class=\"gwtexpui-SafeHtml-WikiPreFormat\">";
|
||||
private static final String B = "<span class=\"wikiPreFormat\">";
|
||||
private static final String E = "</span><br />";
|
||||
|
||||
private static String pre(String raw) {
|
||||
|
||||
Reference in New Issue
Block a user