43,48d42 < * If an internal frame gets activated, the StandardDrawingView is backed < * up for later restorage. < */ < private DrawingView backupDrawingView; < < /** 86a81,92 > * Creates the tools. By default only the selection tool is added. > * Override this method to add additional tools. > * Call the inherited method to include the selection tool. > * @param palette the palette where the tools are added. > */ > protected void createTools(JToolBar palette) { > super.createTools(palette); > Tool tool = new DragNDropTool( this ); > ToolButton tb = createToolButton(IMAGES+"SEL", "Drag N Drop Tool", tool); > palette.add( tb ); > } > /** 92a98,98 > if (view.isInteractive()) { 93,93c99,99 < MDI_InternalFrame internalFrame = createInternalFrame(); --- > MDI_InternalFrame internalFrame = createInternalFrame(view); 94,95d99 < internalFrame.setDrawingView(view); < internalFrame.setSize(200, 200); 96a120,123 > protected MDI_InternalFrame createInternalFrame(DrawingView view) { > String applicationTitle = null; > if ((view == null) || (view.drawing() == null) || (view.drawing().getTitle() == null)) { > applicationTitle = getApplicationName() + " - " + getDefaultDrawingTitle(); 97,99d119 < if (currentFrame == null) { < currentFrame = internalFrame; < backupDrawingView = createDrawingView(); 100a125,130 > else { > applicationTitle = getApplicationName() + " - " + view.drawing().getTitle(); > } > MDI_InternalFrame internalFrame = new MDI_InternalFrame(applicationTitle, true, true, true, true); > internalFrame.setDrawingView(view); > internalFrame.setSize(200, 200); 100,100c124,124 < } --- > } 101,101c131,131 < --- > 102,102c132,132 < // all registered listeners to the new internal frame --- > // all registered listeners to the new internal frame 103,103c133,133 < Enumeration enum = mdiListeners.elements(); --- > Enumeration enum = mdiListeners.elements(); 104,104c134,134 < while (enum.hasMoreElements()) { --- > while (enum.hasMoreElements()) { 105,105c135,135 < internalFrame.addInternalFrameListener((InternalFrameListener)enum.nextElement()); --- > internalFrame.addInternalFrameListener((InternalFrameListener)enum.nextElement()); 106,106c136,136 < } --- > } 107,107c137,137 < --- > 107a138,141 > fireViewCreatedEvent(view); // frame now has connection all the way to heavyweight component > > // return container in which the internal frame is embedded > return internalFrame; 108a103,103 > internalFrame.setVisible(true); //unsafe to set visible here since the desktopPane has not been added to desktop yet (and has no peer I don't believe) 114a110,110 > } 115,115d109 < internalFrame.setVisible(true); 117a113,113 > 124,125d119 < protected MDI_InternalFrame createInternalFrame() { < return new MDI_InternalFrame("untitled", true, true, true, true); 136a153,153 > newWindow(createDrawing()); 137,137d152 < newWindow(); 145,145c161,161 < public void newWindow() { --- > public void newWindow(Drawing newDrawing) { 147,147d162 < Drawing newDrawing = createDrawing(); 152a168,172 > /* protected DrawingView createDrawingView() { > Dimension d = getDrawingViewSize(); > return new StandardDrawingView(this, d.width, d.height); > } > */ 153a174,181 > if (!view().isInteractive()) { > return; > } > String copyTitle = view().drawing().getTitle(); > DrawingView fView = createDrawingView(); > fView.setDrawing( view().drawing() ); > createContents(fView); > if(copyTitle != null ) { 154,157d173 < String copyTitle = getDrawingTitle(); < DrawingView newView = createDrawingView(); < newView.setDrawing(drawing()); < createContents(newView); 158a183,186 > } > else { > setDrawingTitle( getDefaultDrawingTitle() + " (View)"); > } 180,180c208,208 < * frame is created, all currently registered InternalFrameListeners are added. --- > * frame is created, all currently registered InternalFrameListeners are 180a209,209 > * added as listeners to that internal frame as well. 206a236,237 > if(currentFrame != null ) > { 207,209d235 < backupDrawingView.setDrawing(view().drawing()); < currentFrame.replaceDrawingView(backupDrawingView); < currentFrame.validate(); 210a239,240 > currentFrame.getDrawingView().clearSelection(); > } 211,212d238 < setDrawing(newFrame.getDrawingView().drawing()); < backupDrawingView = newFrame.replaceDrawingView(view()); 214a243,252 > setView( currentFrame.getDrawingView() ); > } > /** > * If the frame we are deactivating is the current frame, set the > * currentFrame to null > */ > public void deactivateFrame(MDI_InternalFrame frame) { > if( currentFrame == frame ) { > currentFrame = null; > } 236a275,281 > MDI_InternalFrame mdf = (MDI_InternalFrame)e.getSource(); > DrawingView dv = mdf.getDrawingView(); > fireViewDestroyingEvent( dv ); > if( mdf == currentFrame) { > currentFrame = null; > setView(NullDrawingView.getManagedDrawingView(this)); > } 258,258c303,303 < activateFrame((MDI_InternalFrame)e.getSource()); --- > //activateFrame((MDI_InternalFrame)e.getSource()); 265a311,311 > deactivateFrame((MDI_InternalFrame)e.getSource()); 276,276c322,322 < currentFrame.setTitle(newDrawingTitle); --- > currentFrame.setTitle( getApplicationName() + " - " + newDrawingTitle ); 283,283c329,329 < return currentFrame.getTitle(); --- > return currentFrame.getDrawing().getTitle(); 288a335,358 > > /** > * Returns all the views in the application > */ > public DrawingView[] views() { > DrawingView[] views; > ArrayList frames = new ArrayList(); > > JInternalFrame[] ifs = ((JDesktopPane)getDesktop()).getAllFrames(); > for(int x=0; x < ifs.length ; x++) { > /* Can not use class.isInstance() here since DrawingView is an interface */ > /* Can not use instanceof here since DrawingView is interface */ > if( MDI_InternalFrame.class.isInstance( ifs[x] ) ) { > DrawingView dv = ((MDI_InternalFrame)ifs[x]).getDrawingView(); > if( DrawingView.class.isInstance( dv ) ) { > frames.add( dv ); > } > } > } > views = new DrawingView[ frames.size() ]; > frames.toArray( views ); > > return views; > }