Exemplo n.º 1
0
  protected void initializeFields() {
    Iterator<Object> e = fColorButtons.keySet().iterator();
    while (e.hasNext()) {
      ColorSelector c = (ColorSelector) e.next();
      String key = fColorButtons.get(c);
      RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
      c.setColorValue(rgb);
    }

    e = fCheckBoxes.keySet().iterator();
    while (e.hasNext()) {
      Button b = (Button) e.next();
      String key = fCheckBoxes.get(b);
      b.setSelection(fOverlayStore.getBoolean(key));
    }

    e = fTextFields.keySet().iterator();
    while (e.hasNext()) {
      Text t = (Text) e.next();
      String key = fTextFields.get(t);
      t.setText(fOverlayStore.getString(key));
    }

    e = fComboBoxes.keySet().iterator();
    while (e.hasNext()) {
      Combo c = (Combo) e.next();
      String key = fComboBoxes.get(c);
      String state = fOverlayStore.getString(key);
      // Interpret the state string as a Combo state description
      ProposalFilterPreferencesUtil.restoreComboFromString(c, state);
    }
  }
  void handleSyntaxColorListSelection() {
    final TokenHighlight item = getHighlight();

    fEnableCheckbox.setEnabled(item != null);
    fSyntaxForegroundColorEditor.getButton().setEnabled(item != null);
    fColorEditorLabel.setEnabled(item != null);
    fBoldCheckBox.setEnabled(item != null);
    fItalicCheckBox.setEnabled(item != null);
    fStrikethroughCheckBox.setEnabled(item != null);
    fUnderlineCheckBox.setEnabled(item != null);

    if (item == null) {
      return;
    }

    final HighlightStyle style = item.getStyle(fOverlayStore);
    fSyntaxForegroundColorEditor.setColorValue(style.getColor());
    fBoldCheckBox.setSelection(style.hasStyle(SWT.BOLD));
    fItalicCheckBox.setSelection(style.hasStyle(SWT.ITALIC));
    fStrikethroughCheckBox.setSelection(style.hasStyle(TextAttribute.STRIKETHROUGH));
    fUnderlineCheckBox.setSelection(style.hasStyle(TextAttribute.UNDERLINE));

    // if (item instanceof SemanticHighlightingColorListItem) {
    // fEnableCheckbox.setEnabled(true);
    // final boolean enable = getPreferenceStore().getBoolean(
    // ((SemanticHighlightingColorListItem) item).getEnableKey());
    // fEnableCheckbox.setSelection(enable);
    // fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
    // fColorEditorLabel.setEnabled(enable);
    // fBoldCheckBox.setEnabled(enable);
    // fItalicCheckBox.setEnabled(enable);
    // fStrikethroughCheckBox.setEnabled(enable);
    // fUnderlineCheckBox.setEnabled(enable);
    // }
  }
 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]);
 }
  @Override
  public void refresh() {
    ISplashInfo info = getSplashInfo();
    fBlockNotification = true;

    fColorSelector.setColorValue(hexToRGB(info.getForegroundColor()));

    int[] pgeo = info.getProgressGeometry();
    boolean addProgress = pgeo != null;
    info.addProgressBar(addProgress, fBlockNotification);
    if (addProgress) {
      for (int i = 0; i < pgeo.length; i++) {
        fBarSpinners[i].setSelection(pgeo[i]);
      }
    } else {
      resetProgressBarGeometry();
    }

    fAddBarButton.setSelection(addProgress);

    int[] mgeo = info.getMessageGeometry();
    boolean addMessage = mgeo != null;
    info.addProgressMessage(addMessage, fBlockNotification);
    if (addMessage) {
      for (int i = 0; i < mgeo.length; i++) {
        fMessageSpinners[i].setSelection(mgeo[i]);
      }
    } else {
      resetProgressMessageGeometry();
    }
    fColorSelector.setColorValue(
        addMessage ? hexToRGB(info.getForegroundColor()) : new RGB(0, 0, 0));

    fAddMessageButton.setSelection(addMessage);

    // Update the UI
    updateUIFieldTemplateCombo();
    fBlockNotification = false;
    super.refresh();
    // Update this sections enablement
    updateFieldEnablement();
  }
Exemplo n.º 5
0
  /**
   * Notifies that the selection is changed on attributes viewer.
   *
   * @param selection The selection
   */
  void viewerSlectionChanged(IStructuredSelection selection) {
    if (selection.isEmpty()) {
      if (removeButton != null) {
        removeButton.setEnabled(false);
      }
      colorSelector.setEnabled(false);
      return;
    }

    MBeanAttribute attribute = (MBeanAttribute) selection.getFirstElement();
    if (removeButton != null) {
      removeButton.setEnabled(true);
    }
    colorSelector.setEnabled(true);
    colorSelector.setColorValue(attribute.getRgb());
  }
 private void handleSyntaxColorListSelection() {
   HighlightingColorListItem item = getHighlightingColorListItem();
   if (item == null) {
     fEnableCheckbox.setEnabled(false);
     fSyntaxForegroundColorEditor.getButton().setEnabled(false);
     fColorEditorLabel.setEnabled(false);
     fBoldCheckBox.setEnabled(false);
     fItalicCheckBox.setEnabled(false);
     fStrikethroughCheckBox.setEnabled(false);
     fUnderlineCheckBox.setEnabled(false);
     return;
   }
   RGB rgb = PreferenceConverter.getColor(getPreferenceStore(), item.getColorKey());
   fSyntaxForegroundColorEditor.setColorValue(rgb);
   fBoldCheckBox.setSelection(getPreferenceStore().getBoolean(item.getBoldKey()));
   fItalicCheckBox.setSelection(getPreferenceStore().getBoolean(item.getItalicKey()));
   fStrikethroughCheckBox.setSelection(
       getPreferenceStore().getBoolean(item.getStrikethroughKey()));
   fUnderlineCheckBox.setSelection(getPreferenceStore().getBoolean(item.getUnderlineKey()));
   if (item instanceof SemanticHighlightingColorListItem) {
     boolean semanticHighlightingEnabled =
         getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED);
     fEnableCheckbox.setEnabled(semanticHighlightingEnabled);
     boolean enable =
         semanticHighlightingEnabled
             && getPreferenceStore()
                 .getBoolean(((SemanticHighlightingColorListItem) item).getEnableKey());
     fEnableCheckbox.setSelection(enable);
     fSyntaxForegroundColorEditor.getButton().setEnabled(enable);
     fColorEditorLabel.setEnabled(enable);
     fBoldCheckBox.setEnabled(enable);
     fItalicCheckBox.setEnabled(enable);
     fStrikethroughCheckBox.setEnabled(enable);
     fUnderlineCheckBox.setEnabled(enable);
   } else {
     fSyntaxForegroundColorEditor.getButton().setEnabled(true);
     fColorEditorLabel.setEnabled(true);
     fBoldCheckBox.setEnabled(true);
     fItalicCheckBox.setEnabled(true);
     fStrikethroughCheckBox.setEnabled(true);
     fUnderlineCheckBox.setEnabled(true);
     fEnableCheckbox.setEnabled(false);
     fEnableCheckbox.setSelection(true);
   }
 }
Exemplo n.º 7
0
  public void setEditingRegion(final AbstractSelectionRegion<?> region) {

    this.editingRegion = region;
    this.roiViewer.setRegion(region.getROI(), region.getRegionType(), region.getCoordinateSystem());
    this.roiListener =
        new IROIListener.Stub() {
          @Override
          public void roiChanged(ROIEvent evt) {
            region.setROI(evt.getROI());
          }
        };
    roiViewer.addROIListener(roiListener);

    Range range = xyGraph.primaryXAxis.getRange();
    roiViewer.setXLowerBound(Math.min(range.getUpper(), range.getLower()));
    roiViewer.setXUpperBound(Math.max(range.getUpper(), range.getLower()));

    range = xyGraph.primaryYAxis.getRange();
    roiViewer.setYLowerBound(Math.min(range.getUpper(), range.getLower()));
    roiViewer.setYUpperBound(Math.max(range.getUpper(), range.getLower()));

    nameText.setText(region.getName());
    regionType.select(region.getRegionType().getIndex());
    regionType.setEnabled(false);
    regionType.setEditable(false);

    int index = xyGraph.getXAxisList().indexOf(region.getCoordinateSystem().getX());
    xCombo.select(index);

    index = xyGraph.getYAxisList().indexOf(region.getCoordinateSystem().getY());
    yCombo.select(index);

    colorSelector.setColorValue(region.getRegionColor().getRGB());
    alpha.setSelection(region.getAlpha());
    mobile.setSelection(region.isMobile());
    showPoints.setSelection(region.isShowPosition());
    visible.setSelection(region.isVisible());
    showLabel.setSelection(region.isShowLabel());
    fillRegion.setSelection(region.isFill());
  }
Exemplo n.º 8
0
  private void initialize() {
    nameText.setText(annotation.getName());
    nameText.setSelection(0, nameText.getText().length());
    snapToTrace.setSelection(!annotation.isFree());
    xAxisLabel.setText(
        snapToTrace.getSelection() ? Messages.Annotation_Trace : Messages.Annotation_XAxis);
    xAxisOrTraceCombo.removeAll();
    if (!annotation.isFree()) {
      for (Trace trace : xyGraph.getPlotArea().getTraceList())
        xAxisOrTraceCombo.add(trace.getName());
      xAxisOrTraceCombo.select(xyGraph.getPlotArea().getTraceList().indexOf(annotation.getTrace()));
    } else {
      for (Axis axis : xyGraph.getXAxisList()) xAxisOrTraceCombo.add(axis.getTitle());
      xAxisOrTraceCombo.select(xyGraph.getXAxisList().indexOf(annotation.getXAxis()));
    }
    for (Axis axis : xyGraph.getYAxisList()) yAxisCombo.add(axis.getTitle());
    yAxisCombo.select(xyGraph.getYAxisList().indexOf(annotation.getYAxis()));
    yAxisLabel.setVisible(!snapToTrace.getSelection());
    yAxisCombo.setVisible(!snapToTrace.getSelection());
    useDefaultColorButton.setSelection(annotation.getAnnotationColor() == null);
    colorLabel.setVisible(!useDefaultColorButton.getSelection());
    colorSelector.getButton().setVisible(annotation.getAnnotationColor() != null);
    colorSelector.setColorValue(
        annotation.getAnnotationColor() == null
            ? annotation.getYAxis().getForegroundColor().getRGB()
            : annotation.getAnnotationColor().getRGB());

    fontLabel.setText(
        Messages.Annotation_Font
            + (font == null ? Messages.Annotation_SystemDefault : font.getFontData()[0].getName()));
    fontLabel.setFont(font);
    cursorLineCombo.select(annotation.getCursorLineStyle().getIndex());
    showNameButton.setSelection(annotation.isShowName());
    showSampleInfoButton.setSelection(annotation.isShowSampleInfo());
    showPositionButton.setSelection(annotation.isShowPosition());
  }
Exemplo n.º 9
0
  /**
   * Used internally
   *
   * @param parent
   * @param plottingSystem
   * @param style
   * @param xyGraph
   * @param defaultRegion
   * @param isImplicit Flag to tell whether the RegionComposite is used in a specific window with an
   *     apply button or part of a view where the changes are implicit
   */
  public RegionEditComposite(
      final Composite parent,
      final IPlottingSystem<?> plottingSystem,
      final int style,
      final XYRegionGraph xyGraph,
      final RegionType defaultRegion,
      final boolean isImplicit) {

    super(parent, SWT.NONE);

    this.setImplicit(isImplicit);

    this.xyGraph = xyGraph;
    this.plottingSystem = plottingSystem;

    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    setLayout(new org.eclipse.swt.layout.GridLayout(2, false));

    final Label nameLabel = new Label(this, SWT.NONE);
    nameLabel.setText("Name   ");
    nameLabel.setLayoutData(new GridData());

    nameText = new Text(this, SWT.BORDER | SWT.SINGLE);
    nameText.setToolTipText("Region name");
    nameText.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    if (isImplicit()) {
      nameText.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label horiz = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    horiz.setLayoutData(new GridData(SWT.FILL, 0, true, false, 2, 1));

    final Label typeLabel = new Label(this, SWT.NONE);
    typeLabel.setText("Type");
    typeLabel.setLayoutData(new GridData());

    regionType = new CCombo(this, SWT.BORDER | SWT.NONE);
    regionType.setEditable(false);
    regionType.setToolTipText("Region type");
    regionType.setLayoutData(new GridData(SWT.FILL, 0, true, false));
    for (RegionType type : RegionType.ALL_TYPES) {
      regionType.add(type.getName());
    }
    regionType.select(defaultRegion.getIndex());

    xCombo = createAxisChooser(this, "X Axis", xyGraph.getXAxisList());
    yCombo = createAxisChooser(this, "Y Axis", xyGraph.getYAxisList());

    Label colorLabel = new Label(this, 0);
    colorLabel.setText("Selection Color");
    colorLabel.setLayoutData(new GridData());

    colorSelector = new ColorSelector(this);
    colorSelector.getButton().setLayoutData(new GridData());
    colorSelector.setColorValue(defaultRegion.getDefaultColor().getRGB());
    if (isImplicit()) {
      colorSelector.addListener(
          new IPropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent event) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label horiz2 = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    horiz2.setLayoutData(new GridData(SWT.FILL, 0, true, false, 2, 1));

    Label alphaLabel = new Label(this, 0);
    alphaLabel.setText("Alpha level");
    alphaLabel.setLayoutData(new GridData());

    alpha = new Spinner(this, SWT.NONE);
    alpha.setToolTipText("Alpha transparency level of the shaded shape");
    alpha.setLayoutData(new GridData());
    alpha.setMinimum(0);
    alpha.setMaximum(255);
    alpha.setSelection(80);
    if (isImplicit()) {
      alpha.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.mobile = new Button(this, SWT.CHECK);
    mobile.setText("   Mobile   ");
    mobile.setToolTipText("When true, this selection can be resized and moved around the graph.");
    mobile.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    mobile.setSelection(true);
    if (isImplicit()) {
      mobile.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.showPoints = new Button(this, SWT.CHECK);
    showPoints.setText("   Show vertex values");
    showPoints.setToolTipText(
        "When on this will show the actual value of the point in the axes it was added.");
    showPoints.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    if (isImplicit()) {
      showPoints.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.visible = new Button(this, SWT.CHECK);
    visible.setText("   Show region");
    visible.setToolTipText("You may turn off the visibility of this region.");
    visible.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    visible.setSelection(true);
    if (isImplicit()) {
      visible.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.showLabel = new Button(this, SWT.CHECK);
    showLabel.setText("   Show name");
    showLabel.setToolTipText("Turn on to show the name of a selection region.");
    showLabel.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    showLabel.setSelection(true);
    if (isImplicit()) {
      showLabel.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    this.fillRegion = new Button(this, SWT.CHECK);
    fillRegion.setText("   Fill region");
    fillRegion.setToolTipText("Fill the body of an area region");
    fillRegion.setLayoutData(new GridData(0, 0, false, false, 2, 1));
    fillRegion.setSelection(true);
    if (isImplicit()) {
      fillRegion.addSelectionListener(
          new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
              AbstractSelectionRegion<?> region = getEditingRegion();
              region.repaint();
            }
          });
    }

    final Label spacer = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
    spacer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    // We add a composite for setting the region location programmatically.
    final Label location = new Label(this, SWT.NONE);
    location.setText("Region Location");
    location.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));

    this.roiViewer = new ROIEditTable();
    roiViewer.createPartControl(this);

    // Should be last
    nameText.setText(getDefaultName(defaultRegion.getIndex()));
  }
  @Override
  protected Control createContents(Composite parent) {
    parent = new Composite(parent, SWT.NONE);
    parent.setLayout(new GridLayout(3, false));

    Label label = new Label(parent, SWT.NONE);
    label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    label.setText(
        WordUtils.wrap(local.getString("chatConColP1"), 70)
            + WordUtils.wrap(local.getString("chatConColP2"), 70));

    Label channelNamesLabel = new Label(parent, SWT.NONE);
    channelNamesLabel.setText(local.getString("channels"));
    channelNamesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

    channels = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    channels.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
    channels.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            String selectedChannelName = channels.getItem(channels.getSelectionIndex());
            channelName.setText(selectedChannelName);
            String key = getKey(selectedChannelName);
            colorSelector.setColorValue(raptorPreferenceStore.getColor(key).getRGB());
          }
        });

    Label channelNameLabel = new Label(parent, SWT.NONE);
    channelNameLabel.setText(local.getString("chanName"));
    channelNameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

    channelName = new Text(parent, SWT.SINGLE | SWT.BORDER);
    channelName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    colorSelector = new ColorSelector(parent);
    colorSelector.getButton().setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));

    saveButton = new Button(parent, SWT.PUSH);
    saveButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
    saveButton.setText(local.getString("svAddChCol"));
    saveButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onSave();
          }
        });

    // deleteButton = new Button(parent, SWT.PUSH);
    // deleteButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false,
    // false, 2, 1));
    // deleteButton.setText("Delete Channel Color");
    // deleteButton.addSelectionListener(new SelectionAdapter() {
    // @Override
    // public void widgetSelected(SelectionEvent e) {
    // try {
    // int channelInt = Integer.parseInt(channelName.getText());
    // String key = getKey("" + channelInt);
    // channels.remove("" + channelInt);
    // raptorPreferenceStore.putValue(key, null);
    // } catch (NumberFormatException nfe) {
    // MessageDialog
    // .openInformation(Raptor.getInstance()
    // .getRaptorWindow().getShell(), "Alert",
    // "Channel name must be an integer greater than -1 and less than 256.");
    // }
    // }
    // });

    updateChannelsCombo();
    if (channels.getItemCount() > 0) {
      channels.select(0);
      String selectedChannelName = channels.getItem(channels.getSelectionIndex());
      channelName.setText(selectedChannelName);
      String key = getKey(selectedChannelName);
      colorSelector.setColorValue(raptorPreferenceStore.getColor(key).getRGB());
    }

    return parent;
  }