001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.plaf.wml;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: import com.javelin.swinglets.*;
012: import com.javelin.swinglets.table.*;
013: import com.javelin.swinglets.border.*;
014: import com.javelin.swinglets.plaf.*;
015:
016: /**
017: * WMLLookAndFeel defines a look and feel.
018: *
019: * @author Robin Sharp
020: */
021:
022: public class WMLLookAndFeel extends SLookAndFeel {
023: /**
024: * Intialise the SUIDefaults.
025: */
026: protected void initClassDefaults(SUIDefaults defaults) {
027: //Init SUIClasses
028: defaults.put(SFileChooser.class, WMLFileChooserUI.class);
029: defaults.put(SButton.class, WMLButtonUI.class);
030: defaults.put(SToggleButton.class, WMLCheckBoxUI.class);
031: defaults.put(SCheckBox.class, WMLCheckBoxUI.class);
032: defaults.put(SComboBox.class, WMLComboBoxUI.class);
033: defaults.put(SList.class, WMLListUI.class);
034: defaults.put(SFrame.class, WMLFrameUI.class);
035: defaults.put(SDialog.class, WMLDialogUI.class);
036: defaults.put(SIcon.class, WMLIconUI.class);
037: defaults.put(SLabel.class, WMLLabelUI.class);
038: defaults.put(SPanel.class, WMLPanelUI.class);
039: defaults.put(SSplitPane.class, WMLSplitPaneUI.class);
040: defaults.put(STabbedPane.class, WMLTabbedPaneUI.class);
041: defaults.put(STable.class, WMLTableUI.class);
042: defaults.put(STableHeader.class, WMLTableHeaderUI.class);
043: defaults.put(STree.class, WMLTreeUI.class);
044: defaults.put(STextField.class, WMLTextFieldUI.class);
045: defaults.put(SPasswordField.class, WMLPasswordFieldUI.class);
046: defaults.put(STextArea.class, WMLTextAreaUI.class);
047: defaults.put(SCharacter.class, WMLCharacterUI.class);
048: defaults.put(SForm.class, WMLFormUI.class);
049: defaults.put(SRadioButton.class, WMLRadioButtonUI.class);
050: defaults.put(SButtonGroup.class, WMLButtonGroupUI.class);
051: defaults.put(SToolBar.class, WMLToolBarUI.class);
052: defaults.put(SSeparator.class, WMLSeparatorUI.class);
053: defaults.put(SMenuBar.class, WMLMenuBarUI.class);
054: defaults.put(SMenu.class, WMLMenuUI.class);
055: defaults.put(SMenuItem.class, WMLMenuItemUI.class);
056: defaults.put(SHidden.class, WMLHiddenUI.class);
057: defaults.put(SServlet.class, WMLServletUI.class);
058: defaults.put(SObject.class, WMLObjectUI.class);
059:
060: //Layout UI
061: defaults.put(SFlowLayout.class, WMLFlowLayoutUI.class);
062: defaults.put(SGridLayout.class, WMLGridLayoutUI.class);
063: defaults.put(SGridLayout.class, WMLBorderLayoutUI.class);
064:
065: //Border UI
066: defaults.put(SEmptyBorder.class, WMLBorderUI.class);
067: defaults.put(SBevelBorder.class, WMLBorderUI.class);
068: defaults.put(SCompoundBorder.class, WMLBorderUI.class);
069: defaults.put(SMatteBorder.class, WMLBorderUI.class);
070:
071: //Default Renderers
072: defaults.put(TABLE_DEFAULT_CELL_RENDERER,
073: WMLDefaultTableCellRenderer.class);
074: defaults.put(TABLE_DEFAULT_HEADER_RENDERER,
075: WMLDefaultTableHeaderRenderer.class);
076: //defaults.put( TREE_DEFAULT_CELL_RENDERER, WMLDefaultTreeCellRenderer.class );
077: defaults.put(TABBED_DEFAULT_CELL_RENDERER,
078: WMLDefaultTabbedCellRenderer.class);
079:
080: }
081:
082: /**
083: * Get the name of the look and feel.
084: */
085: public String getName() {
086: return "WML";
087: }
088:
089: /**
090: * Get the content type for the look and feel.
091: */
092: public String getContentType() {
093: return "text/vnd.wap.wml";
094: }
095:
096: /**
097: * Does the look and feel require a Writer (char)
098: * stream or a OutputStream (byte) stream.
099: */
100: public boolean isWriter() {
101: return true;
102: }
103:
104: /**
105: * Get a SComponentUI for a SComponent.
106: */
107: public SComponentUI getUI(SComponent component) {
108: try {
109: Class clazz = (Class) getUIDefaults().getUIClass(
110: component.getUIClass());
111: if (clazz != null) {
112: return (SComponentUI) clazz.newInstance();
113: }
114: } catch (Exception e) {
115: e.printStackTrace();
116: }
117: return null;
118: }
119:
120: /**
121: * Get a SLayoutUI for a SLayout.
122: */
123: public SLayoutUI getLayoutUI(SLayoutManager layoutManager) {
124: try {
125: Class clazz = (Class) getUIDefaults().getUIClass(
126: layoutManager.getUIClass());
127: if (clazz != null) {
128: return (SLayoutUI) clazz.newInstance();
129: }
130: } catch (Exception e) {
131: e.printStackTrace();
132: }
133: return null;
134: }
135:
136: /**
137: * Get a SBorderUI for a SBorder.
138: */
139: public SBorderUI getBorderUI(SBorder border) {
140: try {
141: Class clazz = (Class) getUIDefaults().getUIClass(
142: border.getClass());
143: if (clazz != null) {
144: return (SBorderUI) clazz.newInstance();
145: }
146: } catch (Exception e) {
147: e.printStackTrace();
148: }
149: return null;
150: }
151:
152: // PRIVATE /////////////////////////////////////////////////////////////
153:
154: private Hashtable defaults = new Hashtable();
155:
156: }
|