Actions
and ActionCommand
attributes
12 | *
13 | * @author Wolf Paulus
14 | * @version $Revision: 1.1 $
15 | * @since swixml #065
16 | */
17 | public class Actions extends WindowAdapter implements ActionListener {
18 | private SwingEngine swix;
19 |
20 | public JMenuItem mi_exit, mi_save;
21 | public JPanel pnl_North;
22 | //
23 | // For every Actions, there needs to be a
24 | // public AbstractAction member variables with an anonymous inner class instantiation
25 | //
26 |
27 | /** Action
newAction handles the new action attribute */
28 | public Action newAction = new AbstractAction() {
29 |
30 | public void actionPerformed(ActionEvent e) {
31 | System.out.println( "New" ); // show the access outer class member ..
32 | this.setEnabled( false ); // disables ALL buttons that are tied to this action
33 | }
34 | };
35 |
36 | /** Action
modifyAction handles the modify action attribute */
37 | public Action openAction = new AbstractAction() {
38 | /** Invoked when an action occurs. */
39 | public void actionPerformed(ActionEvent e) {
40 | System.out.println( "Open" );
41 | }
42 | };
43 |
44 | /** Action
petAction handles the combobox */
45 | public Action petAction = new AbstractAction() {
46 | public void actionPerformed(ActionEvent e) {
47 | System.out.println( ((JComboBox) e.getSource()).getSelectedItem().toString() );
48 | }
49 | };
50 |
51 |
52 | /**
53 | * Constructs a new Actions object, registering action handlers for center_panel components.
54 | */
55 | private Actions() {
56 | try {
57 | swix = new SwingEngine( this );
58 | swix.render( "xml/actions.xml" );
59 |
60 | // at this point all AbstractActions are linked with the button etc.
61 | // ActionCommands however need to be linked manually, see below ...
62 |
63 | // add this class as an action listener to all buttons inside the panel with the id = center_panel
64 | swix.setActionListener( pnl_North, this );
65 | // add this class as an action listener to MenuItem with the id = mi_exit.
66 | mi_exit.addActionListener( this );
67 | // add this class as an action listener to MenuItem with the id = mi_save
68 | mi_save.addActionListener( this );
69 | //
70 | // Note, the mi_about MenuItem was not linked at all so far. Therefore, no action is performed when this
71 | // menu item gets requested.
72 | // The Toolbar button with the Actions="newAction" attribute is covered twice,
73 | // during parsing the AbstactAction newAction is linked in and later, the setActionListener() adds
74 | // this object's actionPerformed(). Therefore, when clicked, both actionPerformed() methods are getting called
75 | //
76 | swix.getRootComponent().setVisible(true);
77 | } catch (Exception e) {
78 | e.printStackTrace();
79 | }
80 | }
81 |
82 | //
83 | // Implement ActionListener
84 | //
85 |
86 | /**
87 | * Invoked when an action occurs.
88 | */
89 | public void actionPerformed(ActionEvent e) {
90 | String command = e.getActionCommand();
91 | if ("AC_EXIT".equals( command )) {
92 | this.windowClosing( null );
93 | } else if ("AC_SAVE".equals( command )) {
94 | System.out.println( "Save" );
95 | } else {
96 | System.out.println( "Click" );
97 | }
98 | }
99 |
100 | //
101 | // Overwrite Superclass implementation
102 | //
103 |
104 | /**
105 | * Invoked when the user attempts to close the window
106 | * from the window's system menu. If the program does not
107 | * explicitly hide or dispose the window while processing
108 | * this event, the window close operation will be cancelled.
109 | */
110 | public void windowClosing(WindowEvent e) {
111 | System.out.println( "Good Bye!" );
112 | super.windowClosing(e);
113 | System.exit( 0 );
114 | }
115 |
116 | //
117 | // Make the class bootable
118 | //
119 |
120 | public static void main(String[] args) {
121 | SwingEngine.DEBUG_MODE=true;
122 | new Actions();
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/samples/Cards.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import javax.swing.*;
5 | import java.awt.*;
6 | import java.awt.event.ActionEvent;
7 |
8 | /**
9 | * The Cards
class shows an example for the usage of a CardLayout.
10 | *
11 | * @author Wolf Paulus
12 | * @version $Revision: 1.1 $
13 | *
14 | * @since swixml #109
15 | */
16 | public class Cards {
17 |
18 | private static final String DESCRIPTOR = "xml/cards.xml";
19 | private SwingEngine swix = new SwingEngine( this );
20 |
21 | /** panel with a CardLayout */
22 | public JPanel pnl;
23 |
24 | private Cards() throws Exception {
25 | swix.render( Cards.DESCRIPTOR ).setVisible( true );
26 | this.showAction.actionPerformed( null );
27 | }
28 |
29 | /** shows the next card */
30 | public Action nextAction = new AbstractAction() {
31 | public void actionPerformed( ActionEvent e ) {
32 | CardLayout cl = (CardLayout) ( pnl.getLayout() );
33 | cl.next( pnl );
34 | }
35 | };
36 |
37 | /** shows the card with the id requested in the actioncommand */
38 | public Action showAction = new AbstractAction() {
39 | public void actionPerformed( ActionEvent e ) {
40 | //System.err.println( "ActionCommand=" + e.getActionCommand() );
41 | CardLayout cl = (CardLayout) ( pnl.getLayout() );
42 | if (e!=null) {
43 | cl.show( pnl, e.getActionCommand() );
44 | }
45 | }
46 | };
47 |
48 | public static void main( String[] args ) {
49 | try {
50 | new Cards();
51 | } catch (Exception e) {
52 | System.err.println( e.getMessage() );
53 | }
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/samples/ClientAttr.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import javax.swing.*;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.WindowAdapter;
7 |
8 | /**
9 | * The ClientAttr shows in the usage of client attributes in swixml tags.
10 | *
11 | * @author Wolf Paulus
12 | * @version $Revision: 1.1 $
13 | *
14 | * @since swixml 0.98
15 | */
16 | public class ClientAttr extends WindowAdapter {
17 | private SwingEngine swix = new SwingEngine( this );
18 |
19 | public JButton btn;
20 | public JTextArea ta;
21 | public Action show = new AbstractAction() {
22 | public void actionPerformed( ActionEvent e ) {
23 | ta.setText( "X:" + btn.getClientProperty( "X" ) + "\n" + "Y:" + btn.getClientProperty( "Y" ) );
24 | }
25 | };
26 |
27 | private ClientAttr() {
28 | try {
29 | swix.render( "xml/clientattr.xml" ).setVisible( true );
30 | swix.forget( "x" );
31 | } catch (Exception e) {
32 | e.printStackTrace();
33 | }
34 | }
35 |
36 | public static void main( String[] args ) {
37 | new ClientAttr();
38 | }
39 | }
--------------------------------------------------------------------------------
/samples/ComboModel.java:
--------------------------------------------------------------------------------
1 |
2 | import javax.swing.*;
3 |
4 | /**
5 | * Combobox Model used in the InitClass sample.
6 | */
7 | public class ComboModel extends DefaultComboBoxModel {
8 | /**
9 | * Constructs a DefaultComboBoxModel object.
10 | */
11 | public ComboModel() {
12 | super( new Object[]{"Bird", "Cat", "Dog", "Rabbit", "Pig"} );
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/samples/CustomTags.java:
--------------------------------------------------------------------------------
1 | import com.toedter.calendar.*;
2 | import org.swixml.SwingEngine;
3 |
4 | import java.awt.event.WindowAdapter;
5 | import java.awt.event.WindowEvent;
6 |
7 | public class CustomTags extends WindowAdapter {
8 |
9 |
10 | public CustomTags() throws Exception {
11 | SwingEngine swix = new SwingEngine(this);
12 | swix.getTaglib().registerTag("Calendar", JCalendar.class);
13 | swix.render("xml/customtags.xml").setVisible(true);
14 | }
15 |
16 | /**
17 | * Invoked when a window is in the process of being closed.
18 | * The close operation can be overridden at this point.
19 | */
20 | public void windowClosing(WindowEvent e) {
21 | super.windowClosing(e);
22 | System.exit(0);
23 | }
24 |
25 | //
26 | // Make the class bootable
27 | //
28 | public static void main(String[] args) throws Exception {
29 | new CustomTags();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/samples/ExitAction.java:
--------------------------------------------------------------------------------
1 | import java.awt.event.ActionEvent;
2 |
3 | import javax.swing.AbstractAction;
4 |
5 | /**
6 | * Simple Action to exit a program.
7 | *
8 | * This is intended for usage in swixml xml descriptors and may be instantiated through
9 | * initclass="ExitAction"
for arbitary enclosing {@link javax.swing.AbstractButton}
10 | * objects.
11 | */
12 | public class ExitAction extends AbstractAction {
13 | public void actionPerformed(ActionEvent e) {
14 | System.exit(0);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/samples/Form.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 |
5 | /**
6 | * The Form class shows how to do a simple JGoodies FormLayout
7 | */
8 | public class Form extends SwingEngine {
9 | /** Default ctor for a SwingEngine. */
10 |
11 | private Form() {
12 | try {
13 | render( "xml/form.xml" ).setVisible( true );
14 | } catch (Exception e) {
15 | e.printStackTrace();
16 | }
17 | }
18 |
19 | public static void main(String[] args) {
20 | new Form();
21 | }
22 | }
--------------------------------------------------------------------------------
/samples/FormLayout.java:
--------------------------------------------------------------------------------
1 | import org.swixml.SwingEngine;
2 |
3 | /**
4 | * The Layout class shows the use of layout managers
5 | *
6 | * @author Wolf Paulus
7 | * @version $Revision: 1.1 $
8 | *
9 | * @since swixml (#151)
10 | */
11 | public class FormLayout {
12 | private static final String DESCRIPTOR = "xml/formlayout.xml";
13 |
14 | private FormLayout() throws Exception {
15 | new SwingEngine( this ).render( FormLayout.DESCRIPTOR ).setVisible( true );
16 | }
17 |
18 | public static void main( String[] args ) {
19 | try {
20 | new FormLayout();
21 | } catch (Exception e) {
22 | System.err.println( e.getMessage() );
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/samples/GridBag.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 |
5 | /**
6 | * The GridBag class shows how to do a simple GridBag layout
7 | *
8 | * @author Wolf Paulus
9 | * @version $Revision: 1.1 $
10 | *
11 | * @since swixml 0.5
12 | */
13 | public class GridBag extends SwingEngine {
14 | /** Default ctor for a SwingEngine. */
15 |
16 | private GridBag() {
17 | try {
18 | render( "xml/gridbag.xml" ).setVisible( true );
19 | } catch (Exception e) {
20 | e.printStackTrace();
21 | }
22 | }
23 |
24 | public static void main(String[] args) {
25 | new GridBag();
26 | }
27 | }
--------------------------------------------------------------------------------
/samples/HelloList.java:
--------------------------------------------------------------------------------
1 | import org.swixml.SwingEngine;
2 |
3 | import javax.swing.JList;
4 | import java.awt.event.WindowAdapter;
5 | import java.awt.event.WindowEvent;
6 | import javax.swing.event.ListSelectionListener;
7 | import javax.swing.event.ListSelectionEvent;
8 |
9 | public class HelloList extends WindowAdapter {
10 |
11 | private JList mList; /*instantiated by swixml when rendering the UI */
12 |
13 | private HelloList() throws Exception {
14 | new SwingEngine( this ).render( "./xml/hellolist.xml" ).setVisible( true );
15 | System.out.println( mList.size() );
16 | mList.addListSelectionListener( new ListSelectionListener() {
17 | public void valueChanged( final ListSelectionEvent e) {
18 | System.out.println( mList.getSelectedValue() );
19 | }
20 | });
21 | }
22 |
23 | /**
24 | * Invoked when a window is in the process of being closed.
25 | * The close operation can be overridden at this point.
26 | */
27 | public void windowClosing(final WindowEvent e) {
28 | super.windowClosing(e);
29 | System.exit(0);
30 | }
31 |
32 | /** Makes the class bootable */
33 | public static void main( final String[] args ) throws Exception {
34 | new HelloList();
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/samples/HelloMac.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import javax.swing.*;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.WindowEvent;
7 | import java.awt.event.WindowAdapter;
8 | import java.io.IOException;
9 |
10 | import com.apple.eio.FileManager;
11 |
12 | /**
13 | * The HelloMac class shows a couple of the Mac specifics exposed
14 | * HeeloMac
renders the GUI, which is described in hellomac.xml
15 | *
16 | * @author Wolf Paulus
17 | * @version $Revision: 1.1 $
18 | *
19 | * @since swixml 1.1
20 | */
21 | public class HelloMac extends WindowAdapter {
22 | private SwingEngine swix;
23 |
24 | private HelloMac() throws Exception {
25 | swix= new SwingEngine( this );
26 | swix.render( "xml/hellomac.xml" );
27 | swix.getRootComponent().setVisible( true );
28 | }
29 |
30 | public Action actionAbout = new AbstractAction() {
31 | public void actionPerformed( ActionEvent e ) {
32 | JOptionPane.showMessageDialog( swix.getRootComponent(), "This is the Mac OS X Example." );
33 | }
34 | };
35 |
36 | public Action actionHelp = new AbstractAction() {
37 | public void actionPerformed( ActionEvent e ) {
38 | try {
39 | FileManager.openURL("http://www.swixml.org/apidocs/index.html");
40 | } catch (IOException e1) {
41 | e1.printStackTrace();
42 | }
43 | }
44 | };
45 |
46 | public Action actionExit = new AbstractAction() {
47 | public void actionPerformed( ActionEvent e ) {
48 | JOptionPane.showMessageDialog( swix.getRootComponent(), swix.getLocalizer().getString("mis_Exit"));
49 | HelloMac.this.windowClosing(null);
50 | }
51 | };
52 |
53 | /**
54 | * Invoked when a window is in the process of being closed.
55 | * The close operation can be overridden at this point.
56 | */
57 | public void windowClosing( WindowEvent e ) {
58 | super.windowClosing( e );
59 | System.exit(0);
60 | }
61 |
62 | //
63 | // Make the class bootable
64 | //
65 | public static void main( String[] args ) throws Exception {
66 | new HelloMac();
67 | }
68 | }
--------------------------------------------------------------------------------
/samples/HelloWorld.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import javax.swing.*;
5 | import java.awt.event.ActionEvent;
6 |
7 | public class HelloWorld {
8 | /** submit counter */
9 | private int clicks;
10 |
11 | /** JTextField member gets instantiated through Swixml (look for id="tf" in xml descriptor) */
12 | public JTextField tf;
13 |
14 | /** Jlabel to display number of button clicks */
15 | public JLabel cnt;
16 |
17 | /** Action appends a '#' to the textfields content. */
18 | public Action submit = new AbstractAction() {
19 | public void actionPerformed( ActionEvent e ) {
20 | tf.setText( tf.getText() + '#' );
21 | cnt.setText(String.valueOf( ++clicks ));
22 | }
23 | };
24 |
25 | /** Renders UI at construction */
26 | private HelloWorld() throws Exception {
27 | new SwingEngine( this ).render( "xml/helloworld.xml" ).setVisible( true );
28 | }
29 |
30 | /** Makes the class bootable */
31 | public static void main( String[] args ) throws Exception {
32 | new HelloWorld();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/samples/HelloWorldnoAction.java:
--------------------------------------------------------------------------------
1 | import org.swixml.SwingEngine;
2 |
3 | import javax.swing.*;
4 |
5 | public class HelloWorldnoAction {
6 | /**
7 | * submit counter
8 | */
9 | private int clicks;
10 |
11 | /**
12 | * JTextField member gets instantiated through Swixml (look for id="tf" in xml descriptor)
13 | */
14 | public JTextField tf;
15 |
16 | /**
17 | * Jlabel to display number of button clicks
18 | */
19 | public JLabel cnt;
20 |
21 | /**
22 | * bound, using an element's action attribute, which was set to submit.
23 | */
24 | public void submit() {
25 |
26 | tf.setText(tf.getText() + '#');
27 | cnt.setText(String.valueOf(++clicks));
28 | }
29 |
30 |
31 | /**
32 | * Renders UI at construction
33 | */
34 | private HelloWorldnoAction() throws Exception {
35 | new SwingEngine(this).render("xml/helloworld.xml").setVisible(true);
36 | }
37 |
38 | /**
39 | * Makes the class bootable
40 | */
41 | public static void main(String[] args) throws Exception {
42 | new HelloWorldnoAction();
43 | }
44 | }
45 |
46 |
--------------------------------------------------------------------------------
/samples/InitClass.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import javax.swing.*;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.WindowAdapter;
7 |
8 | /**
9 | * The InitClass class demonstrates how to use the initclass attribute.
10 | * Date: Mar 10, 2003
11 | *
12 | * @author Wolf Paulus
13 | * @version $Revision: 1.1 $
14 | * @since swixml 0.76
15 | */
16 |
17 | public class InitClass extends WindowAdapter {
18 | public Action DO_SELECT = new AbstractAction() {
19 | public void actionPerformed(ActionEvent e) {
20 | System.out.println( ((JComboBox) e.getSource()).getSelectedItem().toString() );
21 | }
22 | };
23 |
24 | private InitClass() throws Exception {
25 | new SwingEngine( this ).render( "xml/initclass.xml" ).setVisible( true );
26 | }
27 |
28 | public static void main(String[] args) {
29 | try {
30 | new InitClass();
31 | } catch (Exception e) {
32 | e.printStackTrace();
33 | }
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/samples/Layout.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | /**
5 | * The Layout class shows the use of layout managers
6 | *
7 | * @author Wolf Paulus
8 | * @version $Revision: 1.1 $
9 | *
10 | * @since swixml (#136)
11 | */
12 | public class Layout {
13 | private static final String DESCRIPTOR = "xml/funlayout.xml";
14 |
15 | private Layout() throws Exception {
16 | new SwingEngine( this ).render( Layout.DESCRIPTOR ).setVisible( true );
17 | }
18 |
19 | public static void main( String[] args ) {
20 | try {
21 | new Layout();
22 | } catch (Exception e) {
23 | System.err.println( e.getMessage() );
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/samples/Localization.java:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * Localization, also shows localization for the MAC OS
4 | *
5 | * @author Wolf Paulus
6 | * @version $Revision: 1.1 $
7 | *
8 | * @since swixml (#129)
9 | */
10 | import org.swixml.SwingEngine;
11 |
12 | import javax.swing.*;
13 | import java.awt.event.ActionEvent;
14 | import java.awt.event.WindowAdapter;
15 | import java.awt.event.WindowEvent;
16 |
17 |
18 | public class Localization extends WindowAdapter {
19 |
20 | private static final String DESCRIPTOR = "xml/localization.xml";
21 | SwingEngine swix = new SwingEngine( this );
22 |
23 |
24 |
25 | public Localization() throws Exception {
26 | swix.render( Localization.DESCRIPTOR ).setVisible( true );
27 | }
28 |
29 |
30 | public Action actionOptions = new AbstractAction() {
31 | public void actionPerformed( ActionEvent e ) {
32 | JOptionPane.showMessageDialog( swix.getRootComponent(), "Sorry, " +swix.getLocalizer().getString("mis_Options") + " not implemented yet.");
33 | }
34 | };
35 |
36 | public Action actionAbout = new AbstractAction() {
37 | public void actionPerformed( ActionEvent e ) {
38 | JOptionPane.showMessageDialog( swix.getRootComponent(), "This is the Mac OS X Example." );
39 | }
40 | };
41 |
42 | public Action actionHelp = new AbstractAction() {
43 | public void actionPerformed( ActionEvent e ) {
44 | JOptionPane.showMessageDialog( swix.getRootComponent(), "Help ...." );
45 | }
46 | };
47 |
48 | public Action actionExit = new AbstractAction() {
49 | public void actionPerformed( ActionEvent e ) {
50 | JOptionPane.showMessageDialog( swix.getRootComponent(), swix.getLocalizer().getString("mis_Exit"));
51 | Localization.this.windowClosing(null);
52 | }
53 | };
54 |
55 | /**
56 | * Invoked when a window is in the process of being closed.
57 | * The close operation can be overridden at this point.
58 | */
59 | public void windowClosing( WindowEvent e ) {
60 | super.windowClosing( e );
61 | System.exit(0);
62 | }
63 |
64 | public static void main( String[] args ) {
65 | try {
66 | new Localization();
67 | } catch (Exception e) {
68 | System.err.println( e.getMessage() );
69 | }
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/samples/MacAboutAction.java:
--------------------------------------------------------------------------------
1 | import java.awt.event.ActionEvent;
2 |
3 | import javax.swing.AbstractAction;
4 | import javax.swing.JOptionPane;
5 | // $Id: MacAboutAction.java,v 1.1 2004/10/05 21:32:34 tichy Exp $
6 |
7 | /**
8 | * Externalized AboutAction taken from {@link HelloMac}.
9 | *
10 | * @author $Author: tichy $
11 | */
12 | public class MacAboutAction extends AbstractAction {
13 | public void actionPerformed( ActionEvent e ) {
14 | JOptionPane.showMessageDialog( MacTest.getSwix().getRootComponent(), "This is the Mac OS X Example." );
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/samples/MacExitAction.java:
--------------------------------------------------------------------------------
1 | import java.awt.event.ActionEvent;
2 |
3 | import javax.swing.AbstractAction;
4 | import javax.swing.JOptionPane;
5 | // $Id: MacExitAction.java,v 1.1 2004/10/05 21:32:34 tichy Exp $
6 |
7 | /**
8 | * Externalized exit action taken from {@link HelloMac}.
9 | *
10 | * @author $Author: tichy $
11 | */
12 | public class MacExitAction extends AbstractAction {
13 | public void actionPerformed( ActionEvent e ) {
14 | JOptionPane.showMessageDialog( MacTest.getSwix().getRootComponent(),
15 | MacTest.getSwix().getLocalizer().getString("mis_Exit"));
16 | System.exit(0);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/samples/MacHelpAction.java:
--------------------------------------------------------------------------------
1 | import java.awt.event.ActionEvent;
2 | import java.io.IOException;
3 |
4 | import javax.swing.AbstractAction;
5 |
6 | import com.apple.eio.FileManager;
7 | // $Id: MacHelpAction.java,v 1.1 2004/10/05 21:32:34 tichy Exp $
8 |
9 | /**
10 | * Externalized help action taken from {@link HelloMac}.
11 | *
12 | * @author $Author: tichy $
13 | */
14 | public class MacHelpAction extends AbstractAction {
15 | public void actionPerformed( ActionEvent e ) {
16 | try {
17 | FileManager.openURL("http://www.swixml.org/apidocs/index.html");
18 | } catch (IOException e1) {
19 | e1.printStackTrace();
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/samples/MacMultipleAction.java:
--------------------------------------------------------------------------------
1 | import java.awt.event.ActionEvent;
2 |
3 | import javax.swing.AbstractAction;
4 | import javax.swing.JOptionPane;
5 | // $Id: MacMultipleAction.java,v 1.1 2004/10/05 21:32:35 tichy Exp $
6 |
7 | /**
8 | * Demonstrates delivering of a valid action command from the ActionEvent.
9 | *
10 | * On MacOS, this contains strings like {@link org.swixml.Parser#ATTR_MACOS_ABOUT}
11 | * when the attribute "macos_about"
was set to true
. See the
12 | * provided file mactester.xml
as an usage example. This allows specifying
13 | * of multiple "macos_*"
attributes for one {@link javax.swing.Action}.
14 | *
15 | *
16 | * @author $Author: tichy $
17 | */
18 | public class MacMultipleAction extends AbstractAction {
19 |
20 | /* (non-Javadoc)
21 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
22 | */
23 | public void actionPerformed(ActionEvent arg0) {
24 | // TODO Auto-generated method stub
25 | JOptionPane.showMessageDialog( MacTest.getSwix().getRootComponent(), "This is the Mac OS X MultipleExample. Showing "+arg0.getActionCommand() );
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/samples/MacTest.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import javax.swing.*;
5 | import java.awt.event.ActionEvent;
6 | import java.awt.event.WindowEvent;
7 | import java.awt.event.WindowAdapter;
8 | import java.io.IOException;
9 |
10 | import com.apple.eio.FileManager;
11 |
12 | /**
13 | * The HelloMac class shows a couple of the Mac specifics exposed
14 | * HeeloMac
renders the GUI, which is described in hellomac.xml
15 | *
16 | * @author Wolf Paulus
17 | * @version $Revision: 1.1 $
18 | *
19 | * @since swixml 1.1
20 | */
21 | public class MacTest extends WindowAdapter {
22 | private static SwingEngine swix;
23 |
24 | private MacTest() throws Exception {
25 | swix= new SwingEngine( this );
26 | swix.render( "xml/mactester.xml" );
27 | swix.getRootComponent().setVisible( true );
28 | }
29 |
30 |
31 | //
32 | // Make the class bootable
33 | //
34 | public static void main( String[] args ) throws Exception {
35 | new MacTest();
36 | }
37 |
38 | /**
39 | * @return
40 | */
41 | public static SwingEngine getSwix() {
42 | // TODO Auto-generated method stub
43 | return swix;
44 | }
45 |
46 |
47 | }
--------------------------------------------------------------------------------
/samples/MenuBarWithConstraints.java:
--------------------------------------------------------------------------------
1 | import java.awt.Container;
2 |
3 | import org.swixml.SwingEngine;
4 |
5 | // $Id: MenuBarWithConstraints.java,v 1.1 2005/08/22 21:20:01 tichy Exp $
6 | /**
7 | * Sample program to show a menubar with constraints attribute in it.
8 | *
9 | */
10 | public class MenuBarWithConstraints {
11 |
12 | /**
13 | * @param args
14 | * @throws Exception if something goes wrong
15 | */
16 | public static void main(String[] args) throws Exception {
17 | SwingEngine se = new SwingEngine();
18 | Container container = se.render("xml/menu-bar.xml");
19 | container.setVisible(true);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/samples/Model.java:
--------------------------------------------------------------------------------
1 | import javax.swing.DefaultListModel;
2 |
3 | public class Model extends DefaultListModelAttribute
object into an output object of the
12 | * specified type.
13 | *
14 | * @param type Class
Data type to which the Attribute's value should be converted
15 | * @param attr Attribute
the attribute, providing the value to be converted.
16 | *
17 | */
18 | public Object convert(Class type, Attribute attr, Localizer lz) throws Exception {
19 | SimpleTimeZone tz = null;
20 | if (attr != null && attr.getValue() != null) {
21 | tz = new SimpleTimeZone( 0, attr.getValue() );
22 | }
23 | return tz;
24 | }
25 |
26 | /**
27 | * A Converters
conversTo method informs about the Class type the converter
28 | * is returning when its convert
method is called
29 | * @return Class
- the Class the converter is returning when its convert method is called
30 | */
31 | public Class convertsTo() {
32 | return SimpleTimeZone.class;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/samples/XInclude.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import java.awt.event.WindowAdapter;
5 |
6 | /**
7 | * The XInclude class shows in simple way how to use xml includes.
8 | * XInclude
extends the WindowAdapter and uses a SwingEngine to renders the GUI.
9 | *
10 | * @author Wolf Paulus
11 | * @version $Revision: 1.1 $
12 | *
13 | * @since swixml 0.95
14 | */
15 | public class XInclude extends WindowAdapter {
16 | private SwingEngine swix = new SwingEngine( this );
17 |
18 |
19 | private XInclude() {
20 | try {
21 | swix.render( "xml/xinclude.xml" ).setVisible( true );
22 | } catch (Exception e) {
23 | e.printStackTrace();
24 | }
25 | }
26 |
27 | public static void main( String[] args ) {
28 | new XInclude();
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/samples/XPanel.java:
--------------------------------------------------------------------------------
1 |
2 | import org.swixml.SwingEngine;
3 |
4 | import javax.swing.*;
5 |
6 | /**
7 | * This file contains proprietary information of CarlsbadCubes
8 | * Copying or reproduction without prior written approval is prohibited.
9 | * Copyright (c) 2002-2003
10 | *
11 | *
12 | *
13 | * Date: Feb 28, 2003
14 | *
15 | * @author Wolf Paulus
16 | * @version $Revision: 1.1 $
17 | * @since
18 | */
19 |
20 | public class XPanel extends JPanel {
21 |
22 | private SwingEngine swix = new SwingEngine( this );
23 |
24 |
25 | public void setXml(String resource) {
26 | try {
27 | swix.insert( "xml/" + resource, this );
28 | } catch (Exception e) {
29 | System.err.println( e.getMessage() );
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/samples/icons/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/samples/icons/about.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/about.gif
--------------------------------------------------------------------------------
/samples/icons/button.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/button.gif
--------------------------------------------------------------------------------
/samples/icons/copy.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/copy.gif
--------------------------------------------------------------------------------
/samples/icons/cut.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/cut.gif
--------------------------------------------------------------------------------
/samples/icons/del.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/del.gif
--------------------------------------------------------------------------------
/samples/icons/delete.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/delete.gif
--------------------------------------------------------------------------------
/samples/icons/exit.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/exit.gif
--------------------------------------------------------------------------------
/samples/icons/green.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/green.gif
--------------------------------------------------------------------------------
/samples/icons/help.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/help.gif
--------------------------------------------------------------------------------
/samples/icons/label.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/label.gif
--------------------------------------------------------------------------------
/samples/icons/new.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/new.gif
--------------------------------------------------------------------------------
/samples/icons/open.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/open.gif
--------------------------------------------------------------------------------
/samples/icons/panel.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/panel.gif
--------------------------------------------------------------------------------
/samples/icons/paste.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/paste.gif
--------------------------------------------------------------------------------
/samples/icons/save.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/icons/save.gif
--------------------------------------------------------------------------------
/samples/img/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/samples/img/accelerator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/accelerator.png
--------------------------------------------------------------------------------
/samples/img/actions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/actions.png
--------------------------------------------------------------------------------
/samples/img/applet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/applet.png
--------------------------------------------------------------------------------
/samples/img/cards.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/cards.png
--------------------------------------------------------------------------------
/samples/img/customtags.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/customtags.png
--------------------------------------------------------------------------------
/samples/img/form.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/form.png
--------------------------------------------------------------------------------
/samples/img/gridbag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/gridbag.png
--------------------------------------------------------------------------------
/samples/img/hellolist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/hellolist.png
--------------------------------------------------------------------------------
/samples/img/hellomac.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/hellomac.png
--------------------------------------------------------------------------------
/samples/img/helloworld.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/helloworld.png
--------------------------------------------------------------------------------
/samples/img/initclass.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/initclass.gif
--------------------------------------------------------------------------------
/samples/img/initclass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/initclass.png
--------------------------------------------------------------------------------
/samples/img/layout.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/layout.png
--------------------------------------------------------------------------------
/samples/img/localization.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/localization.png
--------------------------------------------------------------------------------
/samples/img/newtag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/newtag.png
--------------------------------------------------------------------------------
/samples/img/xinclude.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/img/xinclude.png
--------------------------------------------------------------------------------
/samples/locale/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/samples/locale/swix_de.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/samples/locale/swix_de.properties
--------------------------------------------------------------------------------
/samples/locale/swix_en.properties:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Localization
3 | #############################################################################
4 |
5 | app_Title = Localization Sample Application
6 |
7 | #
8 | # Menu Items
9 | #
10 |
11 | mus_File = File
12 | mus_Help = Help
13 |
14 | mis_New = New
15 | mis_Open = Open
16 | mis_Save = Save
17 | mis_Exit = Exit
18 | mis_About = About
19 | mis_Options = Options
20 | mis_Help = Help
21 |
22 | #
23 | # Accelerators
24 | #
25 | acc_New = control N
26 | acc_About = alt A
27 | acc_Exit = control alt X
28 | acc_Help = F1
29 |
30 | #
31 | # Mnemonic
32 | #
33 |
34 | mn_New = VK_N
35 | mn_Open = VK_O
36 | mn_Save = VK_S
37 | mn_Exit = VK_X
38 | mn_Help = VK_H
39 |
40 | #
41 | # Tooltips
42 | #
43 | tt_Copy = Copy
44 | tt_Cut = Cut
45 | tt_Paste = Paste
46 |
47 | tt_Label = JLabel
48 | tt_Button = JButton
49 | tt_Panel = JPanel
50 | l
51 | #
52 | # Images
53 | #
54 |
55 | img_About = icons/about.gif
56 | img_App = icons/green.gif
57 | img_Copy = icons/copy.gif
58 | img_Cut = icons/cut.gif
59 | img_Exit = icons/exit.gif
60 | img_New = icons/new.gif
61 | img_Open = icons/open.gif
62 | img_Paste = icons/paste.gif
63 | img_Save = icons/save.gif
64 | img_Help = icons/help.gif
65 |
66 | img_Panel = icons/panel.gif
67 | img_Button = icons/button.gif
68 | img_Label = icons/label.gif
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/samples/locale/swix_en_mac.properties:
--------------------------------------------------------------------------------
1 | #############################################################################
2 | # Localization
3 | #############################################################################
4 |
5 | app_Title = Mac OS X Sample Application
6 |
7 | #
8 | # Menu Items
9 | #
10 |
11 | mis_Exit = Quit
12 | mis_Options = Preferences
13 |
14 | #
15 | # Mnemonic
16 | #
17 |
18 | mn_New = VK_N
19 | mn_Open = VK_O
20 | mn_Save = VK_S
21 | mn_Exit = VK_X
22 |
23 | #
24 | # Accelerators
25 | #
26 |
27 | acc_New = meta N
28 | acc_About =
29 | acc_Exit = meta Q
30 | acc_Help = meta L
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/samples/xml/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/samples/xml/accelerator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | General purpose data type converter that can be registered and used 57 | * within the SwingEngine package to manage the conversion of objects from 58 | * one type to another.
59 | * 60 | * @author Wolf Paulus 61 | * @version $Revision: 1.2 $ 62 | */ 63 | public interface Converter { 64 | 65 | /** 66 | * Convert the value of the givenAttribute
object into an output object of the
67 | * specified type.
68 | *
69 | * @param type Class
Data type to which the Attribute's value should be converted
70 | * @param attr Attribute
the attribute, providing the value to be converted.
71 | *
72 | */
73 | Object convert( final Class type, final Attribute attr, final Localizer localizer ) throws Exception;
74 |
75 | /**
76 | * A Converters
conversTo method informs about the Class type the converter
77 | * is returning when its convert
method is called
78 | * @return Class
- the Class the converter is returning when its convert method is called
79 | */
80 | Class convertsTo();
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/src/org/swixml/XAction.java:
--------------------------------------------------------------------------------
1 | /*--
2 | Copyright (C) 2003-2007 Wolf Paulus.
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions
7 | are met:
8 |
9 | 1. Redistributions of source code must retain the above copyright
10 | notice, this list of conditions, and the following disclaimer.
11 |
12 | 2. Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions, and the disclaimer that follows
14 | these conditions in the documentation and/or other materials provided
15 | with the distribution.
16 |
17 | 3. The end-user documentation included with the redistribution,
18 | if any, must include the following acknowledgment:
19 | "This product includes software developed by the
20 | SWIXML Project (http://www.swixml.org/)."
21 | Alternately, this acknowledgment may appear in the software itself,
22 | if and wherever such third-party acknowledgments normally appear.
23 |
24 | 4. The name "Swixml" must not be used to endorse or promote products
25 | derived from this software without prior written permission. For
26 | written permission, please contact XGridBagConstraints
simple extends GridBagConstraints
to
59 | * make bean style getters and setters available for all public fields in the GridBagConstraints class.
60 | *
61 | * @author Wolf Paulus
62 | * @version $Revision: 1.1 $
63 | */
64 | public class XGridBagConstraints extends GridBagConstraints {
65 |
66 | public int getAnchor() {
67 | return anchor;
68 | }
69 |
70 | public void setAnchor(int anchor) {
71 | this.anchor = anchor;
72 | }
73 |
74 | public int getFill() {
75 | return fill;
76 | }
77 |
78 | public void setFill(int fill) {
79 | this.fill = fill;
80 | }
81 |
82 | public int getGridheight() {
83 | return gridheight;
84 | }
85 |
86 | public void setGridheight(int gridheight) {
87 | this.gridheight = gridheight;
88 | }
89 |
90 | public int getGridwidth() {
91 | return gridwidth;
92 | }
93 |
94 | public void setGridwidth(int gridwidth) {
95 | this.gridwidth = gridwidth;
96 | }
97 |
98 | public int getGridx() {
99 | return gridx;
100 | }
101 |
102 | public void setGridx(int gridx) {
103 | this.gridx = gridx;
104 | }
105 |
106 | public int getGridy() {
107 | return gridy;
108 | }
109 |
110 | public void setGridy(int gridy) {
111 | this.gridy = gridy;
112 | }
113 |
114 | public Insets getInsets() {
115 | return insets;
116 | }
117 |
118 | public void setInsets(Insets insets) {
119 | this.insets = insets;
120 | }
121 |
122 | public int getIpadx() {
123 | return ipadx;
124 | }
125 |
126 | public void setIpadx(int ipadx) {
127 | this.ipadx = ipadx;
128 | }
129 |
130 | public int getIpady() {
131 | return ipady;
132 | }
133 |
134 | public void setIpady(int ipady) {
135 | this.ipady = ipady;
136 | }
137 |
138 | public double getWeightx() {
139 | return weightx;
140 | }
141 |
142 | public void setWeightx(double weightx) {
143 | this.weightx = weightx;
144 | }
145 |
146 | public double getWeighty() {
147 | return weighty;
148 | }
149 |
150 | public void setWeighty(double weighty) {
151 | this.weighty = weighty;
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/src/org/swixml/XHBox.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: XHBox.java,v 1.1 2004/03/01 07:56:09 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Color
, the background color of the viewport.
68 | * @see java.awt.Component#getBackground
69 | */
70 | @Override
71 | public void setBackground(Color bg) {
72 | super.getViewport().setBackground(bg);
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/org/swixml/XSplitPane.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: XSplitPane.java,v 1.1 2004/03/01 07:56:09 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact ComponentFactory.createSeparator()
,
62 | * which creates a titled separator.
63 | *
64 | * @author Karl Tauber
65 | */
66 | public class XTitledSeparator extends JComponent {
67 |
68 | private String text;
69 | private int alignment = SwingConstants.LEFT;
70 |
71 | public XTitledSeparator() {
72 | super();
73 | setLayout(new BorderLayout());
74 | update();
75 | }
76 |
77 | private void update() {
78 | removeAll();
79 | add( DefaultComponentFactory.getInstance().createSeparator(text, alignment));
80 | }
81 |
82 | /**
83 | * Returns the title of the separator.
84 | */
85 | public String getText() {
86 | return text;
87 | }
88 |
89 | /**
90 | * Sets the title of the separator.
91 | */
92 | public void setText( String text ) {
93 | this.text = text;
94 | update();
95 | }
96 |
97 | /**
98 | * Returns the title alignment.
99 | * One of SwingConstants.LEFT
, SwingConstants.CENTER
100 | * or SwingConstants.RIGHT
.
101 | */
102 | public int getAlignment() {
103 | return alignment;
104 | }
105 |
106 | /**
107 | * Sets the title alignment.
108 | * One of SwingConstants.LEFT
, SwingConstants.CENTER
109 | * or SwingConstants.RIGHT
.
110 | */
111 | public void setAlignment( int alignment ) {
112 | this.alignment = alignment;
113 | update();
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/org/swixml/XVBox.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: XVBox.java,v 1.1 2004/03/01 07:56:09 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Attribute
object into an output object of the
73 | * specified type.
74 | *
75 | * @param type Class
Data type to which the Attribute's value should be converted
76 | * @param attr Attribute
the attribute, providing the value to be converted.
77 | *
78 | */
79 | public Object convert( Class type, Attribute attr, Localizer localizer ) throws Exception {
80 | return null;
81 | }
82 |
83 | /**
84 | * A conversTo
method informs about the Class type the converter
85 | * is returning when its convert
method is called
86 | * @return Class
- the Class the converter is returning when its convert method is called
87 | */
88 | public Class convertsTo() {
89 | return Action.class;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/src/org/swixml/converters/ComponentConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: ComponentConverter.java,v 1.1 2004/03/01 07:55:58 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Attribute
object into an output object of the
77 | * specified type.
78 | *
79 | * @param attr Attribute
the attribute, providing the value to be converted.
80 | */
81 | public static Component conv(Attribute attr) throws Exception {
82 | return null;
83 | }
84 |
85 | /**
86 | * Convert the value of the given Attribute
object into an output object of the
87 | * specified type.
88 | *
89 | * @param type Class
Data type to which the Attribute's value should be converted
90 | * @param attr Attribute
the attribute, providing the value to be converted.
91 | */
92 | public Object convert(Class type, Attribute attr, Localizer localizer) throws Exception {
93 | return ComponentConverter.conv(attr);
94 | }
95 |
96 |
97 | /**
98 | * A Converters
conversTo method informs about the Class type the converter
99 | * is returning when its convert
method is called
100 | *
101 | * @return Class
- the Class the converter is returning when its convert method is called
102 | */
103 | public Class convertsTo() {
104 | return TEMPLATE;
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/org/swixml/converters/DimensionConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: DimensionConverter.java,v 1.1 2004/03/01 07:55:59 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact 68 | *
Class
not used
85 | * @param attr Attribute
value fields needs provides convertable String
86 | * @return Object
- runtime type is Dimension
87 | */
88 | public Object convert( final Class type, final Attribute attr, Localizer localizer ) {
89 | if (attr != null) {
90 | StringTokenizer st = new StringTokenizer( attr.getValue(), "," );
91 | int width = 0;
92 | int height = 0;
93 | if (st.hasMoreTokens()) {
94 | width = Integer.parseInt( st.nextToken().trim() );
95 | }
96 | if (st.hasMoreTokens()) {
97 | height = Integer.parseInt( st.nextToken().trim() );
98 | }
99 | return new Dimension( width, height );
100 | }
101 | return null;
102 | }
103 |
104 |
105 | /**
106 | * A Converters
conversTo method informs about the Class type the converter
107 | * is returning when its convert
method is called
108 | * @return Class
- the Class the converter is returning when its convert method is called
109 | */
110 | public Class convertsTo() {
111 | return TEMPLATE;
112 | }
113 | }
--------------------------------------------------------------------------------
/src/org/swixml/converters/ImageConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: ImageConverter.java,v 1.1 2004/03/01 07:56:00 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Class
not used
79 | * @param attr Attribute
attribute provides the value to be converted
80 | * @param localizer Localizer
allow the use of resource lookups
81 | * @return Object
- an ImageIcon
82 | */
83 | public Object convert( final Class type, final Attribute attr, Localizer localizer ) {
84 | return ImageConverter.conv( type, attr, localizer );
85 | }
86 |
87 | /**
88 | * Converts a String into an ImageIcon through a Resource lookup
89 | * @param type Class
not used
90 | * @param attr Attribute
attribute provides the value to be converted
91 | * @param localizer Localizer
allow the use of resource lookups
92 | * @return Object
- an ImageIcon
93 | */
94 | public static Object conv( final Class type, final Attribute attr, Localizer localizer ) {
95 | ImageIcon icon = (ImageIcon) ImageIconConverter.conv( type, attr, localizer );
96 | return icon != null ? icon.getImage() : null;
97 | }
98 |
99 | /**
100 | * A Converters
conversTo method informs about the Class type the converter
101 | * is returning when its convert
method is called
102 | * @return Class
- the Class the converter is returning when its convert method is called
103 | */
104 | public Class convertsTo() {
105 | return TEMPLATE;
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/org/swixml/converters/ImageIconConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: ImageIconConverter.java,v 1.1 2004/03/01 07:56:00 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Class
not used
80 | * @param attr Attribute
attribute provides the value to be converted
81 | * @param localizer Localizer
allow the use of resource lookups
82 | * @return Object
- an ImageIcon
83 | */
84 | public Object convert( final Class type, final Attribute attr, Localizer localizer ) {
85 | return ImageIconConverter.conv( type, attr, localizer );
86 | }
87 |
88 | /**
89 | * Converts a String into an ImageIcon through a Resource lookup
90 | * @param type Class
not used
91 | * @param attr Attribute
attribute provides the value to be converted
92 | * @param localizer Localizer
allow the use of resource lookups
93 | * @return Object
- an ImageIcon
94 | */
95 | public static Object conv( final Class type, final Attribute attr, Localizer localizer ) {
96 | ImageIcon icon = null;
97 | if (attr != null) {
98 | if (Parser.LOCALIZED_ATTRIBUTES.contains( attr.getName().toLowerCase() )) {
99 | attr.setValue( localizer.getString( attr.getValue() ) );
100 | }
101 | try {
102 | //java.net.URL imgURL = Converter.class.getResource( attr.getValue() );
103 | //icon = new ImageIcon( imgURL );
104 | icon = new ImageIcon( localizer.getClassLoader().getResource( attr.getValue() ) );
105 | } catch (Exception e) {
106 | // intentionally empty
107 | }
108 | }
109 | return icon;
110 | }
111 |
112 | /**
113 | * A Converters
conversTo method informs about the Class type the converter
114 | * is returning when its convert
method is called
115 | * @return Class
- the Class the converter is returning when its convert method is called
116 | */
117 | public Class convertsTo() {
118 | return TEMPLATE;
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/src/org/swixml/converters/InsetsConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: InsetsConverter.java,v 1.1 2004/03/01 07:56:00 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact InsetsConverter
class defines a converter that creates Insets objects based on a provided String.
64 | *
65 | * 67 | *
Class
not used
90 | * @param attr Attribute
value needs to provide String containing comma sep. integers
91 | * @return Object
runtime type is subclass of Insets
92 | */
93 | public Object convert( final Class type, final Attribute attr, Localizer localizer ) {
94 | Insets insets = null;
95 | if (attr != null) {
96 | StringTokenizer st = new StringTokenizer( attr.getValue(), "(,)" );
97 | if (5 == st.countTokens()) { // assume "insets(...)"
98 | st.nextToken().trim();
99 | }
100 | int[] param = Util.ia( st );
101 | if (4 <= param.length) {
102 | insets = new Insets( param[0], param[1], param[2], param[3] );
103 | }
104 | }
105 | return insets;
106 | }
107 |
108 |
109 | /**
110 | * A Converters
conversTo method informs about the Class type the converter
111 | * is returning when its convert
method is called
112 | * @return Class
- the Class the converter is returning when its convert method is called
113 | */
114 | public Class convertsTo() {
115 | return TEMPLATE;
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/src/org/swixml/converters/LocaleConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: LocaleConverter.java,v 1.1 2004/03/01 07:56:02 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Attribute
object into an output object of the
78 | * specified type.
79 | *
80 | * @param attr Attribute
the attribute, providing the value to be converted.
81 | *
82 | */
83 | public static Locale conv( String attrValue ) throws Exception {
84 | Locale locale = null; // Locale.getDefault();
85 | if (attrValue != null) {
86 | StringTokenizer st = new StringTokenizer( attrValue, "," );
87 | int n = st.countTokens();
88 | if (1 == n) {
89 | locale = new Locale( st.nextToken() );
90 | } else if (2 == n) {
91 | locale = new Locale( st.nextToken(), st.nextToken() );
92 | } else if (3 <= n) {
93 | locale = new Locale( st.nextToken(), st.nextToken(), st.nextToken() );
94 | }
95 | }
96 | return locale;
97 | }
98 |
99 | /**
100 | * Convert the value of the given Attribute
object into an output object of the
101 | * specified type.
102 | *
103 | * @param type Class
Data type to which the Attribute's value should be converted
104 | * @param attr Attribute
the attribute, providing the value to be converted.
105 | *
106 | */
107 | public Object convert( Class type, Attribute attr, Localizer localizer ) throws Exception {
108 | return LocaleConverter.conv( attr.getValue() );
109 | }
110 |
111 |
112 | /**
113 | * A Converters
conversTo method informs about the Class type the converter
114 | * is returning when its convert
method is called
115 | * @return Class
- the Class the converter is returning when its convert method is called
116 | */
117 | public Class convertsTo() {
118 | return TEMPLATE;
119 | }
120 |
121 | }
122 |
--------------------------------------------------------------------------------
/src/org/swixml/converters/PointConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: PointConverter.java,v 1.1 2004/03/01 07:56:02 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Class
not used
77 | * @param attr Attribute
value fields needs provides convertable String
78 | * @return Object
- runtime type is Point
79 | */
80 | public Object convert( final Class type, final Attribute attr, Localizer localizer ) {
81 | if (attr != null) {
82 | StringTokenizer st = new StringTokenizer( attr.getValue(), "," );
83 | int x = 0;
84 | int y = 0;
85 | if (st.hasMoreTokens()) {
86 | x = Integer.parseInt( st.nextToken().trim() );
87 | }
88 | if (st.hasMoreTokens()) {
89 | y = Integer.parseInt( st.nextToken().trim() );
90 | }
91 | return new Point( x, y );
92 | }
93 | return null;
94 | }
95 |
96 |
97 | /**
98 | * A Converters
conversTo method informs about the Class type the converter
99 | * is returning when its convert
method is called
100 | * @return Class
- the Class the converter is returning when its convert method is called
101 | */
102 | public Class convertsTo() {
103 | return TEMPLATE;
104 | }
105 | }
--------------------------------------------------------------------------------
/src/org/swixml/converters/RectangleConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: RectangleConverter.java,v 1.1 2004/03/01 07:56:03 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact 68 | *
Class
not used
85 | * @param attr Attribute
value fields needs provides convertable String
86 | * @return Object
- runtime type is Dimension
87 | */
88 | public Object convert( final Class type, final Attribute attr, Localizer localizer ) {
89 | if (attr != null) {
90 | StringTokenizer st = new StringTokenizer( attr.getValue(), "," );
91 | int x = 0;
92 | int y = 0;
93 | int width = 0;
94 | int height = 0;
95 | if (st.hasMoreTokens()) {
96 | x = Integer.parseInt( st.nextToken().trim() );
97 | }
98 | if (st.hasMoreTokens()) {
99 | y = Integer.parseInt( st.nextToken().trim() );
100 | }
101 | if (st.hasMoreTokens()) {
102 | width = Integer.parseInt( st.nextToken().trim() );
103 | }
104 | if (st.hasMoreTokens()) {
105 | height = Integer.parseInt( st.nextToken().trim() );
106 | }
107 | return new Rectangle( x, y, width, height );
108 | }
109 | return null;
110 | }
111 |
112 |
113 | /**
114 | * A Converters
conversTo method informs about the Class type the converter
115 | * is returning when its convert
method is called
116 | * @return Class
- the Class the converter is returning when its convert method is called
117 | */
118 | public Class convertsTo() {
119 | return TEMPLATE;
120 | }
121 | }
--------------------------------------------------------------------------------
/src/org/swixml/converters/StringConverter.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: StringConverter.java,v 1.1 2004/03/01 07:56:03 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact Attribute
object into an output object of the
76 | * specified type.
77 | *
78 | * @param type Class
Data type to which the Attribute's value should be converted
79 | * @param attr Attribute
the attribute, providing the value to be converted.
80 | *
81 | */
82 | public Object convert( Class type, final Attribute attr, Localizer localizer ) throws Exception {
83 | //
84 | // Localize Strings but only if Attribute calls for localization.
85 | //
86 | if ( Parser.LOCALIZED_ATTRIBUTES.contains( attr.getName().toLowerCase() ))
87 | return localizer.getString( attr.getValue() );
88 | return attr.getValue();
89 | }
90 |
91 | /**
92 | * A Converters
conversTo method informs about the Class type the converter
93 | * is returning when its convert
method is called
94 | * @return Class
- the Class the converter is returning when its convert method is called
95 | */
96 | public Class convertsTo() {
97 | return TEMPLATE;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/org/swixml/converters/Util.java:
--------------------------------------------------------------------------------
1 | /*--
2 | $Id: Util.java,v 1.1 2004/03/01 07:56:03 wolfpaulus Exp $
3 |
4 | Copyright (C) 2003-2007 Wolf Paulus.
5 | All rights reserved.
6 |
7 | Redistribution and use in source and binary forms, with or without
8 | modification, are permitted provided that the following conditions
9 | are met:
10 |
11 | 1. Redistributions of source code must retain the above copyright
12 | notice, this list of conditions, and the following disclaimer.
13 |
14 | 2. Redistributions in binary form must reproduce the above copyright
15 | notice, this list of conditions, and the disclaimer that follows
16 | these conditions in the documentation and/or other materials provided
17 | with the distribution.
18 |
19 | 3. The end-user documentation included with the redistribution,
20 | if any, must include the following acknowledgment:
21 | "This product includes software developed by the
22 | SWIXML Project (http://www.swixml.org/)."
23 | Alternately, this acknowledgment may appear in the software itself,
24 | if and wherever such third-party acknowledgments normally appear.
25 |
26 | 4. The name "Swixml" must not be used to endorse or promote products
27 | derived from this software without prior written permission. For
28 | written permission, please contact StringTokenizer
71 | * @return int[]
array containing the remaining tokens converted into int(s)
72 | */
73 | public static int[] ia( StringTokenizer st ) {
74 | int size = st != null ? st.countTokens() : 0;
75 | int[] a = new int[size];
76 | int i = 0;
77 | while (st != null && st.hasMoreTokens()) {
78 | try {
79 | a[i] = Integer.parseInt( st.nextToken().trim() );
80 | i++;
81 | } catch (NumberFormatException e) {
82 | // no exceptiion handling required
83 | }
84 | }
85 | int[] b = new int[i];
86 | System.arraycopy( a, 0, b, 0, i );
87 | return b;
88 | }
89 |
90 | /**
91 | * Returns the remaining tokens of a StringTokenizer in a double-Array
92 | * @param st StringTokenizer
93 | * @return double[]
array containing the remaining tokens converted into double(s)
94 | */
95 | public static double[] da( StringTokenizer st ) {
96 | int size = st != null ? st.countTokens() : 0;
97 | double[] a = new double[size];
98 | int i = 0;
99 | while (st != null && st.hasMoreTokens()) {
100 | try {
101 | a[i] = Double.parseDouble( st.nextToken().trim() );
102 | i++;
103 | } catch (NumberFormatException e) {
104 | // no exceptiion handling required
105 | }
106 | }
107 | double[] b = new double[i];
108 | System.arraycopy( a, 0, b, 0, i );
109 | return b;
110 | }
111 | /**
112 | * Return a capitalized version of the specified property name.
113 | *
114 | * @param s String
The property name
115 | * @return String
given String with 1st letter capitalized
116 | */
117 | public static final String capitalize( final String s ) {
118 | String cs = null;
119 | if (s != null && 0 < s.length()) {
120 | final char[] chars = s.toCharArray();
121 | chars[0] = Character.toUpperCase( chars[0] );
122 | cs = new String( chars );
123 | }
124 | return cs;
125 | }
126 |
127 | /**
128 | * Returns the integer value of the given XML attribute; or the default value.
129 | */
130 | public static final int getInteger( final Element element, final String attr, int def ) {
131 | String value = Attribute.getAttributeValue(element,attr);
132 | if (value == null)
133 | return def;
134 |
135 | try {
136 | return Integer.parseInt( value.trim() );
137 | } catch (NumberFormatException e) {
138 | // no exceptiion handling required
139 | return def;
140 | }
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/src/org/swixml/doc-files/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/src/org/swixml/doc-files/swixml_1_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/src/org/swixml/doc-files/swixml_1_0.png
--------------------------------------------------------------------------------
/src/org/swixml/layoutconverters/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/tagdocs/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/tagdocs/.DS_Store
--------------------------------------------------------------------------------
/tagdocs/img/apple.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/tagdocs/img/apple.gif
--------------------------------------------------------------------------------
/tagdocs/img/bannerbackground.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/tagdocs/img/bannerbackground.gif
--------------------------------------------------------------------------------
/tagdocs/img/swixml.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/tagdocs/img/swixml.gif
--------------------------------------------------------------------------------
/tagdocs/img/swixmlbig.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/swixml/Two/dab7bda02798d31df537f78f24d4e3e382ea82f0/tagdocs/img/swixmlbig.gif
--------------------------------------------------------------------------------
/tagdocs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 | ![]() |
12 |
PrimitiveConverterTest
JScrollPane.class gets added to the Primitive Converter.
63 | * However, its constants are not added since they are all defined in an additional interface, i.e.
64 | * ScrollPaneConstants
65 | * @author Wolf Paulus
66 | */
67 | public class PrimitiveConverterTest extends TestCase {
68 |
69 |
70 | public PrimitiveConverterTest() {
71 | this(PrimitiveConverterTest.class.getSimpleName());
72 | }
73 |
74 | public PrimitiveConverterTest(String string) {
75 | super(string);
76 |
77 | }
78 |
79 | /**
80 | * This test worked successfully only after PrimitiveConverter also implements ScrollPaneConstants
81 | * @throws Exception
82 | * @see ScrollPaneConstants
83 | */
84 | public void testConstantAvailability() throws Exception {
85 | Object obj= PrimitiveConverter.conv(JScrollPane.class,new Attribute("orientation","VERTICAL_SCROLLBAR_ALWAYS"),null);
86 | TestCase.assertNotNull(obj);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/tests/xml/.gitignore:
--------------------------------------------------------------------------------
1 | /*.DS_Store
2 |
--------------------------------------------------------------------------------
/tests/xml/action.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2 | SwiXml, is a small GUI generating engine for Java 3 | applications and applets. 4 | Graphical User Interfaces are described in XML documents that are parsed at runtime and rendered into 5 | javax.swing objects. 6 |
7 |
8 | Depending on the application, XML descriptors may be deployed with the remaining code or loaded from a
9 | remote server at runtime. This late binding of the GUI has many advantages. Enabling features in an
10 | application based on a license code or a user's role does not have to be hard coded anymore. Instead
11 | an XML document describing the application's GUI could be dynamically loaded.
12 | Generating the GUI based on descriptors also has some of the advantages that code generators provide,
13 | but without generating the none-maintainable code.
14 |
17 | While SwiXml doesn't free the developer from knowing the 18 | javax.swing package, it reduces the amount of repetitive, sometimes error prone, and often 19 | complex GUI related code. 20 |
21 |22 | Constructing a User Interface based on XML documents is not a totally new idea. Projects like Thinlet, XUL, XULUX, Jelly, and SwingML, to name a few, 24 | have successfully proven this concept. 25 |
26 |