/** * Tests if the specified values should be grouped together. * * @param sourceIndex0 the first index of the source list to test * @param sourceIndex1 the second index of the source list to test * * @return true iff the values at the specified index are equal according * to the Comparator which defines the grouping logic; false if * either index is out of range or the values shall not be grouped */ private boolean groupTogether(int sourceIndex0, int sourceIndex1) { if(sourceIndex0 < 0 || sourceIndex0 >= sortedList.size()) return false; if(sourceIndex1 < 0 || sourceIndex1 >= sortedList.size()) return false; return comparator.compare(sortedList.get(sourceIndex0), sortedList.get(sourceIndex1)) == 0; }
/** * Tests if the specified values should be grouped together. * * @param sourceIndex0 the first index of the source list to test * @param sourceIndex1 the second index of the source list to test * * @return true iff the values at the specified index are equal according * to the Comparator which defines the grouping logic; false if * either index is out of range or the values shall not be grouped */ private boolean groupTogether(int sourceIndex0, int sourceIndex1) { if(sourceIndex0 < 0 || sourceIndex0 >= sortedList.size()) return false; if(sourceIndex1 < 0 || sourceIndex1 >= sortedList.size()) return false; return comparator.compare(sortedList.get(sourceIndex0), sortedList.get(sourceIndex1)) == 0; }
/** * Tests if the specified values should be grouped together. * * @param sourceIndex0 the first index of the source list to test * @param sourceIndex1 the second index of the source list to test * * @return true iff the values at the specified index are equal according * to the Comparator which defines the grouping logic; false if * either index is out of range or the values shall not be grouped */ private boolean groupTogether(int sourceIndex0, int sourceIndex1) { if(sourceIndex0 < 0 || sourceIndex0 >= sortedList.size()) return false; if(sourceIndex1 < 0 || sourceIndex1 >= sortedList.size()) return false; return comparator.compare(sortedList.get(sourceIndex0), sortedList.get(sourceIndex1)) == 0; }
public void actionPerformed(final ActionEvent event) { // 1. Get selected activities final int[] selectionIndices = table.getSelectedRows(); // 2. Remove all selected activities final List<ProjectActivity> selectedActivities = new ArrayList<>(selectionIndices.length); for (int selectionIndex : selectionIndices) { selectedActivities.add( model.getActivitiesList().get(selectionIndex) ); } model.removeActivities(selectedActivities, this); }
assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 2, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 2 ).get( "stilton" )).getPrice() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 2, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 2, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 2 ).get( "stilton" )).getPrice() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 1, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() ); assertEquals( 4, ((Cheese)sorted.get( 2 ).get( "stilton" )).getPrice() ); assertEquals( 3, ((Cheese)sorted.get( 0 ).get( "stilton" )).getPrice() ); assertEquals( 4, ((Cheese)sorted.get( 1 ).get( "stilton" )).getPrice() );
public void actionPerformed(final java.awt.event.ActionEvent e) { for (int index : getProjectTable().getSelectedRows()) { model.removeProject( model.getAllProjectsList().get(index), ManageProjectsDialog.this ); } } });
/** {@inheritDoc} */ @Override public int getEndIndex() { // search for the upperThreshold value int index = sortedSource.lastSortIndex(new Integer(upperThreshold)); // if the upperThreshold exists in the sortedSource, convert the exclusive index to an inclusive index if (index < sortedSource.size() && evaluator.evaluate(sortedSource.get(index)) == upperThreshold) index++; return index; }
/** {@inheritDoc} */ @Override public int getEndIndex() { // search for the upperThreshold value int index = sortedSource.lastSortIndex(new Integer(upperThreshold)); // if the upperThreshold exists in the sortedSource, convert the exclusive index to an inclusive index if (index < sortedSource.size() && evaluator.evaluate(sortedSource.get(index)) == upperThreshold) index++; return index; }
/** {@inheritDoc} */ @Override public int getEndIndex() { // search for the upperThreshold value int index = sortedSource.lastSortIndex(new Integer(upperThreshold)); // if the upperThreshold exists in the sortedSource, convert the exclusive index to an inclusive index if (index < sortedSource.size() && evaluator.evaluate(sortedSource.get(index)) == upperThreshold) index++; return index; }
public void actionPerformed(final ActionEvent event) { // 1. Get selected activities final int[] selectionIndices = table.getSelectedRows(); if (selectionIndices.length == 0) { return; } final ProjectActivity activity = model.getActivitiesList().get(selectionIndices[0]); // Copy description to clipboard. final Transferable transferable = new BasicTransferable(org.remast.util.StringUtils.stripXmlTags(activity.getDescription()), activity.getDescription()); final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(transferable, null); }
/** {@inheritDoc} */ @Override public int lastIndexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return source.lastIndexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, false, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for(; index > -1; index--) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if(comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if(GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }
public void actionPerformed(final ActionEvent event) { // 1. Get selected activities int[] selectionIndices = table.getSelectedRows(); // 2. Remove all selected activities if (selectionIndices.length == 0) { return; } final AddOrEditActivityDialog editActivityDialog = new AddOrEditActivityDialog( AWTUtils.getFrame(AllActitvitiesPanel.this), model, model.getActivitiesList().get(selectionIndices[0]) ); editActivityDialog.setVisible(true); }
/** {@inheritDoc} */ @Override public int lastIndexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return super.lastIndexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, false, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for(; index > -1; index--) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if(comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if(GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }
/** {@inheritDoc} */ @Override public int indexOf(Object object) { if(mode != STRICT_SORT_ORDER || comparator == null) return super.indexOf(object); // use the fact that we have sorted data to quickly locate a position // at which we can begin a linear search for an object that .equals(object) int index = ((SimpleTree)sorted).indexOfValue(object, true, false, ALL_COLORS); // if we couldn't use the comparator to find the index, return -1 if (index == -1) return -1; // otherwise, we must now begin a linear search for the index of an element // that .equals() the given object for (; index < size(); index++) { E objectAtIndex = get(index); // if the objectAtIndex no longer compares equally with the given object, stop the linear search if (comparator.compare((E)object, objectAtIndex) != 0) return -1; // if the objectAtIndex and object are equal, return the index if (GlazedListsImpl.equal(object, objectAtIndex)) return index; } // if we fall out of the loop we could not locate the object return -1; }
@Override public void valueChanged(final ListSelectionEvent event) { if (table.getSelectedRows() == null) { table.setToolTipText(null); } double duration = 0; for (int i : table.getSelectedRows()) { try { duration += model.getActivitiesList().get(i).getDuration(); } catch (IndexOutOfBoundsException e) { // Exception occurs when user has selected entries and then the filter changes. // Therefore we can safely ignore the exception and keep going. } } table.setToolTipText(textBundle.textFor("AllActivitiesPanel.tooltipDuration", new DurationFormat().format(duration))); //$NON-NLS-1$ }
public void addHours(final ProjectActivity activity) { final HoursByProject newHoursByProject = new HoursByProject(activity.getProject(), activity.getDuration()); if (this.hoursByProjectList.contains(newHoursByProject)) { HoursByProject HoursByProject = this.hoursByProjectList.get(hoursByProjectList.indexOf(newHoursByProject)); HoursByProject.addHours(newHoursByProject.getHours()); } else { this.hoursByProjectList.add(newHoursByProject); } }
public void addHours(final ProjectActivity activity) { final HoursByDay newHoursByDay = new HoursByDay(activity.getStart(), activity.getDuration()); if (this.hoursByDayList.contains(newHoursByDay)) { HoursByDay HoursByDay = this.hoursByDayList.get(hoursByDayList.indexOf(newHoursByDay)); HoursByDay.addHours(newHoursByDay.getHours()); } else { this.hoursByDayList.add(newHoursByDay); } }
public void addHours(final ProjectActivity activity) { final DateTime dateTime = activity.getStart(); final HoursByMonth newHoursByMonth = new HoursByMonth(dateTime, activity.getDuration()); if (this.hoursByMonthList.contains(newHoursByMonth)) { HoursByMonth hoursByMonth = this.hoursByMonthList.get(hoursByMonthList.indexOf(newHoursByMonth)); hoursByMonth.addHours(newHoursByMonth.getHours()); } else { this.hoursByMonthList.add(newHoursByMonth); } }
public void addHours(final ProjectActivity activity) { final DateTime dateTime = activity.getStart(); final HoursByWeek newHoursByWeek = new HoursByWeek(dateTime, activity.getDuration()); if (this.hoursByWeekList.contains(newHoursByWeek)) { HoursByWeek hoursByWeek = this.hoursByWeekList.get(hoursByWeekList.indexOf(newHoursByWeek)); hoursByWeek.addHours(newHoursByWeek.getHours()); } else { this.hoursByWeekList.add(newHoursByWeek); } }
/** * Add given activity to the accumulated report. * * @param activity * the activity to be added */ public void acummulateActivity(final ProjectActivity activity) { AccumulatedProjectActivity newAccActivity = new AccumulatedProjectActivity(activity.getProject(), activity .getStart(), activity.getDuration()); if (this.accumulatedActivitiesByDay.contains(newAccActivity)) { final AccumulatedProjectActivity accActivity = this.accumulatedActivitiesByDay.get(accumulatedActivitiesByDay.indexOf(newAccActivity)); accActivity.addTime(newAccActivity.getTime()); } else { this.accumulatedActivitiesByDay.add(newAccActivity); } }