Source Code Cross Referenced for AbstractSearchPanel.java in  » Net » SkunkDAV » org » skunk » dav » client » gui » editor » 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 » Net » SkunkDAV » org.skunk.dav.client.gui.editor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright (c) 2000, Jacob Smullyan.
003:         *
004:         *  This is part of SkunkDAV, a WebDAV client.  See http://skunkdav.sourceforge.net/ 
005:         *  for the latest version.
006:         * 
007:         *  SkunkDAV is free software; you can redistribute it and/or
008:         *  modify it under the terms of the GNU General Public License as published
009:         *  by the Free Software Foundation; either version 2, or (at your option)
010:         *  any later version.
011:         * 
012:         *  SkunkDAV  is distributed in the hope that it will be useful,
013:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *  General Public License for more details.
016:         * 
017:         *  You should have received a copy of the GNU General Public License
018:         *  along with SkunkDAV; see the file COPYING.  If not, write to the Free
019:         *  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
020:         *  02111-1307, USA.
021:         */
022:
023:        package org.skunk.dav.client.gui.editor;
024:
025:        import java.awt.Font;
026:        import java.awt.event.ActionEvent;
027:        import java.awt.event.ActionListener;
028:        import java.awt.event.KeyAdapter;
029:        import java.awt.event.KeyEvent;
030:        import java.util.ArrayList;
031:        import java.util.Enumeration;
032:        import javax.swing.AbstractButton;
033:        import javax.swing.ButtonGroup;
034:        import javax.swing.JCheckBox;
035:        import javax.swing.JComponent;
036:        import javax.swing.JRadioButton;
037:        import javax.swing.JTextField;
038:        import javax.swing.JPanel;
039:        import javax.swing.event.DocumentEvent;
040:        import javax.swing.event.DocumentListener;
041:        import org.skunk.dav.client.gui.ResourceManager;
042:        import org.skunk.trace.Debug;
043:
044:        public abstract class AbstractSearchPanel extends JPanel implements 
045:                ISearchPanel {
046:            private ArrayList actionListeners;
047:            public static final int ENTRY_FIELD_LENGTH = 20;
048:            protected JTextField entryField, replaceField;
049:            protected JCheckBox reverseButton, incrementalButton,
050:                    wrappedButton;
051:            protected JRadioButton literalButton, caseButton, regexpButton;
052:            private int searchMode;
053:
054:            public AbstractSearchPanel() {
055:                super ();
056:                actionListeners = new ArrayList();
057:                initComponents();
058:            }
059:
060:            protected abstract void initComponents();
061:
062:            protected void createReverseCheckBox() {
063:                reverseButton = new JCheckBox(ResourceManager
064:                        .getMessage(ResourceManager.REVERSE_OPTION), false);
065:            }
066:
067:            protected void createIncrementalCheckBox() {
068:                incrementalButton = new JCheckBox(ResourceManager
069:                        .getMessage(ResourceManager.INCREMENTAL_OPTION), true);
070:            }
071:
072:            protected void createWrappedCheckBox() {
073:                wrappedButton = new JCheckBox(ResourceManager
074:                        .getMessage(ResourceManager.WRAPPED_OPTION), false);
075:            }
076:
077:            protected void createSearchModeButtonGroup()
078:    {
079:	literalButton=new JRadioButton(ResourceManager.getMessage(ResourceManager.LITERAL_OPTION));
080:	literalButton.setActionCommand(ResourceManager.LITERAL_OPTION);
081:
082:	caseButton=new JRadioButton(ResourceManager.getMessage(ResourceManager.CASE_OPTION));
083:	caseButton.setActionCommand(ResourceManager.CASE_OPTION);
084:
085:	regexpButton=new JRadioButton(ResourceManager.getMessage(ResourceManager.REGEXP_OPTION));
086:	regexpButton.setActionCommand(ResourceManager.REGEXP_OPTION);
087:	
088:	final ButtonGroup group=new ButtonGroup();
089:	group.add(literalButton);
090:	group.add(caseButton);
091:	group.add(regexpButton);
092:	
093:	ActionListener groupListener=new ActionListener()
094:	    {
095:		public void actionPerformed(ActionEvent ae)
096:		{
097:		    int mode=getSearchModeForActionCommand(group.getSelection().getActionCommand());
098:		    AbstractSearchPanel.this .searchMode=mode;
099:		}
100:	    };
101:	for (Enumeration enum=group.getElements();enum.hasMoreElements();)
102:	{
103:	    ((AbstractButton)enum.nextElement()).addActionListener(groupListener);
104:	}
105:	group.setSelected(literalButton.getModel(), true);
106:    }
107:
108:            protected void createEntryField() {
109:                entryField = new JTextField(ENTRY_FIELD_LENGTH);
110:                entryField.setFont(new Font("Serif", Font.PLAIN, 10));
111:                entryField.setMaximumSize(entryField.getPreferredSize());
112:                entryField.getDocument().addDocumentListener(
113:                        new DocumentListener() {
114:                            public void changedUpdate(DocumentEvent donkey) {
115:                            }
116:
117:                            public void insertUpdate(DocumentEvent donkey) {
118:                                if (isIncremental())
119:                                    fireActionEvent(isReverse() ? SEARCH_FROM_SELECTION
120:                                            : SEARCH_FROM_CARET);
121:                            }
122:
123:                            public void removeUpdate(DocumentEvent donkey) {
124:                                if (isIncremental())
125:                                    fireActionEvent(SEARCH_FROM_START_OR_END);
126:                            }
127:                        });
128:
129:                entryField.addKeyListener(new KeyAdapter() {
130:                    public void keyPressed(KeyEvent ke) {
131:                        if (ke.getKeyCode() == KeyEvent.VK_ESCAPE)
132:                            fireActionEvent(END_SEARCH);
133:                    }
134:                });
135:
136:                entryField.addActionListener(new ActionListener() {
137:                    public void actionPerformed(ActionEvent ae) {
138:                        fireActionEvent(isReverse() ? SEARCH_FROM_CARET
139:                                : SEARCH_FROM_SELECTION);
140:                    }
141:                });
142:            }
143:
144:            public void createReplaceField() {
145:                replaceField = new JTextField(ENTRY_FIELD_LENGTH);
146:                replaceField.setFont(new Font("Serif", Font.PLAIN, 10));
147:                replaceField.setMaximumSize(replaceField.getPreferredSize());
148:
149:                replaceField.addKeyListener(new KeyAdapter() {
150:                    public void keyPressed(KeyEvent ke) {
151:                        if (ke.getKeyCode() == KeyEvent.VK_ESCAPE)
152:                            fireActionEvent(END_SEARCH);
153:                    }
154:                });
155:
156:                replaceField.addActionListener(new ActionListener() {
157:                    public void actionPerformed(ActionEvent ae) {
158:                        fireActionEvent(isReverse() ? SEARCH_FROM_CARET
159:                                : SEARCH_FROM_SELECTION);
160:                    }
161:                });
162:            }
163:
164:            public JComponent getComponent() {
165:                return this ;
166:            }
167:
168:            public void addActionListener(ActionListener listener) {
169:                actionListeners.add(listener);
170:            }
171:
172:            public void removeActionListener(ActionListener listener) {
173:                actionListeners.remove(listener);
174:            }
175:
176:            public void fireActionEvent(String command) {
177:                Debug.trace(this , Debug.DP3, "in fireActionEvent()");
178:                ActionEvent ae = new ActionEvent(this ,
179:                        ActionEvent.ACTION_PERFORMED, command);
180:                Object[] listenerArray = actionListeners.toArray();
181:                for (int i = 0; i < listenerArray.length; i++) {
182:                    ((ActionListener) listenerArray[i]).actionPerformed(ae);
183:                }
184:            }
185:
186:            protected int getSearchModeForActionCommand(String actionCommand) {
187:                if (ResourceManager.LITERAL_OPTION.equals(actionCommand))
188:                    return LITERAL_MODE;
189:                else if (ResourceManager.CASE_OPTION.equals(actionCommand))
190:                    return CASE_MODE;
191:                else if (ResourceManager.REGEXP_OPTION.equals(actionCommand))
192:                    return REGEXP_MODE;
193:                throw new IllegalArgumentException(
194:                        "unrecognized action command");
195:            }
196:
197:            public boolean isReverse() {
198:                if (reverseButton != null)
199:                    return reverseButton.isSelected();
200:                else
201:                    return false;
202:            }
203:
204:            public boolean isIncremental() {
205:                if (incrementalButton != null)
206:                    return incrementalButton.isSelected();
207:                else
208:                    return false;
209:            }
210:
211:            public boolean isWrapped() {
212:                if (wrappedButton != null)
213:                    return wrappedButton.isSelected();
214:                else
215:                    return false;
216:            }
217:
218:            public int getSearchMode() {
219:                return this .searchMode;
220:            }
221:
222:            public String getSearchText() {
223:                if (entryField != null)
224:                    return entryField.getText();
225:                else
226:                    return null;
227:            }
228:
229:            public String getReplaceText() {
230:                if (replaceField != null)
231:                    return replaceField.getText();
232:                else
233:                    return null;
234:            }
235:
236:            public void focus() {
237:                entryField.requestFocus();
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.