[SCM] Lisaac eclipse plugin branch, master, updated. ccdfb844cc92fcf04ff7f8122ccb106df4a150c7
Damien Bouvarel
dams.bouvarel at wanadoo.fr
Thu May 21 18:46:08 UTC 2009
The following commit has been merged in the master branch:
commit f34c4715954dcce894607fd5a6e5be90e840a62d
Author: Damien Bouvarel <dams.bouvarel at wanadoo.fr>
Date: Wed May 6 12:04:15 2009 +0200
resource decorator (error,warning) + bugfixes
diff --git a/icons/error_co.gif b/icons/error_co.gif
new file mode 100644
index 0000000..8612eaf
Binary files /dev/null and b/icons/error_co.gif differ
diff --git a/icons/variable_tab.gif b/icons/variable_tab.gif
new file mode 100644
index 0000000..e35f594
Binary files /dev/null and b/icons/variable_tab.gif differ
diff --git a/icons/warning_co.gif b/icons/warning_co.gif
new file mode 100644
index 0000000..3af228c
Binary files /dev/null and b/icons/warning_co.gif differ
diff --git a/plugin.xml b/plugin.xml
index 2cb4f0c..32697b8 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -436,5 +436,21 @@
symbolicIcon="error">
</specification>
</extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ class="org.eclipse.lisaac.editors.LisaacResourceDecorator"
+ id="org.eclipse.lisaac.decorator"
+ label="Lisaac Decorator"
+ lightweight="true"
+ location="BOTTOM_LEFT"
+ state="true">
+ <enablement>
+ <objectClass
+ name="org.eclipse.core.resources.IResource">
+ </objectClass>
+ </enablement>
+ </decorator>
+ </extension>
</plugin>
diff --git a/src/org/eclipse/lisaac/LisaacPlugin.java b/src/org/eclipse/lisaac/LisaacPlugin.java
index badd587..f1edb25 100644
--- a/src/org/eclipse/lisaac/LisaacPlugin.java
+++ b/src/org/eclipse/lisaac/LisaacPlugin.java
@@ -6,9 +6,11 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.templates.ContextTypeRegistry;
import org.eclipse.jface.text.templates.persistence.TemplateStore;
+import org.eclipse.lisaac.builder.LisaacNature;
import org.eclipse.lisaac.model.LisaacModel;
import org.eclipse.lisaac.templates.LisaacContextType;
import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
@@ -85,9 +87,16 @@ public class LisaacPlugin extends AbstractUIPlugin {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i=0; i<projects.length; i++) {
- // create lisaac model
- new LisaacModel(projects[i]);
- //
+ if (projects[i].getNature(LisaacNature.NATURE_ID) != null) {
+ try {
+ // create lisaac model
+ new LisaacModel(projects[i]);
+ //
+ } catch (Exception e) {
+ MessageDialog.openError(getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Error loading "+projects[i].getName(), e.getMessage()); //$NON-NLS-1$
+ }
+ }
}
}
diff --git a/src/org/eclipse/lisaac/editors/LisaacResourceDecorator.java b/src/org/eclipse/lisaac/editors/LisaacResourceDecorator.java
new file mode 100644
index 0000000..cbdd2fd
--- /dev/null
+++ b/src/org/eclipse/lisaac/editors/LisaacResourceDecorator.java
@@ -0,0 +1,70 @@
+package org.eclipse.lisaac.editors;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.lisaac.LisaacPlugin;
+
+/**
+ * Handle image decoration in Navigator View
+ */
+public class LisaacResourceDecorator implements ILightweightLabelDecorator {
+
+ private static ImageDescriptor OVERLAY_ERROR = LisaacPlugin.getImageDescriptor("/icons/error_co.gif");
+ private static ImageDescriptor OVERLAY_WARNING = LisaacPlugin.getImageDescriptor("/icons/warning_co.gif");
+
+
+ public void decorate(Object element, IDecoration decoration) {
+ if (element instanceof IResource) {
+ int type;
+ try {
+ type = getTypeFromMarkers((IResource) element);
+ if (type == 1) {
+ decoration.addOverlay(OVERLAY_WARNING);
+ } else if (type == 2) {
+ decoration.addOverlay(OVERLAY_ERROR);
+ }
+ } catch (CoreException e) {
+ }
+ }
+ }
+
+ private int getTypeFromMarkers(IResource res) throws CoreException {
+ if (res == null || !res.isAccessible()) {
+ return 0;
+ }
+ int markerType = 0;
+
+ IMarker[] markers = res.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
+ if (markers != null) {
+ for (int i = 0; i < markers.length && (markerType != 2); i++) {
+ IMarker curr = markers[i];
+
+ int priority = curr.getAttribute(IMarker.SEVERITY, -1);
+ if (priority == IMarker.SEVERITY_WARNING) {
+ markerType = 1;
+ } else if (priority == IMarker.SEVERITY_ERROR) {
+ markerType = 2;
+ }
+ }
+ }
+ return markerType;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+}
diff --git a/src/org/eclipse/lisaac/editors/LisaacTextHover.java b/src/org/eclipse/lisaac/editors/LisaacTextHover.java
index 4a70aaa..af5efa0 100644
--- a/src/org/eclipse/lisaac/editors/LisaacTextHover.java
+++ b/src/org/eclipse/lisaac/editors/LisaacTextHover.java
@@ -45,7 +45,7 @@ public class LisaacTextHover implements ITextHover, ITextHoverExtension {
if (LisaacScanner.isPrototypeIdentifier(text)) {
// get prototype info
- Prototype prototype = LisaacCompletionParser.findPrototype(text, model);
+ Prototype prototype = model.getPrototype(text);
if (prototype != null) {
return "<I>Prototype</I> : "+prototype.getHoverInformation();
}
diff --git a/src/org/eclipse/lisaac/editors/LisaacWordRule.java b/src/org/eclipse/lisaac/editors/LisaacWordRule.java
index 08da2b4..8bdb690 100644
--- a/src/org/eclipse/lisaac/editors/LisaacWordRule.java
+++ b/src/org/eclipse/lisaac/editors/LisaacWordRule.java
@@ -30,7 +30,11 @@ public class LisaacWordRule extends WordRule {
if (result == fDefaultToken) {
//
- Prototype prototype = LisaacModel.getCurrentPrototype();
+ Prototype prototype = null;
+ try {
+ prototype = LisaacModel.getCurrentPrototype();
+ } catch (CoreException e1) {
+ }
if (prototype == null) {
return result;
}
diff --git a/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java b/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java
index 0bbc821..3ba089b 100644
--- a/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java
+++ b/src/org/eclipse/lisaac/editors/PrototypeHyperLink.java
@@ -60,55 +60,57 @@ public class PrototypeHyperLink implements IHyperlink {
return;
}
- if (project != null) {
- String prototypePath;
- boolean createLink=false;
- Prototype prototype;
+ if (project != null) {// open 'prototype' in editor, select 'slot' at 'position'
+ Prototype prototype = null;
Slot slot = null;
Position position = null;
LisaacModel model = LisaacModel.getModel(project);
- // Slot Hyperlink
- prototype = LisaacModel.getCurrentPrototype();
- try {
- slot = prototype.getSlotFromKeyword(fPrototypeString, prototype.openParser(), fRegion.getOffset());
- } catch (CoreException e1) {
- e1.printStackTrace();
- }
- if (slot != null) {
- // slot hyperlink
- prototype = slot.getPrototype();
- position = slot.getPosition();
+ if (LisaacScanner.isPrototypeIdentifier(fPrototypeString)) {
+ // prototype hyperlink
+ try {
+ prototype = model.getPrototype(fPrototypeString);
+ } catch (CoreException e) {
+ return;
+ }
} else {
- // variable hyperlink
- slot = prototype.getSlot(fRegion.getOffset());
- IVariable variable = slot.getVariable(fPrototypeString, fRegion.getOffset());
- if (variable != null) {
- Position p = variable.getPosition();
- int len = fPrototypeString.length();
- if (p.length > 0) {
- len = p.length;
- }
- position = new Position(0, 0, p.offset-len, len);
+ // Slot Hyperlink
+ try {
+ prototype = LisaacModel.getCurrentPrototype();
+ slot = prototype.getSlotFromKeyword(fPrototypeString, prototype.openParser(), fRegion.getOffset());
+
+ } catch (CoreException e) {
+ return;
+ }
+ if (slot != null) {
+ // slot hyperlink
+ prototype = slot.getPrototype();
+ position = slot.getPosition();
} else {
-
- // prototype hyperlink
- prototype = model.getPrototype(fPrototypeString);
- }
- }
- if (prototype != null) {
- prototypePath = prototype.getFileName();
- } else {
- prototypePath = model.getPathManager().getFullPath(fPrototypeString);
- createLink = true;
+ // variable hyperlink
+ IVariable variable = null;
+ slot = prototype.getSlot(fRegion.getOffset());
+ if (slot != null) {
+ variable = slot.getVariable(fPrototypeString, fRegion.getOffset());
+ }
+ if (variable != null) {
+ Position p = variable.getPosition();
+ int len = fPrototypeString.length();
+ if (p.length > 0) {
+ len = p.length;
+ }
+ position = new Position(0, 0, p.offset-len, len);
+ } else {
+ prototype = null;
+ }
+ }
}
- if (prototypePath != null) {
+ if (prototype != null) {
final IProject p = project;
- final String filename = prototypePath;
- final boolean link = createLink;
+ final String filename = prototype.getFileName();
final Position selectPosition = position;
part.getSite().getShell().getDisplay().asyncExec(new Runnable() {
@@ -119,22 +121,20 @@ public class PrototypeHyperLink implements IHyperlink {
}
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());
+
+ IContainer src = p.getFolder("src");
+ if (src == null) {
+ src = p;
+ }
+ file = src.getFile(location);
+ if (!file.isAccessible()) {
+ IContainer lib = p.getFolder("lib");
+ if (lib == null) {
+ lib = p;
}
- } else {
- file = p.getFile(location.lastSegment());
+ file = lib.getFile(location);
}
try {
- if (link) {
- file.createLink(location, IResource.NONE, null);
- }
IDE.openEditor(page, file);
if (selectPosition != null) {
IWorkbenchPart part = w.getPartService().getActivePart();
@@ -142,9 +142,6 @@ public class PrototypeHyperLink implements IHyperlink {
((LisaacEditor)part).selectAndReveal(selectPosition.offset, selectPosition.length);
}
}
- if (link) {
- //file.delete(true, null);
- }
} catch (CoreException e) {
// TODO open editor error
e.printStackTrace();
diff --git a/src/org/eclipse/lisaac/launch/LaunchConfiguration.java b/src/org/eclipse/lisaac/launch/LaunchConfiguration.java
index 1b743a4..01f8912 100644
--- a/src/org/eclipse/lisaac/launch/LaunchConfiguration.java
+++ b/src/org/eclipse/lisaac/launch/LaunchConfiguration.java
@@ -4,6 +4,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
@@ -11,6 +12,7 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.lisaac.model.LisaacModel;
import org.eclipse.lisaac.model.items.Prototype;
+import org.eclipse.lisaac.properties.LisaacProjectPropertyPage;
public class LaunchConfiguration implements ILaunchConfigurationDelegate {
@@ -36,7 +38,10 @@ public class LaunchConfiguration implements ILaunchConfigurationDelegate {
mainPrototype = mainPrototype.substring(index+1);
}
- compiler = new LisaacCompiler(mainPrototype, lip);
+ String lisaacEnv = project.getPersistentProperty(
+ new QualifiedName("", LisaacProjectPropertyPage.LISAAC_PATH));
+
+ compiler = new LisaacCompiler(mainPrototype, lip, lisaacEnv);
// options
int count = 0;
diff --git a/src/org/eclipse/lisaac/launch/LaunchConfigurationTab.java b/src/org/eclipse/lisaac/launch/LaunchConfigurationTab.java
index b4e1509..b0a1253 100644
--- a/src/org/eclipse/lisaac/launch/LaunchConfigurationTab.java
+++ b/src/org/eclipse/lisaac/launch/LaunchConfigurationTab.java
@@ -5,6 +5,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -30,7 +31,6 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
@@ -42,6 +42,8 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+import org.eclipse.ui.dialogs.ResourceSelectionDialog;
public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
@@ -56,7 +58,6 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
// Project UI widget.
private Text projectText;
private Text mainPrototypeText;
- private Text argumentsText;
private Text lipText;
private Table lipTable;
@@ -72,6 +73,7 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
Composite comp = new Composite(parent, SWT.NONE);
setControl(comp);
GridLayout topLayout = new GridLayout();
+ topLayout.numColumns = 1;
comp.setLayout(topLayout);
// Project Options
@@ -95,7 +97,7 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
projectText = new Text(projComp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
+ gd.horizontalSpan = 1;
projectText.setLayoutData(gd);
projectText.setFont(font);
this.projectText.addModifyListener(new ModifyListener() {
@@ -103,6 +105,16 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
updateLaunchConfigurationDialog();
}
});
+ Button browseButton = new Button(projComp, SWT.PUSH);
+ browseButton.setText(LisaacMessages.getString("LaunchConfigurationTab.9")); //$NON-NLS-1$
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ gd.horizontalSpan = 1;
+ browseButton.setLayoutData(gd);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowseContainer(projectText);
+ }
+ });
Label label = new Label(projComp, SWT.NONE);
label.setText(LisaacMessages.getString("LaunchConfigurationTab.8")); //$NON-NLS-1$
@@ -121,37 +133,14 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
updateLaunchConfigurationDialog();
}
});
- Button browseButton = new Button(projComp, SWT.PUSH);
+ browseButton = new Button(projComp, SWT.PUSH);
browseButton.setText(LisaacMessages.getString("LaunchConfigurationTab.9")); //$NON-NLS-1$
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd.horizontalSpan = 1;
browseButton.setLayoutData(gd);
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- handleBrowse(mainPrototypeText);
- }
- });
-
- // Program Options
- Group programOptions = new Group(comp, SWT.SHADOW_IN);
- programOptions.setText(LisaacMessages.getString("LaunchConfigurationTab.10")); //$NON-NLS-1$
- programOptions.setLayout(new GridLayout());
-
- label = new Label(programOptions, SWT.NONE);
- label.setText(LisaacMessages.getString("LaunchConfigurationTab.11")); //$NON-NLS-1$
- gd = new GridData();
- gd.horizontalSpan = 3;
- label.setLayoutData(gd);
- label.setFont(font);
-
- argumentsText = new Text(programOptions, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- argumentsText.setLayoutData(gd);
- argumentsText.setFont(font);
- this.argumentsText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent evt) {
- updateLaunchConfigurationDialog();
+ handleBrowseFile(mainPrototypeText);
}
});
@@ -161,7 +150,9 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
GridLayout gl = new GridLayout();
gl.numColumns = 3;
compilerOptions.setLayout(gl);
-
+ gd = new GridData(GridData.FILL_VERTICAL);
+ compilerOptions.setLayoutData(gd);
+
label = new Label(compilerOptions, SWT.NONE);
label.setText(LisaacMessages.getString("LaunchConfigurationTab.13")); //$NON-NLS-1$
gd = new GridData();
@@ -186,14 +177,17 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
browseButton.setLayoutData(gd);
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- handleBrowse(lipText);
+ handleBrowseFile(lipText);
}
});
// lip options
Composite tableGroup = new Composite(compilerOptions, SWT.NONE);
- tableGroup.//setLayout(new RowLayout());
- setLayout(new GridLayout(1, false));
+ tableGroup.setLayout(new GridLayout(1, false));
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 1;
+ gd.verticalSpan = 3;
+ tableGroup.setLayoutData(gd);
lipTable = new Table(tableGroup, SWT.BORDER | SWT.SINGLE |
SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.CHECK);
@@ -208,7 +202,8 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
c3.setWidth(100);
lipTable.setHeaderVisible(true);
lipTable.setLinesVisible(true);
-
+ lipTable.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+
final TableEditor editor = new TableEditor(lipTable);
// The editor must have the same size as the cell and must
// not be any smaller than 50 pixels.
@@ -247,7 +242,7 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
}
});
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
tableGroup.setLayoutData(gridData);
}
@@ -270,9 +265,6 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
String mainPrototypeName = configuration.getAttribute(LISAAC_LAUNCH_PROTOTYPE, ""); //$NON-NLS-1$
mainPrototypeText.setText(mainPrototypeName);
- String argumentsName = configuration.getAttribute(LISAAC_LAUNCH_ARGUMENTS, ""); //$NON-NLS-1$
- argumentsText.setText(argumentsName);
-
String lipName = configuration.getAttribute(LISAAC_LAUNCH_LIP, ""); //$NON-NLS-1$
lipText.setText(lipName);
@@ -318,7 +310,6 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(LISAAC_LAUNCH_PROJECT, projectText.getText());
configuration.setAttribute(LISAAC_LAUNCH_PROTOTYPE, mainPrototypeText.getText());
- configuration.setAttribute(LISAAC_LAUNCH_ARGUMENTS, argumentsText.getText());
configuration.setAttribute(LISAAC_LAUNCH_LIP, lipText.getText());
TableItem[] options = lipTable.getItems();
@@ -402,16 +393,40 @@ public class LaunchConfigurationTab extends AbstractLaunchConfigurationTab {
return null;
}
+
/**
* Uses the standard container selection dialog to choose the new value for
* the container field.
*/
- private void handleBrowse(Text text) {
- FileDialog dialog = new FileDialog(getShell());
-
- String result = dialog.open();
- if (result != null) {
- text.setText(result);
+ private void handleBrowseContainer(Text text) {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), null, false,
+ "Select Folder"); //$NON-NLS-1$
+ if (dialog.open() == ContainerSelectionDialog.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length == 1) {
+ Object result = results[0];
+ if (result instanceof IPath) {
+ IPath ipath = (IPath) result;
+ text.setText(ipath.toString());
+ }
+ }
}
}
+
+ private void handleBrowseFile(Text text) {
+ ResourceSelectionDialog dialog = new ResourceSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), "Select File"); //$NON-NLS-1$
+ dialog.setInitialSelections(new Object[0]);
+ if (dialog.open() == ResourceSelectionDialog.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length == 1) {
+ Object result = results[0];
+ if (result instanceof IResource) {
+ text.setText(((IResource) result).getName());
+ }
+ }
+ }
+ }
+
}
diff --git a/src/org/eclipse/lisaac/launch/LaunchConfigurationTabGroup.java b/src/org/eclipse/lisaac/launch/LaunchConfigurationTabGroup.java
index 04c3440..b22bdac 100644
--- a/src/org/eclipse/lisaac/launch/LaunchConfigurationTabGroup.java
+++ b/src/org/eclipse/lisaac/launch/LaunchConfigurationTabGroup.java
@@ -1,20 +1,21 @@
-package org.eclipse.lisaac.launch;
-
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
-import org.eclipse.debug.ui.CommonTab;
-import org.eclipse.debug.ui.ILaunchConfigurationDialog;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
-
-public class LaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
-
- /**
- * @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog, String)
- */
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = {
- new LaunchConfigurationTab(),
- new CommonTab()
- };
- setTabs(tabs);
- }
-}
+package org.eclipse.lisaac.launch;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+public class LaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ /**
+ * @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog, String)
+ */
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = {
+ new LaunchConfigurationTab(),
+ new ProgramArgTab(),
+ new CommonTab()
+ };
+ setTabs(tabs);
+ }
+}
diff --git a/src/org/eclipse/lisaac/launch/LisaacCompiler.java b/src/org/eclipse/lisaac/launch/LisaacCompiler.java
index a817a05..6d659bb 100644
--- a/src/org/eclipse/lisaac/launch/LisaacCompiler.java
+++ b/src/org/eclipse/lisaac/launch/LisaacCompiler.java
@@ -11,13 +11,15 @@ public class LisaacCompiler {
protected String inputFile;
protected String lipFile;
+ protected String envPath;
protected ArrayList<String> options;
- public LisaacCompiler(String inputFile, String lipFile) {
+ public LisaacCompiler(String inputFile, String lipFile, String envPath) {
super();
this.inputFile = inputFile;
this.lipFile = lipFile;
+ this.envPath = envPath;
}
public LisaacCompiler(String inputFile) {
@@ -33,18 +35,18 @@ public class LisaacCompiler {
return LisaacLauncher.executeCommandInConsole(monitor, project, this.toCommandLineArray());
}
- public Process launch(IProject project, IProgressMonitor monitor) throws CoreException {
- IContainer src = project.getFolder("src");
- if (src != null) {
- return LisaacLauncher.executeCommand(monitor, src, this.toCommandLineArray());
- }
- return LisaacLauncher.executeCommand(monitor, project, this.toCommandLineArray());
+ public Process launch(IContainer folder, IProgressMonitor monitor) throws CoreException {
+ return LisaacLauncher.executeCommand(monitor, folder, this.toCommandLineArray());
}
public String[] toCommandLineArray() {
ArrayList<String> cmd = new ArrayList<String>();
- cmd.add("lisaac ");
+ if (envPath != null) {
+ cmd.add(envPath+"bin/lisaac "); // FIXME lisaac envpath
+ } else {
+ cmd.add("lisaac ");
+ }
if (lipFile != null) {
cmd.add(lipFile);
}
@@ -54,11 +56,20 @@ public class LisaacCompiler {
if (options != null) {
cmd.addAll(options);
}
+
return cmd.toArray(new String[cmd.size()]);
}
public String toCommandLine() {
- StringBuffer result = new StringBuffer("lisaac ");
+ StringBuffer result = new StringBuffer();
+
+ if (envPath != null) {
+ result.append(envPath);
+ result.append("bin/lisaac ");
+ } else {
+ result.append("lisaac ");
+ }
+
if (lipFile != null) {
result.append(lipFile);
}
diff --git a/src/org/eclipse/lisaac/launch/ProgramArgTab.java b/src/org/eclipse/lisaac/launch/ProgramArgTab.java
new file mode 100644
index 0000000..94a7de5
--- /dev/null
+++ b/src/org/eclipse/lisaac/launch/ProgramArgTab.java
@@ -0,0 +1,115 @@
+package org.eclipse.lisaac.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.lisaac.LisaacMessages;
+import org.eclipse.lisaac.LisaacPlugin;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class ProgramArgTab extends AbstractLaunchConfigurationTab {
+
+ private Text argumentsText;
+
+ private Image image;
+
+ ProgramArgTab() {
+ ImageDescriptor descr = LisaacPlugin.getImageDescriptor("/icons/variable_tab.gif");
+ image = descr.createImage();
+ }
+
+ /**
+ * @see ILaunchConfigurationTab#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Font font = parent.getFont();
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ GridLayout topLayout = new GridLayout();
+ comp.setLayout(topLayout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ comp.setLayoutData(gd);
+
+ // Program Options
+ Group programOptions = new Group(comp, SWT.SHADOW_IN);
+ programOptions.setText(LisaacMessages.getString("LaunchConfigurationTab.10")); //$NON-NLS-1$
+ programOptions.setLayout(new GridLayout());
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.heightHint = 150;
+ programOptions.setLayoutData(gd);
+
+ argumentsText = new Text(programOptions, SWT.MULTI | SWT.BORDER);
+ gd = new GridData(GridData.FILL_BOTH);
+ argumentsText.setLayoutData(gd);
+ argumentsText.setFont(font);
+ this.argumentsText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent evt) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
+ */
+ public String getName() {
+ return "Arguments";
+ }
+
+ public Image getImage() {
+ return image;
+ }
+
+ public void dispose() {
+ image.dispose();
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ String argumentsName = configuration.getAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_ARGUMENTS, ""); //$NON-NLS-1$
+ argumentsText.setText(argumentsName);
+
+ } catch (CoreException ce) {
+ // Log the error to the Eclipse log.
+ IStatus status = new Status(IStatus.ERROR,
+ LisaacPlugin.PLUGIN_ID, 0,
+ "Error in Lisaac launch: " + //$NON-NLS-1$
+ ce.getMessage(), ce);
+ LisaacPlugin.log(status);
+ }
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_ARGUMENTS, argumentsText.getText());
+ }
+
+ /**
+ * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
+ */
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(LaunchConfigurationTab.LISAAC_LAUNCH_ARGUMENTS, ""); //$NON-NLS-1$
+ }
+}
diff --git a/src/org/eclipse/lisaac/messages.properties b/src/org/eclipse/lisaac/messages.properties
index 78373dc..137c02e 100644
--- a/src/org/eclipse/lisaac/messages.properties
+++ b/src/org/eclipse/lisaac/messages.properties
@@ -5,8 +5,7 @@ AbstractNewFileWizardPage_4=Select container.
AbstractNewFileWizardPage_5=Source folder must be specified.
AbstractNewFileWizardPage_6=File name must be specified.
AbstractNewFileWizardPage_7=File already exists.
-LaunchConfigurationTab.10=Program Options
-LaunchConfigurationTab.11=Program Arguments:
+LaunchConfigurationTab.10=Program Arguments
LaunchConfigurationTab.12=Compiler Options
LaunchConfigurationTab.13=Lisaac Path File (default : make.lip):
LaunchConfigurationTab.14=Browse
diff --git a/src/org/eclipse/lisaac/model/LisaacCompletionParser.java b/src/org/eclipse/lisaac/model/LisaacCompletionParser.java
index a3cee33..8ff6b40 100644
--- a/src/org/eclipse/lisaac/model/LisaacCompletionParser.java
+++ b/src/org/eclipse/lisaac/model/LisaacCompletionParser.java
@@ -172,68 +172,6 @@ public class LisaacCompletionParser extends LisaacParser {
if (project == null) {
project = model.getProject();
}
- Prototype prototype = model.getPrototype(prototypeName);
- if (prototype != null) {
- // prototype is already cached
- return prototype;
- }
-
- // cache new prototype
- String prototypePath = model.getPathManager().getFullPath(prototypeName);
- if (prototypePath != null) {
- IPath location = new Path(prototypePath);
-
- IFile file = project.getFile(location.lastSegment());
- if (! file.isAccessible()) {
- file.createLink(location, IResource.REPLACE, null);
- }
- result = model.parsePrototype(prototypeName, file.getContents(), new ILisaacErrorHandler() {
- public void fatalError(String msg, Position position) {
- }
- public void semanticError(String msg, Position position) {
- }
- public void syntaxError(String msg, Position position) {
- }
- public void warning(String msg, Position position) {
- }
- });
- }
- return result;
- }
-
- /**
- * Find and parse a lisaac prototype.
- */
- public static Prototype findPrototype(String prototypeName, LisaacModel model) throws CoreException {
- Prototype result = null;
-
- Prototype prototype = model.getPrototype(prototypeName);
- if (prototype != null) {
- // prototype is already cached
- return prototype;
- }
-
- // cache new prototype
- String prototypePath = model.getPathManager().getFullPath(prototypeName);
- if (prototypePath != null) {
- IPath location = new Path(prototypePath);
- IProject project = model.getProject();
-
- IFile file = project.getFile(location.lastSegment());
- if (! file.isAccessible()) {
- file.createLink(location, IResource.REPLACE | IResource.HIDDEN, null);
- }
- result = model.parsePrototype(prototypeName, file.getContents(), new ILisaacErrorHandler() {
- public void fatalError(String msg, Position position) {
- }
- public void semanticError(String msg, Position position) {
- }
- public void syntaxError(String msg, Position position) {
- }
- public void warning(String msg, Position position) {
- }
- });
- }
- return result;
+ return model.getPrototype(prototypeName);
}
}
diff --git a/src/org/eclipse/lisaac/model/LisaacModel.java b/src/org/eclipse/lisaac/model/LisaacModel.java
index 293bb53..4592353 100644
--- a/src/org/eclipse/lisaac/model/LisaacModel.java
+++ b/src/org/eclipse/lisaac/model/LisaacModel.java
@@ -3,11 +3,14 @@ package org.eclipse.lisaac.model;
import java.io.InputStream;
import java.util.HashMap;
+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.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -89,11 +92,40 @@ public class LisaacModel implements ILisaacModel{
return lipCode;
}
- public Prototype getPrototype(String name) {
+ public Prototype getPrototype(String name) throws CoreException {
+ Prototype result=null;
+
if (prototypes != null) {
- return prototypes.get(name);
+ result = prototypes.get(name); // prototype is already cached
+
+ if (result == null) {
+ // cache new prototype
+ String prototypePath = modelPath.getFullPath(name);
+ if (prototypePath != null) {
+ IPath location = new Path(prototypePath);
+
+ IContainer lib = project.getFolder("lib");
+ if (lib == null) {
+ lib = project;
+ }
+ IFile file = lib.getFile(new Path(location.lastSegment()));
+ if (! file.isAccessible()) {
+ file.createLink(location, IResource.NONE, null);
+ }
+ result = parsePrototype(name, file.getContents(), new ILisaacErrorHandler() {
+ public void fatalError(String msg, Position position) {
+ }
+ public void semanticError(String msg, Position position) {
+ }
+ public void syntaxError(String msg, Position position) {
+ }
+ public void warning(String msg, Position position) {
+ }
+ });
+ }
+ }
}
- return null;
+ return result;
}
public void incrementalBuild() {
@@ -111,22 +143,22 @@ public class LisaacModel implements ILisaacModel{
e.printStackTrace();
}
}
-
+
public void fullBuild() {
try {
LisaacBuilder.model = this;
project.build(IncrementalProjectBuilder.FULL_BUILD, null);
-
+
} catch (CoreException e) {
e.printStackTrace();
}
}
-
+
public void clean() {
try {
LisaacBuilder.model = this;
project.build(IncrementalProjectBuilder.CLEAN_BUILD, null);
-
+
} catch (CoreException e) {
e.printStackTrace();
}
@@ -216,7 +248,7 @@ public class LisaacModel implements ILisaacModel{
return null;
}
- public static Prototype getCurrentPrototype() {
+ public static Prototype getCurrentPrototype() throws CoreException {
IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
if (w == null) {
return null;
@@ -237,4 +269,9 @@ public class LisaacModel implements ILisaacModel{
}
return null;
}
+
+ public void refreshPath() {
+ // create lisaac path
+ modelPath = new LisaacPath(project, "make.lip"); // TODO get lip from property page
+ }
}
diff --git a/src/org/eclipse/lisaac/model/LisaacPath.java b/src/org/eclipse/lisaac/model/LisaacPath.java
index 116b305..fe17c65 100644
--- a/src/org/eclipse/lisaac/model/LisaacPath.java
+++ b/src/org/eclipse/lisaac/model/LisaacPath.java
@@ -13,12 +13,14 @@ import java.util.Iterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.lisaac.LisaacPlugin;
import org.eclipse.lisaac.launch.LisaacCompiler;
import org.eclipse.lisaac.model.items.Slot;
import org.eclipse.lisaac.outline.OutlineImages;
+import org.eclipse.lisaac.properties.LisaacProjectPropertyPage;
import org.eclipse.swt.widgets.Display;
@@ -31,9 +33,16 @@ public class LisaacPath {
public LisaacPath(final IProject project, String lipFile) {
prototypesPath = new HashMap<String,String>();
- compiler = new LisaacCompiler("", lipFile);
- compiler.addOption("--p");
try {
+ String lisaacEnv = project.getPersistentProperty(
+ new QualifiedName("", LisaacProjectPropertyPage.LISAAC_PATH));
+
+ compiler = new LisaacCompiler("", lipFile, lisaacEnv);
+ compiler.addOption("--p");
+
+ System.out.println("===> "+compiler.toCommandLine());
+
+
final Process process = compiler.launch(project, new NullProgressMonitor());
if (process != null) {
@@ -45,7 +54,7 @@ public class LisaacPath {
BufferedReader bufferIn = new BufferedReader(
new InputStreamReader(
- new FileInputStream(project.getLocation()+"/src/current_path.txt")));
+ new FileInputStream(project.getLocation()+"/current_path.txt")));
String line;
while ((line = bufferIn.readLine()) != null) {
diff --git a/src/org/eclipse/lisaac/model/items/Prototype.java b/src/org/eclipse/lisaac/model/items/Prototype.java
index 018803e..3525c1e 100644
--- a/src/org/eclipse/lisaac/model/items/Prototype.java
+++ b/src/org/eclipse/lisaac/model/items/Prototype.java
@@ -43,6 +43,10 @@ public class Prototype {
slotList = new HashMap<String,Slot>();
parentList = new HashMap<String,Slot>();
+
+ if (filename.compareTo(name) == 0) {
+ this.filename = (filename.toLowerCase()).concat(".li");
+ }
}
public ILisaacModel getModel() {
diff --git a/src/org/eclipse/lisaac/properties/LisaacProjectPropertyPage.java b/src/org/eclipse/lisaac/properties/LisaacProjectPropertyPage.java
index ee97c3a..84e30f7 100644
--- a/src/org/eclipse/lisaac/properties/LisaacProjectPropertyPage.java
+++ b/src/org/eclipse/lisaac/properties/LisaacProjectPropertyPage.java
@@ -7,6 +7,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.lisaac.LisaacMessages;
+import org.eclipse.lisaac.model.LisaacModel;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -45,14 +46,6 @@ public class LisaacProjectPropertyPage extends PropertyPage {
group.setText(LISAAC_PATH);
group.setLayout(new GridLayout());
- final Button b1 = new Button(group, SWT.RADIO);
- b1.setFont(parent.getFont());
- b1.setText(LisaacMessages.getString("LisaacProjectPropertyPage.1")); //$NON-NLS-1$
-
- final Button b2 = new Button(group, SWT.RADIO);
- b2.setFont(parent.getFont());
- b2.setText(LisaacMessages.getString("LisaacProjectPropertyPage.2")); //$NON-NLS-1$
-
Composite envGroup = new Composite(group, SWT.NONE);
envGroup.setLayout(new RowLayout());
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
@@ -66,29 +59,25 @@ public class LisaacProjectPropertyPage extends PropertyPage {
RowData rowData = new RowData();
rowData.width = 200;
pathValueText.setLayoutData(rowData);
+ pathValueText.setEditable(false);
- //pathValueText.setText(((IResource) getElement()).getFullPath().toString());
- pathValueText.setEnabled(false);
-
- b2.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (b2.getSelection()) {
- pathValueText.setEnabled(true);
- browseButton.setEnabled(true);
- } else {
- pathValueText.setEnabled(false);
- browseButton.setEnabled(false);
- }
- }
- });
browseButton = new Button(envGroup, SWT.PUSH);
browseButton.setText(LisaacMessages.getString("LisaacProjectPropertyPage.3")); //$NON-NLS-1$
- browseButton.setEnabled(false);
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
handleBrowse();
}
});
+ browseButton.setEnabled(false);
+
+ Button refreshPathButton = new Button(parent, SWT.PUSH);
+ refreshPathButton.setText("Refresh Lisaac Path");
+ refreshPathButton.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ LisaacModel model = LisaacModel.getModel((IProject)getElement());
+ model.refreshPath();
+ }
+ });
}
private void addSeparator(Composite parent) {
@@ -183,6 +172,9 @@ public class LisaacProjectPropertyPage extends PropertyPage {
((IResource) getElement()).setPersistentProperty(
new QualifiedName("", LISAAC_PATH), //$NON-NLS-1$
pathValueText.getText());
+
+ // TODO remove /lib and create new one with new lisaac path
+
} catch (CoreException e) {
return false;
}
diff --git a/src/org/eclipse/lisaac/views/LisaacOutlineView.java b/src/org/eclipse/lisaac/views/LisaacOutlineView.java
index 1965f53..ea3ec2c 100644
--- a/src/org/eclipse/lisaac/views/LisaacOutlineView.java
+++ b/src/org/eclipse/lisaac/views/LisaacOutlineView.java
@@ -1,191 +1,196 @@
-package org.eclipse.lisaac.views;
-
-import java.util.List;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.lisaac.editors.LisaacEditor;
-import org.eclipse.lisaac.model.LisaacModel;
-import org.eclipse.lisaac.model.items.Prototype;
-import org.eclipse.lisaac.outline.OutlineContentProvider;
-import org.eclipse.lisaac.outline.OutlineItem;
-import org.eclipse.lisaac.outline.OutlineLabelProvider;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
-
-public class LisaacOutlineView extends ContentOutlinePage implements IDocumentListener {
-
- /** the delay before the outline view is updated. */
- private static final long UPDATE_DELAY = 1000;
-
- /** the document provider. */
- private IDocumentProvider documentProvider;
-
- /** the text editor. */
- private AbstractDecoratedTextEditor textEditor;
-
- /** the current document. */
- private IDocument document;
-
- /** the update timer which manages update task scheduling. */
- private Timer updateTimer;
-
-
- public LisaacOutlineView(IDocumentProvider documentProvider, AbstractDecoratedTextEditor textEditor) {
- super();
- this.documentProvider = documentProvider;
- this.textEditor = textEditor;
- createTimer();
- }
-
- /**
- * @see ContentOutlinePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
-
- TreeViewer viewer = getTreeViewer();
- viewer.setContentProvider(new OutlineContentProvider());
- viewer.setLabelProvider(new OutlineLabelProvider());
- viewer.addSelectionChangedListener(this);
-
- document = getDocument();
- if (document != null) {
- document.addDocumentListener(this);
- }
- update();
- }
-
- /**
- * Returns the document attached to this view.
- * @return the document attached to this view
- */
- public IDocument getDocument() {
- if (document == null) {
- document = documentProvider.getDocument(textEditor.getEditorInput());
- }
- return document;
- }
-
- /**
- * Fired when Outline selection changed
- * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection abstractSelection = event.getSelection();
- IDocument document = getDocument();
-
- if (document != null) {
- if ((abstractSelection != null) && (abstractSelection instanceof TreeSelection)) {
- TreeSelection selection = (TreeSelection) abstractSelection;
- Object selectedElement = selection.getFirstElement();
-
- if ((selectedElement != null) && (selectedElement instanceof OutlineItem)) {
- OutlineItem item = (OutlineItem) selectedElement;
- // select current outline item in editor
- textEditor.selectAndReveal(item.startOffset(), item.length());
- }
- }
- }
- }
-
- /**
- * Sends the input to the tree viewer.
- * @param input the input
- */
- public void setInput(Object input) {
- if (!getTreeViewer().getControl().isDisposed()) {
- getTreeViewer().setInput(input);
- //getTreeViewer().collapseAll();// doesn't work..
- }
- }
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
- /**
- * Notify document modifications.
- */
- public void documentChanged(DocumentEvent event) {
- document = event.getDocument();
- update();
- }
-
- /**
- * Get the outline data.
- *
- * @param project Current project
- * @param filename File to outline
- * @return List of outline items
- */
- public List<OutlineItem> getSourceOutline(IProject project, String filename) {
- LisaacModel model = LisaacModel.getModel(project);
- if (model != null) {
- Prototype prototype = model.getPrototype(LisaacModel.extractPrototypeName(filename));
-
- if (prototype != null) {
- return prototype.getOutlineItems();
- }
- }
- return null;
- }
-
- private void createTimer() {
- updateTimer = new Timer("org.eclipse.lisaac.outlinetimer");
- }
-
- /**
- * Updates the outline content view.
- */
- public void update() {
- updateTimer.cancel();
- updateTimer.purge();
- createTimer();
-
- OutlineUpdateTask updateTask = new OutlineUpdateTask();
- updateTimer.schedule(updateTask, UPDATE_DELAY);
- }
-
- /**
- * This class is in charge of updating the outline.
- */
- class OutlineUpdateTask extends TimerTask {
- public OutlineUpdateTask() {
- super();
- }
-
- /**
- * Updates the outline content view.
- * @see TimerTask#run()
- */
- public void run() {
- final IDocument document = getDocument();
- Display display = PlatformUI.getWorkbench().getDisplay();
-
- if (document != null && (textEditor instanceof LisaacEditor)) {
- IProject project = ((LisaacEditor) textEditor).getProject();
- String filename = ((LisaacEditor) textEditor).getFileName();
-
- final List<OutlineItem> items = getSourceOutline(project, filename);
-
- display.asyncExec(new Runnable() {
- public void run() {
- setInput(items.toArray(new OutlineItem[items.size()]));
- }
- });
- }
- }
- }
-}
+package org.eclipse.lisaac.views;
+
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.lisaac.editors.LisaacEditor;
+import org.eclipse.lisaac.model.LisaacModel;
+import org.eclipse.lisaac.model.items.Prototype;
+import org.eclipse.lisaac.outline.OutlineContentProvider;
+import org.eclipse.lisaac.outline.OutlineItem;
+import org.eclipse.lisaac.outline.OutlineLabelProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+
+public class LisaacOutlineView extends ContentOutlinePage implements IDocumentListener {
+
+ /** the delay before the outline view is updated. */
+ private static final long UPDATE_DELAY = 1000;
+
+ /** the document provider. */
+ private IDocumentProvider documentProvider;
+
+ /** the text editor. */
+ private AbstractDecoratedTextEditor textEditor;
+
+ /** the current document. */
+ private IDocument document;
+
+ /** the update timer which manages update task scheduling. */
+ private Timer updateTimer;
+
+
+ public LisaacOutlineView(IDocumentProvider documentProvider, AbstractDecoratedTextEditor textEditor) {
+ super();
+ this.documentProvider = documentProvider;
+ this.textEditor = textEditor;
+ createTimer();
+ }
+
+ /**
+ * @see ContentOutlinePage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ TreeViewer viewer = getTreeViewer();
+ viewer.setContentProvider(new OutlineContentProvider());
+ viewer.setLabelProvider(new OutlineLabelProvider());
+ viewer.addSelectionChangedListener(this);
+
+ document = getDocument();
+ if (document != null) {
+ document.addDocumentListener(this);
+ }
+ update();
+ }
+
+ /**
+ * Returns the document attached to this view.
+ * @return the document attached to this view
+ */
+ public IDocument getDocument() {
+ if (document == null) {
+ document = documentProvider.getDocument(textEditor.getEditorInput());
+ }
+ return document;
+ }
+
+ /**
+ * Fired when Outline selection changed
+ * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection abstractSelection = event.getSelection();
+ IDocument document = getDocument();
+
+ if (document != null) {
+ if ((abstractSelection != null) && (abstractSelection instanceof TreeSelection)) {
+ TreeSelection selection = (TreeSelection) abstractSelection;
+ Object selectedElement = selection.getFirstElement();
+
+ if ((selectedElement != null) && (selectedElement instanceof OutlineItem)) {
+ OutlineItem item = (OutlineItem) selectedElement;
+ // select current outline item in editor
+ textEditor.selectAndReveal(item.startOffset(), item.length());
+ }
+ }
+ }
+ }
+
+ /**
+ * Sends the input to the tree viewer.
+ * @param input the input
+ */
+ public void setInput(Object input) {
+ if (!getTreeViewer().getControl().isDisposed()) {
+ getTreeViewer().setInput(input);
+ //getTreeViewer().collapseAll();// doesn't work..
+ }
+ }
+
+ public void documentAboutToBeChanged(DocumentEvent event) {
+ }
+ /**
+ * Notify document modifications.
+ */
+ public void documentChanged(DocumentEvent event) {
+ document = event.getDocument();
+ update();
+ }
+
+ /**
+ * Get the outline data.
+ *
+ * @param project Current project
+ * @param filename File to outline
+ * @return List of outline items
+ * @throws CoreException
+ */
+ public List<OutlineItem> getSourceOutline(IProject project, String filename) throws CoreException {
+ LisaacModel model = LisaacModel.getModel(project);
+ if (model != null) {
+ Prototype prototype = model.getPrototype(LisaacModel.extractPrototypeName(filename));
+
+ if (prototype != null) {
+ return prototype.getOutlineItems();
+ }
+ }
+ return null;
+ }
+
+ private void createTimer() {
+ updateTimer = new Timer("org.eclipse.lisaac.outlinetimer");
+ }
+
+ /**
+ * Updates the outline content view.
+ */
+ public void update() {
+ updateTimer.cancel();
+ updateTimer.purge();
+ createTimer();
+
+ OutlineUpdateTask updateTask = new OutlineUpdateTask();
+ updateTimer.schedule(updateTask, UPDATE_DELAY);
+ }
+
+ /**
+ * This class is in charge of updating the outline.
+ */
+ class OutlineUpdateTask extends TimerTask {
+ public OutlineUpdateTask() {
+ super();
+ }
+
+ /**
+ * Updates the outline content view.
+ * @see TimerTask#run()
+ */
+ public void run() {
+ final IDocument document = getDocument();
+ Display display = PlatformUI.getWorkbench().getDisplay();
+
+ if (document != null && (textEditor instanceof LisaacEditor)) {
+ IProject project = ((LisaacEditor) textEditor).getProject();
+ String filename = ((LisaacEditor) textEditor).getFileName();
+
+ try {
+ final List<OutlineItem> items = getSourceOutline(project, filename);
+
+ display.asyncExec(new Runnable() {
+ public void run() {
+ setInput(items.toArray(new OutlineItem[items.size()]));
+ }
+ });
+ } catch (CoreException e) {
+ }
+ }
+ }
+ }
+}
diff --git a/src/org/eclipse/lisaac/wizards/NewProjectWizard.java b/src/org/eclipse/lisaac/wizards/NewProjectWizard.java
index b6efe9a..a3ad24f 100644
--- a/src/org/eclipse/lisaac/wizards/NewProjectWizard.java
+++ b/src/org/eclipse/lisaac/wizards/NewProjectWizard.java
@@ -8,11 +8,13 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -31,10 +33,12 @@ import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
@@ -86,7 +90,7 @@ public class NewProjectWizard extends Wizard implements INewWizard {
private void doFinish(String projectName, IPath nomRep, String lisaacPath, IProgressMonitor monitor)
throws CoreException
{
- monitor.beginTask("Project Creation " + projectName, 2); //$NON-NLS-1$
+ monitor.beginTask("Project Creation " + projectName, 4); //$NON-NLS-1$
// get project root
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -94,10 +98,10 @@ public class NewProjectWizard extends Wizard implements INewWizard {
try {
IProject project = root.getProject(projectName);
if (project.exists() && !project.isOpen()) {
- project.open(null);
+ project.open(monitor);
} else {
- project.create(null);
- project.open(null);
+ project.create(monitor);
+ project.open(monitor);
}
try {
@@ -109,15 +113,19 @@ public class NewProjectWizard extends Wizard implements INewWizard {
// set lisaac nature
IProjectDescription description = project.getDescription();
description.setNatureIds(new String[]{LisaacNature.NATURE_ID});
- project.setDescription(description, null);
+ project.setDescription(description, monitor);
} catch (CoreException e) {
// Something went wrong
}
+ monitor.worked(1);
+
//
new LisaacModel(project);
//
+ monitor.worked(1);
+
// create make file for project
IFile lipFile = project.getFile("make.lip"); //$NON-NLS-1$
if (! lipFile.exists()) {
@@ -127,15 +135,24 @@ public class NewProjectWizard extends Wizard implements INewWizard {
// create default folder & files in project
IFolder src = project.getFolder("src"); //$NON-NLS-1$
if (! src.exists()) {
- src.create(false, false, null);
+ src.create(false, false, monitor);
}
+ monitor.worked(1);
IFile mainPrototype = src.getFile(projectName.toLowerCase()+".li"); //$NON-NLS-1$
if (! mainPrototype.exists()) {
mainPrototype.create(new ByteArrayInputStream(getMainPrototypeStream(projectName)), false, monitor);
}
IFolder bin = project.getFolder("bin"); //$NON-NLS-1$
if (! bin.exists()) {
- bin.create(false,false,null);
+ bin.create(false,false,monitor);
+ }
+ monitor.worked(1);
+ IFolder lib = project.getFolder("lib"); //$NON-NLS-1$
+ if (! lib.exists()) {
+ // create link to lib
+ /*IPath location = new Path(lisaacPath+"/lib");// FIXME path delimiter
+ lib.createLink(location, IResource.NONE, monitor);*/
+ lib.create(false,false,monitor);
}
// store the value in the lisaac project field
project.setPersistentProperty(
@@ -147,11 +164,6 @@ public class NewProjectWizard extends Wizard implements INewWizard {
} catch (CoreException e) {
MessageDialog.openError(getShell(), "Project settings Error !", e.getMessage()); //$NON-NLS-1$
}
-
- monitor.worked(1);
- monitor.setTaskName("Opening project ..."); //$NON-NLS-1$
- monitor.worked(1);
- // ...
monitor.done();
}
@@ -177,7 +189,7 @@ public class NewProjectWizard extends Wizard implements INewWizard {
contents += "\nSection Inherit\n\n"; //$NON-NLS-1$
contents += " + parent:STRING;\n"; //$NON-NLS-1$
contents += "\nSection Private\n\n"; //$NON-NLS-1$
- contents += " + project_root:STRING := \""+project.getLocationURI().getPath()+"\";\n\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ contents += " + project_root:STRING := \""+project.getLocationURI().getPath()+"/\";\n\n"; //$NON-NLS-1$ //$NON-NLS-2$
contents += " - project_src_path <- \n"; //$NON-NLS-1$
contents += " // Define the project path for source code.\n"; //$NON-NLS-1$
contents += " (\n"; //$NON-NLS-1$
@@ -238,7 +250,8 @@ class NewProjectWizardPage extends WizardNewProjectCreationPage {
final Button b1 = new Button(group, SWT.RADIO);
b1.setFont(parent.getFont());
b1.setText(LisaacMessages.getString("NewProjectWizard_49"));
-
+ b1.setSelection(true);
+
final Button b2 = new Button(group, SWT.RADIO);
b2.setFont(parent.getFont());
b2.setText(LisaacMessages.getString("NewProjectWizard_50"));
@@ -250,9 +263,11 @@ class NewProjectWizardPage extends WizardNewProjectCreationPage {
gridData.grabExcessHorizontalSpace = true;
envGroup.setLayoutData(gridData);
- // Path text field
+ // Lisaac Path Management
+ final String defaultLisaacPath = LisaacProjectPropertyPage.getDefaultLisaacPath();
+
pathValueText = new Text(envGroup, SWT.BORDER/*SWT.WRAP | SWT.READ_ONLY*/);
- pathValueText.setText(LisaacProjectPropertyPage.getDefaultLisaacPath());
+ pathValueText.setText(defaultLisaacPath);
pathValueText.setEnabled(false);
RowData rowData = new RowData();
rowData.width = 200;
@@ -265,6 +280,7 @@ class NewProjectWizardPage extends WizardNewProjectCreationPage {
browseButton.setEnabled(true);
} else {
pathValueText.setEnabled(false);
+ pathValueText.setText(defaultLisaacPath);
browseButton.setEnabled(false);
}
}
@@ -274,8 +290,21 @@ class NewProjectWizardPage extends WizardNewProjectCreationPage {
browseButton.setEnabled(false);
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- //handleBrowse();
+ handleBrowse();
}
});
}
+
+ /**
+ * Uses the standard container selection dialog to choose the new value for
+ * the container field.
+ */
+ private void handleBrowse() {
+ FileDialog dialog = new FileDialog(getShell());
+ dialog.setText(LisaacMessages.getString("LisaacProjectPropertyPage.8"));
+ String result = dialog.open();
+ if (result != null) {
+ pathValueText.setText(result);
+ }
+ }
}
--
Lisaac eclipse plugin
More information about the Lisaac-commits
mailing list