Source Code Cross Referenced for SelectedPanel.java in  » UML » jrefactory » org » acm » seguin » ide » common » options » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » jrefactory » org.acm.seguin.ide.common.options 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *JSIndentOptionPane.java - JavaStyle indenting options panel
003:         *Copyright (C) 2001 Dirk Moebius
004:         *
005:         *jEdit buffer options:
006:         *:tabSize=4:indentSize=4:noTabs=false:maxLineLen=0:
007:         *
008:         *This program is free software; you can redistribute it and/or
009:         *modify it under the terms of the GNU General Public License
010:         *as published by the Free Software Foundation; either version 2
011:         *of the License, or any later version.
012:         *
013:         *This program is distributed in the hope that it will be useful,
014:         *but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         *GNU General Public License for more details.
017:         *
018:         *You should have received a copy of the GNU General Public License
019:         *along with this program; if not, write to the Free Software
020:         *Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:        package org.acm.seguin.ide.common.options;
023:
024:        import java.awt.Dimension;
025:        import java.awt.BorderLayout;
026:        import java.awt.event.ActionEvent;
027:        import java.awt.event.ActionListener;
028:        import javax.swing.JCheckBox;
029:        import javax.swing.JLabel;
030:        import javax.swing.JPanel;
031:        import javax.swing.JTextArea;
032:        import javax.swing.JTextPane;
033:        import javax.swing.JTextField;
034:        import javax.swing.JComponent;
035:        import javax.swing.JRadioButton;
036:        import javax.swing.AbstractButton;
037:        import javax.swing.BoxLayout;
038:        import javax.swing.event.ChangeListener;
039:        import javax.swing.event.ChangeEvent;
040:        import org.acm.seguin.ide.common.options.PropertiesFile;
041:        import org.acm.seguin.ide.common.IDEPlugin;
042:
043:        /**
044:         * @author       Mike Atkinson (<a
045:         *      href="mailto:javastyle@ladyshot.demon.co.uk">
046:         *      Mike@ladyshot.demon.co.uk</a> )
047:         * @created      02 September 2003
048:         * @version      $Version: $
049:         * @since        1.5
050:         */
051:        public class SelectedPanel extends JPanel {
052:            private JComponent component;
053:            private JLabel optionLabel = null;
054:            private PropertiesFile props;
055:            private String option;
056:            private JCheckBox cb = null;
057:
058:            /**
059:             *    Constructor for the SelectedPanel object
060:             *
061:             * @param    optionPane     Description of the Parameter
062:             * @param    props          Description of the Parameter
063:             * @param    project        Description of the Parameter
064:             * @param    option         Description of the Parameter
065:             * @param    defaultOption  Description of the Parameter
066:             * @param    label          Description of the Parameter
067:             * @param    comp           Description of the Parameter
068:             */
069:            public SelectedPanel(JSHelpOptionPane optionPane,
070:                    PropertiesFile props, String project, String option,
071:                    String defaultOption, String label, JComponent comp) {
072:                this .props = props;
073:                this .option = option;
074:
075:                String fullLabel = (label == null) ? null
076:                        : ("options.javastyle." + label);
077:                boolean selected = false;
078:
079:                String value = null;
080:
081:                if (option != null) {
082:                    if (defaultOption != null) {
083:                        value = props.getString(option, defaultOption);
084:                    } else {
085:                        value = props.getString(option);
086:                    }
087:                    if (value == null) {
088:                        System.out.println("WARNING: Option Not Found option="
089:                                + option);
090:                    }
091:                }
092:                if (comp instanceof  JTextField && value != null
093:                        && value.length() > 50) {
094:                    component = new JTextArea(1, 50);
095:                    ((JTextArea) component).setLineWrap(true);
096:                    component.setBorder(comp.getBorder());
097:                    component.setFont(comp.getFont());
098:                    //value = value.substring(0,50);
099:                    //component = comp;
100:                } else {
101:                    component = comp;
102:                }
103:                setLayout(new BoxLayout(this , BoxLayout.X_AXIS));
104:                if (!"default".equals(project)) {
105:                    selected = props.isLocalProperty(option);
106:                    cb = new JCheckBox("    ");
107:                    cb.setSelected(selected);
108:                    add(cb);
109:                    cb.addChangeListener(new ChangeListener() {
110:                        public void stateChanged(ChangeEvent e) {
111:                            component.setEnabled(cb.isSelected());
112:                            if (optionLabel != null) {
113:                                optionLabel.setEnabled(cb.isSelected());
114:                            }
115:                        }
116:                    });
117:                    optionPane.addHelpFor(cb, "project.local");
118:                } else {
119:                    selected = true;
120:                }
121:                component.setEnabled(selected);
122:
123:                if (component instanceof  AbstractButton) {
124:                    String text = IDEPlugin.getProperty(fullLabel);
125:
126:                    if (text == null) {
127:                        System.out
128:                                .println("WARNING: IDEPlugin.getProperty() not found fullLabel="
129:                                        + fullLabel);
130:                    }
131:                    ((AbstractButton) component).setText(text);
132:                    if (option != null) {
133:                        ((AbstractButton) component).setSelected(props
134:                                .getBoolean(option));
135:                    }
136:                } else if (component instanceof  JMouseComboBox) {
137:                    ((JMouseComboBox) component).setEditable(false);
138:                    if (value != null) {
139:                        ((JMouseComboBox) component).setSelectedItem(value);
140:                    }
141:                } else if (component instanceof  JTextField) {
142:                    if (value != null) {
143:                        ((JTextField) component).setText(value);
144:                    }
145:                } else if (component instanceof  JTextArea) {
146:                    if (value != null) {
147:                        ((JTextArea) component).setText(value);
148:                    }
149:                }
150:                if (label != null && component != null) {
151:                    optionPane.addHelpFor(component, label);
152:                }
153:                if (component instanceof  AbstractButton) {
154:                    add(component);
155:                    optionPane.addComponent(this );
156:                } else if (fullLabel != null) {
157:                    optionLabel = new JLabel(IDEPlugin.getProperty(fullLabel));
158:                    optionLabel.setEnabled(selected);
159:                    add(optionLabel);
160:                    optionPane.addComponent(this , component);
161:                } else {
162:                    optionPane.addComponent(this , component);
163:                }
164:            }
165:
166:            /**
167:             *    Gets the PropertiesFile attribute of the SelectedPanel
168:             *    object
169:             *
170:             * @return      The PropertiesFile value
171:             */
172:            public PropertiesFile getPropertiesFile() {
173:                return props;
174:            }
175:
176:            /**    Description of the Method  */
177:            public void save() {
178:                if (localAvailable()) {
179:                    if (component instanceof  AbstractButton) {
180:                        props.setString(option, ((AbstractButton) component)
181:                                .isSelected() ? "true" : "false");
182:                    } else if (component instanceof  JTextField) {
183:                        props.setString(option, ((JTextField) component)
184:                                .getText());
185:                    } else if (component instanceof  JTextArea) {
186:                        props.setString(option, ((JTextArea) component)
187:                                .getText());
188:                    } else if (component instanceof  JMouseComboBox) {
189:                        props.setString(option, ((JMouseComboBox) component)
190:                                .getSelectedItem().toString());
191:                    } else {
192:                    }
193:                } else if (localDelete()) {
194:                    props.deleteKey(option);
195:                }
196:            }
197:
198:            /**
199:             *    Description of the Method
200:             *
201:             * @param    value  Description of the Parameter
202:             */
203:            public void save(String value) {
204:                if (localAvailable()) {
205:                    System.out.println("SelectedPanel.save(" + value + ")");
206:                    System.out.println("  -props.setString(" + option + ","
207:                            + value + ")");
208:                    props.setString(option, value);
209:                } else if (localDelete()) {
210:                    System.out.println("  -props.deleteKey(" + option + ")");
211:                    props.deleteKey(option);
212:                }
213:            }
214:
215:            /**
216:             *    Description of the Method
217:             *
218:             * @param    defaultValue  Description of Parameter
219:             * @param    minValue      Description of Parameter
220:             */
221:            public void saveInt(int defaultValue, int minValue) {
222:                int val = defaultValue;
223:
224:                try {
225:                    val = Integer.parseInt(((JTextField) component).getText());
226:                } catch (NumberFormatException nfex) {
227:                }
228:                if (val < minValue) {
229:                    val = minValue;
230:                }
231:                save(Integer.toString(val));
232:            }
233:
234:            /**
235:             *    Description of the Method
236:             *
237:             * @return      Description of the Returned Value
238:             */
239:            public boolean localAvailable() {
240:                return (cb == null || cb.isSelected());
241:            }
242:
243:            /**
244:             *    Description of the Method
245:             *
246:             * @return      Description of the Returned Value
247:             */
248:            public boolean localDelete() {
249:                return (props.isLocalProperty(option) && !cb.isSelected());
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.