/** Shows a file dialog and opens a drawing. */ public void promptOpen() { toolDone(); JFileChooser openDialog = createOpenFileChooser(); getStorageFormatManager().registerFileFilters(openDialog); if (openDialog.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { StorageFormat foundFormat = getStorageFormatManager().findStorageFormat(openDialog.getFileFilter()); if (foundFormat != null) { loadDrawing(foundFormat, openDialog.getSelectedFile().getAbsolutePath()); } else { showStatus("Not a valid file format: " + openDialog.getFileFilter().getDescription()); } } }
/** Opens a new window with a drawing view. */ protected void open(DrawingView newDrawingView) { getVersionControlStrategy().assertCompatibleVersion(); setUndoManager(new UndoManager()); fIconkit = new Iconkit(this); getContentPane().setLayout(new BorderLayout()); // status line must be created before a tool is set fStatusLine = createStatusLine(); getContentPane().add(fStatusLine, BorderLayout.SOUTH); // create dummy tool until the default tool is activated during toolDone() setTool(new NullTool(this), ""); setView(newDrawingView); JComponent contents = createContents(view()); contents.setAlignmentX(LEFT_ALIGNMENT); JToolBar tools = createToolPalette(); createTools(tools); JPanel activePanel = new JPanel(); activePanel.setAlignmentX(LEFT_ALIGNMENT); activePanel.setAlignmentY(TOP_ALIGNMENT); activePanel.setLayout(new BorderLayout()); activePanel.add(tools, BorderLayout.NORTH); activePanel.add(contents, BorderLayout.CENTER); getContentPane().add(activePanel, BorderLayout.CENTER); JMenuBar mb = new JMenuBar(); createMenus(mb); setJMenuBar(mb); Dimension d = defaultSize(); if (d.width > mb.getPreferredSize().width) { setSize(d.width, d.height); } else { setSize(mb.getPreferredSize().width, d.height); } addListeners(); setVisible(true); fStorageFormatManager = createStorageFormatManager(); toolDone(); }
/** Resets the drawing to a new empty drawing. */ public void promptNew() { toolDone(); view().setDrawing(createDrawing()); view().drawing().setTitle(getDefaultDrawingTitle()); }