Package org.eclipse.wst.css.core.internal.provisional.document

Examples of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel


      {
        input = CSSUtil.class
          .getResourceAsStream(IJMTConstants.USERAGENT);
        IStructuredModel model = StructuredModelManager.getModelManager()
            .getModelForEdit(IJMTConstants.USERAGENT, input, null);
        ICSSModel cssmodel = (ICSSModel) model;
        _userAgentDefault = (StyleSheet) cssmodel.getDocument();
      }
      finally
      {
        ResourceUtils.ensureClosed(input);
      }
View Full Code Here


    if (index < 0 || index >= validAdapters.size())
      return null;
    StyleSheet sheet = ((IStyleSheetAdapter) validAdapters.get(index)).getSheet();
    if (sheet == null) {// for LINK element whose link is broken
      ICSSModel model = ((AbstractStyleSheetAdapter) validAdapters.get(index)).createModel();
      sheet = ((model != null) ? (StyleSheet) model.getDocument() : null);
    }
    return sheet;
  }
View Full Code Here

      Object adapter = iAdapter.next();
      if (adapter instanceof LinkElementAdapter) {
        ((LinkElementAdapter) adapter).refreshSheet();
      }
      else if (adapter instanceof StyleElementAdapter) {
        ICSSModel model = ((StyleElementAdapter) adapter).getModel();
        ImportRuleCollector trav = new ImportRuleCollector();
        trav.apply(model);
        Iterator iRule = trav.getRules().iterator();
        while (iRule.hasNext()) {
          ICSSImportRule rule = (ICSSImportRule) iRule.next();
View Full Code Here

  protected ICSSModel createModel() {
    // create embedded CSS model (not for external CSS)
    if (getElement() == null)
      return null;
    IStructuredModel baseModel = ((IDOMNode) getElement()).getModel();
    ICSSModel newModel = (ICSSModel) baseModel.getModelManager().createUnManagedStructuredModelFor(CSS_ID);
    ((CSSModelImpl) newModel).setOwnerDOMNode(getElement());
    return newModel;
  }
View Full Code Here

  protected ICSSModel createModel() {
    // create phantom(broken link) external CSS model
    if (getElement() == null)
      return null;
    IStructuredModel baseModel = ((IDOMNode) getElement()).getModel();
    ICSSModel newModel = (ICSSModel) baseModel.getModelManager().createUnManagedStructuredModelFor(CSS_ID);

    // calculate base location and set
    // get resolver in Model
    URIResolver resolver = baseModel.getResolver();

    // resolve to absolute url : this need not exact location of css file. It is important that absurl is not null.
    String ref = getElement().getAttribute(HTML40Namespace.ATTR_NAME_HREF);
    String absurl = (resolver != null && ref != null && ref.length() > 0) ? resolver.getLocationByURI(ref, true) : null;
    if ((absurl == null) || (absurl.length() == 0)) {
      IPath basePath = new Path(baseModel.getBaseLocation());
      URLHelper helper = new URLHelper(basePath.removeLastSegments(1).toString());
      absurl = helper.toAbsolute(ref == null ? "" : ref);//$NON-NLS-1$
    }
    if ((absurl == null) || (absurl.length() == 0)) {
      absurl = ref;
    }
    if (absurl == null) {
      absurl = "";//$NON-NLS-1$
    }
    newModel.setBaseLocation(absurl);

    // set style listener
    newModel.addStyleListener(this);

    return newModel;
  }
View Full Code Here

  }

  /**
   */
  public ICSSModel getModel() {
    ICSSModel model = getExistingModel();
    if (this.replaceModel) {
      ICSSModel oldModel = model;
      try {
        model = retrieveModel();
        setModel(model);

        // release old model
        if (oldModel != null) {
          // get ModelProvideAdapter
          IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
          if (adapter != null)
            adapter.modelRemoved(oldModel);
        }
      }
      finally {
        if (oldModel != null)
          oldModel.releaseFromRead();
      }
      this.replaceModel = false;
    }
    return model;
  }
View Full Code Here

  }

  /**
   */
  public void released() {
    ICSSModel model = getExistingModel();
    if (model != null) {
      try {
        // get ModelProvideAdapter
        IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);

        // set element to null first, so that no document wide updates
        setElement(null);
        setModel(null);

        if (adapter != null)
          adapter.modelReleased(model);
      }
      finally {
        model.releaseFromRead();
      }
    }
    this.replaceModel = false;
  }
View Full Code Here

  }

  /**
   */
  private String getCSSValue(Attr attr) {
    ICSSModel model = getCSSModel(attr);
    if (model == null)
      return null;
    ICSSNode document = model.getDocument();
    if (document == null)
      return null;
    INodeNotifier notifier = (INodeNotifier) document;
    CSSSourceFormatter formatter = (CSSSourceFormatter) notifier.getAdapterFor(CSSSourceFormatter.class);
    // try another way to get formatter
View Full Code Here

  }

  /**
   */
  public void removed() {
    ICSSModel model = getExistingModel();
    if (model != null) {
      try {
        setModel(null);

        // get ModelProvideAdapter
        IModelProvideAdapter adapter = (IModelProvideAdapter) ((INodeNotifier) getElement()).getAdapterFor(IModelProvideAdapter.class);
        if (adapter != null)
          adapter.modelRemoved(model);
      }
      finally {
        model.releaseFromRead();
      }
    }
    this.replaceModel = false;
  }
View Full Code Here

  }

  /**
   */
  protected void setModel(ICSSModel model) {
    ICSSModel oldModel = getExistingModel();
    if (model == oldModel)
      return;
    super.setModel(model);
    if (this.replaceModel)
      this.replaceModel = false;
    if (oldModel != null)
      oldModel.removeStyleListener(this);
    if (model != null)
      model.addStyleListener(this);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.css.core.internal.provisional.document.ICSSModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.