private void updateFigureVisibility(IFigure figure, int visibility) {

    switch (visibility) {
      case INVISIBLE:
        figure.setVisible(false);
        break;

      case VISIBLE:
        figure.setForegroundColor(ColorConstants.listForeground);
        figure.setBackgroundColor(ColorConstants.titleInactiveBackground);
        figure.setVisible(true);
        break;

      case FADED:
        figure.setForegroundColor(
            FigureUtilities.mixColors(
                ColorConstants.listForeground, ColorConstants.listBackground, 0.1));
        figure.setBackgroundColor(
            FigureUtilities.mixColors(
                ColorConstants.titleInactiveBackground, ColorConstants.listBackground, 0.1));
        figure.setVisible(true);
        break;

      default:
        return;
    }
  }
  private IFigure getContents() {
    IFigure panel = new Panel();
    BorderLayout lm = new BorderLayout();

    panel.setLayoutManager(lm);
    arrowButton = new ArrowButton(direction);
    arrowButton.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
    arrowButton.setBackgroundColor(ColorConstants.white);

    Label lbl = new Label(lblText);
    lbl.setBackgroundColor(ColorConstants.black);
    lbl.setForegroundColor(ColorConstants.black);
    setTriangleColor(READY_COLOUR);

    Label imgLblFigure =
        new Label(
            TomoClientActivator.getDefault().getImageRegistry().get(ImageConstants.ICON_CTRL_BTN));
    panel.setBackgroundColor(ColorConstants.white);
    panel.add(imgLblFigure);
    panel.setConstraint(imgLblFigure, BorderLayout.TOP);

    arrowButton.add(lbl);
    panel.add(arrowButton);
    panel.setConstraint(arrowButton, BorderLayout.CENTER);
    lbl.addMouseListener(mousePressListener);
    return panel;
  }
 /*
  * (non-Javadoc)
  *
  * @see org.xmind.gef.part.GraphicalEditPart#createFigure()
  */
 @Override
 protected IFigure createFigure() {
   IFigure figure = new Layer();
   figure.setOpaque(true);
   figure.setBackgroundColor(ColorConstants.black);
   figure.setLayoutManager(new NavigationItemLayout());
   return figure;
 }
  private static void setGroupColumnFigureColor(
      TableViewEditPart parentEditPart, ColumnGroup columnGroup, boolean selected) {
    for (final NormalColumn column : columnGroup.getColumns()) {
      for (final Object editPart : parentEditPart.getChildren()) {
        final ColumnEditPart childEditPart = (ColumnEditPart) editPart;
        if (childEditPart.getModel() == column) {
          final IFigure columnFigure = childEditPart.getFigure();
          if (selected) {
            columnFigure.setBackgroundColor(ColorConstants.titleBackground);
            columnFigure.setForegroundColor(ColorConstants.titleForeground);

          } else {
            columnFigure.setBackgroundColor(null);
            columnFigure.setForegroundColor(null);
          }

          ((NormalColumnEditPart) childEditPart).selected = selected;
          break;
        }
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.gef.editpolicies.LayoutEditPolicy#createSizeOnDropFeedback
   * (org.eclipse.gef.requests.CreateRequest)
   */
  protected IFigure createSizeOnDropFeedback(CreateRequest createRequest) {
    IFigure figure;

    if (createRequest.getNewObject() instanceof Circuit) figure = new CircuitFeedbackFigure();
    else if (createRequest.getNewObject() instanceof LogicFlowContainer)
      figure = new LogicFlowFeedbackFigure();
    else if (createRequest.getNewObject() instanceof LogicLabel) figure = new LabelFeedbackFigure();
    else {
      figure = new RectangleFigure();
      ((RectangleFigure) figure).setXOR(true);
      ((RectangleFigure) figure).setFill(true);
      figure.setBackgroundColor(LogicColorConstants.ghostFillColor);
      figure.setForegroundColor(ColorConstants.white);
    }

    addFeedback(figure);

    return figure;
  }
  /**
   * initialize the figure
   *
   * @param figure
   */
  protected void initFigure(final IFigure figure) {
    if (figure == null)
      throw new IllegalArgumentException("Editpart does not provide a figure!"); // $NON-NLS-1$
    Set<String> allPropIds = getWidgetModel().getAllPropertyIDs();
    if (allPropIds.contains(AbstractWidgetModel.PROP_COLOR_BACKGROUND))
      figure.setBackgroundColor(
          CustomMediaFactory.getInstance().getColor(getWidgetModel().getBackgroundColor()));

    if (allPropIds.contains(AbstractWidgetModel.PROP_COLOR_FOREGROUND))
      figure.setForegroundColor(
          CustomMediaFactory.getInstance().getColor(getWidgetModel().getForegroundColor()));

    if (allPropIds.contains(AbstractWidgetModel.PROP_FONT))
      figure.setFont(getWidgetModel().getFont().getSWTFont());

    if (allPropIds.contains(AbstractWidgetModel.PROP_VISIBLE))
      figure.setVisible(
          getExecutionMode() == ExecutionMode.RUN_MODE ? getWidgetModel().isVisible() : true);

    if (allPropIds.contains(AbstractWidgetModel.PROP_ENABLED))
      figure.setEnabled(getWidgetModel().isEnabled());

    if (allPropIds.contains(AbstractWidgetModel.PROP_WIDTH)
        && allPropIds.contains(AbstractWidgetModel.PROP_HEIGHT))
      figure.setSize(getWidgetModel().getSize());

    if (allPropIds.contains(AbstractWidgetModel.PROP_BORDER_COLOR)
        && allPropIds.contains(AbstractWidgetModel.PROP_BORDER_STYLE)
        && allPropIds.contains(AbstractWidgetModel.PROP_BORDER_WIDTH))
      figure.setBorder(
          BorderFactory.createBorder(
              getWidgetModel().getBorderStyle(),
              getWidgetModel().getBorderWidth(),
              getWidgetModel().getBorderColor(),
              getWidgetModel().getName()));

    if (allPropIds.contains(AbstractWidgetModel.PROP_TOOLTIP)) {
      if (!getWidgetModel().getTooltip().equals("")) { // $NON-NLS-1$
        tooltipLabel = new TooltipLabel(getWidgetModel());
        figure.setToolTip(tooltipLabel);
      }
    }
  }
 public void highlight(
     List<? extends EObject> semanticElements, HighlightingParameters parameters) {
   synchronized (semanticElements) {
     for (EObject semanticElement : semanticElements) {
       IGraphicalEditPart editPartForSemanticElement =
           getEditPartForSemanticElement(semanticElement);
       if (editPartForSemanticElement != null) {
         IFigure figure = getTargetFigure(editPartForSemanticElement);
         if (parameters != null) {
           figure.setForegroundColor(parameters.foregroundFadingColor);
           figure.setBackgroundColor(parameters.backgroundFadingColor);
           figure.invalidate();
         } else {
           ColorMemento memento = figureStates.get(figure);
           if (memento != null) memento.restore();
         }
       }
     }
   }
 }
    public void run() {
      if (!locked) {
        // if we were started as "back-fader" via timer and editor
        // was released in the meantime, don't perform fading back
        return;
      }

      figure.setForegroundColor(targetForegroundColor);
      figure.setBackgroundColor(targetBackgroundColor);
      figure.invalidate();
      if (shouldFadeBack) {
        Display.getCurrent()
            .timerExec(
                fadingTime,
                new Fader(
                    figure,
                    targetForegroundColor,
                    sourceForegroundColor,
                    targetBackgroundColor,
                    sourceBackgroundColor,
                    fadingTime,
                    false));
      }
    }
 /** @generated */
 protected void setBackgroundColor(org.eclipse.swt.graphics.Color color) {
   if (primaryShape != null) {
     primaryShape.setBackgroundColor(color);
   }
 }
 protected void setTriangleColor(Color color) {
   Object object = arrowButton.getChildren().get(0);
   if (object instanceof IFigure) {
     ((IFigure) object).setBackgroundColor(color);
   }
 }
Esempio n. 11
0
 /** @generated */
 protected void setBackgroundColor(Color color) {
   if (primaryShape != null) {
     primaryShape.setBackgroundColor(color);
   }
 }
 protected void restore() {
   figure.setForegroundColor(foregroundColor);
   figure.setBackgroundColor(backgroundColor);
 }