[Exmmt-commit] SF.net SVN: exmmt: [14] net.sourceforge.exmmt
Status: Inactive
Brought to you by:
lgrammel
From: <lgr...@us...> - 2006-05-17 13:26:38
|
Revision: 14 Author: lgrammel Date: 2006-05-17 06:26:08 -0700 (Wed, 17 May 2006) ViewCVS: http://svn.sourceforge.net/exmmt/?rev=14&view=rev Log Message: ----------- 0.0.1 Added Paths: ----------- net.sourceforge.exmmt/net.sourceforge.exmmt/ net.sourceforge.exmmt/net.sourceforge.exmmt/.classpath net.sourceforge.exmmt/net.sourceforge.exmmt/META-INF/MANIFEST.MF net.sourceforge.exmmt/net.sourceforge.exmmt/about.html net.sourceforge.exmmt/net.sourceforge.exmmt/build.properties net.sourceforge.exmmt/net.sourceforge.exmmt/lib/ net.sourceforge.exmmt/net.sourceforge.exmmt/license/ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java Removed Paths: ------------- net.sourceforge.exmmt/net.sourceforge.exmmt/.classpath net.sourceforge.exmmt/net.sourceforge.exmmt/META-INF/MANIFEST.MF net.sourceforge.exmmt/net.sourceforge.exmmt/build.properties net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java Copied: net.sourceforge.exmmt/net.sourceforge.exmmt (from rev 6, net.sourceforge.exmmt) Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/.classpath =================================================================== --- net.sourceforge.exmmt/.classpath 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/.classpath 2006-05-17 13:26:08 UTC (rev 14) @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src/java"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="output" path="bin"/> -</classpath> Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/.classpath (from rev 10, net.sourceforge.exmmt/.classpath) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/.classpath (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/.classpath 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src/java"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="lib" path="lib/jaxen-core.jar"/> + <classpathentry kind="lib" path="lib/jaxen-jdom.jar"/> + <classpathentry kind="lib" path="lib/org.jdom.jar"/> + <classpathentry kind="lib" path="lib/saxpath.jar"/> + <classpathentry kind="output" path="bin"/> +</classpath> Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/META-INF/MANIFEST.MF =================================================================== --- net.sourceforge.exmmt/META-INF/MANIFEST.MF 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/META-INF/MANIFEST.MF 2006-05-17 13:26:08 UTC (rev 14) @@ -1,17 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Eclipse XML Meta-Modeling Tools -Bundle-SymbolicName: net.sourceforge.exmmt;singleton:=true -Bundle-Version: 0.0.1 -Bundle-Vendor: exmmt.sourceforge.net project -Bundle-Localization: plugin -Bundle-ClassPath: org.nomadpim.ide.jar -Eclipse-LazyStart: true -Require-Bundle: org.eclipse.ui, - org.eclipse.core.runtime, - org.eclipse.ui.views, - org.eclipse.ui.editors, - org.eclipse.ui.ide, - org.eclipse.core.resources, - org.jdom -Export-Package: net.sourceforge.exmmt Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/META-INF/MANIFEST.MF (from rev 10, net.sourceforge.exmmt/META-INF/MANIFEST.MF) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/META-INF/MANIFEST.MF (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/META-INF/MANIFEST.MF 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Eclipse XML Meta-Modeling Tools +Bundle-SymbolicName: net.sourceforge.exmmt;singleton:=true +Bundle-Version: 0.0.1 +Bundle-Vendor: exmmt.sourceforge.net project +Bundle-Localization: plugin +Bundle-ClassPath: net.sourceforge.exmmt.jar, + lib/jaxen-core.jar, + lib/jaxen-jdom.jar, + lib/org.jdom.jar, + lib/saxpath.jar +Eclipse-LazyStart: true +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.ui.views, + org.eclipse.ui.editors, + org.eclipse.ui.ide, + org.eclipse.core.resources +Export-Package: net.sourceforge.exmmt Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/about.html (from rev 12, net.sourceforge.exmmt/about.html) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/about.html (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/about.html 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,17 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> +<html> +<head> +<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"> +<title>Plugin License Information</title> +</head> + +<body lang="EN-US" link=blue vlink=purple> +<h2>Plugin License Information</h2> + +This plugin is available under the terms of <a href="license/net.sourceforge.exmmt.html">CPL</a>. + +The JDOM library contained in this plugin is available under the terms +of the <a href="license/jdom.txt">JDOM license</a>. + +</body> +</html> \ No newline at end of file Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/build.properties =================================================================== --- net.sourceforge.exmmt/build.properties 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/build.properties 2006-05-17 13:26:08 UTC (rev 14) @@ -1,10 +0,0 @@ -bin.includes = META-INF/,\ - org.nomadpim.ide.jar,\ - plugin.xml,\ - resources/ -jars.compile.order = org.nomadpim.ide.jar -source.org.nomadpim.ide.jar = src/java/ -output.org.nomadpim.ide.jar = bin/ -src.includes = plugin.xml,\ - src/,\ - resources/ Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/build.properties (from rev 13, net.sourceforge.exmmt/build.properties) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/build.properties (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/build.properties 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,19 @@ +bin.includes = META-INF/,\ + plugin.xml,\ + resources/,\ + net.sourceforge.exmmt.jar,\ + lib/,\ + about.html,\ + license/,\ + src/mappings/ +jars.compile.order = net.sourceforge.exmmt.jar +src.includes = plugin.xml,\ + src/,\ + resources/,\ + lib/,\ + META-INF/,\ + about.html,\ + license/ +source.net.sourceforge.exmmt.jar = src/java/ +output.net.sourceforge.exmmt.jar = bin/ +src.excludes = src/java/ Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/lib (from rev 10, net.sourceforge.exmmt/lib) Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/license (from rev 12, net.sourceforge.exmmt/license) Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java =================================================================== --- net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java 2006-05-17 13:26:08 UTC (rev 14) @@ -1,56 +0,0 @@ -/* $RCSfile$ - * ----------------------------------------------------------------------------- - * - * Copyright (C) Lars Grammel and others. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Common Public License v1.0 which accompanies - * this distribution, and is available at - * - * http://www.eclipse.org/legal/cpl-v10.html - * - */ -package net.sourceforge.exmmt; - -import java.util.ArrayList; -import java.util.List; - -public class Area implements IModelElement { - - private List<IModelElement> children = new ArrayList<IModelElement>(); - - private final int indent; - - public Area(int indent, IModelElement... children) { - assert indent >= 0; - - this.indent = indent; - - for (IModelElement element : children) { - add(element); - } - } - - public void add(IModelElement element) { - this.children.add(element); - } - - public void accept(IModelElementVisitor visitor) { - visitor.areaStart(this); - - for (IModelElement child : children) { - child.accept(visitor); - } - - visitor.areaEnd(this); - } - - public void insertBefore(AdditionPoint point, IModelElement element) { - children.add(children.indexOf(point), element); - } - - public int getIndent() { - return indent; - } - -} Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java (from rev 11, net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/Area.java 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,56 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import java.util.ArrayList; +import java.util.List; + +public class Area implements IModelElement { + + private List<IModelElement> children = new ArrayList<IModelElement>(); + + private final int indent; + + public Area(int indent, IModelElement... children) { + assert indent >= 0; + + this.indent = indent; + + for (IModelElement element : children) { + add(element); + } + } + + public void add(IModelElement element) { + this.children.add(element); + } + + public void accept(IModelElementVisitor visitor) { + visitor.areaStart(this); + + for (IModelElement child : children) { + child.accept(visitor); + } + + visitor.areaEnd(this); + } + + public void insertBefore(AdditionPoint point, IModelElement element) { + children.add(children.indexOf(point), element); + } + + public int getIndent() { + return indent; + } + +} Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java =================================================================== --- net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java 2006-05-17 13:26:08 UTC (rev 14) @@ -1,149 +0,0 @@ -/* $RCSfile$ - * ----------------------------------------------------------------------------- - * - * Copyright (C) Lars Grammel and others. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Common Public License v1.0 which accompanies - * this distribution, and is available at - * - * http://www.eclipse.org/legal/cpl-v10.html - * - */ -package net.sourceforge.exmmt; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.graphics.TextLayout; -import org.eclipse.swt.widgets.Caret; - -public final class DisplayVisitor implements IModelElementVisitor { - - private final TextLayout layout; - - private final GC gc; - - private int xPosition = 0; - - private int yPosition = 0; - - private Color color; - - private Color color2; - - private Color color3; - - private IFocusChecker focusChecker; - - private Caret caret; - - private List<Area> areaStack = new ArrayList<Area>(); - - public DisplayVisitor(GC gc, Color color, Color color2, Color color3, - IFocusChecker focusChecker, Caret caret) { - assert gc != null; - - this.caret = caret; - this.focusChecker = focusChecker; - this.color = color; - this.color2 = color2; - this.color3 = color3; - this.gc = gc; - this.layout = new TextLayout(gc.getDevice()); - - layout.setFont(gc.getFont()); - } - - public void areaEnd(Area area) { - areaStack.remove(0); - } - - public void areaStart(Area area) { - areaStack.add(0, area); - } - - public void dispose() { - layout.dispose(); - } - - public void lineEnd(Line line) { - yPosition += layout.getBounds().height; - } - - public void lineStart(Line line) { - int sum = 0; - for (Area area : areaStack) { - sum += area.getIndent(); - } - - xPosition = sum; - } - - public void visit(AdditionPoint point) { - boolean hasFocus = focusChecker.hasFocus(point); - if (hasFocus) { - gc.setBackground(color3); - } else { - gc.setBackground(color2); - } - - gc.drawText("+", xPosition, yPosition); - layout.setText("+"); - Rectangle bounds = layout.getBounds(); - - xPosition = 0; - yPosition += layout.getBounds().height; - - if (hasFocus) { - caret.setVisible(false); - } - - gc.setBackground(color); - } - - public void visit(FixedLiteral literal) { - visit((Literal) literal); - } - - public void visit(Literal literal) { - gc.drawText(literal.getValue(), xPosition, yPosition); - layout.setText(literal.getValue()); - Rectangle bounds = layout.getBounds(); - - bounds.x = xPosition; - bounds.y = yPosition; - - literal.setBounds(bounds); - - xPosition += bounds.width; - } - - public void visit(VariableLiteral literal) { - boolean hasFocus = focusChecker.hasFocus(literal); - if (hasFocus) { - gc.setBackground(color3); - } else { - gc.setBackground(color2); - } - - visit((Literal) literal); - - if (hasFocus) { - caret.setSize(2, literal.getBounds().height); - caret.setVisible(true); - - String part = literal.getValue().substring(0, literal.getCaretPosition()); - layout.setText(part); - Rectangle bounds = layout.getBounds(); - - caret.setLocation(literal.getBounds().x + bounds.width, literal.getBounds().y); - } - - gc.setBackground(color); - } - -} \ No newline at end of file Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java (from rev 11, net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/DisplayVisitor.java 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,149 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.graphics.TextLayout; +import org.eclipse.swt.widgets.Caret; + +public final class DisplayVisitor implements IModelElementVisitor { + + private final TextLayout layout; + + private final GC gc; + + private int xPosition = 0; + + private int yPosition = 0; + + private Color color; + + private Color color2; + + private Color color3; + + private IFocusChecker focusChecker; + + private Caret caret; + + private List<Area> areaStack = new ArrayList<Area>(); + + public DisplayVisitor(GC gc, Color color, Color color2, Color color3, + IFocusChecker focusChecker, Caret caret) { + assert gc != null; + + this.caret = caret; + this.focusChecker = focusChecker; + this.color = color; + this.color2 = color2; + this.color3 = color3; + this.gc = gc; + this.layout = new TextLayout(gc.getDevice()); + + layout.setFont(gc.getFont()); + } + + public void areaEnd(Area area) { + areaStack.remove(0); + } + + public void areaStart(Area area) { + areaStack.add(0, area); + } + + public void dispose() { + layout.dispose(); + } + + public void lineEnd(Line line) { + yPosition += layout.getBounds().height; + } + + public void lineStart(Line line) { + int sum = 0; + for (Area area : areaStack) { + sum += area.getIndent(); + } + + xPosition = sum; + } + + public void visit(AdditionPoint point) { + boolean hasFocus = focusChecker.hasFocus(point); + if (hasFocus) { + gc.setBackground(color3); + } else { + gc.setBackground(color2); + } + + gc.drawText("+", xPosition, yPosition); + layout.setText("+"); + Rectangle bounds = layout.getBounds(); + + xPosition = 0; + yPosition += layout.getBounds().height; + + if (hasFocus) { + caret.setVisible(false); + } + + gc.setBackground(color); + } + + public void visit(FixedLiteral literal) { + visit((Literal) literal); + } + + public void visit(Literal literal) { + gc.drawText(literal.getValue(), xPosition, yPosition); + layout.setText(literal.getValue()); + Rectangle bounds = layout.getBounds(); + + bounds.x = xPosition; + bounds.y = yPosition; + + literal.setBounds(bounds); + + xPosition += bounds.width; + } + + public void visit(VariableLiteral literal) { + boolean hasFocus = focusChecker.hasFocus(literal); + if (hasFocus) { + gc.setBackground(color3); + } else { + gc.setBackground(color2); + } + + visit((Literal) literal); + + if (hasFocus) { + caret.setSize(2, literal.getBounds().height); + caret.setVisible(true); + + String part = literal.getValue().substring(0, literal.getCaretPosition()); + layout.setText(part); + Rectangle bounds = layout.getBounds(); + + caret.setLocation(literal.getBounds().x + bounds.width, literal.getBounds().y); + } + + gc.setBackground(color); + } + +} \ No newline at end of file Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java =================================================================== --- net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java 2006-05-17 13:26:08 UTC (rev 14) @@ -1,21 +0,0 @@ -/* $RCSfile$ - * ----------------------------------------------------------------------------- - * - * Copyright (C) Lars Grammel and others. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Common Public License v1.0 which accompanies - * this distribution, and is available at - * - * http://www.eclipse.org/legal/cpl-v10.html - * - */ -package net.sourceforge.exmmt; - -import org.jdom.Element; - -public interface IMetaModelElement { - - IModelElement create(Element element, IModelElement parent); - -} Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java (from rev 11, net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/IMetaModelElement.java 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,21 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import org.jdom.Element; + +public interface IMetaModelElement { + + IModelElement create(Element element, IModelElement parent); + +} Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java =================================================================== --- net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java 2006-05-17 13:26:08 UTC (rev 14) @@ -1,331 +0,0 @@ -/* $HeadURL$ - * ----------------------------------------------------------------------------- - * - * Copyright (C) Lars Grammel and others. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Common Public License v1.0 which accompanies - * this distribution, and is available at - * - * http://www.eclipse.org/legal/cpl-v10.html - * - */ -package net.sourceforge.exmmt; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.EditorPart; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; -import org.jdom.output.Format; -import org.jdom.output.XMLOutputter; - -public class ModelEditor extends EditorPart { - - final static boolean IS_CARBON, IS_GTK, IS_MOTIF; - - // TODO move / change - static { - String platform = SWT.getPlatform(); - IS_CARBON = "carbon".equals(platform); - IS_GTK = "gtk".equals(platform); - IS_MOTIF = "motif".equals(platform); - } - - IModelElement selectedLiteral; - - IModelElement rootArea; - - private Canvas control; - - private Document document; - - private boolean dirty = false; - - private IFile file; - - private Map<String, IMetaModelElement> metaModelMap; - - @Override - public void createPartControl(Composite parent) { - control = new ModelText(this, parent, SWT.NONE); - } - - @Override - public void dispose() { - if (control != null) { - control.dispose(); - } - - super.dispose(); - } - - @Override - public void doSave(IProgressMonitor monitor) { - try { - // write the document back - XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - outputter.output(document, out); - - out.flush(); - out.close(); - - ByteArrayInputStream in = new ByteArrayInputStream(out - .toByteArray()); - - file.setContents(in, true, true, null); - - dirty = false; - firePropertyChange(PROP_DIRTY); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Override - public void doSaveAs() { - } - - public Document getMappingFile() throws JDOMException, IOException { - String mappingFile = document.getRootElement().getAttributeValue( - "file", document.getRootElement().getNamespace("mapping")); - - System.out.println(mappingFile); - - IPath projectLocation = file.getProject().getLocation(); - IPath path2 = projectLocation.append(file.getProjectRelativePath() - .removeLastSegments(1)); - IPath path = path2.append(mappingFile); - - SAXBuilder builder = new SAXBuilder(); - return builder.build(path.toFile()); - } - - @Override - public void init(IEditorSite site, IEditorInput input) - throws PartInitException { - setSite(site); - setInput(input); - - file = (IFile) input.getAdapter(IFile.class); - try { - document = new SAXBuilder().build(file.getContents()); - System.out.println(document); - } catch (JDOMException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - createMetaModelMap(); - rootArea = metaModelMap.get(document.getRootElement().getName()) - .create(document.getRootElement(), null); - selectedLiteral = getNavigationElements().get(0); - } - - @Override - public boolean isDirty() { - return dirty; - } - - @Override - public boolean isSaveAsAllowed() { - return false; - } - - @Override - public void setFocus() { - } - - void handleKeyDown(Event event) { - System.out.println(event); - - // TODO refactor - if (((event.keyCode == SWT.TAB) && ((event.stateMask & SWT.SHIFT) == SWT.SHIFT)) - || event.keyCode == SWT.ARROW_UP) { - int index = getNavigationElements().indexOf(selectedLiteral) - 1; - if (index < 0) { - index = getNavigationElements().size() - 1; - } - selectedLiteral = getNavigationElements().get(index); - control.redraw(); - } else if (((event.keyCode == SWT.TAB) && !((event.stateMask & SWT.SHIFT) == SWT.SHIFT)) - || event.keyCode == SWT.ARROW_DOWN) { - int index = getNavigationElements().indexOf(selectedLiteral) + 1; - if (index >= getNavigationElements().size()) { - index = 0; - } - selectedLiteral = getNavigationElements().get(index); - control.redraw(); - } else if (event.keyCode == SWT.ARROW_RIGHT - && selectedLiteral instanceof VariableLiteral) { - - VariableLiteral literal = (VariableLiteral) selectedLiteral; - - literal.setCaretPosition(literal.getCaretPosition() + 1); - control.redraw(); - } else if (event.keyCode == SWT.ARROW_LEFT - && selectedLiteral instanceof VariableLiteral) { - VariableLiteral literal = (VariableLiteral) selectedLiteral; - literal.setCaretPosition(literal.getCaretPosition() - 1); - control.redraw(); - } else if (event.keyCode == SWT.CR - && selectedLiteral instanceof AdditionPoint) { - AdditionPoint literal = (AdditionPoint) selectedLiteral; - literal.execute(); - control.redraw(); - } else if (event.keyCode == SWT.DEL - && selectedLiteral instanceof VariableLiteral) { - VariableLiteral literal = (VariableLiteral) selectedLiteral; - if (literal.getCaretPosition() < literal.getValue().length()) { - StringBuffer value = new StringBuffer(literal.getValue()); - value.deleteCharAt(literal.getCaretPosition()); - literal.setValue(value.toString()); - changed(); - control.redraw(); - } - } else if (event.keyCode == SWT.BS - && selectedLiteral instanceof VariableLiteral) { - VariableLiteral literal = (VariableLiteral) selectedLiteral; - if (literal.getCaretPosition() > 0) { - StringBuffer value = new StringBuffer(literal.getValue()); - value.deleteCharAt(literal.getCaretPosition() - 1); - literal.setValue(value.toString()); - literal.setCaretPosition(literal.getCaretPosition() - 1); - changed(); - control.redraw(); - } - } else if (isValidCharacter(event.stateMask, event.character) - && selectedLiteral instanceof VariableLiteral) { - VariableLiteral literal = (VariableLiteral) selectedLiteral; - StringBuffer value = new StringBuffer(literal.getValue()); - value.insert(literal.getCaretPosition(), event.character); - literal.setValue(value.toString()); - literal.setCaretPosition(literal.getCaretPosition() + 1); - changed(); - control.redraw(); - } - } - - private void changed() { - dirty = true; - firePropertyChange(PROP_DIRTY); - } - - private void createMetaModelMap() { - metaModelMap = new HashMap<String, IMetaModelElement>(); - Map<String, IMetaMetaModelElement> metaMetaModelMap = createMetaMetaModelMap(); - - try { - Document mappingFile = getMappingFile(); - - Element rootElement = mappingFile.getRootElement(); - List<Element> mappings = rootElement.getChildren("mapping"); - - for (Element mappingElement : mappings) { - Element configuration = (Element) mappingElement.getChildren() - .get(0); - - IMetaMetaModelElement metaMetaModelElement = metaMetaModelMap - .get(configuration.getName()); - IMetaModelElement metaModelElement = metaMetaModelElement - .create(configuration, metaMetaModelMap, metaModelMap); - - metaModelMap.put(mappingElement.getAttributeValue("select"), - metaModelElement); - } - - } catch (JDOMException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - - private Map<String, IMetaMetaModelElement> createMetaMetaModelMap() { - Map<String, IMetaMetaModelElement> metaMappingMap = new HashMap<String, IMetaMetaModelElement>(); - - metaMappingMap.put("area", new AreaFactoryFactory()); - metaMappingMap.put("line", new LineFactoryFactory()); - metaMappingMap.put("edit", new VariableFactoryFactory()); - metaMappingMap.put("literal", new FixedLiteralFactoryFactory()); - metaMappingMap.put("apply-mappings", new ApplyMappingsFactoryFactory()); - metaMappingMap.put("addition-point", new AdditionPointFactoryFactory()); - - return metaMappingMap; - } - - // TODO performance: use caching instead of recalculation - private List<IModelElement> getNavigationElements() { - NavigationElementSearcher visitor = new NavigationElementSearcher(); - - rootArea.accept(visitor); - - return visitor.getNavigationElements(); - } - - private boolean isValidCharacter(int stateMask, char character) { - boolean ignore = false; - - if (IS_CARBON) { - // Ignore accelerator key combinations (we do not want to - // insert a character in the text in this instance). Do not - // ignore COMMAND+ALT combinations since that key sequence - // produces characters on the mac. - ignore = (stateMask ^ SWT.COMMAND) == 0 - || (stateMask ^ (SWT.COMMAND | SWT.SHIFT)) == 0; - } else if (IS_MOTIF) { - // Ignore accelerator key combinations (we do not want to - // insert a character in the text in this instance). Do not - // ignore ALT combinations since this key sequence - // produces characters on motif. - ignore = (stateMask ^ SWT.CTRL) == 0 - || (stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0; - } else { - // Ignore accelerator key combinations (we do not want to - // insert a character in the text in this instance). Don't - // ignore CTRL+ALT combinations since that is the Alt Gr - // key on some keyboards. See bug 20953. - ignore = (stateMask ^ SWT.ALT) == 0 || (stateMask ^ SWT.CTRL) == 0 - || (stateMask ^ (SWT.ALT | SWT.SHIFT)) == 0 - || (stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0; - } - boolean isCharacter = !ignore && character > 31 && character != SWT.DEL; - // -ignore anything below SPACE except for line delimiter keys and tab. - // -ignore DEL - return isCharacter; - } -} Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java (from rev 9, net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelEditor.java 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,317 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorPart; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; + +public class ModelEditor extends EditorPart { + + final static boolean IS_CARBON, IS_GTK, IS_MOTIF; + + // TODO move / change + static { + String platform = SWT.getPlatform(); + IS_CARBON = "carbon".equals(platform); + IS_GTK = "gtk".equals(platform); + IS_MOTIF = "motif".equals(platform); + } + + IModelElement selectedLiteral; + + IModelElement rootArea; + + private Canvas control; + + private Document document; + + private boolean dirty = false; + + private IFile file; + + private Map<String, IMetaModelElement> metaModelMap; + + @Override + public void createPartControl(Composite parent) { + control = new ModelText(this, parent, SWT.NONE); + } + + @Override + public void dispose() { + if (control != null) { + control.dispose(); + } + + super.dispose(); + } + + @Override + public void doSave(IProgressMonitor monitor) { + try { + // write the document back + XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + outputter.output(document, out); + + out.flush(); + out.close(); + + ByteArrayInputStream in = new ByteArrayInputStream(out + .toByteArray()); + + file.setContents(in, true, true, null); + + dirty = false; + firePropertyChange(PROP_DIRTY); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void doSaveAs() { + } + + public Document getMappingFile() throws JDOMException, IOException { + String mappingFile = document.getRootElement().getAttributeValue( + "file", document.getRootElement().getNamespace("mapping")); + + System.out.println(mappingFile); + + IPath projectLocation = file.getProject().getLocation(); + IPath path2 = projectLocation.append(file.getProjectRelativePath() + .removeLastSegments(1)); + IPath path = path2.append(mappingFile); + + SAXBuilder builder = new SAXBuilder(); + return builder.build(path.toFile()); + } + + @Override + public void init(IEditorSite site, IEditorInput input) + throws PartInitException { + setSite(site); + setInput(input); + + file = (IFile) input.getAdapter(IFile.class); + try { + document = new SAXBuilder().build(file.getContents()); + System.out.println(document); + } catch (JDOMException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + createMetaModelMap(); + rootArea = metaModelMap.get(document.getRootElement().getName()) + .create(document.getRootElement(), null); + selectedLiteral = getNavigationElements().get(0); + } + + @Override + public boolean isDirty() { + return dirty; + } + + @Override + public boolean isSaveAsAllowed() { + return false; + } + + @Override + public void setFocus() { + } + + void handleKeyDown(Event event) { + System.out.println(event); + + // TODO refactor + if (((event.keyCode == SWT.TAB) && ((event.stateMask & SWT.SHIFT) == SWT.SHIFT)) + || event.keyCode == SWT.ARROW_UP) { + int index = getNavigationElements().indexOf(selectedLiteral) - 1; + if (index < 0) { + index = getNavigationElements().size() - 1; + } + selectedLiteral = getNavigationElements().get(index); + control.redraw(); + } else if (((event.keyCode == SWT.TAB) && !((event.stateMask & SWT.SHIFT) == SWT.SHIFT)) + || event.keyCode == SWT.ARROW_DOWN) { + int index = getNavigationElements().indexOf(selectedLiteral) + 1; + if (index >= getNavigationElements().size()) { + index = 0; + } + selectedLiteral = getNavigationElements().get(index); + control.redraw(); + } else if (selectedLiteral instanceof VariableLiteral) { + VariableLiteral literal = (VariableLiteral) selectedLiteral; + if (event.keyCode == SWT.ARROW_RIGHT) { + literal.setCaretPosition(literal.getCaretPosition() + 1); + } else if (event.keyCode == SWT.ARROW_LEFT) { + literal.setCaretPosition(literal.getCaretPosition() - 1); + } else if (event.keyCode == SWT.DEL + && (literal.getCaretPosition() < literal.getValue() + .length())) { + StringBuffer value = new StringBuffer(literal.getValue()); + value.deleteCharAt(literal.getCaretPosition()); + literal.setValue(value.toString()); + changed(); + } else if (event.keyCode == SWT.BS + && (literal.getCaretPosition() > 0)) { + StringBuffer value = new StringBuffer(literal.getValue()); + value.deleteCharAt(literal.getCaretPosition() - 1); + literal.setValue(value.toString()); + literal.setCaretPosition(literal.getCaretPosition() - 1); + changed(); + } else if (isValidCharacter(event.stateMask, event.character)) { + StringBuffer value = new StringBuffer(literal.getValue()); + value.insert(literal.getCaretPosition(), event.character); + literal.setValue(value.toString()); + literal.setCaretPosition(literal.getCaretPosition() + 1); + changed(); + } + control.redraw(); + } else if (event.keyCode == SWT.CR + && selectedLiteral instanceof AdditionPoint) { + AdditionPoint literal = (AdditionPoint) selectedLiteral; + literal.execute(); + control.redraw(); + } + } + + private void changed() { + dirty = true; + firePropertyChange(PROP_DIRTY); + } + + private void createMetaModelMap() { + metaModelMap = new HashMap<String, IMetaModelElement>(); + Map<String, IMetaMetaModelElement> metaMetaModelMap = createMetaMetaModelMap(); + + try { + Document mappingFile = getMappingFile(); + + Element rootElement = mappingFile.getRootElement(); + List<Element> mappings = rootElement.getChildren("mapping"); + + for (Element mappingElement : mappings) { + Element configuration = (Element) mappingElement.getChildren() + .get(0); + + IMetaMetaModelElement metaMetaModelElement = metaMetaModelMap + .get(configuration.getName()); + IMetaModelElement metaModelElement = metaMetaModelElement + .create(configuration, metaMetaModelMap, metaModelMap); + + metaModelMap.put(mappingElement.getAttributeValue("select"), + metaModelElement); + } + + } catch (JDOMException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private Map<String, IMetaMetaModelElement> createMetaMetaModelMap() { + Map<String, IMetaMetaModelElement> metaMappingMap = new HashMap<String, IMetaMetaModelElement>(); + + metaMappingMap.put("area", new AreaFactoryFactory()); + metaMappingMap.put("line", new LineFactoryFactory()); + metaMappingMap.put("edit", new VariableFactoryFactory()); + metaMappingMap.put("literal", new FixedLiteralFactoryFactory()); + metaMappingMap.put("apply-mappings", new ApplyMappingsFactoryFactory()); + metaMappingMap.put("addition-point", new AdditionPointFactoryFactory()); + + return metaMappingMap; + } + + // TODO performance: use caching instead of recalculation + private List<IModelElement> getNavigationElements() { + NavigationElementSearcher visitor = new NavigationElementSearcher(); + + rootArea.accept(visitor); + + return visitor.getNavigationElements(); + } + + private boolean isValidCharacter(int stateMask, char character) { + boolean ignore = false; + + if (IS_CARBON) { + // Ignore accelerator key combinations (we do not want to + // insert a character in the text in this instance). Do not + // ignore COMMAND+ALT combinations since that key sequence + // produces characters on the mac. + ignore = (stateMask ^ SWT.COMMAND) == 0 + || (stateMask ^ (SWT.COMMAND | SWT.SHIFT)) == 0; + } else if (IS_MOTIF) { + // Ignore accelerator key combinations (we do not want to + // insert a character in the text in this instance). Do not + // ignore ALT combinations since this key sequence + // produces characters on motif. + ignore = (stateMask ^ SWT.CTRL) == 0 + || (stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0; + } else { + // Ignore accelerator key combinations (we do not want to + // insert a character in the text in this instance). Don't + // ignore CTRL+ALT combinations since that is the Alt Gr + // key on some keyboards. See bug 20953. + ignore = (stateMask ^ SWT.ALT) == 0 || (stateMask ^ SWT.CTRL) == 0 + || (stateMask ^ (SWT.ALT | SWT.SHIFT)) == 0 + || (stateMask ^ (SWT.CTRL | SWT.SHIFT)) == 0; + } + boolean isCharacter = !ignore && character > 31 && character != SWT.DEL; + // -ignore anything below SPACE except for line delimiter keys and tab. + // -ignore DEL + return isCharacter; + } +} Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java =================================================================== --- net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java 2006-05-17 13:26:08 UTC (rev 14) @@ -1,93 +0,0 @@ -/* $RCSfile$ - * ----------------------------------------------------------------------------- - * - * Copyright (C) Lars Grammel and others. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Common Public License v1.0 which accompanies - * this distribution, and is available at - * - * http://www.eclipse.org/legal/cpl-v10.html - * - */ -package net.sourceforge.exmmt; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Caret; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - -public class ModelText extends Canvas { - - /** - * - */ - private final ModelEditor editor; - - private Listener listener; - - private Caret caret; - - public ModelText(ModelEditor editor, Composite parent, int style) { - super(parent, style); - this.editor = editor; - - listener = new Listener() { - public void handleEvent(Event event) { - switch (event.type) { - case SWT.Paint: - handlePaint(event); - break; - case SWT.KeyDown: - ModelText.this.editor.handleKeyDown(event); - break; - } - } - - }; - addListener(SWT.Paint, listener); - addListener(SWT.KeyDown, listener); - - caret = new Caret(this, SWT.NULL); - setCaret(caret); - } - - public void dispose() { - caret.dispose(); - super.dispose(); - } - - void handlePaint(Event event) { - System.out.println("handlePaint"); - GC gc = event.gc; - - Color color = new Color(gc.getDevice(), new RGB(255, 255, 255)); - Color color2 = new Color(gc.getDevice(), new RGB(200, 255, 255)); - Color color3 = new Color(gc.getDevice(), new RGB(255, 200, 200)); - gc.setBackground(color); - drawBackground(gc, getClientArea().x, getClientArea().y, - getClientArea().width, getClientArea().height); - - DisplayVisitor visitor = new DisplayVisitor(gc, color, color2, - color3, new IFocusChecker() { - - public boolean hasFocus(IModelElement l) { - return l == ModelText.this.editor.selectedLiteral; - } - - }, caret); - - this.editor.rootArea.accept(visitor); - - color.dispose(); - color2.dispose(); - color3.dispose(); - visitor.dispose(); - } - -} \ No newline at end of file Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java (from rev 11, net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/ModelText.java 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,93 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Caret; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +public class ModelText extends Canvas { + + /** + * + */ + private final ModelEditor editor; + + private Listener listener; + + private Caret caret; + + public ModelText(ModelEditor editor, Composite parent, int style) { + super(parent, style); + this.editor = editor; + + listener = new Listener() { + public void handleEvent(Event event) { + switch (event.type) { + case SWT.Paint: + handlePaint(event); + break; + case SWT.KeyDown: + ModelText.this.editor.handleKeyDown(event); + break; + } + } + + }; + addListener(SWT.Paint, listener); + addListener(SWT.KeyDown, listener); + + caret = new Caret(this, SWT.NULL); + setCaret(caret); + } + + public void dispose() { + caret.dispose(); + super.dispose(); + } + + void handlePaint(Event event) { + System.out.println("handlePaint"); + GC gc = event.gc; + + Color color = new Color(gc.getDevice(), new RGB(255, 255, 255)); + Color color2 = new Color(gc.getDevice(), new RGB(200, 255, 255)); + Color color3 = new Color(gc.getDevice(), new RGB(255, 200, 200)); + gc.setBackground(color); + drawBackground(gc, getClientArea().x, getClientArea().y, + getClientArea().width, getClientArea().height); + + DisplayVisitor visitor = new DisplayVisitor(gc, color, color2, + color3, new IFocusChecker() { + + public boolean hasFocus(IModelElement l) { + return l == ModelText.this.editor.selectedLiteral; + } + + }, caret); + + this.editor.rootArea.accept(visitor); + + color.dispose(); + color2.dispose(); + color3.dispose(); + visitor.dispose(); + } + +} \ No newline at end of file Deleted: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java =================================================================== --- net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java 2006-05-16 20:28:40 UTC (rev 6) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java 2006-05-17 13:26:08 UTC (rev 14) @@ -1,54 +0,0 @@ -/* $RCSfile$ - * ----------------------------------------------------------------------------- - * - * Copyright (C) Lars Grammel and others. - * - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Common Public License v1.0 which accompanies - * this distribution, and is available at - * - * http://www.eclipse.org/legal/cpl-v10.html - * - */ -package net.sourceforge.exmmt; - -import java.util.ArrayList; -import java.util.List; - -/** - * Collects the display model elements that can be reached by the navigation model. This - * may be a problem in the future as the navigation model elements are not necessarily a - * subset of the display model elements (TODO is this true?). - */ -public final class NavigationElementSearcher implements - IModelElementVisitor { - - private List<IModelElement> navigationElements = new ArrayList<IModelElement>(); - - public void visit(AdditionPoint point) { - navigationElements.add(point); - } - - public void visit(VariableLiteral literal) { - navigationElements.add(literal); - } - - public void visit(FixedLiteral literal) { - } - - public void lineStart(Line line) { - } - - public void lineEnd(Line line) { - } - - public void areaStart(Area area) { - } - - public void areaEnd(Area area) { - } - - public List<IModelElement> getNavigationElements() { - return navigationElements; - } -} \ No newline at end of file Copied: net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java (from rev 7, net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java) =================================================================== --- net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java (rev 0) +++ net.sourceforge.exmmt/net.sourceforge.exmmt/src/java/net/sourceforge/exmmt/NavigationElementSearcher.java 2006-05-17 13:26:08 UTC (rev 14) @@ -0,0 +1,54 @@ +/* $HeadURL$ + * ----------------------------------------------------------------------------- + * + * Copyright (C) Lars Grammel and others. + * + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Common Public License v1.0 which accompanies + * this distribution, and is available at + * + * http://www.eclipse.org/legal/cpl-v10.html + * + */ +package net.sourceforge.exmmt; + +import java.util.ArrayList; +import java.util.List; + +/** + * Collects the display model elements that can be reached by the navigation model. This + * may be a problem in the future as the navigation model elements are not necessarily a + * subset of the display model elements (TODO is this true?). + */ +public final class NavigationElementSearcher implements + IModelElementVisitor { + + private List<IModelElement> navigationElements = new ArrayList<IModelElement>(); + + public void visit(AdditionPoint point) { + navigationElements.add(point); + } + + public void visit(VariableLiteral literal) { + navigationElements.add(literal); + } + + public void visit(FixedLiteral literal) { + } + + public void lineStart(Line line) { + } + + public void lineEnd(Line line) { + } + + public void areaStart(Area area) { + } + + public void areaEnd(Area area) { + } + + public List<IModelElement> getNavigationElements() { + return navigationElements; + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |