Source Code Cross Referenced for OptionGroup.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » 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 » Swing Library » jEdit » org.gjt.sp.jedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * OptionGroup.java - Option pane group
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 2000 mike dillon
007:         * Portions copyright (C) 2003 Slava Pestov
008:         *
009:         * This program is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; either version 2
012:         * of the License, or any later version.
013:         *
014:         * This program is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017:         * GNU General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU General Public License
020:         * along with this program; if not, write to the Free Software
021:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
022:         */
023:
024:        package org.gjt.sp.jedit;
025:
026:        import java.util.*;
027:
028:        /**
029:         * A set of option panes shown in one branch in the options dialog.<p>
030:         *
031:         * Plugins should not create instances of this class directly. See
032:         * {@link EditPlugin} for information on how jEdit obtains and constructs
033:         * option pane instances.
034:         *
035:         * @author Mike Dillon
036:         * @version $Id: OptionGroup.java 8133 2006-11-25 19:50:58Z ezust $
037:         */
038:        public class OptionGroup {
039:
040:            // {{{ data members
041:            protected final String name;
042:            protected final String label;
043:            protected final Vector members;
044:            private boolean sort;
045:
046:            // }}}
047:
048:            //{{{ OptionGroup constructor
049:            /**
050:             * Creates an option group.
051:             * @param name The internal name of the option group, used to key a
052:             * property <code>options.<i>name</i>.label</code> which is the
053:             * label displayed in the options dialog.
054:             * @see jEdit#getProperty(String)
055:             */
056:            public OptionGroup(String name) {
057:                this .name = name;
058:                label = jEdit.getProperty("options." + name + ".label");
059:                members = new Vector();
060:            } //}}}
061:
062:            //{{{ OptionGroup constructor
063:            /**
064:             * Creates an option group.
065:             * @param label The label
066:             * @param options A whitespace-separated list of option pane names
067:             * @since jEdit 4.2pre2
068:             */
069:            public OptionGroup(String name, String label, String options) {
070:                this .name = name;
071:                this .label = label;
072:                members = new Vector();
073:
074:                StringTokenizer st = new StringTokenizer(options);
075:                while (st.hasMoreTokens()) {
076:                    String pane = st.nextToken();
077:                    addOptionPane(pane);
078:                }
079:            } //}}}
080:
081:            //{{{ getName() method
082:            public String getName() {
083:                return name;
084:            } //}}}
085:
086:            //{{{ getLabel() method
087:            /**
088:             * Returns the option group's human-readable label.
089:             * @since jEdit 4.2pre1
090:             */
091:            public String getLabel() {
092:                return label;
093:            } //}}}
094:
095:            //{{{ addOptionGroup() method
096:            public void addOptionGroup(OptionGroup group) {
097:                insertionSort(group.getLabel(), group);
098:            } //}}}
099:
100:            //{{{ addOptionPane() method
101:            public void addOptionPane(OptionPane pane) {
102:                String label = jEdit.getProperty("options." + pane.getName()
103:                        + ".label", "NO LABEL PROPERTY: " + pane.getName());
104:
105:                insertionSort(label, pane);
106:            } //}}}
107:
108:            //{{{ addOptionPane() method
109:            public void addOptionPane(String pane) {
110:                String label = jEdit.getProperty("options." + pane + ".label",
111:                        "NO LABEL PROPERTY: " + pane);
112:
113:                insertionSort(label, pane);
114:            } //}}}
115:
116:            //{{{ getMembers() method
117:            public Enumeration getMembers() {
118:                return members.elements();
119:            } //}}}
120:
121:            //{{{ getMember() method
122:            public Object getMember(int index) {
123:                return (index >= 0 && index < members.size()) ? members
124:                        .elementAt(index) : null;
125:            } //}}}
126:
127:            //{{{ getMemberIndex() method
128:            public int getMemberIndex(Object member) {
129:                return members.indexOf(member);
130:            } //}}}
131:
132:            //{{{ getMemberCount() method
133:            public int getMemberCount() {
134:                return members.size();
135:            } //}}}
136:
137:            //{{{ setSort() method
138:            /**
139:             * Sets if the members of this group should be sorted.
140:             * @since jEdit 4.2pre3
141:             */
142:            public void setSort(boolean sort) {
143:                this .sort = sort;
144:            } //}}}
145:
146:            //{{{ Private members
147:
148:            //{{{ insertionSort() method
149:            private void insertionSort(String newLabel, Object newObj) {
150:                if (sort) {
151:                    for (int i = 0; i < members.size(); i++) {
152:                        Object obj = members.elementAt(i);
153:                        String label;
154:                        if (obj instanceof  OptionPane) {
155:                            String name = ((OptionPane) obj).getName();
156:                            label = jEdit.getProperty("options." + name
157:                                    + ".label", "NO LABEL PROPERTY: " + name);
158:                        } else if (obj instanceof  String) {
159:                            label = jEdit.getProperty("options." + obj
160:                                    + ".label", "NO LABEL PROPERTY: " + obj);
161:                        } else if (obj instanceof  OptionGroup)
162:                            label = ((OptionGroup) obj).getLabel();
163:                        else
164:                            throw new InternalError();
165:
166:                        if (newLabel.compareToIgnoreCase(label) < 0) {
167:                            members.insertElementAt(newObj, i);
168:                            return;
169:                        }
170:                    }
171:                }
172:
173:                members.addElement(newObj);
174:            } //}}}
175:
176:            //}}}
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.