Source Code Cross Referenced for MultipleClientModel.java in  » Byte-Code » PROSE » ch » ethz » prose » tools » 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 » Byte Code » PROSE » ch.ethz.prose.tools 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //
002:        //  This file is part of the prose package.
003:        //
004:        //  The contents of this file are subject to the Mozilla Public License
005:        //  Version 1.1 (the "License"); you may not use this file except in
006:        //  compliance with the License. You may obtain a copy of the License at
007:        //  http://www.mozilla.org/MPL/
008:        //
009:        //  Software distributed under the License is distributed on an "AS IS" basis,
010:        //  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
011:        //  for the specific language governing rights and limitations under the
012:        //  License.
013:        //
014:        //  The Original Code is prose.
015:        //
016:        //  The Initial Developer of the Original Code is Andrei Popovici. Portions
017:        //  created by Andrei Popovici are Copyright (C) 2002 Andrei Popovici.
018:        //  All Rights Reserved.
019:        //
020:        //  Contributor(s):
021:        // $Id: MultipleClientModel.java,v 1.1.1.1 2003/07/02 15:30:52 apopovic Exp $
022:        // =====================================================================
023:        //
024:        // (history at end)
025:        //
026:
027:        package ch.ethz.prose.tools;
028:
029:        // used packages
030:        import java.util.HashSet;
031:        import java.util.List;
032:        import java.util.Vector;
033:        import javax.swing.text.Document;
034:        import ch.ethz.prose.Aspect;
035:        import ch.ethz.prose.query.AspectSurrogate;
036:
037:        import javax.swing.JTable;
038:        import javax.swing.JToggleButton;
039:
040:        /**
041:         * Class MultipleClientModel
042:         *
043:         * @version	$Revision: 1.1.1.1 $
044:         * @author	Philippe Schoch
045:         */
046:        public class MultipleClientModel {
047:
048:            protected JTable actualTable = null;
049:            protected WorksheetSingleClientModel actualTableModel = null;
050:            protected List copyList;
051:            protected int copyColumn;
052:            protected String txId = null;
053:            protected int txCnt = 0;
054:            protected Document classPathModel;
055:            protected Document aspectNameModel;
056:            protected ConsoleDocumentModel wbConsole;
057:
058:            protected List createdTableModels;
059:            protected List activeTransactionVMs;
060:            JToggleButton.ToggleButtonModel selectAspectModel;
061:            JToggleButton.ToggleButtonModel selectCrosscutModel;
062:            JToggleButton.ToggleButtonModel selectJoinpointModel;
063:            JToggleButton.ToggleButtonModel groupByAspectModel;
064:            JToggleButton.ToggleButtonModel groupByCrosscutModel;
065:            JToggleButton.ToggleButtonModel groupByJoinpointModel;
066:            JToggleButton.ToggleButtonModel insertInAllVM;
067:            JToggleButton.ToggleButtonModel insertInSelection;
068:
069:            private JMultipleProseClient view;
070:
071:            public MultipleClientModel(JMultipleProseClient view) {
072:                this .view = view;
073:                classPathModel = new javax.swing.text.DefaultStyledDocument();
074:                aspectNameModel = new javax.swing.text.DefaultStyledDocument();
075:                wbConsole = new ConsoleDocumentModel();
076:                activeTransactionVMs = new Vector();
077:                createdTableModels = new Vector();
078:
079:                insertInSelection = new JToggleButton.ToggleButtonModel();
080:                insertInAllVM = new JToggleButton.ToggleButtonModel();
081:                selectAspectModel = new JToggleButton.ToggleButtonModel();
082:                selectCrosscutModel = new JToggleButton.ToggleButtonModel();
083:                selectJoinpointModel = new JToggleButton.ToggleButtonModel();
084:                groupByAspectModel = new JToggleButton.ToggleButtonModel();
085:                groupByCrosscutModel = new JToggleButton.ToggleButtonModel();
086:                groupByJoinpointModel = new JToggleButton.ToggleButtonModel();
087:
088:            }
089:
090:            public WorksheetSingleClientModel createTableModel(String pname,
091:                    String host, String port, boolean pisReal) {
092:                WorksheetSingleClientModel mtm = new WorksheetSingleClientModel(
093:                        this , new Object[][] {}, new String[] { "Aspect",
094:                                "Crosscut", "JoinPointRequest" }, pname, host,
095:                        port, pisReal);
096:                createdTableModels.add(mtm);
097:                return mtm;
098:            }
099:
100:            public List getAllVM() {
101:                return createdTableModels;
102:            }
103:
104:            public void removeVM(String name) {
105:                java.util.Iterator i = createdTableModels.iterator();
106:                Vector toRemove = new Vector();
107:                while (i.hasNext()) {
108:                    WorksheetSingleClientModel m = (WorksheetSingleClientModel) i
109:                            .next();
110:                    if (m.getName().equals(name))
111:                        toRemove.add(m);
112:                }
113:                createdTableModels.removeAll(toRemove);
114:            }
115:
116:            public ConsoleDocumentModel getConsole() {
117:                return wbConsole;
118:            }
119:
120:            public void setActualTableModel(WorksheetSingleClientModel atm) {
121:                actualTableModel = atm;
122:                loadTableSettings(actualTableModel.getSelect(),
123:                        actualTableModel.getGroupBy());
124:            }
125:
126:            public WorksheetSingleClientModel getActualTableModel()
127:                    throws IllegalUserInputException {
128:                if (actualTableModel == null)
129:                    throw new IllegalUserInputException(
130:                            "No VM available; Please add a VM");
131:                return actualTableModel;
132:            }
133:
134:            public List getCopySelection() {
135:                return copyList;
136:            }
137:
138:            public int getCopyColumn() {
139:                return copyColumn;
140:            }
141:
142:            public void setCopySelection(int column, List copyList) {
143:                copyColumn = column;
144:                this .copyList = new Vector(new HashSet(copyList)); // for elimination Duplicates
145:
146:            }
147:
148:            public Document getAspectClassNameModel() {
149:                return aspectNameModel;
150:            }
151:
152:            public Document getClasspathModel() {
153:                return classPathModel;
154:            }
155:
156:            public String getAspectClassName() {
157:                try {
158:                    return getAspectClassNameModel().getText(0,
159:                            getAspectClassNameModel().getLength());
160:                } catch (javax.swing.text.BadLocationException e) {
161:                    throw new Error(e.toString());
162:                }
163:            }
164:
165:            public String getClasspath() {
166:                try {
167:                    return getClasspathModel().getText(0,
168:                            getClasspathModel().getLength());
169:                } catch (javax.swing.text.BadLocationException e) {
170:                    throw new Error(e.toString());
171:                }
172:            }
173:
174:            public void appendToClasspath(String toBeDo) {
175:                try {
176:                    getClasspathModel().insertString(
177:                            getClasspathModel().getLength(),
178:                            System.getProperty("path.separator", ":") + toBeDo,
179:                            null);
180:                } catch (javax.swing.text.BadLocationException e) {
181:                    throw new Error(e.toString());
182:                }
183:
184:                //GEN-LAST:event_classTextFieldActionPerformed
185:            }
186:
187:            public void cutSelection() throws java.rmi.RemoteException,
188:                    TableSelectionException, WithdrawAspectsException,
189:                    IllegalUserInputException {
190:                addVMToActiveTransaction(getActualTableModel());
191:                copySelection();
192:                getActualTableModel().cutAspects();
193:            }
194:
195:            public void copySelection() throws TableSelectionException,
196:                    java.rmi.RemoteException, IllegalUserInputException {
197:                int column = getActualTableModel().getSelectedColumn();
198:                if ((column != JWorksheetProseClientPane.JOINPOINT_COL_INDEX)
199:                        && (column != JWorksheetProseClientPane.ASPECT_COL_INDEX))
200:                    throw new TableSelectionException(
201:                            "Cut and copy only on  'Aspects' or 'Joinpoints'");
202:
203:                List copyList = new Vector();
204:                for (int i = 0; i < getActualTableModel().selectedCells.length; i++) {
205:                    Object value = getActualTableModel().getValueAt(
206:                            getActualTableModel().selectedCells[i], column);
207:                    if (value == null)
208:                        throw new TableSelectionException(
209:                                "Cut and copy of 'null' values is not permitted.");
210:                    copyList.add(value);
211:                }
212:                setCopySelection(column, copyList);
213:            }
214:
215:            public void pasteSelection() throws TableSelectionException,
216:                    java.rmi.RemoteException, IllegalUserInputException,
217:                    PasteAspectsException {
218:                if (getCopySelection() == null)
219:                    throw new TableSelectionException("Nothing to paste!");
220:
221:                getActualTableModel().setSelectedColumn(getCopyColumn());
222:                if (getCopyColumn() == JWorksheetProseClientPane.JOINPOINT_COL_INDEX)
223:                    getActualTableModel().pasteJoinpoints(getCopySelection());
224:                else if (getCopyColumn() == JWorksheetProseClientPane.ASPECT_COL_INDEX) {
225:                    addVMToActiveTransaction(getActualTableModel());
226:                    getActualTableModel().pasteAspects(getCopySelection());
227:                } else
228:                    throw new Error("Error: wrong copy action");
229:            }
230:
231:            public void insertAspect() throws IllegalUserInputException,
232:                    PasteAspectsException, java.rmi.RemoteException,
233:                    TableSelectionException {
234:
235:                if (getAspectClassName() == null
236:                        || getAspectClassName().trim().equals(""))
237:                    throw new IllegalUserInputException(
238:                            "Aspect class name not specified");
239:                List aspectList = new Vector();
240:                aspectList.add(new AspectSurrogate(getAspectClassName(), Aspect
241:                        .generateUniqueAssociation()));
242:
243:                addVMToActiveTransaction(getActualTableModel());
244:                getActualTableModel().pasteAspects(aspectList);
245:            }
246:
247:            public void startTransaction() throws IllegalStateException {
248:                if (txId != null)
249:                    throw new IllegalStateException(
250:                            "Transaction still active. Commit/abort first");
251:
252:                txId = "" + System.currentTimeMillis() + txCnt--;
253:            }
254:
255:            public String getActiveTransactionID() {
256:                return txId;
257:            }
258:
259:            public void commitTransaction(boolean force) throws Exception {
260:                TransactionFinishException exceptionList = new TransactionFinishException();
261:                if (txId == null)
262:                    throw new IllegalUserInputException("Nothing to commit");
263:                java.util.Iterator i = activeTransactionVMs.iterator();
264:                while (i.hasNext()) {
265:                    try {
266:                        WorksheetSingleClientModel qClient = (WorksheetSingleClientModel) (i
267:                                .next());
268:                        qClient.commit(txId);
269:                    } catch (Exception e) {
270:                        if (force)
271:                            exceptionList.add(e);
272:                        else
273:                            throw e;
274:                    }
275:                }
276:                txId = null;
277:                activeTransactionVMs.clear();
278:            }
279:
280:            public void abortTransaction(boolean force) throws Exception {
281:                TransactionFinishException exceptionList = new TransactionFinishException();
282:                if (txId == null)
283:                    throw new IllegalUserInputException("Nothing to abort");
284:                java.util.Iterator i = activeTransactionVMs.iterator();
285:                while (i.hasNext()) {
286:                    try {
287:                        WorksheetSingleClientModel qClient = (WorksheetSingleClientModel) (i
288:                                .next());
289:                        qClient.abort(txId);
290:                    } catch (Exception e) {
291:                        if (force)
292:                            exceptionList.add(e);
293:                        else
294:                            throw e;
295:                    }
296:                }
297:
298:                txId = null;
299:                activeTransactionVMs.clear();
300:            }
301:
302:            public void addVMToActiveTransaction(WorksheetSingleClientModel n) {
303:                if (getActiveTransactionID() == null)
304:                    return;
305:                activeTransactionVMs.add(n);
306:            }
307:
308:            protected void loadTableSettings(int select, int groupBy) {
309:                selectAspectModel
310:                        .setSelected((select & WorksheetSingleClientModel.SELECT_ASPECT) > 0);
311:                selectCrosscutModel
312:                        .setSelected((select & WorksheetSingleClientModel.SELECT_CROSSCUT) > 0);
313:                selectJoinpointModel
314:                        .setSelected((select & WorksheetSingleClientModel.SELECT_JOINPOINT) > 0);
315:                switch (groupBy) {
316:                case WorksheetSingleClientModel.BY_ASPECT:
317:                    groupByAspectModel.setSelected(true);
318:                    break;
319:                case WorksheetSingleClientModel.BY_CROSSCUT:
320:                    groupByCrosscutModel.setSelected(true);
321:                    break;
322:                case WorksheetSingleClientModel.BY_JOINPOINT:
323:                    groupByJoinpointModel.setSelected(true);
324:                    break;
325:                default:
326:                    throw new IndexOutOfBoundsException(
327:                            "BUG: 'GroupBy' value is out of Range: " + groupBy);
328:                }
329:            }
330:
331:            public JToggleButton.ToggleButtonModel getInsertInSelection() {
332:                return insertInSelection;
333:            }
334:
335:            public JToggleButton.ToggleButtonModel getInsertInAllVM() {
336:                return insertInAllVM;
337:            }
338:
339:            public JToggleButton.ToggleButtonModel getSelectAspect() {
340:                return selectAspectModel;
341:            }
342:
343:            public JToggleButton.ToggleButtonModel getSelectCrosscut() {
344:                return selectCrosscutModel;
345:            }
346:
347:            public JToggleButton.ToggleButtonModel getSelectJoinpoint() {
348:                return selectJoinpointModel;
349:            }
350:
351:            public JToggleButton.ToggleButtonModel getGroupByAspect() {
352:                return groupByAspectModel;
353:            }
354:
355:            public JToggleButton.ToggleButtonModel getGroupByCrosscut() {
356:                return groupByCrosscutModel;
357:            }
358:
359:            public JToggleButton.ToggleButtonModel getGroupByJoinpoint() {
360:                return groupByJoinpointModel;
361:            }
362:
363:        }
364:
365:        //======================================================================
366:        //
367:        // $Log: MultipleClientModel.java,v $
368:        // Revision 1.1.1.1  2003/07/02 15:30:52  apopovic
369:        // Imported from ETH Zurich
370:        //
371:        // Revision 1.3  2003/06/06 13:54:28  popovici
372:        // path separator used
373:        //
374:        // Revision 1.2  2003/06/06 12:36:10  popovici
375:        // Bug fix; 'abort' used to be a NOP
376:        //
377:        // Revision 1.1  2003/05/25 13:25:17  popovici
378:        // Refactoring
379:        // inf.iks.tools is now prose.tools
380:        // Stupid 'MyTableModel' renamed to 'WorksheetClientMode'
381:        // - other renamings from bad names to reasonable names
382:        //
383:        // Revision 1.6  2003/05/25 11:48:52  popovici
384:        // Major transformation of the prose tools:
385:        // - GUI now stable and supports aspect insertion from another classpath than its own
386:        // - CommandlineProseClient supports transactions test managers, independent classpath and has a better errhanling
387:        //
388:        // Revision 1.5  2003/05/06 15:51:21  popovici
389:        // Mozilla-ification
390:        //
391:        // Revision 1.4  2003/03/04 18:35:56  popovici
392:        // Organization of imprts
393:        //
394:        // Revision 1.3  2003/02/17 09:23:56  popovici
395:        // RemoteAspectManager interface, implementation, and client added;
396:        // Benchmark changed to work with the remote aspect manager;
397:        // Benchmark changed to include aspect insertion;
398:        //
399:        // Revision 1.2  2003/01/27 13:32:16  pschoch
400:        // wiped out some small bugs in the GUI; GUI adjusted to the query changes
401:        //
402:        // Revision 1.1  2003/01/17 14:48:18  pschoch
403:        // Initial Revision, imported from netbeans
404:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.