@Override
  public IFieldControlData addRegistryBrowseButton(
      Composite container,
      Shell shell,
      String label,
      String buttonCaption,
      Text txtValue,
      int selectedOption,
      ProjectDataModel model,
      String pathBindingProperty) {

    IFieldControlData regFiledControlData = null;

    if (txtValue.getEditable()) {
      regFiledControlData = new ResourceTextFieldControlData(txtValue);
    } else {
      regFiledControlData = new ResourceFieldControlData(txtValue);
    }

    btnRegBrowse = new Button(container, SWT.None);
    btnRegBrowse.setText(buttonCaption);
    btnRegBrowse.addSelectionListener(
        createResourceSelectionListner(
            shell, txtValue, selectedOption, model, pathBindingProperty));

    WSO2UIToolkit.propagateControlStatus(txtValue, regLabel, btnRegBrowse);
    return regFiledControlData;
  }
示例#2
0
 public int getStyle() {
   int style = super.getStyle();
   style &= ~SWT.READ_ONLY;
   if (!text.getEditable()) style |= SWT.READ_ONLY;
   return style;
 }
示例#3
0
 public boolean getEditable() {
   checkWidget();
   return text.getEditable();
 }
示例#4
0
  void textEvent(Event event) {
    switch (event.type) {
      case SWT.FocusIn:
        {
          handleFocus(SWT.FocusIn);
          break;
        }
      case SWT.KeyDown:
        {
          if (event.character == SWT.CR) {
            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;

          if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
            event.doit = false;
            if ((event.stateMask & SWT.ALT) != 0) {
              boolean dropped = isDropped();
              text.selectAll();
              if (!dropped) setFocus();
              dropDown(!dropped);
              break;
            }

            int oldIndex = getSelectionIndex();
            if (event.keyCode == SWT.ARROW_UP && popup.isVisible()) {
              select(Math.max(oldIndex - 1, 0));
            } else if (popup.isVisible()) {
              select(Math.min(oldIndex + 1, getItemCount() - 1));
            }
            if (oldIndex != getSelectionIndex()) {
              Event e = new Event();
              e.time = event.time;
              e.stateMask = event.stateMask;
              notifyListeners(SWT.Selection, e);
            }
            // At this point the widget may have been disposed.
            // If so, do not continue.
            if (isDisposed()) break;
          }

          // Further work : Need to add support for incremental search in
          // pop up list as characters typed in text widget

          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;
        }
      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.Modify:
        {
          list.deselectAll();
          Event e = new Event();
          e.time = event.time;
          notifyListeners(SWT.Modify, e);
          break;
        }

      case SWT.MouseDown:
        {
          if (event.button != 1) return;
          if (text.getEditable()) return;
          boolean dropped = isDropped();
          text.selectAll();
          if (!dropped) setFocus();
          dropDown(!dropped);
          break;
        }

      case SWT.MouseUp:
        {
          if (event.button != 1) return;
          if (text.getEditable()) return;
          text.selectAll();
          break;
        }

      case SWT.Traverse:
        {
          switch (event.detail) {
            case SWT.TRAVERSE_RETURN:
            case SWT.TRAVERSE_ARROW_PREVIOUS:
            case SWT.TRAVERSE_ARROW_NEXT:
              // The enter causes default selection and
              // the arrow keys are used to manipulate the list contents so
              // do not use them for traversal.
              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;
        }
    }
  }
示例#5
0
 /**
  * Sets the receiver's list to be the given array of items.
  *
  * @param items the array of items
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the items array is null
  *       <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null
  *     </ul>
  *
  * @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 setItems(String[] items) {
   checkWidget();
   list.setItems(items);
   if (!text.getEditable()) text.setText(""); // $NON-NLS-1$
 }