?? myjxtaview.java
字號:
return fp; }// --------------------- GETTER / SETTER METHODS --------------------- /** * Returns the preferred size of this container. * * @return an instance of <code>Dimension</code> that represents * the preferred size of this container. * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container) * @see java.awt.Component#getPreferredSize */ public Dimension getPreferredSize() { return m_preferredSize; }// ------------------------ INTERFACE METHODS ------------------------// --------------------- Interface ConfigurationView --------------------- /** * @param configurator * @return true if the configuration was sucessfull * false if the user has choosen "advanced" */ public boolean configure(PlatformConfigAccess configurator) { setStatus(STRINGS.getString("status.setup")); List<URL> configs = new ArrayList<URL>(); String ec = System.getProperty(Env.CONFIG_URL); if (ec != null) { try { configs.add(new URL(ec)); } catch (MalformedURLException mue) { if (net.jxta.logging.Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected Exception", mue); } } } configs.add(Env.getConfiguration()); ConfigurationPanel p = new ConfigurationPanel(configs); JDialog jd = new JDialog(this, STRINGS.getString("title.configurator"), true); jd.getContentPane().add(p); jd.pack(); jd.setLocationRelativeTo(this); jd.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { MyJXTAView.this.getExitAction().actionPerformed(null); } }); jd.setVisible(true); boolean isAdvanced = p.useStandardPlatformConfiguratorUI(); if (isAdvanced) { return false; } this.config = new ConfigData(p.getPeerName(), p.getPassword()); URL hp = p.getHttpProxy(); Constants c = Constants.getInstance(); c.set(Constants.PROXY_HTTP, hp != null ? hp.toString() : ""); c.save(); setStatus(STRINGS.getString("status.configure")); configurator.setName(p.getPeerName()); configurator.setDescription(MyJXTA.VERSION); configurator.setSecurity(p.getPeerName(), p.getPassword()); //configurator.setHome(new File(Env.getHome().getPath())); return true; }// --------------------- Interface View --------------------- public void setVisible(final boolean isVisible) { if (isVisible) { setLocation(); super.setVisible(isVisible); toFront(); setStatus(MyJXTA.VERSION); } else { super.setVisible(isVisible); } } public void setTitle(final String title) { EventQueue.invokeLater(new Runnable() { public void run() { MyJXTAView.super.setTitle(STRINGS.getString("title.myjxta") + ((title != null && title.trim().length() > 0) ? " : " + title.trim() : "")); } }); } public void setControl(MyJXTA myjxta) { this.myjxta = myjxta; getControl().getPluginContainer().registerPopupProvider(this); } public MyJXTA getControl() { return this.myjxta; } public JTabbedPane getNavigationPane() { return m_navigationPane; } public JxtaNode getJxtaNode(Class c) { Object o = null; JxtaNode n = null; if (c != null && JxtaNode.class.isAssignableFrom(c) && m_navigationPane != null) { Component selectedComponent = m_navigationPane.getSelectedComponent(); if (selectedComponent instanceof SingleGroupNavigationPanel) { //Special handling for the Group right now if (c == GroupNode.class) { return new GroupNode(((SingleGroupNavigationPanel) selectedComponent).getGroup()); } //navigation tree is not visible, ask the PluginContainer ISelectableNode[] selection = getControl().getPluginContainer().getSelectedNodes(); if (selection.length >= 1) { n = selection[0].getJxtaNode(); } } else { //the old way for now TreePath tp = getTreeTable().getTreeSelectionModel().getSelectionPath(); o = tp != null ? tp.getLastPathComponent() : null; } } if (o != null && o instanceof JxtaNode) { n = (JxtaNode) o; } if (n != null) { while (n != null && !c.isAssignableFrom(n.getClass())) { n = n.getParent(); } } return n; } public void addJxtaNode(final JxtaNode node) { addJxtaNode(node, false); } public void addJxtaNode(final JxtaNode node, boolean select) { if (node instanceof PeerNode) {// Peer peer=((PeerNode)node).getPeer(); Group group = ((GroupNode) node.getParent()).getGroup();// int count=m_navigationPane.getComponentCount(); getTreeModel().ensurePeerNodeHasVisibleParent((PeerNode) node); GroupNode n = (GroupNode) node.getParent(); while (n != null) { if (!n.isLeaf()) { getTreeTable().expandPath(new TreePath(n.getPath())); } n = (GroupNode) n.getParent(); } return; // we dont want peer nodes inside the Network tab if we are running with the new group tabs } EventQueue.invokeLater(new Runnable() { public void run() { String nodeString = "" + node; if (getTreeModel().add(node)) { if (net.jxta.logging.Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { if (nodeString.length() < 100) { LOG.fine("Added JxtaNode " + nodeString); } else { LOG.fine("Added Long JxtaNode Name: " + Text.hexDump(nodeString)); } } LOG.info(STRINGS.getString("status.resource.add") + ": " + nodeString); JxtaNode n = node; while (n != null) { if (!n.isLeaf()) { getTreeTable().expandPath(new TreePath(n.getPath())); } n = n.getParent(); } } else { if (net.jxta.logging.Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.fine("Couldn\'t add JxtaNode " + nodeString); if (nodeString.length() > 100) { LOG.fine("Added Long JxtaNode Name: " + Text.hexDump(nodeString)); } setStatus(STRINGS.getString("error.resource.add.invalid") + ": " + nodeString); } } } }); if (select) { selectJxtaNode(node); } } public void removeJxtaNode(final JxtaNode node) { EventQueue.invokeLater(new Runnable() { public void run() { getTreeModel().remove(node); } }); } public void updateJxtaNode(final JxtaNode node) { EventQueue.invokeLater(new Runnable() { public void run() { getTreeModel().nodeChanged(node); } }); } public JTabbedPane getSearch() { return this.search == null ? buildSearch() : this.search; } public void addSearch(int search) { addSearchPanel(new SearchPanel(this, search)); } public void addSearchPanel(final JPanel p) { setStatus(STRINGS.getString("status.search.initialized")); EventQueue.invokeLater(new Runnable() { public void run() { JDialog d = getSearchDialog(); JTabbedPane tp = getSearch(); tp.add(p); d.pack(); d.setVisible(true); tp.setSelectedComponent(p); } }); }// public void removeSearch(final JPanel sp)// {// EventQueue.invokeLater(new Runnable()// {// public void run()// {// getSearch().remove(sp);// }// });// } public JTabbedPane getShare() { return this.share == null ? buildShare() : this.share; } public void addSharePanel(final JPanel p) { setStatus(STRINGS.getString("status.share.initialized")); EventQueue.invokeLater(new Runnable() { public void run() { JDialog d = getShareDialog(); JTabbedPane tp = getShare(); tp.add(p); d.pack(); d.setVisible(true); tp.setSelectedComponent(p); } }); } public void removeShare(final JPanel sp) { EventQueue.invokeLater(new Runnable() { public void run() { getShare().remove(sp); } }); } public List<PluginView> getPluginPanels() { List<PluginView> l = new ArrayList<PluginView>(); Component[] c = getPlugins().getComponents(); for (Component aC : c) { if (aC instanceof PluginView) { l.add((PluginView) aC); } } return l; } /** * Add a dialog to the view. Creates a ChatDialogView to represent * that dialog, and returns it. * * @param dialog the dialog to be added. * @modified 2005-02-26 jamoore@jxta.org - added vojxta dialog support * @modified 2005-04-24 jamoore added vijxta dialog support */ public void addDialog(Dialog dialog) { String dialogName = dialog.getName(); JPanel panel = (JPanel) dialog.getDialogPanel(this); //ask the dialog itself which panel it has to provide addDialogPanel(dialogName, panel, dialog.isSecure()); } /** * Remove a dialogs UI resources. Effectively delete the dialogs tab from * plugins. * * @modified 2005-03-31 jamoore add vojxtadialogpanel support * @modified 2005-04-24 jamoore add vijxtadialogpanel support */ public void removeDialog(Dialog dialog) { PluginView dp; //this loop should be powerfull enought to handle all known DialogPanels for (PluginView pluginView : getPluginPanels()) { dp = pluginView; if (dp.getDialog().equals(dialog)) { dp.dismiss(); if (dp instanceof JPanel) { removeDialogPanel((JPanel) dp); } else { LOG.severe("DialogPanel IS NO JPanel!"); } } } } public void showPreferences() { JDialog jd = new JDialog(this, STRINGS.getString("title.preferences"), true); MyPreferencePanel pp = new MyPreferencePanel(); jd.getContentPane().add(pp); jd.pack(); jd.setLocationRelativeTo(this);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -