private void doRemove() {
   setPresentsDefaultValue(false);
   int index = list.getSelectionIndex();
   if (index >= 0) {
     list.remove(index);
     elements.remove(index);
     index = list.getItemCount() <= index ? list.getItemCount() - 1 : index;
     selectionChanged(index);
   }
 }
  private boolean findSource() {
    // Guess, user selects an entry in the list on the right.
    // Find a comparable entry in the source list...
    boolean found = false;

    int targetIndex = wTarget.getSelectionIndex();
    // Skip eventhing after the bracket...
    String targetString = wTarget.getItem(targetIndex).toUpperCase();

    int length = targetString.length();
    boolean first = true;

    while (!found && (length >= 2 || first)) {
      first = false;

      for (int i = 0; i < wSource.getItemCount() && !found; i++) {
        if (wSource.getItem(i).toUpperCase().indexOf(targetString.substring(0, length)) >= 0) {
          wSource.setSelection(i);
          found = true;
        }
      }
      length--;
    }
    return found;
  }
  public void addSelectedFilesToTargetList() {
    ISelection selection = sourceFileViewer.getSelection();

    if (isValidSourceFileViewerSelection(selection)) {
      java.util.List list = null;
      if (selection instanceof IStructuredSelection) {
        list = ((IStructuredSelection) selection).toList();

        if (list != null) {
          list = ((IStructuredSelection) selection).toList();
          for (Iterator i = list.iterator(); i.hasNext(); ) {
            IResource resource = (IResource) i.next();
            if (resource instanceof IFile) {
              // Check if its in the list. Don't add it if it is.
              String resourceName = resource.getFullPath().toString();
              if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName);
            }
          }
          setFiles(selectedListBox.getItems());
        }

        setAddButtonEnabled(false);

        if (selectedListBox.getItemCount() > 0) {
          removeAllButton.setEnabled(true);
          if (isFileMandatory) setPageComplete(true);
          if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true);
          else setRemoveButtonEnabled(false);
        }
      }
    }
  }
Beispiel #4
0
  public void widgetSelected(SelectionEvent e) {
    traceList.remove(traceList.getItemCount() - 1);

    for (IUndoListener listener : observer) {
      listener.notifyUndo();
    }
  }
 private void updateSelectionDependentActions() {
   int index = list.getSelectionIndex();
   int size = list.getItemCount();
   buttons[REMOVE].setEnabled(index >= 0);
   buttons[UP].setEnabled(size > 1 && index > 0);
   buttons[DOWN].setEnabled(size > 1 && index >= 0 && index < size - 1);
 }
  private boolean findTarget() {
    // Guess, user selects an entry in the list on the left.
    // Find a comparable entry in the target list...
    boolean found = false;

    int sourceIndex = wSource.getSelectionIndex();
    // Skip eventhing after the bracket...
    String sourceStr = wSource.getItem(sourceIndex).toUpperCase();

    int indexOfBracket = sourceStr.indexOf(EnterMappingDialog.STRING_ORIGIN_SEPARATOR);
    String sourceString = sourceStr;
    if (indexOfBracket >= 0) {
      sourceString = sourceStr.substring(0, indexOfBracket);
    }

    int length = sourceString.length();
    boolean first = true;

    while (!found && (length >= 2 || first)) {
      first = false;

      for (int i = 0; i < wTarget.getItemCount() && !found; i++) {
        if (wTarget.getItem(i).toUpperCase().indexOf(sourceString.substring(0, length)) >= 0) {
          wTarget.setSelection(i);
          found = true;
        }
      }
      length--;
    }

    return found;
  }
 @Override
 public void performApply(ILaunchConfigurationWorkingCopy configuration) {
   List<String> selectedList = new ArrayList<String>(selectedConfigsList.getItemCount());
   for (String item : selectedConfigsList.getItems()) {
     selectedList.add(item);
   }
   configuration.setAttribute(SELECTED_CONFIGURATION_LIST, selectedList);
 }
 public boolean checkIfFileInTarget(IFile fileToCheck) {
   String[] strings = selectedListBox.getItems();
   int size = selectedListBox.getItemCount();
   for (int i = 0; i < size; i++) {
     if (strings[i].compareTo(fileToCheck.getFullPath().toString()) == 0) return true;
   }
   return false;
 }
  /** Notifies that the list selection has changed. */
  private void selectionChanged() {

    int index = list.getSelectionIndex();
    int size = list.getItemCount();

    removeButton.setEnabled(index >= 0);
    editButton.setEnabled(index >= 0);
    upButton.setEnabled(size > 1 && index > 0);
    downButton.setEnabled(size > 1 && index >= 0 && index < size - 1);
  }
 private void selectionChanged(int newSelection) {
   // make StructuredChangedEvent and notify StructuredChangeListener
   StructuredChange change = new StructuredChange(elements);
   StructuredChangedEvent event = new StructuredChangedEvent(listContentProvider, change);
   structuredChangeListener.structureChanged(event);
   if (newSelection >= 0 && newSelection < list.getItemCount()) {
     list.select(newSelection);
   }
   updateSelectionDependentActions();
 }
 private void addRepositoryList() {
   java.util.List<GuvnorRepository> reps = Activator.getLocationManager().getRepositories();
   for (int i = 0; i < reps.size(); i++) {
     repLocations.add(reps.get(i).getLocation());
   }
   if (repLocations.getItemCount() > 0) {
     repLocations.setSelection(0);
     updateModel();
   }
 }
 private String prepareCopyString() {
   if (list == null || list.isDisposed()) {
     return ""; //$NON-NLS-1$
   }
   StringBuffer sb = new StringBuffer();
   String newLine = System.getProperty("line.separator"); // $NON-NLS-1$
   for (int i = 0; i < list.getItemCount(); i++) {
     sb.append(list.getItem(i));
     sb.append(newLine);
   }
   return sb.toString();
 }
 @Override
 public boolean isValid(ILaunchConfiguration launchConfig) {
   if (selectedConfigsList.getItemCount() == 0) {
     setErrorMessage("At least one configuration should be selected");
     return false;
   }
   for (String item : selectedConfigsList.getItems()) {
     if (!allConfigNames.contains((String) item)) {
       setErrorMessage("Configuration [" + item + "] is undefined");
       return false;
     }
   }
   setErrorMessage(null);
   return super.isValid(launchConfig);
 }
Beispiel #14
0
 /**
  * Selects the item at the given zero-relative index in the receiver's list. If the item at the
  * index was already selected, it remains selected. Indices that are out of range are ignored.
  *
  * @param index the index of the item to select
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void select(int index) {
   checkWidget();
   if (index == -1) {
     list.deselectAll();
     text.setText(""); // $NON-NLS-1$
     return;
   }
   if (0 <= index && index < list.getItemCount()) {
     if (index != getSelectionIndex()) {
       text.setText(list.getItem(index));
       text.selectAll();
       list.select(index);
       list.showSelection();
     }
   }
 }
Beispiel #15
0
  private void computeShowArea() {
    //    Point size = getSize ();
    int itemCount = list.getItemCount();
    itemCount = (itemCount == 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount);
    int itemHeight = list.getItemHeight() * itemCount;
    Point listSize = list.computeSize(SWT.DEFAULT, itemHeight, false);
    //  list.setBounds(1, 1, Math.min (size.x - 2, listSize.x), listSize.y);

    int index = list.getSelectionIndex();
    if (index != -1) list.setTopIndex(index);

    Display display = getDisplay();
    Rectangle listRect = list.getBounds();
    Rectangle parentRect = display.map(getParent(), null, getBounds());
    Point comboSize = getSize();
    Rectangle displayRect = getMonitor().getClientArea();
    int width = Math.max(comboSize.x, listRect.width + 2);
    int height = listRect.height + 2;
    int x = parentRect.x;
    int y = parentRect.y + comboSize.y;
    if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height;
    popup.setBounds(x, y, width - 15, listSize.y + 15);
  }
 @Override
 public void reveal(Object element) {
   Assert.isNotNull(element);
   int index = getElementIndex(element);
   if (index == -1) {
     return;
   }
   // algorithm patterned after List.showSelection()
   int count = list.getItemCount();
   if (count == 0) {
     return;
   }
   int height = list.getItemHeight();
   Rectangle rect = list.getClientArea();
   int topIndex = list.getTopIndex();
   int visibleCount = Math.max(rect.height / height, 1);
   int bottomIndex = Math.min(topIndex + visibleCount, count) - 1;
   if ((topIndex <= index) && (index <= bottomIndex)) {
     return;
   }
   int newTop = Math.min(Math.max(index - (visibleCount / 2), 0), count - 1);
   list.setTopIndex(newTop);
 }
 public void removeCurrentCourse(List list, String Course) {
   list.remove(Course);
   if (list.getItemCount() == 0) list.add("No Courses Selected");
 }
Beispiel #18
0
 public int getItemCount() {
   checkWidget();
   return list.getItemCount();
 }
 @Override
 protected int listGetItemCount() {
   return list.getItemCount();
 }