2c2 < * @(#)DrawApplication.java 5.2 --- > * @(#)DrawApplication.java 3a4,9 > * Project: JHotdraw - a GUI framework for technical drawings > * http://www.jhotdraw.org > * http://jhotdraw.sourceforge.net > * Copyright: © by the original author(s) and all contributors > * License: Lesser GNU Public License (LGPL) > * http://www.opensource.org/licenses/lgpl-license.html 19,21c25,26 < * DrawApplication defines a standard presentation for < * standalone drawing editors. The presentation is < * customized in subclasses. --- > * DrawApplication defines a standard presentation for standalone drawing > * editors. The presentation is customized in subclasses. 28a34,35 > * > * @version <$CURRENT_VERSION$> 30d36 < 40c46 < private StandardDrawingView fView; --- > private DrawingView fView; 75c81 < super("JHotDraw"); --- > this("JHotDraw"); 123,125d128 < // Panel in which a JToolBar can be placed using a BoxLayout < JPanel fullPanel = new JPanel(); < fullPanel.setLayout(new BoxLayout(fullPanel, BoxLayout.X_AXIS)); 132a136 > 140,141d143 < fullPanel.add(activePanel); < 143c145 < getContentPane().add(fullPanel, BorderLayout.CENTER); --- > getContentPane().add(activePanel, BorderLayout.CENTER); 189,193c191,201 < mb.add(createFileMenu()); < mb.add(createEditMenu()); < mb.add(createAlignmentMenu()); < mb.add(createAttributesMenu()); < mb.add(createDebugMenu()); --- > addMenuIfPossible(mb, createFileMenu()); > addMenuIfPossible(mb, createEditMenu()); > addMenuIfPossible(mb, createAlignmentMenu()); > addMenuIfPossible(mb, createAttributesMenu()); > addMenuIfPossible(mb, createDebugMenu()); > } > > protected void addMenuIfPossible(JMenuBar mb, JMenu newMenu) { > if (newMenu != null) { > mb.add(newMenu); > } 261c269,273 < menu.add(new CutCommand("Cut", view()), new MenuShortcut('x')); --- > menu.add(new UndoableCommand( > new SelectAllCommand("Select All", view())), new MenuShortcut('a')); > menu.addSeparator(); > menu.add(new UndoableCommand( > new CutCommand("Cut", view())), new MenuShortcut('x')); 263c275,280 < menu.add(new PasteCommand("Paste", view()), new MenuShortcut('v')); --- > menu.add(new UndoableCommand( > new PasteCommand("Paste", view())), new MenuShortcut('v')); > menu.addSeparator(); > menu.add(new UndoableCommand( > new DuplicateCommand("Duplicate", view())), new MenuShortcut('d')); > menu.add(new UndoableCommand(new DeleteCommand("Delete", view()))); 265,266c282,283 < menu.add(new DuplicateCommand("Duplicate", view()), new MenuShortcut('d')); < menu.add(new DeleteCommand("Delete", view())); --- > menu.add(new UndoableCommand(new GroupCommand("Group", view()))); > menu.add(new UndoableCommand(new UngroupCommand("Ungroup", view()))); 268,269c285,286 < menu.add(new GroupCommand("Group", view())); < menu.add(new UngroupCommand("Ungroup", view())); --- > menu.add(new UndoableCommand(new SendToBackCommand("Send to Back", view()))); > menu.add(new UndoableCommand(new BringToFrontCommand("Bring to Front", view()))); 271,272c288,289 < menu.add(new SendToBackCommand("Send to Back", view())); < menu.add(new BringToFrontCommand("Bring to Front", view())); --- > menu.add(new UndoCommand("Undo Command", view())); > menu.add(new RedoCommand("Redo Command", view())); 282c299 < menu.add(new ToggleGridCommand("Toggle Snap to Grid", view(), new Point(4,4))); --- > menu.addCheckItem(new ToggleGridCommand("Toggle Snap to Grid", view(), new Point(4,4))); 284,286c301,306 < menu.add(new AlignCommand("Lefts", view(), AlignCommand.LEFTS)); < menu.add(new AlignCommand("Centers", view(), AlignCommand.CENTERS)); < menu.add(new AlignCommand("Rights", view(), AlignCommand.RIGHTS)); --- > menu.add(new UndoableCommand( > new AlignCommand(AlignCommand.Alignment.LEFTS, view()))); > menu.add(new UndoableCommand( > new AlignCommand(AlignCommand.Alignment.CENTERS, view()))); > menu.add(new UndoableCommand( > new AlignCommand(AlignCommand.Alignment.RIGHTS, view()))); 288,290c308,313 < menu.add(new AlignCommand("Tops", view(), AlignCommand.TOPS)); < menu.add(new AlignCommand("Middles", view(), AlignCommand.MIDDLES)); < menu.add(new AlignCommand("Bottoms", view(), AlignCommand.BOTTOMS)); --- > menu.add(new UndoableCommand( > new AlignCommand(AlignCommand.Alignment.TOPS, view()))); > menu.add(new UndoableCommand( > new AlignCommand(AlignCommand.Alignment.MIDDLES, view()))); > menu.add(new UndoableCommand( > new AlignCommand(AlignCommand.Alignment.BOTTOMS, view()))); 346a370 > new UndoableCommand( 352a377 > ) 362,365c387,394 < menu.add(new ChangeAttributeCommand("none", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_NONE), view())); < menu.add(new ChangeAttributeCommand("at Start", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_START), view())); < menu.add(new ChangeAttributeCommand("at End", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_END), view())); < menu.add(new ChangeAttributeCommand("at Both", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_BOTH), view())); --- > menu.add(new UndoableCommand( > new ChangeAttributeCommand("none", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_NONE), view()))); > menu.add(new UndoableCommand( > new ChangeAttributeCommand("at Start", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_START), view()))); > menu.add(new UndoableCommand( > new ChangeAttributeCommand("at End", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_END), view()))); > menu.add(new UndoableCommand( > new ChangeAttributeCommand("at Both", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_BOTH), view()))); 377c406,407 < menu.add(new ChangeAttributeCommand(fonts[i], "FontName", fonts[i], view())); --- > menu.add(new UndoableCommand( > new ChangeAttributeCommand(fonts[i], "FontName", fonts[i], view()))); 386,388c416,421 < menu.add(new ChangeAttributeCommand("Plain", "FontStyle", new Integer(Font.PLAIN), view())); < menu.add(new ChangeAttributeCommand("Italic","FontStyle", new Integer(Font.ITALIC),view())); < menu.add(new ChangeAttributeCommand("Bold", "FontStyle", new Integer(Font.BOLD), view())); --- > menu.add(new UndoableCommand( > new ChangeAttributeCommand("Plain", "FontStyle", new Integer(Font.PLAIN), view()))); > menu.add(new UndoableCommand( > new ChangeAttributeCommand("Italic","FontStyle", new Integer(Font.ITALIC),view()))); > menu.add(new UndoableCommand( > new ChangeAttributeCommand("Bold", "FontStyle", new Integer(Font.BOLD), view()))); 399a433 > new UndoableCommand( 403a438 > ) 477c512 < protected StandardDrawingView createDrawingView() { --- > protected DrawingView createDrawingView() { 504,505c539,540 < protected JComponent createContents(StandardDrawingView view) { < JScrollPane sp = new JScrollPane(view); --- > protected JComponent createContents(DrawingView view) { > JScrollPane sp = new JScrollPane((StandardDrawingView)view); 582c617 < if (inside) --- > if (inside) { 584c619,620 < else --- > } > else { 586a623 > } 628c665 < public void selectionChanged(DrawingView view) { --- > public void figureSelectionChanged(DrawingView view) { 630a668,669 > // make sure it does exist > if (editMenu != null) { 631a671 > } 632a673,674 > // make sure it does exist > if (editMenu != null) { 635a678,689 > 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(); > } > } > } > } > 649c703 < fStatusLine.setText(name); --- > showStatus(name); 655c709 < if (fSelectedToolButton != null) --- > if (fSelectedToolButton != null) { 656a711 > } 658c713 < if (fSelectedToolButton != null) --- > if (fSelectedToolButton != null) { 660a716 > } 682a739 > toolDone();