/** Move forward one item in the window history, if possible, and open the view. */ private void onForward() { View view = history.goForward(); if (view != null) oParent.addViewToDesktop(view, view.getLabel()); enableHistoryButtons(); }
/** Display the forwards window history in a menu. */ private void onShowForwardHistory() { UIScrollableMenu hist = new UIScrollableMenu( LanguageProperties.getString( LanguageProperties.TOOLBARS_BUNDLE, "UIToolBarMain.forwardHistory"), 0); //$NON-NLS-1$ Vector views = history.getForwardHistory(); int currentIndex = history.getCurrentPosition(); int count = views.size(); if (count == 0) return; JMenuItem item = null; for (int i = 0; i < count; i++) { View view = (View) views.elementAt(i); item = new JMenuItem(view.getLabel()); final View fview = view; final int fi = (currentIndex + 1) + i; item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (history.goToHistoryItem(fi)) oParent.addViewToDesktop(fview, fview.getLabel()); } }); hist.add(item); } JPopupMenu pop = hist.getPopupMenu(); pop.pack(); Point loc = pbShowForwardHistory.getLocation(); Dimension size = pbShowForwardHistory.getSize(); Dimension popsize = hist.getPreferredSize(); Point finalP = SwingUtilities.convertPoint(tbrToolBar.getParent(), loc, oParent.getDesktop()); int x = 0; int y = 0; if (oManager.getLeftToolBarController().containsBar(tbrToolBar)) { x = finalP.x + size.width; y = finalP.y; } else if (oManager.getRightToolBarController().containsBar(tbrToolBar)) { x = finalP.x - popsize.width; y = finalP.y; } else if (oManager.getTopToolBarController().containsBar(tbrToolBar)) { x = finalP.x; y = finalP.y + size.width; } else if (oManager.getBottomToolBarController().containsBar(tbrToolBar)) { x = finalP.x; y = finalP.y - popsize.height; } hist.setPopupMenuVisible(true); pop.show(oParent.getDesktop(), x, y); }
private void updateNodePos() { for (int i = 0; i < nodeData.size(); i++) { int oldIndex = ((Integer) sorter.getValueAt(i, 0)).intValue(); sorter.setValueAt(new Integer(i), i, 0); if (oldIndex <= nodeData.size()) { NodePosition np = ((NodePosition) nodeData.elementAt(oldIndex)); if (np != null) { try { view.setNodePosition(np.getNode().getId(), new Point(np.getXPos(), (i + 1) * 10)); np.setYPos((i + 1) * 10); } catch (Exception ex) { log.error("Error...", ex); log.info("Error: Unable to update position " + ex.getMessage()); // $NON-NLS-1$ } } } } }
public void constructTableData() { Vector vtTemp = new Vector(); nodeData.removeAllElements(); for (Enumeration e = view.getPositions(); e.hasMoreElements(); ) { NodePosition nodePos = (NodePosition) e.nextElement(); vtTemp.addElement(nodePos); nodeData.addElement(nodePos); } for (Enumeration e = vtTemp.elements(); e.hasMoreElements(); ) { NodePosition nodePos = (NodePosition) e.nextElement(); NodeSummary node = nodePos.getNode(); int index = nodePos.getYPos() / 10; index--; if (index < nodeData.size()) { nodeData.removeElementAt(index); nodeData.insertElementAt(nodePos, index); } } }
/** Reorders the views nodes and sets their yPositions. */ public void sortNodePos() { Vector vtTemp = new Vector(); for (Enumeration e = view.getPositions(); e.hasMoreElements(); ) { vtTemp.addElement((NodePosition) e.nextElement()); } for (int i = 0; i < vtTemp.size(); i++) { int yPos1 = ((NodePosition) vtTemp.elementAt(i)).getYPos(); for (int j = i + 1; j < vtTemp.size(); j++) { int yPos2 = ((NodePosition) vtTemp.elementAt(j)).getYPos(); if (yPos1 > yPos2) { Object o = vtTemp.elementAt(i); vtTemp.setElementAt(vtTemp.elementAt(j), i); vtTemp.setElementAt(o, j); yPos1 = ((NodePosition) vtTemp.elementAt(i)).getYPos(); } } } for (int i = 0; i < vtTemp.size(); i++) { ((NodePosition) vtTemp.elementAt(i)).setYPos((i + 1) * 10); } }
public Object getValueAt(int row, int col) { if (nodeData == null) { return null; } if (row >= nodeData.size()) { return null; } NodePosition np = (NodePosition) nodeData.elementAt(row); if (np != null) { NodeSummary node = np.getNode(); if (node != null) { switch (col) { case ListTableModel.NUMBER_COLUMN: { return new Integer(row); } case ListTableModel.IMAGE_COLUMN: { if (node.getType() == ICoreConstants.REFERENCE) { return UINode.getReferenceImageSmall(node.getSource()); } else { return UINode.getNodeImageSmall(node.getType()); } } case ListTableModel.TAGS_COLUMN: { if (node.getCodeCount() > 0) { return "T"; //$NON-NLS-1$ } else { return ""; //$NON-NLS-1$ } } case ListTableModel.VIEWS_COLUMN: { int count = node.getViewCount(); if (count == 0) { node.updateMultipleViews(); count = node.getViewCount(); } return new Integer(count); } case ListTableModel.DETAIL_COLUMN: { String sDetail = node.getDetail(); sDetail = sDetail.trim(); if (!sDetail.equals("") && !sDetail.equals(ICoreConstants.NODETAIL_STRING)) { // $NON-NLS-1$ return "*"; //$NON-NLS-1$ } else { return ""; //$NON-NLS-1$ } } case ListTableModel.WEIGHT_COLUMN: { if (node instanceof View) { View view = (View) node; int count = 0; try { count = view.getNodeCount(); } catch (Exception e) { } return new Integer(count); } return null; } case ListTableModel.LABEL_COLUMN: { return node.getLabel(); } case ListTableModel.CREATION_DATE_COLUMN: { return node.getCreationDate(); } case ListTableModel.MODIFICATION_DATE_COLUMN: { return node.getModificationDate(); } case ListTableModel.ID_COLUMN: { return node.getId(); } case ListTableModel.AUTHOR_COLUMN: { return node.getAuthor(); } default: return null; } } } return null; }