Coverage Report - org.xmlhammer.gui.output.AttributeDetailsDialog
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeDetailsDialog
0% 
N/A 
0
 
 1  
 /*
 2  
  * $Id: AttributeDetailsDialog.java,v 1.9 2008/05/19 20:41:08 edankert Exp $
 3  
  *
 4  
  * The contents of this file are subject to the Mozilla Public License 
 5  
  * Version 1.1 (the "License"); you may not use this file except in 
 6  
  * compliance with the License. You may obtain a copy of the License at 
 7  
  * http://www.mozilla.org/MPL/ 
 8  
  *
 9  
  * Software distributed under the License is distributed on an "AS IS" basis, 
 10  
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 11  
  * for the specific language governing rights and limitations under the License.
 12  
  *
 13  
  * The Original Code is XML Hammer code. (org.xmlhammer.*)
 14  
  *
 15  
  * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
 16  
  * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
 17  
  * All Rights Reserved.
 18  
  *
 19  
  * Contributor(s): Edwin Dankert <edankert@gmail.com>
 20  
  */
 21  
 package org.xmlhammer.gui.output;
 22  
 
 23  
 import java.awt.BorderLayout;
 24  
 import java.awt.Dimension;
 25  
 import java.awt.Font;
 26  
 
 27  
 import javax.swing.Box;
 28  
 import javax.swing.JEditorPane;
 29  
 import javax.swing.JFrame;
 30  
 import javax.swing.JLabel;
 31  
 import javax.swing.JPanel;
 32  
 import javax.swing.JScrollPane;
 33  
 import javax.swing.JTextField;
 34  
 import javax.swing.text.PlainDocument;
 35  
 
 36  
 import org.bounce.FormLayout;
 37  
 import org.bounce.text.LineNumberMargin;
 38  
 import org.bounce.text.ScrollableEditorPanel;
 39  
 import org.bounce.text.xml.XMLEditorKit;
 40  
 import org.xmlhammer.model.project.Attribute;
 41  
 
 42  
 class AttributeDetailsDialog extends DetailsDialog {
 43  
     private static final long serialVersionUID = 6396657641170177743L;
 44  0
 
 45  0
     private NodePanel nodePanel = null;
 46  0
     private TypePanel typePanel = null;
 47  0
     
 48  0
     private JTextField srcField = null;
 49  0
     private JTextField classField = null;
 50  0
     private JTextField nameField = null;
 51  0
     private JTextField valueField = null;
 52  0
     private JTextField pathField = null;
 53  0
 
 54  0
     private CheckLabel specifiedField = null;
 55  0
     private CheckLabel idField = null;
 56  0
 
 57  0
     private JEditorPane contextPane = null;
 58  
     
 59  0
     AttributeDetailsDialog(JFrame parent) {
 60  0
         super(parent, "Attribute Details");
 61  0
         
 62  0
         DetailsPanel general = new DetailsPanel(new BorderLayout(), "general");
 63  0
         JPanel form = new JPanel(new FormLayout(5, 5));
 64  0
 
 65  0
         srcField = new JTextField();
 66  0
         srcField.setEditable(false);
 67  0
         form.add(new JLabel("URI:"), LABEL_CONSTRAINTS);
 68  0
         form.add(srcField, FormLayout.RIGHT_FILL);
 69  0
 
 70  0
         classField = new JTextField();
 71  0
         classField.setEditable(false);
 72  0
         form.add(new JLabel("Class:"), LABEL_CONSTRAINTS);
 73  0
         form.add(classField, FormLayout.RIGHT_FILL);
 74  0
 
 75  0
         form.add(Box.createVerticalStrut(10), FormLayout.FULL);
 76  0
 
 77  0
         pathField = new JTextField();
 78  0
         pathField.setEditable(false);
 79  0
         form.add(new JLabel("Path:"), LABEL_CONSTRAINTS);
 80  0
         form.add(pathField, FormLayout.RIGHT_FILL);
 81  0
 
 82  0
         form.add(Box.createVerticalStrut(10), FormLayout.FULL);
 83  0
 
 84  0
         specifiedField = new CheckLabel("Specified");
 85  0
         form.add(new JLabel(), LABEL_CONSTRAINTS);
 86  0
         form.add(specifiedField, FormLayout.RIGHT);
 87  0
 
 88  0
         idField = new CheckLabel("ID");
 89  0
         form.add(new JLabel(), LABEL_CONSTRAINTS);
 90  0
         form.add(idField, FormLayout.RIGHT);
 91  0
 
 92  0
         nameField = new JTextField();
 93  0
         nameField.setEditable(false);
 94  0
         form.add(new JLabel("Name:"), LABEL_CONSTRAINTS);
 95  0
         form.add(nameField, FormLayout.RIGHT_FILL);
 96  0
 
 97  0
         valueField = new JTextField();
 98  0
         valueField.setEditable(false);
 99  0
         form.add(new JLabel("Value:"), LABEL_CONSTRAINTS);
 100  0
         form.add(valueField, FormLayout.RIGHT_FILL);
 101  0
 
 102  0
         form.add(Box.createVerticalStrut(10), FormLayout.FULL);
 103  0
 
 104  0
         form.add(new JLabel("Context:"), FormLayout.FULL);
 105  0
 
 106  0
         nodePanel = new NodePanel();
 107  0
         typePanel = new TypePanel();
 108  0
 
 109  0
         contextPane = new JEditorPane();
 110  0
         contextPane.setEditorKit(new XMLEditorKit());
 111  0
         contextPane.setEditable(false);
 112  0
         contextPane.setFont(new Font("monospaced", Font.PLAIN, 12));
 113  0
         contextPane.getDocument().putProperty(PlainDocument.tabSizeAttribute, new Integer(2));
 114  0
 
 115  0
         JScrollPane scroller = new JScrollPane(new ScrollableEditorPanel(contextPane));
 116  0
         scroller.setPreferredSize(AttributeNode.EDITORPANE_SIZE);
 117  0
 
 118  0
         // Add the number margin as a Row Header View
 119  0
         scroller.setRowHeaderView(new LineNumberMargin(contextPane));
 120  0
 
 121  0
         general.add(form, BorderLayout.NORTH);
 122  0
         general.add(scroller, BorderLayout.CENTER);
 123  
 
 124  0
         addTab("General", general);
 125  0
         addTab("Node", nodePanel);
 126  0
         addTab("Type", typePanel);
 127  0
         
 128  0
         pack();
 129  
         
 130  0
         setSize(new Dimension( 500, getSize().height));
 131  0
         setLocationRelativeTo(parent);
 132  0
     }
 133  0
     
 134  
     public void setAttribute( Attribute attribute) {
 135  0
         setTitle(attribute.getNodeName()+" - Attribute Details");
 136  0
         nodePanel.setNode(attribute);
 137  0
         typePanel.setType( attribute.getType());
 138  0
 
 139  0
         srcField.setText(attribute.getSrc());
 140  0
         srcField.setCaretPosition(0);
 141  0
         classField.setText(attribute.getClazz());
 142  0
         classField.setCaretPosition(0);
 143  0
         pathField.setText( attribute.getPath());
 144  0
         pathField.setCaretPosition(0);
 145  0
         specifiedField.setSelected(attribute.isSpecified());
 146  0
         idField.setSelected(attribute.isId());
 147  0
 
 148  0
         nameField.setText( attribute.getName());
 149  0
         nameField.setCaretPosition(0);
 150  0
         valueField.setText( attribute.getValue());
 151  0
         valueField.setCaretPosition(0);
 152  
         
 153  0
         contextPane.setText(attribute.getContext());
 154  0
         contextPane.setCaretPosition(0);
 155  0
     }
 156  
 
 157  
     @Override
 158  
     protected String getBaseHelpID() {
 159  0
         return "output.result.attribute";
 160  
     }
 161  
 }