⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 desktopmediator.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * DesktopMediator.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * */package org.executequery.base;import java.awt.BorderLayout;import java.awt.Component;import java.awt.Cursor;import java.beans.PropertyChangeEvent;import java.beans.PropertyChangeListener;import java.util.ArrayList;import java.util.List;import javax.swing.ActionMap;import javax.swing.BorderFactory;import javax.swing.Icon;import javax.swing.InputMap;import javax.swing.JFrame;import javax.swing.JLayeredPane;import javax.swing.SwingConstants;import javax.swing.SwingUtilities;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the  *           release of version 3.0.0beta1 has meant a  *           resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * * @author   Takis Diakoumis * @version  $Revision: 1.4 $ * @date     $Date: 2006/06/03 01:25:23 $ */public class DesktopMediator implements DockedTabDragListener {        // ----------------------------------    // property names for divider locations    // left-hand left-right split    public static final String LEFT_DIVIDER_LOCATION = "divider.location.left";        // right-hand left-right split    public static final String RIGHT_DIVIDER_LOCATION = "divider.location.right";        // left-hand top-bottom split    public static final String WEST_DIVIDER_LOCATION = "divider.location.west";        // center top-bottom split    public static final String CENTER_DIVIDER_LOCATION = "divider.location.center";        // right-hand top-bottom split    public static final String EAST_DIVIDER_LOCATION = "divider.location.east";    public static final String[] DIVIDER_LOCATION_KEYS = {                                            LEFT_DIVIDER_LOCATION,                                            RIGHT_DIVIDER_LOCATION,                                            WEST_DIVIDER_LOCATION,                                            CENTER_DIVIDER_LOCATION,                                            EAST_DIVIDER_LOCATION};        // ----------------------------------        /** the application frame */    private JFrame frame;        /** the application base panel */    private BaseApplicationPane baseWindowPane;        /** tab pane event listeners */    private List<DockedTabListener> tabListeners;    /** tab pane drag event listeners */    private List<DockedTabDragListener> tabDragListeners;    /** tab pane event listeners */    private List<PropertyChangeListener> propertyListeners;    // -------------------------------------------    // the application tab pane containers    // -------------------------------------------    /** the container at the WEST position */    private DockedTabContainer westContainer;    /** the container at the CENTER position */    private DockedTabContainer centerContainer;    /** the container at the EAST position */    private DockedTabContainer eastContainer;    // -------------------------------------------        /** prevent instantiation */    public DesktopMediator(JFrame frame) {        this.frame = frame;        baseWindowPane = new BaseApplicationPane(this);        /*        JPanel p = new JPanel();        p.setBackground(Color.RED);        frame.add(p, BorderLayout.CENTER);         */        baseWindowPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));                //BaseRootPane rootPane = new BaseRootPane(baseWindowPane);        //frame.add(rootPane, BorderLayout.CENTER);        frame.add(baseWindowPane, BorderLayout.CENTER);    }    /**     * Removes the specified docked tab listener.     *     * @param the listener     */    public void removeDockedTabListener(DockedTabListener listener) {        if (tabListeners == null) {            return;        }        tabListeners.remove(listener);    }        /**     * Adds the specified docked tab listener.     *     * @param the listener     */    public void addDockedTabListener(DockedTabListener listener) {        if (tabListeners == null) {            tabListeners = new ArrayList<DockedTabListener>();        }        tabListeners.add(listener);    }    /**     * Adds the specified docked tab listener.     *     * @param the listener     */    public void addDockedTabDragListener(DockedTabDragListener listener) {        if (tabDragListeners == null) {            tabDragListeners = new ArrayList<DockedTabDragListener>();        }        tabDragListeners.add(listener);    }    /**     * Notifies all registered listeners of a tab minimised event.     *     * @param the event      */    public void fireTabMinimised(DockedTabEvent e) {        if (tabListeners == null || tabListeners.size() == 0) {            return;        }        for (int i = 0, k = tabListeners.size(); i < k; i++) {            tabListeners.get(i).tabMinimised(e);        }    }    /**     * Notifies all registered listeners of a tab selected event.     *     * @param the event      */    public void fireTabSelected(DockedTabEvent e) {        if (tabListeners == null || tabListeners.isEmpty()) {            return;        }        for (int i = 0, k = tabListeners.size(); i < k; i++) {            tabListeners.get(i).tabSelected(e);        }    }    /**     * Notifies all registered listeners of a tab deselected event.     *     * @param the event      */    public void fireTabDeselected(DockedTabEvent e) {        if (tabListeners == null || tabListeners.isEmpty()) {            return;        }        for (int i = 0, k = tabListeners.size(); i < k; i++) {            tabListeners.get(i).tabSelected(e);        }    }        /**     * Notifies all registered listeners of a tab restored event.     *     * @param the event      */    protected void fireTabRestored(DockedTabEvent e) {        if (tabListeners == null || tabListeners.isEmpty()) {            return;        }        for (int i = 0, k = tabListeners.size(); i < k; i++) {            tabListeners.get(i).tabRestored(e);        }            }    /**     * Notifies all registered listeners of a tab closed event.     *     * @param the event      */    public void fireTabClosed(DockedTabEvent e) {        if (tabListeners == null || tabListeners.isEmpty()) {            return;        }        for (int i = 0, k = tabListeners.size(); i < k; i++) {            tabListeners.get(i).tabClosed(e);        }    }    /**     * Invoked when a mouse button is pressed on a tab and then dragged.     *     * @param the encapsulating event object     */    public void fireDockedTabDragged(DockedDragEvent e) {        if (tabDragListeners == null || tabDragListeners.size() == 0) {            return;        }        for (int i = 0, k = tabDragListeners.size(); i < k; i++) {            tabDragListeners.get(i).dockedTabDragged(e);        }    }     /**     *  Invoked when a mouse button has been released on a tab.     *     * @param the encapsulating event object     */    public void fireDockedTabReleased(DockedDragEvent e) {        if (tabDragListeners == null || tabDragListeners.size() == 0) {            return;        }        for (int i = 0, k = tabDragListeners.size(); i < k; i++) {            tabDragListeners.get(i).dockedTabReleased(e);        }            }    public ActionMap getActionMap() {        return baseWindowPane.getActionMap();    }        /**      * Retrieves the applications <code>InputMap</code>.     *     * @return the <code>InputMap</code>     */    public InputMap getInputMap(int condition) {        return baseWindowPane.getInputMap(condition);    }    /**     * Sets the frame's cursor to that specified.     *     * @param the cursor to be set on the frame     */    public void setFrameCursor(Cursor cursor) {        frame.setCursor(cursor);    }        public void addPropertyChangeListener(PropertyChangeListener l) {        if (propertyListeners == null) {            propertyListeners = new ArrayList<PropertyChangeListener>();        }        propertyListeners.add(l);    }        public void firePropertyChange(String name, int oldValue, int newValue) {        if (propertyListeners == null || propertyListeners.isEmpty()) {            return;        }        PropertyChangeEvent e = new PropertyChangeEvent(                this, name, new Integer(oldValue), new Integer(newValue));        for (int i = 0, k = propertyListeners.size(); i < k; i++) {            propertyListeners.get(i).propertyChange(e);        }    }    /**     * Sets the split pane divider location for the split pane     * with the specified key name to the specified value.     *     * @param the split pane location     * @param the divider location     */    public void setSplitPaneDividerLocation(String key, int location) {        if (location <= 0) {            return;        }        int position = -1;        if (key.equals(LEFT_DIVIDER_LOCATION)) {            position = SwingConstants.LEFT;        }        else if (key.equals(RIGHT_DIVIDER_LOCATION)) {            position = SwingConstants.RIGHT;        }        else if (key.equals(WEST_DIVIDER_LOCATION)) {            position = SwingConstants.WEST;        }        else if (key.equals(CENTER_DIVIDER_LOCATION)) {            position = SwingConstants.CENTER;        }        else if (key.equals(EAST_DIVIDER_LOCATION)) {            position = SwingConstants.EAST;        }                if (position != -1) {            setSplitPaneDividerLocation(position, location);        }    }    /**     * Indicates a focus change on the tab components and their containers.     *     * @param tabPane - the new focused tab container     */    protected void tabPaneFocusChange(DockedTabContainer tabContainer) {        DockedTabContainer[] dtca = {westContainer, centerContainer, eastContainer};        for (int i = 0; i < dtca.length; i++) {            DockedTabContainer dtc = dtca[i];            if (dtc != null && dtc != tabContainer) {                dtc.tabPaneFocusLost();            }        }    }    /**     * Sets the split pane divider location for the split pane     * at the specified location to the specified value.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -