47a48 > private DrawingView fView; 51c52 < private static String fApplicationName; --- > private String fApplicationName; 54c55 < private String fgUntitled = "untitled"; --- > protected static String fgUntitled = "untitled"; 116,117c117 < DrawingView dv = getDesktop().getActiveDrawingView(); < if (dv == null || !dv.isInteractive()) {//this should be ASSERT and otherwise handled by context sensitive menus. --- > if (view() == null) { 121,125c121,123 < window.open(); < window.newWindow( dv.drawing() ); < < /* if (dv.drawing().getTitle() != null ) { < window.setDrawingTitle(dv.drawing().getTitle() + " (View)"); --- > window.open(view()); > if (view().drawing().getTitle() != null ) { > window.setDrawingTitle(view().drawing().getTitle() + " (View)"); 129c127 < }*/ --- > } 136,139c134,140 < public void newWindow(Drawing newDrawing) { < getDesktop().removeAllFromDesktop(Desktop.PRIMARY); < getDesktop().addToDesktop( createDrawingView( newDrawing ), Desktop.PRIMARY); < toolDone(); --- > public void newWindow(Drawing initialDrawing) { > DrawApplication window = createApplication(); > if (initialDrawing == null) { > window.open(); > } > else { > window.open(window.createDrawingView(initialDrawing)); 141,142d141 < public final void newWindow() { < newWindow( createDrawing() ); 143a143,150 > > /** > * Opens a new window > */ > public void open() { > open(createInitialDrawingView()); > } > 147c154 < public synchronized void open() { --- > protected synchronized void open(DrawingView newDrawingView) { 157,161d163 < //Initialize Desktop, must be done before tools < setDesktopListener(createDesktopListener()); < setDesktop(createDesktop()); < < //Initialize Tools 163d164 < //why do we need a dummy tool? 164a166,167 > setView(newDrawingView); > 172a176,177 > setDesktopListener(createDesktopListener()); > setDesktop(createDesktop()); 176,178d180 < < < //Initialize Menus 192d193 < 193a195,198 > if (newDrawingView.isInteractive()) { > getDesktop().addToDesktop(newDrawingView , Desktop.PRIMARY); > } > toolDone(); 335c340 < getDesktop().getActiveDrawingView().setDisplayUpdate(new SimpleUpdateStrategy()); --- > this.view().setDisplayUpdate(new SimpleUpdateStrategy()); 342c347 < getDesktop().getActiveDrawingView().setDisplayUpdate(new BufferedUpdateStrategy()); --- > this.view().setDisplayUpdate(new BufferedUpdateStrategy()); 536,538d540 < * Made this final so no one indavertently overrides it. If you need to < * override, override createDrawingView(Drawing newDrawing) below. < * dnoyeb@users.sourceforge.net 540,541c542,545 < protected final DrawingView createDrawingView() { < return createDrawingView( createDrawing() ); --- > protected DrawingView createDrawingView() { > DrawingView createdDrawingView = createDrawingView(createDrawing()); > createdDrawingView.drawing().setTitle(getDefaultDrawingTitle()); > return createdDrawingView; 546c550,551 < DrawingView newDrawingView = new StandardDrawingView(newDrawing, this, d.width, d.height); --- > DrawingView newDrawingView = new StandardDrawingView(this, d.width, d.height); > newDrawingView.setDrawing(newDrawing); 580,582c585 < Drawing dwg = new StandardDrawing(); < dwg.setTitle( getDefaultDrawingTitle() ); < return dwg; --- > return new StandardDrawing(); 586c589 < return new JPanelDesktop(); --- > return new JPanelDesktop(this); 696c699 < return getDesktop().getActiveDrawingView(); --- > return fView; 699c702 < /* protected void setView(DrawingView newView) { --- > protected void setView(DrawingView newView) { 703c706 < }*/ --- > } 706c709 < return new DrawingView[] { getDesktop().getActiveDrawingView() }; --- > return new DrawingView[] { view() }; 869c872,874 < newWindow( ); --- > newWindow(createDrawing()); > //toolDone(); > //view().setDrawing(createDrawing()); 894c899 < if (getDesktop().getActiveDrawingView() != null) { --- > if (view() != null) { 942c947 < ((StandardDrawingView)getDesktop().getActiveDrawingView()).printAll(pg); --- > ((StandardDrawingView)view()).printAll(pg); 955,956c960,962 < DrawingView dv = getDesktop().getActiveDrawingView(); < if (dv != null && dv.isInteractive() ) { --- > if (view() == null) { > return; > } 958,960c964,966 < String name = storeFormat.store(file, dv.drawing()); < dv.drawing().setTitle(name); < updateApplicationTitle(); --- > String name = storeFormat.store(file, view().drawing()); > view().drawing().setTitle(name); > setDrawingTitle(name); 966d971 < } 1003,1009c1008,1010 < protected void updateApplicationTitle() { < DrawingView dv = getDesktop().getActiveDrawingView(); < if(dv != null && dv.isInteractive()){ //mrfloppy, we can do away with null check and ASSERT once their is always at least a NullDrawingView < String drawingTitle = dv.drawing().getTitle(); < if (!getDefaultDrawingTitle().equals(drawingTitle)) { < setTitle(getApplicationName() + " - " + drawingTitle); < } --- > protected void setDrawingTitle(String drawingTitle) { > if (getDefaultDrawingTitle().equals(drawingTitle)) { > setTitle(getApplicationName()); 1012c1013,1014 < setTitle(getApplicationName()); --- > setTitle(getApplicationName() + " - " + drawingTitle); > } 1013a1016,1021 > > /** > * Return the title of the currently selected drawing > */ > protected String getDrawingTitle() { > return view().drawing().getTitle(); 1026c1034 < public static String getApplicationName() { --- > public String getApplicationName() { 1057,1063c1065 < /** < * I made this protected because it should only be used by the DrawApplication. < * This is because all created drawings will be created through createDrawing() < * which is a method of DrawApplication. < * dnoyeb@users.sourceforge.net 12/31/02 < */ < protected String getDefaultDrawingTitle() { --- > public String getDefaultDrawingTitle() { 1085c1087 < public void drawingViewSelected(DrawingView oldView, DesktopEvent dpe) { --- > public void drawingViewSelected(DesktopEvent dpe) { 1092,1093c1094 < fireViewSelectionChangedEvent(oldView, getDesktop().getActiveDrawingView()); < updateApplicationTitle(); --- > setView(dv);