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 ); > } > /** 91a98,99 > if (view.isInteractive()) { > MDI_InternalFrame internalFrame = createInternalFrame(view); 93,95d100 < MDI_InternalFrame internalFrame = createInternalFrame(); < internalFrame.setDrawingView(view); < internalFrame.setSize(200, 200); 97,107d101 < if (currentFrame == null) { < currentFrame = internalFrame; < backupDrawingView = createDrawingView(); < } < < // all registered listeners to the new internal frame < Enumeration enum = mdiListeners.elements(); < while (enum.hasMoreElements()) { < internalFrame.addInternalFrameListener((InternalFrameListener)enum.nextElement()); < } < 108a103 > 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) 115c110 < internalFrame.setVisible(true); --- > } 117a113 > 124,125c120,141 < protected MDI_InternalFrame createInternalFrame() { < return new MDI_InternalFrame("untitled", true, true, true, true); --- > protected MDI_InternalFrame createInternalFrame(DrawingView view) { > String applicationTitle = null; > if ((view == null) || (view.drawing() == null) || (view.drawing().getTitle() == null)) { > applicationTitle = getApplicationName() + " - " + getDefaultDrawingTitle(); > } > else { > applicationTitle = getApplicationName() + " - " + view.drawing().getTitle(); > } > MDI_InternalFrame internalFrame = new MDI_InternalFrame(applicationTitle, true, true, true, true); > internalFrame.setDrawingView(view); > internalFrame.setSize(200, 200); > > // all registered listeners to the new internal frame > Enumeration enum = mdiListeners.elements(); > while (enum.hasMoreElements()) { > internalFrame.addInternalFrameListener((InternalFrameListener)enum.nextElement()); > } > > fireViewCreatedEvent(view); // frame now has connection all the way to heavyweight component > > // return container in which the internal frame is embedded > return internalFrame; 137c153 < newWindow(); --- > newWindow(createDrawing()); 145c161 < public void newWindow() { --- > public void newWindow(Drawing newDrawing) { 147d162 < Drawing newDrawing = createDrawing(); 152a168,172 > /* protected DrawingView createDrawingView() { > Dimension d = getDrawingViewSize(); > return new StandardDrawingView(this, d.width, d.height); > } > */ 154,157c174,181 < String copyTitle = getDrawingTitle(); < DrawingView newView = createDrawingView(); < newView.setDrawing(drawing()); < createContents(newView); --- > if (!view().isInteractive()) { > return; > } > String copyTitle = view().drawing().getTitle(); > DrawingView fView = createDrawingView(); > fView.setDrawing( view().drawing() ); > createContents(fView); > if(copyTitle != null ) { 158a183,186 > } > else { > setDrawingTitle( getDefaultDrawingTitle() + " (View)"); > } 180c208,209 < * frame is created, all currently registered InternalFrameListeners are added. --- > * frame is created, all currently registered InternalFrameListeners are > * added as listeners to that internal frame as well. 207,209c236,237 < backupDrawingView.setDrawing(view().drawing()); < currentFrame.replaceDrawingView(backupDrawingView); < currentFrame.validate(); --- > if(currentFrame != null ) > { 211,212c239,240 < setDrawing(newFrame.getDrawingView().drawing()); < backupDrawingView = newFrame.replaceDrawingView(view()); --- > currentFrame.getDrawingView().clearSelection(); > } 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)); > } 258c303 < activateFrame((MDI_InternalFrame)e.getSource()); --- > //activateFrame((MDI_InternalFrame)e.getSource()); 265a311 > deactivateFrame((MDI_InternalFrame)e.getSource()); 276c322 < currentFrame.setTitle(newDrawingTitle); --- > currentFrame.setTitle( getApplicationName() + " - " + newDrawingTitle ); 283c329 < 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; > }