@Override
  public void customButtonPressed(ListDialogField<ObjectParameter> field, int index) {
    ObjectParameter parameter = new ObjectParameter();
    ObjectParameterConfigurationDialog dialog =
        new ObjectParameterConfigurationDialog(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            page.getResourceSet(),
            importList.getElements(),
            metamodelLoader,
            parameter);
    // a unique parameter object is needed because the dialog will be disposed after the ok button
    // is pressed
    if (index == 0) {
      // Add
      if (dialog.open() == Dialog.OK) {
        field.addElement(parameter);
      }
    } else if (index == 1) {
      // Modify
      ObjectParameter firstElement = field.getSelectedElements().get(0);
      parameter.setObject(firstElement.getObject());
      parameter.setParameterName(firstElement.getParameterName());
      if (dialog.open() == Dialog.OK) {
        firstElement.setObject(parameter.getObject());
        firstElement.setParameterName(parameter.getParameterName());
      }
    }

    field.refresh();
  }
Пример #2
0
  /**
   * Creates ImageColorMap from a file
   *
   * @param imageSource source of the image. Can be url, BufferedImage or ImageWrapper
   * @param sizex - width of the image
   * @param sizey - height of the image
   * @param sizez - depth of the image
   */
  public ImageColorMap(Object imageSource, double sizex, double sizey, double sizez) {

    super.addParams(m_aparams);

    mp_imageSource.setValue(imageSource);
    mp_size.setValue(new Vector3d(sizex, sizey, sizez));
  }
Пример #3
0
  /** @noRefGuide */
  private int prepareImage() {

    long t0 = time();

    printf("ImageColorMap.prepareImage()\n");

    Object imageSource = mp_imageSource.getValue();
    if (imageSource == null) throw new RuntimeException("imageSource is null");

    if (imageSource instanceof String) {

      try {
        m_imageData = new ImageColor(ImageIO.read(new File((String) imageSource)));
      } catch (IOException e) {
        printf("Can't find file: %s\n", imageSource);
        // empty 1x1 image
        m_imageData = new ImageColor(1, 1);
        throw new RuntimeException(e);
      }

    } else if (imageSource instanceof Text2D) {

      m_imageData = new ImageColor(((Text2D) imageSource).getImage());
    } else if (imageSource instanceof FormattedText2D) {

      m_imageData = new ImageColor(((FormattedText2D) imageSource).getImage());

    } else if (imageSource instanceof BufferedImage) {

      m_imageData = new ImageColor((BufferedImage) imageSource);

    } else if (imageSource instanceof ImageWrapper) {

      m_imageData = new ImageColor(((ImageWrapper) imageSource).getImage());
    }

    if (m_imageData == null) {
      // Cast to String for now, not sure how to really handle this
      String file = imageSource.toString();
      printf("Converted to string: " + file);
      try {
        m_imageData = new ImageColor(ImageIO.read(new File(file)));
      } catch (IOException e) {
        // empty 1x1 image
        m_imageData = new ImageColor(1, 1);
        throw new RuntimeException(e);
      }
    }
    if (m_imageData == null) {
      m_imageData = new ImageColor(1, 1);
      throw new IllegalArgumentException(
          "Unhandled imageSource: " + imageSource + " class: " + imageSource.getClass());
    }

    return ResultCodes.RESULT_OK;
  }
Пример #4
0
 /** Removes all picked elements. */
 public final void removeAllElements() {
   LinkedHashSet<String> elements = (LinkedHashSet<String>) selection.getValue();
   elements.clear();
   markDirty();
 }
Пример #5
0
 /**
  * Removes the given element id from the picked element list
  *
  * @param id a valid element id
  */
 public final void removeElement(String id) {
   LinkedHashSet<String> elements = (LinkedHashSet<String>) selection.getValue();
   elements.remove(id);
   markDirty();
 }
Пример #6
0
 public PicklistFilterSetting() {
   insertMode = new IntegerParameter(null);
   insertMode.setValue(INSERT_MODE_FRONT);
   selection = new ObjectParameter();
   selection.setValue(new LinkedHashSet<String>());
 }
Пример #7
0
 private final void copySelection(HashSet<String> newSelection) {
   HashSet<String> _selection = (HashSet<String>) selection.getValue();
   _selection.clear();
   _selection.addAll(newSelection);
   markDirty();
 }
Пример #8
0
 public final void unbind() {
   super.unbind();
   // unbind internal:
   insertMode.unbind();
   selection.unbind();
 }
Пример #9
0
 public final void bind(Subset2 subset) {
   super.bind(subset);
   // bind internal:
   insertMode.bind(subset);
   selection.bind(subset);
 }
Пример #10
0
 /**
  * Sets the selection parameter. Note that in order to take effect the parameter value should be
  * of type {@link LinkedHashSet} (to keep adding order). The <code>HashSet</code> should contain
  * the {@link Element} ids of the picked elements.
  *
  * @param selection
  */
 public final void setSelection(ObjectParameter selection) {
   //		this.selection = selection;
   Object value = selection.getValue();
   if (value instanceof HashSet) copySelection((HashSet<String>) value);
   getSelection().bind(subset);
 }
Пример #11
0
 /**
  * Get the source image
  *
  * @return
  */
 public Object getImage() {
   return mp_imageSource.getValue();
 }
Пример #12
0
 /**
  * Set the source image
  *
  * @param val
  */
 public void setImage(Object val) {
   mp_imageSource.setValue(val);
 }