?? myjxtaview.java
字號:
jd.setModal(false); jd.setVisible(true); } public void updatePluginPanel(PluginView p, final String title) { final JTabbedPane tp = getPlugins(); final Component pFin; final int i = tp.indexOfComponent((Component) p); pFin = (Component) p; if (i > -1) { final Resources res = Resources.getInstance(); EventQueue.invokeLater(new Runnable() { public void run() { int iNow = tp.indexOfComponent(pFin); if (iNow > -1) { tp.setForegroundAt(iNow, (tp.getSelectedIndex() == iNow ? res.getColorResource("TabPane.Selectrdved") : res.getColorResource("TabPane.Unselected"))); if (title != null && title.trim().length() > 0 && !DialogMessage.DEFAULT_ORIGINATOR.equals(title) && !DialogMessage.DEFAULT_GROUP.equals(title)) { tp.setTitleAt(iNow, title); } } } }); } } /** * @return Returns the exitAction. */ public Action getExitAction() { return this.exitAction; }// -------------------------- OTHER METHODS -------------------------- private void addDialogPanel(final String label, final JPanel p, boolean isSecure) { setStatus(STRINGS.getString("status.dialog.join"));// String in = isSecure ? "Dialog.Secure" : "Dialog.UnSecure";// final Icon i = Resources.getInstance().getIconResource(in); EventQueue.invokeLater(new Runnable() { public void run() { getPlugins().addTab(label, p); getPlugins().setSelectedComponent(p);// Rectangle b = getPreferredBounds();// // setSize(new Dimension(Math.max(b.width, Prefs.Default.UI_WIDTH),// Math.max(b.height, Prefs.Default.UI_HEIGHT))); split.resetToPreferredSizes(); } }); } /** * @return Returns the plugins. */ JTabbedPane getPlugins() { return plugins; } public JDialog getSearchDialog() { synchronized (this.lock) { if (this.searchDialog == null) { this.searchDialog = new JDialog(this, STRINGS.getString("label.search")); this.searchDialog.setLocationRelativeTo(this); this.searchDialog.addComponentListener(new ComponentAdapter() { public void componentHidden(ComponentEvent ce) { Component[] cs = getSearchDialog().getContentPane().getComponents(); for (Component c : cs) { if (c instanceof JTabbedPane) { JTabbedPane tp = (JTabbedPane) c; while (tp.getTabCount() > 0) { tp.removeTabAt(0); } } } } }); this.searchDialog.getContentPane().add(this.search = buildSearch()); } } return this.searchDialog; } private JTabbedPane buildSearch() { ClosableTabbedPane tp = new ClosableTabbedPane(JTabbedPane.BOTTOM, JTabbedPane.WRAP_TAB_LAYOUT); tp.addListener(new DismissListener() { public void dismissEvent() { if (getSearch().getTabCount() == 0) { getSearchDialog().setVisible(false); } } }); return tp; } public JDialog getShareDialog() { synchronized (this.lock) { if (this.shareDialog == null) { this.shareDialog = new JDialog(this, STRINGS.getString("label.share")); this.shareDialog.setLocationRelativeTo(this); this.shareDialog.addComponentListener(new ComponentAdapter() { public void componentHidden(ComponentEvent ce) { Component[] cs = getShareDialog().getContentPane().getComponents(); for (Component c : cs) { if (c instanceof JTabbedPane) { JTabbedPane tp = (JTabbedPane) c; while (tp.getTabCount() > 0) { tp.removeTabAt(0); } } } } }); this.shareDialog.getContentPane().add(this.share = buildShare()); } } return this.shareDialog; } private JTabbedPane buildShare() { ClosableTabbedPane tp = new ClosableTabbedPane(JTabbedPane.LEFT, JTabbedPane.SCROLL_TAB_LAYOUT); tp.addListener(new DismissListener() { public void dismissEvent() { if (getShare().getTabCount() == 0) { getShareDialog().setVisible(false); } } }); return tp; } /** * @return Returns the status. */ DefaultComboBoxModel getStatus() { return status; } public JxtaTreeModel getTreeModel() { return this.treeModel; } public void removeDialogPanel(final JPanel p) { EventQueue.invokeLater(new Runnable() { public void run() { getPlugins().remove(p); split.resetToPreferredSizes(); } }); } public void selectJxtaNode(final JxtaNode n) { if (n != null) { EventQueue.invokeLater(new Runnable() { public void run() { TreePath tp = n != null ? new TreePath(n.getPath()) : null; if (tp != null) { getTreeTable().getTreeSelectionModel().setSelectionPath(tp); } } }); } } private void setLocation() { final Rectangle b = getPreferredBounds(); final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); try { EventQueue.invokeAndWait(new Runnable() { public void run() { // xxx: not in 1.5 // setPreferredSize(new Dimension(b.width, b.height)); //setSize(new Dimension(b.width, b.height)); //setBounds(b); setLocation(b.x != Prefs.Default.UI_X ? b.x : screen.width / 2 - b.width / 2, b.y != Prefs.Default.UI_Y ? b.y : screen.height / 2 - b.height / 2); } }); } catch (InterruptedException ie) { if (net.jxta.logging.Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected Exception", ie); } } catch (InvocationTargetException tie) { if (net.jxta.logging.Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected Exception", tie); } } } private Rectangle getPreferredBounds() { // todo: infer from preferences when available return new Rectangle(Prefs.Default.UI_X, Prefs.Default.UI_Y, Prefs.Default.UI_WIDTH, Prefs.Default.UI_HEIGHT); } public void setTitle() { setTitle(null); } public ConfigData getConfig() { return this.config; } //nano: this one is not used right now?// private boolean share(String s)// {// boolean isValid = false;// URI u = null;//// try {// u = s != null ? new URI(s) : null;// }// catch(URISyntaxException use) {// if(LOG.isEnabledFor(Level.SEVERE)) {// LOG.error("Caught unexpected Exception", use);// }// }//// return isValid;// }// -------------------------- INNER CLASSES -------------------------- private class MyTableTransferHandler extends TransferHandler { public Transferable createTransferable(JComponent c) { JxtaNode jn = getJxtaNode(JxtaNode.class); Advertisement a = jn != null ? getAdvertisement(jn) : null; return new StringSelection(a != null ? a.toString() : null); } public int getSourceActions(JComponent c) { return COPY; } private Advertisement getAdvertisement(JxtaNode jn) { Advertisement a = null; if (jn instanceof PeerNode) { Peer p = ((PeerNode) jn).getPeer(); a = p != null ? p.getPipeAdvertisement() : null; } else if (jn instanceof GroupNode) { Group g = ((GroupNode) jn).getGroup(); a = g != null ? g.getPeerGroupAdvertisement() : null; } return a; } } /** * //review relevant * Tree Cell renderer for the Group/Navigation Table */ private static class MyDefaultTreeCellRenderer extends DefaultTreeCellRenderer { public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { //nano: dont generate an own renderer instance here, simply set the icons and let //the super instance do the selected/deselected,hasFocus stuff... setLeafIcon(((JxtaNode) value).getImage(selected, true, hasFocus)); setOpenIcon(((JxtaNode) value).getImage(selected, true, hasFocus)); setClosedIcon(((JxtaNode) value).getImage(selected, false, hasFocus)); return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); } } private class MyDropTargetListener implements DropTargetListener { private TreePath oldSelectionPath = null; public void dragEnter(DropTargetDragEvent dtde) { oldSelectionPath = getTreeTable().getTreeSelectionModel().getSelectionPath(); } public void dragExit(DropTargetEvent dte) { getTreeTable().getTreeSelectionModel().setSelectionPath(oldSelectionPath); oldSelectionPath = null; } public void dragOver(DropTargetDragEvent dtde) { JXTreeTable treeTable = getTreeTable(); int row = treeTable.rowAtPoint(dtde.getLocation()); if (row != -1) { treeTable.getSelectionModel().setSelectionInterval(row, row); } Object o = treeTable.getValueAt(row, 0); if (o instanceof JxtaNode) { TreePath tp = getTreeTable().getTreeSelectionModel().getSelectionPath(); TreePath groupPath = findDeepestJoinedGroup(tp); if (groupPath != null) { getTreeTable().getTreeSelectionModel().setSelectionPath(groupPath); dtde.acceptDrag(DnDConstants.ACTION_COPY); } else { dtde.rejectDrag(); } } } public void drop(DropTargetDropEvent dtde) { Transferable t = dtde.getTransferable(); Object d = null; if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrop(DnDConstants.ACTION_COPY); try { d = t.getTransferData(DataFlavor.javaFileListFlavor); } catch (UnsupportedFlavorException use) { if (net.jxta.logging.Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected Exception", use); } } catch (IOException ioe) { if (net.jxta.logging.Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, "Caught unexpected Exception", ioe); } } } else if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { dtde.acceptDrop(DnDConstants.ACTION_COPY); try { d = t.getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException use) {
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -