Skip to content

Commit 196bd13

Browse files
committed
Update UILoader.
1 parent 97112b1 commit 196bd13

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ The "group" attribute associates a button with a button group. For example, the
250250
<img src="README/orientation.png" width="454px"/>
251251

252252
### Tabbed Panes
253-
When used in conjunction with `JTabbedPane`, the "title" and "icon" attributes can be used to specify a component's title and icon, respectively:
253+
When used in conjunction with `JTabbedPane`, the "tabTitle" and "tabIcon" attributes can be used to specify a component's tab title and icon, respectively:
254254

255255
```xml
256256
<tabbed-pane name="tabbedPane" tabPlacement="top" tabLayoutPolicy="scroll-tab-layout">
257-
<label title="Tab 1" icon="home_18dp.svg"
257+
<label tabTitle="Tab 1" tabIcon="home_18dp.svg"
258258
text="This is the first tab."
259259
horizontalAlignment="center"
260260
verticalAlignment="center"/>

sierra-test/src/main/resources/org/httprpc/sierra/test/RootPaneTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</scroll-pane>
99

1010
<tabbed-pane name="tabbedPane" tabPlacement="top" tabLayoutPolicy="scroll-tab-layout">
11-
<label title="Tab 1" icon="home_18dp.svg"
11+
<label tabTitle="Tab 1" tabIcon="home_18dp.svg"
1212
text="This is the first tab."
1313
horizontalAlignment="center"
1414
verticalAlignment="center"/>

sierra.dtd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!ENTITY % org.httprpc.sierra.UILoader "name CDATA group CDATA border CDATA padding CDATA weight CDATA size CDATA title CDATA icon CDATA style CDATA styleClass CDATA ">
1+
<!ENTITY % org.httprpc.sierra.UILoader "name CDATA group CDATA border CDATA padding CDATA weight CDATA size CDATA tabTitle CDATA tabIcon CDATA style CDATA styleClass CDATA ">
22
<!ENTITY % java.awt.Component "%org.httprpc.sierra.UILoader; background CDATA enabled (true|false) focusTraversalKeysEnabled (true|false) focusable (true|false) font CDATA foreground CDATA ignoreRepaint (true|false) name CDATA visible (true|false) ">
33
<!ENTITY % java.awt.Container "%java.awt.Component; focusCycleRoot (true|false) focusTraversalPolicyProvider (true|false) font CDATA ">
44
<!ENTITY % javax.swing.JComponent "%java.awt.Container; alignmentX CDATA alignmentY CDATA autoscrolls (true|false) background CDATA debugGraphicsOptions CDATA doubleBuffered (true|false) enabled (true|false) font CDATA foreground CDATA inheritsPopupMenu (true|false) opaque (true|false) requestFocusEnabled (true|false) toolTipText CDATA verifyInputWhenFocusTarget (true|false) visible (true|false) ">

sierra/src/main/java/org/httprpc/sierra/UILoader.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ public void write(Void value, Writer writer) throws IOException {
149149
appendAttributeDeclaration(WEIGHT, CDATA, writer);
150150
appendAttributeDeclaration(SIZE, CDATA, writer);
151151

152-
appendAttributeDeclaration(TITLE, CDATA, writer);
153-
appendAttributeDeclaration(ICON, CDATA, writer);
152+
appendAttributeDeclaration(TAB_TITLE, CDATA, writer);
153+
appendAttributeDeclaration(TAB_ICON, CDATA, writer);
154154

155155
appendAttributeDeclaration(STYLE, CDATA, writer);
156156
appendAttributeDeclaration(STYLE_CLASS, CDATA, writer);
@@ -337,8 +337,9 @@ void declareAttributeList(String tag, Class<?> type, Writer writer) throws IOExc
337337
private static final String PADDING = "padding";
338338
private static final String WEIGHT = "weight";
339339
private static final String SIZE = "size";
340-
private static final String TITLE = "title";
341-
private static final String ICON = "icon";
340+
341+
private static final String TAB_TITLE = "tabTitle";
342+
private static final String TAB_ICON = "tabIcon";
342343

343344
private static final String STYLE = "style";
344345
private static final String STYLE_CLASS = "styleClass";
@@ -674,8 +675,8 @@ private void processStartElement(XMLStreamReader xmlStreamReader) {
674675

675676
Object constraints = null;
676677

677-
String title = null;
678-
Icon icon = null;
678+
String tabTitle = null;
679+
Icon tabIcon = null;
679680

680681
for (int i = 0, n = xmlStreamReader.getAttributeCount(); i < n; i++) {
681682
var name = xmlStreamReader.getAttributeLocalName(i);
@@ -723,10 +724,10 @@ private void processStartElement(XMLStreamReader xmlStreamReader) {
723724
constraints = weight;
724725
} else if (name.equals(SIZE)) {
725726
component.setPreferredSize(parseSize(value));
726-
} else if (name.equals(TITLE)) {
727-
title = getText(value);
728-
} else if (name.equals(ICON)) {
729-
icon = getIcon(value);
727+
} else if (name.equals(TAB_TITLE)) {
728+
tabTitle = getText(value);
729+
} else if (name.equals(TAB_ICON)) {
730+
tabIcon = getIcon(value);
730731
} else if (name.equals(STYLE) || name.equals(STYLE_CLASS)) {
731732
component.putClientProperty(String.format("FlatLaf.%s", name), value);
732733
} else if (name.equals(PLACEHOLDER_TEXT)) {
@@ -833,7 +834,7 @@ private void processStartElement(XMLStreamReader xmlStreamReader) {
833834
throw new UnsupportedOperationException("Unexpected split pane content.");
834835
}
835836
} else if (parent instanceof JTabbedPane tabbedPane) {
836-
tabbedPane.addTab(title, icon, component);
837+
tabbedPane.addTab(tabTitle, tabIcon, component);
837838
} else if (parent instanceof JMenuBar || parent instanceof JMenu || parent instanceof JToolBar) {
838839
parent.add(component);
839840
} else {

0 commit comments

Comments
 (0)