Source Code Cross Referenced for EventDetailsDialog.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » runtime » logview » 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 » IDE Eclipse » Eclipse plug in development » org.eclipse.pde.internal.runtime.logview 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.pde.internal.runtime.logview;
011:
012:        import java.io.IOException;
013:        import java.io.PrintWriter;
014:        import java.io.StringWriter;
015:        import java.util.Arrays;
016:        import java.util.Comparator;
017:        import java.util.Date;
018:
019:        import org.eclipse.core.runtime.IAdaptable;
020:        import org.eclipse.jface.dialogs.Dialog;
021:        import org.eclipse.jface.dialogs.IDialogConstants;
022:        import org.eclipse.jface.dialogs.IDialogSettings;
023:        import org.eclipse.jface.dialogs.TrayDialog;
024:        import org.eclipse.jface.viewers.ISelection;
025:        import org.eclipse.jface.viewers.ISelectionProvider;
026:        import org.eclipse.jface.viewers.IStructuredSelection;
027:        import org.eclipse.jface.viewers.StructuredSelection;
028:        import org.eclipse.jface.viewers.TreeViewer;
029:        import org.eclipse.pde.internal.runtime.PDERuntimeMessages;
030:        import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
031:        import org.eclipse.pde.internal.runtime.PDERuntimePluginImages;
032:        import org.eclipse.swt.SWT;
033:        import org.eclipse.swt.custom.SashForm;
034:        import org.eclipse.swt.dnd.Clipboard;
035:        import org.eclipse.swt.dnd.TextTransfer;
036:        import org.eclipse.swt.dnd.Transfer;
037:        import org.eclipse.swt.graphics.Image;
038:        import org.eclipse.swt.graphics.Point;
039:        import org.eclipse.swt.layout.GridData;
040:        import org.eclipse.swt.layout.GridLayout;
041:        import org.eclipse.swt.widgets.Button;
042:        import org.eclipse.swt.widgets.Composite;
043:        import org.eclipse.swt.widgets.Control;
044:        import org.eclipse.swt.widgets.Label;
045:        import org.eclipse.swt.widgets.Shell;
046:        import org.eclipse.swt.widgets.Text;
047:        import org.eclipse.ui.ISharedImages;
048:        import org.eclipse.ui.PlatformUI;
049:
050:        import com.ibm.icu.text.Collator;
051:        import com.ibm.icu.text.DateFormat;
052:        import com.ibm.icu.text.SimpleDateFormat;
053:
054:        public class EventDetailsDialog extends TrayDialog {
055:            private LogEntry entry, parentEntry;
056:            private LogViewLabelProvider labelProvider;
057:            private static int COPY_ID = 22;
058:            private TreeViewer provider;
059:            private int elementNum, totalElementCount;
060:            private LogEntry[] entryChildren;
061:            private int childIndex = 0;
062:            private boolean isOpen;
063:            private boolean isLastChild;
064:            private boolean isAtEndOfLog;
065:
066:            private Label dateLabel;
067:            private Label severityImageLabel;
068:            private Label severityLabel;
069:            private Text msgText;
070:            private Text stackTraceText;
071:            private Text sessionDataText;
072:            private Clipboard clipboard;
073:            private Button copyButton;
074:            private Button backButton;
075:            private Button nextButton;
076:            private Image imgNextEnabled;
077:            private Image imgPrevEnabled;
078:            private Image imgCopyEnabled;
079:            private SashForm sashForm;
080:
081:            // sorting
082:            private Comparator comparator = null;
083:            private Collator collator;
084:
085:            // location configuration
086:            private Point dialogLocation;
087:            private Point dialogSize;
088:            private int[] sashWeights;
089:
090:            /**
091:             * 
092:             * @param parentShell shell in which dialog is displayed
093:             * @param selection entry initially selected and to be displayed
094:             * @param provider viewer
095:             * @param comparator comparator used to order all entries
096:             */
097:            protected EventDetailsDialog(Shell parentShell,
098:                    IAdaptable selection, ISelectionProvider provider,
099:                    Comparator comparator) {
100:                super (parentShell);
101:                this .provider = (TreeViewer) provider;
102:                labelProvider = (LogViewLabelProvider) this .provider
103:                        .getLabelProvider();
104:                labelProvider.connect(this );
105:                this .entry = (LogEntry) selection;
106:                this .comparator = comparator;
107:                setShellStyle(SWT.MODELESS | SWT.MIN | SWT.MAX | SWT.RESIZE
108:                        | SWT.CLOSE | SWT.BORDER | SWT.TITLE);
109:                clipboard = new Clipboard(parentShell.getDisplay());
110:                initialize();
111:                createImages();
112:                collator = Collator.getInstance();
113:                readConfiguration();
114:                isLastChild = false;
115:                isAtEndOfLog = false;
116:            }
117:
118:            private void initialize() {
119:                elementNum = getParentElementNum();
120:                resetTotalElementCount();
121:                parentEntry = (LogEntry) entry.getParent(entry);
122:                if (isChild(entry)) {
123:                    setEntryChildren(parentEntry);
124:                    resetChildIndex();
125:                }
126:                isLastChild = false;
127:                isAtEndOfLog = false;
128:            }
129:
130:            private void resetChildIndex() {
131:                for (int i = 0; i < entryChildren.length; i++) {
132:                    if (equal(entryChildren[i].getMessage(), entry.getMessage())
133:                            && equal(entryChildren[i].getDate(), entry
134:                                    .getDate())
135:                            && equal(entryChildren[i].getPluginId(), entry
136:                                    .getPluginId())
137:                            && entryChildren[i].getSeverity() == entry
138:                                    .getSeverity()
139:                            && equal(entryChildren[i].getSeverityText(), entry
140:                                    .getSeverityText())) {
141:                        childIndex = i;
142:                        break;
143:                    }
144:                }
145:            }
146:
147:            private boolean equal(String str1, String str2) {
148:                if (str1 == null) {
149:                    return str1 == str2;
150:                }
151:                return str1.equals(str2);
152:            }
153:
154:            private boolean equal(Date d1, Date d2) {
155:                if (d1 == null)
156:                    return d1 == d2;
157:                return d1.equals(d2);
158:            }
159:
160:            private void createImages() {
161:                imgCopyEnabled = PlatformUI.getWorkbench().getSharedImages()
162:                        .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)
163:                        .createImage(true);
164:                //imgNextDisabled. = PDERuntimePluginImages.DESC_NEXT_EVENT_DISABLED.createImage(true);
165:                //imgPrevDisabled = PDERuntimePluginImages.DESC_PREV_EVENT_DISABLED.createImage(true);
166:                imgPrevEnabled = PDERuntimePluginImages.DESC_PREV_EVENT
167:                        .createImage(true);
168:                imgNextEnabled = PDERuntimePluginImages.DESC_NEXT_EVENT
169:                        .createImage(true);
170:            }
171:
172:            private boolean isChild(LogEntry entry) {
173:                return entry.getParent(entry) != null;
174:            }
175:
176:            public boolean isOpen() {
177:                return isOpen;
178:            }
179:
180:            public int open() {
181:                isOpen = true;
182:                if (sashWeights == null) {
183:                    int width = getSashForm().getClientArea().width;
184:                    if (width - 100 > 0)
185:                        width -= 100;
186:                    else
187:                        width = width / 2;
188:                    sashWeights = new int[] { width,
189:                            getSashForm().getClientArea().width - width };
190:                }
191:                getSashForm().setWeights(sashWeights);
192:                return super .open();
193:            }
194:
195:            public boolean close() {
196:                storeSettings();
197:                isOpen = false;
198:                imgCopyEnabled.dispose();
199:                imgNextEnabled.dispose();
200:                imgPrevEnabled.dispose();
201:                labelProvider.disconnect(this );
202:                return super .close();
203:            }
204:
205:            public void create() {
206:                super .create();
207:
208:                // dialog location 
209:                if (dialogLocation != null)
210:                    getShell().setLocation(dialogLocation);
211:
212:                // dialog size
213:                if (dialogSize != null)
214:                    getShell().setSize(dialogSize);
215:                else
216:                    getShell().setSize(500, 550);
217:
218:                applyDialogFont(buttonBar);
219:                getButton(IDialogConstants.OK_ID).setFocus();
220:            }
221:
222:            protected void buttonPressed(int buttonId) {
223:                if (IDialogConstants.OK_ID == buttonId)
224:                    okPressed();
225:                else if (IDialogConstants.CANCEL_ID == buttonId)
226:                    cancelPressed();
227:                else if (IDialogConstants.BACK_ID == buttonId)
228:                    backPressed();
229:                else if (IDialogConstants.NEXT_ID == buttonId)
230:                    nextPressed();
231:                else if (COPY_ID == buttonId)
232:                    copyPressed();
233:            }
234:
235:            protected void backPressed() {
236:                if (isChild(entry)) {
237:                    if (childIndex > 0) {
238:                        if (isLastChild) {
239:                            setEntryChildren(parentEntry);
240:                            isLastChild = false;
241:                        }
242:                        childIndex--;
243:                        entry = entryChildren[childIndex];
244:                    } else
245:                        entry = parentEntry;
246:                } else {
247:                    if (elementNum - 1 >= 0)
248:                        elementNum -= 1;
249:                    entry = entryChildren[elementNum];
250:                }
251:                setEntrySelectionInTable();
252:            }
253:
254:            protected void nextPressed() {
255:                if (isChild(entry) && childIndex < entryChildren.length - 1) {
256:                    childIndex++;
257:                    entry = entryChildren[childIndex];
258:                    isLastChild = childIndex == entryChildren.length - 1;
259:                } else if (isChild(entry) && isLastChild && !isAtEndOfLog) {
260:                    findNextSelectedChild(entry);
261:                } else if (elementNum + 1 < totalElementCount) {
262:                    if (isLastChild) {
263:                        setEntryChildren();
264:                        isLastChild = false;
265:                    }
266:                    elementNum += 1;
267:                    entry = entryChildren[elementNum];
268:                } else { // at end of list but can branch into child elements - bug 58083
269:                    setEntryChildren(entry);
270:                    entry = entryChildren[0];
271:                    isAtEndOfLog = entryChildren.length == 0;
272:                    isLastChild = entryChildren.length == 0;
273:                }
274:                setEntrySelectionInTable();
275:            }
276:
277:            protected void copyPressed() {
278:                StringWriter writer = new StringWriter();
279:                PrintWriter pwriter = new PrintWriter(writer);
280:
281:                entry.write(pwriter);
282:                pwriter.flush();
283:                String textVersion = writer.toString();
284:                try {
285:                    pwriter.close();
286:                    writer.close();
287:                } catch (IOException e) {
288:                }
289:                // set the clipboard contents
290:                clipboard.setContents(new Object[] { textVersion },
291:                        new Transfer[] { TextTransfer.getInstance() });
292:            }
293:
294:            public void setComparator(Comparator comparator) {
295:                this .comparator = comparator;
296:                updateProperties();
297:            }
298:
299:            private void setComparator(byte sortType, final int sortOrder) {
300:                if (sortType == LogView.DATE) {
301:                    comparator = new Comparator() {
302:                        public int compare(Object e1, Object e2) {
303:                            Date date1 = ((LogEntry) e1).getDate();
304:                            Date date2 = ((LogEntry) e2).getDate();
305:                            if (sortOrder == LogView.ASCENDING)
306:                                return date1.getTime() < date2.getTime() ? LogView.DESCENDING
307:                                        : LogView.ASCENDING;
308:                            return date1.getTime() > date2.getTime() ? LogView.DESCENDING
309:                                    : LogView.ASCENDING;
310:                        }
311:                    };
312:                } else if (sortType == LogView.PLUGIN) {
313:                    comparator = new Comparator() {
314:                        public int compare(Object e1, Object e2) {
315:                            LogEntry entry1 = (LogEntry) e1;
316:                            LogEntry entry2 = (LogEntry) e2;
317:                            return collator.compare(entry1.getPluginId(),
318:                                    entry2.getPluginId())
319:                                    * sortOrder;
320:                        }
321:                    };
322:                } else {
323:                    comparator = new Comparator() {
324:                        public int compare(Object e1, Object e2) {
325:                            LogEntry entry1 = (LogEntry) e1;
326:                            LogEntry entry2 = (LogEntry) e2;
327:                            return collator.compare(entry1.getMessage(), entry2
328:                                    .getMessage())
329:                                    * sortOrder;
330:                        }
331:                    };
332:                }
333:            }
334:
335:            public void resetSelection(IAdaptable selectedEntry, byte sortType,
336:                    int sortOrder) {
337:                setComparator(sortType, sortOrder);
338:                resetSelection(selectedEntry);
339:            }
340:
341:            public void resetSelection(IAdaptable selectedEntry) {
342:                if (entry.equals(selectedEntry)
343:                        && elementNum == getParentElementNum()) {
344:                    updateProperties();
345:                    return;
346:                }
347:                entry = (LogEntry) selectedEntry;
348:                initialize();
349:                updateProperties();
350:            }
351:
352:            public void resetButtons() {
353:                backButton.setEnabled(false);
354:                nextButton.setEnabled(false);
355:            }
356:
357:            private void setEntrySelectionInTable() {
358:                ISelection selection = new StructuredSelection(entry);
359:                provider.setSelection(selection);
360:            }
361:
362:            public void updateProperties() {
363:                if (isChild(entry)) {
364:                    parentEntry = (LogEntry) entry.getParent(entry);
365:                    setEntryChildren(parentEntry);
366:                    resetChildIndex();
367:                    if (childIndex == entryChildren.length - 1)
368:                        isLastChild = true;
369:                }
370:
371:                resetTotalElementCount();
372:
373:                Date date = entry.getDate();
374:                String strDate = null;
375:                if (date != null) {
376:                    DateFormat formatter = new SimpleDateFormat(
377:                            LogEntry.F_DATE_FORMAT);
378:                    strDate = formatter.format(date);
379:                }
380:                dateLabel.setText(strDate != null ? strDate : ""); //$NON-NLS-1$
381:                severityImageLabel.setImage(labelProvider.getColumnImage(entry,
382:                        0));
383:                severityLabel.setText(entry.getSeverityText());
384:                msgText.setText(entry.getMessage() != null ? entry.getMessage()
385:                        : ""); //$NON-NLS-1$
386:                String stack = entry.getStack();
387:                if (stack != null) {
388:                    stackTraceText.setText(stack);
389:                } else {
390:                    stackTraceText
391:                            .setText(PDERuntimeMessages.EventDetailsDialog_noStack);
392:                }
393:                LogSession session = entry.getSession();
394:                if (session != null && session.getSessionData() != null)
395:                    sessionDataText.setText(session.getSessionData());
396:
397:                updateButtons();
398:            }
399:
400:            private void updateButtons() {
401:                boolean isAtEnd = elementNum == totalElementCount - 1;
402:                if (isChild(entry)) {
403:                    backButton.setEnabled(true);
404:                    nextButton.setEnabled(nextChildExists(entry, parentEntry,
405:                            entryChildren)
406:                            || !isLastChild || !isAtEnd || entry.hasChildren());
407:                } else {
408:                    backButton.setEnabled(elementNum != 0);
409:                    nextButton.setEnabled(!isAtEnd || entry.hasChildren());
410:                }
411:            }
412:
413:            private void findNextSelectedChild(LogEntry originalEntry) {
414:                if (isChild(parentEntry)) {
415:                    // we're at the end of the child list; find next parent
416:                    // to select.  If the parent is a child at the end of the child
417:                    // list, find its next parent entry to select, etc.
418:
419:                    entry = parentEntry;
420:                    setEntryChildren((LogEntry) parentEntry
421:                            .getParent(parentEntry));
422:                    parentEntry = (LogEntry) parentEntry.getParent(parentEntry);
423:                    resetChildIndex();
424:                    isLastChild = childIndex == entryChildren.length - 1;
425:                    if (isLastChild) {
426:                        findNextSelectedChild(originalEntry);
427:                    } else {
428:                        nextPressed();
429:                    }
430:                } else {
431:                    entry = originalEntry;
432:                    isAtEndOfLog = true;
433:                    nextPressed();
434:                }
435:            }
436:
437:            private boolean nextChildExists(LogEntry originalEntry,
438:                    LogEntry originalParent, LogEntry[] originalEntries) {
439:                if (isChild(parentEntry)) {
440:                    // we're at the end of the child list; find next parent
441:                    // to select.  If the parent is a child at the end of the child
442:                    // list, find its next parent entry to select, etc.
443:
444:                    entry = parentEntry;
445:                    setEntryChildren((LogEntry) parentEntry
446:                            .getParent(parentEntry));
447:                    parentEntry = (LogEntry) parentEntry.getParent(parentEntry);
448:                    resetChildIndex();
449:                    if (childIndex == entryChildren.length - 1) {
450:                        nextChildExists(originalEntry, originalParent,
451:                                originalEntries);
452:                    } else {
453:                        entry = originalEntry;
454:                        parentEntry = originalParent;
455:                        entryChildren = originalEntries;
456:                        resetChildIndex();
457:                        return true;
458:                    }
459:                }
460:                entry = originalEntry;
461:                parentEntry = originalParent;
462:                entryChildren = originalEntries;
463:                resetChildIndex();
464:                return false;
465:
466:            }
467:
468:            private void setEntryChildren() {
469:                Object[] children = ((LogViewContentProvider) provider
470:                        .getContentProvider()).getElements(null);
471:
472:                if (comparator != null)
473:                    Arrays.sort(children, comparator);
474:                entryChildren = new LogEntry[children.length];
475:
476:                System
477:                        .arraycopy(children, 0, entryChildren, 0,
478:                                children.length);
479:            }
480:
481:            private void resetTotalElementCount() {
482:                totalElementCount = provider.getTree().getItemCount();
483:            }
484:
485:            private void setEntryChildren(LogEntry parent) {
486:                if (parent == null) {
487:                    setEntryChildren();
488:                    return;
489:                }
490:                Object[] children = parent.getChildren(parent);
491:                if (comparator != null)
492:                    Arrays.sort(children, comparator);
493:                entryChildren = new LogEntry[children.length];
494:
495:                System
496:                        .arraycopy(children, 0, entryChildren, 0,
497:                                children.length);
498:            }
499:
500:            private int getParentElementNum() {
501:                LogEntry itemEntry = (LogEntry) ((IStructuredSelection) provider
502:                        .getSelection()).getFirstElement();
503:                itemEntry = getRootEntry(itemEntry);
504:
505:                setEntryChildren();
506:                for (int i = 0; i < provider.getTree().getItemCount(); i++) {
507:                    try {
508:                        LogEntry littleEntry = entryChildren[i];
509:                        if (itemEntry.equals(littleEntry)) {
510:                            return i;
511:                        }
512:                    } catch (Exception e) {
513:
514:                    }
515:                }
516:                return 0;
517:            }
518:
519:            private LogEntry getRootEntry(LogEntry entry) {
520:                if (!isChild(entry))
521:                    return entry;
522:                return getRootEntry((LogEntry) entry.getParent(entry));
523:            }
524:
525:            public SashForm getSashForm() {
526:                return sashForm;
527:            }
528:
529:            protected Control createDialogArea(Composite parent) {
530:                Composite container = new Composite(parent, SWT.NONE);
531:                GridLayout layout = new GridLayout();
532:                layout.numColumns = 1;
533:                container.setLayout(layout);
534:                GridData gd = new GridData(GridData.FILL_BOTH);
535:                container.setLayoutData(gd);
536:
537:                createDetailsSection(container);
538:                createSashForm(container);
539:                createStackSection(getSashForm());
540:                createSessionSection(getSashForm());
541:
542:                updateProperties();
543:                Dialog.applyDialogFont(container);
544:                return container;
545:            }
546:
547:            private void createSashForm(Composite parent) {
548:                sashForm = new SashForm(parent, SWT.VERTICAL);
549:                GridLayout layout = new GridLayout();
550:                layout.marginHeight = layout.marginWidth = 0;
551:                sashForm.setLayout(layout);
552:                sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
553:            }
554:
555:            private void createToolbarButtonBar(Composite parent) {
556:                Composite comp = new Composite(parent, SWT.NONE);
557:                GridLayout layout = new GridLayout();
558:                layout.marginWidth = layout.marginHeight = 0;
559:                layout.numColumns = 1;
560:                comp.setLayout(layout);
561:                comp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
562:
563:                Composite container = new Composite(comp, SWT.NONE);
564:                layout = new GridLayout();
565:                layout.marginWidth = 0;
566:                layout.marginHeight = 10;
567:                layout.numColumns = 1;
568:                container.setLayout(layout);
569:                container.setLayoutData(new GridData(GridData.FILL_BOTH));
570:
571:                backButton = createButton(container, IDialogConstants.BACK_ID,
572:                        "", false); //$NON-NLS-1$
573:                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
574:                gd.horizontalSpan = 3;
575:                gd.verticalSpan = 1;
576:                backButton.setLayoutData(gd);
577:                backButton
578:                        .setToolTipText(PDERuntimeMessages.EventDetailsDialog_previous);
579:                backButton.setImage(imgPrevEnabled);
580:
581:                nextButton = createButton(container, IDialogConstants.NEXT_ID,
582:                        "", false); //$NON-NLS-1$
583:                gd = new GridData();
584:                gd.horizontalSpan = 3;
585:                gd.verticalSpan = 1;
586:                nextButton.setLayoutData(gd);
587:                nextButton
588:                        .setToolTipText(PDERuntimeMessages.EventDetailsDialog_next);
589:                nextButton.setImage(imgNextEnabled);
590:
591:                copyButton = createButton(container, COPY_ID, "", false); //$NON-NLS-1$
592:                gd = new GridData();
593:                gd.horizontalSpan = 3;
594:                gd.verticalSpan = 1;
595:                copyButton.setLayoutData(gd);
596:                copyButton.setImage(imgCopyEnabled);
597:                copyButton
598:                        .setToolTipText(PDERuntimeMessages.EventDetailsDialog_copy);
599:            }
600:
601:            protected void createButtonsForButtonBar(Composite parent) {
602:                // create OK button only by default
603:                createButton(parent, IDialogConstants.OK_ID,
604:                        IDialogConstants.OK_LABEL, true);
605:            }
606:
607:            private void createDetailsSection(Composite parent) {
608:                Composite container = new Composite(parent, SWT.NONE);
609:                GridLayout layout = new GridLayout();
610:                layout.numColumns = 2;
611:                container.setLayout(layout);
612:                container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
613:
614:                createTextSection(container);
615:                createToolbarButtonBar(container);
616:            }
617:
618:            private void createTextSection(Composite parent) {
619:                Composite textContainer = new Composite(parent, SWT.NONE);
620:                GridLayout layout = new GridLayout();
621:                layout.numColumns = 3;
622:                layout.marginHeight = layout.marginWidth = 0;
623:                textContainer.setLayout(layout);
624:                textContainer.setLayoutData(new GridData(
625:                        GridData.FILL_HORIZONTAL));
626:
627:                Label label = new Label(textContainer, SWT.NONE);
628:                label.setText(PDERuntimeMessages.EventDetailsDialog_date);
629:                dateLabel = new Label(textContainer, SWT.NULL);
630:                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
631:                gd.horizontalSpan = 2;
632:                dateLabel.setLayoutData(gd);
633:
634:                label = new Label(textContainer, SWT.NONE);
635:                label.setText(PDERuntimeMessages.EventDetailsDialog_severity);
636:                severityImageLabel = new Label(textContainer, SWT.NULL);
637:                severityLabel = new Label(textContainer, SWT.NULL);
638:                gd = new GridData(GridData.FILL_HORIZONTAL);
639:                severityLabel.setLayoutData(gd);
640:
641:                label = new Label(textContainer, SWT.NONE);
642:                label.setText(PDERuntimeMessages.EventDetailsDialog_message);
643:                gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
644:                label.setLayoutData(gd);
645:                msgText = new Text(textContainer, SWT.MULTI | SWT.V_SCROLL
646:                        | SWT.WRAP | SWT.BORDER);
647:                msgText.setEditable(false);
648:                gd = new GridData(GridData.FILL_BOTH
649:                        | GridData.VERTICAL_ALIGN_BEGINNING
650:                        | GridData.GRAB_VERTICAL);
651:                gd.horizontalSpan = 2;
652:                gd.heightHint = 44;
653:                gd.grabExcessVerticalSpace = true;
654:                msgText.setLayoutData(gd);
655:            }
656:
657:            private void createStackSection(Composite parent) {
658:                Composite container = new Composite(parent, SWT.NONE);
659:                GridLayout layout = new GridLayout();
660:                layout.marginHeight = 0;
661:                layout.marginWidth = 6;
662:                container.setLayout(layout);
663:                GridData gd = new GridData(GridData.FILL_BOTH);
664:                gd.heightHint = 100;
665:                container.setLayoutData(gd);
666:
667:                Label label = new Label(container, SWT.NULL);
668:                label.setText(PDERuntimeMessages.EventDetailsDialog_exception);
669:                gd = new GridData(GridData.FILL_HORIZONTAL);
670:                gd.horizontalSpan = 3;
671:                label.setLayoutData(gd);
672:
673:                stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL
674:                        | SWT.H_SCROLL | SWT.BORDER);
675:                gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
676:                gd.grabExcessHorizontalSpace = true;
677:                stackTraceText.setLayoutData(gd);
678:                stackTraceText.setEditable(false);
679:            }
680:
681:            private void createSessionSection(Composite parent) {
682:                Composite container = new Composite(parent, SWT.NONE);
683:                GridLayout layout = new GridLayout();
684:                layout.marginHeight = 0;
685:                layout.marginWidth = 6;
686:                container.setLayout(layout);
687:                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
688:                gd.heightHint = 100;
689:                container.setLayoutData(gd);
690:
691:                Label line = new Label(container, SWT.SEPARATOR
692:                        | SWT.HORIZONTAL);
693:                gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
694:                gd.widthHint = 1;
695:                line.setLayoutData(gd);
696:
697:                Label label = new Label(container, SWT.NONE);
698:                label.setText(PDERuntimeMessages.EventDetailsDialog_session);
699:                gd = new GridData(GridData.FILL_HORIZONTAL);
700:                label.setLayoutData(gd);
701:                sessionDataText = new Text(container, SWT.BORDER | SWT.V_SCROLL
702:                        | SWT.H_SCROLL);
703:                gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
704:                gd.grabExcessHorizontalSpace = true;
705:                sessionDataText.setLayoutData(gd);
706:                sessionDataText.setEditable(false);
707:            }
708:
709:            //--------------- configuration handling --------------
710:
711:            /**
712:             * Stores the current state in the dialog settings.
713:             * @since 2.0
714:             */
715:            private void storeSettings() {
716:                writeConfiguration();
717:            }
718:
719:            /**
720:             * Returns the dialog settings object used to share state
721:             * between several event detail dialogs.
722:             * 
723:             * @return the dialog settings to be used
724:             */
725:            private IDialogSettings getDialogSettings() {
726:                IDialogSettings settings = PDERuntimePlugin.getDefault()
727:                        .getDialogSettings();
728:                IDialogSettings dialogSettings = settings.getSection(getClass()
729:                        .getName());
730:                if (dialogSettings == null)
731:                    dialogSettings = settings.addNewSection(getClass()
732:                            .getName());
733:                return dialogSettings;
734:            }
735:
736:            /**
737:             * Initializes itself from the dialog settings with the same state
738:             * as at the previous invocation.
739:             */
740:            private void readConfiguration() {
741:                IDialogSettings s = getDialogSettings();
742:                try {
743:                    int x = s.getInt("x"); //$NON-NLS-1$
744:                    int y = s.getInt("y"); //$NON-NLS-1$
745:                    dialogLocation = new Point(x, y);
746:
747:                    x = s.getInt("width"); //$NON-NLS-1$
748:                    y = s.getInt("height"); //$NON-NLS-1$
749:                    dialogSize = new Point(x, y);
750:
751:                    sashWeights = new int[2];
752:                    sashWeights[0] = s.getInt("sashWidth1"); //$NON-NLS-1$
753:                    sashWeights[1] = s.getInt("sashWidth2"); //$NON-NLS-1$
754:
755:                } catch (NumberFormatException e) {
756:                    dialogLocation = null;
757:                    dialogSize = null;
758:                    sashWeights = null;
759:                }
760:            }
761:
762:            private void writeConfiguration() {
763:                IDialogSettings s = getDialogSettings();
764:                Point location = getShell().getLocation();
765:                s.put("x", location.x); //$NON-NLS-1$
766:                s.put("y", location.y); //$NON-NLS-1$
767:
768:                Point size = getShell().getSize();
769:                s.put("width", size.x); //$NON-NLS-1$
770:                s.put("height", size.y); //$NON-NLS-1$
771:
772:                sashWeights = getSashForm().getWeights();
773:                s.put("sashWidth1", sashWeights[0]); //$NON-NLS-1$
774:                s.put("sashWidth2", sashWeights[1]); //$NON-NLS-1$
775:            }
776:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.