[SCM] Lisaac eclipse plugin branch, master, updated. d0a635c9b6a1a05af5326348e3da70c69d4c387b
Damien Bouvarel
dams.bouvarel at wanadoo.fr
Sat Apr 4 09:52:46 UTC 2009
The following commit has been merged in the master branch:
commit d0a635c9b6a1a05af5326348e3da70c69d4c387b
Author: Damien Bouvarel <dams.bouvarel at wanadoo.fr>
Date: Sat Apr 4 11:45:38 2009 +0200
improve completion (completion on first keyword of slot)
diff --git a/.classpath b/.classpath
index ad32c83..802fbdb 100644
--- a/.classpath
+++ b/.classpath
@@ -1,7 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src">
+ <attributes>
+ <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="/usr/lib/jvm/java-1.5.0-sun-1.5.0.15"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 2fd4063..da76e01 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,12 @@
-#Fri Feb 13 13:38:46 CET 2009
+#Fri Mar 27 19:34:14 CET 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF
index cf7a09a..01694cf 100644
--- a/META-INF/MANIFEST.MF
+++ b/META-INF/MANIFEST.MF
@@ -22,4 +22,5 @@ Import-Package: org.eclipse.ant.core,
org.eclipse.debug.core,
org.eclipse.debug.core.model,
org.eclipse.debug.ui,
+ org.eclipse.ui.texteditor.templates,
org.eclipse.ui.views.contentoutline
diff --git a/icons/Thumbs.db b/icons/Thumbs.db
deleted file mode 100644
index b5aba5a..0000000
Binary files a/icons/Thumbs.db and /dev/null differ
diff --git a/src/org/eclipse/lisaac/LisaacPlugin.java b/src/org/eclipse/lisaac/LisaacPlugin.java
index 6f0b780..94e1fa6 100644
--- a/src/org/eclipse/lisaac/LisaacPlugin.java
+++ b/src/org/eclipse/lisaac/LisaacPlugin.java
@@ -1,82 +1,82 @@
-package org.eclipse.lisaac;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.lisaac.model.LisaacModel;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class LisaacPlugin extends AbstractUIPlugin {
-
- // The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.lisaac";
-
- // The shared instance
- private static LisaacPlugin plugin;
-
- /**
- * The constructor
- */
- public LisaacPlugin() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
-
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i=0; i<projects.length; i++) {
- // create lisaac model
- new LisaacModel(projects[i]);
- //
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static LisaacPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns an image descriptor for the image file at the given
- * plug-in relative path
- *
- * @param path the path
- * @return the image descriptor
- */
- public static ImageDescriptor getImageDescriptor(String path) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- /**
- * Logs the specified status with this plug-in's log.
- *
- * @param status status to log.
- */
- public static void log(final IStatus status) {
- getDefault().getLog().log(status);
- }
-
-}
+package org.eclipse.lisaac;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.lisaac.model.LisaacModel;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class LisaacPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.lisaac";
+
+ // The shared instance
+ private static LisaacPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public LisaacPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i=0; i<projects.length; i++) {
+ // create lisaac model
+ new LisaacModel(projects[i]);
+ //
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static LisaacPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+ /**
+ * Logs the specified status with this plug-in's log.
+ *
+ * @param status status to log.
+ */
+ public static void log(final IStatus status) {
+ getDefault().getLog().log(status);
+ }
+
+}
diff --git a/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java b/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java
index ed8a636..282b32a 100644
--- a/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java
+++ b/src/org/eclipse/lisaac/editors/AbstractLisaacEditor.java
@@ -74,6 +74,11 @@ public class AbstractLisaacEditor extends TextEditor {
model.buildAll();
}
}
+
+ public ISourceViewer getViewer() {
+ return getSourceViewer();
+ }
+
/**
* Redraw whole text presentation of the editor
*/
@@ -125,8 +130,9 @@ public class AbstractLisaacEditor extends TextEditor {
if (outlineView == null) {
outlineView = new LisaacOutlineView(getDocumentProvider(), this);
}
+
return outlineView;
- } else {
+ } else {
return super.getAdapter(required);
}
}
diff --git a/src/org/eclipse/lisaac/editors/LisaacCompletionProcessor.java b/src/org/eclipse/lisaac/editors/LisaacCompletionProcessor.java
index eea28e0..1c30641 100644
--- a/src/org/eclipse/lisaac/editors/LisaacCompletionProcessor.java
+++ b/src/org/eclipse/lisaac/editors/LisaacCompletionProcessor.java
@@ -2,12 +2,7 @@ package org.eclipse.lisaac.editors;
import java.util.ArrayList;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
@@ -16,17 +11,7 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.lisaac.LisaacPlugin;
-import org.eclipse.lisaac.builder.ILisaacErrorHandler;
import org.eclipse.lisaac.model.LisaacCompletionParser;
-import org.eclipse.lisaac.model.LisaacModel;
-import org.eclipse.lisaac.model.LisaacParser;
-import org.eclipse.lisaac.model.Position;
-import org.eclipse.lisaac.model.items.ICode;
-import org.eclipse.lisaac.model.items.Prototype;
-import org.eclipse.lisaac.model.types.IType;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
public class LisaacCompletionProcessor implements IContentAssistProcessor {
@@ -136,5 +121,4 @@ public class LisaacCompletionProcessor implements IContentAssistProcessor {
public String getErrorMessage() {
return "Lisaac Completion error";
}
-
}
diff --git a/src/org/eclipse/lisaac/editors/LisaacConfiguration.java b/src/org/eclipse/lisaac/editors/LisaacConfiguration.java
index bc61bf2..8dced78 100644
--- a/src/org/eclipse/lisaac/editors/LisaacConfiguration.java
+++ b/src/org/eclipse/lisaac/editors/LisaacConfiguration.java
@@ -17,10 +17,7 @@ import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.lisaac.LisaacPlugin;
import org.eclipse.lisaac.model.LisaacModel;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
/**
* Manage the configuration of syntax coloration for lisaac documents.
diff --git a/src/org/eclipse/lisaac/editors/LisaacTextHover.java b/src/org/eclipse/lisaac/editors/LisaacTextHover.java
index b7ec6a8..9e8d0c4 100644
--- a/src/org/eclipse/lisaac/editors/LisaacTextHover.java
+++ b/src/org/eclipse/lisaac/editors/LisaacTextHover.java
@@ -15,9 +15,7 @@ import org.eclipse.jface.text.Region;
import org.eclipse.lisaac.model.LisaacCompletionParser;
import org.eclipse.lisaac.model.LisaacModel;
import org.eclipse.lisaac.model.items.Prototype;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.editors.text.EditorsUI;
public class LisaacTextHover implements ITextHover, ITextHoverExtension {
diff --git a/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java b/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java
index abf8946..1a6c423 100644
--- a/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java
+++ b/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java
@@ -1,124 +1,127 @@
-package org.eclipse.lisaac.editors;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.lisaac.LisaacPlugin;
-import org.eclipse.lisaac.model.LisaacModel;
-import org.eclipse.lisaac.model.items.Prototype;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.ide.IDE;
-
-
-
-public class PrototypeHyperLink implements IHyperlink {
-
- private String fPrototypeString;
- private IRegion fRegion;
-
- /**
- * Creates a new Prototype hyperlink.
- * @param region
- * @param urlString
- */
- public PrototypeHyperLink(IRegion region, String string) {
- fRegion= region;
- fPrototypeString= string;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion()
- */
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#open()
- */
- public void open() {
- if (fPrototypeString != null) {
- IProject project = null;
- final IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPart part = w.getPartService().getActivePart();
- if (part instanceof LisaacEditor) {
- project = ((LisaacEditor)part).getProject();
- }
-
- if (project != null) {
- String prototypePath;
- boolean createLink=false;
-
- LisaacModel model = LisaacModel.getModel(project);
- Prototype prototype = model.getPrototype(fPrototypeString);
- if (prototype != null) {
- prototypePath = prototype.getFileName();
- } else {
- prototypePath = model.getPathManager().getFullPath(fPrototypeString);
- createLink = true;
- }
-
- if (prototypePath != null) {
- final IProject p = project;
- final String filename = prototypePath;
- final boolean link = createLink;
-
- part.getSite().getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- IWorkbenchPage page = w.getActivePage();
- if (page == null) {
- return;
- }
- IFile file;
- IPath location = new Path(filename);
- if (! link) {
- IContainer src = p.getFolder("src");
- if (src == null) {
- src = p;
- }
- file = src.getFile(location/*.lastSegment()*/);
- } else {
- file = p.getFile(location.lastSegment());
- }
- try {
- if (link) {
- file.createLink(location, IResource.NONE, null);
- }
- IDE.openEditor(page, file);
- if (link) {
- //file.delete(true, null);
- }
- } catch (CoreException e) {
- // TODO open editor error
- e.printStackTrace();
- }
- }
- });
- }
- }
- fPrototypeString = null;
- }
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- return fPrototypeString;
- }
-
- /*
- * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- return null;
- }
-}
+package org.eclipse.lisaac.editors;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.lisaac.LisaacPlugin;
+import org.eclipse.lisaac.model.LisaacModel;
+import org.eclipse.lisaac.model.items.Prototype;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.ide.IDE;
+
+
+
+public class PrototypeHyperLink implements IHyperlink {
+
+ private String fPrototypeString;
+ private IRegion fRegion;
+
+ /**
+ * Creates a new Prototype hyperlink.
+ * @param region
+ * @param urlString
+ */
+ public PrototypeHyperLink(IRegion region, String string) {
+ fRegion= region;
+ fPrototypeString= string;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkRegion()
+ */
+ public IRegion getHyperlinkRegion() {
+ return fRegion;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#open()
+ */
+ public void open() {
+ if (fPrototypeString != null) {
+ IProject project = null;
+ final IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof LisaacEditor) {
+ project = ((LisaacEditor)part).getProject();
+ }
+
+ if (project != null) {
+ String prototypePath;
+ boolean createLink=false;
+
+ LisaacModel model = LisaacModel.getModel(project);
+ Prototype prototype = model.getPrototype(fPrototypeString);
+ if (prototype != null) {
+ prototypePath = prototype.getFileName();
+ } else {
+ prototypePath = model.getPathManager().getFullPath(fPrototypeString);
+ createLink = true;
+ }
+
+ if (prototypePath != null) {
+ final IProject p = project;
+ final String filename = prototypePath;
+ final boolean link = createLink;
+
+ part.getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page = w.getActivePage();
+ if (page == null) {
+ return;
+ }
+ IFile file=null;
+ IPath location = new Path(filename);
+ if (! link) {
+ IContainer src = p.getFolder("src");
+ if (src == null) {
+ src = p;
+ }
+ file = src.getFile(location/*.lastSegment()*/);
+ if (!file.isAccessible()) {
+ file = p.getFile(location.lastSegment());
+ }
+ } else {
+ file = p.getFile(location.lastSegment());
+ }
+ try {
+ if (link) {
+ file.createLink(location, IResource.NONE, null);
+ }
+ IDE.openEditor(page, file);
+ if (link) {
+ //file.delete(true, null);
+ }
+ } catch (CoreException e) {
+ // TODO open editor error
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }
+ fPrototypeString = null;
+ }
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ return fPrototypeString;
+ }
+
+ /*
+ * @see org.eclipse.jdt.internal.ui.javaeditor.IHyperlink#getTypeLabel()
+ */
+ public String getTypeLabel() {
+ return null;
+ }
+}
diff --git a/src/org/eclipse/lisaac/model/LisaacCompletionParser.java b/src/org/eclipse/lisaac/model/LisaacCompletionParser.java
index 552a9e6..be5343f 100644
--- a/src/org/eclipse/lisaac/model/LisaacCompletionParser.java
+++ b/src/org/eclipse/lisaac/model/LisaacCompletionParser.java
@@ -46,15 +46,21 @@ public class LisaacCompletionParser extends LisaacParser {
currentSlot = currentPrototype.getSlot(startOffset);
ICode code = readExpr();
- if (code != null) {
+ if (code != null && currentPrototype != null) {
type = code.getType(currentSlot, currentPrototype);
- if (type != null && currentPrototype != null) {
+ if (type != null) {
//if (! type.equals(TypeSimple.getTypeSelf())) {
if ("SELF".compareTo(type.toString()) != 0) {
currentPrototype = findPrototype(type.toString());
}
currentPrototype.getSlotProposals(proposals, baseOffset, 0);
proposals.add(new CompletionProposal(""+type,baseOffset,0,0));
+ } else {
+ // partial slot name (first keyword)
+ if (code instanceof ITMRead) {
+ String prefix = ((ITMRead) code).getName();
+ currentPrototype.getSlotMatch(prefix, proposals, baseOffset, 0);
+ }
}
}
}
@@ -161,7 +167,7 @@ public class LisaacCompletionParser extends LisaacParser {
IFile file = project.getFile(location.lastSegment());
if (! file.isAccessible()) {
- file.createLink(location, IResource.REPLACE, null);
+ file.createLink(location, IResource.REPLACE | IResource.HIDDEN, null);
}
result = model.parsePrototype(prototypeName, file.getContents(), new ILisaacErrorHandler() {
public void fatalError(String msg, Position position) {
diff --git a/src/org/eclipse/lisaac/model/items/Prototype.java b/src/org/eclipse/lisaac/model/items/Prototype.java
index bdeec30..eb35a8d 100644
--- a/src/org/eclipse/lisaac/model/items/Prototype.java
+++ b/src/org/eclipse/lisaac/model/items/Prototype.java
@@ -33,8 +33,8 @@ public class Prototype {
// hover informations
protected String headerData;
protected String headerComment;
-
-
+
+
public Prototype(String filename, String name, ILisaacModel model) {
this.filename = filename;
this.name = name;
@@ -107,7 +107,7 @@ public class Prototype {
if (result == null) {
result = getParentSlot(n);
}
-
+
if (result == null) {
//
// Search in parents.
@@ -192,6 +192,57 @@ public class Prototype {
return null;
}
+ public void lookupSlotMatch(String n, ArrayList<CompletionProposal> matchList, int offset, int length) {
+ //
+ // Search in 'Self'.
+ //
+ getSlotMatch(n, matchList, offset, length);
+ getParentSlotMatch(n, matchList, offset, length);
+
+ //
+ // Search in parents.
+ //
+ Collection<Slot> values = parentList.values();
+ Iterator<Slot> it = values.iterator() ;
+ while (it.hasNext()) {
+ Slot slotParent = it.next();
+ IType typeParent = slotParent.getResultType();
+ try {
+ Prototype parent = LisaacCompletionParser.findPrototype(""+typeParent);
+ if (parent != null) {
+ parent.lookupSlotMatch(n, matchList, offset, length);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ public void getSlotMatch(String n, ArrayList<CompletionProposal> matchList, int offset, int length) {
+ //
+ // Search in 'Self' only.
+ //
+ Collection<Slot> values = slotList.values();
+ Iterator<Slot> it = values.iterator() ;
+ while (it.hasNext()) {
+ Slot slot = it.next();
+ if (slot.match(n)) {
+ slot.getSlotMatchProposals(matchList, offset, length, n.length());
+ }
+ }
+ }
+
+ public void getParentSlotMatch(String n, ArrayList<CompletionProposal> matchList, int offset, int length) {
+ // Search in 'Self' parent.
+ Collection<Slot> values = parentList.values();
+ Iterator<Slot> it = values.iterator() ;
+ while (it.hasNext()) {
+ Slot slot = it.next();
+ if (slot.match(n)) {
+ slot.getSlotMatchProposals(matchList, offset, length, n.length());
+ }
+ }
+ }
+
public void addSlot(Slot s) {
slotList.put(s.getName(), s);
}
@@ -213,7 +264,7 @@ public class Prototype {
}
return buffer.toString();
}
-
+
public List<OutlineItem> getOutlineItems() {
List<OutlineItem> slots = new ArrayList<OutlineItem>();
@@ -234,12 +285,7 @@ public class Prototype {
Iterator<Slot> it = values.iterator() ;
while (it.hasNext()) {
Slot slot = it.next();
- Image image = new OutlineSlot(slot).getImage();
- String displayString = slot.getSignature(true);
-
- proposals.add(new CompletionProposal(displayString,
- offset, length, displayString.length(), image,
- slot.getSignature(false), null, null));
+ slot.getSlotProposals(proposals, offset, length);
}
}
}
diff --git a/src/org/eclipse/lisaac/model/items/Slot.java b/src/org/eclipse/lisaac/model/items/Slot.java
index d3701d3..7afcef6 100644
--- a/src/org/eclipse/lisaac/model/items/Slot.java
+++ b/src/org/eclipse/lisaac/model/items/Slot.java
@@ -1,174 +1,208 @@
-package org.eclipse.lisaac.model.items;
-
-import org.eclipse.lisaac.model.ILisaacModel;
-import org.eclipse.lisaac.model.Position;
-import org.eclipse.lisaac.model.types.IType;
-
-public class Slot {
-
- protected Section sectionId;
- protected Position position;
-
- protected String name;
- protected char style;
- protected char affect; // ':', '?', '<'
-
- protected IArgument[] argumentList;
- protected IType resultType;
-
- protected String[] keywordList;
-
-
- public Slot(Position position, String name, Section sectionId) {
- this.name = name;
- this.position = position;
- this.sectionId = sectionId;
- }
-
- public String getName() {
- return name;
- }
- public char getStyle() {
- return style;
- }
-
- public char getAffect() {
- return affect;
- }
-
- public IArgument getArgument(int i) {
- return argumentList[i];
- }
-
- public Section getSectionId() {
- return sectionId;
- }
-
- public IType getResultType() {
- return resultType;
- }
-
- public void setArgumentList(IArgument[] argumentList) {
- this.argumentList = argumentList;
- }
-
- public void setResultType(IType resultType) {
- this.resultType = resultType;
- }
-
- public void setKeywordList(String[] keywordList) {
- this.keywordList = keywordList;
- }
-
- public void setAffect(char affect) {
- this.affect = affect;
- }
-
- public Position getPosition() {
- return position;
- }
-
- //
- // Value.
- //
- ICode value;
-
- public void setValue(ICode v) {
- if (affect == '<') {
- value = v;
- } else {
- // TODO not yet implemented
- }
- }
- public ICode getValue() {
- return value;
- }
-
- //
- // Access associativity & priority level.
- //
- protected int priorityAndLevel;
-
- public void setAssociativity(String p, int l) {
- if (p == null || p.equals(ILisaacModel.keyword_left)) {
- priorityAndLevel = l;
- } else {
- priorityAndLevel = -l;
- }
- }
-
- public String getAssociativity() {
- String result;
-
- if (priorityAndLevel >= 0) {
- result = ILisaacModel.keyword_left;
- } else {
- result = ILisaacModel.keyword_right;
- }
- return result;
- }
-
- public int getPriority() {
- if (priorityAndLevel < 0) {
- return -priorityAndLevel;
- }
- return priorityAndLevel;
- }
-
- public void setStyle(char style) {
- this.style = style;
- }
-
- public boolean hasArgument(String word) {
- return getArgument(word) != null;
- }
-
- public IArgument getArgument(String word) {
- if (argumentList != null) {
- for (int i=0; i<argumentList.length; i++) {
- if (argumentList[i] instanceof ITMArgs) {
- if (((ITMArgs)argumentList[i]).hasArgument(word)) {
- return argumentList[i];
- }
- } else if (argumentList[i].getName().compareTo(word) == 0) {
- return argumentList[i];
- }
- }
- }
- return null;
- }
-
- public Prototype getPrototype() {
- return sectionId.getPrototype();
- }
-
- public String getSignature(boolean isCall) {
- if (keywordList == null || keywordList.length < 1) {
- return name;
- }
- StringBuffer buffer = new StringBuffer();
- buffer.append(keywordList[0]);
- buffer.append(" ");
-
- int keywordIndex = 1;
- for (int argIndex=0; argIndex < argumentList.length; argIndex++) {
- if (isCall) {
- buffer.append(argumentList[argIndex].getName());
- } else {
- argumentList[argIndex].printIn(buffer);
- }
- buffer.append(" ");
-
- if (keywordIndex < keywordList.length) {
- buffer.append(keywordList[keywordIndex]);
- buffer.append(" ");
- keywordIndex++;
- }
- }
- if (! isCall && resultType.toString() != null) {
- buffer.append(" : "+resultType);
- }
- return buffer.toString();
- }
-}
-
+package org.eclipse.lisaac.model.items;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.jface.text.contentassist.CompletionProposal;
+import org.eclipse.lisaac.model.ILisaacModel;
+import org.eclipse.lisaac.model.Position;
+import org.eclipse.lisaac.model.types.IType;
+import org.eclipse.lisaac.outline.OutlineSlot;
+import org.eclipse.swt.graphics.Image;
+
+public class Slot {
+
+ protected Section sectionId;
+ protected Position position;
+
+ protected String name;
+ protected char style;
+ protected char affect; // ':', '?', '<'
+
+ protected IArgument[] argumentList;
+ protected IType resultType;
+
+ protected String[] keywordList;
+
+
+ public Slot(Position position, String name, Section sectionId) {
+ this.name = name;
+ this.position = position;
+ this.sectionId = sectionId;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public char getStyle() {
+ return style;
+ }
+
+ public char getAffect() {
+ return affect;
+ }
+
+ public IArgument getArgument(int i) {
+ return argumentList[i];
+ }
+
+ public Section getSectionId() {
+ return sectionId;
+ }
+
+ public IType getResultType() {
+ return resultType;
+ }
+
+ public void setArgumentList(IArgument[] argumentList) {
+ this.argumentList = argumentList;
+ }
+
+ public void setResultType(IType resultType) {
+ this.resultType = resultType;
+ }
+
+ public void setKeywordList(String[] keywordList) {
+ this.keywordList = keywordList;
+ }
+
+ public void setAffect(char affect) {
+ this.affect = affect;
+ }
+
+ public Position getPosition() {
+ return position;
+ }
+
+ //
+ // Value.
+ //
+ ICode value;
+
+ public void setValue(ICode v) {
+ if (affect == '<') {
+ value = v;
+ } else {
+ // TODO not yet implemented
+ }
+ }
+ public ICode getValue() {
+ return value;
+ }
+
+ //
+ // Access associativity & priority level.
+ //
+ protected int priorityAndLevel;
+
+ public void setAssociativity(String p, int l) {
+ if (p == null || p.equals(ILisaacModel.keyword_left)) {
+ priorityAndLevel = l;
+ } else {
+ priorityAndLevel = -l;
+ }
+ }
+
+ public String getAssociativity() {
+ String result;
+
+ if (priorityAndLevel >= 0) {
+ result = ILisaacModel.keyword_left;
+ } else {
+ result = ILisaacModel.keyword_right;
+ }
+ return result;
+ }
+
+ public int getPriority() {
+ if (priorityAndLevel < 0) {
+ return -priorityAndLevel;
+ }
+ return priorityAndLevel;
+ }
+
+ public void setStyle(char style) {
+ this.style = style;
+ }
+
+ public boolean hasArgument(String word) {
+ return getArgument(word) != null;
+ }
+
+ public IArgument getArgument(String word) {
+ if (argumentList != null) {
+ for (int i=0; i<argumentList.length; i++) {
+ if (argumentList[i] instanceof ITMArgs) {
+ if (((ITMArgs)argumentList[i]).hasArgument(word)) {
+ return argumentList[i];
+ }
+ } else if (argumentList[i].getName().compareTo(word) == 0) {
+ return argumentList[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ public Prototype getPrototype() {
+ return sectionId.getPrototype();
+ }
+
+ public String getSignature(boolean isCall) {
+ if (keywordList == null || keywordList.length < 1) {
+ return name;
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(keywordList[0]);
+ buffer.append(" ");
+
+ int keywordIndex = 1;
+ for (int argIndex=0; argIndex < argumentList.length; argIndex++) {
+ if (isCall) {
+ buffer.append(argumentList[argIndex].getName());
+ } else {
+ argumentList[argIndex].printIn(buffer);
+ }
+ buffer.append(" ");
+
+ if (keywordIndex < keywordList.length) {
+ buffer.append(keywordList[keywordIndex]);
+ buffer.append(" ");
+ keywordIndex++;
+ }
+ }
+ if (! isCall && resultType.toString() != null) {
+ buffer.append(" : "+resultType);
+ }
+ return buffer.toString();
+ }
+
+ public void getSlotProposals(ArrayList<CompletionProposal> proposals,
+ int offset, int length) {
+
+ Image image = new OutlineSlot(this).getImage();
+ String displayString = getSignature(true);
+
+ proposals.add(new CompletionProposal(displayString,
+ offset, length, displayString.length(), image,
+ getSignature(false), null, null));
+ }
+
+ public void getSlotMatchProposals(ArrayList<CompletionProposal> proposals,
+ int offset, int length, int matchLength) {
+
+ Image image = new OutlineSlot(this).getImage();
+ String displayString = getSignature(true);
+
+ displayString = displayString.substring(matchLength);
+ proposals.add(new CompletionProposal(displayString,
+ offset, length, displayString.length(), image,
+ getSignature(false), null, null));
+ }
+
+ public boolean match(String n) {
+ return name.startsWith(n);
+ }
+}
+
diff --git a/src/org/eclipse/lisaac/wizards/NewPrototypeWizard.java b/src/org/eclipse/lisaac/wizards/NewPrototypeWizard.java
index 6da91ff..34e4191 100644
--- a/src/org/eclipse/lisaac/wizards/NewPrototypeWizard.java
+++ b/src/org/eclipse/lisaac/wizards/NewPrototypeWizard.java
@@ -1,232 +1,230 @@
-package org.eclipse.lisaac.wizards;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.lisaac.model.ILisaacModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-
-/**
- * Lisaac source file creator.
- */
-public class NewPrototypeWizard extends AbstractNewFileWizard {
-
- public NewPrototypeWizard() {
- super();
- setWindowTitle("New Prototype");
- }
-
- /**
- * Create wizard page
- */
- protected AbstractNewFileWizardPage createPage() {
- return new NewPrototypeWizardPage(getSelection());
- }
-}
-
-/**
- * Represent the main page in "new lisaac prototype" wizard.
- */
-class NewPrototypeWizardPage extends AbstractNewFileWizardPage {
- final private String INITIAL_PROTOTYPE_NAME = "prototype.li";
-
- protected Text commentField;
-
- protected Button styleNone;
- protected Button styleExpanded;
- protected Button styleStrict;
-
- protected Table tableInherit;
-
- protected NewPrototypeWizardPage(IStructuredSelection selection) {
- super(NewPrototypeWizardPage.class.getName(), selection);
-
- setTitle("Prototype File");
- setDescription("Creates a new source file into a project");
- setFileExtension(".li");
- }
-
- public String getPrototypeDescription() {
- return commentField.getText();
- }
-
- /**
- * Return the initial content of new file.
- */
- protected InputStream getInitialContents(String filename) {
- try {
- int index = filename.lastIndexOf('.');
- if (index != -1) {
- filename = filename.substring(0, index);
- }
- return new ByteArrayInputStream(getPrototypeStream(filename));
- } catch (IOException e) {
- return null; // ignore and create empty comments
- }
- }
-
- public byte[] getPrototypeStream(String filename) throws IOException {
- boolean isExpanded = styleExpanded.getSelection();
- boolean isStrict = styleExpanded.getSelection();
-
- String contents = "\nSection Header\n\n";
- contents += " + name := ";
- if (isExpanded) {
- contents += "Expanded ";
- } else if (isStrict) {
- contents += "Strict ";
- }
- contents += filename.toUpperCase()+";\n";
-
- String descr = getPrototypeDescription();
- if (descr != null && descr.length() > 0) {
- contents += " - comment := \""+descr+"\";\n";
- }
- if (! isExpanded) {
- contents += "\nSection Inherit\n\n";
- } else {
- contents += "\nSection Insert\n\n";
- }
- int n = tableInherit.getItemCount();
- if (n > 0) {
- for (int i=0; i<n; i++) {
- TableItem item = tableInherit.getItem(i);
- String type = item.getText(1);
- if (type.equals(ILisaacModel.inherit_shared) ||
- type.equals(ILisaacModel.inherit_shared_expanded)) {
- contents += " - ";
- } else {
- contents += " + ";
- }
- contents += "parent_";
- contents += item.getText(0).toLowerCase() + ":";
- if (type.equals(ILisaacModel.inherit_shared_expanded) ||
- type.equals(ILisaacModel.inherit_nonshared_expanded)) {
- contents += "Expanded " + item.getText(0);
- } else {
- contents += item.getText(0) + " := " + item.getText(0);
- }
- contents += ";\n";
- }
- } else {
- contents += " - parent_object:OBJECT := OBJECT;\n";
- }
- contents += "\nSection Public\n\n";
- return contents.getBytes();
- }
-
- /**
- * Additional wizard information
- */
- public void createAdvancedControls(Composite parent) {
-
- // -- Style --
- Label label = new Label(parent, SWT.NONE);
- label.setText("Prototype Style : ");
- label.setFont(parent.getFont());
-
- Composite radioGroup = new Composite(parent, SWT.NONE);
- radioGroup.setLayout(new RowLayout());
- styleNone = new Button(radioGroup, SWT.RADIO);
- styleNone.setFont(parent.getFont());
- styleNone.setText("None");
- styleExpanded = new Button(radioGroup, SWT.RADIO);
- styleExpanded.setFont(parent.getFont());
- styleExpanded.setText("Expanded");
- styleStrict = new Button(radioGroup, SWT.RADIO);
- styleStrict.setFont(parent.getFont());
- styleStrict.setText("Strict");
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.horizontalSpan = 2;
- radioGroup.setLayoutData(gridData);
- //
-
- // -- Description --
- label = new Label(parent, SWT.NONE);
- label.setText("Description : ");
- label.setFont(parent.getFont());
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.horizontalSpan = 1;
- label.setLayoutData(gridData);
-
- commentField = new Text(parent, SWT.BORDER);
- commentField.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.horizontalSpan = 2;
- commentField.setLayoutData(gridData);
- //
-
- // -- inherits --
- label = new Label(parent, SWT.NONE);
- label.setText("Inheritance : ");
- label.setFont(parent.getFont());
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.horizontalSpan = 1;
- label.setLayoutData(gridData);
-
- Composite tableGroup = new Composite(parent, SWT.NONE);
- tableGroup.setLayout(new RowLayout());
-
- final Table table = new Table(tableGroup, SWT.BORDER | SWT.SINGLE |
- SWT.H_SCROLL | SWT.FULL_SELECTION);
- final TableColumn c1 = new TableColumn(table, SWT.LEFT);
- c1.setText("Prototype");
- c1.setWidth(150);
- final TableColumn c2 = new TableColumn(table, SWT.LEFT);
- c2.setText("Inheritance Type");
- c2.setWidth(100);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- final TableItem itemDefault = new TableItem(table, SWT.NONE);
- itemDefault.setText(new String[] {"OBJECT", ILisaacModel.inherit_shared});
-
- Composite buttonGroup = new Composite(tableGroup, SWT.NONE);
- buttonGroup.setLayout(new GridLayout());
- Button tableAdd = new Button(buttonGroup, SWT.PUSH);
- tableAdd.setFont(parent.getFont());
- tableAdd.setText("Add");
- tableAdd.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- // TODO dialog to create inherit table item
- }
- });
- Button tableRemove= new Button(buttonGroup, SWT.PUSH);
- tableRemove.setFont(parent.getFont());
- tableRemove.setText("Remove");
- tableRemove.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- int[] indices = table.getSelectionIndices();
- if (indices != null && indices.length > 0) {
- int index = indices[0];
- table.remove(index);
- }
- }
- });
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gridData.horizontalSpan = 2;
- tableGroup.setLayoutData(gridData);
-
- tableInherit = table;
- //
- }
-
- protected String getInitialFileName() {
- return INITIAL_PROTOTYPE_NAME;
- }
-}
+package org.eclipse.lisaac.wizards;
+
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.lisaac.model.ILisaacModel;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
+
+import java.io.*;
+
+/**
+ * Lisaac source file creator.
+ */
+public class NewPrototypeWizard extends AbstractNewFileWizard {
+
+ public NewPrototypeWizard() {
+ super();
+ setWindowTitle("New Prototype");
+ }
+
+ /**
+ * Create wizard page
+ */
+ protected AbstractNewFileWizardPage createPage() {
+ return new NewPrototypeWizardPage(getSelection());
+ }
+}
+
+/**
+ * Represent the main page in "new lisaac prototype" wizard.
+ */
+class NewPrototypeWizardPage extends AbstractNewFileWizardPage {
+ final private String INITIAL_PROTOTYPE_NAME = "prototype.li";
+
+ protected Text commentField;
+
+ protected Button styleNone;
+ protected Button styleExpanded;
+ protected Button styleStrict;
+
+ protected Table tableInherit;
+
+ protected NewPrototypeWizardPage(IStructuredSelection selection) {
+ super(NewPrototypeWizardPage.class.getName(), selection);
+
+ setTitle("Prototype File");
+ setDescription("Creates a new source file into a project");
+ setFileExtension(".li");
+ }
+
+ public String getPrototypeDescription() {
+ return commentField.getText();
+ }
+
+ /**
+ * Return the initial content of new file.
+ */
+ protected InputStream getInitialContents(String filename) {
+ try {
+ int index = filename.lastIndexOf('.');
+ if (index != -1) {
+ filename = filename.substring(0, index);
+ }
+ return new ByteArrayInputStream(getPrototypeStream(filename));
+ } catch (IOException e) {
+ return null; // ignore and create empty comments
+ }
+ }
+
+ public byte[] getPrototypeStream(String filename) throws IOException {
+ boolean isExpanded = styleExpanded.getSelection();
+ boolean isStrict = styleExpanded.getSelection();
+
+ String contents = "\nSection Header\n\n";
+ contents += " + name := ";
+ if (isExpanded) {
+ contents += "Expanded ";
+ } else if (isStrict) {
+ contents += "Strict ";
+ }
+ contents += filename.toUpperCase()+";\n";
+
+ String descr = getPrototypeDescription();
+ if (descr != null && descr.length() > 0) {
+ contents += " - comment := \""+descr+"\";\n";
+ }
+ if (! isExpanded) {
+ contents += "\nSection Inherit\n\n";
+ } else {
+ contents += "\nSection Insert\n\n";
+ }
+ int n = tableInherit.getItemCount();
+ if (n > 0) {
+ for (int i=0; i<n; i++) {
+ TableItem item = tableInherit.getItem(i);
+ String type = item.getText(1);
+ if (type.equals(ILisaacModel.inherit_shared) ||
+ type.equals(ILisaacModel.inherit_shared_expanded)) {
+ contents += " - ";
+ } else {
+ contents += " + ";
+ }
+ contents += "parent_";
+ contents += item.getText(0).toLowerCase() + ":";
+ if (type.equals(ILisaacModel.inherit_shared_expanded) ||
+ type.equals(ILisaacModel.inherit_nonshared_expanded)) {
+ contents += "Expanded " + item.getText(0);
+ } else {
+ contents += item.getText(0) + " := " + item.getText(0);
+ }
+ contents += ";\n";
+ }
+ } else {
+ contents += " - parent_object:OBJECT := OBJECT;\n";
+ }
+ contents += "\nSection Public\n\n";
+ return contents.getBytes();
+ }
+
+ /**
+ * Additional wizard information
+ */
+ public void createAdvancedControls(Composite parent) {
+
+ // -- Style --
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("Prototype Style : ");
+ label.setFont(parent.getFont());
+
+ Composite radioGroup = new Composite(parent, SWT.NONE);
+ radioGroup.setLayout(new RowLayout());
+ styleNone = new Button(radioGroup, SWT.RADIO);
+ styleNone.setFont(parent.getFont());
+ styleNone.setText("None");
+ styleExpanded = new Button(radioGroup, SWT.RADIO);
+ styleExpanded.setFont(parent.getFont());
+ styleExpanded.setText("Expanded");
+ styleStrict = new Button(radioGroup, SWT.RADIO);
+ styleStrict.setFont(parent.getFont());
+ styleStrict.setText("Strict");
+ GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ radioGroup.setLayoutData(gridData);
+ //
+
+ // -- Description --
+ label = new Label(parent, SWT.NONE);
+ label.setText("Description : ");
+ label.setFont(parent.getFont());
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 1;
+ label.setLayoutData(gridData);
+
+ commentField = new Text(parent, SWT.BORDER);
+ commentField.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ commentField.setLayoutData(gridData);
+ //
+
+ // -- inherits --
+ label = new Label(parent, SWT.NONE);
+ label.setText("Inheritance : ");
+ label.setFont(parent.getFont());
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 1;
+ label.setLayoutData(gridData);
+
+ Composite tableGroup = new Composite(parent, SWT.NONE);
+ tableGroup.setLayout(new RowLayout());
+
+ final Table table = new Table(tableGroup, SWT.BORDER | SWT.SINGLE |
+ SWT.H_SCROLL | SWT.FULL_SELECTION);
+ final TableColumn c1 = new TableColumn(table, SWT.LEFT);
+ c1.setText("Prototype");
+ c1.setWidth(150);
+ final TableColumn c2 = new TableColumn(table, SWT.LEFT);
+ c2.setText("Inheritance Type");
+ c2.setWidth(100);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ final TableItem itemDefault = new TableItem(table, SWT.NONE);
+ itemDefault.setText(new String[] {"OBJECT", ILisaacModel.inherit_shared});
+
+ Composite buttonGroup = new Composite(tableGroup, SWT.NONE);
+ buttonGroup.setLayout(new GridLayout());
+ Button tableAdd = new Button(buttonGroup, SWT.PUSH);
+ tableAdd.setFont(parent.getFont());
+ tableAdd.setText("Add");
+ tableAdd.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ // TODO dialog to create inherit table item
+ }
+ });
+ Button tableRemove= new Button(buttonGroup, SWT.PUSH);
+ tableRemove.setFont(parent.getFont());
+ tableRemove.setText("Remove");
+ tableRemove.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ int[] indices = table.getSelectionIndices();
+ if (indices != null && indices.length > 0) {
+ int index = indices[0];
+ table.remove(index);
+ }
+ }
+ });
+ gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gridData.horizontalSpan = 2;
+ tableGroup.setLayoutData(gridData);
+
+ tableInherit = table;
+ //
+ }
+
+ protected String getInitialFileName() {
+ return INITIAL_PROTOTYPE_NAME;
+ }
+}
--
Lisaac eclipse plugin
More information about the Lisaac-commits
mailing list