@Test public void testEnsureSize() throws Exception { List<ExternalTaskExecutionInfo> tasks = ContainerUtilRt.newArrayList(); myModel.setTasks(tasks); myModel.ensureSize(ExternalSystemConstants.RECENT_TASKS_NUMBER); Assert.assertEquals("task list widening failed", ExternalSystemConstants.RECENT_TASKS_NUMBER, myModel.getSize()); for (int i = 0; i < ExternalSystemConstants.RECENT_TASKS_NUMBER + 1; i++) { tasks.add(new ExternalTaskExecutionInfo(new ExternalSystemTaskExecutionSettings(), "task" + i)); } myModel.setTasks(tasks); Assert.assertEquals(ExternalSystemConstants.RECENT_TASKS_NUMBER + 1, myModel.getSize()); myModel.ensureSize(ExternalSystemConstants.RECENT_TASKS_NUMBER); Assert.assertEquals("task list reduction failed", ExternalSystemConstants.RECENT_TASKS_NUMBER, myModel.getSize()); }
@SuppressWarnings("unchecked") public void ensureSize(int elementsNumber) { int toAdd = elementsNumber - size(); if (toAdd == 0) { return; } if(toAdd < 0) { removeRange(elementsNumber, size() - 1); } while (--toAdd >= 0) { addElement(new MyEmptyDescriptor()); } }
ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void ensureSize(int elementsNumber) { int toAdd = elementsNumber - size(); if (toAdd == 0) { return; } if(toAdd < 0) { removeRange(elementsNumber, size() - 1); } while (--toAdd >= 0) { addElement(new MyEmptyDescriptor()); } } }
ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void ensureSize(int elementsNumber) { int toAdd = elementsNumber - size(); if (toAdd == 0) { return; } if(toAdd < 0) { removeRange(elementsNumber, size() - 1); } while (--toAdd >= 0) { addElement(new MyEmptyDescriptor()); } } ExternalSystemRecentTaskListModel(@Nonnull ProjectSystemId externalSystemId, @Nonnull Project project); }
ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void ensureSize(int elementsNumber) { int toAdd = elementsNumber - size(); if (toAdd == 0) { return; } if(toAdd < 0) { removeRange(elementsNumber, size() - 1); } while (--toAdd >= 0) { addElement(new MyEmptyDescriptor()); } } ExternalSystemRecentTaskListModel(@Nonnull ProjectSystemId externalSystemId, @Nonnull Project project); @SuppressWarnings("unchecked") void setTasks(@Nonnull List<ExternalTaskExecutionInfo> tasks); @SuppressWarnings("unchecked") void setFirst(@Nonnull ExternalTaskExecutionInfo task); @Nonnull List<ExternalTaskExecutionInfo> getTasks(); @SuppressWarnings("unchecked") void ensureSize(int elementsNumber); void forgetTasksFrom(@Nonnull String externalProjectPath); }
ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void ensureSize(int elementsNumber) { int toAdd = elementsNumber - size(); if (toAdd == 0) { return; } if(toAdd < 0) { removeRange(elementsNumber, size() - 1); } while (--toAdd >= 0) { addElement(new MyEmptyDescriptor()); } } ExternalSystemRecentTaskListModel(@Nonnull ProjectSystemId externalSystemId, @Nonnull Project project); @SuppressWarnings("unchecked") void setTasks(@Nonnull List<ExternalTaskExecutionInfo> tasks); @SuppressWarnings("unchecked") void setFirst(@Nonnull ExternalTaskExecutionInfo task); @Nonnull List<ExternalTaskExecutionInfo> getTasks(); @SuppressWarnings("unchecked") void ensureSize(int elementsNumber); void forgetTasksFrom(@Nonnull String externalProjectPath);  }