Source Code Cross Referenced for AbstractLockDialog.java in  » Net » Terracotta » org » terracotta » dso » dialogs » 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 » Net » Terracotta » org.terracotta.dso.dialogs 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package org.terracotta.dso.dialogs;
006:
007:        import org.apache.xmlbeans.XmlObject;
008:        import org.eclipse.jdt.core.IBuffer;
009:        import org.eclipse.jdt.core.IJavaElement;
010:        import org.eclipse.jdt.core.IMethod;
011:        import org.eclipse.jdt.core.IOpenable;
012:        import org.eclipse.jdt.core.ISourceRange;
013:        import org.eclipse.jdt.core.IType;
014:        import org.eclipse.jdt.core.ITypeRoot;
015:        import org.eclipse.jdt.core.JavaModelException;
016:        import org.eclipse.jdt.internal.ui.JavaPlugin;
017:        import org.eclipse.jface.dialogs.IDialogConstants;
018:        import org.eclipse.jface.text.BadLocationException;
019:        import org.eclipse.jface.text.Document;
020:        import org.eclipse.jface.text.IRegion;
021:        import org.eclipse.jface.text.Region;
022:        import org.eclipse.swt.SWT;
023:        import org.eclipse.swt.custom.StackLayout;
024:        import org.eclipse.swt.events.MouseAdapter;
025:        import org.eclipse.swt.events.MouseEvent;
026:        import org.eclipse.swt.events.SelectionAdapter;
027:        import org.eclipse.swt.events.SelectionEvent;
028:        import org.eclipse.swt.graphics.Image;
029:        import org.eclipse.swt.layout.GridData;
030:        import org.eclipse.swt.layout.GridLayout;
031:        import org.eclipse.swt.widgets.Button;
032:        import org.eclipse.swt.widgets.Combo;
033:        import org.eclipse.swt.widgets.Composite;
034:        import org.eclipse.swt.widgets.Control;
035:        import org.eclipse.swt.widgets.Group;
036:        import org.eclipse.swt.widgets.Label;
037:        import org.eclipse.swt.widgets.Shell;
038:        import org.eclipse.swt.widgets.Table;
039:        import org.eclipse.swt.widgets.TableItem;
040:        import org.eclipse.swt.widgets.Text;
041:        import org.eclipse.swt.widgets.TreeItem;
042:        import org.eclipse.ui.forms.events.HyperlinkAdapter;
043:        import org.eclipse.ui.forms.events.HyperlinkEvent;
044:        import org.eclipse.ui.forms.widgets.ImageHyperlink;
045:        import org.terracotta.dso.JdtUtils;
046:        import org.terracotta.dso.PatternHelper;
047:        import org.terracotta.dso.TcPlugin;
048:        import org.terracotta.dso.util.StackElementInfo;
049:        import org.terracotta.dso.views.ConfigUI;
050:        import org.terracotta.ui.util.SWTUtil;
051:
052:        import com.tc.admin.common.AbstractResolutionAction;
053:        import com.tc.admin.common.AbstractWorkState;
054:        import com.tc.admin.common.BrowserLauncher;
055:        import com.tc.admin.common.NonPortableMessages;
056:        import com.tc.admin.common.NonPortableWorkState;
057:        import com.tc.object.appevent.AbstractLockEvent;
058:        import com.tc.object.appevent.AbstractLockEventContext;
059:        import com.terracottatech.config.Autolock;
060:        import com.terracottatech.config.Include;
061:        import com.terracottatech.config.LockLevel;
062:        import com.terracottatech.config.NamedLock;
063:
064:        import java.lang.reflect.Field;
065:        import java.util.ArrayList;
066:        import java.util.Iterator;
067:        import java.util.List;
068:
069:        import javax.swing.tree.DefaultMutableTreeNode;
070:
071:        public abstract class AbstractLockDialog extends
072:                AbstractApplicationEventDialog {
073:            private AbstractWorkState fWorkState;
074:            private List<StackElementInfo> fStackElementInfos;
075:            private NonPortableWorkState fTargetObjectState;
076:            private Table fStackTable;
077:            private LockRulePanel fLockRuleView;
078:
079:            protected static final Image WRITE_ICON = TcPlugin
080:                    .createImage("/images/eclipse/occ_write.gif"); //$NON-NLS-1$
081:            protected static final Image READ_ICON = TcPlugin
082:                    .createImage("/images/eclipse/occ_read.gif"); //$NON-NLS-1$
083:            protected static final Image CONCURRENT_ICON = TcPlugin
084:                    .createImage("/images/eclipse/occ_write.gif"); //$NON-NLS-1$
085:            protected static final Image SYNCHRONOUS_WRITE_ICON = TcPlugin
086:                    .createImage("/images/eclipse/sync_write.gif"); //$NON-NLS-1$
087:
088:            public AbstractLockDialog(Shell parentShell, String title,
089:                    AbstractLockEvent lockEvent) {
090:                super (parentShell, title, lockEvent, new String[] { //$NON-NLS-1$
091:                        IDialogConstants.CANCEL_LABEL,
092:                                IDialogConstants.OK_LABEL, //$NON-NLS-1$
093:                        }, 1);
094:                fWorkState = createWorkState(lockEvent);
095:                populateStackElementInfos();
096:            }
097:
098:            protected abstract AbstractWorkState createWorkState(
099:                    AbstractLockEvent lockEvent);
100:
101:            protected AbstractWorkState getWorkState() {
102:                return fWorkState;
103:            }
104:
105:            protected abstract String getIssueName();
106:
107:            private AbstractLockEvent getAbstractLockEvent() {
108:                return (AbstractLockEvent) getApplicationEvent();
109:            }
110:
111:            private AbstractLockEventContext getAbstractLockEventContext() {
112:                return getAbstractLockEvent().getAbstractLockEventContext();
113:            }
114:
115:            private void populateStackElementInfos() {
116:                StackTraceElement[] elements = getAbstractLockEventContext()
117:                        .getStackElements();
118:                ArrayList<StackTraceElement> list = new ArrayList<StackTraceElement>();
119:
120:                for (int i = 0; i < elements.length; i++) {
121:                    StackTraceElement element = elements[i];
122:                    if (element.getMethodName().startsWith("__tc_wrapped")) {
123:                        int nextIndex = i + 1;
124:                        StackTraceElement nextElement = elements[nextIndex];
125:                        if (nextElement.getLineNumber() < 0
126:                                && element.getLineNumber() >= 1) {
127:                            try {
128:                                Field[] fields = nextElement.getClass()
129:                                        .getDeclaredFields();
130:                                for (Field f : fields) {
131:                                    if (f.getName().equals("lineNumber")) {
132:                                        f.setAccessible(true);
133:                                        f.setInt(nextElement, element
134:                                                .getLineNumber());
135:                                        break;
136:                                    }
137:                                }
138:                            } catch (Exception e) {/**/
139:                            }
140:                        }
141:                    } else {
142:                        list.add(element);
143:                    }
144:                }
145:
146:                int startIndex = 0;
147:                for (int i = list.size() - 1; i >= 0; i--) {
148:                    StackTraceElement element = list.get(i);
149:                    if (element.getMethodName().startsWith("__tc_")
150:                            || element.getLineNumber() < 0) {
151:                        startIndex = i + 1;
152:                        break;
153:                    }
154:                }
155:
156:                fStackElementInfos = new ArrayList<StackElementInfo>();
157:                for (int i = startIndex; i < list.size(); i++) {
158:                    fStackElementInfos.add(new StackElementInfo(list.get(i)));
159:                }
160:            }
161:
162:            protected void createIssueDescriptionArea(Composite parent) {
163:                fStackTable = new Table(parent, SWT.V_SCROLL | SWT.BORDER
164:                        | SWT.READ_ONLY);
165:                GridData gridData = new GridData(GridData.FILL_BOTH);
166:                gridData.widthHint = SWTUtil.textColumnsToPixels(fStackTable,
167:                        80);
168:                gridData.heightHint = SWTUtil.textRowsToPixels(fStackTable, 8);
169:                fStackTable.setLayoutData(gridData);
170:            }
171:
172:            protected Control createCustomArea(Composite parent) {
173:                Control customArea = super .createCustomArea(parent);
174:
175:                fLockRuleView = new LockRulePanel(fActionPanel);
176:
177:                populateStackTable();
178:
179:                fSummaryLabel
180:                        .setText(fTargetObjectState != null ? fTargetObjectState
181:                                .summary()
182:                                : "Thread stack");
183:                fSummaryLabel
184:                        .setImage(fTargetObjectState != null ? imageFor(fTargetObjectState)
185:                                : null);
186:
187:                fActionTreeViewer.setInput(fWorkState);
188:                fActionTreeViewer.expandAll();
189:
190:                return customArea;
191:            }
192:
193:            protected boolean anySelectedActions() {
194:                return fWorkState.hasSelectedActions();
195:            }
196:
197:            protected void initIssueList() {
198:                TreeItem treeItem = fObjectTree.getItem(0);
199:
200:                fIssueTable.setRedraw(false);
201:                try {
202:                    fIssueTable.setItemCount(0);
203:                    TableItem tableItem = new TableItem(fIssueTable, SWT.NONE);
204:
205:                    tableItem.setData(treeItem);
206:                    tableItem.setImage(anyActionSelected() ? RESOLVED_ICON
207:                            : BLANK_ICON);
208:                    tableItem.setText(getIssueName());
209:                    fIssueTable.setSelection(0);
210:                } finally {
211:                    fIssueTable.setRedraw(true);
212:                }
213:            }
214:
215:            protected void handleTreeSelectionChange() {
216:                // The object browser isn't tied to any actions directly, it's just for context
217:                // and for browsing to the field's source defintion.
218:            }
219:
220:            protected void apply() {
221:                for (AbstractResolutionAction action : fWorkState.getActions()) {
222:                    if (action.isSelected())
223:                        action.apply();
224:                }
225:
226:                super .apply();
227:            }
228:
229:            protected void initTreeItem(TreeItem item,
230:                    DefaultMutableTreeNode node) {
231:                super .initTreeItem(item, node);
232:
233:                Object userObject = node.getUserObject();
234:                if (userObject instanceof  NonPortableWorkState) {
235:                    NonPortableWorkState workState = (NonPortableWorkState) userObject;
236:
237:                    String fieldName = getAbstractLockEventContext()
238:                            .getFieldName();
239:                    if (fieldName != null
240:                            && fieldName.equals(workState.getFieldName())) {
241:                        item.setBackground(getShell().getDisplay()
242:                                .getSystemColor(SWT.COLOR_YELLOW));
243:                        fObjectTree.showItem(item);
244:                        fTargetObjectState = workState;
245:                    }
246:                }
247:            }
248:
249:            void populateStackTable() {
250:                Iterator<StackElementInfo> iter = fStackElementInfos.iterator();
251:
252:                while (iter.hasNext()) {
253:                    TableItem item = new TableItem(fStackTable, SWT.NONE);
254:                    StackElementInfo stackElemInfo = iter.next();
255:                    StackTraceElement stackElement = stackElemInfo
256:                            .getStackElement();
257:                    Image image = BLANK_ICON;
258:                    String typeName = stackElement.getClassName();
259:                    int lineNumber = stackElement.getLineNumber() - 1;
260:
261:                    try {
262:                        IType type = JdtUtils.findType(fJavaProject, typeName);
263:
264:                        if (type != null) {
265:                            IRegion region = null;
266:                            IMethod method = null;
267:
268:                            stackElemInfo.setType(type);
269:                            IMethod[] methods = JdtUtils.findMethods(type,
270:                                    stackElement.getMethodName());
271:                            if (methods.length == 1)
272:                                method = methods[0];
273:
274:                            IBuffer buffer;
275:                            if (lineNumber >= 1
276:                                    && (buffer = getBufferForMember(type)) != null) {
277:                                Document document = new Document(buffer
278:                                        .getContents());
279:
280:                                try {
281:                                    region = document
282:                                            .getLineInformation(lineNumber);
283:                                } catch (BadLocationException e) {
284:                                    JavaPlugin.log(e);
285:                                }
286:                            } else if (method != null) {
287:                                ISourceRange srcRange = method.getNameRange();
288:                                if (srcRange != null) {
289:                                    region = new Region(srcRange.getOffset(),
290:                                            srcRange.getLength());
291:                                }
292:                            }
293:
294:                            if (region != null) {
295:                                stackElemInfo.setRegion(region);
296:                                if (method == null) {
297:                                    ITypeRoot typeRoot = type.getTypeRoot();
298:                                    IJavaElement elem = typeRoot
299:                                            .getElementAt(region.getOffset());
300:                                    if (elem instanceof  IMethod) {
301:                                        method = (IMethod) elem;
302:                                    }
303:                                }
304:                            }
305:
306:                            if (method != null) {
307:                                XmlObject lock = fConfigHelper.getLock(method);
308:                                if (lock != null) {
309:                                    LockLevel.Enum level;
310:                                    if (lock instanceof  Autolock) {
311:                                        Autolock autolock = (Autolock) lock;
312:                                        level = autolock.getLockLevel();
313:                                    } else {
314:                                        NamedLock namedLock = (NamedLock) lock;
315:                                        level = namedLock.getLockLevel();
316:                                    }
317:                                    if (level == LockLevel.WRITE)
318:                                        image = WRITE_ICON;
319:                                    else if (level == LockLevel.READ)
320:                                        image = READ_ICON;
321:                                    else if (level == LockLevel.CONCURRENT)
322:                                        image = CONCURRENT_ICON;
323:                                    else if (level == LockLevel.SYNCHRONOUS_WRITE)
324:                                        image = SYNCHRONOUS_WRITE_ICON;
325:                                }
326:                                stackElemInfo.setMethod(method);
327:                            }
328:                        }
329:                    } catch (JavaModelException jme) {
330:                        JavaPlugin.log(jme);
331:                    }
332:
333:                    item.setImage(image);
334:                    item.setText(stackElemInfo.toString());
335:                }
336:
337:                fStackTable.addMouseListener(new MouseAdapter() {
338:                    public void mouseDoubleClick(MouseEvent e) {
339:                        e.widget.getDisplay().asyncExec(new Runnable() {
340:                            public void run() {
341:                                handleStackElementSelectionChange(fStackTable
342:                                        .getSelectionIndex());
343:                            }
344:                        });
345:                    }
346:                });
347:            }
348:
349:            protected void handleStackElementSelectionChange(
350:                    int frameElementIndex) {
351:                if (frameElementIndex >= 0) {
352:                    StackElementInfo stackElementInfo = fStackElementInfos
353:                            .get(frameElementIndex);
354:                    IType type = stackElementInfo.getType();
355:
356:                    if (type != null) {
357:                        IRegion region = stackElementInfo.getRegion();
358:
359:                        if (region != null) {
360:                            ConfigUI.jumpToRegion(type, region);
361:                        }
362:                    }
363:                }
364:            }
365:
366:            private IBuffer getBufferForMember(IJavaElement member) {
367:                IBuffer buffer = null;
368:                try {
369:                    IOpenable openable = member.getOpenable();
370:                    if (openable != null && member.exists()) {
371:                        buffer = openable.getBuffer();
372:                    }
373:                } catch (JavaModelException e) {
374:                    JavaPlugin.log(e);
375:                }
376:                return buffer;
377:            }
378:
379:            protected Iterator<StackElementInfo> createStackElementInfoIterator() {
380:                return fStackElementInfos.iterator();
381:            }
382:
383:            protected StackElementInfo getStackElementInfo(int index) {
384:                return fStackElementInfos.get(index);
385:            }
386:
387:            protected AbstractResolutionAction[] createActions(
388:                    AbstractWorkState workState) {
389:                ArrayList list = new ArrayList();
390:                String fieldName = getAbstractLockEventContext().getFieldName();
391:
392:                if (fieldName != null && !fConfigHelper.isTransient(fieldName)) {
393:                    list.add(new MakeTransientAction());
394:                }
395:
396:                return (AbstractResolutionAction[]) list
397:                        .toArray(new AbstractResolutionAction[0]);
398:            }
399:
400:            protected void updateButtons() {
401:                getButton(IDialogConstants.OK_ID).setEnabled(
402:                        anyActionSelected());
403:            }
404:
405:            class MakeTransientAction extends AbstractResolutionAction {
406:                public void showControl(Object parentControl) {
407:                    String fieldName = getAbstractLockEventContext()
408:                            .getFieldName();
409:                    String declaringType = fieldName.substring(0, fieldName
410:                            .lastIndexOf('.'));
411:                    Include include = fConfigHelper
412:                            .includeRuleFor(declaringType);
413:
414:                    if (include != null) {
415:                        fActionStackLayout.topControl = fIncludeRuleView;
416:                        fIncludeRuleView.setInclude(include);
417:                        fActionPanel.layout();
418:                        fActionPanel.redraw();
419:                    }
420:                }
421:
422:                public String getText() {
423:                    return NonPortableMessages.getString("DO_NOT_SHARE"); //$NON-NLS-1$
424:                }
425:
426:                public void setSelected(boolean selected) {
427:                    super .setSelected(selected);
428:
429:                    String fieldName = getAbstractLockEventContext()
430:                            .getFieldName();
431:                    if (selected) {
432:                        fConfigHelper
433:                                .ensureTransient(fieldName, NULL_SIGNALLER);
434:                    } else {
435:                        fConfigHelper.ensureNotTransient(fieldName,
436:                                NULL_SIGNALLER);
437:                    }
438:                }
439:            }
440:
441:            class AddLockAction extends AbstractResolutionAction {
442:                public void showControl(Object parentControl) {
443:                    fActionStackLayout.topControl = fLockRuleView;
444:                    fActionPanel.layout();
445:                    fActionPanel.redraw();
446:                }
447:
448:                public String getText() {
449:                    return "Add lock"; //$NON-NLS-1$
450:                }
451:
452:                public void apply() {
453:                    IMethod method = fLockRuleView.getMethod();
454:                    LockLevel.Enum level = fLockRuleView.getLockLevel();
455:                    String expr;
456:
457:                    try {
458:                        expr = PatternHelper.getJavadocSignature(method);
459:                    } catch (Exception e) {
460:                        StackTraceElement stackElement = fLockRuleView
461:                                .getStackElement();
462:                        expr = "* " + stackElement.getClassName() + "."
463:                                + stackElement.getMethodName() + "(..)";
464:                    }
465:
466:                    if (fLockRuleView.isAuto()) {
467:                        Autolock lock = fConfigHelper.addNewAutolock(expr,
468:                                level, NULL_SIGNALLER);
469:                        lock.setAutoSynchronized(fLockRuleView
470:                                .isAutoSynchronized());
471:                    } else {
472:                        fConfigHelper.addNewNamedLock(fLockRuleView
473:                                .getLockName(), expr, level, NULL_SIGNALLER);
474:                    }
475:                }
476:            }
477:
478:            class LockRulePanel extends Composite {
479:                Combo fStackCombo;
480:
481:                Button fTypeAutoButton;
482:                Button fTypeNamedButton;
483:                SelectionAdapter fTypeListener;
484:
485:                Button fLevelReadButton;
486:                Button fLevelWriteButton;
487:                Button fLevelConcurrentButton;
488:                Button fLevelSyncWriteButton;
489:                SelectionAdapter fLevelListener;
490:
491:                Composite fTypeSpecificPanel;
492:                StackLayout fTypeSpecificStackLayout;
493:                Button fAutoSyncButton;
494:                Composite fNamePanel;
495:                Text fNameText;
496:
497:                LockRulePanel(Composite parent) {
498:                    super (parent, SWT.NONE);
499:                    setLayout(new GridLayout());
500:                    setLayoutData(new GridData(GridData.FILL_BOTH));
501:                    Composite methodChooser = new Composite(this , SWT.NONE);
502:                    methodChooser.setLayout(new GridLayout(2, false));
503:                    methodChooser.setLayoutData(new GridData(
504:                            GridData.FILL_HORIZONTAL));
505:                    Label label = new Label(methodChooser, SWT.NONE);
506:                    label.setText("Method"); //$NON-NLS-1$
507:                    label.setLayoutData(new GridData());
508:                    fStackCombo = new Combo(methodChooser, SWT.BORDER
509:                            | SWT.READ_ONLY);
510:                    fStackCombo.setLayoutData(new GridData(
511:                            GridData.FILL_HORIZONTAL));
512:                    fStackCombo.setFont(parent.getFont());
513:                    fStackCombo.addSelectionListener(new SelectionAdapter() {
514:                        public void widgetSelected(SelectionEvent e) {
515:                            getDisplay().asyncExec(new Runnable() {
516:                                public void run() {
517:                                    handleStackElementSelectionChange(fStackCombo
518:                                            .getSelectionIndex());
519:                                }
520:                            });
521:                        }
522:                    });
523:                    populateStackCombo();
524:
525:                    fTypeListener = new SelectionAdapter() {
526:                        public void widgetSelected(SelectionEvent event) {
527:                            if (event.widget == fTypeAutoButton) {
528:                                fTypeSpecificStackLayout.topControl = fAutoSyncButton;
529:                                fTypeNamedButton.setSelection(false);
530:                            } else {
531:                                fTypeSpecificStackLayout.topControl = fNamePanel;
532:                                fTypeAutoButton.setSelection(false);
533:                            }
534:                            fTypeSpecificPanel.layout();
535:                            fTypeSpecificPanel.redraw();
536:                        }
537:                    };
538:
539:                    Composite detailsGroup = new Composite(this , SWT.NONE);
540:                    detailsGroup.setLayout(new GridLayout(3, false));
541:                    detailsGroup.setLayoutData(new GridData(
542:                            GridData.FILL_HORIZONTAL));
543:                    Group typeGroup = new Group(detailsGroup, SWT.SHADOW_NONE);
544:                    typeGroup.setLayout(new GridLayout());
545:                    typeGroup.setLayoutData(new GridData(SWT.BEGINNING,
546:                            SWT.BEGINNING, false, false));
547:                    typeGroup.setText("Lock type");
548:                    Composite autoGroup = new Composite(typeGroup, SWT.NONE);
549:                    GridLayout autoGroupLayout = new GridLayout(2, false);
550:                    autoGroupLayout.marginWidth = autoGroupLayout.marginHeight = 0;
551:                    autoGroup.setLayout(autoGroupLayout);
552:                    autoGroup.setLayoutData(new GridData(
553:                            GridData.FILL_HORIZONTAL));
554:                    fTypeAutoButton = new Button(autoGroup, SWT.RADIO);
555:                    fTypeAutoButton.setLayoutData(new GridData());
556:                    fTypeAutoButton.setText("Auto");
557:                    fTypeAutoButton.setSelection(true);
558:                    fTypeAutoButton.addSelectionListener(fTypeListener);
559:                    ImageHyperlink autoHelpLink = getFormToolkit()
560:                            .createImageHyperlink(autoGroup, SWT.NONE);
561:                    autoHelpLink.setImage(HELP_ICON);
562:                    autoHelpLink.addHyperlinkListener(new HyperlinkAdapter() {
563:                        public void linkActivated(HyperlinkEvent e) {
564:                            BrowserLauncher
565:                                    .openURL("http://www.terracotta.org/confluence/display/docs1/Concept+and+Architecture+Guide#ConceptandArchitectureGuide-Locks");
566:                        }
567:                    });
568:                    autoHelpLink.setLayoutData(new GridData(SWT.END,
569:                            SWT.CENTER, true, false));
570:
571:                    Composite namedGroup = new Composite(typeGroup, SWT.NONE);
572:                    GridLayout namedGroupLayout = new GridLayout(2, false);
573:                    namedGroupLayout.marginWidth = autoGroupLayout.marginHeight = 0;
574:                    namedGroup.setLayout(autoGroupLayout);
575:                    namedGroup.setLayoutData(new GridData(
576:                            GridData.FILL_HORIZONTAL));
577:                    fTypeNamedButton = new Button(namedGroup, SWT.RADIO);
578:                    fTypeNamedButton.setLayoutData(new GridData());
579:                    fTypeNamedButton.setText("Named");
580:                    fTypeNamedButton.addSelectionListener(fTypeListener);
581:                    ImageHyperlink namedHelpLink = getFormToolkit()
582:                            .createImageHyperlink(namedGroup, SWT.NONE);
583:                    namedHelpLink.setImage(HELP_ICON);
584:                    namedHelpLink.addHyperlinkListener(new HyperlinkAdapter() {
585:                        public void linkActivated(HyperlinkEvent e) {
586:                            BrowserLauncher
587:                                    .openURL("http://www.terracotta.org/confluence/display/docs1/Concept+and+Architecture+Guide#ConceptandArchitectureGuide-Locks");
588:                        }
589:                    });
590:                    namedHelpLink.setLayoutData(new GridData(SWT.END,
591:                            SWT.CENTER, true, false));
592:
593:                    Group levelGroup = new Group(detailsGroup, SWT.SHADOW_NONE);
594:                    levelGroup.setLayout(new GridLayout());
595:                    levelGroup.setLayoutData(new GridData(SWT.BEGINNING,
596:                            SWT.BEGINNING, false, false));
597:                    levelGroup.setText("Lock level");
598:                    fLevelReadButton = new Button(levelGroup, SWT.RADIO);
599:                    fLevelReadButton.setLayoutData(new GridData());
600:                    fLevelReadButton.setText("Read");
601:                    fLevelWriteButton = new Button(levelGroup, SWT.RADIO);
602:                    fLevelWriteButton.setLayoutData(new GridData());
603:                    fLevelWriteButton.setText("Write");
604:                    fLevelWriteButton.setSelection(true);
605:                    fLevelConcurrentButton = new Button(levelGroup, SWT.RADIO);
606:                    fLevelConcurrentButton.setLayoutData(new GridData());
607:                    fLevelConcurrentButton.setText("Concurrent");
608:                    fLevelSyncWriteButton = new Button(levelGroup, SWT.RADIO);
609:                    fLevelSyncWriteButton.setLayoutData(new GridData());
610:                    fLevelSyncWriteButton.setText("Synchronous-write");
611:
612:                    fTypeSpecificPanel = new Composite(detailsGroup, SWT.NONE);
613:                    fTypeSpecificPanel.setLayoutData(new GridData(SWT.FILL,
614:                            SWT.BEGINNING, true, false));
615:                    fTypeSpecificPanel
616:                            .setLayout(fTypeSpecificStackLayout = new StackLayout());
617:                    fAutoSyncButton = new Button(fTypeSpecificPanel, SWT.CHECK);
618:                    fAutoSyncButton.setLayoutData(new GridData());
619:                    fAutoSyncButton.setText("Auto-synchronize");
620:                    fNamePanel = new Composite(fTypeSpecificPanel, SWT.NONE);
621:                    fNamePanel.setLayout(new GridLayout(2, false));
622:                    fNamePanel.setLayoutData(new GridData(
623:                            GridData.FILL_HORIZONTAL));
624:                    Label nameLabel = new Label(fNamePanel, SWT.NONE);
625:                    nameLabel.setLayoutData(new GridData());
626:                    nameLabel.setText("Lock name:");
627:                    fNameText = new Text(fNamePanel, SWT.BORDER);
628:                    fNameText.setLayoutData(new GridData(
629:                            GridData.FILL_HORIZONTAL));
630:
631:                    fTypeSpecificStackLayout.topControl = fAutoSyncButton;
632:                }
633:
634:                void populateStackCombo() {
635:                    fStackCombo.removeAll();
636:                    Iterator iter = fStackElementInfos.iterator();
637:                    while (iter.hasNext()) {
638:                        fStackCombo.add(iter.next().toString());
639:                    }
640:                    fStackCombo.select(0);
641:                }
642:
643:                StackTraceElement getStackElement() {
644:                    return fStackElementInfos.get(
645:                            fStackCombo.getSelectionIndex()).getStackElement();
646:                }
647:
648:                IMethod getMethod() {
649:                    return fStackElementInfos.get(
650:                            fStackCombo.getSelectionIndex()).getMethod();
651:                }
652:
653:                boolean isAuto() {
654:                    return fTypeAutoButton.getSelection();
655:                }
656:
657:                String getLockName() {
658:                    return fNameText.getText();
659:                }
660:
661:                boolean isAutoSynchronized() {
662:                    return fAutoSyncButton.getSelection();
663:                }
664:
665:                LockLevel.Enum getLockLevel() {
666:                    if (fLevelReadButton.getSelection())
667:                        return LockLevel.READ;
668:                    else if (fLevelWriteButton.getSelection())
669:                        return LockLevel.WRITE;
670:                    else if (fLevelConcurrentButton.getSelection())
671:                        return LockLevel.CONCURRENT;
672:                    else
673:                        return LockLevel.SYNCHRONOUS_WRITE;
674:                }
675:            }
676:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.