001    /*
002     * $Id: ContextMenuAuxTextUI.java,v 1.5 2005/10/24 13:20:45 kleopatra Exp $
003     *
004     * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005     * Santa Clara, California 95054, U.S.A. All rights reserved.
006     *
007     * This library is free software; you can redistribute it and/or
008     * modify it under the terms of the GNU Lesser General Public
009     * License as published by the Free Software Foundation; either
010     * version 2.1 of the License, or (at your option) any later version.
011     * 
012     * This library is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015     * Lesser General Public License for more details.
016     * 
017     * You should have received a copy of the GNU Lesser General Public
018     * License along with this library; if not, write to the Free Software
019     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020     */
021    package org.jdesktop.swingx.plaf;
022    
023    import java.awt.Graphics;
024    import java.awt.Point;
025    import java.awt.Rectangle;
026    import java.awt.event.MouseListener;
027    
028    import javax.swing.JComponent;
029    import javax.swing.plaf.ComponentUI;
030    import javax.swing.plaf.TextUI;
031    import javax.swing.text.BadLocationException;
032    import javax.swing.text.EditorKit;
033    import javax.swing.text.JTextComponent;
034    import javax.swing.text.View;
035    import javax.swing.text.Position.Bias;
036    
037    /**
038     * @author Jeanette Winzenburg
039     */
040    public class ContextMenuAuxTextUI extends TextUI {
041    
042        private MouseListener mouseHandler;
043    
044        public static ComponentUI createUI(JComponent c) {
045            return new ContextMenuAuxTextUI(); 
046        }
047    
048        public void installUI(JComponent comp) {
049            comp.addMouseListener(getMouseListener());
050        }
051    
052        public void uninstallUI(JComponent comp) {
053            comp.removeMouseListener(getMouseListener());
054        }
055    
056    
057    
058        private MouseListener getMouseListener() {
059            if (mouseHandler == null) {
060                mouseHandler = createPopupHandler();
061            }
062            return mouseHandler;
063        }
064    
065        private MouseListener createPopupHandler() {
066            return new ContextMenuHandler(createContextSource());
067        }
068    
069        private ContextMenuSource createContextSource() {
070            return new TextContextMenuSource();
071        }
072    
073        public void update(Graphics g, JComponent c) {
074        }
075    
076        public Rectangle modelToView(JTextComponent t, int pos)
077                throws BadLocationException {
078            // TODO Auto-generated method stub
079            return null;
080        }
081    
082        public Rectangle modelToView(JTextComponent t, int pos, Bias bias)
083                throws BadLocationException {
084            // TODO Auto-generated method stub
085            return null;
086        }
087    
088        public int viewToModel(JTextComponent t, Point pt) {
089            // TODO Auto-generated method stub
090            return 0;
091        }
092    
093        public int viewToModel(JTextComponent t, Point pt, Bias[] biasReturn) {
094            // TODO Auto-generated method stub
095            return 0;
096        }
097    
098        public int getNextVisualPositionFrom(JTextComponent t, int pos, Bias b,
099                int direction, Bias[] biasRet) throws BadLocationException {
100            // TODO Auto-generated method stub
101            return 0;
102        }
103    
104        public void damageRange(JTextComponent t, int p0, int p1) {
105            // TODO Auto-generated method stub
106    
107        }
108    
109        public void damageRange(JTextComponent t, int p0, int p1, Bias firstBias,
110                Bias secondBias) {
111            // TODO Auto-generated method stub
112    
113        }
114    
115        public EditorKit getEditorKit(JTextComponent t) {
116            // TODO Auto-generated method stub
117            return null;
118        }
119    
120        public View getRootView(JTextComponent t) {
121            // TODO Auto-generated method stub
122            return null;
123        }
124    
125    }