📄 myjxtaview.java
字号:
double propScale = i.getIconWidth() / (double) i.getIconHeight(); int maxHeight = 19; i = new ImageIcon(i.getImage().getScaledInstance((int) (maxHeight * propScale), maxHeight, Image.SCALE_SMOOTH)); l = new JLabel(i); l.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent me) { String u = STRINGS.getString("uri.sun"); try { ExecFactory.getExec().execDocument(new URL(u)); } catch (MalformedURLException mue) { if (LOG.isEnabledFor(Level.INFO)) { LOG.info("bad url: " + u); } } } }); l.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); infoPanel.add(l); fp.add(emptyPanel); infoPanel.setMinimumSize(new Dimension(280, 20)); infoPanel.setBorder(new EmptyBorder(-5, 0, -5, 0)); fp.add(infoPanel); fp.setName("FOOTER"); 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 JxtaConfigurable --------------------- public void configure(Configurator 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 (LOG.isEnabledFor(Level.ERROR)) { LOG.error("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 isExit = p.isExit(); if (isExit) { getExitAction().actionPerformed(null); } 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(this.config.getName()); configurator.setDescription(MyJXTA.VERSION); configurator.setSecurity(this.config.getName(), this.config.getPassword()); //configurator.setHome(new File(Env.getHome().getPath())); }// --------------------- 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(); SingleGroupNavigationPanel navigationForGroup = getNavigationForGroup(group); if (navigationForGroup != null) { navigationForGroup.updatePeerInfo((PeerNode) node); } 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; // ensures that even a null node is turned into a string. if (getTreeModel().add(node)) { if (LOG.isEnabledFor(Level.DEBUG)) { if (nodeString.length() < 100) { LOG.debug("Added JxtaNode " + nodeString); } else { LOG.debug("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 (LOG.isEnabledFor(Level.DEBUG)) { LOG.debug("Couldn't add JxtaNode " + nodeString); if (nodeString.length() > 100) { LOG.debug("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<PluginPanel> getPluginPanels() { List<PluginPanel> l = new ArrayList<PluginPanel>(); Component[] c = getPlugins().getComponents(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof PluginPanel) { l.add((PluginPanel) c[i]); } } return l; } /** * Add a dialog to the view. Creates a ChatDialogPanel 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) { PluginPanel dp = null; //this loop should be powerfull enought to handle all known DialogPanels for (Iterator<PluginPanel> p = getPluginPanels().iterator(); p.hasNext();) { dp = p.next(); if (dp.getDialog().equals(dialog)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -