17a18,19 > import CH.ifa.draw.contrib.*; > 22d23 < import java.util.*; 55a57,62 > private DesktopListener fDesktopListener; > > /** > * This component acts as a desktop for the content. > */ > private Desktop fDesktop; 141,144c148 < DrawingView initialDrawingView = createInitialDrawingView(); < initialDrawingView.setDrawing(createDrawing()); < initialDrawingView.drawing().setTitle(getDefaultDrawingTitle()); < open(initialDrawingView); --- > open(createInitialDrawingView()); 153c157 < fIconkit = new Iconkit(this); --- > setIconkit(createIconkit()); 163,164d166 < JComponent contents = createContents(view()); < contents.setAlignmentX(LEFT_ALIGNMENT); 174,175c176,178 < activePanel.add(contents, BorderLayout.CENTER); < --- > setDesktopListener(createDesktopListener()); > setDesktop(createDesktop()); > activePanel.add((Component)getDesktop(), BorderLayout.CENTER); 192c195,197 < --- > if (newDrawingView.isInteractive()) { > getDesktop().addToDesktop(newDrawingView , Desktop.PRIMARY); > } 490,491c495 < Tool tool = createSelectionTool(); < setDefaultTool(createDefaultToo()); --- > setDefaultTool(createDefaultTool()); 503c507 < protected Tool createDefaultToo() { --- > protected Tool createDefaultTool() { 548c552,553 < fireViewCreatedEvent(newDrawingView); --- > // notify listeners about created view when the view is added to the desktop > //fireViewCreatedEvent(newDrawingView); 583,594c588,590 < /** < * 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; --- > protected Desktop createDesktop() { > return new JPanelDesktop(this); > // return new JScrollPaneDesktop(); 596,597c592,595 < else { < return new JPanel(); --- > > protected void setDesktop(Desktop newDesktop) { > newDesktop.addDesktopListener(getDesktopListener()); > fDesktop = newDesktop; 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 > // storageFormatManager.addStorageFormat(new JDOStorageFormat()); 702a709 > System.out.println("ToolDone"); 710,711c717,719 < * Fired by a view when the figure seleciton changes. Since Commands and < * Tools are Actions they are registered to be notified about these events. --- > * Fired by a view when the figure selection changes. Since Commands and > * Tools may depend on the figure selection they are registered to be notified > * about these events. 713c721,722 < * own state if the selection has changed. --- > * own state if the selection has changed, e.g. selection sensitive menuitems > * will update their own states. 718,735c727,732 < 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(); --- > > for (int x=0; x < mb.getMenuCount(); x++) { > JMenu jm = mb.getMenu(x); > if (CommandMenu.class.isInstance(jm)) { > checkCommandMenu((CommandMenu)jm); > } 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 > */ 851,853c864,866 < toolDone(); < view().setDrawing(createDrawing()); < view().drawing().setTitle(getDefaultDrawingTitle()); --- > newWindow(createDrawing()); > //toolDone(); > //view().setDrawing(createDrawing()); 877a891 > if (view() != null) { 891a906 > } 963c978,979 < } catch (IOException e) { --- > } > catch (IOException e) { 1041c1057 < 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; > }