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;
    }
  }
  protected void showHighlight() {
    // remove previous highlight
    removeHighlight();

    // determine new highlight-values
    Color newForeground = GFColorConstants.HANDLE_BG;
    int newLineStyle = Graphics.LINE_DASH;

    if (getHost() != null && getHost().getModel() instanceof Connection) {
      Connection connection = (Connection) getHost().getModel();
      IToolBehaviorProvider tbp =
          getConfigurationProvider().getDiagramTypeProvider().getCurrentToolBehaviorProvider();
      ISelectionInfo selectionInfo = tbp.getSelectionInfoForConnection(connection);
      if (selectionInfo != null) {
        IColorConstant selectionColor = selectionInfo.getColor();
        if (selectionColor != null) {
          newForeground =
              DataTypeTransformation.toSwtColor(
                  getConfigurationProvider().getResourceRegistry(), selectionColor);
        }
        LineStyle selectionLineStyle = selectionInfo.getLineStyle();
        if (selectionLineStyle != null) {
          newLineStyle = DataTypeTransformation.toDraw2dLineStyle(selectionLineStyle);
        }
      }
    }

    // store old highlight-values and set new highlight-values
    // important: get old colors via getLocalForeGround() to ignore parent
    Collection<Shape> connectionFigures = getConnectionFigures();
    for (Shape connectionFigure : connectionFigures) {
      figureToColor.put(connectionFigure, connectionFigure.getLocalForegroundColor());
      connectionFigure.setForegroundColor(newForeground);
      shapeToLineStyle.put(connectionFigure, connectionFigure.getLineStyle());
      connectionFigure.setLineStyle(newLineStyle);

      if (connectionFigure instanceof GFPolylineConnection) {
        GFPolylineConnection polylineConnection = (GFPolylineConnection) connectionFigure;
        List<IFigure> allDecorations = polylineConnection.getAllDecorations();
        for (IFigure decoration : allDecorations) {
          if (decoration != null) {
            figureToColor.put(decoration, decoration.getLocalForegroundColor());
            decoration.setForegroundColor(newForeground);
            if (decoration instanceof Shape) {
              Shape decorationShape = (Shape) decoration;
              shapeToLineStyle.put(decorationShape, new Integer(decorationShape.getLineStyle()));
              decorationShape.setLineStyle(newLineStyle);
            }
          }
        }
      }
    }
  }
  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;
        }
      }
    }
  }
  protected void removeHighlight() {
    Set<IFigure> colorFigures = figureToColor.keySet();
    for (IFigure colorFigure : colorFigures) {
      Color oldColor = figureToColor.get(colorFigure);
      colorFigure.setForegroundColor(oldColor);
    }

    Set<Shape> lineStyleShapes = shapeToLineStyle.keySet();
    for (Shape lineStyleShape : lineStyleShapes) {
      int lineStyle = shapeToLineStyle.get(lineStyleShape);
      lineStyleShape.setLineStyle(lineStyle);
    }

    figureToColor.clear();
    shapeToLineStyle.clear();
  }
  /*
   * (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 setForegroundColor(org.eclipse.swt.graphics.Color color) {
   if (primaryShape != null) {
     primaryShape.setForegroundColor(color);
   }
 }
 /** @generated */
 protected void setForegroundColor(Color color) {
   if (primaryShape != null) {
     primaryShape.setForegroundColor(color);
   }
 }
 protected void restore() {
   figure.setForegroundColor(foregroundColor);
   figure.setBackgroundColor(backgroundColor);
 }