/**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public boolean eIsSet(int featureID) {
   switch (featureID) {
     case ModelPackage.TABBED_PANE__SELECTION:
       return selection != SELECTION_EDEFAULT;
     case ModelPackage.TABBED_PANE__VALUE:
       return value != VALUE_EDEFAULT;
     case ModelPackage.TABBED_PANE__VERTICAL_SCROLLBAR:
       return verticalScrollbar != VERTICAL_SCROLLBAR_EDEFAULT;
     case ModelPackage.TABBED_PANE__BACKGROUND:
       return BACKGROUND_EDEFAULT == null
           ? background != null
           : !BACKGROUND_EDEFAULT.equals(background);
     case ModelPackage.TABBED_PANE__ALPHA:
       return alpha != ALPHA_EDEFAULT;
     case ModelPackage.TABBED_PANE__ITEMS:
       return items != null && !items.isEmpty();
     case ModelPackage.TABBED_PANE__FONT:
       return font != null;
     case ModelPackage.TABBED_PANE__SKIN:
       return SKIN_EDEFAULT == null ? skin != null : !SKIN_EDEFAULT.equals(skin);
     case ModelPackage.TABBED_PANE__POSITION:
       return position != POSITION_EDEFAULT;
   }
   return super.eIsSet(featureID);
 }
Example #2
0
 /** @since 2.3 */
 protected void registerURI(Resource resource) {
   Map<URI, Resource> map = getURIResourceMap();
   if (map != null) {
     final URI uri = resource.getURI();
     if (uri != null) {
       URI normalized = getURIConverter().normalize(uri);
       if (!normalized.equals(uri)) {
         Resource previous = map.put(normalized, resource);
         if (previous != null && previous != resource) {
           throw new IllegalStateException(
               "A resource with the normalized URI '"
                   + normalized
                   + "' was already registered. The resource with the URI '"
                   + previous
                   + "' is no longer registered with the normalized form.");
         }
       }
     }
     Resource previous = map.put(uri, resource);
     if (previous != null && previous != resource) {
       throw new IllegalStateException(
           "A different resource with the URI '" + uri + "' was already registered.");
     }
   }
 }
 /**
  * {@inheritDoc}
  *
  * @see ExtensibleURIConverterImpl#normalize(URI)
  */
 @Override
 public URI normalize(URI uri) {
   URI normalized = normalizeWithParent(uri);
   if (normalized == null || normalized.equals(uri)) {
     normalized = dynamicNormalize(uri);
   }
   return normalized;
 }
Example #4
0
 @Override
 public boolean equals(@Nullable Object obj) {
   if (this == obj) return true;
   if (obj == null || !super.equals(obj)) return false;
   if (getClass() != obj.getClass()) return false;
   LocationData other = (LocationData) obj;
   if (path == null) {
     if (other.path != null) return false;
   } else if (!path.equals(other.path)) return false;
   if (projectName == null) {
     if (other.projectName != null) return false;
   } else if (!projectName.equals(other.projectName)) return false;
   return true;
 }
Example #5
0
 public boolean loadResource(ModelSet modelSet, URI uri) {
   // pathmap resource are always loaded
   boolean result = !uri.isPlatform() && !uri.isFile();
   if (!result) {
     URI lastInitialURI = SashModelUtils.getInitialURI(modelSet).trimFileExtension();
     if (!lastInitialURI.equals(initialURI)) {
       clear();
       initialURI = lastInitialURI;
     }
     URI uritrimFragment = uri.trimFragment().trimFileExtension();
     Set<String> extensions = mappingURIExtensions.get(uritrimFragment);
     if (extensions == null) {
       extensions = new HashSet<String>();
       mappingURIExtensions.put(uritrimFragment, extensions);
     }
     extensions.add(uri.fileExtension());
     result = lastInitialURI.equals(uritrimFragment);
     if (!result) {
       result = alreadyValidated.contains(uritrimFragment);
       if (!result) {
         if (!alreadyGuessed.contains(uritrimFragment)) {
           String message =
               new StringBuffer("<form><p>Your model is linked to an external resource (")
                   .append(uritrimFragment.toString())
                   .append(").</p><p>Do you want to load it ?</p></form>")
                   .toString();
           NotificationBuilder builder = getNotification(message, uritrimFragment, modelSet);
           builder.run();
           alreadyGuessed.add(uritrimFragment);
           // notification
         }
       }
     }
   }
   return result;
 }
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated
  */
 @Override
 public boolean eIsSet(int featureID) {
   switch (featureID) {
     case ModelPackage.CURLY_BRACE__FONT:
       return font != null;
     case ModelPackage.CURLY_BRACE__FOREGROUND:
       return FOREGROUND_EDEFAULT == null
           ? foreground != null
           : !FOREGROUND_EDEFAULT.equals(foreground);
     case ModelPackage.CURLY_BRACE__SKIN:
       return SKIN_EDEFAULT == null ? skin != null : !SKIN_EDEFAULT.equals(skin);
     case ModelPackage.CURLY_BRACE__POSITION:
       return position != POSITION_EDEFAULT;
   }
   return super.eIsSet(featureID);
 }
Example #7
0
 @Override
 public void notifyChanged(Notification notification) {
   final Map<URI, Resource> map = getURIResourceMap();
   if (map != null
       && notification.getFeatureID(Resource.class) == Resource.RESOURCE__URI
       && notification.getNotifier() instanceof Resource) {
     URI oldOne = (URI) notification.getOldValue();
     map.remove(oldOne);
     if (oldOne != null) {
       URI oldNormalized = getURIConverter().normalize(oldOne);
       if (!oldOne.equals(oldNormalized)) map.remove(oldNormalized);
     }
     Resource resource = (Resource) notification.getNotifier();
     registerURI(resource);
   }
   super.notifyChanged(notification);
 }
  private static boolean inUnit(EObject object, URI unit) {
    boolean result = false;

    if (unit != null) {
      // get the extension-less model URIs
      URI uri = getResourceURI(object);

      if (uri != null) {
        uri = uri.trimFileExtension();
        URI otherURI = unit.trimFileExtension();

        result = uri.equals(otherURI);
      }
    }

    return result;
  }
Example #9
0
  /**
   * Checks whether the given object has a resource or is in the pseudo resource
   *
   * @param <T> the typ of the given object
   * @param typ the given object
   * @return null, if the object is in a valid resource, a copy of the object otherwise @see {@link
   *     EcoreUtil#copy(EObject)}
   */
  @SuppressWarnings("unchecked")
  private <T extends EObject> T handle(T typ) {
    if (typ != null && orgToCopy.containsKey(typ)) {
      return (T) orgToCopy.get(typ);
    }
    if (typ != null && (typ.eResource() == null || typ.eResource().getURI() != null)) {
      /*
       * get URI if any there
       */
      URI uri = typ.eResource() == null ? null : typ.eResource().getURI();

      if (uri == null || uri.equals(URI.createURI(OCL_PSEUDO_RESOURCE_URI))) {

        return EcoreUtil.copy(typ);
      }
    }
    return null;
  }
Example #10
0
 public LoadCustomizationsDialog(
     final Shell parent,
     final List<Customization> availableCustomizations,
     final List<Customization> selectedCustoms,
     final List<Customization> lockedCustoms,
     final IDialogCallbackWithPreCommit<List<Customization>, Boolean, D> callback,
     final String lockMsg) {
   super(parent);
   this.labelProvider = new ColorLabelProvider(this);
   this.callback = callback;
   this.selectedCustomizations = new BasicEList<Customization>();
   this.availableCustoms = new ArrayList<Customization>(availableCustomizations);
   this.lockedCustoms = lockedCustoms;
   this.lockMsg = lockMsg;
   setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX);
   // initial selection
   for (final Customization initiallySelectedCustomization : selectedCustoms) {
     final URI initiallySelectedCustomizationURI =
         EcoreUtil.getURI(initiallySelectedCustomization);
     final ListIterator<Customization> availableCustomizationsIterator =
         this.availableCustoms.listIterator();
     while (availableCustomizationsIterator.hasNext()) {
       final Customization availableCustomization = availableCustomizationsIterator.next();
       final URI availableCustomizationURI = EcoreUtil.getURI(availableCustomization);
       if (availableCustomizationURI.equals(initiallySelectedCustomizationURI)) {
         availableCustomizationsIterator.remove();
         LoadCustomizationsDialog.this.selectedCustomizations.add(initiallySelectedCustomization);
       }
     }
   }
   for (Customization lockedCustom : this.lockedCustoms) {
     if (!this.selectedCustomizations.contains(lockedCustom)) {
       this.selectedCustomizations.add(lockedCustom);
     }
   }
   // TODO: Remove before to commit
   //		LoadCustomizationsDialog.this.availableCustomizationsTreeViewer
   //				.refresh();
   //		LoadCustomizationsDialog.this.selectedCustomizationsTreeViewer
   //				.refresh();
   // TODO(end):  Remove before to commit
 }
  /**
   * This will be called if the parent {@link URIConverter} didn't know how to convert the given
   * URI.
   *
   * @param uri The uri we are to normalize.
   * @return The normalized form of <code>uri</code>.
   */
  private URI dynamicNormalize(URI uri) {
    URI normalized = getURIMap().get(uri);
    if (normalized == null && EMFPlugin.IS_ECLIPSE_RUNNING) {
      BundleURLConverter conv = new BundleURLConverter(uri.toString());
      if (conv.resolveBundle() != null) {
        normalized = URI.createURI(conv.resolveAsPlatformPlugin());
      }
    }
    if (normalized == null
        && (!IAcceleoConstants.EMTL_FILE_EXTENSION.equals(uri.fileExtension())
            || !"file".equals(uri.scheme()))) { // $NON-NLS-1$
      normalized = super.normalize(uri);
    }
    if (normalized != null) {
      getURIMap().put(uri, normalized);
      return normalized;
    }

    String moduleName = uri.lastSegment();
    moduleName = moduleName.substring(0, moduleName.lastIndexOf('.'));
    Set<URI> candidateURIs = new CompactLinkedHashSet<URI>();

    // Search matching module in the current generation context
    Set<Module> candidateModules = searchCurrentModuleForCandidateMatches(moduleName);
    for (Module candidateModule : candidateModules) {
      if (candidateModule.eResource() != null) {
        candidateURIs.add(candidateModule.eResource().getURI());
      }
    }
    // If there were no matching module, search in their ResourceSet(s)
    if (candidateURIs.size() == 0) {
      candidateURIs.addAll(searchResourceSetForMatches(moduleName));
    }
    if (candidateURIs.size() == 1) {
      normalized = candidateURIs.iterator().next();
    } else if (candidateURIs.size() > 0) {
      normalized = findBestMatchFor(uri, candidateURIs);
    }
    // There is a chance that our match should itself be normalized
    if ((normalized == null || "file".equals(normalized.scheme())) // $NON-NLS-1$
        && EMFPlugin.IS_ECLIPSE_RUNNING) {
      BundleURLConverter conv = new BundleURLConverter(uri.toString());
      if (conv.resolveBundle() != null) {
        normalized = URI.createURI(conv.resolveAsPlatformPlugin());
      } else {
        String uriToString = uri.toString();
        if (uriToString.indexOf('#') > 0) {
          uriToString = uriToString.substring(0, uriToString.indexOf('#'));
        }
        String resolvedPath = AcceleoWorkspaceUtil.resolveInBundles(uriToString);
        if (resolvedPath != null) {
          normalized = URI.createURI(resolvedPath);
        }
      }
    }
    if (normalized == null) {
      normalized = super.normalize(uri);
    }
    if (!uri.equals(normalized)) {
      getURIMap().put(uri, normalized);
    }
    return normalized;
  }