Source Code Cross Referenced for BookmarkReference.java in  » Database-Client » iSQL-Viewer » org » isqlviewer » bookmarks » 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 » Database Client » iSQL Viewer » org.isqlviewer.bookmarks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Mozilla Public License
003:         * Version 1.1 (the "License"); you may not use this file except in
004:         * compliance with the License. You may obtain a copy of the License at
005:         * http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009:         * License for the specific language governing rights and limitations
010:         * under the License.
011:         * 
012:         * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013:         *
014:         * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015:         * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016:         *
017:         * Contributor(s): 
018:         *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019:         *  
020:         * If you didn't download this code from the following link, you should check
021:         * if you aren't using an obsolete version: http://www.isqlviewer.com
022:         */
023:        package org.isqlviewer.bookmarks;
024:
025:        import java.awt.datatransfer.DataFlavor;
026:        import java.awt.datatransfer.Transferable;
027:        import java.awt.datatransfer.UnsupportedFlavorException;
028:        import java.io.IOException;
029:        import java.io.Serializable;
030:        import java.sql.SQLException;
031:
032:        import org.isqlviewer.sql.embedded.EmbeddedDatabase;
033:        import org.isqlviewer.util.BasicUtilities;
034:
035:        /**
036:         * TODO Add BookmarkReference JavaDoc inforamation
037:         * <p>
038:         * 
039:         * @author Mark A. Kobold &lt;mkobold at isqlviewer dot com&gt;
040:         * @version 1.0
041:         */
042:        public class BookmarkReference implements  Transferable, Serializable {
043:
044:            /**
045:             * Standard data-transfer flavor for DnD operations.
046:             */
047:            public static final DataFlavor BOOKMARK_REFERENCE_FLAVOR = new DataFlavor(
048:                    BookmarkReference.class, "iSQL-Viewer Bookmark Reference");
049:
050:            private static final long serialVersionUID = 3377871201547716160L;
051:            private long id = -1;
052:            private String name = null;
053:            private BookmarkFolder folder = null;
054:            private boolean favorite = false;
055:            private ColorLabel colorLabel = null;
056:
057:            @Override
058:            public boolean equals(Object other) {
059:
060:                if (other instanceof  BookmarkReference) {
061:                    BookmarkReference reference = (BookmarkReference) other;
062:                    return id == reference.id;
063:                }
064:                return false;
065:            }
066:
067:            @Override
068:            public int hashCode() {
069:
070:                return (int) (id ^ (id >>> 32));
071:            }
072:
073:            @Override
074:            public String toString() {
075:
076:                return name;
077:            }
078:
079:            /**
080:             * Determine if this flag is a favourite.
081:             * <p>
082:             * If a bookmark has the favourite flag set to true, then the bookmark will also be made available into a special
083:             * favourites folder.
084:             * 
085:             * @return if this bookmark is a favourite bookmark.
086:             */
087:            public boolean isFavorite() {
088:
089:                return favorite;
090:            }
091:
092:            /**
093:             * Modifies the favourite flag for this bookmark instance.
094:             * <p>
095:             * 
096:             * @param favorite setting to enable/disable the favourite status of this bookmark.
097:             */
098:            public void setFavorite(boolean favorite) {
099:
100:                this .favorite = favorite;
101:            }
102:
103:            /**
104:             * @param folder the folder to set
105:             */
106:            public void setFolder(BookmarkFolder folder) {
107:
108:                this .folder = folder;
109:            }
110:
111:            /**
112:             * @return the id
113:             */
114:            public long getId() {
115:
116:                return id;
117:            }
118:
119:            /**
120:             * @param id the id to set
121:             */
122:            public void setId(long id) {
123:
124:                this .id = id;
125:            }
126:
127:            /**
128:             * Gets the user defined name for this bookmark.
129:             * <p>
130:             * 
131:             * @return the conical name for this bookmark as defined by the user.
132:             */
133:            public String getName() {
134:
135:                return name == null ? "" : name;
136:            }
137:
138:            /**
139:             * Sets the user defined name for this bookmark.
140:             * <p>
141:             * If a <tt>null</tt> name is provided, then a empty string will be inferred as the intended value of the new
142:             * name.
143:             * 
144:             * @param name of the bookmark to be identified by the user.
145:             */
146:            public void setName(String name) {
147:
148:                this .name = name == null ? "" : name;
149:            }
150:
151:            /**
152:             * Gets the path of this folder.
153:             * <p>
154:             * 
155:             * @return UNIX like path of the folder that contains this bookmark.
156:             */
157:            public String getPath() {
158:
159:                return folder == null ? "/" : folder.getPath();
160:            }
161:
162:            /**
163:             * Gets the label color for this bookmark.
164:             * <p>
165:             * Allows specific client-side coloring for particular bookmarks; inspired from Finder.
166:             * 
167:             * @return the colorLabel to color the label; can be null;
168:             */
169:            public ColorLabel getColorLabel() {
170:
171:                return colorLabel;
172:            }
173:
174:            /**
175:             * Sets the label color color for displaying this bookmark.
176:             * <p>
177:             * 
178:             * @param colorLabel the colorLabel to set; use null to turn of
179:             */
180:            public void setColorLabel(ColorLabel labelColor) {
181:
182:                this .colorLabel = labelColor;
183:            }
184:
185:            public Object getTransferData(DataFlavor flavor)
186:                    throws UnsupportedFlavorException, IOException {
187:
188:                if (flavor != null) {
189:                    if (BOOKMARK_REFERENCE_FLAVOR.equals(flavor)) {
190:                        return this ;
191:                    }
192:                    Bookmark bookmark = null;
193:                    EmbeddedDatabase database = EmbeddedDatabase
194:                            .getSharedInstance();
195:                    try {
196:                        bookmark = database.getBookmark(this );
197:                        bookmark.setFolder(getFolder());
198:                    } catch (SQLException sourceError) {
199:                        IOException wrappedError = new IOException(sourceError
200:                                .getMessage());
201:                        BasicUtilities.wrapThrowable(sourceError, wrappedError);
202:                        throw wrappedError;
203:                    }
204:                    if (Bookmark.BOOKMARK_FLAVOR.equals(flavor)) {
205:                        return bookmark;
206:                    } else if (flavor.isFlavorTextType()) {
207:                        return bookmark.getCommandText();
208:                    }
209:
210:                }
211:                throw new UnsupportedFlavorException(flavor);
212:            }
213:
214:            public DataFlavor[] getTransferDataFlavors() {
215:
216:                return new DataFlavor[] { BOOKMARK_REFERENCE_FLAVOR,
217:                        Bookmark.BOOKMARK_FLAVOR, DataFlavor.stringFlavor };
218:            }
219:
220:            public boolean isDataFlavorSupported(DataFlavor flavor) {
221:
222:                if (flavor != null) {
223:                    if (BOOKMARK_REFERENCE_FLAVOR.equals(flavor)) {
224:                        return true;
225:                    } else if (Bookmark.BOOKMARK_FLAVOR.equals(flavor)) {
226:                        return true;
227:                    } else if (flavor.isFlavorTextType()) {
228:                        return true;
229:                    }
230:                }
231:                return false;
232:            }
233:
234:            /**
235:             * Protected call for getting a reference to this bookmarks parent folder.
236:             * <p>
237:             * Bookmarks publicly should be always be manipulated from the folder object that owns it.
238:             * 
239:             * @return reference to the owning folder.
240:             */
241:            public BookmarkFolder getFolder() {
242:
243:                return folder;
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.