Source Code Cross Referenced for FindTextAction.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » gui » explorer » 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 » Content Management System » contelligent » de.finix.contelligent.client.gui.explorer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.client.gui.explorer;
019:
020:        import java.awt.event.ActionEvent;
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:        import java.util.logging.Level;
024:
025:        import javax.swing.AbstractAction;
026:        import javax.swing.Action;
027:        import javax.swing.JOptionPane;
028:        import javax.swing.tree.DefaultMutableTreeNode;
029:        import javax.swing.tree.TreePath;
030:
031:        import de.finix.contelligent.client.base.ComponentFactory;
032:        import de.finix.contelligent.client.base.ComponentNotFoundException;
033:        import de.finix.contelligent.client.base.ComponentReference;
034:        import de.finix.contelligent.client.base.ContelligentComponent;
035:        import de.finix.contelligent.client.gui.ComponentEditor;
036:        import de.finix.contelligent.client.gui.ContelligentAction;
037:        import de.finix.contelligent.client.gui.category.CategorySensitiveComposedEditor;
038:        import de.finix.contelligent.client.gui.directory.FindOptionPane;
039:        import de.finix.contelligent.client.gui.text.ContelligentEditorKit;
040:        import de.finix.contelligent.client.gui.text.ReplaceDialog;
041:        import de.finix.contelligent.client.gui.text.TextEditor;
042:        import de.finix.contelligent.client.i18n.Resources;
043:        import de.finix.contelligent.client.remote.ActionResult;
044:        import de.finix.contelligent.client.remote.Actions;
045:        import de.finix.contelligent.client.remote.RemoteActionException;
046:        import de.finix.contelligent.client.util.ExceptionDialog;
047:
048:        public class FindTextAction extends AbstractAction implements 
049:                ContelligentAction {
050:            /**
051:             * 
052:             */
053:            private final ExplorerEditor editor;
054:
055:            public FindTextAction(ExplorerEditor editor) {
056:                super ("find_text_action", Resources.findIcon);
057:                this .editor = editor;
058:                putValue(TYPE, PUSH_ACTION);
059:                putValue(ACTION_TYPE, EDIT_ACTION);
060:                putValue(ACTION_GROUP, EDIT_SEARCH_GROUP);
061:                putValue(ACTION_POS, EDIT_SEARCH_TEXT);
062:                putValue(MENU_TARGET, MENU);
063:                putValue(BUTTON_TARGET, NO_BUTTON);
064:                putValue(POPUP_TARGET, POPUP_SUBMENU);
065:                putValue(POPUP_PARENT_ACTION, this .editor.findAction);
066:            }
067:
068:            public void actionPerformed(ActionEvent e) {
069:                final TreePath[] selectionPaths = this .editor.tree
070:                        .getSelectionPaths();
071:                String findPath = null;
072:                if (selectionPaths != null) {
073:                    if (selectionPaths.length > 0
074:                            && this .editor.guiContainer != null) {
075:                        DefaultMutableTreeNode firstNode = ((DefaultMutableTreeNode) selectionPaths[0]
076:                                .getLastPathComponent());
077:                        if (firstNode != null
078:                                && firstNode.getUserObject() instanceof  ComponentReference) {
079:                            try {
080:                                ContelligentComponent component = ((ComponentReference) firstNode
081:                                        .getUserObject()).getComponent();
082:                                findPath = component.getPath();
083:                            } catch (ComponentNotFoundException cnfe) {
084:                                ExceptionDialog.show(cnfe);
085:                            }
086:                        }
087:                    }
088:                }
089:                FindOptionPane findOptionPane = new FindOptionPane();
090:                if (findOptionPane.showFindDialog(this .editor.searchTerm,
091:                        findPath, false) == JOptionPane.OK_OPTION) {
092:                    try {
093:                        this .editor.searchTerm = findOptionPane.getSearchText();
094:                        if (findOptionPane.searchAll()) {
095:                            findPath = "/";
096:                        } else {
097:                            findPath = findOptionPane.getPath();
098:                        }
099:                        ActionResult response = Actions.find(editor.getView()
100:                                .getEnvironment(), this .editor.searchTerm,
101:                                findPath, ComponentFactory.getInstance()
102:                                        .getCurrentContext().getName());
103:                        ContelligentEditorKit
104:                                .setSearchString(this .editor.searchTerm);
105:                        final Collection paths = response.getPaths();
106:                        if (this .editor.pathSelectionManager != null) {
107:                            this .editor.pathSelectionManager
108:                                    .setPaths(Resources
109:                                            .getLocalString("search_results"),
110:                                            paths,
111:                                            new Action[] { new AbstractAction(
112:                                                    "replace") {
113:                                                public void actionPerformed(
114:                                                        ActionEvent e) {
115:                                                    ReplaceDialog dialog = new ReplaceDialog(
116:                                                            ContelligentEditorKit
117:                                                                    .getSearchString(),
118:                                                            ContelligentEditorKit
119:                                                                    .getReplaceString(),
120:                                                            false);
121:                                                    int option;
122:                                                    if ((option = dialog
123:                                                            .showReplaceDialog()) != JOptionPane.CANCEL_OPTION
124:                                                            && getSearchString(dialog)) {
125:                                                        String selectedPath = FindTextAction.this .editor.pathSelectionManager
126:                                                                .getSelectedPath();
127:                                                        boolean start = (selectedPath == null);
128:                                                        for (Iterator it = paths
129:                                                                .iterator(); it
130:                                                                .hasNext();) {
131:                                                            String path = (String) it
132:                                                                    .next();
133:                                                            if (!start
134:                                                                    && !path
135:                                                                            .equals(selectedPath)) {
136:                                                                continue;
137:                                                            } else {
138:                                                                start = true;
139:                                                                FindTextAction.this .editor
140:                                                                        .selectComponent(path);
141:                                                                try {
142:                                                                    ContelligentComponent component = ComponentFactory
143:                                                                            .getInstance()
144:                                                                            .getComponent(
145:                                                                                    path);
146:                                                                    FindTextAction.this .editor.guiContainer
147:                                                                            .setSelectedComponent(component);
148:                                                                    FindTextAction.this .editor.guiContainer
149:                                                                            .renderSelectedComponent();
150:                                                                    FindTextAction.this .editor
151:                                                                            .selectComponent(component);
152:                                                                    FindTextAction.this .editor.guiContainer
153:                                                                            .editSelectedComponent();
154:                                                                    ComponentEditor[] editor = FindTextAction.this .editor
155:                                                                            .getView()
156:                                                                            .getEditors();
157:                                                                    for (int i = 0; i < editor.length; i++) {
158:                                                                        if (editor[i] instanceof  CategorySensitiveComposedEditor) {
159:                                                                            FindTextAction.this .editor
160:                                                                                    .getView()
161:                                                                                    .makeEditorVisible(
162:                                                                                            editor[i]);
163:                                                                            for (Iterator ie = ((CategorySensitiveComposedEditor) editor[i])
164:                                                                                    .getEditors()
165:                                                                                    .iterator(); ie
166:                                                                                    .hasNext();) {
167:                                                                                ComponentEditor innerEditor = (ComponentEditor) ie
168:                                                                                        .next();
169:                                                                                if (innerEditor instanceof  TextEditor) {
170:                                                                                    ContelligentEditorKit
171:                                                                                            .setSearchString(dialog
172:                                                                                                    .getSearchText());
173:                                                                                    ContelligentEditorKit
174:                                                                                            .setReplaceString(dialog
175:                                                                                                    .getReplaceText());
176:                                                                                    option = ((TextEditor) innerEditor)
177:                                                                                            .getEditorKit()
178:                                                                                            .replace(
179:                                                                                                    0,
180:                                                                                                    option);
181:                                                                                    innerEditor
182:                                                                                            .commit();
183:                                                                                }
184:                                                                            }
185:                                                                        }
186:                                                                    }
187:                                                                } catch (ComponentNotFoundException cnfe) {
188:                                                                    ExplorerEditor.logger
189:                                                                            .log(
190:                                                                                    Level.WARNING,
191:                                                                                    "Could not search in component!",
192:                                                                                    cnfe);
193:                                                                }
194:                                                            }
195:                                                            FindTextAction.this .editor
196:                                                                    .getView()
197:                                                                    .commit();
198:                                                        }
199:                                                    }
200:                                                }
201:                                            } });
202:                            this .editor.pathSelectionManager.showPaths();
203:                        }
204:                    } catch (RemoteActionException rae) {
205:                        ExceptionDialog.show(rae);
206:                    }
207:                }
208:            }
209:
210:            private boolean getSearchString(ReplaceDialog replaceDialog) {
211:                if (replaceDialog == null)
212:                    return false;
213:                ContelligentEditorKit.setSearchString(replaceDialog
214:                        .getSearchText());
215:                ContelligentEditorKit.setReplaceString(replaceDialog
216:                        .getReplaceText());
217:                if (ContelligentEditorKit.getSearchString().length() == 0) {
218:                    java.awt.Toolkit.getDefaultToolkit().beep();
219:                    return false;
220:                }
221:                return true;
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.