rem
stringlengths
0
477k
add
stringlengths
0
313k
context
stringlengths
6
599k
meta
stringlengths
141
403
public int[] getSizes() { int[] array; int index;
public int[] getSizes() { int[] array; int index;
public int[] getSizes() { // Variables int[] array; int index; // Create New Array array = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { array[index] = sizes[index]; } // for // Return Newly created array return array; } // getSizes()
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/SizeSequence.java/buggy/core/src/classpath/javax/javax/swing/SizeSequence.java
array = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { array[index] = sizes[index]; }
array = new int[sizes.length]; for (index = 0; index < sizes.length; index++) array[index] = sizes[index];
public int[] getSizes() { // Variables int[] array; int index; // Create New Array array = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { array[index] = sizes[index]; } // for // Return Newly created array return array; } // getSizes()
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/SizeSequence.java/buggy/core/src/classpath/javax/javax/swing/SizeSequence.java
return array;
return array;
public int[] getSizes() { // Variables int[] array; int index; // Create New Array array = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { array[index] = sizes[index]; } // for // Return Newly created array return array; } // getSizes()
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/SizeSequence.java/buggy/core/src/classpath/javax/javax/swing/SizeSequence.java
}
}
public int[] getSizes() { // Variables int[] array; int index; // Create New Array array = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { array[index] = sizes[index]; } // for // Return Newly created array return array; } // getSizes()
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/SizeSequence.java/buggy/core/src/classpath/javax/javax/swing/SizeSequence.java
public void setSizes(int[] sizes) { int index; this.sizes = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { this.sizes[index] = sizes[index]; }
public void setSizes(int[] sizes) { int index; this.sizes = new int[sizes.length]; for (index = 0; index < sizes.length; index++) this.sizes[index] = sizes[index];
public void setSizes(int[] sizes) { // Variables int index; // Initialize Sizes this.sizes = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { this.sizes[index] = sizes[index]; } // for } // setSizes()
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/SizeSequence.java/buggy/core/src/classpath/javax/javax/swing/SizeSequence.java
}
}
public void setSizes(int[] sizes) { // Variables int index; // Initialize Sizes this.sizes = new int[sizes.length]; for (index = 0; index < sizes.length; index++) { this.sizes[index] = sizes[index]; } // for } // setSizes()
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/SizeSequence.java/buggy/core/src/classpath/javax/javax/swing/SizeSequence.java
MockFloppyDeviceFactory factory = (MockFloppyDeviceFactory) FSDriverUtils.getFloppyDeviceFactory();
MockFloppyDeviceFactory factory; try { factory = (MockFloppyDeviceFactory) FloppyDriverUtils.getFloppyDeviceFactory(); } catch (NamingException ex) { throw (IOException)new IOException().initCause(ex); }
public void init(TestConfig config, MockObjectTestCase testCase) throws IOException { // set the current testCase for our factory MockFloppyDeviceFactory factory = (MockFloppyDeviceFactory) FSDriverUtils.getFloppyDeviceFactory(); factory.setTestCase((MockObjectTestCase) testCase); DeviceFinder deviceFinder = new FloppyControllerFinder(); StubDeviceManager.INSTANCE.removeAll(); StubDeviceManager.INSTANCE.add(deviceFinder, new FloppyDeviceToDriverMapper()); FloppyDriver driver = (FloppyDriver) findDriver(deviceFinder, "fd0"); log.debug("findDriver->"+driver); init(null, driver, null); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5f20db8806d47252a697922a7da3255a442e6bdf/FloppyDriverContext.java/buggy/fs/src/test/org/jnode/test/fs/driver/context/FloppyDriverContext.java
return getEncoded(IKeyPairCodec.RAW_FORMAT);
return getEncoded(defaultFormat);
public byte[] getEncoded() { return getEncoded(IKeyPairCodec.RAW_FORMAT); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b9aa2b76c5fb6ec27c94f7eecf71cb3bc137fe2f/DSSKey.java/buggy/core/src/classpath/gnu/gnu/java/security/key/dss/DSSKey.java
return KeyPairCodecFactory.getEncodingShortName(defaultFormat);
return FormatUtil.getEncodingShortName(defaultFormat);
public String getFormat() { return KeyPairCodecFactory.getEncodingShortName(defaultFormat); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b9aa2b76c5fb6ec27c94f7eecf71cb3bc137fe2f/DSSKey.java/buggy/core/src/classpath/gnu/gnu/java/security/key/dss/DSSKey.java
public UShortSeqHolder(short[] initial_value)
public UShortSeqHolder()
public UShortSeqHolder(short[] initial_value) { value = initial_value; typecode.setLength(value.length); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b9b55eb78411ab1a82da7ba097b7b93a8cd80865/UShortSeqHolder.java/buggy/core/src/classpath/org/org/omg/CORBA/UShortSeqHolder.java
value = initial_value; typecode.setLength(value.length);
public UShortSeqHolder(short[] initial_value) { value = initial_value; typecode.setLength(value.length); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/b9b55eb78411ab1a82da7ba097b7b93a8cd80865/UShortSeqHolder.java/buggy/core/src/classpath/org/org/omg/CORBA/UShortSeqHolder.java
bad.minor = Minor.Any;
public static ForwardRequest extract(Any any) { try { return ((ForwardRequestHolder) any.extract_Streamable()).value; } catch (ClassCastException cex) { BAD_OPERATION bad = new BAD_OPERATION("ForwardRequest expected"); bad.initCause(cex); throw bad; } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/44e3ea509d80974dab547c4d1cf8c070d32bac86/ForwardRequestHelper.java/clean/core/src/classpath/org/org/omg/PortableServer/ForwardRequestHelper.java
e.printStackTrace();
log.warn("In constructor: ", e);
public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } }
1179 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1179/379255347f37d0432228baaff23d41ccb4ad68bd/My5250App.java/clean/tn5250j/src/org/tn5250j/My5250App.java
System.out.println("Parameter " + parm + " is specified as: " + getParameter(parm));
log.info("Parameter " + parm + " is specified as: " + getParameter(parm));
private boolean isSpecified(String parm) { if (getParameter(parm) != null) { System.out.println("Parameter " + parm + " is specified as: " + getParameter(parm)); return true; } return false; }
1179 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1179/379255347f37d0432228baaff23d41ccb4ad68bd/My5250App.java/clean/tn5250j/src/org/tn5250j/My5250App.java
System.out.println(" We have loaded a new one");
log.info(" We have loaded a new one");
private void jbInit() throws Exception { this.setSize(new Dimension(400,300)); Properties sesProps = new Properties(); System.out.println(" We have loaded a new one"); // Start loading properties - Host must exist sesProps.put(SESSION_HOST,getParameter("host")); if (isSpecified("-e")) sesProps.put(SESSION_TN_ENHANCED,"1"); if (isSpecified("-p")) { sesProps.put(SESSION_HOST_PORT,getParameter("-p")); }// if (isSpecified("-f",args))// propFileName = getParm("-f",args); if (isSpecified("-cp")) sesProps.put(SESSION_CODE_PAGE ,getParameter("-cp")); if (isSpecified("-gui")) sesProps.put(SESSION_USE_GUI,"1"); if (isSpecified("-132")) sesProps.put(SESSION_SCREEN_SIZE,SCREEN_SIZE_27X132_STR); else sesProps.put(SESSION_SCREEN_SIZE,SCREEN_SIZE_24X80_STR); // socks proxy host argument if (isSpecified("-sph")) { sesProps.put(SESSION_PROXY_HOST ,getParameter("-sph")); } // socks proxy port argument if (isSpecified("-spp")) sesProps.put(SESSION_PROXY_PORT ,getParameter("-spp")); // check if device name is specified if (isSpecified("-dn")) sesProps.put(SESSION_DEVICE_NAME ,getParameter("-dn")); if (isSpecified("-L")) LangTool.init(parseLocale(getParameter("-L"))); else LangTool.init(); loadSystemProperty("SESSION_CONNECT_USER"); loadSystemProperty("SESSION_CONNECT_PASSWORD"); loadSystemProperty("SESSION_CONNECT_PROGRAM"); loadSystemProperty("SESSION_CONNECT_LIBRARY"); loadSystemProperty("SESSION_CONNECT_MENU"); manager = new SessionManager(); final Session s = manager.openSession(sesProps,"","Test Applet"); this.getContentPane().add(s); s.connect(); SwingUtilities.invokeLater(new Runnable() { public void run() { s.grabFocus(); } }); }
1179 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1179/379255347f37d0432228baaff23d41ccb4ad68bd/My5250App.java/clean/tn5250j/src/org/tn5250j/My5250App.java
g.drawPolygon(bright);
g.drawPolyline(bright.xpoints, bright.ypoints, bright.npoints);
public void paintThumb(Graphics g) { Color saved_color = g.getColor(); Polygon thumb = new Polygon(); Point a = new Point(thumbRect.x, thumbRect.y); Point b = new Point(a); Point c = new Point(a); Point d = new Point(a); Point e = new Point(a); Polygon bright; Polygon dark; Polygon all; // This will be in X-dimension if the slider is inverted and y if it isn't. int turnPoint; if (slider.getOrientation() == JSlider.HORIZONTAL) { turnPoint = thumbRect.height * 3 / 4; b.translate(thumbRect.width, 0); c.translate(thumbRect.width, turnPoint); d.translate(thumbRect.width / 2, thumbRect.height); e.translate(0, turnPoint); bright = new Polygon(new int[] { b.x, a.x, e.x, d.x }, new int[] { b.y, a.y, e.y, d.y }, 4); dark = new Polygon(new int[] { b.x, c.x, d.x }, new int[] { b.y, c.y, d.y }, 3); all = new Polygon(new int[] { a.x + 1, b.x, c.x, d.x, e.x + 1 }, new int[] { a.y + 1, b.y + 1, c.y, d.y + 1, e.y }, 5); } else { turnPoint = thumbRect.width * 3 / 4; b.translate(turnPoint, 0); c.translate(thumbRect.width, thumbRect.height / 2); d.translate(turnPoint, thumbRect.height); e.translate(0, thumbRect.height); bright = new Polygon(new int[] { c.x, b.x, a.x, e.x }, new int[] { c.y, b.y, a.y, e.y }, 4); dark = new Polygon(new int[] { c.x, d.x, e.x + 1 }, new int[] { c.y, d.y, e.y }, 3); all = new Polygon(new int[] { a.x + 1, b.x, c.x - 1, d.x, e.x + 1 }, new int[] { a.y + 1, b.y + 1, c.y, d.y, e.y }, 5); } g.setColor(Color.WHITE); g.drawPolygon(bright); g.setColor(Color.BLACK); g.drawPolygon(dark); g.setColor(Color.GRAY); g.fillPolygon(all); g.setColor(saved_color); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/698ac538b7482b0e4aac918befb43b8376e364e3/BasicSliderUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicSliderUI.java
g.drawPolygon(dark);
g.drawPolyline(dark.xpoints, dark.ypoints, dark.npoints);
public void paintThumb(Graphics g) { Color saved_color = g.getColor(); Polygon thumb = new Polygon(); Point a = new Point(thumbRect.x, thumbRect.y); Point b = new Point(a); Point c = new Point(a); Point d = new Point(a); Point e = new Point(a); Polygon bright; Polygon dark; Polygon all; // This will be in X-dimension if the slider is inverted and y if it isn't. int turnPoint; if (slider.getOrientation() == JSlider.HORIZONTAL) { turnPoint = thumbRect.height * 3 / 4; b.translate(thumbRect.width, 0); c.translate(thumbRect.width, turnPoint); d.translate(thumbRect.width / 2, thumbRect.height); e.translate(0, turnPoint); bright = new Polygon(new int[] { b.x, a.x, e.x, d.x }, new int[] { b.y, a.y, e.y, d.y }, 4); dark = new Polygon(new int[] { b.x, c.x, d.x }, new int[] { b.y, c.y, d.y }, 3); all = new Polygon(new int[] { a.x + 1, b.x, c.x, d.x, e.x + 1 }, new int[] { a.y + 1, b.y + 1, c.y, d.y + 1, e.y }, 5); } else { turnPoint = thumbRect.width * 3 / 4; b.translate(turnPoint, 0); c.translate(thumbRect.width, thumbRect.height / 2); d.translate(turnPoint, thumbRect.height); e.translate(0, thumbRect.height); bright = new Polygon(new int[] { c.x, b.x, a.x, e.x }, new int[] { c.y, b.y, a.y, e.y }, 4); dark = new Polygon(new int[] { c.x, d.x, e.x + 1 }, new int[] { c.y, d.y, e.y }, 3); all = new Polygon(new int[] { a.x + 1, b.x, c.x - 1, d.x, e.x + 1 }, new int[] { a.y + 1, b.y + 1, c.y, d.y, e.y }, 5); } g.setColor(Color.WHITE); g.drawPolygon(bright); g.setColor(Color.BLACK); g.drawPolygon(dark); g.setColor(Color.GRAY); g.fillPolygon(all); g.setColor(saved_color); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/698ac538b7482b0e4aac918befb43b8376e364e3/BasicSliderUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicSliderUI.java
if ((gapEnd - gapStart) < strLen) shiftEnd(strLen + DEFAULT_BUFSIZE);
replace(where, 0, str.toCharArray(), str.length());
public UndoableEdit insertString(int where, String str) throws BadLocationException { // check arguments int length = length(); int strLen = str.length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); // check if the gap is big enough to hold the string if ((gapEnd - gapStart) < strLen) // make room for this string and some more shiftEnd(strLen + DEFAULT_BUFSIZE); // are we at the gap boundary? if (where != gapStart) shiftGap(where); // now we can simple copy the string into the gap and adjust the // gap boundaries System.arraycopy(str.toCharArray(), 0, buffer, gapStart, strLen); gapStart += strLen; return null; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
if (where != gapStart) shiftGap(where); System.arraycopy(str.toCharArray(), 0, buffer, gapStart, strLen); gapStart += strLen;
public UndoableEdit insertString(int where, String str) throws BadLocationException { // check arguments int length = length(); int strLen = str.length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); // check if the gap is big enough to hold the string if ((gapEnd - gapStart) < strLen) // make room for this string and some more shiftEnd(strLen + DEFAULT_BUFSIZE); // are we at the gap boundary? if (where != gapStart) shiftGap(where); // now we can simple copy the string into the gap and adjust the // gap boundaries System.arraycopy(str.toCharArray(), 0, buffer, gapStart, strLen); gapStart += strLen; return null; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
if (where != gapStart) shiftGap(where);
replace(where, nitems, null, 0);
public UndoableEdit remove(int where, int nitems) throws BadLocationException { // check arguments int length = length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); if ((where + nitems) > length) throw new BadLocationException("where + nitems cannot be greater" + " than the content length", where + nitems); // check if we are at the gap boundary if (where != gapStart) shiftGap(where); // now we simply have to enlarge the gap gapEnd += nitems; return null; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
gapEnd += nitems;
public UndoableEdit remove(int where, int nitems) throws BadLocationException { // check arguments int length = length(); if (where >= length) throw new BadLocationException("the where argument cannot be greater" + " than the content length", where); if ((where + nitems) > length) throw new BadLocationException("where + nitems cannot be greater" + " than the content length", where + nitems); // check if we are at the gap boundary if (where != gapStart) shiftGap(where); // now we simply have to enlarge the gap gapEnd += nitems; return null; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
protected void replace(int position, int rmSize, Object addItems, int addSize)
protected void replace(int position, int rmSize, Object addItems, int addSize)
protected void replace(int position, int rmSize, Object addItems, int addSize) { // Remove content shiftGap(position); gapEnd += rmSize; // If gap is too small, enlarge the gap. if ((gapEnd - gapStart) < addSize) shiftEnd(addSize); // Add new items to the buffer. System.arraycopy(addItems, 0, buffer, gapStart, addSize); gapStart += addSize; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
}
protected void replace(int position, int rmSize, Object addItems, int addSize) { // Remove content shiftGap(position); gapEnd += rmSize; // If gap is too small, enlarge the gap. if ((gapEnd - gapStart) < addSize) shiftEnd(addSize); // Add new items to the buffer. System.arraycopy(addItems, 0, buffer, gapStart, addSize); gapStart += addSize; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
int index1 = Collections.binarySearch(positions, new GapContentPosition( gapEnd)); int index2 = Collections.binarySearch(positions, new GapContentPosition( newGapEnd));
int index1 = Collections.binarySearch(positions, new GapContentPosition(gapEnd)); int index2 = Collections.binarySearch(positions, new GapContentPosition(newGapEnd));
protected void shiftGap(int newGapStart) { int newGapEnd = newGapStart + (gapEnd - gapStart); // Update the positions between newGapEnd and (old) gapEnd. The marks // must be shifted by (gapEnd - newGapEnd). int index1 = Collections.binarySearch(positions, new GapContentPosition( gapEnd)); int index2 = Collections.binarySearch(positions, new GapContentPosition( newGapEnd)); if (index1 > 0 && index2 > 0) { int i1 = Math.min(index1, index2); int i2 = Math.max(index1, index2); for (ListIterator i = positions.listIterator(i1); i.hasNext();) { if (i.nextIndex() > i2) break; GapContentPosition p = (GapContentPosition) i.next(); p.mark += gapEnd - newGapEnd; } if (newGapStart == gapStart) return; else if (newGapStart < gapStart) { System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart - newGapStart); gapStart = newGapStart; gapEnd = newGapEnd; } else { System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart - gapStart); gapStart = newGapStart; gapEnd = newGapEnd; } } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
}
protected void shiftGap(int newGapStart) { int newGapEnd = newGapStart + (gapEnd - gapStart); // Update the positions between newGapEnd and (old) gapEnd. The marks // must be shifted by (gapEnd - newGapEnd). int index1 = Collections.binarySearch(positions, new GapContentPosition( gapEnd)); int index2 = Collections.binarySearch(positions, new GapContentPosition( newGapEnd)); if (index1 > 0 && index2 > 0) { int i1 = Math.min(index1, index2); int i2 = Math.max(index1, index2); for (ListIterator i = positions.listIterator(i1); i.hasNext();) { if (i.nextIndex() > i2) break; GapContentPosition p = (GapContentPosition) i.next(); p.mark += gapEnd - newGapEnd; } if (newGapStart == gapStart) return; else if (newGapStart < gapStart) { System.arraycopy(buffer, newGapStart, buffer, newGapEnd, gapStart - newGapStart); gapStart = newGapStart; gapEnd = newGapEnd; } else { System.arraycopy(buffer, gapEnd, buffer, gapStart, newGapStart - gapStart); gapStart = newGapStart; gapEnd = newGapEnd; } } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7b0a77266671350e38451a50ce054282a5860ef/GapContent.java/clean/core/src/classpath/javax/javax/swing/text/GapContent.java
public MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds)
public MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds)
public MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds) { this.type = type; this.divisionType = divisionType; this.resolution = resolution; this.bytes = bytes; this.microseconds = microseconds; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5edad632205aa44aca51004923ae52d754cced11/MidiFileFormat.java/buggy/core/src/classpath/javax/javax/sound/midi/MidiFileFormat.java
this.bytes = bytes; this.microseconds = microseconds;
this.byteLength = bytes; this.microsecondLength = microseconds;
public MidiFileFormat(int type, float divisionType, int resolution, int bytes, long microseconds) { this.type = type; this.divisionType = divisionType; this.resolution = resolution; this.bytes = bytes; this.microseconds = microseconds; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5edad632205aa44aca51004923ae52d754cced11/MidiFileFormat.java/buggy/core/src/classpath/javax/javax/sound/midi/MidiFileFormat.java
return bytes;
return byteLength;
public int getByteLength() { return bytes; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5edad632205aa44aca51004923ae52d754cced11/MidiFileFormat.java/buggy/core/src/classpath/javax/javax/sound/midi/MidiFileFormat.java
return microseconds;
return microsecondLength;
public long getMicrosecondLength() { return microseconds; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5edad632205aa44aca51004923ae52d754cced11/MidiFileFormat.java/buggy/core/src/classpath/javax/javax/sound/midi/MidiFileFormat.java
final Graphics g = getGraphics(); if (g != null) { if (id == PaintEvent.PAINT) { ((Component)component).paint(g); } else { ((Component)component).update(g); } g.dispose(); }
processPaintEvent((PaintEvent)event);
public void handleEvent(AWTEvent event) { Unsafe.debug("handleEvent(" + event + ")"); final int id = event.getID(); switch (id) { case PaintEvent.PAINT: case PaintEvent.UPDATE: { final Graphics g = getGraphics(); if (g != null) { //Point p = component.getLocationOnScreen(); //g.translate(p.x, p.y); if (id == PaintEvent.PAINT) { ((Component)component).paint(g); } else { ((Component)component).update(g); } //g.translate(-p.x, -p.y); g.dispose(); } } break; } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/c772b17b7fb843d3870d0fbcde37f457a2948dbf/DesktopFramePeer.java/clean/gui/src/awt/org/jnode/awt/swingpeers/DesktopFramePeer.java
GrubFatFormatter ff = (GrubFatFormatter)createFormatter();
GrubFatFormatter ff = createFormatter();
protected void formatDevice(Device device) throws IOException { /* Format the MBR & partitiontable */ GrubBootSector mbr = (GrubBootSector)(createFormatter().getBootSector()); mbr.getPartition(0).clear(); mbr.getPartition(1).clear(); mbr.getPartition(2).clear(); mbr.getPartition(3).clear(); IBMPartitionTableEntry pte = mbr.getPartition(0); pte.setBootIndicator(true); pte.setStartLba(1); pte.setNrSectors(geom.getTotalSectors() - 1); pte.setSystemIndicator(IBMPartitionTypes.PARTTYPE_DOS_FAT16_LT32M); pte.setStartCHS(geom.getCHS(pte.getStartLba())); pte.setEndCHS(geom.getCHS(pte.getStartLba() + pte.getNrSectors() - 1)); /*System.out.println("partition table:"); for (int i = 0; i < 4; i++) { System.out.println("" + i + " " + mbr.getPartition(i)); }*/ /* Format partition 0 */ part0 = new MappedBlockDeviceSupport(device, pte.getStartLba() * bytesPerSector, pte.getNrSectors() * bytesPerSector); GrubFatFormatter ff = (GrubFatFormatter)createFormatter(); ff.setInstallPartition(0x0000FFFF); ff.format(part0); GrubBootSector part0bs = (GrubBootSector)ff.getBootSector(); /* Fixup stage2 sector in MBR */ mbr.setStage2Sector(pte.getStartLba() + part0bs.getStage2Sector()); try { mbr.write((BlockDeviceAPI)device.getAPI(BlockDeviceAPI.class)); } catch (ApiNotFoundException ex) { throw new IOException("BlockDeviceAPI not found on device", ex); } //System.out.println("mbr stage2 sector=" + mbr.getStage2Sector()); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/d974d9b7c8007292fb3bf35e9f401b7489394db3/BootDiskBuilder.java/buggy/builder/src/builder/org/jnode/build/BootDiskBuilder.java
Font l_font = font;
Font txFont = font;
public void drawText(Graphics2D g, String text, Font font, int x, int y) { FontProvider prv = getProvider(font); Font l_font = font; if (prv == null) { l_font = new Font("Luxi Sans", Font.PLAIN, 10); //log.error("No FontProvider for font=" + font + " using " + l_font + " instead."); prv = getProvider(l_font); } final TextRenderer renderer = prv.getTextRenderer(l_font); renderer.render(g, text, x, y); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/d64552ee2bc6ad50a696471b75cf8d30fdc5c266/DefaultFontManager.java/buggy/gui/src/awt/org/jnode/awt/font/def/DefaultFontManager.java
l_font = new Font("Luxi Sans", Font.PLAIN, 10); prv = getProvider(l_font);
txFont = getTranslatedFont(font); prv = getProvider(txFont);
public void drawText(Graphics2D g, String text, Font font, int x, int y) { FontProvider prv = getProvider(font); Font l_font = font; if (prv == null) { l_font = new Font("Luxi Sans", Font.PLAIN, 10); //log.error("No FontProvider for font=" + font + " using " + l_font + " instead."); prv = getProvider(l_font); } final TextRenderer renderer = prv.getTextRenderer(l_font); renderer.render(g, text, x, y); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/d64552ee2bc6ad50a696471b75cf8d30fdc5c266/DefaultFontManager.java/buggy/gui/src/awt/org/jnode/awt/font/def/DefaultFontManager.java
final TextRenderer renderer = prv.getTextRenderer(l_font); renderer.render(g, text, x, y);
if (prv != null) { final TextRenderer renderer = prv.getTextRenderer(txFont); renderer.render(g, text, x, y); } else { log.error("No provider found for font " + txFont); }
public void drawText(Graphics2D g, String text, Font font, int x, int y) { FontProvider prv = getProvider(font); Font l_font = font; if (prv == null) { l_font = new Font("Luxi Sans", Font.PLAIN, 10); //log.error("No FontProvider for font=" + font + " using " + l_font + " instead."); prv = getProvider(l_font); } final TextRenderer renderer = prv.getTextRenderer(l_font); renderer.render(g, text, x, y); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/d64552ee2bc6ad50a696471b75cf8d30fdc5c266/DefaultFontManager.java/buggy/gui/src/awt/org/jnode/awt/font/def/DefaultFontManager.java
final FontProvider prv = getProvider(font);
FontProvider prv = getProvider(font); Font txFont = font; if (prv == null) { txFont = getTranslatedFont(font); prv = getProvider(txFont); }
public FontMetrics getFontMetrics(Font font) { final FontProvider prv = getProvider(font); if (prv != null) { return prv.getFontMetrics(font); } else { return new EmptyFontMetrics(font); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/d64552ee2bc6ad50a696471b75cf8d30fdc5c266/DefaultFontManager.java/buggy/gui/src/awt/org/jnode/awt/font/def/DefaultFontManager.java
return prv.getFontMetrics(font);
return prv.getFontMetrics(txFont);
public FontMetrics getFontMetrics(Font font) { final FontProvider prv = getProvider(font); if (prv != null) { return prv.getFontMetrics(font); } else { return new EmptyFontMetrics(font); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/d64552ee2bc6ad50a696471b75cf8d30fdc5c266/DefaultFontManager.java/buggy/gui/src/awt/org/jnode/awt/font/def/DefaultFontManager.java
return new EmptyFontMetrics(font);
log.error("No provider found for font " + txFont); return new EmptyFontMetrics(txFont);
public FontMetrics getFontMetrics(Font font) { final FontProvider prv = getProvider(font); if (prv != null) { return prv.getFontMetrics(font); } else { return new EmptyFontMetrics(font); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/d64552ee2bc6ad50a696471b75cf8d30fdc5c266/DefaultFontManager.java/buggy/gui/src/awt/org/jnode/awt/font/def/DefaultFontManager.java
m.minor = Minor.IOR;
public void write(cdrOutput out) { try { // Need to write the Internet profile into the separate // stream as we must know the size in advance. cdrOutput b = out.createEncapsulation(); version.write(b); b.write_string(host); b.write_ushort((short) (port & 0xFFFF)); // Write the object key. b.write_long(key.length); b.write(key); // Number of the tagged components. b.write_long(1 + components.size()); b.write_long(CodeSets_profile.TAG_CODE_SETS); CodeSets.write(b); TaggedComponent t; for (int i = 0; i < components.size(); i++) { t = (TaggedComponent) components.get(i); TaggedComponentHelper.write(b, t); } b.close(); } catch (Exception e) { MARSHAL m = new MARSHAL("Unable to write Internet profile."); m.initCause(e); throw m; } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/44e3ea509d80974dab547c4d1cf8c070d32bac86/IOR.java/clean/core/src/classpath/gnu/gnu/CORBA/IOR.java
bad.minor = Minor.Any;
public static AdapterInactive extract(Any any) { try { EmptyExceptionHolder h = (EmptyExceptionHolder) any.extract_Streamable(); return (AdapterInactive) h.value; } catch (ClassCastException cex) { BAD_OPERATION bad = new BAD_OPERATION("AdapterInactive expected"); bad.initCause(cex); throw bad; } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/44e3ea509d80974dab547c4d1cf8c070d32bac86/AdapterInactiveHelper.java/buggy/core/src/classpath/org/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
throw new NullPointerException();
return 0;
public static int getHashCode(Object obj) { if (obj == null) { throw new NullPointerException(); } else { return ObjectReference.fromObject(obj).toAddress().toInt(); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/f7a63abb55c64a33249c8a78b7e9c304c95800cf/VmSystem.java/buggy/core/src/core/org/jnode/vm/VmSystem.java
throw new MARSHAL(NOT_APPLICABLE);
MARSHAL m = new MARSHAL(NOT_APPLICABLE); m.minor = Minor.Inappropriate; throw m;
public DynAny create_dyn_any(Any _0) throws InconsistentTypeCode { throw new MARSHAL(NOT_APPLICABLE); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/44e3ea509d80974dab547c4d1cf8c070d32bac86/_DynAnyFactoryStub.java/clean/core/src/classpath/org/org/omg/DynamicAny/_DynAnyFactoryStub.java
throw new MARSHAL(NOT_APPLICABLE);
MARSHAL m = new MARSHAL(NOT_APPLICABLE); m.minor = Minor.Inappropriate; throw m;
public DynAny create_dyn_any_from_type_code(TypeCode _0) throws InconsistentTypeCode { throw new MARSHAL(NOT_APPLICABLE); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/44e3ea509d80974dab547c4d1cf8c070d32bac86/_DynAnyFactoryStub.java/clean/core/src/classpath/org/org/omg/DynamicAny/_DynAnyFactoryStub.java
s.grabFocus();
private void jbInit() throws Exception { this.setSize(new Dimension(400,300)); Properties sesProps = new Properties(); // Start loading properties - Host must exist sesProps.put(SESSION_HOST,getParameter("host")); if (isSpecified("-e")) sesProps.put(SESSION_TN_ENHANCED,"1"); if (isSpecified("-p")) { sesProps.put(SESSION_HOST_PORT,getParameter("-p")); }// if (isSpecified("-f",args))// propFileName = getParm("-f",args); if (isSpecified("-cp")) sesProps.put(SESSION_CODE_PAGE ,getParameter("-cp")); if (isSpecified("-gui")) sesProps.put(SESSION_USE_GUI,"1"); if (isSpecified("-132")) sesProps.put(SESSION_SCREEN_SIZE,SCREEN_SIZE_27X132_STR); else sesProps.put(SESSION_SCREEN_SIZE,SCREEN_SIZE_24X80_STR); // socks proxy host argument if (isSpecified("-sph")) { sesProps.put(SESSION_PROXY_HOST ,getParameter("-sph")); } // socks proxy port argument if (isSpecified("-spp")) sesProps.put(SESSION_PROXY_PORT ,getParameter("-spp")); // check if device name is specified if (isSpecified("-dn")) sesProps.put(SESSION_DEVICE_NAME ,getParameter("-dn")); if (isSpecified("-L")) LangTool.init(parseLocale(getParameter("-L"))); else LangTool.init(); manager = new SessionManager(); Session s = manager.openSession(sesProps,"","Test Applet"); this.getContentPane().add(s); s.grabFocus(); s.connect(); }
1179 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1179/d4104819203aa6b5361aa997d2cd29a076f417a7/My5250App.java/buggy/tn5250j/src/org/tn5250j/My5250App.java
JTextComponent.KeyBinding[] bindings = (JTextComponent.KeyBinding[]) UIManager.get(prefix + ".keyBindings");
InputMapUIResource m = (InputMapUIResource) UIManager.get(prefix + ".focusInputMap"); if (m != null) { KeyStroke[] keys = m.keys(); int len = keys.length; bindings = new JTextComponent.KeyBinding[len]; for (int i = 0; i < len; i++) { KeyStroke curr = keys[i]; bindings[i] = new JTextComponent.KeyBinding(curr, (String) m.get(curr)); } }
protected Keymap createKeymap() { String prefix = getPropertyPrefix(); JTextComponent.KeyBinding[] bindings = (JTextComponent.KeyBinding[]) UIManager.get(prefix + ".keyBindings"); if (bindings == null) { bindings = new JTextComponent.KeyBinding[0]; // FIXME: Putting something into the defaults map is certainly wrong. // Must be fixed somehow. UIManager.put(prefix + ".keyBindings", bindings); } Keymap km = JTextComponent.addKeymap(getKeymapName(), JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP)); JTextComponent.loadKeymap(km, bindings, textComponent.getActions()); return km; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/a78ab2f492456918e4f5c52be600854882e139fc/BasicTextUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTextUI.java
UIManager.put(prefix + ".keyBindings", bindings);
UIManager.put(prefix + ".focusInputMap", bindings);
protected Keymap createKeymap() { String prefix = getPropertyPrefix(); JTextComponent.KeyBinding[] bindings = (JTextComponent.KeyBinding[]) UIManager.get(prefix + ".keyBindings"); if (bindings == null) { bindings = new JTextComponent.KeyBinding[0]; // FIXME: Putting something into the defaults map is certainly wrong. // Must be fixed somehow. UIManager.put(prefix + ".keyBindings", bindings); } Keymap km = JTextComponent.addKeymap(getKeymapName(), JTextComponent.getKeymap(JTextComponent.DEFAULT_KEYMAP)); JTextComponent.loadKeymap(km, bindings, textComponent.getActions()); return km; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/a78ab2f492456918e4f5c52be600854882e139fc/BasicTextUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTextUI.java
protected void installKeyboardActions() { // load any bindings for the older Keymap interface Keymap km = JTextComponent.getKeymap(getKeymapName()); if (km == null) km = createKeymap(); textComponent.setKeymap(km); // load any bindings for the newer InputMap / ActionMap interface SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED, getInputMap(JComponent.WHEN_FOCUSED)); SwingUtilities.replaceUIActionMap(textComponent, getActionMap()); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/a78ab2f492456918e4f5c52be600854882e139fc/BasicTextUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTextUI.java
SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED,
SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED,
protected void installKeyboardActions() { // load any bindings for the older Keymap interface Keymap km = JTextComponent.getKeymap(getKeymapName()); if (km == null) km = createKeymap(); textComponent.setKeymap(km); // load any bindings for the newer InputMap / ActionMap interface SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED, getInputMap(JComponent.WHEN_FOCUSED)); SwingUtilities.replaceUIActionMap(textComponent, getActionMap()); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/a78ab2f492456918e4f5c52be600854882e139fc/BasicTextUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTextUI.java
SwingUtilities.replaceUIActionMap(textComponent, getActionMap());
SwingUtilities.replaceUIActionMap(textComponent, createActionMap()); ActionMap parentActionMap = new ActionMapUIResource(); Action[] actions = textComponent.getActions(); for (int j = 0; j < actions.length; j++) { Action currAction = actions[j]; parentActionMap.put(currAction.getValue(Action.NAME), currAction); } SwingUtilities.replaceUIActionMap(textComponent, parentActionMap);
protected void installKeyboardActions() { // load any bindings for the older Keymap interface Keymap km = JTextComponent.getKeymap(getKeymapName()); if (km == null) km = createKeymap(); textComponent.setKeymap(km); // load any bindings for the newer InputMap / ActionMap interface SwingUtilities.replaceUIInputMap(textComponent, JComponent.WHEN_FOCUSED, getInputMap(JComponent.WHEN_FOCUSED)); SwingUtilities.replaceUIActionMap(textComponent, getActionMap()); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/a78ab2f492456918e4f5c52be600854882e139fc/BasicTextUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTextUI.java
throws IllegalArgumentException
throws IllegalArgumentException
public void setDisplayedMnemonicIndex(int newIndex) throws IllegalArgumentException { if (newIndex < -1 || (text != null && newIndex >= text.length())) throw new IllegalArgumentException(); if (newIndex == -1 || text == null || text.charAt(newIndex) != displayedMnemonic) newIndex = -1; if (newIndex != displayedMnemonicIndex) { int oldIndex = displayedMnemonicIndex; displayedMnemonicIndex = newIndex; firePropertyChange("displayedMnemonicIndex", oldIndex, newIndex); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/JLabel.java/clean/core/src/classpath/javax/javax/swing/JLabel.java
public void setDisplayedMnemonicIndex(int newIndex) throws IllegalArgumentException { if (newIndex < -1 || (text != null && newIndex >= text.length())) throw new IllegalArgumentException(); if (newIndex == -1 || text == null || text.charAt(newIndex) != displayedMnemonic) newIndex = -1; if (newIndex != displayedMnemonicIndex) { int oldIndex = displayedMnemonicIndex; displayedMnemonicIndex = newIndex; firePropertyChange("displayedMnemonicIndex", oldIndex, newIndex); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/JLabel.java/clean/core/src/classpath/javax/javax/swing/JLabel.java
public void setDisplayedMnemonicIndex(int newIndex) throws IllegalArgumentException { if (newIndex < -1 || (text != null && newIndex >= text.length())) throw new IllegalArgumentException(); if (newIndex == -1 || text == null || text.charAt(newIndex) != displayedMnemonic) newIndex = -1; if (newIndex != displayedMnemonicIndex) { int oldIndex = displayedMnemonicIndex; displayedMnemonicIndex = newIndex; firePropertyChange("displayedMnemonicIndex", oldIndex, newIndex); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/JLabel.java/clean/core/src/classpath/javax/javax/swing/JLabel.java
{
{
public void setDisplayedMnemonicIndex(int newIndex) throws IllegalArgumentException { if (newIndex < -1 || (text != null && newIndex >= text.length())) throw new IllegalArgumentException(); if (newIndex == -1 || text == null || text.charAt(newIndex) != displayedMnemonic) newIndex = -1; if (newIndex != displayedMnemonicIndex) { int oldIndex = displayedMnemonicIndex; displayedMnemonicIndex = newIndex; firePropertyChange("displayedMnemonicIndex", oldIndex, newIndex); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/JLabel.java/clean/core/src/classpath/javax/javax/swing/JLabel.java
}
}
public void setDisplayedMnemonicIndex(int newIndex) throws IllegalArgumentException { if (newIndex < -1 || (text != null && newIndex >= text.length())) throw new IllegalArgumentException(); if (newIndex == -1 || text == null || text.charAt(newIndex) != displayedMnemonic) newIndex = -1; if (newIndex != displayedMnemonicIndex) { int oldIndex = displayedMnemonicIndex; displayedMnemonicIndex = newIndex; firePropertyChange("displayedMnemonicIndex", oldIndex, newIndex); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/3826e72d9ebe31a854c4d01d6c8f1ec65a8d80fe/JLabel.java/clean/core/src/classpath/javax/javax/swing/JLabel.java
/* Ignored */
public void setEnabled(boolean enabled) { /* Ignored */ }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
{ Event oldStyleEvent; /* Convert AWT 1.1 event to AWT 1.0 event */ oldStyleEvent = Component.translateEvent(event); if (oldStyleEvent != null)
void dispatchEventImpl(AWTEvent event){ Event oldStyleEvent; // This is overridden by subclasses that support events. /* Convert AWT 1.1 event to AWT 1.0 event */ oldStyleEvent = Component.translateEvent(event); if (oldStyleEvent != null) { postEvent(oldStyleEvent); } /* Do local processing */ processEvent(event);}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
postEvent(oldStyleEvent); } /* Do local processing */
void dispatchEventImpl(AWTEvent event){ Event oldStyleEvent; // This is overridden by subclasses that support events. /* Convert AWT 1.1 event to AWT 1.0 event */ oldStyleEvent = Component.translateEvent(event); if (oldStyleEvent != null) { postEvent(oldStyleEvent); } /* Do local processing */ processEvent(event);}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
}
}
void dispatchEventImpl(AWTEvent event){ Event oldStyleEvent; // This is overridden by subclasses that support events. /* Convert AWT 1.1 event to AWT 1.0 event */ oldStyleEvent = Component.translateEvent(event); if (oldStyleEvent != null) { postEvent(oldStyleEvent); } /* Do local processing */ processEvent(event);}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
getParent() { return(parent); }
public MenuContainer getParent() { return parent; }
getParent(){ return(parent);}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
paramString() {
protected String paramString() {
paramString(){ return "name=" + getName();}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
}
}
paramString(){ return "name=" + getName();}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
processEvent(AWTEvent event) { /* Pass a focus event to the focus listener for the accessibility context. */
protected void processEvent(AWTEvent event) {
processEvent(AWTEvent event){ /* Pass a focus event to the focus listener for the accessibility context. */ if (event instanceof FocusEvent) { if (focusListener != null) { switch (event.id) { case FocusEvent.FOCUS_GAINED: focusListener.focusGained((FocusEvent) event); break; case FocusEvent.FOCUS_LOST: focusListener.focusLost((FocusEvent) event); break; } } }}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
}
}
processEvent(AWTEvent event){ /* Pass a focus event to the focus listener for the accessibility context. */ if (event instanceof FocusEvent) { if (focusListener != null) { switch (event.id) { case FocusEvent.FOCUS_GAINED: focusListener.focusGained((FocusEvent) event); break; case FocusEvent.FOCUS_LOST: focusListener.focusLost((FocusEvent) event); break; } } }}
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5806c07c3eeedb0f4f92b9fbacf30c0f55915c25/MenuComponent.java/buggy/core/src/classpath/java/java/awt/MenuComponent.java
rect = getAcceleratorRect(accelerator,
rect = getAcceleratorRect( accelerator,
protected Dimension getPreferredMenuItemSize(JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Dimension d = BasicGraphicsUtils.getPreferredButtonSize(m, defaultTextIconGap); // if menu item has accelerator then take accelerator's size into account // when calculating preferred size. KeyStroke accelerator = m.getAccelerator(); Rectangle rect; if (accelerator != null) { rect = getAcceleratorRect(accelerator, m.getToolkit().getFontMetrics(acceleratorFont)); // add width of accelerator's text d.width = d.width + rect.width + defaultAcceleratorLabelGap; // adjust the heigth of the preferred size if necessary if (d.height < rect.height) d.height = rect.height; } if (checkIcon != null) { d.width = d.width + checkIcon.getIconWidth() + defaultTextIconGap; if (checkIcon.getIconHeight() > d.height) d.height = checkIcon.getIconHeight(); } if (arrowIcon != null && (c instanceof JMenu)) { d.width = d.width + arrowIcon.getIconWidth() + defaultTextIconGap; if (arrowIcon.getIconHeight() > d.height) d.height = arrowIcon.getIconHeight(); } return d; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap);
return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap);
public Dimension getPreferredSize(JComponent c) { return getPreferredMenuItemSize(c, checkIcon, arrowIcon, defaultTextIconGap); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
/* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */
/* * MenuItems insets are equal to menuItems margin, space between text and * menuItems border. We need to paint insets region as well. */
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (! ((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement))
if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement))
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (! ((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
if (! ((JMenu) c).isTopLevelMenu())
if (!((JMenu) c).isTopLevelMenu())
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (! ((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap);
SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap);
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (! ((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
vr.x = br.width - ar.width;
vr.x = br.width - ar.width - defaultTextIconGap;
protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) { JMenuItem m = (JMenuItem) c; Rectangle tr = new Rectangle(); // text rectangle Rectangle ir = new Rectangle(); // icon rectangle Rectangle vr = new Rectangle(); // view rectangle Rectangle br = new Rectangle(); // border rectangle Rectangle ar = new Rectangle(); // accelerator rectangle Rectangle cr = new Rectangle(); // checkIcon rectangle int vertAlign = m.getVerticalAlignment(); int horAlign = m.getHorizontalAlignment(); int vertTextPos = m.getVerticalTextPosition(); int horTextPos = m.getHorizontalTextPosition(); Font f = m.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); SwingUtilities.calculateInnerArea(m, br); SwingUtilities.calculateInsetArea(br, m.getInsets(), vr); paintBackground(g, m, m.getBackground()); /* MenuItems insets are equal to menuItems margin, space between text and menuItems border. We need to paint insets region as well. */ Insets insets = m.getInsets(); br.x -= insets.left; br.y -= insets.top; br.width += insets.right + insets.left; br.height += insets.top + insets.bottom; // Menu item is considered to be highlighted when it is selected. // But we don't want to paint the background of JCheckBoxMenuItems if ((m.isSelected() && checkIcon == null) || m.getModel().isArmed() && (m.getParent() instanceof MenuElement)) { if (m.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(br.x, br.y, br.width, br.height); } } else { if (m.isContentAreaFilled()) { g.setColor(m.getBackground()); g.fillRect(br.x, br.y, br.width, br.height); } } // If this menu item is a JCheckBoxMenuItem then paint check icon if (checkIcon != null) { SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign, horAlign, vertTextPos, horTextPos, vr, cr, tr, defaultTextIconGap); checkIcon.paintIcon(m, g, cr.x, cr.y); // We need to calculate position of the menu text and position of // user menu icon if there exists one relative to the check icon. // So we need to adjust view rectangle s.t. its starting point is at // checkIcon.width + defaultTextIconGap. vr.x = cr.x + cr.width + defaultTextIconGap; } // if this is a submenu, then paint arrow icon to indicate it. if (arrowIcon != null && (c instanceof JMenu)) { if (! ((JMenu) c).isTopLevelMenu()) { int width = arrowIcon.getIconWidth(); int height = arrowIcon.getIconHeight(); arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap, vr.y + 2); } } // paint text and user menu icon if it exists Icon i = m.getIcon(); SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), i, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, tr, defaultTextIconGap); if (i != null) i.paintIcon(c, g, ir.x, ir.y); paintText(g, m, tr, m.getText()); // paint accelerator String acceleratorText = ""; if (m.getAccelerator() != null) { acceleratorText = getAcceleratorText(m.getAccelerator()); fm = g.getFontMetrics(acceleratorFont); ar.width = fm.stringWidth(acceleratorText); ar.x = br.width - ar.width; vr.x = br.width - ar.width; SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null, vertAlign, horAlign, vertTextPos, horTextPos, vr, ir, ar, defaultTextIconGap); paintAccelerator(g, m, ar, acceleratorText); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
if (text != null && ! text.equals(""))
if (text != null && !text.equals(""))
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && ! text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement))
if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement))
protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { Font f = menuItem.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); if (text != null && ! text.equals("")) { if (menuItem.isEnabled()) { // Menu item is considered to be highlighted when it is selected. // But not if it's a JCheckBoxMenuItem if ((menuItem.isSelected() && checkIcon == null) || menuItem.getModel().isArmed() && (menuItem.getParent() instanceof MenuElement)) g.setColor(selectionForeground); else g.setColor(menuItem.getForeground()); } else // FIXME: should fix this to use 'disabledForeground', but its // default value in BasicLookAndFeel is null. // FIXME: should there be different foreground colours for selected // or deselected, when disabled? g.setColor(Color.gray); int mnemonicIndex = menuItem.getDisplayedMnemonicIndex(); if (mnemonicIndex != -1) BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemonicIndex, textRect.x, textRect.y + fm.getAscent()); else BasicGraphicsUtils.drawString(g, text, 0, textRect.x, textRect.y + fm.getAscent()); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/045a5b41cdfa747889101d3993040acf89788bc4/BasicMenuItemUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicMenuItemUI.java
protected void installKeyboardActions() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); // FIXME: The JDK uses a LazyActionMap for parentActionMap ActionMap parentActionMap = new ActionMap(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); // Register key bindings in the UI InputMap-ActionMap pair // Note that we register key bindings with both the old and new modifier // masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on. for (int i = 0; i < keys.length; i++) { parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), convertModifiers (((KeyStroke)keys[i]).getModifiers())), (String)ancestorMap.get((KeyStroke)keys[i])); parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()), (String)ancestorMap.get((KeyStroke)keys[i])); parentActionMap.put ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy (action, (String)ancestorMap.get((KeyStroke)keys[i]))); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/804045622bd8dd509311bab751f88cfa2f79345a/BasicTableUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), convertModifiers (((KeyStroke)keys[i]).getModifiers())), (String)ancestorMap.get((KeyStroke)keys[i]));
KeyStroke stroke = (KeyStroke)keys[i]; String actionString = (String) ancestorMap.get(stroke);
protected void installKeyboardActions() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); // FIXME: The JDK uses a LazyActionMap for parentActionMap ActionMap parentActionMap = new ActionMap(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); // Register key bindings in the UI InputMap-ActionMap pair // Note that we register key bindings with both the old and new modifier // masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on. for (int i = 0; i < keys.length; i++) { parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), convertModifiers (((KeyStroke)keys[i]).getModifiers())), (String)ancestorMap.get((KeyStroke)keys[i])); parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()), (String)ancestorMap.get((KeyStroke)keys[i])); parentActionMap.put ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy (action, (String)ancestorMap.get((KeyStroke)keys[i]))); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/804045622bd8dd509311bab751f88cfa2f79345a/BasicTableUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()), (String)ancestorMap.get((KeyStroke)keys[i]));
parentInputMap.put(KeyStroke.getKeyStroke(stroke.getKeyCode(), stroke.getModifiers()), actionString);
protected void installKeyboardActions() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); // FIXME: The JDK uses a LazyActionMap for parentActionMap ActionMap parentActionMap = new ActionMap(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); // Register key bindings in the UI InputMap-ActionMap pair // Note that we register key bindings with both the old and new modifier // masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on. for (int i = 0; i < keys.length; i++) { parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), convertModifiers (((KeyStroke)keys[i]).getModifiers())), (String)ancestorMap.get((KeyStroke)keys[i])); parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()), (String)ancestorMap.get((KeyStroke)keys[i])); parentActionMap.put ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy (action, (String)ancestorMap.get((KeyStroke)keys[i]))); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/804045622bd8dd509311bab751f88cfa2f79345a/BasicTableUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
parentActionMap.put ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy (action, (String)ancestorMap.get((KeyStroke)keys[i])));
parentActionMap.put (actionString, new ActionListenerProxy (action, actionString));
protected void installKeyboardActions() { UIDefaults defaults = UIManager.getLookAndFeelDefaults(); InputMap ancestorMap = (InputMap)defaults.get("Table.ancestorInputMap"); InputMapUIResource parentInputMap = new InputMapUIResource(); // FIXME: The JDK uses a LazyActionMap for parentActionMap ActionMap parentActionMap = new ActionMap(); action = new TableAction(); Object keys[] = ancestorMap.allKeys(); // Register key bindings in the UI InputMap-ActionMap pair // Note that we register key bindings with both the old and new modifier // masks: InputEvent.SHIFT_MASK and InputEvent.SHIFT_DOWN_MASK and so on. for (int i = 0; i < keys.length; i++) { parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), convertModifiers (((KeyStroke)keys[i]).getModifiers())), (String)ancestorMap.get((KeyStroke)keys[i])); parentInputMap.put(KeyStroke.getKeyStroke (((KeyStroke)keys[i]).getKeyCode(), ((KeyStroke)keys[i]).getModifiers()), (String)ancestorMap.get((KeyStroke)keys[i])); parentActionMap.put ((String)ancestorMap.get((KeyStroke)keys[i]), new ActionListenerProxy (action, (String)ancestorMap.get((KeyStroke)keys[i]))); } // Set the UI InputMap-ActionMap pair to be the parents of the // JTable's InputMap-ActionMap pair parentInputMap.setParent (table.getInputMap (JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).getParent()); parentActionMap.setParent(table.getActionMap().getParent()); table.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT). setParent(parentInputMap); table.getActionMap().setParent(parentActionMap); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/804045622bd8dd509311bab751f88cfa2f79345a/BasicTableUI.java/buggy/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
IDEBus ideBus = FSDriverUtils.getIDEDeviceFactory().createIDEBus(parentDev, primary);
IDEBus ideBus; try { ideBus = IDEDriverUtils.getIDEDeviceFactory().createIDEBus(parentDev, primary); } catch (NamingException ex) { throw new DriverException(ex); }
public static IDEDevice createIDEDevice(Device parentDev, TestCase testCase, final boolean supp48bitsAddr, final long deviceSize) throws IllegalArgumentException, DriverException, ResourceNotFreeException { if((deviceSize % IDEConstants.SECTOR_SIZE) != 0) { throw new IllegalArgumentException("deviceSize("+deviceSize+ ") must be a multiple of SECTOR_SIZE("+IDEConstants.SECTOR_SIZE+")"); } boolean master = true; boolean primary = true; IDEBus ideBus = FSDriverUtils.getIDEDeviceFactory().createIDEBus(parentDev, primary); // must have length 256 (see IDEDriveDescriptor) int[] data = new int[256]; Boolean atapi = Boolean.valueOf(true); final MockObjectTestCase mockTestCase = (MockObjectTestCase) testCase; MockInitializer initializer = new MockInitializer() { public void init(Mock mockDesc) { Boolean bSupp48bitsAddr = Boolean.valueOf(supp48bitsAddr); mockDesc.expects(mockTestCase.atLeastOnce()). method("supports48bitAddressing"). withNoArguments().will(new ReturnStub(bSupp48bitsAddr)); long nbSectors = deviceSize / IDEConstants.SECTOR_SIZE; Long lNbSectors = new Long(nbSectors); String methodName = supp48bitsAddr ? "getSectorsIn48bitAddressing" : "getSectorsIn28bitAddressing"; mockDesc.expects(mockTestCase.atLeastOnce()). method(methodName). withNoArguments().will(new ReturnStub(lNbSectors)); } }; Class[] clsArgs = {int[].class, boolean.class}; Object[] args = {data, atapi}; IDEDriveDescriptor desc = (IDEDriveDescriptor) MockUtils.createMockObject(IDEDriveDescriptor.class, initializer, clsArgs, args); DefaultIDEControllerDriver ctrlDriver = new DefaultIDEControllerDriver(); IDEDevice device = new IDEDevice(ideBus, primary, master, "hdTest", desc, ctrlDriver); return device; }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/5f20db8806d47252a697922a7da3255a442e6bdf/MockObjectFactory.java/buggy/fs/src/test/org/jnode/test/support/MockObjectFactory.java
repaintLeadCell();
public void focusGained(FocusEvent e) { // TODO: Implement this properly. }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
repaintLeadCell();
public void focusLost(FocusEvent e) { // TODO: Implement this properly. }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
public void mouseEntered(MouseEvent e) { // TODO: What should be done here, if anything? }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
public void mouseExited(MouseEvent e) { // TODO: What should be done here, if anything? }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
public void mouseMoved(MouseEvent e) { // TODO: What should be done here, if anything? }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (e.isControlDown() && table. isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin)))
if (e.isControlDown() && table.isCellSelected( table.rowAtPoint(begin), table.columnAtPoint(begin)))
public void mousePressed(MouseEvent e) { if (table.isEnabled()) { ListSelectionModel rowModel = table.getSelectionModel(); ListSelectionModel colModel = table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int colLead = colModel.getLeadSelectionIndex(); begin = new Point(e.getX(), e.getY()); curr = new Point(e.getX(), e.getY()); //if control is pressed and the cell is already selected, deselect it if (e.isControlDown() && table. isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin))) { table.getSelectionModel(). removeSelectionInterval(table.rowAtPoint(begin), table.rowAtPoint(begin)); table.getColumnModel().getSelectionModel(). removeSelectionInterval(table.columnAtPoint(begin), table.columnAtPoint(begin)); } else updateSelection(e.isControlDown()); // If we were editing, but the moved to another cell, stop editing if (rowLead != rowModel.getLeadSelectionIndex() || colLead != colModel.getLeadSelectionIndex()) if (table.isEditing()) table.editingStopped(new ChangeEvent(e)); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
table.requestFocusInWindow();
public void mousePressed(MouseEvent e) { if (table.isEnabled()) { ListSelectionModel rowModel = table.getSelectionModel(); ListSelectionModel colModel = table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int colLead = colModel.getLeadSelectionIndex(); begin = new Point(e.getX(), e.getY()); curr = new Point(e.getX(), e.getY()); //if control is pressed and the cell is already selected, deselect it if (e.isControlDown() && table. isCellSelected(table.rowAtPoint(begin),table.columnAtPoint(begin))) { table.getSelectionModel(). removeSelectionInterval(table.rowAtPoint(begin), table.rowAtPoint(begin)); table.getColumnModel().getSelectionModel(). removeSelectionInterval(table.columnAtPoint(begin), table.columnAtPoint(begin)); } else updateSelection(e.isControlDown()); // If we were editing, but the moved to another cell, stop editing if (rowLead != rowModel.getLeadSelectionIndex() || colLead != colModel.getLeadSelectionIndex()) if (table.isEditing()) table.editingStopped(new ChangeEvent(e)); } }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
public void actionPerformed (ActionEvent e)
public void actionPerformed(ActionEvent e)
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel();
JTable table = (JTable) e.getSource(); DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel();
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
String command = e.getActionCommand();
String command = (String) getValue("__command__");
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
table.editCellAt(rowLead,colLead);
table.editCellAt(rowLead, colLead);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
rowModel.setSelectionInterval(rowMax,rowMax);
rowModel.setSelectionInterval(rowMax, rowMax);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
rowModel.setSelectionInterval(0,0);
rowModel.setSelectionInterval(0, 0);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex();
if (rowLead == getFirstVisibleRowIndex(table)) target = Math.max(0, rowLead - (getLastVisibleRowIndex(table) - getFirstVisibleRowIndex(table) + 1)); else target = getFirstVisibleRowIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex();
if (colLead == getLastVisibleColumnIndex(table)) target = Math.min(colMax, colLead + (getLastVisibleColumnIndex(table) - getFirstVisibleColumnIndex(table) + 1)); else target = getLastVisibleColumnIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex();
if (colLead == getFirstVisibleColumnIndex(table)) target = Math.max(0, colLead - (getLastVisibleColumnIndex(table) - getFirstVisibleColumnIndex(table) + 1)); else target = getFirstVisibleColumnIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
(command.equals ("selectPreviousColumnCell")));
command.equals("selectPreviousColumnCell"));
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
(command.equals ("selectPreviousRowCell")));
command.equals("selectPreviousRowCell"));
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false);
advanceMultipleSelection(table, colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, command.equals("selectPreviousColumnCell"), true); else advanceMultipleSelection(table, rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, command.equals("selectPreviousRowCell"), false);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex();
if (colLead == getFirstVisibleColumnIndex(table)) target = Math.max(0, colLead - (getLastVisibleColumnIndex(table) - getFirstVisibleColumnIndex(table) + 1)); else target = getFirstVisibleColumnIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex();
if (rowLead == getLastVisibleRowIndex(table)) target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex(table) - getFirstVisibleRowIndex(table) + 1)); else target = getLastVisibleRowIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex();
if (colLead == getLastVisibleColumnIndex(table)) target = Math.min(colMax, colLead + (getLastVisibleColumnIndex(table) - getFirstVisibleColumnIndex(table) + 1)); else target = getLastVisibleColumnIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex();
if (rowLead == getLastVisibleRowIndex(table)) target = Math.min(rowMax, rowLead + (getLastVisibleRowIndex(table) - getFirstVisibleRowIndex(table) + 1)); else target = getLastVisibleRowIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java
if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex();
if (rowLead == getFirstVisibleRowIndex(table)) target = Math.max(0, rowLead - (getLastVisibleRowIndex(table) - getFirstVisibleRowIndex(table) + 1)); else target = getFirstVisibleRowIndex(table);
public void actionPerformed (ActionEvent e) { DefaultListSelectionModel rowModel = (DefaultListSelectionModel) table.getSelectionModel(); DefaultListSelectionModel colModel = (DefaultListSelectionModel) table.getColumnModel().getSelectionModel(); int rowLead = rowModel.getLeadSelectionIndex(); int rowMax = table.getModel().getRowCount() - 1; int colLead = colModel.getLeadSelectionIndex(); int colMax = table.getModel().getColumnCount() - 1; String command = e.getActionCommand(); if (command.equals("selectPreviousRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectLastColumn")) { colModel.setSelectionInterval(colMax, colMax); } else if (command.equals("startEditing")) { if (table.isCellEditable(rowLead, colLead)) table.editCellAt(rowLead,colLead); } else if (command.equals("selectFirstRowExtendSelection")) { rowModel.setLeadSelectionIndex(0); } else if (command.equals("selectFirstColumn")) { colModel.setSelectionInterval(0, 0); } else if (command.equals("selectFirstColumnExtendSelection")) { colModel.setLeadSelectionIndex(0); } else if (command.equals("selectLastRow")) { rowModel.setSelectionInterval(rowMax,rowMax); } else if (command.equals("selectNextRowExtendSelection")) { rowModel.setLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectFirstRow")) { rowModel.setSelectionInterval(0,0); } else if (command.equals("selectNextColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectLastColumnExtendSelection")) { colModel.setLeadSelectionIndex(colMax); } else if (command.equals("selectPreviousColumnExtendSelection")) { colModel.setLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("selectNextRow")) { rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); } else if (command.equals("scrollUpExtendSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("selectPreviousRow")) { rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.max(rowLead - 1, 0)); } else if (command.equals("scrollRightChangeSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("selectPreviousColumn")) { colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else if (command.equals("scrollLeftChangeSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setSelectionInterval(target, target); rowModel.setSelectionInterval(rowLead, rowLead); } else if (command.equals("clearSelection")) { table.clearSelection(); } else if (command.equals("cancel")) { // FIXME: implement other parts of "cancel" like undo-ing last // selection. Right now it just calls editingCancelled if // we're currently editing. if (table.isEditing()) table.editingCanceled(new ChangeEvent("cancel")); } else if (command.equals("selectNextRowCell") || command.equals("selectPreviousRowCell") || command.equals("selectNextColumnCell") || command.equals("selectPreviousColumnCell")) { // If nothing is selected, select the first cell in the table if (table.getSelectedRowCount() == 0 && table.getSelectedColumnCount() == 0) { rowModel.setSelectionInterval(0, 0); colModel.setSelectionInterval(0, 0); return; } // If the lead selection index isn't selected (ie a remove operation // happened, then set the lead to the first selected cell in the // table if (!table.isCellSelected(rowLead, colLead)) { rowModel.addSelectionInterval(rowModel.getMinSelectionIndex(), rowModel.getMinSelectionIndex()); colModel.addSelectionInterval(colModel.getMinSelectionIndex(), colModel.getMinSelectionIndex()); return; } // multRowsSelected and multColsSelected tell us if multiple rows or // columns are selected, respectively boolean multRowsSelected, multColsSelected; multRowsSelected = table.getSelectedRowCount() > 1 && table.getRowSelectionAllowed(); multColsSelected = table.getSelectedColumnCount() > 1 && table.getColumnSelectionAllowed(); // If there is just one selection, select the next cell, and wrap // when you get to the edges of the table. if (!multColsSelected && !multRowsSelected) { if (command.indexOf("Column") != -1) advanceSingleSelection(colModel, colMax, rowModel, rowMax, (command.equals ("selectPreviousColumnCell"))); else advanceSingleSelection(rowModel, rowMax, colModel, colMax, (command.equals ("selectPreviousRowCell"))); return; } // rowMinSelected and rowMaxSelected are the minimum and maximum // values respectively of selected cells in the row selection model // Similarly for colMinSelected and colMaxSelected. int rowMaxSelected = table.getRowSelectionAllowed() ? rowModel.getMaxSelectionIndex() : table.getModel().getRowCount() - 1; int rowMinSelected = table.getRowSelectionAllowed() ? rowModel.getMinSelectionIndex() : 0; int colMaxSelected = table.getColumnSelectionAllowed() ? colModel.getMaxSelectionIndex() : table.getModel().getColumnCount() - 1; int colMinSelected = table.getColumnSelectionAllowed() ? colModel.getMinSelectionIndex() : 0; // If there are multiple rows and columns selected, select the next // cell and wrap at the edges of the selection. if (command.indexOf("Column") != -1) advanceMultipleSelection(colModel, colMinSelected, colMaxSelected, rowModel, rowMinSelected, rowMaxSelected, (command.equals ("selectPreviousColumnCell")), true); else advanceMultipleSelection(rowModel, rowMinSelected, rowMaxSelected, colModel, colMinSelected, colMaxSelected, (command.equals ("selectPreviousRowCell")), false); } else if (command.equals("selectNextColumn")) { colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else if (command.equals("scrollLeftExtendSelection")) { int target; if (colLead == getFirstVisibleColumnIndex()) target = Math.max (0, colLead - (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getFirstVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("scrollDownChangeSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("scrollRightExtendSelection")) { int target; if (colLead == getLastVisibleColumnIndex()) target = Math.min (colMax, colLead + (getLastVisibleColumnIndex() - getFirstVisibleColumnIndex() + 1)); else target = getLastVisibleColumnIndex(); colModel.setLeadSelectionIndex(target); rowModel.setLeadSelectionIndex(rowLead); } else if (command.equals("selectAll")) { table.selectAll(); } else if (command.equals("selectLastRowExtendSelection")) { rowModel.setLeadSelectionIndex(rowMax); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollDownExtendSelection")) { int target; if (rowLead == getLastVisibleRowIndex()) target = Math.min (rowMax, rowLead + (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getLastVisibleRowIndex(); rowModel.setLeadSelectionIndex(target); colModel.setLeadSelectionIndex(colLead); } else if (command.equals("scrollUpChangeSelection")) { int target; if (rowLead == getFirstVisibleRowIndex()) target = Math.max (0, rowLead - (getLastVisibleRowIndex() - getFirstVisibleRowIndex() + 1)); else target = getFirstVisibleRowIndex(); rowModel.setSelectionInterval(target, target); colModel.setSelectionInterval(colLead, colLead); } else if (command.equals("selectNextRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just "selectNextRow" rowModel.setSelectionInterval(Math.min(rowLead + 1, rowMax), Math.min(rowLead + 1, rowMax)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.min(rowLead + 1, rowMax)); } else if (command.equals("selectPreviousRowChangeLead")) { if (rowModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousRow rowModel.setSelectionInterval(Math.max(rowLead - 1, 0), Math.min(rowLead -1, 0)); colModel.setSelectionInterval(colLead,colLead); } else rowModel.moveLeadSelectionIndex(Math.max(rowLead - 1, 0)); } else if (command.equals("selectNextColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectNextColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.min(colLead + 1, colMax), Math.min(colLead + 1, colMax)); } else colModel.moveLeadSelectionIndex(Math.min(colLead + 1, colMax)); } else if (command.equals("selectPreviousColumnChangeLead")) { if (colModel.getSelectionMode() != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) { // just selectPreviousColumn rowModel.setSelectionInterval(rowLead,rowLead); colModel.setSelectionInterval(Math.max(colLead - 1, 0), Math.max(colLead - 1, 0)); } else colModel.moveLeadSelectionIndex(Math.max(colLead - 1, 0)); } else if (command.equals("addToSelection")) { if (!table.isEditing()) { int oldRowAnchor = rowModel.getAnchorSelectionIndex(); int oldColAnchor = colModel.getAnchorSelectionIndex(); rowModel.addSelectionInterval(rowLead, rowLead); colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(oldRowAnchor); colModel.setAnchorSelectionIndex(oldColAnchor); } } else if (command.equals("extendTo")) { rowModel.setSelectionInterval(rowModel.getAnchorSelectionIndex(), rowLead); colModel.setSelectionInterval(colModel.getAnchorSelectionIndex(), colLead); } else if (command.equals("toggleAndAnchor")) { if (rowModel.isSelectedIndex(rowLead)) rowModel.removeSelectionInterval(rowLead, rowLead); else rowModel.addSelectionInterval(rowLead, rowLead); if (colModel.isSelectedIndex(colLead)) colModel.removeSelectionInterval(colLead, colLead); else colModel.addSelectionInterval(colLead, colLead); rowModel.setAnchorSelectionIndex(rowLead); colModel.setAnchorSelectionIndex(colLead); } else if (command.equals("stopEditing")) { table.editingStopped(new ChangeEvent(command)); } else { // If we're here that means we bound this TableAction class // to a keyboard input but we either want to ignore that input // or we just haven't implemented its action yet. // Uncomment the following line to print the names of unused bindings // when their keys are pressed // System.out.println ("not implemented: "+e.getActionCommand()); } // Any commands whose keyStrokes should be used by the Editor should not // cause editing to be stopped: ie, the SPACE sends "addToSelection" but // if the table is in editing mode, the space should not cause us to stop // editing because it should be used by the Editor. if (table.isEditing() && command != "startEditing" && command != "addToSelection") table.editingStopped(new ChangeEvent("update")); table.scrollRectToVisible (table.getCellRect(rowModel.getLeadSelectionIndex(), colModel.getLeadSelectionIndex(), false)); }
1056 /local/tlutelli/issta_data/temp/all_java0context/java/2006_temp/2006/1056/ff4d557efcee4a2c3a25a9cac2252bc626fb10fe/BasicTableUI.java/clean/core/src/classpath/javax/javax/swing/plaf/basic/BasicTableUI.java