Commit 28245255 authored by Simon Barner's avatar Simon Barner
Browse files

- Replace ColorCache (that never implemented a real cache) with anonymous...

- Replace ColorCache (that never implemented a real cache) with anonymous class that forwards to SWTResourceManager
- Avoid infinite recursion introduced to ColorCache in previous commit
refs 2709
parent b9207ffb
CodeSpecificationEditor.java 7afe41a1f3aaa983c223d62a434fb89bec31baa8 RED
CodeSpecificationEditor.java 69b46f91543900be44b8e107c97c5062598625c9 RED
CodeSpecificationEditorBinding.java a0cff3224d8d0755e948188c2480e528c82eb590 GREEN
ComponentArchitectureEditorBinding.java 262e86525dda985d7baaee6a90150d34389b34ca GREEN
ComponentStructureEditor.java 11aee03b8db78a93a7704a8b8240b84a6d192012 GREEN
......
......@@ -15,6 +15,7 @@
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor;
import static java.util.regex.Pattern.compile;
import static org.eclipse.wb.swt.SWTResourceManager.getColor;
import static org.fortiss.af3.component.ui.editor.code.ErrorAnnotation.ERROR_RGB;
import static org.fortiss.af3.component.ui.editor.code.ErrorAnnotation.ERROR_TYPE;
......@@ -35,6 +36,7 @@ import org.eclipse.jface.text.source.AnnotationPainter;
import org.eclipse.jface.text.source.AnnotationRulerColumn;
import org.eclipse.jface.text.source.CompositeRuler;
import org.eclipse.jface.text.source.IAnnotationAccess;
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.SourceViewerConfiguration;
......@@ -45,8 +47,10 @@ import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
......@@ -56,13 +60,13 @@ import org.eclipse.ui.IActionBars;
import org.eclipse.ui.actions.TextStyledTextActionHandler;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.wb.swt.SWTResourceManager;
import org.fortiss.af3.component.model.behavior.code.CodePackage;
import org.fortiss.af3.component.model.behavior.code.CodeSpecification;
import org.fortiss.af3.component.ui.editor.code.AnnotationConfiguration;
import org.fortiss.af3.component.ui.editor.code.AnnotationHover;
import org.fortiss.af3.component.ui.editor.code.AnnotationMarkerAccess;
import org.fortiss.af3.component.ui.editor.code.CodeEditorConfiguration;
import org.fortiss.af3.component.ui.editor.code.ColorCache;
import org.fortiss.af3.component.ui.editor.code.ErrorAnnotation;
import org.fortiss.af3.component.ui.editor.code.UndoRedo;
import org.fortiss.af3.expression.language.Compiler;
......@@ -105,7 +109,7 @@ public class CodeSpecificationEditor extends EditorBase<CodeSpecification> {
private final ITypeSystemCompiler compiler = TypeSystemHandler.INSTANCE.getTypeSystemCompiler();
/** Stores the pattern applied to the error messages. */
private final Pattern pattern = Pattern.compile("line (\\d*):(\\d*) (.*)");
private final Pattern pattern = compile("line (\\d*):(\\d*) (.*)");
/** {@inheritDoc} */
@Override
......@@ -130,12 +134,23 @@ public class CodeSpecificationEditor extends EditorBase<CodeSpecification> {
private void createCodeEditor(Composite parent) {
IAnnotationAccess fAnnotationAccess = new AnnotationMarkerAccess();
// necessary magic
ColorCache cc = new ColorCache();
// rulers
CompositeRuler fCompositeRuler = new CompositeRuler();
OverviewRuler fOverviewRuler = new OverviewRuler(fAnnotationAccess, 12, cc);
OverviewRuler fOverviewRuler =
new OverviewRuler(fAnnotationAccess, 12, new ISharedTextColors() {
/** {@inheritDoc} */
@Override
public Color getColor(RGB rgb) {
// Cannot use static import to disambiguate from local method name
return SWTResourceManager.getColor(rgb);
}
/** {@inheritDoc} */
@Override
public void dispose() {
// Nothing to do
}
});
AnnotationRulerColumn annotationRuler =
new AnnotationRulerColumn(annotationModel, 16, fAnnotationAccess);
fCompositeRuler.setModel(annotationModel);
......
......@@ -2,6 +2,5 @@ AnnotationConfiguration.java 088cabbbcb9229685e1ffb2dcc34b83e05c0461a GREEN
AnnotationHover.java 358cf5c6da186c300662c5132bc0e8c6e20b7ca8 GREEN
AnnotationMarkerAccess.java f0fdeb10d89a3611249f5334ea76e518baca710f GREEN
CodeEditorConfiguration.java 33a6316f9a589745b3c0b66fa3bada5191368156 RED
ColorCache.java a94bcf443a540c7814341ed16fc116d4e1ab26b3 YELLOW
ErrorAnnotation.java a7ec0ad49bb7965c79e99d15844d8a3377572025 GREEN
UndoRedo.java 7009ef378aafc33f1fb8e4c94227e9104ded7ce3 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2012 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.component.ui.editor.code;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
/**
* Simple color cache used for error highlighting.
*
* @author doebber
*/
public class ColorCache implements ISharedTextColors {
/** {@inheritDoc} */
@Override
public Color getColor(RGB rgb) {
return getColor(rgb);
}
/** {@inheritDoc} */
@Override
public void dispose() {
// nothing to do
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment