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

📄 myjxtaview.java

📁 myjxta是用jxta开发的一个p2p通讯软件 有聊天 文件共享 视频3大功能 界面采用swing
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* *  Copyright (c) 2001 Sun Microsystems, Inc.  All rights *  reserved. * *  Redistribution and use in source and binary forms, with or withouta *  modification, are permitted provided that the following conditions *  are met:addjxt * *  1. Redistributions of sourcec code must retain the above copyright *  notice, this list of conditions and the following disclaimer. * *  2. Redistributions in binary form must reproduce the above copyright *  notice, this list of conditions and the following discalimer in *  the documentation and/or other materials provided with the *  distribution.c * *  3. The end-user documentation included with the redistribution, *  if any, must include the following acknowledgment: *  "This product includes softgetware developed by the *  Sun Microsystems, Inc. for Project JXTA." *  Alternately, this acknowledgment may appear in the software itself, *  if and wherever such third-party acknowledgments normally appear. * *  4. The names "Sun", "Sun Microsystems, Inc.", "JXTA" and "Project JXTA" *  must not be used to endorse or promote products derived from this *  software without prior written permission. For written *  permission, please contact Project JXTA at http://www.jxta.org. * *  5. Products derived from this software may not be called "JXTA",s *  nor may "JXTA" appear in their name, without prior written *  permission of Sun. * *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *  SUCH DAMAGE. *  ===================================================tre================= * *  This software consists of voluntary contributions made by many *  individuals on behalf of Project JXTA.  For more *  information on Project JXTA, please see *  <http://www.jxta.org/>. * * *  $Id: MyJXTAView.java,v 1.110 2007/06/10 21:15:13 nano Exp $ */package net.jxta.myjxta.ui;import net.jxta.document.*;import net.jxta.myjxta.MyJXTA;import net.jxta.myjxta.View;import net.jxta.myjxta.dialog.Dialog;import net.jxta.myjxta.dialog.DialogMessage;import net.jxta.myjxta.dialog.OneToOneCommandDialog;import net.jxta.myjxta.dialog.util.Text;import net.jxta.myjxta.plugin.ISelectableNode;import net.jxta.myjxta.plugin.PluginContainer;import net.jxta.myjxta.plugin.PluginView;import net.jxta.myjxta.search.SearchContext;import net.jxta.myjxta.search.SearchManager;import net.jxta.myjxta.search.SearchModifier;import net.jxta.myjxta.search.Searcher;import net.jxta.myjxta.share.IShareManagerProvider;import net.jxta.myjxta.ui.action.ExitAction;import net.jxta.myjxta.ui.action.GroupJoinAction;import net.jxta.myjxta.ui.action.ShareViewAction;import net.jxta.myjxta.ui.model.JxtaTreeModel;import net.jxta.myjxta.util.*;import net.jxta.myjxta.util.exec.ExecFactory;import net.jxta.myjxta.util.objectmodel.GroupNode;import net.jxta.myjxta.util.objectmodel.JxtaNode;import net.jxta.myjxta.util.objectmodel.PeerNode;import net.jxta.myjxta.util.objectmodel.ShareNode;import net.jxta.myjxta.util.preferences.MyPreferencePanel;import net.jxta.peergroup.PeerGroup;import net.jxta.pipe.PipeService;import net.jxta.protocol.PeerGroupAdvertisement;import net.jxta.protocol.PipeAdvertisement;import org.jdesktop.swingx.JXFrame;import org.jdesktop.swingx.JXTreeTable;import javax.swing.*;import javax.swing.border.EmptyBorder;import javax.swing.border.EtchedBorder;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import javax.swing.tree.DefaultTreeCellRenderer;import javax.swing.tree.TreePath;import javax.swing.tree.TreeSelectionModel;import java.awt.*;import java.awt.datatransfer.DataFlavor;import java.awt.datatransfer.StringSelection;import java.awt.datatransfer.Transferable;import java.awt.datatransfer.UnsupportedFlavorException;import java.awt.dnd.*;import java.awt.event.*;import java.io.*;import java.lang.reflect.InvocationTargetException;import java.net.MalformedURLException;import java.net.URI;import java.net.URISyntaxException;import java.net.URL;import java.util.*;import java.util.List;import java.util.logging.Level;import java.util.logging.Logger;/** * @author james todd [gonzo at jxta dot org] * @author joe leach [coconatty at jxta dot org] * @version $Id: MyJXTAView.java,v 1.110 2007/06/10 21:15:13 nano Exp $ * @modified 2005-03-26 jamoore add general PlugInPanel type to removeDialog * @modified 2005-03-27 jamoore add vojxta to menus * @modified 2005-03-27 jamoore add vojxta add/remove dialog support * @modified 2005-04-24 jamoore add vijxta add/remove dialog support * @modified 2005-05-01 jamoore enable video only if system property is set */public final class MyJXTAView        extends JXFrame        implements View, PluginContainer.IPopupProvider {// ------------------------------ FIELDS ------------------------------    static final Logger LOG = Logger.getLogger(MyJXTAView.class.getName());    private static final int STATUS_MAX = 15;    private static final String DOT = ".";    private static final ResourceBundle STRINGS = Resources.getStrings();    private MyJXTA myjxta = null;    private JSplitPane split = null;    private JXTreeTable tree = null;    private JxtaTreeModel treeModel = null;    private JDialog searchDialog = null;    private JTabbedPane search = null;    private JDialog shareDialog = null;    private JTabbedPane share = null;    private JTabbedPane plugins = null;    private JTabbedPane m_navigationPane = null;    private DefaultComboBoxModel status = null;    private Action exitAction = null;    private JPopupMenu popup = null;    private final Object lock = new Object();    private final Dimension m_preferredSize = new Dimension(600, 375);    private ConfigData config = null;    private MenuManager m_menuManager;// --------------------------- CONSTRUCTORS ---------------------------    /**     * Default Constructor     *     * @param p_myjxta     */    public MyJXTAView(MyJXTA p_myjxta) {        super(MyJXTA.NAME);        setControl(p_myjxta);        initialize();    }    private void initialize() {        ui();        pack();    }    private void ui() {        Resources res = Resources.getInstance();        ImageIcon icon = res.getIconResource("Application.Icon");        if (icon != null) {            setIconImage(icon.getImage());        }        buildActions();        buildMenu();        buildUI();    }    private void buildActions() {        this.exitAction = new ExitAction(STRINGS.getString("menu.exit"), this.getControl());    }    private void buildMenu() {        m_menuManager = MenuManager.getInstance(this);        setJMenuBar(m_menuManager.getMenuBar());        //todo: why is it necessary to add the popup menu to the content pane?        getContentPane().add(this.popup =                buildPopupMenu(m_menuManager.getActionMenu().getMenuComponents()));    }    //set up popup menu, and add mouse listener (see internal class popuplistener)    private JPopupMenu buildPopupMenu(Component[] c) {        JPopupMenu jp = new JPopupMenu();        for (Component aC : c) {            jp.add(aC);        }        return jp;    }    private void buildUI() {        GridBagLayout gb = new GridBagLayout();        GridBagConstraints gbc = new GridBagConstraints();        getContentPane().setLayout(gb);        ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));        //sp.setViewportBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));        gbc.gridx = 0;        gbc.gridy = 0;        gbc.gridwidth = 1;        gbc.gridheight = 1;        gbc.insets = new Insets(3, 3, 3, 3);        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        gbc.fill = GridBagConstraints.BOTH;        JPanel newLeftComponent = buildNavigation();        JPanel newRightComponent = buildPlugins();        this.split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,                newLeftComponent, newRightComponent);//        this.split.setDividerLocation(0.3);        this.split.setResizeWeight(0.15);        this.split.setOneTouchExpandable(true);        this.split.setDividerSize(8);        gb.setConstraints(this.split, gbc);        getContentPane().add(this.split);        gbc.gridx = 0;        gbc.gridy++;        gbc.anchor = GridBagConstraints.LINE_START;        gbc.weightx = 0.0;        gbc.weighty = 0.0;        gbc.fill = GridBagConstraints.HORIZONTAL;        JPanel fp = buildFooter();        gb.setConstraints(fp, gbc);        getContentPane().add(fp);        addComponentListener(new ComponentAdapter() {            public void componentMoved(ComponentEvent we) {                componentResized(we);            }            public void componentResized(ComponentEvent we) {//                Rectangle b = getBounds();                MyJXTA myJXTA = MyJXTAView.this.getControl();                //nano: myJXTA can be null during the initial setup, so prevent the NPE here                if (myJXTA != null) {                    // todo: persist app size, location, etc//                    p.putInt(Prefs.UI_WIDTH, b.width);//                    p.putInt(Prefs.UI_HEIGHT, b.height);//                    p.putInt(Prefs.UI_X, b.x);//                    p.putInt(Prefs.UI_Y, b.y);                }            }        });        MyJXTAView.this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);        addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent we) {                MyJXTAView.this.getExitAction().actionPerformed(null);            }        });        addFocusListener(new FocusListener() {            public void focusGained(FocusEvent fe) {                toFront();            }            public void focusLost(FocusEvent fe) {                // Do nothing            }        });    }    private JPanel buildNavigation() {        JPanel p = new JPanel();        GridBagLayout gb = new GridBagLayout();        GridBagConstraints gbc = new GridBagConstraints();        p.setLayout(gb);        JScrollPane sp = new JScrollPane(this.tree = buildTree());        tree.getSelectionModel().addListSelectionListener(new ListSelectionListener() {            public void valueChanged(ListSelectionEvent arg0) {                m_menuManager.updateMenuStatus();            }        });        tree.getSelectionModel().addListSelectionListener(new ListSelectionListener() {            public void valueChanged(ListSelectionEvent e) {                m_menuManager.updateMenuStatus();            }        });        gbc.gridx = 0;        gbc.gridy = 0;        gbc.gridwidth = GridBagConstraints.REMAINDER;        gbc.gridheight = GridBagConstraints.RELATIVE;        gbc.insets = new Insets(3, 3, 3, 3);        gbc.anchor = GridBagConstraints.NORTHWEST;        gbc.weightx = 1.0;        gbc.weighty = 1.0;        gbc.fill = GridBagConstraints.BOTH;        gb.setConstraints(sp, gbc);        p.add(sp);        JComboBox quickSearchContext = new JComboBox(new DefaultComboBoxModel(new Object[]{                new SearchContext(STRINGS.getString("label.pipe.name"),                        Searcher.PIPE),                new SearchContext(STRINGS.getString("label.group.name"),                        Searcher.GROUP),                new SearchContext(STRINGS.getString("label.share.name"),                        Searcher.SHARE)        }));        gbc.gridy++;        gbc.gridwidth = GridBagConstraints.RELATIVE;        gbc.gridheight = GridBagConstraints.REMAINDER;        gbc.weightx = 0.0;        gbc.weighty = 0.0;        gbc.fill = GridBagConstraints.NONE;        gb.setConstraints(quickSearchContext, gbc);        p.add(quickSearchContext);        JTextField quickSearch = new JTextField(25);        quickSearch.addKeyListener(new QuickSearchKeyAdapter(quickSearchContext, this));        gbc.gridx++;        gbc.gridwidth = GridBagConstraints.REMAINDER;        gbc.weightx = 1.0;        gbc.fill = GridBagConstraints.HORIZONTAL;        gb.setConstraints(quickSearch, gbc);        p.add(quickSearch);        m_navigationPane = new JTabbedPane();        m_navigationPane.addChangeListener(new ChangeListener() {            public void stateChanged(ChangeEvent e) {                if (m_menuManager != null) {                    m_menuManager.updateMenuStatus();

⌨️ 快捷键说明

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