home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &… the Search for Life CD 3 / 0_CD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / plaf / basic / BasicDesktopPaneUI.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  6.5 KB  |  277 lines

  1. package javax.swing.plaf.basic;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.awt.Graphics;
  6. import java.util.Vector;
  7. import javax.swing.ActionMap;
  8. import javax.swing.DefaultDesktopManager;
  9. import javax.swing.DesktopManager;
  10. import javax.swing.InputMap;
  11. import javax.swing.JComponent;
  12. import javax.swing.JDesktopPane;
  13. import javax.swing.JInternalFrame;
  14. import javax.swing.KeyStroke;
  15. import javax.swing.LookAndFeel;
  16. import javax.swing.SwingUtilities;
  17. import javax.swing.UIManager;
  18. import javax.swing.plaf.ActionMapUIResource;
  19. import javax.swing.plaf.ComponentUI;
  20. import javax.swing.plaf.DesktopPaneUI;
  21. import javax.swing.plaf.UIResource;
  22.  
  23. public class BasicDesktopPaneUI extends DesktopPaneUI {
  24.    private static Dimension minSize = new Dimension(0, 0);
  25.    private static Dimension maxSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
  26.    protected JDesktopPane desktop;
  27.    protected DesktopManager desktopManager;
  28.    protected KeyStroke minimizeKey;
  29.    protected KeyStroke maximizeKey;
  30.    protected KeyStroke closeKey;
  31.    protected KeyStroke navigateKey;
  32.    protected KeyStroke navigateKey2;
  33.    private static Vector framesCache;
  34.    private static int selectedIndex;
  35.    private NavigateAction nextAction;
  36.    private boolean moving = false;
  37.    private boolean resizing = false;
  38.    private final int MOVE_RESIZE_INCREMENT = 10;
  39.  
  40.    public static ComponentUI createUI(JComponent var0) {
  41.       return new BasicDesktopPaneUI();
  42.    }
  43.  
  44.    public void installUI(JComponent var1) {
  45.       this.desktop = (JDesktopPane)var1;
  46.       this.installDefaults();
  47.       this.installDesktopManager();
  48.       this.installKeyboardActions();
  49.    }
  50.  
  51.    public void uninstallUI(JComponent var1) {
  52.       this.uninstallKeyboardActions();
  53.       this.uninstallDesktopManager();
  54.       this.uninstallDefaults();
  55.       this.desktop = null;
  56.    }
  57.  
  58.    protected void installDefaults() {
  59.       if (this.desktop.getBackground() == null || this.desktop.getBackground() instanceof UIResource) {
  60.          this.desktop.setBackground(UIManager.getColor("Desktop.background"));
  61.       }
  62.  
  63.    }
  64.  
  65.    protected void uninstallDefaults() {
  66.    }
  67.  
  68.    protected void installDesktopManager() {
  69.       if (this.desktop.getDesktopManager() == null) {
  70.          this.desktopManager = new DefaultDesktopManager();
  71.          this.desktop.setDesktopManager(this.desktopManager);
  72.       }
  73.  
  74.    }
  75.  
  76.    protected void uninstallDesktopManager() {
  77.       if (this.desktop.getDesktopManager() == this.desktopManager) {
  78.          this.desktop.setDesktopManager((DesktopManager)null);
  79.       }
  80.  
  81.       this.desktopManager = null;
  82.    }
  83.  
  84.    protected void installKeyboardActions() {
  85.       InputMap var1 = this.getInputMap(2);
  86.       if (var1 != null) {
  87.          SwingUtilities.replaceUIInputMap(this.desktop, 2, var1);
  88.       }
  89.  
  90.       var1 = this.getInputMap(1);
  91.       if (var1 != null) {
  92.          SwingUtilities.replaceUIInputMap(this.desktop, 1, var1);
  93.       }
  94.  
  95.       ActionMap var2 = this.getActionMap();
  96.       SwingUtilities.replaceUIActionMap(this.desktop, var2);
  97.       this.registerKeyboardActions();
  98.    }
  99.  
  100.    protected void registerKeyboardActions() {
  101.    }
  102.  
  103.    protected void unregisterKeyboardActions() {
  104.    }
  105.  
  106.    InputMap getInputMap(int var1) {
  107.       if (var1 == 2) {
  108.          return this.createInputMap(var1);
  109.       } else {
  110.          return var1 == 1 ? (InputMap)UIManager.get("Desktop.ancestorInputMap") : null;
  111.       }
  112.    }
  113.  
  114.    InputMap createInputMap(int var1) {
  115.       if (var1 == 2) {
  116.          Object[] var2 = UIManager.get("Desktop.windowBindings");
  117.          if (var2 != null) {
  118.             return LookAndFeel.makeComponentInputMap(this.desktop, var2);
  119.          }
  120.       }
  121.  
  122.       return null;
  123.    }
  124.  
  125.    ActionMap getActionMap() {
  126.       return this.createActionMap();
  127.    }
  128.  
  129.    ActionMap createActionMap() {
  130.       ActionMapUIResource var1 = new ActionMapUIResource();
  131.       ((ActionMap)var1).put("restore", new OpenAction(this));
  132.       ((ActionMap)var1).put("close", new CloseAction(this));
  133.       ((ActionMap)var1).put("move", new MoveResizeAction(this, "move"));
  134.       ((ActionMap)var1).put("resize", new MoveResizeAction(this, "resize"));
  135.       ((ActionMap)var1).put("left", new MoveResizeAction(this, "left"));
  136.       ((ActionMap)var1).put("right", new MoveResizeAction(this, "right"));
  137.       ((ActionMap)var1).put("up", new MoveResizeAction(this, "up"));
  138.       ((ActionMap)var1).put("down", new MoveResizeAction(this, "down"));
  139.       ((ActionMap)var1).put("escape", new MoveResizeAction(this, "escape"));
  140.       ((ActionMap)var1).put("minimize", new MinimizeAction(this));
  141.       ((ActionMap)var1).put("maximize", new MaximizeAction(this));
  142.       ((ActionMap)var1).put("selectNextFrame", this.nextAction = new NavigateAction(this));
  143.       ((ActionMap)var1).put("selectPreviousFrame", new PreviousAction(this, (1)null));
  144.       return var1;
  145.    }
  146.  
  147.    protected void uninstallKeyboardActions() {
  148.       this.unregisterKeyboardActions();
  149.       SwingUtilities.replaceUIInputMap(this.desktop, 2, (InputMap)null);
  150.       SwingUtilities.replaceUIInputMap(this.desktop, 1, (InputMap)null);
  151.       SwingUtilities.replaceUIActionMap(this.desktop, (ActionMap)null);
  152.    }
  153.  
  154.    public void paint(Graphics var1, JComponent var2) {
  155.    }
  156.  
  157.    public Dimension getPreferredSize(JComponent var1) {
  158.       return null;
  159.    }
  160.  
  161.    public Dimension getMinimumSize(JComponent var1) {
  162.       return minSize;
  163.    }
  164.  
  165.    public Dimension getMaximumSize(JComponent var1) {
  166.       return maxSize;
  167.    }
  168.  
  169.    private void verifyFramesCache() {
  170.       boolean var1 = false;
  171.       if (framesCache == null) {
  172.          framesCache = new Vector();
  173.          var1 = true;
  174.       }
  175.  
  176.       boolean var2 = false;
  177.       int var3 = framesCache.size();
  178.  
  179.       for(int var4 = 0; var4 < var3; ++var4) {
  180.          JComponent var5 = (JComponent)framesCache.elementAt(var4);
  181.          if (var5 instanceof JInternalFrame) {
  182.             JInternalFrame var6 = (JInternalFrame)var5;
  183.             if (var6.isClosed()) {
  184.                var2 = true;
  185.                break;
  186.             }
  187.          } else if (var5 instanceof JInternalFrame.JDesktopIcon) {
  188.             JInternalFrame.JDesktopIcon var13 = (JInternalFrame.JDesktopIcon)var5;
  189.             JInternalFrame var7 = var13.getInternalFrame();
  190.             if (var7.isClosed()) {
  191.                var2 = true;
  192.                break;
  193.             }
  194.          }
  195.       }
  196.  
  197.       JInternalFrame[] var12 = this.desktop.getAllFrames();
  198.       if (var2 || var12.length != framesCache.size()) {
  199.          framesCache.clear();
  200.          int var14 = this.desktop.lowestLayer();
  201.          int var15 = this.desktop.highestLayer();
  202.          int var8 = 0;
  203.  
  204.          for(int var9 = var15; var9 >= var14; --var9) {
  205.             Component[] var10 = this.desktop.getComponentsInLayer(var9);
  206.             if (var10.length > 0) {
  207.                for(int var11 = 0; var11 < var10.length; ++var11) {
  208.                   framesCache.addElement(var10[var11]);
  209.                   if (var1 && var10[var11] instanceof JInternalFrame && ((JInternalFrame)var10[var11]).isSelected()) {
  210.                      selectedIndex = var8;
  211.                   }
  212.  
  213.                   ++var8;
  214.                }
  215.             }
  216.          }
  217.       }
  218.  
  219.    }
  220.  
  221.    // $FF: synthetic method
  222.    static void access$100(BasicDesktopPaneUI var0) {
  223.       var0.verifyFramesCache();
  224.    }
  225.  
  226.    // $FF: synthetic method
  227.    static int access$200() {
  228.       return selectedIndex;
  229.    }
  230.  
  231.    // $FF: synthetic method
  232.    static Vector access$300() {
  233.       return framesCache;
  234.    }
  235.  
  236.    // $FF: synthetic method
  237.    static NavigateAction access$400(BasicDesktopPaneUI var0) {
  238.       return var0.nextAction;
  239.    }
  240.  
  241.    // $FF: synthetic method
  242.    static boolean access$502(BasicDesktopPaneUI var0, boolean var1) {
  243.       return var0.moving = var1;
  244.    }
  245.  
  246.    // $FF: synthetic method
  247.    static boolean access$602(BasicDesktopPaneUI var0, boolean var1) {
  248.       return var0.resizing = var1;
  249.    }
  250.  
  251.    // $FF: synthetic method
  252.    static boolean access$500(BasicDesktopPaneUI var0) {
  253.       return var0.moving;
  254.    }
  255.  
  256.    // $FF: synthetic method
  257.    static boolean access$600(BasicDesktopPaneUI var0) {
  258.       return var0.resizing;
  259.    }
  260.  
  261.    // $FF: synthetic method
  262.    static int access$208() {
  263.       return selectedIndex++;
  264.    }
  265.  
  266.    // $FF: synthetic method
  267.    static int access$202(int var0) {
  268.       selectedIndex = var0;
  269.       return var0;
  270.    }
  271.  
  272.    // $FF: synthetic method
  273.    static int access$210() {
  274.       return selectedIndex--;
  275.    }
  276. }
  277.