Esempio n. 1
0
  /**
   * Gets the validation report from the validator.
   *
   * @param source the source text
   * @param path the source path
   * @return the report
   */
  private static String getReport(String source, URI path) {
    StyleSheetParser parser = new StyleSheetParser();
    ApplContext ac = new ApplContext("en"); // $NON-NLS-1$
    ac.setProfile(APTANA_PROFILE);
    try {
      parser.parseStyleElement(
          ac, new ByteArrayInputStream(source.getBytes(IOUtil.UTF_8)), null, null, path.toURL(), 0);
    } catch (MalformedURLException e) {
      IdeLog.logError(
          CSSPlugin.getDefault(),
          MessageFormat.format(Messages.CSSValidator_ERR_InvalidPath, path),
          e);
    } catch (UnsupportedEncodingException e) {
      IdeLog.logError(CSSPlugin.getDefault(), e);
    }

    StyleSheet stylesheet = parser.getStyleSheet();
    stylesheet.findConflicts(ac);
    StyleReport report =
        StyleReportFactory.getStyleReport(
            ac, "Title", stylesheet, "soap12", 2); // $NON-NLS-1$ //$NON-NLS-2$
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    report.print(new PrintWriter(out));
    return out.toString().replaceAll("m:", ""); // $NON-NLS-1$ //$NON-NLS-2$
  }
Esempio n. 2
0
  /**
   * Loads our CSS profile.
   *
   * @throws IOException if profile loading fails
   */
  private static void loadAptanaCSSProfile() {
    InputStream configStream = CSSValidator.class.getResourceAsStream(CONFIG_FILE);
    InputStream profilesStream = CSSValidator.class.getResourceAsStream(PROFILES_CONFIG_FILE);

    try {
      // loads our config
      PropertiesLoader.config.load(configStream);

      // loads our profile
      Utf8Properties profiles = new Utf8Properties();
      profiles.load(profilesStream);
      // a hack, but no other way since PropertiesLoader provides no public access to stored
      // profiles
      Field field = PropertiesLoader.class.getDeclaredField("profiles"); // $NON-NLS-1$
      field.setAccessible(true);
      field.set(null, profiles);
    } catch (Exception e) {
      IdeLog.logError(CSSPlugin.getDefault(), Messages.CSSValidator_ERR_FailToLoadProfile, e);
    } finally {
      try {
        configStream.close();
      } catch (IOException e) {
      }
      try {
        profilesStream.close();
      } catch (IOException e) {
      }
    }
  }
 public static IPreferenceStore getChainedPreferenceStore() {
   return new ChainedPreferenceStore(
       new IPreferenceStore[] {
         CSSPlugin.getDefault().getPreferenceStore(),
         CommonEditorPlugin.getDefault().getPreferenceStore(),
         EditorsPlugin.getDefault().getPreferenceStore()
       });
 }
  @Override
  protected void initializeEditor() {
    super.initializeEditor();

    setPreferenceStore(getChainedPreferenceStore());
    setSourceViewerConfiguration(new CSSSourceViewerConfiguration(getPreferenceStore(), this));

    setDocumentProvider(CSSPlugin.getDefault().getCSSDocumentProvider());
  }
Esempio n. 5
0
  /**
   * getImage
   *
   * @param path
   * @return
   */
  public static Image getImage(String path) {
    ImageRegistry registry = plugin.getImageRegistry();
    Image image = registry.get(path);

    if (image == null) {
      ImageDescriptor id = getImageDescriptor(path);

      if (id == null) {
        return null;
      }

      registry.put(path, id);
      image = registry.get(path);
    }

    return image;
  }
Esempio n. 6
0
  public void testEditorPreferences() {
    String spacesForTabs;

    EditorsPlugin.getDefault()
        .getPreferenceStore()
        .setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, false);

    spacesForTabs =
        CSSSourceEditor.getChainedPreferenceStore()
            .getString(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
    assertEquals("false", spacesForTabs);

    CSSPlugin.getDefault()
        .getPreferenceStore()
        .setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, true);

    spacesForTabs =
        CSSSourceEditor.getChainedPreferenceStore()
            .getString(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
    assertEquals("true", spacesForTabs);
  }
 /*
  * (non-Javadoc)
  * @see com.aptana.editor.common.AbstractThemeableEditor#getPluginPreferenceStore()
  */
 @Override
 protected IPreferenceStore getPluginPreferenceStore() {
   return CSSPlugin.getDefault().getPreferenceStore();
 }