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;
  }
  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 addCurrentCourse(List list, String course) {
   if (list.getItem(0).equals("No Courses Selected")) {
     list.remove(0);
     list.add(course);
   } else {
     list.add(course);
   }
 }
Example #4
0
  public void handleEvent(Event event) {
    String input;

    for (int i : list.getSelectionIndices()) {
      input = list.getItem(i).split(" ")[0];
      getController().notifyEbookChanged(input);
    }
  }
Example #5
0
  private void handleConverterSelection() {
    // Determine which configuration was selected
    int selectionIndex = convertersList.getSelectionIndex();

    String selectedConverterName = convertersList.getItem(selectionIndex);

    IConfigurationElement selectedElement = getConversionElements().get(selectedConverterName);
    setSelectedConversionElement(selectedElement);
    return;
  }
 private void editPressed() {
   setPresentsDefaultValue(false);
   String value = list.getItem(list.getSelectionIndex());
   value = promptForText(local.getString("entNewVal"), value);
   if (value != null && isTextValid(value)) {
     list.setItem(list.getSelectionIndex(), value);
     selectionChanged();
   } else {
     showErrorMessage(local.getString("invalid") + value);
   }
 }
 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();
 }
Example #8
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();
     }
   }
 }
  @Override
  public void widgetSelected(SelectionEvent e) {

    if (retrieveMessageButton.isFocusControl()) {
      if (!clicked) {
        try {
          MessageReceiverHighLevelClass.ReceiveMessage(
              queueList.getItem(queueList.getSelectionIndex()));
          retrieveMessageButton.setText("Next Message");
          clicked = true;
        } catch (IOException e1) {
          e1.printStackTrace();
        }
      } else MessageReceiverHighLevelClass.GetNextMessage();
    } else if (closeButton.isFocusControl()) {
      MessageReceiverHighLevelClass.CloseApplication();
    }
  }
Example #10
0
  void listEvent(Event event) {
    switch (event.type) {
      case SWT.Dispose:
        if (getShell() != popup.getParent()) {
          String[] items = list.getItems();
          int selectionIndex = list.getSelectionIndex();
          popup = null;
          list = null;
          createPopup(items, selectionIndex);
        }
        break;
      case SWT.FocusIn:
        {
          handleFocus(SWT.FocusIn);
          break;
        }
      case SWT.MouseUp:
        {
          if (event.button != 1) return;
          dropDown(false);
          break;
        }
      case SWT.Selection:
        {
          int index = list.getSelectionIndex();
          if (index == -1) return;
          text.setText(list.getItem(index));
          //    text.selectAll ();
          list.setSelection(index);
          //    list.forceFocus();

          Event e = new Event();
          e.time = event.time;
          e.stateMask = event.stateMask;
          e.doit = event.doit;
          notifyListeners(SWT.Selection, e);
          event.doit = e.doit;
          break;
        }
      case SWT.Traverse:
        {
          switch (event.detail) {
            case SWT.TRAVERSE_RETURN:
            case SWT.TRAVERSE_ESCAPE:
            case SWT.TRAVERSE_ARROW_PREVIOUS:
            case SWT.TRAVERSE_ARROW_NEXT:
              event.doit = false;
              break;
          }
          Event e = new Event();
          e.time = event.time;
          e.detail = event.detail;
          e.doit = event.doit;
          e.character = event.character;
          e.keyCode = event.keyCode;
          notifyListeners(SWT.Traverse, e);
          event.doit = e.doit;
          event.detail = e.detail;
          break;
        }
      case SWT.KeyUp:
        {
          Event e = new Event();
          e.time = event.time;
          e.character = event.character;
          e.keyCode = event.keyCode;
          e.stateMask = event.stateMask;
          notifyListeners(SWT.KeyUp, e);
          break;
        }

      case SWT.KeyDown:
        {
          if (event.character == SWT.ESC) {
            // Escape key cancels popup list
            dropDown(false);
          }
          if ((event.stateMask & SWT.ALT) != 0
              && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) {
            dropDown(false);
          }
          if (event.character == SWT.CR) {
            // Enter causes default selection
            dropDown(false);
            Event e = new Event();
            e.time = event.time;
            e.stateMask = event.stateMask;
            notifyListeners(SWT.DefaultSelection, e);
          }
          // At this point the widget may have been disposed.
          // If so, do not continue.
          if (isDisposed()) break;
          Event e = new Event();
          e.time = event.time;
          e.character = event.character;
          e.keyCode = event.keyCode;
          e.stateMask = event.stateMask;
          notifyListeners(SWT.KeyDown, e);
          break;
        }
    }
  }
Example #11
0
 public String getItem(int index) {
   checkWidget();
   return list.getItem(index);
 }