001: /*
002: * The contents of this file are subject to the Mozilla Public License
003: * Version 1.1 (the "License"); you may not use this file except in
004: * compliance with the License. You may obtain a copy of the License at
005: * http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009: * License for the specific language governing rights and limitations
010: * under the License.
011: *
012: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013: *
014: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016: *
017: * Contributor(s):
018: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019: *
020: * If you didn't download this code from the following link, you should check
021: * if you aren't using an obsolete version: http://www.isqlviewer.com
022: */
023: package org.isqlviewer.ui;
024:
025: import java.awt.Dimension;
026: import java.awt.GridBagConstraints;
027: import java.awt.GridBagLayout;
028: import java.awt.dnd.DnDConstants;
029: import java.awt.dnd.DragSource;
030: import java.util.prefs.Preferences;
031:
032: import javax.swing.JComponent;
033: import javax.swing.JLabel;
034: import javax.swing.JMenuBar;
035: import javax.swing.JPanel;
036: import javax.swing.JScrollPane;
037: import javax.swing.table.TableColumn;
038: import javax.swing.table.TableColumnModel;
039:
040: import org.isqlviewer.model.ThrowableOutlineModel;
041: import org.isqlviewer.swing.WizardPanel;
042: import org.isqlviewer.swing.action.SwingEventManager;
043: import org.isqlviewer.swing.outline.JOutline;
044: import org.isqlviewer.ui.laf.EnhancedTableCellRenderer;
045: import org.isqlviewer.ui.listeners.ThrowableTreeDragListener;
046: import org.isqlviewer.ui.renderer.ThrowableTreeCellRenderer;
047:
048: /**
049: * Basic view for displaying Java throwable objects.
050: * <p>
051: *
052: * @author Mark A. Kobold <mkobold at isqlviewer dot com>
053: * @version 1.0
054: */
055: public class ThrowableView extends AbstractApplicationView {
056:
057: private Throwable error = null;
058: private String message = null;
059: private JScrollPane scrollPanel = null;
060:
061: public ThrowableView(Throwable error, String message) {
062:
063: this .error = error;
064: this .message = message;
065: }
066:
067: public void configureMenubar(JMenuBar menuBar) {
068:
069: }
070:
071: public void disposeView(Preferences preferences) {
072:
073: }
074:
075: public void doLayout(JComponent parentComponent,
076: Preferences preferences, SwingEventManager eventManager) {
077:
078: parentComponent.setLayout(new WizardPanel.Layout());
079: JPanel panel = new JPanel(new GridBagLayout());
080:
081: Object constraint = null;
082: constraint = constrain(0, 0, 1, 1, 1.0, 0.0,
083: GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL);
084: panel.add(new JLabel(message), constraint);
085: if (error != null) {
086:
087: JOutline outline = new JOutline(new ThrowableOutlineModel(
088: error));
089: outline.setRootVisible(false);
090: outline.setTreeCellRenderer(new ThrowableTreeCellRenderer(
091: outline));
092:
093: ThrowableTreeDragListener dragListener = new ThrowableTreeDragListener(
094: outline);
095: DragSource dndDragSource = DragSource
096: .getDefaultDragSource();
097: dndDragSource.createDefaultDragGestureRecognizer(outline,
098: DnDConstants.ACTION_COPY, dragListener);
099:
100: TableColumnModel columnModel = outline.getColumnModel();
101: TableColumn column = columnModel.getColumn(1);
102: column.setCellRenderer(new EnhancedTableCellRenderer());
103:
104: scrollPanel = new JScrollPane(outline);
105: scrollPanel.setPreferredSize(new Dimension(320, 200));
106: scrollPanel.setMinimumSize(scrollPanel.getPreferredSize());
107: scrollPanel.setMaximumSize(scrollPanel.getPreferredSize());
108: constraint = constrain(0, 1, 1, 1, 1.0, 1.0,
109: GridBagConstraints.CENTER, GridBagConstraints.BOTH);
110: panel.add(scrollPanel, constraint);
111: }
112: parentComponent.add(panel);
113: parentComponent.invalidate();
114: }
115:
116: public void initializeView() {
117:
118: }
119: }
|