?? relationtypepropertyframe.java
字號:
package toocom.ui;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.lang.*;
import toocom.ocgl.*;
import toocom.exceptions.*;
/**
* This class represents the graphical window used to specify the properties of a relation type.
*
* @author Fr閐閞ic F黵st
*/
public class RelationTypePropertyFrame extends JDialog implements ActionListener{
private RelationType rt;
private MainFrame mf;
private GridBagLayout lay;
private GridBagConstraints gbc;
private JTextField termTextField;
private JComboBox languageMenu;
private JList parents;
private JList children;
private Language currentLanguage;
private JSpinner aritySpinner;
private LinkedList sign;
private LinkedList exRelTypes;
private Object[] ctList;
private LinkedList propBox;
private JComboBox exclusivityList;
private final JList incompatibilityList;
private JList nonIncompRelTypes;
private LinkedList nonIncompRelTypesList;
private Box signatureBox;
private Box minCardinalityBox;
private Box maxCardinalityBox;
private Box globalBox;
public RelationTypePropertyFrame(RelationType rt,MainFrame mf){
super(mf,Constants.PROPERTIES_OF_LABEL + rt.getTerm(mf.getOntologyLanguage()),true);
this.rt = rt;
this.mf = mf;
this.propBox = new LinkedList();
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
currentLanguage = mf.getOntologyLanguage();
ctList = NamedObject.sortListByName(mf.getOntology().getConceptTypes(),mf.getOntologyLanguage()).toArray();
sign = new LinkedList();
lay = new GridBagLayout();
this.getContentPane().setLayout(lay);
gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 1.0;
//Term
Label lab = new Label(Constants.TERM_LABEL);
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
termTextField = new JTextField(rt.getTerm(mf.getOntologyLanguage()));
lay.setConstraints(termTextField,gbc);
this.getContentPane().add(termTextField);
languageMenu = new JComboBox(Language.getAllLanguages().toArray());
languageMenu.setMaximumRowCount(Constants.PROPERTY_FRAME_COMBO_BOX_MAX_ROW_COUNT);
languageMenu.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setLanguage();
}
});
languageMenu.setSelectedItem(mf.getOntologyLanguage());
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(languageMenu,gbc);
this.getContentPane().add(languageMenu,gbc);
gbc.gridwidth = 1;
// Parents
lab = new Label(Constants.PARENTS_LABEL);
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
String[] parentList = new String[rt.getParents().size()];
int cpt = 0;
for(Iterator i = rt.getParents().iterator();i.hasNext();){
parentList[cpt] = ((RelationType) i.next()).getTerm(mf.getOntologyLanguage());
cpt ++;
}
parents = new JList(parentList);
parents.setVisibleRowCount(rt.getParents().size());
JScrollPane parentsBoxScrollPane = new JScrollPane(parents);
gbc.weightx = 2.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(parentsBoxScrollPane,gbc);
this.getContentPane().add(parentsBoxScrollPane);
// Children
lab = new Label(Constants.CHILDREN_LABEL);
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
String[] childrenList = new String[rt.getChildren().size()];
cpt = 0;
for(Iterator i = rt.getChildren().iterator();i.hasNext();){
childrenList[cpt] = ((RelationType) i.next()).getTerm(mf.getOntologyLanguage());
cpt ++;
}
children = new JList(childrenList);
children.setVisibleRowCount(rt.getChildren().size());
JScrollPane childrenBoxScrollPane = new JScrollPane(children);
gbc.weightx = 2.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(childrenBoxScrollPane,gbc);
this.getContentPane().add(childrenBoxScrollPane);
// Arity
lab = new Label(Constants.ARITY_LABEL);
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
SpinnerNumberModel snm = new SpinnerNumberModel(rt.getArity(),CGConstants.RELATION_TYPE_MIN_ARITY,CGConstants.RELATION_TYPE_MAX_ARITY,1);
aritySpinner = new JSpinner(snm);
aritySpinner.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
setArity();
}
});
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(aritySpinner,gbc);
this.getContentPane().add(aritySpinner);
// Signature
lab = new Label(Constants.SIGNATURE_LABEL);
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
signatureBox = new Box(BoxLayout.X_AXIS);
this.setSignatureBox();
gbc.weightx = 2.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(signatureBox,gbc);
this.getContentPane().add(signatureBox);
// Incompatibility
exRelTypes = NamedObject.sortListByName(RelationExclusivity.getLinkablePrimitives(mf.getOntology().getRelationTypes(),rt),mf.getOntologyLanguage());
lab = new Label(Constants.INCOMPATIBILITY_LABEL);
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
incompatibilityList = new JList(new DefaultListModel());
incompatibilityList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
incompatibilityList.setVisibleRowCount(Constants.INCOMPATIBILITY_LIST_VISIBLE_ROW_COUNT);
this.setIncompatibility();
gbc.weightx = 2.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(incompatibilityList,gbc);
this.getContentPane().add(incompatibilityList);
// Exclusivity
lab = new Label(Constants.EXCLUSIVITY_LABEL);
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
exclusivityList = new JComboBox();
this.setExclusivity();
exclusivityList.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setExclusive();
}
});
gbc.weightx = 2.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(exclusivityList,gbc);
this.getContentPane().add(exclusivityList);
// Min Cardinalities
lab = new Label(Constants.MIN_CARDINALITY_LABEL);
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
minCardinalityBox = new Box(BoxLayout.X_AXIS);
this.setMinCardinalityBox();
gbc.weightx = 2.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(minCardinalityBox,gbc);
this.getContentPane().add(minCardinalityBox);
// Max Cardinalities
lab = new Label(Constants.MAX_CARDINALITY_LABEL);
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
maxCardinalityBox = new Box(BoxLayout.X_AXIS);
this.setMaxCardinalityBox();
gbc.weightx = 2.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(maxCardinalityBox,gbc);
this.getContentPane().add(maxCardinalityBox);
// Symmetry
lab = new Label(CGConstants.getRelationSymmetryTerms().getTerm(mf.getOntologyLanguage()));
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
JCheckBox cb = new JCheckBox();
if(rt.hasAxiomSchema("toocom.ocgl.RelationSymmetry")) cb.setSelected(true);
cb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setProperty("toocom.ocgl.RelationSymmetry");
}
});
this.propBox.add(cb);
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(cb,gbc);
this.getContentPane().add(cb);
// Reflexivity
lab = new Label(CGConstants.getRelationReflexivityTerms().getTerm(mf.getOntologyLanguage()));
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
cb = new JCheckBox();
if(rt.hasAxiomSchema("toocom.ocgl.RelationReflexivity")) cb.setSelected(true);
cb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setProperty("toocom.ocgl.RelationReflexivity");
}
});
this.propBox.add(cb);
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(cb,gbc);
this.getContentPane().add(cb);
// Transitivity
lab = new Label(CGConstants.getRelationTransitivityTerms().getTerm(mf.getOntologyLanguage()));
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
cb = new JCheckBox();
if(rt.hasAxiomSchema("toocom.ocgl.RelationTransitivity")) cb.setSelected(true);
cb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setProperty("toocom.ocgl.RelationTransitivity");
}
});
this.propBox.add(cb);
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(cb,gbc);
this.getContentPane().add(cb);
// Irreflexivity
lab = new Label(CGConstants.getRelationIrreflexivityTerms().getTerm(mf.getOntologyLanguage()));
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
cb = new JCheckBox();
if(rt.hasAxiomSchema("toocom.ocgl.RelationIrreflexivity")) cb.setSelected(true);
cb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setProperty("toocom.ocgl.RelationIrreflexivity");
}
});
this.propBox.add(cb);
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(cb,gbc);
this.getContentPane().add(cb);
// Antisymmetry
lab = new Label(CGConstants.getRelationAntisymmetryTerms().getTerm(mf.getOntologyLanguage()));
gbc.weightx = 1.0;
gbc.gridwidth = 1;
lay.setConstraints(lab,gbc);
this.getContentPane().add(lab);
cb = new JCheckBox();
if(rt.hasAxiomSchema("toocom.ocgl.RelationAntisymmetry")) cb.setSelected(true);
cb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setProperty("toocom.ocgl.RelationAntisymmetry");
}
});
this.propBox.add(cb);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -