/[classpath]/classpath/javax/swing/tree/DefaultTreeSelectionModel.java
ViewVC logotype

Diff of /classpath/javax/swing/tree/DefaultTreeSelectionModel.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by langel, Tue Jul 12 19:26:41 2005 UTC revision 1.19 by trebligd, Wed Jul 13 08:37:46 2005 UTC
# Line 1  Line 1 
1  /* DefaultTreeSelectionModel.java  /* DefaultTreeSelectionModel.java
2     Copyright (C) 2002, 2004 Free Software Foundation, Inc.     Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
3        
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 173  public class DefaultTreeSelectionModel Line 173  public class DefaultTreeSelectionModel
173           *           *
174           * @param rowMapper the RowMapper to set           * @param rowMapper the RowMapper to set
175           *           *
176           * @see {@link RowMapper           * @see RowMapper
177           */           */
178          public void setRowMapper(RowMapper value0)          public void setRowMapper(RowMapper rowMapper)
179          {          {
180                  // TODO                  // TODO
181          }          }
# Line 186  public class DefaultTreeSelectionModel Line 186  public class DefaultTreeSelectionModel
186           *           *
187           * @return the current RowMapper           * @return the current RowMapper
188           *           *
189           * @see {@link RowMapper           * @see RowMapper
190           */           */
191          public RowMapper getRowMapper()          public RowMapper getRowMapper()
192          {          {
# Line 195  public class DefaultTreeSelectionModel Line 195  public class DefaultTreeSelectionModel
195    
196          /**          /**
197           * Sets the current selection mode. Possible values are           * Sets the current selection mode. Possible values are
198           * {@link #SINGLE_TREE_SELECTION}, {@link CONTIGUOUS_TREE_SELECTION} and           * {@link #SINGLE_TREE_SELECTION}, {@link #CONTIGUOUS_TREE_SELECTION} and
199           * {@link #DISCONTIGUOUS_TREE_SELECTION}.           * {@link #DISCONTIGUOUS_TREE_SELECTION}.
200           *           *
201           * @param mode the selection mode to be set           * @param mode the selection mode to be set
202           *           *
203           * @see {@link #getSelectionMode}           * @see #getSelectionMode
204           * @see {@link #SINGLE_TREE_SELECTION}           * @see #SINGLE_TREE_SELECTION
205           * @see {@link #CONTIGUOUS_TREE_SELECTION}           * @see #CONTIGUOUS_TREE_SELECTION
206           * @see {@link #DISCONTIGUOUS_TREE_SELECTION}           * @see #DISCONTIGUOUS_TREE_SELECTION
207           */           */
208          public void setSelectionMode(int mode)          public void setSelectionMode(int mode)
209          {          {
# Line 215  public class DefaultTreeSelectionModel Line 215  public class DefaultTreeSelectionModel
215           *           *
216           * @return the current selection mode           * @return the current selection mode
217           *           *
218           * @see {@link #setSelectionMode}           * @see #setSelectionMode
219           * @see {@link #SINGLE_TREE_SELECTION}           * @see #SINGLE_TREE_SELECTION
220           * @see {@link #CONTIGUOUS_TREE_SELECTION}           * @see #CONTIGUOUS_TREE_SELECTION
221           * @see {@link #DISCONTIGUOUS_TREE_SELECTION}           * @see #DISCONTIGUOUS_TREE_SELECTION
222           */           */
223          public int getSelectionMode()          public int getSelectionMode()
224          {          {
# Line 248  public class DefaultTreeSelectionModel Line 248  public class DefaultTreeSelectionModel
248           *           *
249           * @param paths the paths to set as selection           * @param paths the paths to set as selection
250           */           */
251          public void setSelectionPaths(TreePath[] value0)          public void setSelectionPaths(TreePath[] paths)
252          {          {
253                  // TODO                  // TODO
254          }          }
# Line 262  public class DefaultTreeSelectionModel Line 262  public class DefaultTreeSelectionModel
262           *           *
263           * @param path the path to add to the selection           * @param path the path to add to the selection
264           */           */
265          public void addSelectionPath(TreePath value0)          public void addSelectionPath(TreePath path)
266          {          {
267                  if (!isPathSelected(value0))                  if (!isPathSelected(path))
268                  {                  {
269                          if (isSelectionEmpty())                          if (isSelectionEmpty())
270                                  setSelectionPath(value0);                                  setSelectionPath(path);
271                          else                          else
272                          {                          {
273                                  TreePath[] temp = new TreePath[selection.length + 1];                                  TreePath[] temp = new TreePath[selection.length + 1];
274                                  System.arraycopy(selection, 0, temp, 0, selection.length);                                  System.arraycopy(selection, 0, temp, 0, selection.length);
275                                  temp[temp.length - 1] = value0;                                  temp[temp.length - 1] = path;
276                                  selection = new TreePath[temp.length];                                  selection = new TreePath[temp.length];
277                                  System.arraycopy(temp, 0, selection, 0, temp.length);                                  System.arraycopy(temp, 0, selection, 0, temp.length);
278                          }                          }
279                          leadPath = value0;                          leadPath = path;
280                          fireValueChanged(new TreeSelectionEvent(this, value0, true,                          fireValueChanged(new TreeSelectionEvent(this, path, true,
281                                          leadPath, value0));                                          leadPath, path));
282                  }                  }
283          }          }
284    
# Line 291  public class DefaultTreeSelectionModel Line 291  public class DefaultTreeSelectionModel
291           *           *
292           * @param paths the paths to add to the selection           * @param paths the paths to add to the selection
293           */           */
294          public void addSelectionPaths(TreePath[] value0)          public void addSelectionPaths(TreePath[] paths)
295          {          {
296                  if (value0 != null)                  if (paths != null)
297                  {                  {
298                          TreePath v0 = null;                          TreePath v0 = null;
299                          for (int i = 0; i < value0.length; i++)                          for (int i = 0; i < paths.length; i++)
300                          {                          {
301                                  v0 = value0[i];                                  v0 = paths[i];
302                                  if (!isPathSelected(v0))                                  if (!isPathSelected(v0))
303                                  {                                  {
304                                          if (isSelectionEmpty())                                          if (isSelectionEmpty())
# Line 312  public class DefaultTreeSelectionModel Line 312  public class DefaultTreeSelectionModel
312                                                  selection = new TreePath[temp.length];                                                  selection = new TreePath[temp.length];
313                                                  System.arraycopy(temp, 0, selection, 0, temp.length);                                                  System.arraycopy(temp, 0, selection, 0, temp.length);
314                                          }                                          }
315                                          leadPath = value0[value0.length - 1];                                          leadPath = paths[paths.length - 1];
316                                          fireValueChanged(new TreeSelectionEvent(this, v0, true,                                          fireValueChanged(new TreeSelectionEvent(this, v0, true,
317                                                          leadPath, value0[0]));                                                          leadPath, paths[0]));
318                                  }                                  }
319                          }                          }
320                  }                  }
# Line 328  public class DefaultTreeSelectionModel Line 328  public class DefaultTreeSelectionModel
328           *           *
329           * @param path the path to remove           * @param path the path to remove
330           */           */
331          public void removeSelectionPath(TreePath value0)          public void removeSelectionPath(TreePath path)
332          {          {
333                  int index = -1;                  int index = -1;
334                  if (isPathSelected(value0))                  if (isPathSelected(path))
335                  {                  {
336                          for (int i = 0; i < selection.length; i++)                          for (int i = 0; i < selection.length; i++)
337                          {                          {
338                                  if (selection[i].equals(value0))                                  if (selection[i].equals(path))
339                                  {                                  {
340                                          index = i;                                          index = i;
341                                          break;                                          break;
# Line 348  public class DefaultTreeSelectionModel Line 348  public class DefaultTreeSelectionModel
348                          selection = new TreePath[temp.length];                          selection = new TreePath[temp.length];
349                          System.arraycopy(temp, 0, selection, 0, temp.length);                          System.arraycopy(temp, 0, selection, 0, temp.length);
350    
351                          fireValueChanged(new TreeSelectionEvent(this, value0, false,                          fireValueChanged(new TreeSelectionEvent(this, path, false,
352                                          leadPath, value0));                                          leadPath, path));
353                  }                  }
354          }          }
355    
# Line 359  public class DefaultTreeSelectionModel Line 359  public class DefaultTreeSelectionModel
359           * If this changes the selection the registered TreeSelectionListeners are           * If this changes the selection the registered TreeSelectionListeners are
360           * notified.           * notified.
361           *           *
362           * @param paths the path to remove           * @param paths the paths to remove
363           */           */
364          public void removeSelectionPaths(TreePath[] value0)          public void removeSelectionPaths(TreePath[] paths)
365          {          {
366                  if (value0 != null)                  if (paths != null)
367                  {                  {
368                          int index = -1;                          int index = -1;
369                          TreePath v0 = null;                          TreePath v0 = null;
370                          for (int i = 0; i < value0.length; i++)                          for (int i = 0; i < paths.length; i++)
371                          {                          {
372                                  v0 = value0[i];                                  v0 = paths[i];
373                                  if (isPathSelected(v0))                                  if (isPathSelected(v0))
374                                  {                                  {
375                                          for (int x = 0; x < selection.length; x++)                                          for (int x = 0; x < selection.length; x++)
# Line 388  public class DefaultTreeSelectionModel Line 388  public class DefaultTreeSelectionModel
388                                          System.arraycopy(temp, 0, selection, 0, temp.length);                                          System.arraycopy(temp, 0, selection, 0, temp.length);
389    
390                                          fireValueChanged(new TreeSelectionEvent(this, v0, false,                                          fireValueChanged(new TreeSelectionEvent(this, v0, false,
391                                                          leadPath, value0[0]));                                                          leadPath, paths[0]));
392                                  }                                  }
393                          }                          }
394                  }                  }
# Line 439  public class DefaultTreeSelectionModel Line 439  public class DefaultTreeSelectionModel
439           * @return <code>true</code> if the path is in the selection,           * @return <code>true</code> if the path is in the selection,
440           *         <code>false</code> otherwise           *         <code>false</code> otherwise
441           */           */
442          public boolean isPathSelected(TreePath value0)          public boolean isPathSelected(TreePath path)
443          {          {
444                  if (selection == null)                  if (selection == null)
445                          return false;                          return false;
446    
447                  for (int i = 0; i < selection.length; i++)                  for (int i = 0; i < selection.length; i++)
448                  {                  {
449                          if (selection[i].equals(value0))                          if (selection[i].equals(path))
450                                  return true;                                  return true;
451                  }                  }
452                  return false;                  return false;
# Line 593  public class DefaultTreeSelectionModel Line 593  public class DefaultTreeSelectionModel
593           * @return <code>true</code> if the row is in this selection,           * @return <code>true</code> if the row is in this selection,
594           *         <code>false</code> otherwise           *         <code>false</code> otherwise
595           */           */
596          public boolean isRowSelected(int value0)          public boolean isRowSelected(int row)
597          {          {
598                  return false; // TODO                  return false; // TODO
599          }          }
# Line 666  public class DefaultTreeSelectionModel Line 666  public class DefaultTreeSelectionModel
666           * Makes sure the currently selected paths are valid according to the           * Makes sure the currently selected paths are valid according to the
667           * current selectionMode.           * current selectionMode.
668           *           *
669           * If the selectionMode is set to {@link CONTIGUOUS_TREE_SELECTION} and the           * If the selectionMode is set to {@link #CONTIGUOUS_TREE_SELECTION} and the
670           * selection isn't contiguous then the selection is reset to the first set           * selection isn't contiguous then the selection is reset to the first set
671           * of contguous paths.           * of contguous paths.
672           *           *
673           * If the selectionMode is set to {@link SINGLE_TREE_SELECTION} and the           * If the selectionMode is set to {@link #SINGLE_TREE_SELECTION} and the
674           * selection has more than one path, the selection is reset to the contain           * selection has more than one path, the selection is reset to the contain
675           * only the first path.           * only the first path.
676           */           */
# Line 687  public class DefaultTreeSelectionModel Line 687  public class DefaultTreeSelectionModel
687           * @return <code>true</code> if the paths are contiguous or we have no           * @return <code>true</code> if the paths are contiguous or we have no
688           *         RowMapper assigned           *         RowMapper assigned
689           */           */
690          protected boolean arePathsContiguous(TreePath[] value0)          protected boolean arePathsContiguous(TreePath[] paths)
691          {          {
692                  return false; // TODO                  return false; // TODO
693          }          }
# Line 698  public class DefaultTreeSelectionModel Line 698  public class DefaultTreeSelectionModel
698           * <li><code>paths</code> is <code>null</code> or empty</li>           * <li><code>paths</code> is <code>null</code> or empty</li>
699           * <li>we have no RowMapper assigned</li>           * <li>we have no RowMapper assigned</li>
700           * <li>nothing is currently selected</li>           * <li>nothing is currently selected</li>
701           * <li>selectionMode is {@link DISCONTIGUOUS_TREE_SELECTION</li>           * <li>selectionMode is {@link #DISCONTIGUOUS_TREE_SELECTION}</li>
702           * <li>adding the paths to the selection still results in a contiguous set           * <li>adding the paths to the selection still results in a contiguous set
703           * of paths</li>           * of paths</li>
704           *           *
# Line 707  public class DefaultTreeSelectionModel Line 707  public class DefaultTreeSelectionModel
707           * @return <code>true</code> if the paths can be added with respect to the           * @return <code>true</code> if the paths can be added with respect to the
708           *         selectionMode           *         selectionMode
709           */           */
710          protected boolean canPathsBeAdded(TreePath[] value0)          protected boolean canPathsBeAdded(TreePath[] paths)
711          {          {
712                  return false; // TODO                  return false; // TODO
713          }          }
# Line 720  public class DefaultTreeSelectionModel Line 720  public class DefaultTreeSelectionModel
720           * @return <code>true</code> if the paths can be removed with respect to           * @return <code>true</code> if the paths can be removed with respect to
721           *         the selectionMode           *         the selectionMode
722           */           */
723          protected boolean canPathsBeRemoved(TreePath[] value0)          protected boolean canPathsBeRemoved(TreePath[] paths)
724          {          {
725                  return false; // TODO                  return false; // TODO
726          }          }

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26