home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.plaf.basic;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Cursor;
- import java.awt.Dimension;
- import java.awt.IllegalComponentStateException;
- import java.awt.LayoutManager;
- import java.awt.Rectangle;
- import java.awt.event.ComponentListener;
- import java.beans.PropertyChangeListener;
- import javax.swing.ActionMap;
- import javax.swing.DefaultDesktopManager;
- import javax.swing.DesktopManager;
- import javax.swing.Icon;
- import javax.swing.InputMap;
- import javax.swing.JComponent;
- import javax.swing.JInternalFrame;
- import javax.swing.KeyStroke;
- import javax.swing.LookAndFeel;
- import javax.swing.SwingUtilities;
- import javax.swing.UIManager;
- import javax.swing.event.InternalFrameListener;
- import javax.swing.event.MouseInputAdapter;
- import javax.swing.event.MouseInputListener;
- import javax.swing.plaf.ActionMapUIResource;
- import javax.swing.plaf.ComponentUI;
- import javax.swing.plaf.InternalFrameUI;
- import javax.swing.plaf.UIResource;
-
- public class BasicInternalFrameUI extends InternalFrameUI {
- protected JInternalFrame frame;
- protected MouseInputAdapter borderListener;
- protected PropertyChangeListener propertyChangeListener;
- protected LayoutManager internalFrameLayout;
- protected ComponentListener componentListener;
- protected MouseInputListener glassPaneDispatcher;
- protected JComponent northPane;
- protected JComponent southPane;
- protected JComponent westPane;
- protected JComponent eastPane;
- protected BasicInternalFrameTitlePane titlePane;
- private static DesktopManager sharedDesktopManager;
- private boolean componentListenerAdded = false;
- private Rectangle parentBounds = null;
- protected KeyStroke openMenuKey;
- private boolean keyBindingRegistered = false;
- private boolean keyBindingActive = false;
- private InternalFrameListener internalFrameListener = null;
-
- public static ComponentUI createUI(JComponent var0) {
- return new BasicInternalFrameUI((JInternalFrame)var0);
- }
-
- public BasicInternalFrameUI(JInternalFrame var1) {
- }
-
- public void installUI(JComponent var1) {
- this.frame = (JInternalFrame)var1;
- this.frame.add(this.frame.getRootPane(), "Center");
- this.installDefaults();
- this.installComponents();
- this.installListeners();
- this.installKeyboardActions();
- this.setNorthPane(this.createNorthPane(this.frame));
- this.setSouthPane(this.createSouthPane(this.frame));
- this.setEastPane(this.createEastPane(this.frame));
- this.setWestPane(this.createWestPane(this.frame));
- this.frame.setOpaque(true);
- int var2 = (this.getNorthPane() != null ? this.getNorthPane().getMinimumSize().height : 0) + this.frame.getInsets().top + this.frame.getInsets().bottom;
- this.frame.setMinimumSize(new Dimension(120, var2));
- }
-
- public void uninstallUI(JComponent var1) {
- if (var1 != this.frame) {
- throw new IllegalComponentStateException(this + " was asked to deinstall() " + var1 + " when it only knows about " + this.frame + ".");
- } else {
- this.uninstallDefaults();
- this.uninstallComponents();
- this.frame.setCursor(Cursor.getPredefinedCursor(0));
- this.setNorthPane((JComponent)null);
- this.setSouthPane((JComponent)null);
- this.setEastPane((JComponent)null);
- this.setWestPane((JComponent)null);
- this.uninstallListeners();
- this.uninstallKeyboardActions();
- this.frame.remove(this.frame.getRootPane());
- this.frame = null;
- }
- }
-
- protected void installDefaults() {
- Icon var1 = this.frame.getFrameIcon();
- if (var1 == null || var1 instanceof UIResource) {
- this.frame.setFrameIcon(UIManager.getIcon("InternalFrame.icon"));
- }
-
- JComponent var2 = (JComponent)this.frame.getContentPane();
- if (var2 != null) {
- Color var3 = ((Component)var2).getBackground();
- if (var3 instanceof UIResource) {
- var2.setBackground((Color)null);
- }
- }
-
- LookAndFeel.installBorder(this.frame, "InternalFrame.border");
- }
-
- protected void installKeyboardActions() {
- if (this.internalFrameListener == null) {
- this.createInternalFrameListener();
- }
-
- this.frame.addInternalFrameListener(this.internalFrameListener);
- }
-
- protected void installComponents() {
- }
-
- protected void installListeners() {
- this.borderListener = this.createBorderListener(this.frame);
- this.propertyChangeListener = this.createPropertyChangeListener();
- this.frame.addPropertyChangeListener(this.propertyChangeListener);
- this.frame.setLayout(this.internalFrameLayout = this.createLayoutManager());
- this.installMouseHandlers(this.frame);
- this.glassPaneDispatcher = this.createGlassPaneDispatcher();
- this.frame.getGlassPane().addMouseListener(this.glassPaneDispatcher);
- this.frame.getGlassPane().addMouseMotionListener(this.glassPaneDispatcher);
- this.componentListener = this.createComponentListener();
- if (this.frame.getParent() != null && !this.componentListenerAdded) {
- this.frame.getParent().addComponentListener(this.componentListener);
- this.componentListenerAdded = true;
- this.parentBounds = this.frame.getParent().getBounds();
- }
-
- }
-
- InputMap getInputMap(int var1) {
- return var1 == 2 ? this.createInputMap(var1) : null;
- }
-
- InputMap createInputMap(int var1) {
- if (var1 == 2) {
- Object[] var2 = UIManager.get("InternalFrame.windowBindings");
- if (var2 != null) {
- return LookAndFeel.makeComponentInputMap(this.frame, var2);
- }
- }
-
- return null;
- }
-
- ActionMap getActionMap() {
- return this.createActionMap();
- }
-
- ActionMap createActionMap() {
- ActionMapUIResource var1 = new ActionMapUIResource();
- ((ActionMap)var1).put("showSystemMenu", new 1(this));
- return var1;
- }
-
- protected void uninstallDefaults() {
- Icon var1 = this.frame.getFrameIcon();
- if (var1 instanceof UIResource) {
- this.frame.setFrameIcon((Icon)null);
- }
-
- LookAndFeel.uninstallBorder(this.frame);
- }
-
- protected void uninstallComponents() {
- }
-
- protected void uninstallListeners() {
- this.deinstallMouseHandlers(this.frame);
- this.frame.removePropertyChangeListener(this.propertyChangeListener);
- this.frame.setLayout((LayoutManager)null);
- this.internalFrameLayout = null;
- this.propertyChangeListener = null;
- this.frame.getGlassPane().removeMouseListener(this.glassPaneDispatcher);
- this.frame.getGlassPane().removeMouseMotionListener(this.glassPaneDispatcher);
- if (this.frame.getParent() != null && this.componentListenerAdded) {
- this.frame.getParent().removeComponentListener(this.componentListener);
- this.componentListenerAdded = false;
- }
-
- this.glassPaneDispatcher = null;
- this.componentListener = null;
- this.borderListener = null;
- }
-
- protected void uninstallKeyboardActions() {
- if (this.internalFrameListener != null) {
- this.frame.removeInternalFrameListener(this.internalFrameListener);
- }
-
- if (this.isKeyBindingRegistered()) {
- SwingUtilities.replaceUIInputMap(this.frame, 2, (InputMap)null);
- SwingUtilities.replaceUIActionMap(this.frame, (ActionMap)null);
- }
-
- }
-
- protected LayoutManager createLayoutManager() {
- return new InternalFrameLayout(this);
- }
-
- protected PropertyChangeListener createPropertyChangeListener() {
- return new InternalFramePropertyChangeListener(this);
- }
-
- public Dimension getPreferredSize(JComponent var1) {
- return this.frame == var1 ? this.frame.getLayout().preferredLayoutSize(var1) : new Dimension(100, 100);
- }
-
- public Dimension getMinimumSize(JComponent var1) {
- return this.frame == var1 ? this.frame.getLayout().minimumLayoutSize(var1) : new Dimension(0, 0);
- }
-
- public Dimension getMaximumSize(JComponent var1) {
- return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
- }
-
- protected void replacePane(JComponent var1, JComponent var2) {
- if (var1 != null) {
- this.deinstallMouseHandlers(var1);
- this.frame.remove(var1);
- }
-
- if (var2 != null) {
- this.frame.add(var2);
- this.installMouseHandlers(var2);
- }
-
- }
-
- protected void deinstallMouseHandlers(JComponent var1) {
- ((Component)var1).removeMouseListener(this.borderListener);
- ((Component)var1).removeMouseMotionListener(this.borderListener);
- }
-
- protected void installMouseHandlers(JComponent var1) {
- ((Component)var1).addMouseListener(this.borderListener);
- ((Component)var1).addMouseMotionListener(this.borderListener);
- }
-
- protected JComponent createNorthPane(JInternalFrame var1) {
- this.titlePane = new BasicInternalFrameTitlePane(var1);
- return this.titlePane;
- }
-
- protected JComponent createSouthPane(JInternalFrame var1) {
- return null;
- }
-
- protected JComponent createWestPane(JInternalFrame var1) {
- return null;
- }
-
- protected JComponent createEastPane(JInternalFrame var1) {
- return null;
- }
-
- protected MouseInputAdapter createBorderListener(JInternalFrame var1) {
- return new BorderListener(this);
- }
-
- private InternalFrameListener getInternalFrameListener() {
- return this.internalFrameListener;
- }
-
- protected void createInternalFrameListener() {
- this.internalFrameListener = new BasicInternalFrameListener(this);
- }
-
- protected final boolean isKeyBindingRegistered() {
- return this.keyBindingRegistered;
- }
-
- protected final void setKeyBindingRegistered(boolean var1) {
- this.keyBindingRegistered = var1;
- }
-
- public final boolean isKeyBindingActive() {
- return this.keyBindingActive;
- }
-
- protected final void setKeyBindingActive(boolean var1) {
- this.keyBindingActive = var1;
- }
-
- protected void setupMenuOpenKey() {
- InputMap var1 = this.getInputMap(2);
- SwingUtilities.replaceUIInputMap(this.frame, 2, var1);
- ActionMap var2 = this.getActionMap();
- SwingUtilities.replaceUIActionMap(this.frame, var2);
- }
-
- protected void setupMenuCloseKey() {
- }
-
- public JComponent getNorthPane() {
- return this.northPane;
- }
-
- public void setNorthPane(JComponent var1) {
- this.replacePane(this.northPane, var1);
- this.northPane = var1;
- }
-
- public JComponent getSouthPane() {
- return this.southPane;
- }
-
- public void setSouthPane(JComponent var1) {
- this.southPane = var1;
- }
-
- public JComponent getWestPane() {
- return this.westPane;
- }
-
- public void setWestPane(JComponent var1) {
- this.westPane = var1;
- }
-
- public JComponent getEastPane() {
- return this.eastPane;
- }
-
- public void setEastPane(JComponent var1) {
- this.eastPane = var1;
- }
-
- protected DesktopManager getDesktopManager() {
- if (this.frame.getDesktopPane() != null && this.frame.getDesktopPane().getDesktopManager() != null) {
- return this.frame.getDesktopPane().getDesktopManager();
- } else {
- if (sharedDesktopManager == null) {
- sharedDesktopManager = this.createDesktopManager();
- }
-
- return sharedDesktopManager;
- }
- }
-
- protected DesktopManager createDesktopManager() {
- return new DefaultDesktopManager();
- }
-
- protected void closeFrame(JInternalFrame var1) {
- this.getDesktopManager().closeFrame(var1);
- }
-
- protected void maximizeFrame(JInternalFrame var1) {
- this.getDesktopManager().maximizeFrame(var1);
- }
-
- protected void minimizeFrame(JInternalFrame var1) {
- this.getDesktopManager().minimizeFrame(var1);
- }
-
- protected void iconifyFrame(JInternalFrame var1) {
- this.getDesktopManager().iconifyFrame(var1);
- }
-
- protected void deiconifyFrame(JInternalFrame var1) {
- this.getDesktopManager().deiconifyFrame(var1);
- }
-
- protected void activateFrame(JInternalFrame var1) {
- this.getDesktopManager().activateFrame(var1);
- }
-
- protected void deactivateFrame(JInternalFrame var1) {
- this.getDesktopManager().deactivateFrame(var1);
- }
-
- protected ComponentListener createComponentListener() {
- return new ComponentHandler(this);
- }
-
- protected MouseInputListener createGlassPaneDispatcher() {
- return new GlassPaneDispatcher(this);
- }
-
- // $FF: synthetic method
- static boolean access$000(BasicInternalFrameUI var0) {
- return var0.componentListenerAdded;
- }
-
- // $FF: synthetic method
- static boolean access$002(BasicInternalFrameUI var0, boolean var1) {
- return var0.componentListenerAdded = var1;
- }
-
- // $FF: synthetic method
- static Rectangle access$102(BasicInternalFrameUI var0, Rectangle var1) {
- return var0.parentBounds = var1;
- }
-
- // $FF: synthetic method
- static Rectangle access$100(BasicInternalFrameUI var0) {
- return var0.parentBounds;
- }
-
- // $FF: synthetic method
- static InternalFrameListener access$200(BasicInternalFrameUI var0) {
- return var0.internalFrameListener;
- }
- }
-