Example #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");
    }
  }
Example #2
0
  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");
  }
Example #3
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);
      }
    }
  }