Esempio n. 1
0
  private void init(final CustomizationManager customizationManager) {
    // the appearance can be customized here:

    customizationManager.setShowDerivedLinks(true);

    try {

      // load customizations defined as default through the customization
      // extension
      List<MetamodelView> registryDefaultCustomizations =
          CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
      for (MetamodelView metamodelView : registryDefaultCustomizations) {
        customizationManager.registerCustomization(metamodelView);
      }
      customizationManager.loadCustomizations();
      loadFacetsForCustomizations(registryDefaultCustomizations, customizationManager);

    } catch (Throwable e) {
      Activator.getDefault()
          .getLog()
          .log(
              new Status(
                  IStatus.ERROR,
                  Activator.PLUGIN_ID,
                  "Error initializing customizations",
                  e)); //$NON-NLS-1$
    }
  }
  // TODO duplicate code from ModelExplorer
  // TODO vérifier que l'on n'a pas la même chose dans les tables également!
  @Override
  public void run() {
    final IEditorPart currentEditor = Utils.getCurrentEditor();
    final CustomizationManager customizationManager =
        Activator.getDefault().getCustomizationManager(currentEditor);
    final List<MetamodelView> initiallySelectedCustomizations =
        customizationManager.getRegisteredCustomizations();
    final LoadCustomizationsDialog loadCustomizationsDialog =
        new LoadCustomizationsDialog(
            Display.getCurrent().getActiveShell(),
            initiallySelectedCustomizations,
            this.registeredMetamodel);
    // TODO : override the dialog to hide the checkbox for the facet
    if (Window.OK == loadCustomizationsDialog.open()) {
      customizationManager.clearCustomizations();
      final List<MetamodelView> selectedCustomizations =
          loadCustomizationsDialog.getSelectedCustomizations();
      // before loading, clean all facet to prevent to let not interesting facets.
      customizationManager.clearFacets();
      if (loadCustomizationsDialog.isLoadRequiredFacetsSelected()) {
        // load facets corresponding to customizations
        // we ignore the facet in this dialog
      }
      for (final MetamodelView metamodelView : selectedCustomizations) {
        customizationManager.registerCustomization(metamodelView);
      }
      customizationManager.loadCustomizations();
    }
    // dialog.s

    // TODO
    // TODO Auto-generated method stub
    //	super.run();
  }
Esempio n. 3
0
  /**
   * load the facets
   *
   * @param customizations list of customization
   * @param customizationManager the Customization Manager
   */
  protected void loadFacetsForCustomizations(
      final List<MetamodelView> customizations, final CustomizationManager customizationManager) {
    final Set<Facet> referencedFacets = new HashSet<Facet>();
    final Collection<FacetSet> facetSets = FacetSetCatalog.getSingleton().getAllFacetSets();

    for (MetamodelView customization : customizations) {
      String metamodelURI = customization.getMetamodelURI();
      // find customized FacetSet
      FacetSet customizedFacetSet = null;
      if (metamodelURI != null) {
        for (FacetSet facetSet : facetSets) {
          if (metamodelURI.equals(facetSet.getNsURI())) {
            customizedFacetSet = facetSet;
            break;
          }
        }
      }
      if (customizedFacetSet == null) {
        continue;
      }

      // find customized Facets
      EList<TypeView> types = customization.getTypes();
      for (TypeView typeView : types) {
        String metaclassName = typeView.getMetaclassName();
        Facet facet = findFacetWithFullyQualifiedName(metaclassName, customizedFacetSet);
        if (facet != null) {
          referencedFacets.add(facet);
        } else {
          Activator.log.warn(
              NLS.bind(
                  Messages.BrowserActionBarContributor_missingRequiredFacet,
                  new Object[] {
                    metaclassName, customizedFacetSet.getName(), customization.getName()
                  }));
        }
      }

      for (Facet referencedFacet : referencedFacets) {
        customizationManager.loadFacet(referencedFacet);
      }
    }

    //
    // for modified facets
    // customizationManager.getInstancesForMetaclasses().buildDerivationTree();
    // customizationManager.getAppearanceConfiguration().touch();
    // customizationManager.refreshDelayed(true);
  }
  private void init(final CustomizationManager customizationManager) {
    customizationManager.setShowContainer(false);
    customizationManager.setShowDerivedLinks(false);
    customizationManager.setShowEmptyLinks(false);

    try {
      List<MetamodelView> registryDefaultCustomizations =
          CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
      for (MetamodelView metamodelView : registryDefaultCustomizations) {
        customizationManager.registerCustomization(metamodelView);
      }

      customizationManager.loadCustomizations();
    } catch (Throwable e) {
      Activator.getDefault()
          .getLog()
          .log(
              new Status(
                  IStatus.ERROR,
                  Activator.PLUGIN_ID,
                  "Error initializing customizations",
                  e)); //$NON-NLS-1$
    }
  }