Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/CSSUiModule.java28
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CSSProposalProvider.xtend12
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingCalculator.java103
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingConfiguration.java72
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSDescriptionLabelProvider.xtend24
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSLabelProvider.xtend29
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/outline/CSSOutlineTreeProvider.xtend13
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/quickfix/CSSQuickfixProvider.xtend26
8 files changed, 307 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/CSSUiModule.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/CSSUiModule.java
new file mode 100644
index 00000000000..2b34ca80f4e
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/CSSUiModule.java
@@ -0,0 +1,28 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui;
+
+import org.eclipse.papyrus.infra.gmfdiag.css3.ui.highlighting.CSSHighlightingCalculator;
+import org.eclipse.papyrus.infra.gmfdiag.css3.ui.highlighting.CSSHighlightingConfiguration;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfiguration;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
+
+/**
+ * Use this class to register components to be used within the IDE.
+ */
+public class CSSUiModule extends org.eclipse.papyrus.infra.gmfdiag.css3.ui.AbstractCSSUiModule {
+
+ public CSSUiModule(AbstractUIPlugin plugin) {
+ super(plugin);
+ }
+
+ public Class<? extends IHighlightingConfiguration> bindIHighlightingConfiguration() {
+ return CSSHighlightingConfiguration.class;
+ }
+
+ public Class<? extends ISemanticHighlightingCalculator> bindISemanticHighlightingCalculator() {
+ return CSSHighlightingCalculator.class;
+ }
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CSSProposalProvider.xtend b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CSSProposalProvider.xtend
new file mode 100644
index 00000000000..d73c99d5acb
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/contentassist/CSSProposalProvider.xtend
@@ -0,0 +1,12 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui.contentassist
+
+import org.eclipse.papyrus.infra.gmfdiag.css3.ui.contentassist.AbstractCSSProposalProvider
+
+/**
+ * see http://www.eclipse.org/Xtext/documentation.html#contentAssist on how to customize content assistant
+ */
+class CSSProposalProvider extends AbstractCSSProposalProvider {
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingCalculator.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingCalculator.java
new file mode 100644
index 00000000000..0b764316acc
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingCalculator.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2011 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christoph Caks <ccaks@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui.highlighting;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.CssTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.ElementSelector;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.FuncTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.IdentifierTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.StringTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.SymbolTok;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.URLType;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.css_declaration;
+import org.eclipse.papyrus.infra.gmfdiag.css3.cSS.simple_selector;
+import org.eclipse.xtext.nodemodel.ICompositeNode;
+import org.eclipse.xtext.nodemodel.util.NodeModelUtils;
+import org.eclipse.xtext.resource.XtextResource;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightedPositionAcceptor;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.ISemanticHighlightingCalculator;
+
+public class CSSHighlightingCalculator implements ISemanticHighlightingCalculator {
+
+ @Override
+ public void provideHighlightingFor(XtextResource resource, IHighlightedPositionAcceptor acceptor) {
+ if (resource == null) {
+ return;
+ }
+ TreeIterator<Object> it = EcoreUtil.getAllContents(resource, true);
+ while (it.hasNext()) {
+ Object o = it.next();
+ if (o instanceof ElementSelector) {
+ final ICompositeNode n = NodeModelUtils.getNode((EObject) o);
+ if (n != null) {
+ acceptor.addPosition(n.getOffset(), n.getLength(), CSSHighlightingConfiguration.ELEMENT);
+ }
+ } else if (o instanceof IdentifierTok) {
+ final ICompositeNode n = NodeModelUtils.getNode((EObject) o);
+ if (n != null) {
+ acceptor.addPosition(n.getOffset(), n.getLength(), DefaultHighlightingConfiguration.DEFAULT_ID);
+ }
+ } else if (o instanceof css_declaration) {
+ css_declaration dec = (css_declaration) o;
+ if (dec.getProperty() != null && dec.getProperty().getName() != null && dec.getProperty().getName().trim().length() > 0) {
+ ICompositeNode n = NodeModelUtils.getNode(dec);
+ if (n != null) {
+ if (n.hasChildren()) {
+ acceptor.addPosition(n.getFirstChild().getOffset(), n.getFirstChild().getLength(), CSSHighlightingConfiguration.DECLARATIONNAME);
+ }
+ }
+ }
+ } else if (o instanceof simple_selector) {
+ final ICompositeNode n = NodeModelUtils.getNode((EObject) o);
+ if (n != null) {
+ acceptor.addPosition(n.getOffset(), n.getLength(), CSSHighlightingConfiguration.SELECTOR);
+ }
+ } else if (o instanceof URLType) {
+ final URLType url = (URLType) o;
+ final ICompositeNode n = NodeModelUtils.getNode(url);
+ if (n != null) {
+ acceptor.addPosition(n.getOffset(), 4, CSSHighlightingConfiguration.FUNCTION);
+ acceptor.addPosition(n.getOffset() + 4, n.getLength() - 5, CSSHighlightingConfiguration.URL);
+ acceptor.addPosition(n.getOffset() + n.getLength() - 1, 1, CSSHighlightingConfiguration.FUNCTION);
+ }
+ } else if (o instanceof FuncTok) {
+ final FuncTok funcTok = (FuncTok) o;
+ final ICompositeNode n = NodeModelUtils.getNode(funcTok);
+ int nameLength = funcTok.getName().getName().length();
+ if (n != null) {
+ acceptor.addPosition(n.getOffset(), nameLength + 1, CSSHighlightingConfiguration.FUNCTION);
+ }
+ for (CssTok tok : ((FuncTok) o).getParams()) {
+ if (tok instanceof SymbolTok) {
+ if (",".equals(((SymbolTok) tok).getSymbol())) { //$NON-NLS-1$
+ ICompositeNode colonNode = NodeModelUtils.getNode(tok);
+ if (colonNode != null) {
+ acceptor.addPosition(colonNode.getOffset(), colonNode.getLength(), CSSHighlightingConfiguration.FUNCTION);
+ }
+ }
+ }
+ }
+ if (n != null) {
+ acceptor.addPosition(n.getOffset() + n.getLength() - 1, 1, CSSHighlightingConfiguration.FUNCTION);
+ }
+ } else if (o instanceof StringTok) {
+ final ICompositeNode n = NodeModelUtils.getNode((EObject) o);
+ if (n != null) {
+ acceptor.addPosition(n.getOffset(), n.getLength(), DefaultHighlightingConfiguration.STRING_ID);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingConfiguration.java b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingConfiguration.java
new file mode 100644
index 00000000000..4e5b6dd6334
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/highlighting/CSSHighlightingConfiguration.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christoph Caks <ccaks@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui.highlighting;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.DefaultHighlightingConfiguration;
+import org.eclipse.xtext.ui.editor.syntaxcoloring.IHighlightingConfigurationAcceptor;
+import org.eclipse.xtext.ui.editor.utils.TextStyle;
+
+public class CSSHighlightingConfiguration extends DefaultHighlightingConfiguration {
+ public final static String DECLARATIONNAME = "DeclarationName";
+ public final static String SELECTOR = "Selector";
+ public final static String ELEMENT = "ELEMENT";
+ public final static String URL = "Url";
+ public final static String FUNCTION = "Function";
+
+ @Override
+ public void configure(IHighlightingConfigurationAcceptor acceptor) {
+ // from super (without the keyword)
+ acceptor.acceptDefaultHighlighting(PUNCTUATION_ID, "Punctuation character", punctuationTextStyle());
+ acceptor.acceptDefaultHighlighting(COMMENT_ID, "Comment", commentTextStyle());
+ acceptor.acceptDefaultHighlighting(STRING_ID, "String", stringTextStyle());
+ acceptor.acceptDefaultHighlighting(NUMBER_ID, "Number", numberTextStyle());
+ acceptor.acceptDefaultHighlighting(DEFAULT_ID, "Default", defaultTextStyle());
+ acceptor.acceptDefaultHighlighting(INVALID_TOKEN_ID, "Invalid Symbol", errorTextStyle());
+ // local
+ acceptor.acceptDefaultHighlighting(DECLARATIONNAME, "Declaration", crossDeclarationTextStyle());
+ acceptor.acceptDefaultHighlighting(SELECTOR, "Selector", crossSelectorTextStyle());
+ acceptor.acceptDefaultHighlighting(URL, "Url", urlTextStyle());
+ acceptor.acceptDefaultHighlighting(FUNCTION, "Function", functionTextStyle());
+ acceptor.acceptDefaultHighlighting(ELEMENT, "Element", elementTextStyle());
+ }
+
+ public TextStyle crossDeclarationTextStyle() {
+ TextStyle textStyle = defaultTextStyle().copy();
+ textStyle.setColor(new RGB(0, 153, 0));
+ return textStyle;
+ }
+
+ public TextStyle elementTextStyle() {
+ TextStyle textStyle = crossSelectorTextStyle().copy();
+ textStyle.setStyle(SWT.BOLD);
+ return textStyle;
+ }
+
+
+ public TextStyle crossSelectorTextStyle() {
+ TextStyle textStyle = defaultTextStyle().copy();
+ textStyle.setColor(new RGB(206, 123, 0));
+ return textStyle;
+ }
+
+ public TextStyle urlTextStyle() {
+ TextStyle textStyle = stringTextStyle().copy();
+ return textStyle;
+ }
+
+ public TextStyle functionTextStyle() {
+ TextStyle textStyle = defaultTextStyle().copy();
+ textStyle.setStyle(SWT.BOLD);
+ return textStyle;
+ }
+} \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSDescriptionLabelProvider.xtend b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSDescriptionLabelProvider.xtend
new file mode 100644
index 00000000000..480a54a4b31
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSDescriptionLabelProvider.xtend
@@ -0,0 +1,24 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui.labeling
+
+//import org.eclipse.xtext.resource.IEObjectDescription
+
+/**
+ * Provides labels for a IEObjectDescriptions and IResourceDescriptions.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#labelProvider
+ */
+class CSSDescriptionLabelProvider extends org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider {
+
+ // Labels and icons can be computed like this:
+
+// override text(IEObjectDescription ele) {
+// ele.name.toString
+// }
+//
+// override image(IEObjectDescription ele) {
+// ele.EClass.name + '.gif'
+// }
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSLabelProvider.xtend b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSLabelProvider.xtend
new file mode 100644
index 00000000000..a77a18c7579
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/labeling/CSSLabelProvider.xtend
@@ -0,0 +1,29 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui.labeling
+
+import com.google.inject.Inject
+
+/**
+ * Provides labels for a EObjects.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#labelProvider
+ */
+class CSSLabelProvider extends org.eclipse.xtext.ui.label.DefaultEObjectLabelProvider {
+
+ @Inject
+ new(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider delegate) {
+ super(delegate);
+ }
+
+ // Labels and icons can be computed like this:
+
+// def text(Greeting ele) {
+// 'A greeting to ' + ele.name
+// }
+//
+// def image(Greeting ele) {
+// 'Greeting.gif'
+// }
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/outline/CSSOutlineTreeProvider.xtend b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/outline/CSSOutlineTreeProvider.xtend
new file mode 100644
index 00000000000..8de35448292
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/outline/CSSOutlineTreeProvider.xtend
@@ -0,0 +1,13 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui.outline
+
+/**
+ * Customization of the default outline structure.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#outline
+ */
+class CSSOutlineTreeProvider extends org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider {
+
+}
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/quickfix/CSSQuickfixProvider.xtend b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/quickfix/CSSQuickfixProvider.xtend
new file mode 100644
index 00000000000..10d4d9e4ff2
--- /dev/null
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext.ui/src/org/eclipse/papyrus/infra/gmfdiag/css3/ui/quickfix/CSSQuickfixProvider.xtend
@@ -0,0 +1,26 @@
+/*
+ * generated by Xtext
+ */
+package org.eclipse.papyrus.infra.gmfdiag.css3.ui.quickfix
+
+//import org.eclipse.xtext.ui.editor.quickfix.Fix
+//import org.eclipse.xtext.ui.editor.quickfix.IssueResolutionAcceptor
+//import org.eclipse.xtext.validation.Issue
+
+/**
+ * Custom quickfixes.
+ *
+ * see http://www.eclipse.org/Xtext/documentation.html#quickfixes
+ */
+class CSSQuickfixProvider extends org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider {
+
+// @Fix(MyDslValidator::INVALID_NAME)
+// def capitalizeName(Issue issue, IssueResolutionAcceptor acceptor) {
+// acceptor.accept(issue, 'Capitalize name', 'Capitalize the name.', 'upcase.png') [
+// context |
+// val xtextDocument = context.xtextDocument
+// val firstLetter = xtextDocument.get(issue.offset, 1)
+// xtextDocument.replace(issue.offset, 1, firstLetter.toUpperCase)
+// ]
+// }
+}

Back to the top