private void setState(JDesktopPane dp, String state) {
   if (state == CLOSE) {
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     f.doDefaultCloseAction();
   } else if (state == MAXIMIZE) {
     // maximize the selected frame
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     if (!f.isMaximum()) {
       if (f.isIcon()) {
         try {
           f.setIcon(false);
           f.setMaximum(true);
         } catch (PropertyVetoException pve) {
         }
       } else {
         try {
           f.setMaximum(true);
         } catch (PropertyVetoException pve) {
         }
       }
     }
   } else if (state == MINIMIZE) {
     // minimize the selected frame
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     if (!f.isIcon()) {
       try {
         f.setIcon(true);
       } catch (PropertyVetoException pve) {
       }
     }
   } else if (state == RESTORE) {
     // restore the selected minimized or maximized frame
     JInternalFrame f = dp.getSelectedFrame();
     if (f == null) {
       return;
     }
     try {
       if (f.isIcon()) {
         f.setIcon(false);
       } else if (f.isMaximum()) {
         f.setMaximum(false);
       }
       f.setSelected(true);
     } catch (PropertyVetoException pve) {
     }
   }
 }
  private void jMenuItemCutActionPerformed(
      java.awt.event.ActionEvent evt) // GEN-FIRST:event_jMenuItemCutActionPerformed
      { // GEN-HEADEREND:event_jMenuItemCutActionPerformed
    Toolkit t = java.awt.Toolkit.getDefaultToolkit();
    Clipboard c = t.getSystemClipboard();

    JInternalFrame currentFrame = theDesktop.getSelectedFrame();
    /*StringSelection contents = new StringSelection(srcData);
    clipboard.setContents(contents, this);*/

  } // GEN-LAST:event_jMenuItemCutActionPerformed
 public boolean isEnabled(Object sender) {
   if (sender instanceof JDesktopPane) {
     JDesktopPane dp = (JDesktopPane) sender;
     String action = getName();
     if (action == Actions.NEXT_FRAME || action == Actions.PREVIOUS_FRAME) {
       return true;
     }
     JInternalFrame iFrame = dp.getSelectedFrame();
     if (iFrame == null) {
       return false;
     } else if (action == Actions.CLOSE) {
       return iFrame.isClosable();
     } else if (action == Actions.MINIMIZE) {
       return iFrame.isIconifiable();
     } else if (action == Actions.MAXIMIZE) {
       return iFrame.isMaximizable();
     }
     return true;
   }
   return false;
 }
Ejemplo n.º 4
0
  public JInternalFrame getActiveInternalFrame() {

    return desktopPane.getSelectedFrame();
  }
Ejemplo n.º 5
0
 public TaskComponent getActiveTaskComponent() {
   if (desktopPane.getSelectedFrame() instanceof TaskComponent)
     return (TaskComponent) desktopPane.getSelectedFrame();
   else return null;
 }
    public void actionPerformed(ActionEvent e) {
      JDesktopPane dp = (JDesktopPane) e.getSource();
      String key = getName();

      if (CLOSE == key || MAXIMIZE == key || MINIMIZE == key || RESTORE == key) {
        setState(dp, key);
      } else if (ESCAPE == key) {
        if (sourceFrame == dp.getSelectedFrame() && focusOwner != null) {
          focusOwner.requestFocus();
        }
        moving = false;
        resizing = false;
        sourceFrame = null;
        focusOwner = null;
      } else if (MOVE == key || RESIZE == key) {
        sourceFrame = dp.getSelectedFrame();
        if (sourceFrame == null) {
          return;
        }
        moving = (key == MOVE) ? true : false;
        resizing = (key == RESIZE) ? true : false;

        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (!SwingUtilities.isDescendingFrom(focusOwner, sourceFrame)) {
          focusOwner = null;
        }
        sourceFrame.requestFocus();
      } else if (LEFT == key
          || RIGHT == key
          || UP == key
          || DOWN == key
          || SHRINK_RIGHT == key
          || SHRINK_LEFT == key
          || SHRINK_UP == key
          || SHRINK_DOWN == key) {
        JInternalFrame c = dp.getSelectedFrame();
        if (sourceFrame == null
            || c != sourceFrame
            || KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()
                != sourceFrame) {
          return;
        }
        Insets minOnScreenInsets = UIManager.getInsets("Desktop.minOnScreenInsets");
        Dimension size = c.getSize();
        Dimension minSize = c.getMinimumSize();
        int dpWidth = dp.getWidth();
        int dpHeight = dp.getHeight();
        int delta;
        Point loc = c.getLocation();
        if (LEFT == key) {
          if (moving) {
            c.setLocation(
                loc.x + size.width - MOVE_RESIZE_INCREMENT < minOnScreenInsets.right
                    ? -size.width + minOnScreenInsets.right
                    : loc.x - MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (RIGHT == key) {
          if (moving) {
            c.setLocation(
                loc.x + MOVE_RESIZE_INCREMENT > dpWidth - minOnScreenInsets.left
                    ? dpWidth - minOnScreenInsets.left
                    : loc.x + MOVE_RESIZE_INCREMENT,
                loc.y);
          } else if (resizing) {
            c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);
          }
        } else if (UP == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + size.height - MOVE_RESIZE_INCREMENT < minOnScreenInsets.bottom
                    ? -size.height + minOnScreenInsets.bottom
                    : loc.y - MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (DOWN == key) {
          if (moving) {
            c.setLocation(
                loc.x,
                loc.y + MOVE_RESIZE_INCREMENT > dpHeight - minOnScreenInsets.top
                    ? dpHeight - minOnScreenInsets.top
                    : loc.y + MOVE_RESIZE_INCREMENT);
          } else if (resizing) {
            c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);
          }
        } else if (SHRINK_LEFT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + size.width - delta < minOnScreenInsets.left) {
            delta = loc.x + size.width - minOnScreenInsets.left;
          }
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_RIGHT == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.width - minSize.width;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.x + delta > dpWidth - minOnScreenInsets.right) {
            delta = (dpWidth - minOnScreenInsets.right) - loc.x;
          }

          c.setLocation(loc.x + delta, loc.y);
          c.setSize(size.width - delta, size.height);
        } else if (SHRINK_UP == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + size.height - delta < minOnScreenInsets.bottom) {
            delta = loc.y + size.height - minOnScreenInsets.bottom;
          }

          c.setSize(size.width, size.height - delta);
        } else if (SHRINK_DOWN == key && resizing) {
          // Make sure we don't resize less than minimum size.
          if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {
            delta = MOVE_RESIZE_INCREMENT;
          } else {
            delta = size.height - minSize.height;
          }

          // Ensure that we keep the internal frame on the desktop.
          if (loc.y + delta > dpHeight - minOnScreenInsets.top) {
            delta = (dpHeight - minOnScreenInsets.top) - loc.y;
          }

          c.setLocation(loc.x, loc.y + delta);
          c.setSize(size.width, size.height - delta);
        }
      } else if (NEXT_FRAME == key || PREVIOUS_FRAME == key) {
        dp.selectFrame((key == NEXT_FRAME) ? true : false);
      } else if (NAVIGATE_NEXT == key || NAVIGATE_PREVIOUS == key) {
        boolean moveForward = true;
        if (NAVIGATE_PREVIOUS == key) {
          moveForward = false;
        }
        Container cycleRoot = dp.getFocusCycleRootAncestor();

        if (cycleRoot != null) {
          FocusTraversalPolicy policy = cycleRoot.getFocusTraversalPolicy();
          if (policy != null && policy instanceof SortingFocusTraversalPolicy) {
            SortingFocusTraversalPolicy sPolicy = (SortingFocusTraversalPolicy) policy;
            boolean idc = sPolicy.getImplicitDownCycleTraversal();
            try {
              sPolicy.setImplicitDownCycleTraversal(false);
              if (moveForward) {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent(dp);
              } else {
                KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent(dp);
              }
            } finally {
              sPolicy.setImplicitDownCycleTraversal(idc);
            }
          }
        }
      }
    }
Ejemplo n.º 7
0
  /**
   * Handles most menu action event for this application.
   *
   * @param evt the generated action event to be handled.
   */
  public void actionPerformed(ActionEvent evt) {

    ProjectCompendium.APP.setWaitCursor();

    Object source = evt.getSource();

    if (source.equals(miStencilManagement)) {
      UIStencilDialog dlg =
          new UIStencilDialog(ProjectCompendium.APP, ProjectCompendium.APP.oStencilManager);
      UIUtilities.centerComponent(dlg, ProjectCompendium.APP);
      dlg.setVisible(true);
    } else if (source.equals(miLinkGroupManagement)) {
      UILinkManagementDialog dlg =
          new UILinkManagementDialog(
              ProjectCompendium.APP, ProjectCompendium.APP.oLinkGroupManager);
      UIUtilities.centerComponent(dlg, ProjectCompendium.APP);
      dlg.setVisible(true);
    } else if (source.equals(miLinkGroupDefault)) {
      ProjectCompendium.APP.oLinkGroupManager.createDefaultLinkGroup();
    } else if (source.equals(miLinkGroupManagement)) {
      ProjectCompendium.APP.oLinkGroupManager.createDefaultLinkGroup();
      ProjectCompendium.APP.oLinkGroupManager.refreshTree();
    } else if (source.equals(miUsers)) ProjectCompendium.APP.onUsers();
    else if (source.equals(miLinkedFilesFileBrowser)) ProjectCompendium.APP.onLinkedFilesBrowser();
    else if (source.equals(miMeetingRecording)) {
      ProjectCompendium.APP.displayError(
          LanguageProperties.getString(
              LanguageProperties.MENUS_BUNDLE, "UIMenuTools.memeticMessage1")); // $NON-NLS-1$
    } else if (source.equals(miMeetingUpload)) {
    } else if (source.equals(miCodes)) ProjectCompendium.APP.onCodes();
    else if (source.equals(miShowCodes)) ProjectCompendium.APP.onShowCodes();
    else if (source.equals(miHideCodes)) ProjectCompendium.APP.onHideCodes();
    else if (source.equals(miShowScribblePad)) {
      ProjectCompendium.APP.onShowScribblePad();
      miShowScribblePad.setEnabled(false);
      miHideScribblePad.setEnabled(true);
      miSaveScribblePad.setEnabled(true);
      miClearScribblePad.setEnabled(true);
    } else if (source.equals(miHideScribblePad)) {
      ProjectCompendium.APP.onHideScribblePad();
      miShowScribblePad.setEnabled(true);
      miHideScribblePad.setEnabled(false);
      miSaveScribblePad.setEnabled(false);
      miClearScribblePad.setEnabled(false);
    } else if (source.equals(miSaveScribblePad)) ProjectCompendium.APP.onSaveScribblePad();
    else if (source.equals(miClearScribblePad)) ProjectCompendium.APP.onClearScribblePad();
    else if (source.equals(miProjectOptions)) {
      UIProjectOptionsDialog dialog =
          new UIProjectOptionsDialog(ProjectCompendium.APP, ProjectCompendium.APP.getModel());
      dialog.setVisible(true);
    } else if (source.equals(miOptions)) {
      UIOptionsDialog dialog = new UIOptionsDialog(ProjectCompendium.APP);
      dialog.setVisible(true);
    } else if (source.equals(miFocusFrames)) {
      JDesktopPane pane = ProjectCompendium.APP.getDesktop();
      JInternalFrame frame = pane.getSelectedFrame();
      if (frame instanceof UIMapViewFrame) {
        UIMapViewFrame mapframe = (UIMapViewFrame) frame;
        mapframe.getViewPane().requestFocus();
      } else if (frame instanceof UIListViewFrame) {
        UIListViewFrame listframe = (UIListViewFrame) frame;
        listframe.getUIList().getList().requestFocus();
      }
    } else if (source.equals(miFocusTabs)) {
      JTabbedPane oTabbedPane = ProjectCompendium.APP.oTabbedPane;
      if (oTabbedPane.getTabCount() > 0) {
        oTabbedPane.requestFocus();
      }
    }

    ProjectCompendium.APP.setDefaultCursor();
  }