Source Code Cross Referenced for PermissionsSelectionList.java in  » Content-Management-System » harmonise » org » openharmonise » him » serverconfig » permissions » list » 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 » harmonise » org.openharmonise.him.serverconfig.permissions.list 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at 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. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:        package org.openharmonise.him.serverconfig.permissions.list;
020:
021:        import java.awt.BorderLayout;
022:        import java.awt.Color;
023:        import java.awt.Component;
024:        import java.awt.Container;
025:        import java.awt.Dimension;
026:        import java.awt.LayoutManager;
027:        import java.awt.event.MouseEvent;
028:        import java.awt.event.MouseListener;
029:        import java.util.ArrayList;
030:        import java.util.Iterator;
031:
032:        import javax.swing.BorderFactory;
033:        import javax.swing.JPanel;
034:        import javax.swing.JScrollPane;
035:
036:        import org.openharmonise.vfs.*;
037:
038:        /**
039:         * List of Roles.
040:         * 
041:         * @author Matthew Large
042:         * @version $Revision: 1.1 $
043:         *
044:         */
045:        public class PermissionsSelectionList extends JPanel implements 
046:                MouseListener, LayoutManager {
047:
048:            /**
049:             * Array of Role cells.
050:             */
051:            private Object[] m_roleCells = null;
052:
053:            /**
054:             * Inner panel.
055:             */
056:            private JPanel m_list = null;
057:
058:            /**
059:             * Scroll pane.
060:             */
061:            private JScrollPane m_scroller = null;
062:
063:            /**
064:             * Height of this component.
065:             */
066:            private int m_nHeight = 0;
067:
068:            /**
069:             * Width of this component.
070:             */
071:            private int m_nWidth = 340;
072:
073:            /**
074:             * List of {@link PermissionsSelectionListener} listeners.
075:             */
076:            private ArrayList m_listeners = new ArrayList();
077:
078:            /**
079:             * Constructs a new permissions selection list.
080:             */
081:            public PermissionsSelectionList() {
082:                super ();
083:                this .setup();
084:            }
085:
086:            /**
087:             * 
088:             * 
089:             * @param vals
090:             */
091:            public PermissionsSelectionList(Object[] vals) {
092:                super ();
093:                m_roleCells = vals;
094:                this .setup();
095:            }
096:
097:            /**
098:             * @param arg0
099:             */
100:            private PermissionsSelectionList(boolean arg0) {
101:                super (arg0);
102:            }
103:
104:            /**
105:             * @param arg0
106:             */
107:            private PermissionsSelectionList(LayoutManager arg0) {
108:                super (arg0);
109:            }
110:
111:            /**
112:             * @param arg0
113:             * @param arg1
114:             */
115:            private PermissionsSelectionList(LayoutManager arg0, boolean arg1) {
116:                super (arg0, arg1);
117:            }
118:
119:            private void setup() {
120:                this .setLayout(new BorderLayout());
121:                this .setBorder(BorderFactory.createLineBorder(Color.BLACK));
122:
123:                this .setBackground(Color.WHITE);
124:
125:                m_list = new JPanel();
126:                m_list.setBackground(Color.WHITE);
127:                m_list.setLayout(this );
128:
129:                m_scroller = new JScrollPane(m_list,
130:                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
131:                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
132:                m_scroller.setPreferredSize(new Dimension(270, 300));
133:
134:                this .add(m_scroller);
135:                this .validate();
136:            }
137:
138:            /* (non-Javadoc)
139:             * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
140:             */
141:            public void removeLayoutComponent(Component arg0) {
142:            }
143:
144:            /* (non-Javadoc)
145:             * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
146:             */
147:            public void layoutContainer(Container container) {
148:                int nCount = container.getComponentCount();
149:                int nHeight = 0;
150:
151:                nCount = container.getComponentCount();
152:                for (int i = 0; i < nCount; i++) {
153:                    Component comp = container.getComponent(i);
154:                    comp.setSize(comp.getPreferredSize());
155:                    comp.setLocation(0, nHeight);
156:                    nHeight = nHeight + comp.getPreferredSize().height;
157:                }
158:                if (nHeight != this .m_nHeight) {
159:                    this .m_nHeight = nHeight;
160:                    if (nHeight > 300) {
161:                        ((JPanel) container).setPreferredSize(new Dimension(
162:                                m_nWidth, nHeight));
163:                        this .m_scroller.validate();
164:                    } else {
165:                        ((JPanel) container).setPreferredSize(new Dimension(
166:                                m_nWidth, 300));
167:                        this .m_scroller.validate();
168:                    }
169:                }
170:            }
171:
172:            /* (non-Javadoc)
173:             * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
174:             */
175:            public void addLayoutComponent(String arg0, Component arg1) {
176:            }
177:
178:            /* (non-Javadoc)
179:             * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
180:             */
181:            public Dimension minimumLayoutSize(Container arg0) {
182:                return new Dimension(m_nWidth, this .m_roleCells.length * 20);
183:            }
184:
185:            /* (non-Javadoc)
186:             * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
187:             */
188:            public Dimension preferredLayoutSize(Container arg0) {
189:                return new Dimension(m_nWidth, 100);
190:            }
191:
192:            /* (non-Javadoc)
193:             * @see java.awt.Component#getPreferredSize()
194:             */
195:            public Dimension getPreferredSize() {
196:                return new Dimension(300, 300);
197:            }
198:
199:            public void removeFile(String sPath) {
200:                for (int i = 0; i < m_list.getComponentCount(); i++) {
201:                    if ((m_list.getComponent(i) instanceof  PermissionsSelectionCell)) {
202:                        if (((PermissionsSelectionCell) m_list.getComponent(i))
203:                                .getPath().equals(sPath)) {
204:                            this .m_list.remove(m_list.getComponent(i));
205:                        }
206:                    }
207:                }
208:                this .validateTree();
209:                this .repaint();
210:            }
211:
212:            public void removeSelected() {
213:                for (int i = 0; i < m_list.getComponentCount(); i++) {
214:                    if ((m_list.getComponent(i) instanceof  PermissionsSelectionCell)) {
215:                        if (((PermissionsSelectionCell) m_list.getComponent(i))
216:                                .isSelected()) {
217:                            this .m_list.remove(m_list.getComponent(i));
218:                        }
219:                    }
220:                }
221:                this .validateTree();
222:                this .repaint();
223:            }
224:
225:            public String getSelectedPath() {
226:                for (int i = 0; i < m_list.getComponentCount(); i++) {
227:                    if ((m_list.getComponent(i) instanceof  PermissionsSelectionCell)) {
228:                        if (((PermissionsSelectionCell) m_list.getComponent(i))
229:                                .isSelected()) {
230:                            return ((PermissionsSelectionCell) m_list
231:                                    .getComponent(i)).getPath();
232:                        }
233:                    }
234:                }
235:                return null;
236:            }
237:
238:            /* (non-Javadoc)
239:             * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
240:             */
241:            public void mouseClicked(MouseEvent me) {
242:                if (me.getSource() instanceof  PermissionsSelectionCell) {
243:                    PermissionsSelectionCell cell = (PermissionsSelectionCell) me
244:                            .getSource();
245:                    this .fireSelectionEvent(cell.getPath());
246:                    for (int i = 0; i < m_list.getComponentCount(); i++) {
247:                        if ((m_list.getComponent(i) instanceof  PermissionsSelectionCell)) {
248:                            ((PermissionsSelectionCell) m_list.getComponent(i))
249:                                    .setSelected(false);
250:                        }
251:                    }
252:                    if ((me.getModifiersEx() & (MouseEvent.CTRL_DOWN_MASK)) == MouseEvent.CTRL_DOWN_MASK) {
253:                        cell.setSelected(false);
254:                    } else {
255:                        cell.setSelected(true);
256:                    }
257:                }
258:                this .validateTree();
259:                this .repaint();
260:            }
261:
262:            public void selectPermission(String sPath) {
263:                PermissionsSelectionCell cell = null;
264:                for (int i = 0; i < m_list.getComponentCount(); i++) {
265:                    if ((m_list.getComponent(i) instanceof  PermissionsSelectionCell)) {
266:                        PermissionsSelectionCell tempCell = ((PermissionsSelectionCell) m_list
267:                                .getComponent(i));
268:                        tempCell.setSelected(false);
269:                        if (tempCell.getPath().equals(sPath)) {
270:                            cell = tempCell;
271:                        }
272:                    }
273:                }
274:                if (cell != null) {
275:                    cell.setSelected(true);
276:                    this .fireSelectionEvent(sPath);
277:                }
278:            }
279:
280:            /* (non-Javadoc)
281:             * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
282:             */
283:            public void mouseEntered(MouseEvent arg0) {
284:            }
285:
286:            /* (non-Javadoc)
287:             * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
288:             */
289:            public void mouseExited(MouseEvent arg0) {
290:            }
291:
292:            /* (non-Javadoc)
293:             * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
294:             */
295:            public void mousePressed(MouseEvent arg0) {
296:            }
297:
298:            /* (non-Javadoc)
299:             * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
300:             */
301:            public void mouseReleased(MouseEvent arg0) {
302:            }
303:
304:            public void addFile(String sPath, AbstractVirtualFileSystem vfs) {
305:                ArrayList aReasons = new ArrayList();
306:
307:                PermissionsSelectionCell cell = new PermissionsSelectionCell(
308:                        this , sPath, vfs);
309:                boolean bFound = false;
310:                for (int i = 0; i < m_list.getComponentCount(); i++) {
311:                    if ((m_list.getComponent(i) instanceof  PermissionsSelectionCell)
312:                            && ((PermissionsSelectionCell) m_list
313:                                    .getComponent(i)).equals(cell)) {
314:                        bFound = true;
315:                    }
316:                }
317:                if (!bFound) {
318:                    cell.addMouseListener(this );
319:                    m_list.add(cell);
320:                }
321:
322:                this .validateTree();
323:
324:                m_scroller.validate();
325:            }
326:
327:            public void addPermissionsSelectionListener(
328:                    PermissionsSelectionListener listener) {
329:                if (!this .m_listeners.contains(listener)) {
330:                    this .m_listeners.add(listener);
331:                }
332:            }
333:
334:            public void removePermissionsSelectionListener(
335:                    PermissionsSelectionListener listener) {
336:                this .m_listeners.remove(listener);
337:            }
338:
339:            private void fireSelectionEvent(String sPath) {
340:                Iterator itor = this .m_listeners.iterator();
341:                while (itor.hasNext()) {
342:                    PermissionsSelectionListener element = (PermissionsSelectionListener) itor
343:                            .next();
344:                    element.permissionSelected(sPath);
345:                }
346:            }
347:
348:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.