001: /*
002: * Copyright (c) 2000, Jacob Smullyan.
003: *
004: * This is part of SkunkDAV, a WebDAV client. See http://skunkdav.sourceforge.net/
005: * for the latest version.
006: *
007: * SkunkDAV is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License as published
009: * by the Free Software Foundation; either version 2, or (at your option)
010: * any later version.
011: *
012: * SkunkDAV 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: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with SkunkDAV; see the file COPYING. If not, write to the Free
019: * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
020: * 02111-1307, USA.
021: */
022:
023: package org.skunk.dav.client.gui;
024:
025: import java.awt.Event;
026: import java.awt.event.ActionEvent;
027: import java.awt.event.KeyEvent;
028: import java.util.Enumeration;
029: import java.util.Vector;
030: import javax.swing.JMenu;
031: import javax.swing.JMenuItem;
032: import javax.swing.KeyStroke;
033: import org.skunk.dav.client.gui.action.AddConnectionAction;
034: import org.skunk.dav.client.gui.action.ConnectionAction;
035: import org.skunk.dav.client.gui.action.RemoveConnectionAction;
036:
037: public class ConnectMenu extends JMenu {
038: private Explorer explorer;
039: private int displayLimit = 10;
040:
041: public ConnectMenu(Explorer explorer) {
042: super ();
043: this .explorer = explorer;
044: String label = ResourceManager
045: .getMessage(ResourceManager.CONNECT_PREVIOUS_KEY);
046: setText(label);
047: ServerData.init();
048: initComponents();
049: }
050:
051: public ConnectMenu(String text) {
052: super (text);
053: initComponents();
054: }
055:
056: public ConnectMenu(String text, boolean tearOff) {
057: super (text, tearOff);
058: initComponents();
059: }
060:
061: public void refresh() {
062: removeAll();
063: initComponents();
064: revalidate();
065: repaint();
066: }
067:
068: public int getDisplayLimit() {
069: return this .displayLimit;
070: }
071:
072: public void setDisplayLimit(int displayLimit) {
073: this .displayLimit = displayLimit;
074: }
075:
076: private void initComponents()
077: {
078: int incr=0;
079: for (Enumeration enum=((Vector)ServerData.getServers().clone()).elements();
080: incr<displayLimit && enum.hasMoreElements();
081: incr++)
082: {
083: ServerData sd=(ServerData) enum.nextElement();
084: final String host=sd.getHost();
085: final int port=sd.getPort();
086: final String initialPath=sd.getInitialPath();
087: JMenuItem item=new JMenuItem(sd.toString());
088: item.addActionListener(new ConnectionAction(explorer, sd));
089: item.setActionCommand(ConnectionAction.CONNECT_COMMAND);
090:// if (functionKeyIncrement<=9)
091:// {
092:// KeyStroke ks=KeyStroke.getKeyStroke(KeyEvent.VK_F1
093:// + (functionKeyIncrement++),
094:// Event.ALT_MASK);
095:// item.setAccelerator(ks);
096:// }
097: this .add(item);
098: }
099:
100: JMenuItem addItem=new JMenuItem(AddConnectionAction.ADD_CONNECTION_LABEL);
101: addItem.addActionListener(new AddConnectionAction());
102:// addItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
103:// Event.ALT_MASK));
104: this .add(addItem);
105:
106: JMenuItem removeItem=new JMenuItem(RemoveConnectionAction.REMOVE_CONNECTION_LABEL);
107: removeItem.addActionListener(new RemoveConnectionAction(explorer));
108:// removeItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,
109:// Event.ALT_MASK));
110: this .add(removeItem);
111: }
112: }
113:
114: /* $Log: ConnectMenu.java,v $
115: /* Revision 1.9 2001/01/05 08:01:12 smulloni
116: /* changes to the connection gui for the Explorer; added depth configurability to
117: /* propfind in the jpython test script; added an experimental "allprop" system
118: /* property which affects the propfind query type
119: /*
120: /* Revision 1.8 2000/12/19 22:36:05 smulloni
121: /* adjustments to preamble.
122: /*
123: /* Revision 1.7 2000/12/03 23:53:26 smulloni
124: /* added license and copyright preamble to java files.
125: /*
126: /* Revision 1.6 2000/11/09 23:34:54 smullyan
127: /* log added to every Java file, with the help of python. Lock stealing
128: /* implemented, and treatment of locks made more robust.
129: /* */
|