Ejemplo n.º 1
0
  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");
    }
  }
Ejemplo n.º 2
0
  public void actionPerformed(ActionEvent ev) {
    String aKey = ev.getActionCommand();

    if ("New Project".equals(aKey)) {
      BDevelop newdevdesk = new BDevelop(root, top, treemodel, configDir, logHandle);
      newdevdesk.setVisible(true);
      desktop.add(newdevdesk);
      try {
        newdevdesk.setSelected(true);
      } catch (java.beans.PropertyVetoException ex) {
        log.severe("Desktop show error : " + ex);
      }
    } else if ("Close Project".equals(aKey)) {
      closeProject(false);
    } else if ("Delete Project".equals(aKey)) {
      closeProject(true);
    } else if ("Save Projects".equals(aKey)) {
      Bio io = new Bio();
      io.saveFile(configDir + configFile, root.toString());
    } else if ("Encrypt File".equals(aKey)) {
      // Create encrypter/decrypter class and encrypt
      String encryFile = configFile.substring(0, configFile.length() - 3) + "cph";
      BDesEncrypter encrypter = new BDesEncrypter(root.getAttribute("encryption"));
      encrypter.encrypt(configDir + configFile, configDir + encryFile);
    } else if ("Open Applications".equals(aKey)) {
      // Create a file chooser
      JFileChooser fc = new JFileChooser(configDir);
      int returnVal = fc.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File cnFile = fc.getSelectedFile();
        configDir = cnFile.getParent() + "/";
        configFile = cnFile.getName();

        BXML xml = new BXML(configDir + configFile, false);
        root = xml.getRoot();
        top = new BTreeNode(root, "APP");
        for (BElement el : root.getElements()) top.add(new BTreeNode(el, el.getValue()));

        treemodel.setRoot(top);
        treemodel.reload();
      }
    } else if ("About".equals(aKey)) {
      BAbout about = new BAbout("IDE");
      about.setVisible(true);
      desktop.add(about);
      try {
        about.setSelected(true);
      } catch (java.beans.PropertyVetoException ex) {
        log.severe("Desktop show error : " + ex);
      }
    }
  }