/** @generated */
  public static void initDefaults(IPreferenceStore store) {

    String key = ActivityDiagramEditPart.MODEL_ID + "_OutputPin";
    store.setDefault(
        PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.WIDTH), 16);
    store.setDefault(
        PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.HEIGHT), 16);

    Map<String, Boolean> map = getStaticLabelVisibilityPreferences();

    for (String role : map.keySet()) {
      String preferenceName =
          PreferenceConstantHelper.getLabelElementConstant(
              key, role, PreferenceConstantHelper.LABEL_VISIBILITY);
      store.setDefault(preferenceName, map.get(role));
    }

    // org.eclipse.jface.preference.PreferenceConverter.setDefault(store,
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255));
    // org.eclipse.jface.preference.PreferenceConverter.setDefault(store,
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0));

    // Set the default for the gradient
    // store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.GRADIENT_POLICY),false);
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter
    // gradientPreferenceConverter = new
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter(
    //		new org.eclipse.swt.graphics.RGB(255, 255, 255),
    //		new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0);
    // store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue());

  }
  /**
   * initialize the status of the compartment for the node (Showed or hidden)
   *
   * @param view the element to initialize
   * @param store the preference store
   * @param elementName the name to the element
   */
  public static void initCompartmentsStatusFromPrefs(
      View view, final IPreferenceStore store, String elementName) {
    EList<?> children = view.getPersistedChildren();
    if (children != null) {
      for (Object object : children) {

        // we look for the name of the compartment for this view
        EditPart dummyEP = EditPartService.getInstance().createGraphicEditPart((View) object);
        IGraphicalEditPart epp = (IGraphicalEditPart) dummyEP;
        IFigure fig1 = epp.getFigure();

        if (fig1 instanceof ResizableCompartmentFigure) {
          String compartmentName = ((ResizableCompartmentFigure) fig1).getCompartmentTitle();
          if (compartmentName != null) {
            String diagramKind = view.getDiagram().getType();
            String preferenceKey =
                PreferenceConstantHelper.getCompartmentElementConstant(
                    diagramKind + "_" + elementName,
                    compartmentName,
                    PreferenceConstantHelper.COMPARTMENT_VISIBILITY); // $NON-NLS-1$
            boolean value = store.getBoolean(preferenceKey);

            if (!value) { // the default value is true : nothing to
              // do
              ENamedElement namedElement =
                  PackageUtil.getElement("notation.View.visible"); // $NON-NLS-1$
              ViewUtil.setStructuralFeatureValue(
                  (View) object, (EStructuralFeature) namedElement, value);
            }

            String compartmentNameVisibilityPreference =
                PreferenceConstantHelper.getCompartmentElementConstant(
                    diagramKind + "_" + elementName,
                    compartmentName,
                    PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY); // $NON-NLS-1$
            boolean showCompartmentName = store.getBoolean(compartmentNameVisibilityPreference);
            View childView = (View) object;
            TitleStyle style =
                (TitleStyle) childView.getStyle(NotationPackage.eINSTANCE.getTitleStyle());
            if (style != null) {
              style.setShowTitle(showCompartmentName);
            }
          }
        }
        dummyEP = null;
      }
    }
  }
Пример #3
0
  /** @generated */
  @Override
  public Object getPreferredValue(EStructuralFeature feature) {
    IPreferenceStore preferenceStore =
        (IPreferenceStore) getDiagramPreferencesHint().getPreferenceStore();
    Object result = null;

    if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()
        || feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()
        || feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) {
      String prefColor = null;
      if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
        prefColor =
            PreferenceConstantHelper.getElementConstant(
                "Metaclass", PreferenceConstantHelper.COLOR_LINE);
      } else if (feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()) {
        prefColor =
            PreferenceConstantHelper.getElementConstant(
                "Metaclass", PreferenceConstantHelper.COLOR_FONT);
      } else if (feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) {
        prefColor =
            PreferenceConstantHelper.getElementConstant(
                "Metaclass", PreferenceConstantHelper.COLOR_FILL);
      }
      result =
          FigureUtilities.RGBToInteger(
              PreferenceConverter.getColor((IPreferenceStore) preferenceStore, prefColor));
    } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()
        || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) {
      String prefGradient =
          PreferenceConstantHelper.getElementConstant(
              "Metaclass", PreferenceConstantHelper.COLOR_GRADIENT);
      GradientPreferenceConverter gradientPreferenceConverter =
          new GradientPreferenceConverter(preferenceStore.getString(prefGradient));
      if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()) {
        result = new Integer(gradientPreferenceConverter.getTransparency());
      } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) {
        result = gradientPreferenceConverter.getGradientData();
      }
    }

    if (result == null) {
      result = getStructuralFeatureValue(feature);
    }
    return result;
  }
  /** @generated */
  public static void initDefaults(IPreferenceStore store) {

    String key = CompositeStructureDiagramEditPart.MODEL_ID + "_InteractionConstraint";
    store.setDefault(
        PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.WIDTH), 40);
    store.setDefault(
        PreferenceConstantHelper.getElementConstant(key, PreferenceConstantHelper.HEIGHT), 40);

    // org.eclipse.jface.preference.PreferenceConverter.setDefault(store,
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_FILL), new org.eclipse.swt.graphics.RGB(255, 255, 255));
    // org.eclipse.jface.preference.PreferenceConverter.setDefault(store,
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_LINE), new org.eclipse.swt.graphics.RGB(0, 0, 0));

    // Set the default for the gradient
    // store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.GRADIENT_POLICY),false);
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter
    // gradientPreferenceConverter = new
    // org.eclipse.papyrus.infra.gmfdiag.preferences.utils.GradientPreferenceConverter(
    //		new org.eclipse.swt.graphics.RGB(255, 255, 255),
    //		new org.eclipse.swt.graphics.RGB(0, 0, 0), 0, 0);
    // store.setDefault(org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.getElementConstant(elementName, org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper.COLOR_GRADIENT), gradientPreferenceConverter.getPreferenceValue());

  }
  /**
   * initialize the status of each label for the node or for the link (Showed or hidden)
   *
   * @param view the element to initialize
   * @param store the preference store
   * @param elementName the name to the element
   */
  public static void initLabelVisibilityFromPrefs(
      View view, final IPreferenceStore store, String elementName) {
    EList<?> children = view.getPersistedChildren();
    if (children != null) {
      for (Object object : children) {

        // we look for the name of the label for this view
        EditPart dummyEP = EditPartService.getInstance().createGraphicEditPart((View) object);
        if (dummyEP instanceof ILabelRoleProvider) {
          String role = ((ILabelRoleProvider) dummyEP).getLabelRole();
          String diagramKind = view.getDiagram().getType();
          String key =
              PreferenceConstantHelper.getLabelElementConstant(
                  diagramKind + "_" + elementName,
                  role,
                  PreferenceConstantHelper.LABEL_VISIBILITY); // $NON-NLS-1$
          ((View) object).setVisible(store.getBoolean(key));
        }
        dummyEP = null;
      }
    }
  }
 public static String getpreferenceKey(View view, String elementName, int pref) {
   return PreferenceConstantHelper.getElementConstant(
       view.getDiagram().getType() + "_" + elementName, pref); // $NON-NLS-1$
 }