public void closeProject(boolean delNode) { BTreeNode node = (BTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { BTreeNode parent = (BTreeNode) (node.getParent()); if (node.isLeaf()) { BElement dKey = node.getKey(); if (develop.get(dKey) != null) { develop.get(dKey).close(); develop.remove(dKey); tree.removeSelectionPath(tree.getSelectionPath()); } if ((delNode) && (parent != null)) { int n = JOptionPane.showConfirmDialog( treePanel, "Are you sure you want to delete the project?", "Project Deletion", JOptionPane.YES_NO_OPTION); if (n == 0) { treemodel.removeNodeFromParent(node); root.delNode(dKey); Bio io = new Bio(); io.saveFile(configDir + "config.xml", root.toString()); log.info("Project deleted"); } } } } else { log.info("Select a project first"); } }
public BIDE(String configDir) { super(new BorderLayout()); this.configDir = configDir; configFile = "config.xml"; BXML xml = new BXML(configDir + configFile, false); root = xml.getRoot(); logHandle = new BLogHandle(); logHandle.config(log); // Create an application list develop = new HashMap<BElement, BDevelop>(); mainPanel = new JPanel(new BorderLayout()); treePanel = new JPanel(new BorderLayout()); // Create a tree that allows one selection at a time. top = new BTreeNode(root, "APP"); for (BElement el : root.getElements()) top.add(new BTreeNode(el, el.getValue())); treemodel = new DefaultTreeModel(top); tree = new BImageTree("/org/baraza/resources/leftpanel.jpg", treemodel, true); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setCellRenderer(new BCellRenderer()); tree.addTreeSelectionListener(this); treeScroll = new JScrollPane(tree); treePanel.add(treeScroll, BorderLayout.CENTER); String menuStrs[] = { "New Project", "Close Project", "Delete Project", "Save Projects", "Encrypt File", "Open Applications", "About" }; JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem menuItem = null; for (String menuStr : menuStrs) { menuItem = new JMenuItem(menuStr); menuItem.addActionListener(this); fileMenu.add(menuItem); } menuBar.add(fileMenu); super.add(menuBar, BorderLayout.PAGE_START); desktop = new BImageDesktop("/org/baraza/resources/background.jpg"); mainPanel.add(desktop, BorderLayout.CENTER); mainPanel.add(logHandle.getStatusBar(), BorderLayout.PAGE_END); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePanel, mainPanel); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(150); super.add(splitPane, BorderLayout.CENTER); log.info("Status : Running"); }
public void valueChanged(TreeSelectionEvent ev) { BTreeNode node = (BTreeNode) tree.getLastSelectedPathComponent(); if (node != null) { BElement dKey = node.getKey(); if (develop.get(dKey) == null) // Create a new IDE if one is not one the MAP develop.put(dKey, new BDevelop(dKey, root, node, treemodel, configDir, logHandle)); try { if (develop.get(dKey).isVisible()) { develop.get(dKey).setSelected(true); if (develop.get(dKey).isIcon()) develop.get(dKey).setIcon(false); } else { develop.get(dKey).setVisible(true); desktop.add(develop.get(dKey)); develop.get(dKey).setSelected(true); } } catch (java.beans.PropertyVetoException ex) { log.severe("Desktop show error : " + ex); } } }