Exemplo n.º 1
0
 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 void storeDefault() {
   LocalizedPropertiesPlugin.getDefault()
       .getPreferenceStore()
       .setValue(
           PreferenceConstants.WILDCARD_PATH_DEFAULT_INDEX_PREFERENCES,
           listControl.getSelectionIndex());
 }
  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;
  }
Exemplo n.º 5
0
  /**
   * {@inheritDoc}
   *
   * @return Returns an instance of <tt>StructuredSelection</tt> which is either empty or contains
   *     the selected instance of <tt>ProductInfo</tt>.
   * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
   */
  @Override
  public ISelection getSelection() {
    int selIdx = productTypeGUIList.getSelectionIndex();
    if (selIdx < 0) return new StructuredSelection(new Object[] {});

    return new StructuredSelection(productTypeItemList.get(selIdx));
  }
Exemplo n.º 6
0
  private void dropDown(boolean drop) {
    if (drop == isDropped()) return;
    if (!drop) {
      popup.setVisible(false);
      if (!isDisposed() && arrow.isFocusControl()) {
        text.setFocus();
      }
      return;
    }

    if (getShell() != popup.getParent()) {
      String[] items = list.getItems();
      int selectionIndex = list.getSelectionIndex();
      list.removeListener(SWT.Dispose, listener);
      popup.dispose();
      popup = null;
      list = null;
      createPopup(items, selectionIndex);
    }

    computeShowArea();

    popup.setAlpha(popup.getFinalAlpha());
    popup.setVisible(true);
  }
 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 void handleAppearanceColorListSelection() {
   int i = fAppearanceColorList.getSelectionIndex();
   if (i == -1) return;
   String key = fAppearanceColorListModel[i][1];
   RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), key);
   fAppearanceColorEditor.setColorValue(rgb);
   updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]);
 }
Exemplo n.º 9
0
 /** Notifies that the Remove button has been pressed. */
 private void removePressed() {
   setPresentsDefaultValue(false);
   int index = list.getSelectionIndex();
   if (index >= 0) {
     list.remove(index);
     selectionChanged();
   }
 }
 /**
  * Callback invoked when an item is selected in the page list. If this is not an internal page
  * change, displays the given page.
  */
 private void onPageListSelected() {
   if (mInternalPageChange == false) {
     int index = mPageList.getSelectionIndex();
     if (index >= 0) {
       displayPage(index);
     }
   }
 }
Exemplo n.º 11
0
 void paintCanvas(Event event) {
   canvas.setCursor(null);
   int index = list.getSelectionIndex();
   if (index == -1) return;
   GC gc = event.gc;
   Object object = objects[index];
   if (object instanceof Color) {
     if (((Color) object).isDisposed()) return;
     gc.setBackground((Color) object);
     gc.fillRectangle(canvas.getClientArea());
     return;
   }
   if (object instanceof Cursor) {
     if (((Cursor) object).isDisposed()) return;
     canvas.setCursor((Cursor) object);
     return;
   }
   if (object instanceof Font) {
     if (((Font) object).isDisposed()) return;
     gc.setFont((Font) object);
     FontData[] array = gc.getFont().getFontData();
     StringBuffer sb = new StringBuffer();
     String lf = text.getLineDelimiter();
     for (int i = 0; i < array.length; i++) {
       FontData data = array[i];
       String style = "NORMAL"; // $NON-NLS-1$
       int bits = data.getStyle();
       if (bits != 0) {
         if ((bits & SWT.BOLD) != 0) style = "BOLD "; // $NON-NLS-1$
         if ((bits & SWT.ITALIC) != 0) style += "ITALIC"; // $NON-NLS-1$
       }
       sb.append(data.getName())
           .append(" ")
           .append(data.getHeight()) // $NON-NLS-1$
           .append(" ")
           .append(style)
           .append(lf); // $NON-NLS-1$
     }
     gc.drawString(sb.toString(), 0, 0);
     return;
   }
   // NOTHING TO DRAW FOR GC
   // if (object instanceof GC) {
   // return;
   // }
   if (object instanceof Image) {
     if (((Image) object).isDisposed()) return;
     gc.drawImage((Image) object, 0, 0);
     return;
   }
   if (object instanceof Region) {
     if (((Region) object).isDisposed()) return;
     String string = ((Region) object).getBounds().toString();
     gc.drawString(string, 0, 0);
     return;
   }
 }
 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 void selectionChanged1() {
   if (listControl == null) {
     listControl = getListControl(parent);
   }
   int defaultIndex =
       LocalizedPropertiesPlugin.getDefault()
           .getPreferenceStore()
           .getInt(PreferenceConstants.WILDCARD_PATH_DEFAULT_INDEX_PREFERENCES);
   defaultButton.setEnabled(listControl.getSelectionIndex() != defaultIndex);
 }
Exemplo n.º 14
0
  /** 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);
  }
Exemplo n.º 15
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;
  }
Exemplo n.º 16
0
 protected EdgeExtension.Edge getEditingEdge() {
   EdgeExtension ext = (EdgeExtension) animateSet.findExtension("EDGE");
   if (ext == null) {
     return null;
   }
   int sel = borderList.getSelectionIndex();
   if (sel == -1) {
     return null;
   }
   return ext.edges.get(sel);
 }
Exemplo n.º 17
0
  @Override
  public ProductTypeSelector.Item getSelectedProductTypeItem(
      boolean throwExceptionIfNothingSelected) {
    int productIdx = productTypeGUIList.getSelectionIndex();
    if (throwExceptionIfNothingSelected && productIdx < 0)
      throw new IllegalStateException("Nothing selected!"); // $NON-NLS-1$

    if (productIdx < 0) return null;

    return productTypeItemList.get(productIdx);
  }
Exemplo n.º 18
0
 protected void onDeleteEdge() {
   EdgeExtension ext = (EdgeExtension) animateSet.findExtension("EDGE");
   if (ext == null) {
     return;
   }
   int sel = borderList.getSelectionIndex();
   ext.edges.remove(sel);
   owner.setDirty(true);
   borderListViewer.refresh();
   edgeSelectionChanged();
 }
Exemplo n.º 19
0
  /**
   * Moves the currently selected item up or down.
   *
   * @param up <code>true</code> if the item should move up, and <code>false</code> if it should
   *     move down
   */
  private void swap(boolean up) {
    setPresentsDefaultValue(false);
    int index = list.getSelectionIndex();
    int target = up ? index - 1 : index + 1;

    if (index >= 0) {
      String[] selection = list.getSelection();
      Assert.isTrue(selection.length == 1);
      list.remove(index);
      list.add(selection[0], target);
      list.setSelection(target);
    }
    selectionChanged();
  }
Exemplo n.º 20
0
 /** Notifies that the Add button has been pressed. */
 private void addPressed() {
   setPresentsDefaultValue(false);
   String value = promptForText(local.getString("entNewVal"));
   if (value != null && isTextValid(value)) {
     int index = list.getSelectionIndex();
     if (index >= 0) {
       list.add(value, index + 1);
     } else {
       list.add(value, 0);
     }
     selectionChanged();
   } else {
     showErrorMessage(local.getString("invalid") + value);
   }
 }
 @Override
 protected void okPressed() {
   if (consoleList.getSelectionIndex() == -1) {
     MessageDialog.openError(
         getShell(),
         Activator.GREP_CONSOLE_NAME,
         Messages.ConsoleConfigDialog_NoTextSourceConsoleSelected);
   } else {
     updateSearchHistory(ecgModel.getSearchString());
     if (ecgModel.isRangeMatching()) {
       updateSearchHistory(ecgModel.getSearchEndString());
     }
     super.okPressed();
   }
 }
Exemplo n.º 22
0
 void refreshObject() {
   int index = list.getSelectionIndex();
   if (index == -1) return;
   if (check.getSelection()) {
     ByteArrayOutputStream stream = new ByteArrayOutputStream();
     PrintStream s = new PrintStream(stream);
     errors[index].printStackTrace(s);
     text.setText(stream.toString());
     text.setVisible(true);
     canvas.setVisible(false);
   } else {
     canvas.setVisible(true);
     text.setVisible(false);
     canvas.redraw();
   }
 }
Exemplo n.º 23
0
 protected void edgeSelectionChanged() {
   EdgeExtension ext = (EdgeExtension) animateSet.findExtension("EDGE");
   int sel = borderList.getSelectionIndex();
   if (ext == null || sel == -1) {
     textFirstAnimate.setEnabled(false);
     textLastAnimate.setEnabled(false);
     editViewer.setInput(null, null);
   } else {
     textFirstAnimate.setEnabled(true);
     textLastAnimate.setEnabled(true);
     updating = true;
     textFirstAnimate.setText(String.valueOf(ext.edges.get(sel).beginAnimateIndex));
     textLastAnimate.setText(String.valueOf(ext.edges.get(sel).endAnimateIndex));
     editViewer.setInput(animateSet, ext.edges.get(sel));
     updating = false;
   }
 }
Exemplo n.º 24
0
 private boolean saveData() {
   params.segmentSource = chkSegmentSource.getSelection();
   if (params.segmentSource) {
     params.setSourceSrxPath(edSourceSRX.getText());
   }
   params.segmentTarget = chkSegmentTarget.getSelection();
   if (params.segmentTarget) {
     params.setTargetSrxPath(edTargetSRX.getText());
   }
   params.copySource = chkCopySource.getSelection();
   params.checkSegments = chkCheckSegments.getSelection();
   params.setForcesegmentedOutput(chkForceSegmentedOutput.getSelection());
   params.setSegmentationStrategy(
       SegmStrategy.values()[listBehaviorForSegmented.getSelectionIndex()]);
   result = true;
   return true;
 }
 private void doAdd() {
   setPresentsDefaultValue(false);
   Object[] input = getNewInputObjects();
   for (int i = 0; i < input.length; i++) {
     String s = this.labelProvider.getText(input[i]);
     int index = list.getSelectionIndex();
     int target = -1;
     if (index >= 0) {
       elements.add(index + 1, input[i]);
       list.add(s, target = index + 1);
     } else {
       elements.add(i, input[i]);
       list.add(s, target = i);
     }
     selectionChanged(target);
   }
 }
  @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();
    }
  }
Exemplo n.º 27
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);
  }
Exemplo n.º 28
0
  private void show() {
    if (rowDatas.size() == 0) return;

    int nr = wStepList.getSelectionIndex();

    java.util.List<Object[]> buffer = (java.util.List<Object[]>) rowDatas.get(nr);
    RowMetaInterface rowMeta = (RowMetaInterface) rowMetas.get(nr);
    String name = (String) stepNames.get(nr);

    if (rowMeta != null && buffer != null && buffer.size() > 0) {
      PreviewRowsDialog prd =
          new PreviewRowsDialog(
              shell, Variables.getADefaultVariableSpace(), SWT.NONE, name, rowMeta, buffer);
      prd.open();
    } else {
      MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
      mb.setText(
          BaseMessages.getString(PKG, "EnterPreviewRowsDialog.Dialog.NoPreviewRowsFound.Title"));
      mb.setMessage(
          BaseMessages.getString(PKG, "EnterPreviewRowsDialog.Dialog.NoPreviewRowsFound.Message"));
      mb.open();
    }
  }
Exemplo n.º 29
0
 @Override
 public void widgetSelected(SelectionEvent e) {
   performOk();
   switch (list.getSelectionIndex()) {
     case 0:
       updateEditors(SYNTAXCOLOR_KEYWORD);
       break;
     case 1:
       updateEditors(SYNTAXCOLOR_STRING);
       break;
     case 2:
       updateEditors(SYNTAXCOLOR_COMMENT);
       break;
     case 3:
       updateEditors(SYNTAXCOLOR_FUNCTION);
       break;
     case 4:
       updateEditors(SYNTAXCOLOR_DATATYPE);
       break;
     case 5:
       updateEditors(SYNTAXCOLOR_VAR);
       break;
     case 6:
       updateEditors(SYNTAXCOLOR_PARAM);
       break;
     case 7:
       updateEditors(SYNTAXCOLOR_FIELD);
       break;
     case 8:
       updateEditors(SYNTAXCOLOR_INTERFACE);
       break;
     case 9:
       updateEditors(SYNTAXCOLOR_CONSTRUCTOR);
       break;
   }
 }
Exemplo n.º 30
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;
        }
    }
  }