Switch all CSS to use CssResource
Change-Id: I72600495e15c094afcd9bbb10b11469a2c096ece
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gwtexpui/clippy/Clippy.gwt.xml b/src/main/java/com/google/gwtexpui/clippy/Clippy.gwt.xml
index b5d4a16..0e9b072 100644
--- a/src/main/java/com/google/gwtexpui/clippy/Clippy.gwt.xml
+++ b/src/main/java/com/google/gwtexpui/clippy/Clippy.gwt.xml
@@ -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>
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/clippy/client/ClippyCss.java
similarity index 75%
copy from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
copy to src/main/java/com/google/gwtexpui/clippy/client/ClippyCss.java
index 50280db..68495e8 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/clippy/client/ClippyCss.java
@@ -12,13 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtexpui.globalkey.client;
+package com.google.gwtexpui.clippy.client;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.CssResource;
-public class Util {
- public static final KeyConstants C = GWT.create(KeyConstants.class);
-
- private Util() {
- }
+public interface ClippyCss extends CssResource {
+ String label();
+ String control();
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/clippy/client/ClippyResources.java
similarity index 70%
copy from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
copy to src/main/java/com/google/gwtexpui/clippy/client/ClippyResources.java
index 50280db..4c2b898 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/clippy/client/ClippyResources.java
@@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtexpui.globalkey.client;
+package com.google.gwtexpui.clippy.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 ClippyResources extends ClientBundle {
+ public static final ClippyResources I = GWT.create(ClippyResources.class);
- private Util() {
- }
+ @Source("clippy.css")
+ ClippyCss css();
}
diff --git a/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java b/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java
index f5595c9..60a988b 100644
--- a/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java
+++ b/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java
@@ -43,8 +43,6 @@
* 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 @@
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 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 @@
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);
diff --git a/src/main/java/com/google/gwtexpui/clippy/client/clippy.css b/src/main/java/com/google/gwtexpui/clippy/client/clippy.css
new file mode 100644
index 0000000..3cf7b90
--- /dev/null
+++ b/src/main/java/com/google/gwtexpui/clippy/client/clippy.css
@@ -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;
+}
diff --git a/src/main/java/com/google/gwtexpui/clippy/public/gwtexpui_clippy1.cache.css b/src/main/java/com/google/gwtexpui/clippy/public/gwtexpui_clippy1.cache.css
deleted file mode 100644
index 25ca9e8..0000000
--- a/src/main/java/com/google/gwtexpui/clippy/public/gwtexpui_clippy1.cache.css
+++ /dev/null
@@ -1,8 +0,0 @@
-.gwtexpui-Clippy {
-}
-.gwtexpui-Clippy-Label {
- vertical-align: top;
-}
-.gwtexpui-Clippy-Control {
- margin-left: 5px;
-}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/GlobalKey.gwt.xml b/src/main/java/com/google/gwtexpui/globalkey/GlobalKey.gwt.xml
index 8a6190a..771050f 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/GlobalKey.gwt.xml
+++ b/src/main/java/com/google/gwtexpui/globalkey/GlobalKey.gwt.xml
@@ -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>
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java b/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java
index a50f205..1eaaa3c 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/GlobalKey.java
@@ -38,6 +38,10 @@
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 @@
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();
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java b/src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java
index 6d9c50e..0274b9d 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/HidePopupPanelCommand.java
@@ -22,7 +22,7 @@
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;
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/KeyCommand.java b/src/main/java/com/google/gwtexpui/globalkey/client/KeyCommand.java
index 7ba7b27..ba4f626 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/KeyCommand.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/KeyCommand.java
@@ -24,7 +24,6 @@
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 @@
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 @@
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(">");
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/KeyConstants.java b/src/main/java/com/google/gwtexpui/globalkey/client/KeyConstants.java
index 802e349..56fb85c 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/KeyConstants.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/KeyConstants.java
@@ -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();
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/globalkey/client/KeyCss.java
similarity index 67%
copy from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
copy to src/main/java/com/google/gwtexpui/globalkey/client/KeyCss.java
index 50280db..d19018d 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/KeyCss.java
@@ -14,11 +14,16 @@
package com.google.gwtexpui.globalkey.client;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.CssResource;
-public class Util {
- public static final KeyConstants C = GWT.create(KeyConstants.class);
-
- private Util() {
- }
+public interface KeyCss extends CssResource {
+ String helpPopup();
+ String helpHeader();
+ String helpHeaderGlue();
+ String helpTable();
+ String helpTableGlue();
+ String helpGroup();
+ String helpKeyStroke();
+ String helpSeparator();
+ String helpKey();
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java b/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java
index 66dd6df..26fefbe 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/KeyHelpPopup.java
@@ -39,15 +39,13 @@
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 @@
});
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 @@
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 @@
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 @@
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 @@
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++;
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/globalkey/client/KeyResources.java
similarity index 77%
rename from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
rename to src/main/java/com/google/gwtexpui/globalkey/client/KeyResources.java
index 50280db..a52ca2a 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/KeyResources.java
@@ -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();
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java b/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java
index c4fa6c0..50a4a86 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/ShowHelpCommand.java
@@ -27,7 +27,7 @@
private static KeyHelpPopup current;
public ShowHelpCommand() {
- super(0, '?', Util.C.showHelp());
+ super(0, '?', KeyConstants.I.showHelp());
}
@Override
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/key.css b/src/main/java/com/google/gwtexpui/globalkey/client/key.css
new file mode 100644
index 0000000..f3fd445
--- /dev/null
+++ b/src/main/java/com/google/gwtexpui/globalkey/client/key.css
@@ -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;
+}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/public/gwtexpui_globalkey1.cache.css b/src/main/java/com/google/gwtexpui/globalkey/public/gwtexpui_globalkey1.cache.css
deleted file mode 100644
index df9ad44..0000000
--- a/src/main/java/com/google/gwtexpui/globalkey/public/gwtexpui_globalkey1.cache.css
+++ /dev/null
@@ -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;
-}
diff --git a/src/main/java/com/google/gwtexpui/progress/Progress.gwt.xml b/src/main/java/com/google/gwtexpui/progress/Progress.gwt.xml
index e878c4c..0df8928 100644
--- a/src/main/java/com/google/gwtexpui/progress/Progress.gwt.xml
+++ b/src/main/java/com/google/gwtexpui/progress/Progress.gwt.xml
@@ -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>
diff --git a/src/main/java/com/google/gwtexpui/progress/client/ProgressBar.java b/src/main/java/com/google/gwtexpui/progress/client/ProgressBar.java
index 1d37711..5e13f55 100644
--- a/src/main/java/com/google/gwtexpui/progress/client/ProgressBar.java
+++ b/src/main/java/com/google/gwtexpui/progress/client/ProgressBar.java
@@ -24,10 +24,12 @@
* 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 @@
}
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);
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/progress/client/ProgressCss.java
similarity index 74%
copy from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
copy to src/main/java/com/google/gwtexpui/progress/client/ProgressCss.java
index 50280db..9de2748 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/progress/client/ProgressCss.java
@@ -12,13 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtexpui.globalkey.client;
+package com.google.gwtexpui.progress.client;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.CssResource;
-public class Util {
- public static final KeyConstants C = GWT.create(KeyConstants.class);
-
- private Util() {
- }
+public interface ProgressCss extends CssResource {
+ String container();
+ String text();
+ String bar();
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/progress/client/ProgressResources.java
similarity index 69%
copy from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
copy to src/main/java/com/google/gwtexpui/progress/client/ProgressResources.java
index 50280db..0276e9a 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/progress/client/ProgressResources.java
@@ -12,13 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtexpui.globalkey.client;
+package com.google.gwtexpui.progress.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 ProgressResources extends ClientBundle {
+ public static final ProgressResources I = GWT.create(ProgressResources.class);
- private Util() {
- }
+ @Source("progress.css")
+ ProgressCss css();
}
diff --git a/src/main/java/com/google/gwtexpui/progress/client/progress.css b/src/main/java/com/google/gwtexpui/progress/client/progress.css
new file mode 100644
index 0000000..a0c15a0
--- /dev/null
+++ b/src/main/java/com/google/gwtexpui/progress/client/progress.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;
+}
diff --git a/src/main/java/com/google/gwtexpui/progress/public/gwtexpui_progress1.cache.css b/src/main/java/com/google/gwtexpui/progress/public/gwtexpui_progress1.cache.css
deleted file mode 100644
index 347df36..0000000
--- a/src/main/java/com/google/gwtexpui/progress/public/gwtexpui_progress1.cache.css
+++ /dev/null
@@ -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;
-}
diff --git a/src/main/java/com/google/gwtexpui/safehtml/SafeHtml.gwt.xml b/src/main/java/com/google/gwtexpui/safehtml/SafeHtml.gwt.xml
index 3d5d5d8..0df8928 100644
--- a/src/main/java/com/google/gwtexpui/safehtml/SafeHtml.gwt.xml
+++ b/src/main/java/com/google/gwtexpui/safehtml/SafeHtml.gwt.xml
@@ -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>
diff --git a/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
index cfe573c..8ab015e 100644
--- a/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
+++ b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtml.java
@@ -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 @@
/** 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 @@
* 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 @@
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 @@
in_ul = true;
r.openElement("ul");
- r.setStyleName("gwtexpui-SafeHtml-WikiList");
+ r.setStyleName(RESOURCES.css().wikiList());
}
line = line.substring(1).trim();
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtmlCss.java
similarity index 74%
copy from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
copy to src/main/java/com/google/gwtexpui/safehtml/client/SafeHtmlCss.java
index 50280db..f6836a0 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtmlCss.java
@@ -12,13 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtexpui.globalkey.client;
+package com.google.gwtexpui.safehtml.client;
-import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.CssResource;
-public class Util {
- public static final KeyConstants C = GWT.create(KeyConstants.class);
-
- private Util() {
- }
+public interface SafeHtmlCss extends CssResource {
+ String wikiPreFormat();
+ String wikiList();
}
diff --git a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtmlResources.java
similarity index 74%
copy from src/main/java/com/google/gwtexpui/globalkey/client/Util.java
copy to src/main/java/com/google/gwtexpui/safehtml/client/SafeHtmlResources.java
index 50280db..e3f5724 100644
--- a/src/main/java/com/google/gwtexpui/globalkey/client/Util.java
+++ b/src/main/java/com/google/gwtexpui/safehtml/client/SafeHtmlResources.java
@@ -12,13 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtexpui.globalkey.client;
+package com.google.gwtexpui.safehtml.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);
-
- private Util() {
- }
+public interface SafeHtmlResources extends ClientBundle {
+ @Source("safehtml.css")
+ SafeHtmlCss css();
}
diff --git a/src/main/java/com/google/gwtexpui/safehtml/client/safehtml.css b/src/main/java/com/google/gwtexpui/safehtml/client/safehtml.css
new file mode 100644
index 0000000..0db8116
--- /dev/null
+++ b/src/main/java/com/google/gwtexpui/safehtml/client/safehtml.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 {
+}
diff --git a/src/main/java/com/google/gwtexpui/safehtml/public/gwtexpui_safehtml1.cache.css b/src/main/java/com/google/gwtexpui/safehtml/public/gwtexpui_safehtml1.cache.css
deleted file mode 100644
index 029e301..0000000
--- a/src/main/java/com/google/gwtexpui/safehtml/public/gwtexpui_safehtml1.cache.css
+++ /dev/null
@@ -1,5 +0,0 @@
-.gwtexpui-SafeHtml-WikiPreFormat {
- white-space: pre;
- font-family: monospace;
- font-size: small;
-}
diff --git a/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyListTest.java b/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyListTest.java
index 672a63b..250a1b5 100644
--- a/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyListTest.java
+++ b/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyListTest.java
@@ -17,7 +17,7 @@
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) {
diff --git a/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyPreformatTest.java b/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyPreformatTest.java
index 27e7565..cbb315b 100644
--- a/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyPreformatTest.java
+++ b/src/test/java/com/google/gwtexpui/safehtml/client/SafeHtml_WikifyPreformatTest.java
@@ -17,7 +17,7 @@
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) {