Ejemplo n.º 1
0
  /** Frees resources, clears references */
  public void dispose() {
    if (tempFloatingTimer != null) {
      tempFloatingTimer.stop();
    }

    if (initialized) {
      if (winListener != null) removeListener(winListener);
      if (cmpListener != null) c.removeComponentListener(cmpListener);

      wh.removeWindow(this, null);
      //			AbstractApplication.getApplication().addComponent( getClass().getName(), null );

      if (borrowMenuBar) {
        borrowMenuBar(null);
        wh.removeBorrowListener(this);
      }
      if (wh.getMenuBarBorrower() == this) wh.setMenuBarBorrower(null);
      if (ownMenuBar) {
        setJMenuBar(null);
        wh.getMenuBarRoot().destroy(this);
      }
    }

    if (w != null) {
      w.dispose();
    } else if (jif != null) {
      jif.dispose();
    }

    if (ggTitle != null) ggTitle.dispose();

    classPrefs = null;
    cmpListener = null;
    winListener = null;
  }
  /**
   * Reacts to property change events 'editorClosing', 'closeFrame', and 'name'.
   *
   * @param e the property change event.
   */
  public void propertyChange(PropertyChangeEvent e) {

    // Handles the removal of editor frames from desktop
    String name = e.getPropertyName();

    if ("editorClosing".equals(name)) {

      // find NewValue in String array, and remove
      for (int n = 0; n < sessionNodeKeys.size(); n++) {
        if (e.getNewValue().equals((sessionNodeKeys.get(n)))) {
          sessionNodeKeys.remove(n);
        }
      }
    } else if ("closeFrame".equals(e.getPropertyName())) {
      if (getFramesMap().containsKey(e.getSource())) {
        Object frameObject = getFramesMap().get(e.getSource());
        JInternalFrame frame = (JInternalFrame) frameObject;
        frame.setVisible(false);
        frame.dispose();
      }
    } else if ("name".equals(e.getPropertyName())) {
      if (getFramesMap().containsKey(e.getSource())) {
        Object frameObject = getFramesMap().get(e.getSource());
        JInternalFrame frame = (JInternalFrame) frameObject;
        String _name = (String) (e.getNewValue());
        frame.setTitle(_name);
        setMainTitle(_name);
      }
    }
  }
Ejemplo n.º 3
0
 public void disposeCurrentFrame() {
   if (currentFrame != null) {
     lastLocation = currentFrame.getLocation();
     currentFrame.setVisible(false);
     currentFrame.dispose();
     currentFrame = null;
   }
 }
  public void closeEmptySessions() {
    JInternalFrame[] frames = desktopPane.getAllFramesInLayer(0);

    for (JInternalFrame frame : frames) {
      Object o = frame.getContentPane().getComponents()[0];

      if (o instanceof SessionEditor) {
        SessionEditor sessionEditor = (SessionEditor) o;
        SessionEditorWorkbench workbench = sessionEditor.getSessionWorkbench();
        Graph graph = workbench.getGraph();
        if (graph.getNumNodes() == 0) {
          frame.dispose();
        }
      }
    }
  }
Ejemplo n.º 5
0
  public void disposeWindow(MkWindow mkWindow) {

    Container window = mkWindow.getRootPane().getParent();

    if (window instanceof JDialog) {
      JDialog modalFrame = (JDialog) window;
      modalFrame.dispose();
    } else {
      JInternalFrame modalFrame = (JInternalFrame) window;
      modalFrame.dispose();
    }

    logger.debug("Removendo MkWindow " + mkWindow.getClass().getName());
    listMkWindow.remove(mkWindow);

    focusLastFrame();
  }
 public void internalFrameClosing(InternalFrameEvent e) {
   JInternalFrame w = e.getInternalFrame();
   System.out.println("Internal Frame Monitor Ventana Cerrada");
   w.dispose();
 }
Ejemplo n.º 7
0
 /** Fecha todas as Janelas abertas */
 public void closeAll() {
   JInternalFrame[] frames = dPane.getAllFrames();
   for (JInternalFrame f : frames) {
     f.dispose();
   }
 }
Ejemplo n.º 8
0
  /** Invoked when an action occurs. */
  public void actionPerformed(ActionEvent e) {
    String actionCmd = e.getActionCommand();

    if (actionCmd.equals("cancel")) {
      closeForm();
    }

    if (actionCmd.equals("new_branch")) {
      int index = Configurator.getIntProperty("newBranch", 0, "gui-forms");
      DefaultForm form = Gui.getForm(index);
      if (form != null && !form.isClosed()) {
        form.pack();
        try {
          form.setSelected(true);
        } catch (java.beans.PropertyVetoException ev) {
        }
      } else {
        BranchForm branchForm = new BranchForm(index, null);
      }
    }

    if (actionCmd.equals("checkout")) {
      boolean selected = false;
      for (int i = 0; i < myBranches.length; i++) {
        TableModel model = branchTable.getModel();
        Boolean checked = (Boolean) model.getValueAt(i, 0);
        if (Boolean.TRUE.equals(checked)) selected = true;
      }
      int selectedRow = branchTable.getSelectedRow();
      if (selected || (!selected && selectedRow >= 0)) checkoutItems(selected, selectedRow);
      else {
        showNoSectionMessage();
      }
    }

    if (actionCmd.equals("edit")) {
      Point formLocation = null;
      int selectedRow = branchTable.getSelectedRow();
      if (selectedRow >= 0) {
        Branch branchToEdit = (Branch) myBranches[selectedRow];
        int editBranchIndex = Configurator.getIntProperty("editBranch", 0, "gui-forms");
        JInternalFrame form = Gui.getForm(editBranchIndex);
        if (form != null && !form.isClosed()) {
          int switch_frame = getEditOpenedDialog();
          if (switch_frame == JOptionPane.YES_OPTION) {
            formLocation = form.getLocation();
            form.dispose();
            BranchForm editBranch =
                new BranchForm(editBranchIndex, branchToEdit, selectedRow, formLocation);
          } else {
            try {
              form.setSelected(true);
            } catch (java.beans.PropertyVetoException ev) {
            }
          }
        } else {
          BranchForm editBranch =
              new BranchForm(editBranchIndex, branchToEdit, selectedRow, formLocation);
        }
      } // if(selectedRow>=0)
      else {
        showNoEditSelectionMessage();
      }
    }

    if (actionCmd.equals("delete")) {
      boolean selected = false;
      for (int i = 0; i < myBranches.length; i++) {
        TableModel model = branchTable.getModel();
        Boolean checked = (Boolean) model.getValueAt(i, 0);
        if (Boolean.TRUE.equals(checked)) selected = true;
      }
      int selectedRow = branchTable.getSelectedRow();
      if (selected || (!selected && selectedRow >= 0)) deleteItems(selected, selectedRow);
      else {
        showNoDeleteSelectionMessage();
      }
    }

    if (actionCmd.equals("branch_content")) {
      boolean selected = false;
      for (int i = 0; i < myBranches.length; i++) {
        TableModel model = branchTable.getModel();
        Boolean checked = (Boolean) model.getValueAt(i, 0);
        if (Boolean.TRUE.equals(checked)) selected = true;
      }
      int selectedRow = branchTable.getSelectedRow();
      if (selected || (!selected && selectedRow >= 0)) listItems(selected, selectedRow);
      else {
        showNoListcontentSection();
      }
    }

    if (actionCmd.equals("select_all")) {
      selectAll();
    }

    if (actionCmd.equals("select_all_pop")) {
      selectAllPop();
    }
  }
Ejemplo n.º 9
0
 /** Run the task. */
 public void run() {
   final BoundedRangeModel model = progressBar.getModel();
   switch (task) {
     case -LABEL:
       {
         value = description.getText();
         return;
       }
     case +LABEL:
       {
         description.setText((String) value);
         return;
       }
     case PROGRESS:
       {
         model.setValue(((Integer) value).intValue());
         progressBar.setIndeterminate(false);
         return;
       }
     case STARTED:
       {
         model.setRangeProperties(0, 1, 0, 100, false);
         window.setVisible(true);
         break; // Need further action below.
       }
     case COMPLETE:
       {
         model.setRangeProperties(100, 1, 0, 100, false);
         window.setVisible(warningArea != null);
         cancel.setEnabled(false);
         break; // Need further action below.
       }
   }
   /*
    * Some of the tasks above requires an action on the window, which may be a JDialog or
    * a JInternalFrame. We need to determine the window type before to apply the action.
    */
   synchronized (ProgressWindow.this) {
     if (window instanceof JDialog) {
       final JDialog window = (JDialog) ProgressWindow.this.window;
       switch (task) {
         case -TITLE:
           {
             value = window.getTitle();
             return;
           }
         case +TITLE:
           {
             window.setTitle((String) value);
             return;
           }
         case STARTED:
           {
             window.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
             return;
           }
         case COMPLETE:
           {
             window.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
             return;
           }
         case DISPOSE:
           {
             window.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
             if (warningArea == null || !window.isVisible()) {
               window.dispose();
             }
             return;
           }
       }
     } else {
       final JInternalFrame window = (JInternalFrame) ProgressWindow.this.window;
       switch (task) {
         case -TITLE:
           {
             value = window.getTitle();
             return;
           }
         case +TITLE:
           {
             window.setTitle((String) value);
             return;
           }
         case STARTED:
           {
             window.setClosable(false);
             return;
           }
         case COMPLETE:
           {
             window.setClosable(true);
             return;
           }
         case DISPOSE:
           {
             window.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE);
             if (warningArea == null || !window.isVisible()) {
               window.dispose();
             }
             return;
           }
       }
     }
     /*
      * Si la tâche spécifiée n'est aucune des tâches énumérées ci-haut,
      * on supposera que l'on voulait afficher un message d'avertissement.
      */
     if (warningArea == null) {
       final JTextArea warningArea = new JTextArea();
       final JScrollPane scroll = new JScrollPane(warningArea);
       final JPanel namedArea = new JPanel(new BorderLayout());
       ProgressWindow.this.warningArea = warningArea;
       warningArea.setFont(Font.getFont("Monospaced"));
       warningArea.setEditable(false);
       namedArea.setBorder(BorderFactory.createEmptyBorder(0, HMARGIN, VMARGIN, HMARGIN));
       namedArea.add(new JLabel(getString(VocabularyKeys.WARNING)), BorderLayout.NORTH);
       namedArea.add(scroll, BorderLayout.CENTER);
       content.add(namedArea, BorderLayout.CENTER);
       if (window instanceof JDialog) {
         final JDialog window = (JDialog) ProgressWindow.this.window;
         window.setResizable(true);
       } else {
         final JInternalFrame window = (JInternalFrame) ProgressWindow.this.window;
         window.setResizable(true);
       }
       window.setSize(WIDTH, HEIGHT + WARNING_HEIGHT);
       window.setVisible(true); // Seems required in order to force relayout.
     }
     final JTextArea warningArea = (JTextArea) ProgressWindow.this.warningArea;
     warningArea.append((String) value);
   }
 }