From: Hannu Niemistö Date: Fri, 12 May 2017 21:12:51 +0000 (+0300) Subject: (refs #7219) Remove deprecated code (scl.compiler.dummy and editor) X-Git-Tag: v1.29.0~52 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=daab168e98bc21070ccb45beba497e3d712adfeb;p=simantics%2Fplatform.git (refs #7219) Remove deprecated code (scl.compiler.dummy and editor) Change-Id: Ibd2bc7b4ca78637460701351b7511dc77ba6ef2f --- diff --git a/bundles/org.simantics.browsing.ui.swt/META-INF/MANIFEST.MF b/bundles/org.simantics.browsing.ui.swt/META-INF/MANIFEST.MF index 37466aeda..4eaa04be3 100644 --- a/bundles/org.simantics.browsing.ui.swt/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.browsing.ui.swt/META-INF/MANIFEST.MF @@ -14,8 +14,6 @@ Require-Bundle: org.simantics.utils.thread.swt;bundle-version="1.0.0", org.simantics.g2d;bundle-version="[1.0.0,2.0.0)", org.eclipse.ui.forms;bundle-version="3.4.1", com.lowagie.text;bundle-version="2.1.5", - org.simantics.scl.ui.editor;bundle-version="0.1.3";visibility:=reexport, - org.simantics.scl.compiler.dummy;bundle-version="0.1.3", org.eclipse.e4.core.contexts;bundle-version="1.4.0", org.slf4j.api;bundle-version="1.7.20" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/SCLEditor.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/SCLEditor.java deleted file mode 100644 index 109d84084..000000000 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/widgets/SCLEditor.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 Association for Decentralized Information Management - * in Industry THTH ry. - * 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.browsing.ui.swt.widgets; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.simantics.browsing.ui.swt.widgets.impl.ReadFactory; -import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; -import org.simantics.db.management.ISessionContext; -import org.simantics.db.procedure.Listener; -import org.simantics.scl.compiler.StandardSCLCompilerConfiguration; -import org.simantics.scl.ui.editor.SCLTextEditor; -import org.simantics.utils.ui.SWTUtils; - -public class SCLEditor extends WidgetImpl { - - private ReadFactory textFactory; - - final private SCLTextEditor editor; - - public SCLEditor(Composite parent, WidgetSupport support, int style) { - super(support); - editor = new SCLTextEditor(parent, style, StandardSCLCompilerConfiguration.INSTANCE); - support.register(this); - } - - public void setTextFactory(ReadFactory textFactory) { - this.textFactory = textFactory; - } - - public SCLTextEditor getWidget() { - return editor; - } - - @Override - public Control getControl() { - return editor; - } - - @Override - public void setInput(ISessionContext context, Object input) { - - if(textFactory != null) { - textFactory.listen(context, input, new Listener() { - - public void exception(final Throwable t) { - SWTUtils.asyncExec(editor, new Runnable() { - - @Override - public void run() { - if(isDisposed()) return; -// System.out.println("Button received new text: " + text); - editor.setContent(t.toString()); - } - - }); - } - - @Override - public void execute(final String s) { - SWTUtils.asyncExec(editor, new Runnable() { - - @Override - public void run() { - if(isDisposed()) return; - editor.setContent(s); - } - - }); - } - - @Override - public boolean isDisposed() { - return editor.isDisposed(); - } - - }); - - } - - } - - public void setContent(String s) { - editor.setContent(s); - } - - public String getContent() { - return editor.getContent(); - } - -} diff --git a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/SCLEditorComposite.java b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/SCLEditorComposite.java index c73efe63f..391648b62 100644 --- a/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/SCLEditorComposite.java +++ b/bundles/org.simantics.diagram.profile/src/org/simantics/diagram/profile/view/SCLEditorComposite.java @@ -18,8 +18,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IWorkbenchSite; import org.simantics.browsing.ui.swt.widgets.Button; -import org.simantics.browsing.ui.swt.widgets.SCLEditor; import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory; +import org.simantics.browsing.ui.swt.widgets.Text; import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl; import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport; import org.simantics.db.Resource; @@ -32,7 +32,7 @@ import org.simantics.selectionview.ConfigurationComposite; public class SCLEditorComposite extends ConfigurationComposite { - private SCLEditor editor; + private Text editor; public void create(Composite body, IWorkbenchSite site, ISessionContext context, final WidgetSupport support) { @@ -47,10 +47,10 @@ public class SCLEditorComposite extends ConfigurationComposite { @Override public void beforeApply() { - content = editor.getContent(); - editor.getWidget().storeSelectedRange(); + content = editor.getWidget().getText(); + //editor.getWidget().storeSelectedRange(); editor.getControl().setFocus(); - editor.getWidget().restoreSelectedRange(); + //editor.getWidget().restoreSelectedRange(); } @Override @@ -61,7 +61,7 @@ public class SCLEditorComposite extends ConfigurationComposite { }); - editor = new SCLEditor(body, support, SWT.BORDER | SWT.FLAT); + editor = new Text(body, support, SWT.BORDER | SWT.FLAT); editor.setTextFactory(new StringPropertyFactory(Layer0X.URIs.HasExpression)); //editor.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasExpression)); GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(editor.getControl()); diff --git a/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF b/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF index 525c8da52..a426ba5c9 100644 --- a/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.modeling.ui/META-INF/MANIFEST.MF @@ -35,7 +35,6 @@ Require-Bundle: org.simantics.project;bundle-version="1.0.0", org.bouncycastle.bcprov-jdk14;bundle-version="1.38.0", org.simantics.image2.ontology;bundle-version="1.1.0", org.simantics.scl.compiler;bundle-version="0.4.0", - org.simantics.scl.compiler.dummy;bundle-version="1.0.0", org.simantics.scl.osgi;bundle-version="1.0.4", org.eclipse.jface.text;bundle-version="3.7.1", org.simantics.graphviz, diff --git a/bundles/org.simantics.scl.compiler.dummy/.classpath b/bundles/org.simantics.scl.compiler.dummy/.classpath deleted file mode 100644 index eca7bdba8..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.simantics.scl.compiler.dummy/.project b/bundles/org.simantics.scl.compiler.dummy/.project deleted file mode 100644 index 62879b7cf..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.simantics.scl.compiler.dummy - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/bundles/org.simantics.scl.compiler.dummy/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.scl.compiler.dummy/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c68a61dc..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bundles/org.simantics.scl.compiler.dummy/META-INF/MANIFEST.MF b/bundles/org.simantics.scl.compiler.dummy/META-INF/MANIFEST.MF deleted file mode 100644 index da14e1372..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/META-INF/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Dummy SCL compiler -Bundle-SymbolicName: org.simantics.scl.compiler.dummy -Bundle-Version: 1.0.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: org.simantics.scl.compiler -Require-Bundle: org.simantics.scl.runtime;bundle-version="0.2.0" diff --git a/bundles/org.simantics.scl.compiler.dummy/build.properties b/bundles/org.simantics.scl.compiler.dummy/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/ErrorMessage.java b/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/ErrorMessage.java deleted file mode 100644 index 958fd1204..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/ErrorMessage.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.simantics.scl.compiler; - -public class ErrorMessage { - int line; - int start; - int stop; - String message; - - public ErrorMessage(int line, int start, int stop, String message) { - this.line = line; - this.start = start; - this.stop = stop; - this.message = message; - } - - public int getLine() { - return line; - } - - public int getStart() { - return start; - } - - public int getStop() { - return stop; - } - - public String getMessage() { - return message; - } - - @Override - public String toString() { - return "at " + line + ":" + start + "-" + stop + " " + message; - } -} diff --git a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/InvalidInputException.java b/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/InvalidInputException.java deleted file mode 100644 index 7a61c27f0..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/InvalidInputException.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.simantics.scl.compiler; - -import java.util.Collection; - -public class InvalidInputException extends Exception { - - private static final long serialVersionUID = 2923907879583127677L; - - Collection errors; - - public InvalidInputException(Collection errors) { - this.errors = errors; - } - - public Collection getErrors() { - return errors; - } - -} diff --git a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/SCLCompiler.java b/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/SCLCompiler.java deleted file mode 100644 index b552c707b..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/SCLCompiler.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.simantics.scl.compiler; - -import java.io.InputStream; -import java.util.Collections; - -import org.simantics.scl.runtime.Computation; - -public class SCLCompiler { - - public SCLCompiler(SCLCompilerConfiguration configuration) { - } - - public static Computation compileExpression(SCLCompilerConfiguration configuration, InputStream code) throws InvalidInputException { - throw new InvalidInputException(Collections.singleton(new ErrorMessage(0, 0, 0, "No SCL compiler"))); - } - - public static Computation compileExpression(SCLCompilerConfiguration configuration, String code) throws InvalidInputException { - throw new InvalidInputException(Collections.singleton(new ErrorMessage(0, 0, 0, "No SCL compiler"))); - } - -} diff --git a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/SCLCompilerConfiguration.java b/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/SCLCompilerConfiguration.java deleted file mode 100644 index de0461ff1..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/SCLCompilerConfiguration.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.simantics.scl.compiler; - - -public interface SCLCompilerConfiguration { -} diff --git a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/StandardSCLCompilerConfiguration.java b/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/StandardSCLCompilerConfiguration.java deleted file mode 100644 index e86be850d..000000000 --- a/bundles/org.simantics.scl.compiler.dummy/src/org/simantics/scl/compiler/StandardSCLCompilerConfiguration.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.simantics.scl.compiler; - - -public class StandardSCLCompilerConfiguration implements SCLCompilerConfiguration { - - public static final SCLCompilerConfiguration INSTANCE = new StandardSCLCompilerConfiguration(); - -} diff --git a/bundles/org.simantics.scl.ui.editor/.classpath b/bundles/org.simantics.scl.ui.editor/.classpath deleted file mode 100644 index eca7bdba8..000000000 --- a/bundles/org.simantics.scl.ui.editor/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/bundles/org.simantics.scl.ui.editor/.gitignore b/bundles/org.simantics.scl.ui.editor/.gitignore deleted file mode 100644 index c5e82d745..000000000 --- a/bundles/org.simantics.scl.ui.editor/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bin \ No newline at end of file diff --git a/bundles/org.simantics.scl.ui.editor/.project b/bundles/org.simantics.scl.ui.editor/.project deleted file mode 100644 index aef84f509..000000000 --- a/bundles/org.simantics.scl.ui.editor/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.simantics.scl.ui.editor - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/bundles/org.simantics.scl.ui.editor/.settings/org.eclipse.jdt.core.prefs b/bundles/org.simantics.scl.ui.editor/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0c68a61dc..000000000 --- a/bundles/org.simantics.scl.ui.editor/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bundles/org.simantics.scl.ui.editor/META-INF/MANIFEST.MF b/bundles/org.simantics.scl.ui.editor/META-INF/MANIFEST.MF deleted file mode 100644 index 6dc71a61b..000000000 --- a/bundles/org.simantics.scl.ui.editor/META-INF/MANIFEST.MF +++ /dev/null @@ -1,17 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: SCL Workbench Editor -Bundle-SymbolicName: org.simantics.scl.ui.editor -Bundle-Version: 0.1.3 -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Require-Bundle: org.eclipse.swt;bundle-version="3.104.0", - gnu.trove3;bundle-version="3.0.3", - org.simantics.scl.compiler.dummy;bundle-version="0.0.9", - org.simantics.scl.runtime;bundle-version="0.0.9", - org.eclipse.jface;bundle-version="3.11.0", - org.eclipse.jface.text;bundle-version="3.6.0", - org.eclipse.core.runtime;bundle-version="3.11.0", - org.eclipse.ui.workbench.texteditor;bundle-version="3.6.0", - org.eclipse.ui.editors;bundle-version="3.6.0" -Export-Package: org.simantics.scl.ui.editor -Bundle-Vendor: VTT Technical Research Centre of Finland diff --git a/bundles/org.simantics.scl.ui.editor/build.properties b/bundles/org.simantics.scl.ui.editor/build.properties deleted file mode 100644 index 34d2e4d2d..000000000 --- a/bundles/org.simantics.scl.ui.editor/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - . diff --git a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLAnnotationAccess.java b/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLAnnotationAccess.java deleted file mode 100644 index 5a300fbfa..000000000 --- a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLAnnotationAccess.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.simantics.scl.ui.editor; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationAccess; -import org.eclipse.jface.text.source.IAnnotationAccessExtension; -import org.eclipse.jface.text.source.ImageUtilities; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; - -final class SCLAnnotationAccess implements IAnnotationAccess, IAnnotationAccessExtension { - - ImageRegistry registry; - - public SCLAnnotationAccess(ImageRegistry registry) { - this.registry = registry; - } - - @Override - public Object getType(Annotation annotation) { - return annotation.getType(); - } - - @Override - public boolean isMultiLine(Annotation annotation) { - return true; - } - - @Override - public boolean isTemporary(Annotation annotation) { - return !annotation.isPersistent(); - } - - @Override - public String getTypeLabel(Annotation annotation) { - return annotation.getType(); - } - - @Override - public int getLayer(Annotation annotation) { - return 0; - } - - @Override - public void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds) { - Image image = registry.get("error"); - if(image == null) { - registry.put("error", ImageDescriptor.createFromFile(getClass(), "error_tsk.gif")); - image = registry.get("error"); - } - ImageUtilities.drawImage(image, gc, canvas, bounds, SWT.CENTER, SWT.TOP); - } - - @Override - public boolean isPaintable(Annotation annotation) { - return true; - } - - @Override - public boolean isSubtype(Object annotationType, Object potentialSupertype) { - return annotationType.equals(potentialSupertype); - } - - @Override - public Object[] getSupertypes(Object annotationType) { - return new Object[0]; - } -} \ No newline at end of file diff --git a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLSourceViewerConfiguration.java b/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLSourceViewerConfiguration.java deleted file mode 100644 index 0ceb9f6e0..000000000 --- a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLSourceViewerConfiguration.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.simantics.scl.ui.editor; - -import org.eclipse.jface.text.DefaultTextHover; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextHover; -import org.eclipse.jface.text.TextAttribute; -import org.eclipse.jface.text.presentation.IPresentationReconciler; -import org.eclipse.jface.text.presentation.PresentationReconciler; -import org.eclipse.jface.text.rules.DefaultDamagerRepairer; -import org.eclipse.jface.text.rules.IRule; -import org.eclipse.jface.text.rules.ITokenScanner; -import org.eclipse.jface.text.rules.IWordDetector; -import org.eclipse.jface.text.rules.MultiLineRule; -import org.eclipse.jface.text.rules.PatternRule; -import org.eclipse.jface.text.rules.RuleBasedScanner; -import org.eclipse.jface.text.rules.Token; -import org.eclipse.jface.text.rules.WordRule; -import org.eclipse.jface.text.source.DefaultAnnotationHover; -import org.eclipse.jface.text.source.IAnnotationHover; -import org.eclipse.jface.text.source.ISharedTextColors; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Device; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.RGB; - -public class SCLSourceViewerConfiguration extends SourceViewerConfiguration { - - public static final char[] CONTENT_ASSIST_AUTO_CHARS = new char[] { '.' }; - Device device; - - ISharedTextColors sharedTextColors; - - public SCLSourceViewerConfiguration(Device device, - ISharedTextColors sharedTextColors) { - this.device = device; - this.sharedTextColors = sharedTextColors; - } - - public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) { - return new String[] { - IDocument.DEFAULT_CONTENT_TYPE - }; - } - - public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) { - PresentationReconciler reconciler = new PresentationReconciler(); - - DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getSclTokenScanner()); - - reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE); - reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE); - - return reconciler; - } - - ITokenScanner getSclTokenScanner() { - RuleBasedScanner scanner = new RuleBasedScanner(); - - Font font = new Font(device, "Courier New", 10, SWT.NORMAL); - Font boldFont = new Font(device, "Courier New", 10, SWT.BOLD); - - Token defaultToken = new Token( - new TextAttribute( - sharedTextColors.getColor(new RGB(0, 0, 0)), - null, - 0, - font - )); - Token string = new Token(new TextAttribute( - sharedTextColors.getColor(new RGB(42, 0, 255)), - null, - 0, - font - )); - Token reserved = new Token( - new TextAttribute( - sharedTextColors.getColor(new RGB(127, 0, 85)), - null, - SWT.BOLD, - boldFont - )); - Token comment = new Token(new TextAttribute( - sharedTextColors.getColor(new RGB(63, 127, 95)), - null, - 0, - font - )); - - WordRule reservedWord = new WordRule(new IWordDetector() { - @Override - public boolean isWordStart(char c) { - return Character.isJavaIdentifierStart(c); - } - - @Override - public boolean isWordPart(char c) { - return Character.isJavaIdentifierPart(c) || c=='.'; - } - }); - - reservedWord.addWord("if", reserved); - reservedWord.addWord("then", reserved); - reservedWord.addWord("else", reserved); - reservedWord.addWord("match", reserved); - reservedWord.addWord("with", reserved); - reservedWord.addWord("data", reserved); - reservedWord.addWord("type", reserved); - reservedWord.addWord("class", reserved); - - IRule[] rules = new IRule[] { - //new MultiLineRule("\"\"\"", "\"\"\"", string), - new PatternRule("\"", "\"", string, '\\', true), - new MultiLineRule("/*", "*/", comment), - new PatternRule("//", null, comment, '\0', true), - reservedWord - }; - scanner.setRules(rules); - scanner.setDefaultReturnToken(defaultToken); - - return scanner; - } - - @Override - public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) { - return new DefaultTextHover(sourceViewer); - } - - @Override - public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) { - return new DefaultAnnotationHover(); - } -} diff --git a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLTextEditor.java b/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLTextEditor.java deleted file mode 100644 index ee081ff16..000000000 --- a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SCLTextEditor.java +++ /dev/null @@ -1,234 +0,0 @@ -package org.simantics.scl.ui.editor; - - -import java.util.Collection; -import java.util.Iterator; - -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.ITextListener; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.TextEvent; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.AnnotationModel; -import org.eclipse.jface.text.source.AnnotationPainter; -import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.ISharedTextColors; -import org.eclipse.jface.text.source.OverviewRuler; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.VerticalRuler; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.simantics.scl.compiler.ErrorMessage; -import org.simantics.scl.compiler.InvalidInputException; -import org.simantics.scl.compiler.SCLCompiler; -import org.simantics.scl.compiler.SCLCompilerConfiguration; - -public class SCLTextEditor extends Composite { - - private static final int DELAY_BEFORE_COMPILATION = 500 /*ms*/; - - SCLCompilerConfiguration configuration; - - SourceViewer viewer; - ImageRegistry imageRegistry; - SCLAnnotationAccess annotationAccess; - ISharedTextColors sharedTextColors; - IAnnotationModel annotationModel; - - public SCLTextEditor(Composite parent, int style, SCLCompilerConfiguration configuration) { - super(parent, style); - setLayout(new FillLayout()); - - this.configuration = configuration; - - imageRegistry = new ImageRegistry(parent.getDisplay()); - annotationAccess = new SCLAnnotationAccess(imageRegistry); - sharedTextColors = new SharedTextColors(getDisplay()); - annotationModel = new AnnotationModel(); - - VerticalRuler leftRuler = new VerticalRuler(12, annotationAccess); - leftRuler.setModel(annotationModel); - - OverviewRuler rightRuler = - new OverviewRuler(annotationAccess, 12, sharedTextColors); - rightRuler.setModel(annotationModel); - rightRuler.addAnnotationType("error"); - rightRuler.setAnnotationTypeLayer("error", 0); - rightRuler.setAnnotationTypeColor("error", sharedTextColors.getColor(new RGB(255,0,128))); - - viewer = new SourceViewer(this, - leftRuler, rightRuler, - true, - SWT.H_SCROLL | SWT.V_SCROLL); - Document document = new Document(); - viewer.setDocument(document, annotationModel); - viewer.setEditable(true); - viewer.configure(new SCLSourceViewerConfiguration( - getDisplay(), sharedTextColors)); - - // Annotations to text area - AnnotationPainter annotationPainter = - new AnnotationPainter(viewer, annotationAccess); - annotationPainter.addAnnotationType("error"); - annotationPainter.setAnnotationTypeColor("error", sharedTextColors.getColor(new RGB(255,0,128))); - viewer.addPainter(annotationPainter); - annotationModel.addAnnotationModelListener(annotationPainter); - - // Undo support (maybe not needed in workbench?) - viewer.getTextWidget().addKeyListener(new KeyAdapter() { - @Override - public void keyReleased(KeyEvent e) { - } - @Override - public void keyPressed(KeyEvent e) { - if(e.keyCode=='z'&& e.stateMask == SWT.CTRL) { - viewer.getUndoManager().undo(); - } - else if(e.keyCode=='y'&& e.stateMask == SWT.CTRL) { - viewer.getUndoManager().redo(); - } - } - }); - - // Automatic compilation when text changes - viewer.addTextListener(new ITextListener() { - @Override - public void textChanged(TextEvent event) { - scheduleCompilation(); - } - }); - } - - @Override - public void dispose() { - super.dispose(); - sharedTextColors.dispose(); - } - - @SuppressWarnings("unchecked") - private void removeAnnotations() { - Iterator it = annotationModel.getAnnotationIterator(); - while(it.hasNext()) { - Annotation annotation = it.next(); - annotationModel.removeAnnotation(annotation); - } - } - - private void setAnnotations(Collection messages) { - removeAnnotations(); - for(ErrorMessage message : messages) { - annotationModel.addAnnotation( - new Annotation("error", true, message.getMessage()), - new Position(message.getStart(), message.getStop()-message.getStart()+1)); - } - } - - /** - * Tries to compile current - */ - private void compileSync(String code) { - try { - SCLCompiler.compileExpression(configuration, code); - getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - removeAnnotations(); - } - }); - } catch (final InvalidInputException e) { - getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - setAnnotations(e.getErrors()); - } - }); - } catch(Exception e) { - e.printStackTrace(); - } - } - - Object compilationLock = new Object(); - String codeToBeCompiled; - - private synchronized void scheduleCompilation() { - synchronized(compilationLock) { - if(codeToBeCompiled == null) { - new Thread("SCLTextEditor compilation") { - public void run() { - while(true) { - String code; - // Waits until code has remained unmodified for - // time specified by DELAY_BEFORE_COMPILATION. - synchronized(compilationLock) { - do { - code = codeToBeCompiled; - try { - compilationLock.wait(DELAY_BEFORE_COMPILATION); - } catch (InterruptedException e) { - } - } while(!code.equals(codeToBeCompiled)); - } - - // Does the actual compilation and updates - // annotations. - compileSync(code); - - // If code was not modified during compilation, - // exits the compilation thread and sets - // codeToBeCompiled null to signal inactivity. - synchronized(compilationLock) { - if(code.equals(codeToBeCompiled)) { - codeToBeCompiled = null; - return; - } - } - } - } - }.start(); - } - codeToBeCompiled = viewer.getDocument().get(); - compilationLock.notify(); - } - } - - public String getContent() { - final String[] result = new String[1]; - getDisplay().syncExec(new Runnable() { - @Override - public void run() { - result[0] = viewer.getDocument().get(); - } - }); - return result[0]; - } - - public void setContent(final String content) { - getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (viewer.getTextWidget().isDisposed()) return; - viewer.getDocument().set(content); - } - }); - } - - private Point storedSelectedRange; - - public void storeSelectedRange() { - storedSelectedRange = viewer.getSelectedRange(); - } - - public void restoreSelectedRange() { - if (storedSelectedRange != null) { - viewer.setSelectedRange(storedSelectedRange.x, storedSelectedRange.y); - storedSelectedRange = null; - } - } - -} diff --git a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SharedTextColors.java b/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SharedTextColors.java deleted file mode 100644 index f5c71dc21..000000000 --- a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/SharedTextColors.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.simantics.scl.ui.editor; - -import gnu.trove.map.hash.THashMap; - -import org.eclipse.jface.text.source.ISharedTextColors; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Display; - -final class SharedTextColors implements ISharedTextColors { - - Display display; - THashMap map = new THashMap(); - - public SharedTextColors(Display display) { - this.display = display; - } - - @Override - public Color getColor(RGB rgb) { - Color color = map.get(rgb); - if(color == null) { - color = new Color(display, rgb); - map.put(rgb, color); - } - return color; - } - - @Override - public void dispose() { - for(Color color : map.values()) - color.dispose(); - map.clear(); - } -} \ No newline at end of file diff --git a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/TestTextEditor.java b/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/TestTextEditor.java deleted file mode 100644 index 7f29fbb1a..000000000 --- a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/TestTextEditor.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.simantics.scl.ui.editor; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.simantics.scl.compiler.SCLCompiler; -import org.simantics.scl.compiler.StandardSCLCompilerConfiguration; - -public class TestTextEditor { - - public static void main(String[] args) { - Display display = new Display(); - final Shell shell = new Shell(display); - shell.setText("SCL text widget example"); - shell.setLayout(new FillLayout()); - - SashForm sashForm = new SashForm(shell, SWT.VERTICAL); - - final SCLTextEditor editor = new SCLTextEditor(sashForm, 0, StandardSCLCompilerConfiguration.INSTANCE); - editor.setContent( - "// Difficulty: 0\n" + - "// Expected: [2.0, 3.0, 5.0, 7.0, 11.0, 13.0, 17.0, 19.0]\n\n" + - "// and : [Boolean] -> Boolean\n" + - "and = fold (&&) True\n\n" + - "// isPrime : Integer -> Boolean\n" + - "isPrime p = and (\n" + - " d <- [2 .. sqrt p]\n" + - " [p % d > 0]\n" + - ")\n\n" + - "x <- [2 .. 20]\n" + - "isPrime x\n" + - "[x]" - ); - - final Text resultArea = new Text(sashForm, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); - resultArea.setText("Ctrl-S executes the code."); - resultArea.setEditable(false); - resultArea.setBackground(new Color(shell.getDisplay(), 255, 255, 255)); - resultArea.setFont(new Font(shell.getDisplay(), "Courier New", 10, SWT.NORMAL)); - - sashForm.setWeights(new int[] {5, 1}); - - display.addFilter(SWT.KeyDown, new Listener() { - @Override - public void handleEvent(Event event) { - if(event.keyCode == 's' && event.stateMask == SWT.CTRL) { - final String code = editor.getContent(); - new Thread() { - public void run() { - try { - final String result = SCLCompiler.compileExpression(StandardSCLCompilerConfiguration.INSTANCE, code).execute().toString(); - shell.getDisplay().asyncExec(new Runnable() { - public void run() { - resultArea.setText(result); - } - }); - } catch (Exception e) { - } - } - }.start(); - event.doit = false; - } - } - }); - shell.addKeyListener(new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - System.out.println(e); - } - }); - - shell.open(); - while (!shell.isDisposed ()) { - if (!display.readAndDispatch ()) display.sleep (); - } - display.dispose (); - } - -} diff --git a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/error_tsk.gif b/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/error_tsk.gif deleted file mode 100644 index 9b048d605..000000000 Binary files a/bundles/org.simantics.scl.ui.editor/src/org/simantics/scl/ui/editor/error_tsk.gif and /dev/null differ diff --git a/bundles/org.simantics.spreadsheet.graph/META-INF/MANIFEST.MF b/bundles/org.simantics.spreadsheet.graph/META-INF/MANIFEST.MF index 08fdd9180..8ecef199d 100644 --- a/bundles/org.simantics.spreadsheet.graph/META-INF/MANIFEST.MF +++ b/bundles/org.simantics.spreadsheet.graph/META-INF/MANIFEST.MF @@ -11,7 +11,6 @@ Require-Bundle: org.simantics.layer0.utils, org.simantics.diagram.ontology;bundle-version="1.0.0", org.simantics.structural.ontology;bundle-version="1.0.0", org.simantics.basicexpression;bundle-version="1.0.0", - org.simantics.scl.compiler.dummy;bundle-version="0.1.2", org.simantics.db.layer0;bundle-version="1.1.0", org.simantics.scl.db;bundle-version="0.1.2", org.simantics.scl.runtime;bundle-version="0.1.2", diff --git a/bundles/pom.xml b/bundles/pom.xml index beafd6ec7..bc89d553c 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -182,7 +182,6 @@ org.simantics.scenegraph.ui org.simantics.scl.commands org.simantics.scl.compiler - org.simantics.scl.compiler.dummy org.simantics.scl.data org.simantics.scl.db org.simantics.scl.expressions @@ -190,7 +189,6 @@ org.simantics.scl.reflection org.simantics.scl.runtime org.simantics.scl.ui - org.simantics.scl.ui.editor org.simantics.selectionview org.simantics.selectionview.ontology org.simantics.selectionview.ui.ontology diff --git a/features/org.simantics.browsing.ui.feature/feature.xml b/features/org.simantics.browsing.ui.feature/feature.xml index 39291c7d6..bedbde323 100644 --- a/features/org.simantics.browsing.ui.feature/feature.xml +++ b/features/org.simantics.browsing.ui.feature/feature.xml @@ -160,11 +160,4 @@ This Agreement is governed by the laws of the State of New York and the intellec version="0.0.0" unpack="false"/> - - diff --git a/features/org.simantics.scl.feature/feature.xml b/features/org.simantics.scl.feature/feature.xml index 1ddb06140..5c8f6fd1d 100644 --- a/features/org.simantics.scl.feature/feature.xml +++ b/features/org.simantics.scl.feature/feature.xml @@ -143,20 +143,6 @@ This Agreement is governed by the laws of the State of New York and the intellec version="0.0.0" unpack="false"/> - - - -