// File: Editor.java // Classes: Editor // Original Author: Kedar Patankar // Date 15 Jan 1997 // package uci.graphedit; import java.util.Vector; import java.util.Hashtable; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Panel; import java.awt.CardLayout; import java.awt.Scrollbar; public class CdPanel extends Panel { private UmlPalette _palette; private Editor _editor; private Panel _documentPanel; private Scrollpanel _documentScrollpanel; private int _documentCount; private int _noOfDocuments; private Vector _documentNames; private Vector _outStanding; private Hashtable _documentTable; private Document _document; private CardLayout _cardLayout; public Vector get_outStanding(){return _outStanding;} public void addInOutstanding(String s) { if(_outStanding.contains(s)) return; else _outStanding.addElement(s); } public void removeFromOutstanding(String s) { if(!_outStanding.contains(s)) return; else _outStanding.removeElement(s); } public int getNoOfOpenDocuments(){ return _noOfDocuments;} public void updateDocname(String previousName,String presentName) { Document d=(Document)_documentTable.remove(previousName); _documentNames.removeElement(previousName); _documentPanel.remove(d); get_outStanding().removeElement(previousName); d.setDocName(presentName); _documentPanel.add(presentName,d); _documentNames.addElement(presentName); _documentTable.put(presentName,d); } public boolean isPresent(String s) { Object o=_documentTable.get(s); if(o==null) return false; else return true; } public void showDocument(String s) { _document=(Document)_documentTable.get(s); System.out.println("showDocument XY"); System.out.println( _document.size().width ); System.out.println( _document.size().height ); _cardLayout.show(_documentPanel,s); show(); _document.setCursorType(_editor); } public Document getDocument(String s){return (Document)_documentTable.get(s);} public void attach(String name,Document d) { _documentPanel.add(name,d); _documentNames.addElement(name); _documentTable.put(name,d); _noOfDocuments +=1; _document=d; _document.resize(2000, 2000); System.out.println("Attach XY"); System.out.println( _document.size().width ); System.out.println( _document.size().height ); _cardLayout.show(_documentPanel,name); show(); } public String detach(String name,Document d) { _documentPanel.remove(d); _documentTable.remove(name); _documentNames.removeElement(name); _noOfDocuments -=1; get_outStanding().removeElement(name); if(_noOfDocuments>=1) { String title=(String)_documentNames.elementAt(0); _document=(Document)_documentTable.get(title); System.out.println("detach XY"); System.out.println( _document.size().width ); System.out.println( _document.size().height ); _cardLayout.show(_documentPanel,title); return title; } else { _document=null; return null; } } public int nextDocumentNumber() { _documentCount +=1; return _documentCount; } public void refresh() { _palette.refresh(); } /** Construct a new Editor to edit the given NetList */ public CdPanel(Editor editor) { _editor=editor; setLayout(new BorderLayout()); _documentScrollpanel = new Scrollpanel(); _documentPanel = _documentScrollpanel.panel; _cardLayout=new CardLayout(); _documentPanel.setLayout(_cardLayout); add("Center",_documentScrollpanel); _palette=new UmlPalette(_editor); _palette.setBackground(Color.gray); add("West",_palette); _documentNames=new Vector(); _outStanding=new Vector(); _documentTable=new Hashtable(); _documentCount=0; _noOfDocuments=0; System.out.println("DocumentScrollPanel XY"); System.out.println( _documentScrollpanel.size().width ); System.out.println( _documentScrollpanel.size().height ); System.out.println("DocumentPanel"); System.out.println( _documentPanel.size().width); System.out.println( _documentPanel.size().height ); } public Document curDocument(){ return _document;} }/* end class Editor */