?? relationtypepropertyframe.java
字號:
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(cb,gbc);
this.getContentPane().add(cb);
JButton ok = new JButton(Constants.OK_LABEL);
ok.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setValues();
}
});
gbc.weightx = 2.0;
gbc.gridx = 0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
lay.setConstraints(ok,gbc);
this.getContentPane().add(ok);
this.pack();
this.setLocation((mf.getWidth() - this.getWidth())/2,(mf.getHeight() - this.getHeight())/2);
this.getRootPane().registerKeyboardAction(this,"ok",KeyStroke.getKeyStroke(Constants.OK_KEY),JComponent.WHEN_IN_FOCUSED_WINDOW);
this.setVisible(true);
this.toFront();
}
public void actionPerformed(ActionEvent event){
if(event.getActionCommand().equals("ok")) this.setValues();
}
public void processWindowEvent(WindowEvent e){
if(e.getID() == WindowEvent.WINDOW_CLOSING) this.setValues();
}
/** Set the Box which contains the JComboBox with the concept types of the signature of the
* relation type. */
private void setSignatureBox(){
LinkedList tempSign = new LinkedList();
signatureBox.removeAll();
for(int i = 0;i < rt.getArity();i ++){
JComboBox tempCB = new JComboBox();
tempCB.setMaximumRowCount(Constants.PROPERTY_FRAME_COMBO_BOX_MAX_ROW_COUNT);
tempCB.addItem("");
if(ctList.length != 0){
ConceptType ct = rt.getSignature().getConceptType(i + 1);
int tempSelectIndex = 0;
for(int j = 0;j < ctList.length;j ++){
ConceptType tempCT = (ConceptType) ctList[j];
tempCB.addItem(tempCT.getTerm(mf.getOntologyLanguage()));
if(ct != null){
if(tempCT.equals(ct)) tempSelectIndex = j + 1;
}
}
tempCB.setSelectedIndex(tempSelectIndex);
tempCB.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
setSignature();
}
});
}
tempSign.add(tempCB);
signatureBox.add(tempCB);
}
sign = tempSign;
}
private void setMinCardinalityBox(){
this.minCardinalityBox.removeAll();
for(int i = 1;i <= rt.getArity();i ++){
final int index = i;
LinkedList minCard = rt.getAxiomSchemata("toocom.ocgl.RelationMinCardinality");
RelationMinCardinality mc = null;
for(Iterator j = minCard.iterator();j.hasNext() && (mc == null);){
RelationMinCardinality mcTemp = (RelationMinCardinality) j.next();
if(mcTemp.getIndex() == index) mc = mcTemp;
}
SpinnerNumberModel snm;
if(mc != null) snm = new SpinnerNumberModel(mc.getValue(),CGConstants.RELATION_TYPE_MIN_CARDINALITY,CGConstants.RELATION_TYPE_MAX_CARDINALITY,1);
else snm = new SpinnerNumberModel(0,CGConstants.RELATION_TYPE_MIN_CARDINALITY,CGConstants.RELATION_TYPE_MAX_CARDINALITY,1);
JSpinner spin = new JSpinner(snm);
spin.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
setMinCardinality(index,((SpinnerNumberModel) ((JSpinner) e.getSource()).getModel()));
}
});
this.minCardinalityBox.add(spin);
}
}
public void setMinCardinality(int index,SpinnerNumberModel snm){
int value = snm.getNumber().intValue();
LinkedList minCard = rt.getAxiomSchemata("toocom.ocgl.RelationMinCardinality");
RelationMinCardinality mc = null;
for(Iterator j = minCard.iterator();j.hasNext() && (mc == null);){
RelationMinCardinality mcTemp = (RelationMinCardinality) j.next();
if(mcTemp.getIndex() == index) mc = mcTemp;
}
if(value != 0){
if((mc != null) && (value != mc.getValue())){
rt.removeAxiomSchemata("toocom.ocgl.RelationMinCardinality");
new RelationMinCardinality(rt,index,value);
}
if(mc == null) new RelationMinCardinality(rt,index,value);
}
else{
if(mc != null) rt.removeAxiomSchemata("toocom.ocgl.RelationMinCardinality");
}
mf.getOntologySummaryFrame().refresh();
}
private void setMaxCardinalityBox(){
this.maxCardinalityBox.removeAll();
for(int i = 1;i <= rt.getArity();i ++){
final int index = i;
LinkedList maxCard = rt.getAxiomSchemata("toocom.ocgl.RelationMaxCardinality");
RelationMaxCardinality mc = null;
for(Iterator j = maxCard.iterator();j.hasNext() && (mc == null);){
RelationMaxCardinality mcTemp = (RelationMaxCardinality) j.next();
if(mcTemp.getIndex() == index) mc = mcTemp;
}
final SpinnerNumberModel snm;
if(mc != null) snm = new SpinnerNumberModel(mc.getValue(),CGConstants.RELATION_TYPE_MIN_CARDINALITY,CGConstants.RELATION_TYPE_MAX_CARDINALITY,1);
else snm = new SpinnerNumberModel(0,CGConstants.RELATION_TYPE_MIN_CARDINALITY,CGConstants.RELATION_TYPE_MAX_CARDINALITY,1);
JSpinner spin = new JSpinner(snm);
spin.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
setMaxCardinality(index,(JSpinner) e.getSource());
}
});
this.maxCardinalityBox.add(spin);
}
}
public void setMaxCardinality(int index,JSpinner js){
SpinnerNumberModel snm = (SpinnerNumberModel) js.getModel();
int value = snm.getNumber().intValue();
LinkedList maxCard = rt.getAxiomSchemata("toocom.ocgl.RelationMaxCardinality");
RelationMaxCardinality mc = null;
for(Iterator j = maxCard.iterator();j.hasNext() && (mc == null);){
RelationMaxCardinality mcTemp = (RelationMaxCardinality) j.next();
if(mcTemp.getIndex() == index) mc = mcTemp;
}
if(value != 0){
if((mc != null) && (value != mc.getValue())){
rt.removeAxiomSchemata("toocom.ocgl.RelationMaxCardinality");
new RelationMaxCardinality(rt,index,value);
}
if(mc == null) new RelationMaxCardinality(rt,index,value);
}
else{
if(mc != null) rt.removeAxiomSchemata("toocom.ocgl.RelationMaxCardinality");
}
mf.getOntologySummaryFrame().refresh();
}
public void setArity(){
int arity = ((SpinnerNumberModel) aritySpinner.getModel()).getNumber().intValue();
if(rt.getArity() != arity){
rt.setArity(arity);
exRelTypes = NamedObject.sortListByName(RelationExclusivity.getLinkablePrimitives(mf.getOntology().getRelationTypes(),rt),mf.getOntologyLanguage());
this.setSignatureBox();
this.setMinCardinalityBox();
this.setMaxCardinalityBox();
this.setIncompatibility();
this.setExclusivity();
rt.removeAllAxiomSchemata();
this.setProperties();
mf.getOntologySummaryFrame().refresh();
this.pack();
this.validate();
this.repaint();
}
}
public void setSignature(){
int cpt = 1;
for(Iterator i = sign.iterator();i.hasNext();){
int selectedIndex = ((JComboBox) i.next()).getSelectedIndex();
if(selectedIndex == 0) rt.getSignature().setConceptType(null,cpt);
else rt.getSignature().setConceptType((ConceptType) ctList[selectedIndex - 1],cpt);
cpt ++;
}
exRelTypes = NamedObject.sortListByName(RelationExclusivity.getLinkablePrimitives(mf.getOntology().getRelationTypes(),rt),mf.getOntologyLanguage());
this.setIncompatibility();
this.setExclusivity();
rt.updateAxiomSchemata();
mf.getOntologySummaryFrame().refresh();
this.setProperties();
this.setMinCardinalityBox();
this.setMaxCardinalityBox();
this.pack();
this.validate();
this.repaint();
}
private void setIncompatibility(){
((DefaultListModel) incompatibilityList.getModel()).clear();
int cpt = 0;
for(Iterator i = exRelTypes.iterator();i.hasNext();cpt ++){
RelationType rTemp = (RelationType) i.next();
((DefaultListModel) incompatibilityList.getModel()).addElement(rTemp.toString(mf.getOntologyLanguage()));
if(rt.hasAxiomSchemaTwo("toocom.ocgl.RelationIncompatibility",rTemp)) incompatibilityList.setSelectedIndex(cpt);
}
}
private void setExclusive(){
rt.removeAxiomSchemata("toocom.ocgl.RelationExclusivity");
if(exclusivityList.getSelectedIndex() > 0) new RelationExclusivity(rt,(RelationType) exRelTypes.get(exclusivityList.getSelectedIndex() - 1));
}
private void setExclusivity(){
int cpt2 = 1;
exclusivityList.removeAllItems();
exclusivityList.addItem(Constants.NO_EXCLUSIVITY_LABEL);
for(Iterator i = exRelTypes.iterator();i.hasNext();cpt2 ++){
RelationType rt2 = (RelationType) i.next();
exclusivityList.addItem(rt2.toString(mf.getOntologyLanguage()));
ConceptualPrimitive cp = (ConceptualPrimitive) rt.getLinkedPrimitives("toocom.ocgl.RelationExclusivity").getFirst();
if((cp != null) && cp.equals(rt2))
exclusivityList.setSelectedIndex(cpt2);
}
}
private void setProperties(){
if(rt.hasAxiomSchema("toocom.ocgl.RelationSymmetry")) ((JCheckBox) propBox.get(0)).setSelected(true);
else ((JCheckBox) propBox.get(0)).setSelected(false);
if(rt.hasAxiomSchema("toocom.ocgl.RelationReflexivity")) ((JCheckBox) propBox.get(1)).setSelected(true);
else ((JCheckBox) propBox.get(1)).setSelected(false);
if(rt.hasAxiomSchema("toocom.ocgl.RelationTransitivity")) ((JCheckBox) propBox.get(2)).setSelected(true);
else ((JCheckBox) propBox.get(2)).setSelected(false);
if(rt.hasAxiomSchema("toocom.ocgl.RelationIrreflexivity")) ((JCheckBox) propBox.get(3)).setSelected(true);
else ((JCheckBox) propBox.get(3)).setSelected(false);
if(rt.hasAxiomSchema("toocom.ocgl.RelationAntisymmetry")) ((JCheckBox) propBox.get(4)).setSelected(true);
else ((JCheckBox) propBox.get(4)).setSelected(false);
}
public void setProperty(String axiomSchemaClassName){
JCheckBox cb = null;
if(axiomSchemaClassName.equals("toocom.ocgl.RelationSymmetry")) cb = (JCheckBox) propBox.get(0);
if(axiomSchemaClassName.equals("toocom.ocgl.RelationReflexivity")) cb = (JCheckBox) propBox.get(1);
if(axiomSchemaClassName.equals("toocom.ocgl.RelationTransitivity")) cb = (JCheckBox) propBox.get(2);
if(axiomSchemaClassName.equals("toocom.ocgl.RelationIrreflexivity")) cb = (JCheckBox) propBox.get(3);
if(axiomSchemaClassName.equals("toocom.ocgl.RelationAntisymmetry")) cb = (JCheckBox) propBox.get(4);
LinkedList axScList = rt.getAxiomSchemata(axiomSchemaClassName);
if(cb.isSelected() && (axScList.size() == 0)){
try{
Class.forName(axiomSchemaClassName).getConstructors()[0].newInstance(rt);
}
catch(Exception e){}
mf.getOntologySummaryFrame().refresh();
}
if(!cb.isSelected() && (axScList.size() == 0)){
rt.removeAxiomSchemata(axiomSchemaClassName);
mf.getOntologySummaryFrame().refresh();
}
}
public void setValues(){
Language l = (Language) languageMenu.getSelectedItem();
String term = termTextField.getText();
if(CGConstants.getDifferentTerms().getTerm(l).compareToIgnoreCase(term) == 0){
JOptionPane.showMessageDialog(mf,Constants.DIFFERENCE_LABEL_NOT_AUTHORIZED);
}
else{
rt.setTerm(term,l);
rt.removeAxiomSchemata("toocom.ocgl.RelationExclusivity");
if(exclusivityList.getSelectedIndex() > 0) new RelationExclusivity(rt,(RelationType) exRelTypes.get(exclusivityList.getSelectedIndex() - 1));
int[] indices = incompatibilityList.getSelectedIndices();
rt.removeAxiomSchemata("toocom.ocgl.RelationIncompatibility");
for(int cpt = 0;cpt < indices.length;cpt ++){
new RelationIncompatibility(rt,(RelationType) exRelTypes.get(indices[cpt]));
}
mf.getOntologySummaryFrame().refresh();
mf.repaint();
this.dispose();
}
}
public void setLanguage(){
rt.setTerm(termTextField.getText(),currentLanguage);
currentLanguage = (Language) languageMenu.getSelectedItem();
termTextField.setText(rt.getTerm(currentLanguage));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -