Source Code Cross Referenced for ForumAdmin.java in  » Groupware » lucane » org » lucane » applications » forumadmin » 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 » Groupware » lucane » org.lucane.applications.forumadmin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Lucane - a collaborative platform
003:         * Copyright (C) 2002  Vincent Fiack <vfiack@mail15.com>
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:        package org.lucane.applications.forumadmin;
020:
021:        import org.lucane.client.*;
022:        import org.lucane.client.acl.AclEditor;
023:        import org.lucane.client.widgets.*;
024:        import org.lucane.common.*;
025:        import org.lucane.common.acl.AclInfo;
026:        import org.lucane.common.acl.AclProducer;
027:        import org.lucane.common.net.ObjectConnection;
028:
029:        import java.awt.*;
030:        import java.awt.event.*;
031:        import java.util.ArrayList;
032:        import javax.swing.*;
033:
034:        public class ForumAdmin extends StandalonePlugin implements 
035:                ActionListener, AclProducer {
036:
037:            private ManagedWindow mainWindow;
038:            private JButton btnCreate;
039:            private JButton btnDelete;
040:            private JButton btnACL;
041:            private JButton btnClose;
042:            private JList lstForums;
043:            private ConnectInfo service;
044:
045:            public ForumAdmin() {
046:            }
047:
048:            public Plugin newInstance(ConnectInfo[] friends) {
049:                return new ForumAdmin();
050:            }
051:
052:            public void start() {
053:                this .service = Communicator.getInstance().getConnectInfo(
054:                        "org.lucane.applications.forumadmin");
055:
056:                mainWindow = new ManagedWindow(this , getTitle());
057:                lstForums = new JList();
058:                btnCreate = new JButton(tr("btn.create"));
059:                btnDelete = new JButton(tr("btn.remove"));
060:                btnACL = new JButton(tr("btn.accessControl"));
061:                btnClose = new JButton(tr("btn.close"));
062:                btnCreate.addActionListener(this );
063:                btnDelete.addActionListener(this );
064:                btnACL.addActionListener(this );
065:                btnClose.addActionListener(this );
066:                mainWindow.getContentPane().setLayout(new BorderLayout());
067:                mainWindow.getContentPane().add(lstForums, BorderLayout.CENTER);
068:
069:                JPanel pnlBtns = new JPanel(new BorderLayout());
070:                JPanel pnlTop = new JPanel(new GridLayout(0, 1));
071:                pnlTop.add(btnCreate);
072:                pnlTop.add(btnDelete);
073:                pnlTop.add(btnACL);
074:                pnlBtns.add(pnlTop, BorderLayout.NORTH);
075:                pnlBtns.add(btnClose, BorderLayout.SOUTH);
076:                mainWindow.getContentPane().add(pnlBtns, BorderLayout.EAST);
077:                mainWindow.setPreferredSize(new Dimension(400, 300));
078:                mainWindow.show();
079:                getForumList();
080:            }
081:
082:            public void actionPerformed(ActionEvent ae) {
083:                if (ae.getSource() == btnCreate)
084:                    createForum();
085:                else if (ae.getSource() == btnDelete)
086:                    deleteForum();
087:                else if (ae.getSource() == btnClose) {
088:                    mainWindow.dispose();
089:                    exit();
090:                } else if (ae.getSource() == btnACL)
091:                    editAcl();
092:            }
093:
094:            private void getForumList() {
095:                try {
096:                    ForumAdminAction action = new ForumAdminAction(
097:                            ForumAdminAction.LIST_FORUMS);
098:                    ObjectConnection oc = Communicator.getInstance()
099:                            .sendMessageTo(service, getName(), action);
100:
101:                    String ack = oc.readString();
102:                    if (ack.equals("OK")) {
103:                        ArrayList forums = (ArrayList) oc.read();
104:                        lstForums.setListData(forums.toArray());
105:                    } else
106:                        DialogBox.error(ack);
107:
108:                    oc.close();
109:                } catch (Exception e) {
110:                    DialogBox.error(tr("err.list"));
111:                }
112:            }
113:
114:            private void createForum() {
115:                String forum = JOptionPane.showInputDialog(tr("msg.newForum"));
116:
117:                if (forum == null || forum.equals(""))
118:                    return;
119:
120:                try {
121:                    ForumAdminAction action = new ForumAdminAction(
122:                            ForumAdminAction.CREATE_FORUM, forum);
123:                    ObjectConnection oc = Communicator.getInstance()
124:                            .sendMessageTo(service, getName(), action);
125:
126:                    String ack = (String) oc.read();
127:                    oc.close();
128:
129:                    if (ack.equals("OK"))
130:                        getForumList();
131:                    else
132:                        DialogBox.error(ack);
133:
134:                } catch (Exception e) {
135:                    DialogBox.error(tr("err.create"));
136:                }
137:            }
138:
139:            private void deleteForum() {
140:                String forum = (String) lstForums.getSelectedValue();
141:
142:                if (forum == null)
143:                    return;
144:
145:                try {
146:                    ForumAdminAction action = new ForumAdminAction(
147:                            ForumAdminAction.DELETE_FORUM, forum);
148:
149:                    ObjectConnection oc = Communicator.getInstance()
150:                            .sendMessageTo(service, getName(), action);
151:                    String ack = (String) oc.read();
152:                    oc.close();
153:
154:                    if (ack.equals("OK"))
155:                        getForumList();
156:                    else
157:                        DialogBox.error(ack);
158:                } catch (Exception e) {
159:                    DialogBox.error(tr("err.delete"));
160:                }
161:            }
162:
163:            private void editAcl() {
164:                String forum = (String) lstForums.getSelectedValue();
165:
166:                if (forum == null)
167:                    return;
168:
169:                try {
170:                    AclEditor editor = new AclEditor(this , this , forum);
171:                    editor.show();
172:                } catch (Exception e) {
173:                    DialogBox.error(tr("err.unableToEditAcl"));
174:                    e.printStackTrace();
175:                }
176:            }
177:
178:            public AclInfo[] getAcls(String forum) throws Exception {
179:                AclInfo[] acl = null;
180:
181:                ForumAdminAction action = new ForumAdminAction(
182:                        ForumAdminAction.GET_ACLS, forum);
183:                ObjectConnection oc = Communicator.getInstance().sendMessageTo(
184:                        service, getName(), action);
185:                String ack = (String) oc.read();
186:
187:                if (ack.equals("OK")) {
188:                    acl = (AclInfo[]) oc.read();
189:                    oc.close();
190:
191:                    return acl;
192:                }
193:                oc.close();
194:                throw new Exception(ack);
195:            }
196:
197:            public ArrayList getAllGroups() throws Exception {
198:                ArrayList groups = null;
199:
200:                ForumAdminAction action = new ForumAdminAction(
201:                        ForumAdminAction.GET_GROUPS);
202:                ObjectConnection oc = Communicator.getInstance().sendMessageTo(
203:                        service, getName(), action);
204:                String ack = (String) oc.read();
205:
206:                if (ack.equals("OK")) {
207:                    groups = (ArrayList) oc.read();
208:                    oc.close();
209:
210:                    return groups;
211:                }
212:                oc.close();
213:                throw new Exception(ack);
214:            }
215:
216:            public ArrayList getAllUsers() throws Exception {
217:                ArrayList users = null;
218:
219:                ForumAdminAction action = new ForumAdminAction(
220:                        ForumAdminAction.GET_USERS);
221:                ObjectConnection oc = Communicator.getInstance().sendMessageTo(
222:                        service, getName(), action);
223:                String ack = (String) oc.read();
224:
225:                if (ack.equals("OK")) {
226:                    users = (ArrayList) oc.read();
227:                    oc.close();
228:
229:                    return users;
230:                }
231:                oc.close();
232:                throw new Exception(ack);
233:            }
234:
235:            public void addAcl(String forum, AclInfo info) throws Exception {
236:                ForumAdminAction action = new ForumAdminAction(
237:                        ForumAdminAction.ADD_ACL, forum, info);
238:                ObjectConnection oc = Communicator.getInstance().sendMessageTo(
239:                        service, getName(), action);
240:                String ack = (String) oc.read();
241:                oc.close();
242:
243:                if (!ack.equals("OK"))
244:                    throw new Exception(ack);
245:            }
246:
247:            public void removeAcl(String forum, AclInfo info) throws Exception {
248:                ForumAdminAction action = new ForumAdminAction(
249:                        ForumAdminAction.REMOVE_ACL, forum, info);
250:                ObjectConnection oc = Communicator.getInstance().sendMessageTo(
251:                        service, getName(), action);
252:                String ack = (String) oc.read();
253:                oc.close();
254:
255:                if (!ack.equals("OK"))
256:                    throw new Exception(ack);
257:            }
258:
259:            //introduced for acl webapp
260:            public String[] getAccesses() {
261:                return new String[] { "Moderate", "Write", "Read" };
262:            }
263:
264:            public String getItemName(String itemId) {
265:                return itemId;
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.