Ejemplo n.º 1
0
 /** sort frames top-down-left-right */
 private void handleSwingTabAction(int delta) {
   JInternalFrame[] frames = getSwingDesktopPane().getAllFrames();
   TreeMap<Integer, JInternalFrame> sortedMap = new TreeMap<Integer, JInternalFrame>();
   for (JInternalFrame f : frames) {
     if (f.isVisible()) {
       int tabIndex = f.getX() * 100000 + f.getY();
       if (delta < 0) {
         tabIndex = -tabIndex;
       }
       sortedMap.put(tabIndex, f);
     }
   }
   JInternalFrame next = null;
   if (sortedMap.size() > 0) {
     ArrayList<JInternalFrame> list = new ArrayList<JInternalFrame>(sortedMap.values());
     int nextIndex = 0;
     JInternalFrame selectedFrame = getSwingDesktopPane().getSelectedFrame();
     if (selectedFrame != null) {
       nextIndex = (list.indexOf(selectedFrame) + 1) % list.size();
     }
     next = list.get(nextIndex);
   }
   if (next != null) {
     try {
       next.setSelected(true);
     } catch (PropertyVetoException ve) {
     }
   }
 }
Ejemplo n.º 2
0
 public void saveFrameConfiguration() {
   String frameTitle = jif.getTitle();
   pref.putInt(frameTitle + posXPreferenceKey, jif.getX());
   pref.putInt(frameTitle + posYPreferenceKey, jif.getY());
   pref.putInt(frameTitle + sizeXPreferenceKey, jif.getSize().width);
   pref.putInt(frameTitle + sizeYPreferenceKey, jif.getSize().height);
   pref.putBoolean(frameTitle + isVisiblePreferenceKey, jif.isVisible());
 }
Ejemplo n.º 3
0
 /**
  * Returns if the code window (represented by its textarea) is visible
  *
  * @param b
  */
 public boolean isVisible() {
   return editFrame.isVisible();
 }
Ejemplo n.º 4
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);
   }
 }