Package org.eclipse.php.internal.ui.editor.highlighter

Examples of org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting


        Object description = fStyleToDescriptionMap.get(element);
        if (description != null)
          return description.toString();
        else if (SemanticHighlightingManager.getInstance()
            .getSemanticHighlightings().containsKey(element)) {
          AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
              .getInstance().getSemanticHighlightings()
              .get(element);
          return semanticHighlighting.getDisplayName();
        }
        return super.getText(element);
      }
    });
    stylesViewer.setContentProvider(new ITreeContentProvider() {
View Full Code Here


    if (namedStyle != null && fOverlayStore != null) {

      if (SemanticHighlightingManager.getInstance()
          .getSemanticHighlightings().containsKey(namedStyle)) {
        AbstractSemanticHighlighting semanticHighlightingType = SemanticHighlightingManager
            .getInstance().getSemanticHighlightings()
            .get(namedStyle);

        int fontModifier = SWT.NORMAL;
        boolean on = getOverlayStore().getBoolean(
            semanticHighlightingType.getBoldPreferenceKey());
        if (on)
          fontModifier = fontModifier | SWT.BOLD;

        on = getOverlayStore().getBoolean(
            semanticHighlightingType.getItalicPreferenceKey());
        if (on)
          fontModifier = fontModifier | SWT.ITALIC;

        on = getOverlayStore().getBoolean(
            semanticHighlightingType
                .getStrikethroughPreferenceKey());
        if (on)
          fontModifier = fontModifier | TextAttribute.STRIKETHROUGH;

        on = getOverlayStore().getBoolean(
            semanticHighlightingType.getUnderlinePreferenceKey());
        if (on)
          fontModifier = fontModifier | TextAttribute.UNDERLINE;

        String color = getOverlayStore().getString(
            semanticHighlightingType.getColorPreferenceKey());
        RGB foreground = ColorHelper.toRGB(color);
        String bgcolor = getOverlayStore().getString(
            semanticHighlightingType
                .getBackgroundColorPreferenceKey());
        RGB bgforeground = ColorHelper.toRGB(bgcolor);
        ta = new TextAttribute(
            (foreground != null) ? EditorUtility.getColor(foreground)
                : null,
View Full Code Here

        Collections.sort(highlightings);

        for (Iterator iterator = highlightings.iterator(); iterator
            .hasNext();) {
          AbstractSemanticHighlighting abstractSemanticHighlighting = (AbstractSemanticHighlighting) iterator
              .next();
          Position[] positions = abstractSemanticHighlighting
              .consumes(program);

          if (positions != null && positions.length > 0) {
            highlightingPositionMap
                .put(abstractSemanticHighlighting
                    .getPreferenceKey(), positions);

          }
        }
      }
View Full Code Here

      fItalic.setSelection(false);
      fStrike.setSelection(false);
      fUnderline.setSelection(false);
    } else {
      TextAttribute attribute = getAttributeFor(namedStyle);
      AbstractSemanticHighlighting semanticType = SemanticHighlightingManager
          .getInstance().getSemanticHighlightings().get(namedStyle);
      boolean enabled = true;
      if (semanticType != null) {
        enabled = getOverlayStore().getBoolean(
            semanticType.getEnabledPreferenceKey());
      } else {
        enabled = getOverlayStore()
            .getBoolean(
                PreferenceConstants
                    .getEnabledPreferenceKey(namedStyle));
View Full Code Here

              .getSelection()).getFirstElement();
          String namedStyle = o.toString();

          if (SemanticHighlightingManager.getInstance()
              .getSemanticHighlightings().containsKey(namedStyle)) {
            AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
                .getInstance().getSemanticHighlightings()
                .get(namedStyle);
            String oldValue = getOverlayStore().getString(
                semanticHighlighting.getColorPreferenceKey());
            String newValue = ColorHelper
                .toRGBString(fForegroundColorEditor
                    .getColorValue());

            if (!newValue.equals(oldValue)) {
              getOverlayStore().setValue(
                  semanticHighlighting
                      .getColorPreferenceKey(), newValue);
              applyStyles();
              fText.redraw();
            }
            return;
          }

          String prefString = getOverlayStore().getString(namedStyle);
          String[] stylePrefs = ColorHelper
              .unpackStylePreferences(prefString);
          if (stylePrefs != null) {
            String oldValue = stylePrefs[0];
            // open color dialog to get new color
            String newValue = ColorHelper
                .toRGBString(fForegroundColorEditor
                    .getColorValue());

            if (!newValue.equals(oldValue)) {
              stylePrefs[0] = newValue;
              String newPrefString = ColorHelper
                  .packStylePreferences(stylePrefs);
              getOverlayStore().setValue(namedStyle,
                  newPrefString);
              applyStyles();
              fText.redraw();
            }
          }
        }
      }
    });

    fBackgroundColorEditor.addListener(new IPropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent event) {
        if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
          Object o = ((IStructuredSelection) fStylesViewer
              .getSelection()).getFirstElement();
          String namedStyle = o.toString();

          if (SemanticHighlightingManager.getInstance()
              .getSemanticHighlightings().containsKey(namedStyle)) {
            AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
                .getInstance().getSemanticHighlightings()
                .get(namedStyle);
            String oldValue = getOverlayStore().getString(
                semanticHighlighting
                    .getBackgroundColorPreferenceKey());
            String newValue = ColorHelper
                .toRGBString(fBackgroundColorEditor
                    .getColorValue());

            if (!newValue.equals(oldValue)) {
              getOverlayStore().setValue(
                  semanticHighlighting
                      .getBackgroundColorPreferenceKey(),
                  newValue);
              applyStyles();
              fText.redraw();
            }
            return;
          }

          String prefString = getOverlayStore().getString(namedStyle);
          String[] stylePrefs = ColorHelper
              .unpackStylePreferences(prefString);
          if (stylePrefs != null) {
            String oldValue = stylePrefs[1];
            // open color dialog to get new color
            String newValue = ColorHelper
                .toRGBString(fBackgroundColorEditor
                    .getColorValue());

            if (!newValue.equals(oldValue)) {
              stylePrefs[1] = newValue;
              String newPrefString = ColorHelper
                  .packStylePreferences(stylePrefs);
              getOverlayStore().setValue(namedStyle,
                  newPrefString);
              applyStyles();
              fText.redraw();
              activate(namedStyle);
            }
          }
        }
      }
    });

    fBold.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        super.widgetSelected(e);
        // get current (newly old) style
        Object o = ((IStructuredSelection) fStylesViewer.getSelection())
            .getFirstElement();
        String namedStyle = o.toString();

        if (SemanticHighlightingManager.getInstance()
            .getSemanticHighlightings().containsKey(namedStyle)) {
          AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
              .getInstance().getSemanticHighlightings()
              .get(namedStyle);
          String oldValue = getOverlayStore().getString(
              semanticHighlighting.getBoldPreferenceKey());
          String newValue = String.valueOf(fBold.getSelection());

          if (!newValue.equals(oldValue)) {
            getOverlayStore().setValue(
                semanticHighlighting.getBoldPreferenceKey(),
                newValue);
            applyStyles();
            fText.redraw();
          }
          return;
        }

        String prefString = getOverlayStore().getString(namedStyle);
        String[] stylePrefs = ColorHelper
            .unpackStylePreferences(prefString);
        if (stylePrefs != null) {
          String oldValue = stylePrefs[2];
          String newValue = String.valueOf(fBold.getSelection());
          if (!newValue.equals(oldValue)) {
            stylePrefs[2] = newValue;
            String newPrefString = ColorHelper
                .packStylePreferences(stylePrefs);
            getOverlayStore().setValue(namedStyle, newPrefString);
            applyStyles();
            fText.redraw();
          }
        }
      }
    });

    fItalic.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        super.widgetSelected(e);
        // get current (newly old) style
        Object o = ((IStructuredSelection) fStylesViewer.getSelection())
            .getFirstElement();
        String namedStyle = o.toString();
        if (SemanticHighlightingManager.getInstance()
            .getSemanticHighlightings().containsKey(namedStyle)) {
          AbstractSemanticHighlighting semanticHighlightingType = SemanticHighlightingManager
              .getInstance().getSemanticHighlightings()
              .get(namedStyle);
          String oldValue = getOverlayStore().getString(
              semanticHighlightingType.getItalicPreferenceKey());
          String newValue = String.valueOf(fItalic.getSelection());

          if (!newValue.equals(oldValue)) {
            getOverlayStore().setValue(
                semanticHighlightingType
                    .getItalicPreferenceKey(), newValue);
            applyStyles();
            fText.redraw();
          }
          return;
        }
        String prefString = getOverlayStore().getString(namedStyle);
        String[] stylePrefs = ColorHelper
            .unpackStylePreferences(prefString);
        if (stylePrefs != null) {
          String oldValue = stylePrefs[3];
          String newValue = String.valueOf(fItalic.getSelection());
          if (!newValue.equals(oldValue)) {
            stylePrefs[3] = newValue;
            String newPrefString = ColorHelper
                .packStylePreferences(stylePrefs);
            getOverlayStore().setValue(namedStyle, newPrefString);
            applyStyles();
            fText.redraw();
          }
        }
      }
    });

    fStrike.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        super.widgetSelected(e);
        // get current (newly old) style
        Object o = ((IStructuredSelection) fStylesViewer.getSelection())
            .getFirstElement();
        String namedStyle = o.toString();
        if (SemanticHighlightingManager.getInstance()
            .getSemanticHighlightings().containsKey(namedStyle)) {
          AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
              .getInstance().getSemanticHighlightings()
              .get(namedStyle);
          String oldValue = getOverlayStore().getString(
              semanticHighlighting
                  .getStrikethroughPreferenceKey());
          String newValue = String.valueOf(fStrike.getSelection());

          if (!newValue.equals(oldValue)) {
            getOverlayStore().setValue(
                semanticHighlighting
                    .getStrikethroughPreferenceKey(),
                newValue);
            applyStyles();
            fText.redraw();
          }
          return;
        }
        String prefString = getOverlayStore().getString(namedStyle);
        String[] stylePrefs = ColorHelper
            .unpackStylePreferences(prefString);
        if (stylePrefs != null) {
          String oldValue = stylePrefs[4];
          String newValue = String.valueOf(fStrike.getSelection());
          if (!newValue.equals(oldValue)) {
            stylePrefs[4] = newValue;
            String newPrefString = ColorHelper
                .packStylePreferences(stylePrefs);
            getOverlayStore().setValue(namedStyle, newPrefString);
            applyStyles();
            fText.redraw();
          }
        }
      }
    });

    fUnderline.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        super.widgetSelected(e);
        // get current (newly old) style
        Object o = ((IStructuredSelection) fStylesViewer.getSelection())
            .getFirstElement();
        String namedStyle = o.toString();

        if (SemanticHighlightingManager.getInstance()
            .getSemanticHighlightings().containsKey(namedStyle)) {
          AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
              .getInstance().getSemanticHighlightings()
              .get(namedStyle);
          String oldValue = getOverlayStore().getString(
              semanticHighlighting.getUnderlinePreferenceKey());
          String newValue = String.valueOf(fUnderline.getSelection());

          if (!newValue.equals(oldValue)) {
            getOverlayStore().setValue(
                semanticHighlighting
                    .getUnderlinePreferenceKey(), newValue);
            applyStyles();
            fText.redraw();
          }
          return;
        }

        String prefString = getOverlayStore().getString(namedStyle);
        String[] stylePrefs = ColorHelper
            .unpackStylePreferences(prefString);
        if (stylePrefs != null) {
          String oldValue = stylePrefs[5];
          String newValue = String.valueOf(fUnderline.getSelection());
          if (!newValue.equals(oldValue)) {
            stylePrefs[5] = newValue;
            String newPrefString = ColorHelper
                .packStylePreferences(stylePrefs);
            getOverlayStore().setValue(namedStyle, newPrefString);
            applyStyles();
            fText.redraw();
          }
        }
      }
    });

    fClearStyle.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        if (fStylesViewer.getSelection().isEmpty())
          return;
        String namedStyle = ((IStructuredSelection) fStylesViewer
            .getSelection()).getFirstElement().toString();
        if (SemanticHighlightingManager.getInstance()
            .getSemanticHighlightings().containsKey(namedStyle)) {
          AbstractSemanticHighlighting semanticHighlighting = SemanticHighlightingManager
              .getInstance().getSemanticHighlightings()
              .get(namedStyle);
          getOverlayStore().setToDefault(
              semanticHighlighting.getBoldPreferenceKey());
          getOverlayStore().setToDefault(
              semanticHighlighting.getColorPreferenceKey());
          getOverlayStore().setToDefault(
              semanticHighlighting
                  .getBackgroundColorPreferenceKey());
          getOverlayStore().setToDefault(
              semanticHighlighting.getEnabledPreferenceKey());
          getOverlayStore().setToDefault(
              semanticHighlighting.getItalicPreferenceKey());
          getOverlayStore().setToDefault(
              semanticHighlighting
                  .getStrikethroughPreferenceKey());
          getOverlayStore().setToDefault(
              semanticHighlighting.getUnderlinePreferenceKey());
          boolean enablement = getOverlayStore().getDefaultBoolean(
              semanticHighlighting.getEnabledPreferenceKey());
          switchEnablement(enablement);
        } else {
          getOverlayStore().setToDefault(namedStyle);
        }
        applyStyles();
        fText.redraw();
        activate(namedStyle);
      }
    });

    fEnabler.addSelectionListener(new SelectionAdapter() {

      public void widgetSelected(SelectionEvent e) {
        // get current (newly old) style
        Object o = ((IStructuredSelection) fStylesViewer.getSelection())
            .getFirstElement();
        String namedStyle = o.toString();

        Map<String, AbstractSemanticHighlighting> highlightingMap = SemanticHighlightingManager
            .getInstance().getSemanticHighlightings();
        if (highlightingMap.containsKey(namedStyle)) {
          AbstractSemanticHighlighting semantic = highlightingMap
              .get(namedStyle);
          boolean enablement = fEnabler.getSelection();
          semantic.getStyle().setEnabledByDefault(enablement);
          switchEnablement(enablement);
          getOverlayStore().setValue(
              semantic.getEnabledPreferenceKey(), enablement);
          applyStyles();
          fText.redraw();

        } else if (getStylePreferenceKeys().contains(namedStyle)) {
          boolean enablement = fEnabler.getSelection();
View Full Code Here

    for (IConfigurationElement element : elements) {
      String target = element.getAttribute("target"); //$NON-NLS-1$
      if ("org.eclipse.php.core.phpsource".equals(target)) { //$NON-NLS-1$
        final Object o = element.createExecutableExtension("class"); //$NON-NLS-1$
        if (o instanceof AbstractSemanticHighlighting) {
          AbstractSemanticHighlighting instance = (AbstractSemanticHighlighting) o;
          rules.add(instance);
        }
      }
    }
    return this;
View Full Code Here

              assertNotNull(module);
              String index = fileName.substring(fileName
                  .lastIndexOf('/') + 1, fileName
                  .indexOf('.'));
              // System.err.println(index);
              AbstractSemanticHighlighting highlighter = highlighters
                  .get(index);
              assertNotNull(highlighter);
              Program program = getProgram(module);
              highlighter.initDefaultPreferences();
              Position[] positions = highlighter
                  .consumes(program);
              assertNoDuplicates(highlighter.getDisplayName(),
                  positions);
              result += highlighter.getClass().getName() + ":\n";
              for (Position position : positions) {
                result += "highlight("
                    + pdttFile.getFile().substring(
                        position.getOffset(),
                        position.getOffset()
                            + position.getLength())
                    + ")\n";
              }
              assertEquals(pdttFile.getExpected(), result);
              // We check the other highlighters for failure
              for (AbstractSemanticHighlighting h : highlighters
                  .values()) {
                if (h != highlighter) {
                  h.initDefaultPreferences();
                  positions = h.consumes(program);
                  assertNoDuplicates(highlighter
                      .getDisplayName(), positions);
                }
              }
            }
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.ui.editor.highlighter.AbstractSemanticHighlighting

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.