rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
startOffset = -1; endOffset = -1;
public BranchElement(Element parent, AttributeSet attributes) { super(parent, attributes); }
int end = 0; if (getElementCount() == 0) end = getLength();
if (children.length == 0) { if (endOffset == -1) throw new NullPointerException("BranchElement has no children."); }
public int getEndOffset() { int end = 0; if (getElementCount() == 0) end = getLength(); // FIXME: That ain't correct, fix it. else end = children[children.length - 1].getEndOffset(); return end; }
end = children[children.length - 1].getEndOffset(); return end;
endOffset = children[children.length - 1].getEndOffset(); return endOffset;
public int getEndOffset() { int end = 0; if (getElementCount() == 0) end = getLength(); // FIXME: That ain't correct, fix it. else end = children[children.length - 1].getEndOffset(); return end; }
int start = 0; if (getElementCount() == 0) start = 0;
if (children.length == 0) { if (startOffset == -1) throw new NullPointerException("BranchElement has no children."); }
public int getStartOffset() { int start = 0; if (getElementCount() == 0) start = 0; // FIXME: That ain't correct, fix it. else start = children[0].getStartOffset(); return start; }
start = children[0].getStartOffset(); return start;
startOffset = children[0].getStartOffset(); return startOffset;
public int getStartOffset() { int start = 0; if (getElementCount() == 0) start = 0; // FIXME: That ain't correct, fix it. else start = children[0].getStartOffset(); return start; }
{
int len = content.length(); startDelta = 0; if (start > len) startDelta = start - len; endDelta = 0; if (end > len) endDelta = end - len;
public LeafElement(Element parent, AttributeSet attributes, int start, int end) { super(parent, attributes); { try { if (parent != null) { startPos = parent.getDocument().createPosition(start); endPos = parent.getDocument().createPosition(end); } else { startPos = createPosition(start); endPos = createPosition(end); } } catch (BadLocationException ex) { AssertionError as; as = new AssertionError("BadLocationException thrown " + "here. start=" + start + ", end=" + end + ", length=" + getLength()); as.initCause(ex); throw as; } } }
if (parent != null) { startPos = parent.getDocument().createPosition(start); endPos = parent.getDocument().createPosition(end); } else { startPos = createPosition(start); endPos = createPosition(end); }
startPos = createPosition(start - startDelta); endPos = createPosition(end - endDelta);
public LeafElement(Element parent, AttributeSet attributes, int start, int end) { super(parent, attributes); { try { if (parent != null) { startPos = parent.getDocument().createPosition(start); endPos = parent.getDocument().createPosition(end); } else { startPos = createPosition(start); endPos = createPosition(end); } } catch (BadLocationException ex) { AssertionError as; as = new AssertionError("BadLocationException thrown " + "here. start=" + start + ", end=" + end + ", length=" + getLength()); as.initCause(ex); throw as; } } }
}
public LeafElement(Element parent, AttributeSet attributes, int start, int end) { super(parent, attributes); { try { if (parent != null) { startPos = parent.getDocument().createPosition(start); endPos = parent.getDocument().createPosition(end); } else { startPos = createPosition(start); endPos = createPosition(end); } } catch (BadLocationException ex) { AssertionError as; as = new AssertionError("BadLocationException thrown " + "here. start=" + start + ", end=" + end + ", length=" + getLength()); as.initCause(ex); throw as; } } }
return endPos.getOffset();
return endPos.getOffset() + endDelta;
public int getEndOffset() { return endPos.getOffset(); }
return startPos.getOffset();
return startPos.getOffset() + startDelta;
public int getStartOffset() { return startPos.getOffset(); }
String scrollModeProp = System.getProperty("gnu.javax.swing.JViewport.scrollMode", "BLIT"); int myScrollMode; if (scrollModeProp.equalsIgnoreCase("simple")) myScrollMode = SIMPLE_SCROLL_MODE; else if (scrollModeProp.equalsIgnoreCase("backingstore")) myScrollMode = BACKINGSTORE_SCROLL_MODE; else myScrollMode = BLIT_SCROLL_MODE; setScrollMode(myScrollMode);
setScrollMode(defaultScrollMode);
public JViewport() { setOpaque(true); String scrollModeProp = System.getProperty("gnu.javax.swing.JViewport.scrollMode", "BLIT"); int myScrollMode; if (scrollModeProp.equalsIgnoreCase("simple")) myScrollMode = SIMPLE_SCROLL_MODE; else if (scrollModeProp.equalsIgnoreCase("backingstore")) myScrollMode = BACKINGSTORE_SCROLL_MODE; else myScrollMode = BLIT_SCROLL_MODE; setScrollMode(myScrollMode); updateUI(); setLayout(createLayoutManager()); lastPaintPosition = new Point(); cachedBlitFrom = new Point(); cachedBlitTo = new Point(); cachedBlitSize = new Dimension(); cachedBlitPaint = new Rectangle(); }
bad.minor = Minor.ClassCast;
public static ServantLocator narrow(org.omg.CORBA.Object obj) { try { return (ServantLocator) obj; } catch (ClassCastException ex) { BAD_OPERATION bad = new BAD_OPERATION(); bad.initCause(ex); throw bad; } }
throw new MARSHAL();
MARSHAL m = new MARSHAL("Inappropriate"); m.minor = Minor.Inappropriate; throw m;
public static ServantLocator read(InputStream input) { throw new MARSHAL(); }
throw new MARSHAL();
MARSHAL m = new MARSHAL("Inappropriate"); m.minor = Minor.Inappropriate; throw m;
public static void write(OutputStream output, ServantLocator value) { throw new MARSHAL(); }
attribHash.put("datatype", new XMLAttribute(null, Constants.OBJECT_TYPE));
attribHash.put("datatype", new XMLAttribute(null, Constants.STRING_TYPE));
private void init() { classXDFNodeName = "parameter"; // order matters! these are in *reverse* order of their // occurence in the XDF DTD attribOrder.add(0,"noteList"); attribOrder.add(0,"valueList"); attribOrder.add(0,"units"); attribOrder.add(0,"datatype"); attribOrder.add(0,"paramIdRef"); attribOrder.add(0,"paramId"); attribOrder.add(0,"description"); attribOrder.add(0,"name"); //set up the attribute hashtable key with the default initial value attribHash.put("noteList", new XMLAttribute(Collections.synchronizedList(new ArrayList()), Constants.LIST_TYPE)); attribHash.put("valueList", new XMLAttribute(Collections.synchronizedList(new ArrayList()), Constants.LIST_TYPE)); attribHash.put("units", new XMLAttribute(null, Constants.OBJECT_TYPE)); attribHash.put("datatype", new XMLAttribute(null, Constants.OBJECT_TYPE)); attribHash.put("paramIdRef", new XMLAttribute(null, Constants.STRING_TYPE)); //double check k.z. attribHash.put("paramId", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("description", new XMLAttribute(null, Constants.STRING_TYPE)); attribHash.put("name", new XMLAttribute(null, Constants.STRING_TYPE)); };
public DoubleItem(int kind, int offsetToFP, Register lsb, Register msb, double value) { super(kind, offsetToFP, lsb, msb); this.value = value;
DoubleItem(ItemFactory factory) { super(factory);
public DoubleItem(int kind, int offsetToFP, Register lsb, Register msb, double value) { super(kind, offsetToFP, lsb, msb); this.value = value; }
return createConst(getValue());
return factory.createDConst(getValue());
protected DoubleWordItem cloneConstant() { return createConst(getValue()); }
setPropertiesFromAttributes();
valid = false;
public LabelView(Element element) { super(element); setPropertiesFromAttributes(); }
setPropertiesFromAttributes();
valid = false; super.changedUpdate(e, a, vf);
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory vf) { setPropertiesFromAttributes(); }
if (! valid) setPropertiesFromAttributes();
public Color getBackground() { return background; }
if (! valid) setPropertiesFromAttributes();
public Font getFont() { return font; }
return getContainer().getGraphics().getFontMetrics(font);
if (! valid) setPropertiesFromAttributes(); Container c = getContainer(); FontMetrics fm; if (c != null) fm = c.getFontMetrics(font); else fm = Toolkit.getDefaultToolkit().getFontMetrics(font); return fm;
protected FontMetrics getFontMetrics() { return getContainer().getGraphics().getFontMetrics(font); }
if (! valid) setPropertiesFromAttributes();
public Color getForeground() { return foreground; }
if (! valid) setPropertiesFromAttributes();
public boolean isStrikeThrough() { return strikeThrough; }
if (! valid) setPropertiesFromAttributes();
public boolean isSubscript() { return subscript; }
if (! valid) setPropertiesFromAttributes();
public boolean isSuperscript() { return superscript; }
if (! valid) setPropertiesFromAttributes();
public boolean isUnderline() { return underline; }
Element el = getElement(); AttributeSet atts = el.getAttributes(); background = (Color) atts.getAttribute(StyleConstants.Background); foreground = StyleConstants.getForeground(atts); strikeThrough = StyleConstants.isStrikeThrough(atts); subscript = StyleConstants.isSubscript(atts); superscript = StyleConstants.isSuperscript(atts); underline = StyleConstants.isUnderline(atts);
AttributeSet atts = getAttributes(); setStrikeThrough(StyleConstants.isStrikeThrough(atts)); setSubscript(StyleConstants.isSubscript(atts)); setSuperscript(StyleConstants.isSuperscript(atts)); setUnderline(StyleConstants.isUnderline(atts));
protected void setPropertiesFromAttributes() { Element el = getElement(); AttributeSet atts = el.getAttributes(); // We cannot use StyleConstants.getBackground() here, because that returns // BLACK as default (when background == null). What we need is the // background setting of the text component instead, which is what we get // when background == null anyway. background = (Color) atts.getAttribute(StyleConstants.Background); foreground = StyleConstants.getForeground(atts); strikeThrough = StyleConstants.isStrikeThrough(atts); subscript = StyleConstants.isSubscript(atts); superscript = StyleConstants.isSuperscript(atts); underline = StyleConstants.isUnderline(atts); // Determine the font. String family = StyleConstants.getFontFamily(atts); int size = StyleConstants.getFontSize(atts); int style = Font.PLAIN; if (StyleConstants.isBold(atts)) style |= Font.BOLD; if (StyleConstants.isItalic(atts)) style |= Font.ITALIC; font = new Font(family, style, size); }
String family = StyleConstants.getFontFamily(atts); int size = StyleConstants.getFontSize(atts); int style = Font.PLAIN; if (StyleConstants.isBold(atts)) style |= Font.BOLD; if (StyleConstants.isItalic(atts)) style |= Font.ITALIC; font = new Font(family, style, size);
Document d = getDocument(); if (d instanceof StyledDocument) { StyledDocument doc = (StyledDocument) d; font = doc.getFont(atts); if (atts.isDefined(StyleConstants.Background)) background = doc.getBackground(atts); else background = null; foreground = doc.getForeground(atts); } valid = true;
protected void setPropertiesFromAttributes() { Element el = getElement(); AttributeSet atts = el.getAttributes(); // We cannot use StyleConstants.getBackground() here, because that returns // BLACK as default (when background == null). What we need is the // background setting of the text component instead, which is what we get // when background == null anyway. background = (Color) atts.getAttribute(StyleConstants.Background); foreground = StyleConstants.getForeground(atts); strikeThrough = StyleConstants.isStrikeThrough(atts); subscript = StyleConstants.isSubscript(atts); superscript = StyleConstants.isSuperscript(atts); underline = StyleConstants.isUnderline(atts); // Determine the font. String family = StyleConstants.getFontFamily(atts); int size = StyleConstants.getFontSize(atts); int style = Font.PLAIN; if (StyleConstants.isBold(atts)) style |= Font.BOLD; if (StyleConstants.isItalic(atts)) style |= Font.ITALIC; font = new Font(family, style, size); }
while (fLen-- > 0) { planes.setScreenFieldAttr(fPos++,ffw1); }
public final void restoreScreen() throws IOException { int which = 0; ScreenPlanes planes = screen52.planes; try { log.debug("Restore "); bk.getNextByte(); bk.getNextByte(); int rows = bk.getNextByte() & 0xff; int cols = bk.getNextByte() & 0xff; int pos = bk.getNextByte() << 8 & 0xff00; pos |= bk.getNextByte() & 0xff; int hPos = bk.getNextByte() << 8 & 0xff00; hPos |= bk.getNextByte() & 0xff; if (rows != screen52.getRows()) screen52.setRowsCols(rows, cols); screen52.clearAll(); // initialize what we currenty have int b = 32; int la = 32; int len = rows * cols; for (int y = 0; y < len; y++) { b = bk.getNextByte(); if (isAttribute(b)) {// screen52.screen[y].setCharAndAttr(screen52.screen[y]// .getChar(), b, true); planes.setScreenCharAndAttr(y, planes.getChar(y), b, true); la = b; } else { //LDC - 12/02/2003 - Check to see if it is an displayable // character. If not, // do not convert the character. // The characters on screen are in unicode char ch = (char) b; if (isDataEBCDIC(b)) ch = ebcdic2uni(b);// screen52.screen[y].setCharAndAttr(// //getASCIIChar(b),// ch, la, false); planes.setScreenCharAndAttr(y, ch, la, false); } } int numFields = bk.getNextByte() << 8 & 0xff00; numFields |= bk.getNextByte() & 0xff; log.debug("number of fields " + numFields); if (numFields > 0) { int x = 0; int attr = 0; int fPos = 0; int fLen = 0; int ffw1 = 0; int ffw2 = 0; int fcw1 = 0; int fcw2 = 0; boolean mdt = false; ScreenField sf = null; while (x < numFields) { attr = bk.getNextByte(); fPos = bk.getNextByte() << 8 & 0xff00; fPos |= bk.getNextByte() & 0xff; if (bk.getNextByte() == 1) mdt = true; else mdt = false; fLen = bk.getNextByte() << 8 & 0xff00; fLen |= bk.getNextByte() & 0xff; ffw1 = bk.getNextByte(); ffw2 = bk.getNextByte(); fcw1 = bk.getNextByte(); fcw2 = bk.getNextByte(); sf = screen52.getScreenFields().setField(attr, screen52.getRow(fPos), screen52.getCol(fPos), fLen, ffw1, ffw2, fcw1, fcw2); if (mdt) { sf.setMDT(); screen52.getScreenFields().setMasterMDT(); } if (log.isDebugEnabled()) { log.debug("/nRestored "); log.debug(sf.toString()); } x++; } } screen52.restoreScreen(); // display the screen screen52.setPendingInsert(true, screen52.getRow(pos), screen52 .getCol(pos)); screen52.goto_XY(pos); screen52.isInField(); if (screen52.isUsingGuiInterface()) screen52.drawFields(); } catch (Exception e) { log.warn("error restoring screen " + which + " with " + e.getMessage()); } }
float span = 0;
public float getPreferredSpan(int axis) { if (axis != X_AXIS && axis != Y_AXIS) throw new IllegalArgumentException(); // make sure we have the metrics updateMetrics(); float span = 0; Element el = getElement(); switch (axis) { case X_AXIS: span = determineMaxLineLength(); case Y_AXIS: default: span = metrics.getHeight() * el.getElementCount(); break; } return span; }
int line = getElement().getElementIndex(changes.getOffset());
int line = el.getElementIndex(changes.getOffset()); if (changes.getType() == DocumentEvent.EventType.REMOVE && el.getElement(line) == longestLine) { maxLineLength = -1; if (determineMaxLineLength() != alloc.width) preferenceChanged(this, true, false); }
protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) { Element el = getElement(); ElementChange ec = changes.getChange(el); // If ec is null then no lines were added or removed, just // repaint the changed line if (ec == null) { int line = getElement().getElementIndex(changes.getOffset()); damageLineRange(line, line, a, getContainer()); return; } Element[] removed = ec.getChildrenRemoved(); Element[] newElements = ec.getChildrenAdded(); // If no Elements were added or removed, we just want to repaint // the area containing the line that was modified if (removed == null && newElements == null) { int line = getElement().getElementIndex(changes.getOffset()); damageLineRange(line, line, a, getContainer()); return; } // Check to see if we removed the longest line, if so we have to // search through all lines and find the longest one again if (removed != null) { for (int i = 0; i < removed.length; i++) if (removed[i].equals(longestLine)) { // reset maxLineLength and search through all lines for longest one maxLineLength = -1; determineMaxLineLength(); ((JTextComponent)getContainer()).repaint(); return; } } // If we've reached here, that means we haven't removed the longest line if (newElements == null) { // No lines were added, just repaint the container and exit ((JTextComponent)getContainer()).repaint(); return; } // Make sure we have the metrics updateMetrics(); // If we've reached here, that means we haven't removed the longest line // and we have added at least one line, so we have to check if added lines // are longer than the previous longest line Segment seg = getLineBuffer(); float longestNewLength = 0; Element longestNewLine = null; // Loop through the added lines to check their length for (int i = 0; i < newElements.length; i++) { Element child = newElements[i]; int start = child.getStartOffset(); int end = child.getEndOffset(); try { el.getDocument().getText(start, end - start, seg); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } if (seg == null || seg.array == null || seg.count == 0) continue; int width = metrics.charsWidth(seg.array, seg.offset, seg.count); if (width > longestNewLength) { longestNewLine = child; longestNewLength = width; } } // Check if the longest of the new lines is longer than our previous // longest line, and if so update our values if (longestNewLength > maxLineLength) { maxLineLength = longestNewLength; longestLine = longestNewLine; } // Repaint the container ((JTextComponent)getContainer()).repaint(); }
determineMaxLineLength();
if (determineMaxLineLength() != alloc.width) preferenceChanged(this, true, removed.length != newElements.length);
protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) { Element el = getElement(); ElementChange ec = changes.getChange(el); // If ec is null then no lines were added or removed, just // repaint the changed line if (ec == null) { int line = getElement().getElementIndex(changes.getOffset()); damageLineRange(line, line, a, getContainer()); return; } Element[] removed = ec.getChildrenRemoved(); Element[] newElements = ec.getChildrenAdded(); // If no Elements were added or removed, we just want to repaint // the area containing the line that was modified if (removed == null && newElements == null) { int line = getElement().getElementIndex(changes.getOffset()); damageLineRange(line, line, a, getContainer()); return; } // Check to see if we removed the longest line, if so we have to // search through all lines and find the longest one again if (removed != null) { for (int i = 0; i < removed.length; i++) if (removed[i].equals(longestLine)) { // reset maxLineLength and search through all lines for longest one maxLineLength = -1; determineMaxLineLength(); ((JTextComponent)getContainer()).repaint(); return; } } // If we've reached here, that means we haven't removed the longest line if (newElements == null) { // No lines were added, just repaint the container and exit ((JTextComponent)getContainer()).repaint(); return; } // Make sure we have the metrics updateMetrics(); // If we've reached here, that means we haven't removed the longest line // and we have added at least one line, so we have to check if added lines // are longer than the previous longest line Segment seg = getLineBuffer(); float longestNewLength = 0; Element longestNewLine = null; // Loop through the added lines to check their length for (int i = 0; i < newElements.length; i++) { Element child = newElements[i]; int start = child.getStartOffset(); int end = child.getEndOffset(); try { el.getDocument().getText(start, end - start, seg); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } if (seg == null || seg.array == null || seg.count == 0) continue; int width = metrics.charsWidth(seg.array, seg.offset, seg.count); if (width > longestNewLength) { longestNewLine = child; longestNewLength = width; } } // Check if the longest of the new lines is longer than our previous // longest line, and if so update our values if (longestNewLength > maxLineLength) { maxLineLength = longestNewLength; longestLine = longestNewLine; } // Repaint the container ((JTextComponent)getContainer()).repaint(); }
boolean widthChanged = oldMaxLineLength != maxLineLength; boolean heightChanged = removed.length != newElements.length; if (widthChanged || heightChanged) preferenceChanged(this, widthChanged, heightChanged);
protected void updateDamage(DocumentEvent changes, Shape a, ViewFactory f) { Element el = getElement(); ElementChange ec = changes.getChange(el); // If ec is null then no lines were added or removed, just // repaint the changed line if (ec == null) { int line = getElement().getElementIndex(changes.getOffset()); damageLineRange(line, line, a, getContainer()); return; } Element[] removed = ec.getChildrenRemoved(); Element[] newElements = ec.getChildrenAdded(); // If no Elements were added or removed, we just want to repaint // the area containing the line that was modified if (removed == null && newElements == null) { int line = getElement().getElementIndex(changes.getOffset()); damageLineRange(line, line, a, getContainer()); return; } // Check to see if we removed the longest line, if so we have to // search through all lines and find the longest one again if (removed != null) { for (int i = 0; i < removed.length; i++) if (removed[i].equals(longestLine)) { // reset maxLineLength and search through all lines for longest one maxLineLength = -1; determineMaxLineLength(); ((JTextComponent)getContainer()).repaint(); return; } } // If we've reached here, that means we haven't removed the longest line if (newElements == null) { // No lines were added, just repaint the container and exit ((JTextComponent)getContainer()).repaint(); return; } // Make sure we have the metrics updateMetrics(); // If we've reached here, that means we haven't removed the longest line // and we have added at least one line, so we have to check if added lines // are longer than the previous longest line Segment seg = getLineBuffer(); float longestNewLength = 0; Element longestNewLine = null; // Loop through the added lines to check their length for (int i = 0; i < newElements.length; i++) { Element child = newElements[i]; int start = child.getStartOffset(); int end = child.getEndOffset(); try { el.getDocument().getText(start, end - start, seg); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } if (seg == null || seg.array == null || seg.count == 0) continue; int width = metrics.charsWidth(seg.array, seg.offset, seg.count); if (width > longestNewLength) { longestNewLine = child; longestNewLength = width; } } // Check if the longest of the new lines is longer than our previous // longest line, and if so update our values if (longestNewLength > maxLineLength) { maxLineLength = longestNewLength; longestLine = longestNewLine; } // Repaint the container ((JTextComponent)getContainer()).repaint(); }
int lineClicked = (int) (y - rec.y) / metrics.getHeight(); if (lineClicked >= root.getElementCount()) return getEndOffset() - 1;
int lineClicked = Math.min(Math.max((int) (y - rec.y) / metrics.getHeight(), 0), root.getElementCount() - 1);
public int viewToModel(float x, float y, Shape a, Position.Bias[] b) { Rectangle rec = a.getBounds(); Document doc = getDocument(); Element root = doc.getDefaultRootElement(); // PlainView doesn't support line-wrapping so we can find out which // Element was clicked on just by the y-position int lineClicked = (int) (y - rec.y) / metrics.getHeight(); if (lineClicked >= root.getElementCount()) return getEndOffset() - 1; Element line = root.getElement(lineClicked); Segment s = getLineBuffer(); int start = line.getStartOffset(); // We don't want the \n at the end of the line. int end = line.getEndOffset() - 1; try { doc.getText(start, end - start, s); } catch (BadLocationException ble) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ble); throw ae; } int pos = Utilities.getTabbedTextOffset(s, metrics, rec.x, (int)x, this, start); return Math.max (0, pos); }
if (SwingUtilities.isRightMouseButton(e)) { return; }
private void jbInit() throws Exception { this.setLayout(borderLayout1);// this.setOpaque(false);// setDoubleBuffered(true); s.setOpaque(false); s.setDoubleBuffered(false); session.setGUI((SessionGUI)this);// screen = new Screen5250(this,sesConfig); screen = session.getScreen(); this.addComponentListener(this); if (bi == null) { checkOffScreenImage(); } setRubberBand(new TNRubberBand(this)); keyHandler = KeyboardHandler.getKeyboardHandlerInstance(session); if (!sesConfig.isPropertyExists("width") || !sesConfig.isPropertyExists("height")) // set the initialize size this.setSize(bi.getPreferredSize()); else { this.setSize(sesConfig.getIntegerProperty("width"), sesConfig.getIntegerProperty("height")); } addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { /** @todo check for popup trigger on linux * */// if (e.isPopupTrigger()) { // using SwingUtilities because popuptrigger does not work on linux if (SwingUtilities.isRightMouseButton(e)) { actionPopup(e); } } public void mouseReleased(MouseEvent e) {// System.out.println("Mouse Released"); } public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 & doubleClick) { screen.sendKeys("[enter]"); } else { int pos = bi.getPosFromView(e.getX(), e.getY()); if (log.isDebugEnabled()) { log.debug((screen.getRow(pos)) + "," + (screen.getCol(pos))); log.debug(e.getX() + "," + e.getY() + "," + bi.columnWidth + "," + bi.rowHeight); } boolean moved = screen.moveCursor(e, pos); // this is a note to not execute this code here when we // implement the remain after edit function option. if (moved) { if (rubberband.isAreaSelected()) { rubberband.reset(); } screen.repaintScreen(); } getFocusForMe(); } } }); scroller = new SessionScroller().getScrollerInstance((SessionGUI)this); if (!sesConfig.getStringProperty("mouseWheel").equals("Yes")) scroller.removeMouseWheelListener((SessionGUI)this); log.debug("Initializing macros"); macros = new Macronizer(); Macronizer.init(); keyPad.addActionListener(this); if (sesConfig.getStringProperty("keypad").equals("Yes")) keyPad.setVisible(true); else keyPad.setVisible(false); // Warning do not change the the order of the adding of keypad and // the screen. This will cause resizing problems because it will // resize the screen first and during the resize we need to calculate // the bouding area based on the height of the keyPad. // See resizeMe() and getDrawingBounds() this.add(keyPad,BorderLayout.SOUTH); this.add(s,BorderLayout.CENTER); this.requestFocus(); jumpEvent = new SessionJumpEvent(this); // check if double click sends enter if (sesConfig.getStringProperty("doubleClick").equals("Yes")) doubleClick = true; else doubleClick = false;// DropTargetAdapter dta = new DropTargetAdapter() {// public void drop(DropTargetDropEvent dtde) {// Transferable tr = dtde.getTransferable();// dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);// DataFlavor[] dfs = dtde.getCurrentDataFlavors();// if(tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {// try {// log.debug("dtde drop it2 ");//// java.util.List fileList =// (java.util.List)tr.getTransferData(DataFlavor.javaFileListFlavor);// // implementation for when we are able to process a list// // of files.// // Iterator iterator = fileList.iterator();// // if (iterator.hasNext()) {// // File file = (File)iterator.next();// // }// java.io.File file = (java.io.File)fileList.get(0);// System.out.println(file.toString());// dtde.dropComplete(true);// doTransfer(file);// return;// }// catch (UnsupportedFlavorException ufe) {// log.info("importData: unsupported data flavor");// }// catch (java.io.IOException ieo) {// log.warn("importData: I/O exception");// }// catch (Exception ex) {// log.warn(""+ex.getMessage());// }// finally {// dtde.dropComplete(false);// }// }// }// };// DropTarget dt = new DropTarget((JPanel)this,dta);//// setDropTarget(dt); }
if (SwingUtilities.isRightMouseButton(e)) { return; }
public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 & doubleClick) { screen.sendKeys("[enter]"); } else { int pos = bi.getPosFromView(e.getX(), e.getY()); if (log.isDebugEnabled()) { log.debug((screen.getRow(pos)) + "," + (screen.getCol(pos))); log.debug(e.getX() + "," + e.getY() + "," + bi.columnWidth + "," + bi.rowHeight); } boolean moved = screen.moveCursor(e, pos); // this is a note to not execute this code here when we // implement the remain after edit function option. if (moved) { if (rubberband.isAreaSelected()) { rubberband.reset(); } screen.repaintScreen(); } getFocusForMe(); } }
cancelEditing(tree);
completeEditing(false, false, false);
public void editingCanceled(ChangeEvent e) { cancelEditing(tree); }
stopEditing(tree);
completeEditing(false, false, true);
public void editingStopped(ChangeEvent e) { stopEditing(tree); }
throws NotImplementedException
public void keyPressed(KeyEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
public void keyReleased(KeyEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
public void keyTyped(KeyEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
char typed = Character.toLowerCase(e.getKeyChar()); for (int row = tree.getLeadSelectionRow() + 1; row < tree.getRowCount(); row++) { if (checkMatch(row, typed)) { tree.setSelectionRow(row); tree.scrollRowToVisible(row); return; } } for (int row = 0; row < tree.getLeadSelectionRow(); row++) { if (checkMatch(row, typed)) { tree.setSelectionRow(row); tree.scrollRowToVisible(row); return; } }
public void keyTyped(KeyEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
public void mouseDragged(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
public void mouseMoved(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
if (tree != null && tree.isEnabled())
if (! e.isConsumed()) { handleEvent(e); selectedOnPress = true; } else
public void mousePressed(MouseEvent e) { if (tree != null && tree.isEnabled()) { // Maybe stop editing and return. if (isEditing(tree) && tree.getInvokesStopCellEditing() && !stopEditing(tree)) return; int x = e.getX(); int y = e.getY(); TreePath path = getClosestPathForLocation(tree, x, y); if (path != null) { Rectangle bounds = getPathBounds(tree, path); if (SwingUtilities.isLeftMouseButton(e)) checkForClickInExpandControl(path, x, y); if (x > bounds.x && x <= (bounds.x + bounds.width)) { if (! startEditing(path, e)) selectPathForEvent(path, e); } } } }
if (isEditing(tree) && tree.getInvokesStopCellEditing() && !stopEditing(tree)) return; int x = e.getX(); int y = e.getY(); TreePath path = getClosestPathForLocation(tree, x, y); if (path != null) { Rectangle bounds = getPathBounds(tree, path); if (SwingUtilities.isLeftMouseButton(e)) checkForClickInExpandControl(path, x, y); if (x > bounds.x && x <= (bounds.x + bounds.width)) { if (! startEditing(path, e)) selectPathForEvent(path, e); } }
selectedOnPress = false;
public void mousePressed(MouseEvent e) { if (tree != null && tree.isEnabled()) { // Maybe stop editing and return. if (isEditing(tree) && tree.getInvokesStopCellEditing() && !stopEditing(tree)) return; int x = e.getX(); int y = e.getY(); TreePath path = getClosestPathForLocation(tree, x, y); if (path != null) { Rectangle bounds = getPathBounds(tree, path); if (SwingUtilities.isLeftMouseButton(e)) checkForClickInExpandControl(path, x, y); if (x > bounds.x && x <= (bounds.x + bounds.width)) { if (! startEditing(path, e)) selectPathForEvent(path, e); } } } }
throws NotImplementedException
public void mouseReleased(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
if (! e.isConsumed() && ! selectedOnPress) handleEvent(e);
public void mouseReleased(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
source.addMouseListener(this); source.addMouseMotionListener(this); dispatch(e);
public MouseInputHandler(Component source, Component destination, MouseEvent e) { this.source = source; this.destination = destination; }
throws NotImplementedException
public void mouseClicked(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
dispatch(e);
public void mouseClicked(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
dispatch(e);
public void mouseDragged(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
public void mouseEntered(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
if (! SwingUtilities.isLeftMouseButton(e)) removeFromSource();
public void mouseEntered(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
public void mouseExited(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
if (! SwingUtilities.isLeftMouseButton(e)) removeFromSource();
public void mouseExited(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
removeFromSource();
public void mouseMoved(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
public void mousePressed(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
dispatch(e); removeFromSource();
public void mouseReleased(MouseEvent e) throws NotImplementedException { // TODO: What should be done here, if anything? }
throws NotImplementedException
protected void removeFromSource() throws NotImplementedException { // TODO: Implement this properly. }
if (source != null) { source.removeMouseListener(this); source.removeMouseMotionListener(this); } source = null; destination = null;
protected void removeFromSource() throws NotImplementedException { // TODO: Implement this properly. }
if (size == null || cell == null) return null; String s = cell.toString(); Font f = tree.getFont(); FontMetrics fm = tree.getToolkit().getFontMetrics(f); if (s != null)
Dimension prefSize; if (editingComponent != null && editingRow == row)
public Rectangle getNodeDimensions(Object cell, int row, int depth, boolean expanded, Rectangle size) { if (size == null || cell == null) return null; String s = cell.toString(); Font f = tree.getFont(); FontMetrics fm = tree.getToolkit().getFontMetrics(f); if (s != null) { TreePath path = treeState.getPathForRow(row); size.x = getRowX(row, depth); size.width = SwingUtilities.computeStringWidth(fm, s); size.width = size.width + getCurrentControlIcon(path).getIconWidth() + gap + getNodeIcon(path).getIconWidth(); size.height = getMaxHeight(tree); size.y = size.height * row; } return size; }
TreePath path = treeState.getPathForRow(row);
prefSize = editingComponent.getPreferredSize(); int rowHeight = getRowHeight(); if (rowHeight > 0 && rowHeight != prefSize.height) prefSize.height = rowHeight; } else { Component rend = currentCellRenderer.getTreeCellRendererComponent(tree, cell, tree.isRowSelected(row), expanded, treeModel.isLeaf(cell), row, false); rendererPane.add(rend); rend.validate(); prefSize = rend.getPreferredSize(); } if (size != null) {
public Rectangle getNodeDimensions(Object cell, int row, int depth, boolean expanded, Rectangle size) { if (size == null || cell == null) return null; String s = cell.toString(); Font f = tree.getFont(); FontMetrics fm = tree.getToolkit().getFontMetrics(f); if (s != null) { TreePath path = treeState.getPathForRow(row); size.x = getRowX(row, depth); size.width = SwingUtilities.computeStringWidth(fm, s); size.width = size.width + getCurrentControlIcon(path).getIconWidth() + gap + getNodeIcon(path).getIconWidth(); size.height = getMaxHeight(tree); size.y = size.height * row; } return size; }
size.width = SwingUtilities.computeStringWidth(fm, s); size.width = size.width + getCurrentControlIcon(path).getIconWidth() + gap + getNodeIcon(path).getIconWidth(); size.height = getMaxHeight(tree); size.y = size.height * row;
size.y = prefSize.height * row; size.width = prefSize.width; size.height = prefSize.height;
public Rectangle getNodeDimensions(Object cell, int row, int depth, boolean expanded, Rectangle size) { if (size == null || cell == null) return null; String s = cell.toString(); Font f = tree.getFont(); FontMetrics fm = tree.getToolkit().getFontMetrics(f); if (s != null) { TreePath path = treeState.getPathForRow(row); size.x = getRowX(row, depth); size.width = SwingUtilities.computeStringWidth(fm, s); size.width = size.width + getCurrentControlIcon(path).getIconWidth() + gap + getNodeIcon(path).getIconWidth(); size.height = getMaxHeight(tree); size.y = size.height * row; } return size; }
else size = new Rectangle(getRowX(row, depth), prefSize.height * row, prefSize.width, prefSize.height);
public Rectangle getNodeDimensions(Object cell, int row, int depth, boolean expanded, Rectangle size) { if (size == null || cell == null) return null; String s = cell.toString(); Font f = tree.getFont(); FontMetrics fm = tree.getToolkit().getFontMetrics(f); if (s != null) { TreePath path = treeState.getPathForRow(row); size.x = getRowX(row, depth); size.width = SwingUtilities.computeStringWidth(fm, s); size.width = size.width + getCurrentControlIcon(path).getIconWidth() + gap + getNodeIcon(path).getIconWidth(); size.height = getMaxHeight(tree); size.y = size.height * row; } return size; }
else if (property.equals(JTree.EDITABLE_PROPERTY)) setEditable(((Boolean) event.getNewValue()).booleanValue());
public void propertyChange(PropertyChangeEvent event) { String property = event.getPropertyName(); if (property.equals(JTree.ROOT_VISIBLE_PROPERTY)) { validCachedPreferredSize = false; treeState.setRootVisible(tree.isRootVisible()); tree.repaint(); } else if (property.equals(JTree.SELECTION_MODEL_PROPERTY)) { treeSelectionModel = tree.getSelectionModel(); treeSelectionModel.setRowMapper(treeState); } else if (property.equals(JTree.TREE_MODEL_PROPERTY)) { setModel(tree.getModel()); } else if (property.equals(JTree.CELL_RENDERER_PROPERTY)) { setCellRenderer(tree.getCellRenderer()); // Update layout. if (treeState != null) treeState.invalidateSizes(); } }
throws NotImplementedException
public void propertyChange(PropertyChangeEvent event) throws NotImplementedException { // TODO: What should be done here, if anything? }
treeSelectionModel.resetRowSelection();
public void propertyChange(PropertyChangeEvent event) throws NotImplementedException { // TODO: What should be done here, if anything? }
completeEditing();
public void treeCollapsed(TreeExpansionEvent event) { validCachedPreferredSize = false; treeState.setExpandedState(event.getPath(), false); // The maximal cell height may change maxHeight = 0; tree.revalidate(); tree.repaint(); }
tree.scrollPathToVisible(tree.getLeadSelectionPath());
public void actionPerformed(ActionEvent e) { if (tree != null) { String command = (String) getValue(Action.NAME); if (command.equals("selectFirst")) { ensureRowsAreVisible(0, 0); tree.setSelectionInterval(0, 0); } if (command.equals("selectFirstChangeLead")) { ensureRowsAreVisible(0, 0); tree.setLeadSelectionPath(getPathForRow(tree, 0)); } if (command.equals("selectFirstExtendSelection")) { ensureRowsAreVisible(0, 0); TreePath anchorPath = tree.getAnchorSelectionPath(); if (anchorPath == null) tree.setSelectionInterval(0, 0); else { int anchorRow = getRowForPath(tree, anchorPath); tree.setSelectionInterval(0, anchorRow); tree.setAnchorSelectionPath(anchorPath); tree.setLeadSelectionPath(getPathForRow(tree, 0)); } } else if (command.equals("selectLast")) { int end = getRowCount(tree) - 1; ensureRowsAreVisible(end, end); tree.setSelectionInterval(end, end); } else if (command.equals("selectLastChangeLead")) { int end = getRowCount(tree) - 1; ensureRowsAreVisible(end, end); tree.setLeadSelectionPath(getPathForRow(tree, end)); } else if (command.equals("selectLastExtendSelection")) { int end = getRowCount(tree) - 1; ensureRowsAreVisible(end, end); TreePath anchorPath = tree.getAnchorSelectionPath(); if (anchorPath == null) tree.setSelectionInterval(end, end); else { int anchorRow = getRowForPath(tree, anchorPath); tree.setSelectionInterval(end, anchorRow); tree.setAnchorSelectionPath(anchorPath); tree.setLeadSelectionPath(getPathForRow(tree, end)); } } } }
tree.scrollPathToVisible(tree.getLeadSelectionPath());
public void actionPerformed(ActionEvent e) { TreePath currentPath = tree.getLeadSelectionPath(); int currentRow; if (currentPath != null) currentRow = treeState.getRowForPath(currentPath); else currentRow = 0; int rows = treeState.getRowCount(); int nextRow = currentRow + 1; int prevRow = currentRow - 1; boolean hasNext = nextRow < rows; boolean hasPrev = prevRow >= 0 && rows > 0; TreePath newPath; String command = (String) getValue(Action.NAME); if (command.equals("selectPreviousChangeLead") && hasPrev) { newPath = treeState.getPathForRow(prevRow); tree.setSelectionPath(newPath); tree.setAnchorSelectionPath(newPath); tree.setLeadSelectionPath(newPath); } else if (command.equals("selectPreviousExtendSelection") && hasPrev) { newPath = treeState.getPathForRow(prevRow); // If the new path is already selected, the selection shrinks, // unselecting the previously current path. if (tree.isPathSelected(newPath)) tree.getSelectionModel().removeSelectionPath(currentPath); // This must be called in any case because it updates the model // lead selection index. tree.addSelectionPath(newPath); tree.setLeadSelectionPath(newPath); } else if (command.equals("selectPrevious") && hasPrev) { newPath = treeState.getPathForRow(prevRow); tree.setSelectionPath(newPath); } else if (command.equals("selectNext") && hasNext) { newPath = treeState.getPathForRow(nextRow); tree.setSelectionPath(newPath); } else if (command.equals("selectNextExtendSelection") && hasNext) { newPath = treeState.getPathForRow(nextRow); // If the new path is already selected, the selection shrinks, // unselecting the previously current path. if (tree.isPathSelected(newPath)) tree.getSelectionModel().removeSelectionPath(currentPath); // This must be called in any case because it updates the model // lead selection index. tree.addSelectionPath(newPath); tree.setLeadSelectionPath(newPath); } else if (command.equals("selectNextChangeLead") && hasNext) { newPath = treeState.getPathForRow(nextRow); tree.setSelectionPath(newPath); tree.setAnchorSelectionPath(newPath); tree.setLeadSelectionPath(newPath); } }
newVisible.y -= (visible.height - newVisible.height);
newVisible.y -= visible.height - newVisible.height;
public void actionPerformed(ActionEvent e) { String command = (String) getValue(Action.NAME); boolean extendSelection = command.equals("scrollUpExtendSelection") || command.equals("scrollDownExtendSelection"); boolean changeSelection = command.equals("scrollUpChangeSelection") || command.equals("scrollDownChangeSelection"); // Disable change lead, unless we are in discontinuous mode. if (!extendSelection && !changeSelection && tree.getSelectionModel().getSelectionMode() != TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) { changeSelection = true; } int rowCount = getRowCount(tree); if (rowCount > 0 && treeSelectionModel != null) { Dimension maxSize = tree.getSize(); TreePath lead = tree.getLeadSelectionPath(); TreePath newPath = null; Rectangle visible = tree.getVisibleRect(); if (direction == -1) // The RI handles -1 as up. { newPath = getClosestPathForLocation(tree, visible.x, visible.y); if (newPath.equals(lead)) // Corner case, adjust one page up. { visible.y = Math.max(0, visible.y - visible.height); newPath = getClosestPathForLocation(tree, visible.x, visible.y); } } else // +1 is down. { visible.y = Math.min(maxSize.height, visible.y + visible.height - 1); newPath = getClosestPathForLocation(tree, visible.x, visible.y); if (newPath.equals(lead)) // Corner case, adjust one page down. { visible.y = Math.min(maxSize.height, visible.y + visible.height - 1); newPath = getClosestPathForLocation(tree, visible.x, visible.y); } } // Determine new visible rect. Rectangle newVisible = getPathBounds(tree, newPath); newVisible.x = visible.x; newVisible.width = visible.width; if (direction == -1) { newVisible.height = visible.height; } else { newVisible.y -= (visible.height - newVisible.height); newVisible.height = visible.height; } if (extendSelection) { // Extend selection. TreePath anchorPath = tree.getAnchorSelectionPath(); if (anchorPath == null) { tree.setSelectionPath(newPath); } else { int newIndex = getRowForPath(tree, newPath); int anchorIndex = getRowForPath(tree, anchorPath); tree.setSelectionInterval(Math.min(anchorIndex, newIndex), Math.max(anchorIndex, newIndex)); tree.setAnchorSelectionPath(anchorPath); tree.setLeadSelectionPath(newPath); } } else if (changeSelection) { tree.setSelectionPath(newPath); } else // Change lead. { tree.setLeadSelectionPath(newPath); } tree.scrollRectToVisible(newVisible); } }
if (tree.isEditing()) tree.cancelEditing();
completeEditing();
public void valueChanged(TreeSelectionEvent event) { if (tree.isEditing()) tree.cancelEditing(); TreePath op = event.getOldLeadSelectionPath(); TreePath np = event.getNewLeadSelectionPath(); // Repaint of the changed lead selection path. if (op != np) { Rectangle o = treeState.getBounds(event.getOldLeadSelectionPath(), new Rectangle()); Rectangle n = treeState.getBounds(event.getNewLeadSelectionPath(), new Rectangle()); if (o!=null) tree.repaint(o); if (n!=null) tree.repaint(n); } }
tree.scrollPathToVisible(tree.getLeadSelectionPath());
public void actionPerformed(ActionEvent e) { int selected = tree.getLeadSelectionRow(); if (selected != -1 && isLeaf(selected)) { TreePath anchorPath = tree.getAnchorSelectionPath(); TreePath leadPath = tree.getLeadSelectionPath(); toggleExpandState(getPathForRow(tree, selected)); // Need to do this, so that the toggling doesn't mess up the lead // and anchor. tree.setLeadSelectionPath(leadPath); tree.setAnchorSelectionPath(anchorPath); } }
tree.scrollPathToVisible(tree.getLeadSelectionPath());
public void actionPerformed(ActionEvent e) { TreePath current = tree.getLeadSelectionPath(); if (current == null) return; String command = (String) getValue(Action.NAME); if (command.equals("selectParent")) { if (current == null) return; if (tree.isExpanded(current)) { tree.collapsePath(current); } else { // If the node is not expanded (also, if it is a leaf node), // we just select the parent. We do not select the root if it // is not visible. TreePath parent = current.getParentPath(); if (parent != null && !(parent.getPathCount()==1 && !tree.isRootVisible()) ) tree.setSelectionPath(parent); } } else if (command.equals("selectChild")) { Object node = current.getLastPathComponent(); int nc = treeModel.getChildCount(node); if (nc == 0 || treeState.isExpanded(current)) { // If the node is leaf or it is already expanded, // we just select the next row. int nextRow = tree.getLeadSelectionRow() + 1; if (nextRow <= tree.getRowCount()) tree.setSelectionRow(nextRow); } else { tree.expandPath(current); } } }
completeEditing(false, false, false); finish();
if (editingComponent != null) completeEditing(false, true, false);
public void cancelEditing(JTree tree) { // There is no need to send the cancel message to the editor, // as the cancellation event itself arrives from it. This would // only be necessary when cancelling the editing programatically. completeEditing(false, false, false); finish(); }
if (tree.getInvokesStopCellEditing() && stopEditingInCompleteEditing && editingComponent != null) cellEditor.stopCellEditing();
protected void completeEditing() { completeEditing(false, true, false); }
treeState = createLayoutCache();
configureLayoutCache(); treeState.setRootVisible(tree.isRootVisible());
protected void completeUIInstall() { setShowsRootHandles(tree.getShowsRootHandles()); updateRenderer(); updateDepthOffset(); setSelectionModel(tree.getSelectionModel()); treeState = createLayoutCache(); treeSelectionModel.setRowMapper(treeState); configureLayoutCache(); updateSize(); }
configureLayoutCache();
protected void completeUIInstall() { setShowsRootHandles(tree.getShowsRootHandles()); updateRenderer(); updateDepthOffset(); setSelectionModel(tree.getSelectionModel()); treeState = createLayoutCache(); treeSelectionModel.setRowMapper(treeState); configureLayoutCache(); updateSize(); }
action= new TreeAction();
action = new TreeHomeAction(-1, "selectFirst");
private ActionMap createDefaultActions() { ActionMapUIResource am = new ActionMapUIResource(); Action action; action= new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. action= new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. action = new TreeIncrementAction(-1, "selectPrevious"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNext"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextChangeLead"); am.put(action.getValue(Action.NAME), action); // TreeTraverseAction. action = new TreeTraverseAction(-1, "selectParent"); am.put(action.getValue(Action.NAME), action); action = new TreeTraverseAction(1, "selectChild"); am.put(action.getValue(Action.NAME), action); // TreeToggleAction. action = new TreeToggleAction("toggleAndAnchor"); am.put(action.getValue(Action.NAME), action); // TreePageAction. action = new TreePageAction(-1, "scrollUpChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeLead"); am.put(action.getValue(Action.NAME), action); return am; }
action= new TreeHomeAction(-1, "selectFirst");
action = new TreeHomeAction(-1, "selectFirstChangeLead");
private ActionMap createDefaultActions() { ActionMapUIResource am = new ActionMapUIResource(); Action action; action= new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. action= new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. action = new TreeIncrementAction(-1, "selectPrevious"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNext"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextChangeLead"); am.put(action.getValue(Action.NAME), action); // TreeTraverseAction. action = new TreeTraverseAction(-1, "selectParent"); am.put(action.getValue(Action.NAME), action); action = new TreeTraverseAction(1, "selectChild"); am.put(action.getValue(Action.NAME), action); // TreeToggleAction. action = new TreeToggleAction("toggleAndAnchor"); am.put(action.getValue(Action.NAME), action); // TreePageAction. action = new TreePageAction(-1, "scrollUpChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeLead"); am.put(action.getValue(Action.NAME), action); return am; }
action= new TreeHomeAction(-1, "selectFirstChangeLead");
action = new TreeHomeAction(-1, "selectFirstExtendSelection");
private ActionMap createDefaultActions() { ActionMapUIResource am = new ActionMapUIResource(); Action action; action= new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. action= new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. action = new TreeIncrementAction(-1, "selectPrevious"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNext"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextChangeLead"); am.put(action.getValue(Action.NAME), action); // TreeTraverseAction. action = new TreeTraverseAction(-1, "selectParent"); am.put(action.getValue(Action.NAME), action); action = new TreeTraverseAction(1, "selectChild"); am.put(action.getValue(Action.NAME), action); // TreeToggleAction. action = new TreeToggleAction("toggleAndAnchor"); am.put(action.getValue(Action.NAME), action); // TreePageAction. action = new TreePageAction(-1, "scrollUpChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeLead"); am.put(action.getValue(Action.NAME), action); return am; }
action= new TreeHomeAction(-1, "selectFirstExtendSelection");
action = new TreeHomeAction(1, "selectLast");
private ActionMap createDefaultActions() { ActionMapUIResource am = new ActionMapUIResource(); Action action; action= new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. action= new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. action = new TreeIncrementAction(-1, "selectPrevious"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNext"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextChangeLead"); am.put(action.getValue(Action.NAME), action); // TreeTraverseAction. action = new TreeTraverseAction(-1, "selectParent"); am.put(action.getValue(Action.NAME), action); action = new TreeTraverseAction(1, "selectChild"); am.put(action.getValue(Action.NAME), action); // TreeToggleAction. action = new TreeToggleAction("toggleAndAnchor"); am.put(action.getValue(Action.NAME), action); // TreePageAction. action = new TreePageAction(-1, "scrollUpChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeLead"); am.put(action.getValue(Action.NAME), action); return am; }
action= new TreeHomeAction(1, "selectLast");
action = new TreeHomeAction(1, "selectLastChangeLead");
private ActionMap createDefaultActions() { ActionMapUIResource am = new ActionMapUIResource(); Action action; action= new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. action= new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. action = new TreeIncrementAction(-1, "selectPrevious"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNext"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextChangeLead"); am.put(action.getValue(Action.NAME), action); // TreeTraverseAction. action = new TreeTraverseAction(-1, "selectParent"); am.put(action.getValue(Action.NAME), action); action = new TreeTraverseAction(1, "selectChild"); am.put(action.getValue(Action.NAME), action); // TreeToggleAction. action = new TreeToggleAction("toggleAndAnchor"); am.put(action.getValue(Action.NAME), action); // TreePageAction. action = new TreePageAction(-1, "scrollUpChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeLead"); am.put(action.getValue(Action.NAME), action); return am; }
action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection");
action = new TreeHomeAction(1, "selectLastExtendSelection");
private ActionMap createDefaultActions() { ActionMapUIResource am = new ActionMapUIResource(); Action action; action= new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. action= new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. action = new TreeIncrementAction(-1, "selectPrevious"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNext"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextChangeLead"); am.put(action.getValue(Action.NAME), action); // TreeTraverseAction. action = new TreeTraverseAction(-1, "selectParent"); am.put(action.getValue(Action.NAME), action); action = new TreeTraverseAction(1, "selectChild"); am.put(action.getValue(Action.NAME), action); // TreeToggleAction. action = new TreeToggleAction("toggleAndAnchor"); am.put(action.getValue(Action.NAME), action); // TreePageAction. action = new TreePageAction(-1, "scrollUpChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeLead"); am.put(action.getValue(Action.NAME), action); return am; }
action = new TreeStartEditingAction("startEditing"); am.put(action.getValue(Action.NAME), action); action = new TreeCancelEditingAction("cancel"); am.put(action.getValue(Action.NAME), action);
private ActionMap createDefaultActions() { ActionMapUIResource am = new ActionMapUIResource(); Action action; action= new TreeAction(); am.put(action.getValue(Action.NAME), action); // TreeHomeAction. action= new TreeHomeAction(-1, "selectFirst"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(-1, "selectFirstExtendSelection"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLast"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastChangeLead"); am.put(action.getValue(Action.NAME), action); action= new TreeHomeAction(1, "selectLastExtendSelection"); am.put(action.getValue(Action.NAME), action); // TreeIncrementAction. action = new TreeIncrementAction(-1, "selectPrevious"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(-1, "selectPreviousChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNext"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreeIncrementAction(1, "selectNextChangeLead"); am.put(action.getValue(Action.NAME), action); // TreeTraverseAction. action = new TreeTraverseAction(-1, "selectParent"); am.put(action.getValue(Action.NAME), action); action = new TreeTraverseAction(1, "selectChild"); am.put(action.getValue(Action.NAME), action); // TreeToggleAction. action = new TreeToggleAction("toggleAndAnchor"); am.put(action.getValue(Action.NAME), action); // TreePageAction. action = new TreePageAction(-1, "scrollUpChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(-1, "scrollUpChangeLead"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownExtendSelection"); am.put(action.getValue(Action.NAME), action); action = new TreePageAction(1, "scrollDownChangeLead"); am.put(action.getValue(Action.NAME), action); return am; }
return ((TreePath) parent.getLastPathComponent());
return (TreePath) parent.getLastPathComponent();
protected TreePath getLastChildPath(TreePath parent) { return ((TreePath) parent.getLastPathComponent()); }
hashColor = UIManager.getColor("Tree.hash"); if (hashColor == null) hashColor = Color.black;
protected void installDefaults() { LookAndFeel.installColorsAndFont(tree, "Tree.background", "Tree.foreground", "Tree.font"); tree.setOpaque(true); rightChildIndent = UIManager.getInt("Tree.rightChildIndent"); leftChildIndent = UIManager.getInt("Tree.leftChildIndent"); totalChildIndent = rightChildIndent + leftChildIndent; setRowHeight(UIManager.getInt("Tree.rowHeight")); tree.setRowHeight(getRowHeight()); tree.setScrollsOnExpand(UIManager.getBoolean("Tree.scrollsOnExpand")); setExpandedIcon(UIManager.getIcon("Tree.expandedIcon")); setCollapsedIcon(UIManager.getIcon("Tree.collapsedIcon")); }
action = new TreeAction();
protected void installKeyboardActions() { InputMap focusInputMap = (InputMap) SharedUIDefaults.get("Tree.focusInputMap"); SwingUtilities.replaceUIInputMap(tree, JComponent.WHEN_FOCUSED, focusInputMap); InputMap ancestorInputMap = (InputMap) SharedUIDefaults.get("Tree.ancestorInputMap"); SwingUtilities.replaceUIInputMap(tree, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, ancestorInputMap); action = new TreeAction(); SwingUtilities.replaceUIActionMap(tree, getActionMap()); }
int width = 8;
int width;
protected boolean isLocationInExpandControl(TreePath path, int mouseX, int mouseY) { boolean cntlClick = false; if (! treeModel.isLeaf(path.getLastPathComponent())) { int width = 8; // Only guessing. Icon expandedIcon = getExpandedIcon(); if (expandedIcon != null) width = expandedIcon.getIconWidth(); Insets i = tree.getInsets(); int left = getRowX(tree.getRowForPath(path), path.getPathCount() - 1) -getRightChildIndent() - width / 2 + i.left; cntlClick = mouseX >= left && mouseX <= left + width; } return cntlClick; }
int left = getRowX(tree.getRowForPath(path), path.getPathCount() - 1) -getRightChildIndent() - width / 2 + i.left;
int depth; if (isRootVisible()) depth = path.getPathCount()-1; else depth = path.getPathCount()-2; int left = getRowX(tree.getRowForPath(path), depth) - width + i.left;
protected boolean isLocationInExpandControl(TreePath path, int mouseX, int mouseY) { boolean cntlClick = false; if (! treeModel.isLeaf(path.getLastPathComponent())) { int width = 8; // Only guessing. Icon expandedIcon = getExpandedIcon(); if (expandedIcon != null) width = expandedIcon.getIconWidth(); Insets i = tree.getInsets(); int left = getRowX(tree.getRowForPath(path), path.getPathCount() - 1) -getRightChildIndent() - width / 2 + i.left; cntlClick = mouseX >= left && mouseX <= left + width; } return cntlClick; }
if (parent != null)
boolean paintLine; if (isRootVisible()) paintLine = parent != null; else paintLine = parent != null && parent.getPathCount() > 1; if (paintLine)
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path) { Rectangle bounds = getPathBounds(tree, path); TreePath parent = path.getParentPath(); if (parent != null) { Rectangle parentBounds = getPathBounds(tree, parent); paintVerticalLine(g, tree, parentBounds.x + 2* gap, parentBounds.y + parentBounds.height / 2, bounds.y + bounds.height / 2); } }
stopEditingInCompleteEditing = true;
protected void prepareForUIInstall() { lastSelectedRow = -1; preferredSize = new Dimension(); largeModel = tree.isLargeModel(); preferredSize = new Dimension(); setModel(tree.getModel()); }
cellEditor = editor; createdCellEditor = true;
updateCellEditor();
protected void setCellEditor(TreeCellEditor editor) { cellEditor = editor; createdCellEditor = true; }
currentCellRenderer = tcr;
completeEditing();
protected void setCellRenderer(TreeCellRenderer tcr) { currentCellRenderer = tcr; updateRenderer(); }
if (treeState != null) { treeState.invalidateSizes(); updateSize(); }
protected void setCellRenderer(TreeCellRenderer tcr) { currentCellRenderer = tcr; updateRenderer(); }
tree.setEditable(newValue);
updateCellEditor();
protected void setEditable(boolean newValue) { tree.setEditable(newValue); }
completeEditing();
protected void setLargeModel(boolean largeModel) { if (largeModel != this.largeModel) { tree.removeComponentListener(componentListener); this.largeModel = largeModel; tree.addComponentListener(componentListener); } }
completeEditing();
protected void setRootVisible(boolean newValue) { tree.setRootVisible(newValue); }