<commit_before>/*
 * Copyright 2006-2011 The Virtual Laboratory for e-Science (VL-e) 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License").  
 * You may not use this file except in compliance with the License. 
 * For details, see the LICENCE.txt file location in the root directory of this 
 * distribution or obtain the Apache Licence at the following location: 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 * 
 * See: http://www.vl-e.nl/ 
 * See: LICENCE.txt (located in the root folder of this distribution). 
 * ---
 * $Id: AttributeViewer.java,v 1.2 2011-04-18 12:27:13 ptdeboer Exp $  
 * $Date: 2011-04-18 12:27:13 $
 */ 
// source: 

package nl.uva.vlet.gui.panels.attribute;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;

import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;

import nl.uva.vlet.Global;
import nl.uva.vlet.data.VAttribute;
import nl.uva.vlet.gui.GuiSettings;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AttributeViewer extends JDialog implements FocusListener, ActionListener
{
    private JPanel panel;
    private JLabel attrNameLabel;
    private JTextField attrNameField;
    private JTextArea attrValueField;
    private JLabel nameLabel;
    private JTextField attrTypeField;
    private JLabel attrValueLabel;
    private JLabel attrTypeLabel;
    
    private VAttribute attribute=new VAttribute("LongAttribute",(long)10);
    private JScrollPane attrScrollPane; 

    public static void viewAttribute(VAttribute attr)
    {
    	editAttribute(attr,false); 
    }
    
    VAttribute newAttribute=null;
	private boolean editable=true;
	private JButton cancelButton;
	private JButton okButton;
	private JPanel buttonPanel;

    public static VAttribute editAttribute(VAttribute attr,boolean editable)
    {
        AttributeViewer av=new AttributeViewer(attr);
        av.setEditable(editable); 
        av.setModal(true);
        av.setVisible(true);
       
        return av.newAttribute; 
    }
    
    public AttributeViewer()
    {
        initGUI(); 
    }
    
    public void setEditable(boolean editbl)
    {
    	this.editable=editbl; 
    	this.attrValueField.setEditable(editbl); 
    	
    }
    
    public AttributeViewer(VAttribute attr)
    { 
        this.attribute=attr;
        initGUI(); 
    }

    private void initGUI()
    {
        try 
        {
            {
                this.setSize(379, 189);
            }
            {
                panel = new JPanel();
                getContentPane().add(panel, BorderLayout.CENTER);
                FormLayout panelLayout = new FormLayout(
                    "max(p;5dlu), right:pref, left:pref:grow,1px,left:pref:grow, 0px,max(p;5dlu)",
                    "max(p;5dlu), center:pref,10px,center:pref,center:pref,top:pref:grow,0px,max(p;10dlu)");
                panel.setLayout(panelLayout);
                panel.setPreferredSize(new java.awt.Dimension(350, 160));
                {
                    attrNameLabel = new JLabel();
                    panel.add(attrNameLabel, new CellConstraints(
                        "2, 4, 1, 1, default, default"));
                    attrNameLabel.setText("Attribute Name:");
                }
                {
                    attrNameField = new JTextField();
                    panel.add(attrNameField, new CellConstraints("3, 4, 2, 1, default, default"));
                    attrNameField.setText(attribute.getName());
                    attrNameField.setEditable(false); 
                }
                {
                    attrTypeLabel = new JLabel();
                    panel.add(attrTypeLabel, new CellConstraints(
                        "2, 5, 1, 1, default, default"));
                    attrTypeLabel.setText("Attribute Type:");
                }
                {
                    attrTypeField = new JTextField();
                    panel.add(attrTypeField, new CellConstraints("3, 5, 2, 1, default, default"));
                    attrTypeField.setText(attribute.getType().toString());
                    attrTypeField.setEditable(false); 
                }
                {
                    attrValueLabel = new JLabel();
                    panel.add(attrValueLabel, new CellConstraints(
                        "2, 6, 1, 1, default, default"));
                    attrValueLabel.setText("Value:");
                }
                {
                    attrScrollPane=new JScrollPane(); 
                    panel.add(attrScrollPane, new CellConstraints("3, 6, 3, 2, default, default"));
                    attrScrollPane.setPreferredSize(new Dimension(200,40)); 
                  {
                      attrValueField = new JTextArea();
                      attrScrollPane.setViewportView(attrValueField);
                      attrValueField.setText(attribute.getValue());
                      attrValueField.setBorder(BorderFactory
                        .createEtchedBorder(BevelBorder.LOWERED));
                      attrValueField.setEditable(this.editable);
                      
                  }
                }
                {
                    nameLabel = new JLabel();
                    panel.add(nameLabel, new CellConstraints(
                        "2, 2, 2, 1, center, default"));<commit_msg>Type safety: changed VAttribute.getValue() to typed VAttribute.getStringValue()<commit_after>/*
 * Copyright 2006-2011 The Virtual Laboratory for e-Science (VL-e) 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License").  
 * You may not use this file except in compliance with the License. 
 * For details, see the LICENCE.txt file location in the root directory of this 
 * distribution or obtain the Apache Licence at the following location: 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 * 
 * See: http://www.vl-e.nl/ 
 * See: LICENCE.txt (located in the root folder of this distribution). 
 * ---
 * $Id: AttributeViewer.java,v 1.2 2011-04-18 12:27:13 ptdeboer Exp $  
 * $Date: 2011-04-18 12:27:13 $
 */ 
// source: 

package nl.uva.vlet.gui.panels.attribute;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;

import nl.uva.vlet.Global;
import nl.uva.vlet.data.VAttribute;
import nl.uva.vlet.gui.GuiSettings;

import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AttributeViewer extends JDialog implements FocusListener, ActionListener
{
    private JPanel panel;
    private JLabel attrNameLabel;
    private JTextField attrNameField;
    private JTextArea attrValueField;
    private JLabel nameLabel;
    private JTextField attrTypeField;
    private JLabel attrValueLabel;
    private JLabel attrTypeLabel;
    
    private VAttribute attribute=new VAttribute("LongAttribute",(long)10);
    private JScrollPane attrScrollPane; 

    public static void viewAttribute(VAttribute attr)
    {
    	editAttribute(attr,false); 
    }
    
    VAttribute newAttribute=null;
	private boolean editable=true;
	private JButton cancelButton;
	private JButton okButton;
	private JPanel buttonPanel;

    public static VAttribute editAttribute(VAttribute attr,boolean editable)
    {
        AttributeViewer av=new AttributeViewer(attr);
        av.setEditable(editable); 
        av.setModal(true);
        av.setVisible(true);
       
        return av.newAttribute; 
    }
    
    public AttributeViewer()
    {
        initGUI(); 
    }
    
    public void setEditable(boolean editbl)
    {
    	this.editable=editbl; 
    	this.attrValueField.setEditable(editbl); 
    	
    }
    
    public AttributeViewer(VAttribute attr)
    { 
        this.attribute=attr;
        initGUI(); 
    }

    private void initGUI()
    {
        try 
        {
            {
                this.setSize(379, 189);
            }
            {
                panel = new JPanel();
                getContentPane().add(panel, BorderLayout.CENTER);
                FormLayout panelLayout = new FormLayout(
                    "max(p;5dlu), right:pref, left:pref:grow,1px,left:pref:grow, 0px,max(p;5dlu)",
                    "max(p;5dlu), center:pref,10px,center:pref,center:pref,top:pref:grow,0px,max(p;10dlu)");
                panel.setLayout(panelLayout);
                panel.setPreferredSize(new java.awt.Dimension(350, 160));
                {
                    attrNameLabel = new JLabel();
                    panel.add(attrNameLabel, new CellConstraints(
                        "2, 4, 1, 1, default, default"));
                    attrNameLabel.setText("Attribute Name:");
                }
                {
                    attrNameField = new JTextField();
                    panel.add(attrNameField, new CellConstraints("3, 4, 2, 1, default, default"));
                    attrNameField.setText(attribute.getName());
                    attrNameField.setEditable(false); 
                }
                {
                    attrTypeLabel = new JLabel();
                    panel.add(attrTypeLabel, new CellConstraints(
                        "2, 5, 1, 1, default, default"));
                    attrTypeLabel.setText("Attribute Type:");
                }
                {
                    attrTypeField = new JTextField();
                    panel.add(attrTypeField, new CellConstraints("3, 5, 2, 1, default, default"));
                    attrTypeField.setText(attribute.getType().toString());
                    attrTypeField.setEditable(false); 
                }
                {
                    attrValueLabel = new JLabel();
                    panel.add(attrValueLabel, new CellConstraints(
                        "2, 6, 1, 1, default, default"));
                    attrValueLabel.setText("Value:");
                }
                {
                    attrScrollPane=new JScrollPane(); 
                    panel.add(attrScrollPane, new CellConstraints("3, 6, 3, 2, default, default"));
                    attrScrollPane.setPreferredSize(new Dimension(200,40)); 
                  {
                      attrValueField = new JTextArea();
                      attrScrollPane.setViewportView(attrValueField);
                      attrValueField.setText(attribute.getStringValue());
                      attrValueField.setBorder(BorderFactory
                        .createEtchedBorder(BevelBorder.LOWERED));
                      attrValueField.setEditable(this.editable);
                      
                  }
                }
                {
                    nameLabel = new JLabel();
                    panel.add(nameLabel, new CellConstraints(
                        "2, 2, 2, 1, center, default"));
{'fraction_non_alphanumeric': 0.09017628446587314, 'fraction_numerical': 0.014916377881573, 'mean_word_length': 2.1390399621659966, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4945052', 'n_tokens_mistral': 3818, 'n_tokens_neox': 3479, 'n_words': 931}