//This file is part of SECONDO. //Copyright (C) 2004, University in Hagen, Department of Computer Science, //Database Systems for New Applications. //SECONDO is free software; you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation; either version 2 of the License, or //(at your option) any later version. //SECONDO is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with SECONDO; if not, write to the Free Software //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package viewer.hoese; import viewer.*; import sj.lang.ListExpr; import javax.swing.*; import java.util.Vector; import java.awt.*; import javax.swing.event.*; import java.awt.event.*; import javax.swing.table.*; import tools.Reporter; public class LinkAttrCat extends JDialog{ /** Construct a new Dialog for assigning * categories to given values **/ public LinkAttrCat(HoeseViewer HV){ super(HV.getMainFrame(),true); this.HV = HV; setTitle("link attributes to categorys"); setSize(300,300); getContentPane().setLayout(new BorderLayout()); Tab = new JTable(TM); JScrollPane SP = new JScrollPane(Tab); // Control Panel JPanel P2 = new JPanel(); P2.add(ComboBox); SetBtn = new JButton("set"); P2.add(SetBtn); CatEditBtn = new JButton("category editor"); CatEditBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ new CategoryEditor(LinkAttrCat.this.HV, true).show(); LinkAttrCat.this.HV.GraphDisplay.repaint(); if(LinkAttrCat.this.HV.Cats.size()!= ComboBox.getItemCount()) setCategories(LinkAttrCat.this.HV.Cats); }}); P2.add(CatEditBtn); // Close Btn JPanel P3 = new JPanel(); CloseBtn = new JButton("OK"); CancelBtn = new JButton("Cancel"); P3.add(CloseBtn); P3.add(CancelBtn); // Name Btn JPanel P4 = new JPanel(new GridLayout(1,2)); P4.add(new JLabel("Name :")); NameText = new JTextField(12); P4.add(NameText); JPanel P1 = new JPanel(new BorderLayout()); // combines P2 and SP P1.add(P2,BorderLayout.NORTH); P1.add(SP,BorderLayout.CENTER); getContentPane().add(P4,BorderLayout.NORTH); getContentPane().add(P1,BorderLayout.CENTER); getContentPane().add(P3,BorderLayout.SOUTH); CloseBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ if(NameText.getText().equals("")){ Reporter.showError("Please enter a Name "); return; } if(!UpdateMode){ if(ManualLinkPool.exists(NameText.getText())){ Reporter.showError("the name allready exists \n please chose another one "); return; } TM.getLinks().setName(NameText.getText()); RetValue = OK; LinkAttrCat.this.setVisible(false); } else{ // begin updateMode if(OldName.equals(NameText.getText())){ // no change RetValue=OK; LinkAttrCat.this.setVisible(false); }else{ // Name is changed if(ManualLinkPool.exists(NameText.getText())){ Reporter.showError("the name allready exists \n please chose another one "); return; } TM.getLinks().setName(NameText.getText()); RetValue = OK; LinkAttrCat.this.setVisible(false); } } }}); CancelBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ LinkAttrCat.this.setVisible(false); }}); SetBtn.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt){ setCat(); }}); } public void setName(String N){ NameText.setText(N); TM.getLinks().setName(N); } public void setUpdateMode(boolean on,String OldName){ UpdateMode = on; this.OldName = OldName; } public String getName(){ return TM.getLinks().getName(); } /* set the available categories. all Categories in v are inserted other objects are ignored */ public void setCategories(Vector v){ ComboBox.removeAllItems(); if(v==null) return; Object o; for(int i=0;i