17a18,19 > import CH.ifa.draw.contrib.*; > 22,22d23 < import java.util.*; 55a57,62 > private DesktopListener fDesktopListener; > > /** > * This component acts as a desktop for the content. > */ > private Desktop fDesktop; 140a148,148 > open(createInitialDrawingView()); 141,144d147 < DrawingView initialDrawingView = createInitialDrawingView(); < initialDrawingView.setDrawing(createDrawing()); < initialDrawingView.drawing().setTitle(getDefaultDrawingTitle()); < open(initialDrawingView); 152a157,157 > setIconkit(createIconkit()); 153,153d156 < fIconkit = new Iconkit(this); 163,164d166 < JComponent contents = createContents(view()); < contents.setAlignmentX(LEFT_ALIGNMENT); 173a176,177 > setDesktopListener(createDesktopListener()); > setDesktop(createDesktop()); 174,174c178,178 < activePanel.add(contents, BorderLayout.CENTER); --- > activePanel.add((Component)getDesktop(), BorderLayout.CENTER); 175,175d178 < 191a195,197 > if (newDrawingView.isInteractive()) { > getDesktop().addToDesktop(newDrawingView , Desktop.PRIMARY); > } 191a906,906 > } 192,192d905 < 489a495,495 > setDefaultTool(createDefaultTool()); 490,491d494 < Tool tool = createSelectionTool(); < setDefaultTool(createDefaultToo()); 503,503c507,507 < protected Tool createDefaultToo() { --- > protected Tool createDefaultTool() { 547a552,553 > // notify listeners about created view when the view is added to the desktop > //fireViewCreatedEvent(newDrawingView); 548,548d551 < fireViewCreatedEvent(newDrawingView); 582a588,590 > protected Desktop createDesktop() { > return new JPanelDesktop(this); > // return new JScrollPaneDesktop(); 583,594d587 < /** < * Creates the contents component of the application < * frame. By default the DrawingView is returned in < * a JScrollPane. < */ < protected JComponent createContents(DrawingView view) { < if (view instanceof Component) { < JScrollPane sp = new JScrollPane((Component)view); < sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); < sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); < < return sp; 595a592,595 > > protected void setDesktop(Desktop newDesktop) { > newDesktop.addDesktopListener(getDesktopListener()); > fDesktop = newDesktop; 596,597d591 < else { < return new JPanel(); 598a597,603 > > /** > * Get the component, in which the content is embedded. This component > * acts as a desktop for the content. > */ > public Desktop getDesktop() { > return fDesktop; 610a616,616 > // storageFormatManager.addStorageFormat(new JDOStorageFormat()); 702a709,709 > System.out.println("ToolDone"); 710,710c717,717 < * Fired by a view when the figure seleciton changes. Since Commands and --- > * Fired by a view when the figure selection changes. Since Commands and 711a719,719 > * about these events. 711,711c718,718 < * Tools are Actions they are registered to be notified about these events. --- > * Tools may depend on the figure selection they are registered to be notified 713a722,722 > * will update their own states. 713,713c721,721 < * own state if the selection has changed. --- > * own state if the selection has changed, e.g. selection sensitive menuitems 717a727,732 > > for (int x=0; x < mb.getMenuCount(); x++) { > JMenu jm = mb.getMenu(x); > if (CommandMenu.class.isInstance(jm)) { > checkCommandMenu((CommandMenu)jm); > } 718,735d726 < CommandMenu editMenu = (CommandMenu)mb.getMenu(EDIT_MENU); < // make sure it does exist < if (editMenu != null) { < editMenu.checkEnabled(); < } < CommandMenu alignmentMenu = (CommandMenu)mb.getMenu(ALIGNMENT_MENU); < // make sure it does exist < if (alignmentMenu != null) { < alignmentMenu.checkEnabled(); < } < < JMenu attributeMenu = mb.getMenu(ATTRIBUTES_MENU); < // make sure it does exist < if (attributeMenu != null) { < for (int i = 0; i < attributeMenu.getItemCount(); i++) { < JMenuItem currentMenu = attributeMenu.getItem(i); < if (currentMenu instanceof CommandMenu) { < ((CommandMenu)currentMenu).checkEnabled(); 737a735,742 > > protected void checkCommandMenu(CommandMenu cm) { > cm.checkEnabled(); > for(int y=0;y < cm.getItemCount();y++){ > JMenuItem jmi = cm.getItem(y); > if(CommandMenu.class.isInstance(jmi)){ > checkCommandMenu((CommandMenu)jmi); > } 802a808,815 > /** > * Note: it is inconsistent to directly assign a variable but when using it > * use it from a method. (assignment: fTool = t, usage: tool()) dnoyeB-4/8/02 > * Note: should we check that the tool is inactive before we activate it? > * this would be consistent with how we do deactivate. I think we should do > * this now and not wait till a bug pops up. even if their is no bug, its > * consistent and adds understandability to the code. dnoyeB-4/8/02 > */ 850a864,865 > newWindow(createDrawing()); > //toolDone(); 851,851d863 < toolDone(); 852,852c866,866 < view().setDrawing(createDrawing()); --- > //view().setDrawing(createDrawing()); 853,853d866 < view().drawing().setTitle(getDefaultDrawingTitle()); 877a891,891 > if (view() != null) { 962a978,978 > } 963,963c979,979 < } catch (IOException e) { --- > catch (IOException e) { 1041,1041c1057,1057 < protected String getDefaultDrawingTitle() { --- > public String getDefaultDrawingTitle() { 1043a1060,1101 > > protected DesktopListener getDesktopListener() { > return fDesktopListener; > } > > protected void setDesktopListener(DesktopListener desktopPaneListener) { > fDesktopListener = desktopPaneListener; > } > > protected DesktopListener createDesktopListener() { > return new DesktopListener() { > public void drawingViewAdded(DesktopEvent dpe) { > DrawingView dv = dpe.getDrawingView(); > fireViewCreatedEvent(dv); > } > public void drawingViewRemoved(DesktopEvent dpe) { > DrawingView dv = dpe.getDrawingView(); > fireViewDestroyingEvent(dv); > } > public void drawingViewSelected(DesktopEvent dpe) { > DrawingView dv = dpe.getDrawingView(); > //get the current selection and freeze it. > if (dv != null) { > if (dv.drawing() != null) > dv.unfreezeView(); > } > setView(dv); > } > }; > } > > protected Iconkit createIconkit() { > return new Iconkit(this); > } > > private void setIconkit(Iconkit newIconkit) { > fIconkit = newIconkit; > } > > protected Iconkit getIconkit() { > return fIconkit; > }