Commit 246e18de authored by Kerstin Bach's avatar Kerstin Bach

Merge branch 'mycbr-3.0.1' into 'master'

myCBR 3.1 merge request

Merging all changes into master

See merge request !15
parents 0a9f7ae2 9c0ac81a
......@@ -8,7 +8,8 @@ Bundle-Version: 3.0.0.beta
Bundle-Activator: de.dfki.mycbr.gui.plugin.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.forms
org.eclipse.ui.forms,
org.eclipse.core.expressions
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: lib/mycbr.jar,
......@@ -51,6 +52,7 @@ Export-Package: .,
de.dfki.mycbr.gui.attribute.wizard,
de.dfki.mycbr.gui.casebase.editor,
de.dfki.mycbr.gui.casebase.list,
de.dfki.mycbr.gui.casebaseexport.editor,
de.dfki.mycbr.gui.commands,
de.dfki.mycbr.gui.concept.editor,
de.dfki.mycbr.gui.csvimporter.wizard,
......
......@@ -11,11 +11,14 @@ editor.name.5 = Float Editor
editor.name.6 = Advanced Float Editor
editor.name.7 = Concept Desc Editor
editor.name.8 = Amalgamation Function Editor
editor.name.9 = Concept editor
editor.name.10 = Attribute editor
editor.name.9 = Concept Editor
editor.name.10 = Attribute Editor
editor.name.11 = Retrieval
editor.name.12 = Filter Editor
editor.name.13 = Instance editor
editor.name.13 = Instance Editor
editor.name.14 = Double Editor
editor.name.15 = Advanced Double Editor
editor.name.16 = Export
view.name = Projects
view.name.0 = Similarity Measures
view.name.1 = Case Bases
......@@ -47,6 +50,7 @@ command.name.22 = Add new attribute
command.name.23 = Delete (in project list)
command.name.24 = Edit Instance
command.name.25 = Open Recent ...
command.name.26 = Export case base to CSV file
command.label = New Project
command.tooltip = Create a new project
command.label.0 = Open Project
......@@ -85,6 +89,9 @@ command.label.19 = Add new attribute
command.tooltip.10 = Add new attribute
command.label.20 = Delete
command.tooltip.11 = Delete
menu.label.2 = Case Base
command.label.21 = Export
command.label.22 = Import
product.name = myCBR
scheme.name = de.dfki.mycbr.gui.scheme
Bundle-Name = myCBR
\ No newline at end of file
This diff is collapsed.
......@@ -141,6 +141,12 @@
id="de.dfki.mycbr.gui.function.editor.AdvancedDoubleEditor"
name="%editor.name.15">
</editor>
<editor
class="de.dfki.mycbr.gui.casebaseexport.editor.CasebaseExport"
default="false"
id="de.dfki.mycbr.gui.casebaseexport.editor.CasebaseExport"
name="%editor.name.16">
</editor>
</extension>
<extension
point="org.eclipse.ui.views">
......@@ -155,9 +161,9 @@
id="de.dfki.mycbr.gui.function.list.FunctionListView">
</view>
<view
name="%view.name.1"
class="de.dfki.mycbr.gui.casebase.list.CasebaseListView"
id="de.dfki.mycbr.gui.casebase.list.CasebaseListView">
id="de.dfki.mycbr.gui.casebase.list.CasebaseListView"
name="%view.name.1">
</view>
<view
class="de.dfki.mycbr.gui.instance.list.InstanceListView"
......@@ -238,7 +244,6 @@
name="%command.name.12">
</command>
<command
defaultHandler="de.dfki.mycbr.gui.csvimporter.wizard.OpenCSVImporterWizard"
id="de.dfki.mycbr.gui.csvimporter.wizard.OpenCSVImporterWizard"
name="%command.name.13">
</command>
......@@ -255,11 +260,13 @@
id="de.dfki.mycbr.gui.project.list.FilterAction"
name="%command.name.16">
</command>
<!--
<command
defaultHandler="de.dfki.mycbr.gui.ie.lod.wizard.OpenScoobieLodWizard"
id="de.dfki.mycbr.scoobie.lod.wizard.OpenScoobieLodWizard"
name="%command.name.17">
</command>
-->
<command
id="de.dfki.mycbr.gui.function.list.NewFunctionAction"
name="%command.name.18">
......@@ -294,6 +301,10 @@
id="de.dfki.mycbr.gui.OpenRecent"
name="%command.name.25">
</command>
<command
id="de.dfki.mycbr.gui.project.list.NewCasebaseExport"
name="%command.name.26">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
......@@ -408,6 +419,22 @@
style="push">
</command>
</menu>
<menu
id="export"
label="%menu.label.2">
<command
commandId="de.dfki.mycbr.gui.csvimporter.wizard.OpenCSVImporterWizard"
icon="icons/import.png"
label="%command.label.22"
style="push">
</command>
<command
commandId="de.dfki.mycbr.gui.project.list.NewCasebaseExport"
icon="icons/export.png"
label="%command.label.21"
style="push">
</command>
</menu>
<menu
id="help"
label="%menu.label.1">
......@@ -447,6 +474,7 @@
</with>
</visibleWhen>
</command>
<!--
<command
commandId="de.dfki.mycbr.scoobie.lod.wizard.OpenScoobieLodWizard"
id="de.dfki.mycbr.gui.project.list.ProjectListView.context"
......@@ -461,6 +489,7 @@
</with>
</visibleWhen>
</command>
-->
<command
commandId="de.dfki.mycbr.gui.csvimporter.wizard.OpenCSVImporterWizard"
id="de.dfki.mycbr.gui.project.list.ProjectListView.context"
......@@ -475,6 +504,20 @@
</with>
</visibleWhen>
</command>
<command
commandId="de.dfki.mycbr.gui.project.list.NewCasebaseExport"
id="de.dfki.mycbr.gui.project.list.ProjectListView.context"
style="push">
<visibleWhen>
<with variable="selection">
<count value="1"/>
<iterate ifEmpty="false">
<instanceof value="de.dfki.mycbr.core.model.Concept"/>
</iterate>
</with>
</visibleWhen>
</command>
<command
commandId="de.dfki.mycbr.gui.project.list.EditInheritanceFunctionHandler"
id="de.dfki.mycbr.gui.project.list.ProjectListView.context"
......@@ -577,10 +620,10 @@
point="org.eclipse.core.runtime.products">
<product
application="de.dfki.mycbr.gui.application"
name="myCBR">
name="myCBR workbench">
<property
name="appName"
value="myCBR">
value="myCBR workbench">
</property>
<property
name="aboutImage"
......@@ -727,5 +770,55 @@
</with>
</activeWhen>
</handler>
<handler
class="de.dfki.mycbr.gui.project.list.NewCasebaseExportHandler"
commandId="de.dfki.mycbr.gui.project.list.NewCasebaseExport">
<activeWhen>
<with
variable="selection">
<count
value="1">
</count>
<iterate
ifEmpty="false">
<and>
<instanceof
value="de.dfki.mycbr.core.model.Concept">
</instanceof>
<not>
<instanceof
value="de.dfki.mycbr.core.Project">
</instanceof>
</not>
</and>
</iterate>
</with>
</activeWhen>
</handler>
<handler
class="de.dfki.mycbr.gui.csvimporter.wizard.OpenCSVImporterWizard"
commandId="de.dfki.mycbr.gui.csvimporter.wizard.OpenCSVImporterWizard">
<activeWhen>
<with
variable="selection">
<count
value="1">
</count>
<iterate
ifEmpty="false">
<and>
<instanceof
value="de.dfki.mycbr.core.model.Concept">
</instanceof>
<not>
<instanceof
value="de.dfki.mycbr.core.Project">
</instanceof>
</not>
</and>
</iterate>
</with>
</activeWhen>
</handler>
</extension>
</plugin>
......@@ -6,58 +6,69 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
/**
* This class controls all aspects of the application's execution
*/
public class Application implements IApplication {
/* (non-Javadoc)
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
* IApplicationContext)
*/
public Object start(IApplicationContext context) {
Display display = PlatformUI.createDisplay();
try {
// MyCbrInterface.getInstance().load("/Users/fabian/code/myCBR/projects/UsedCarsFlat/used_cars_flat.zip");
// Project prj = MyCbrInterface.getInstance().load("/Users/fabian/code/myCBR/scoobie/recipes/recipes_CBR_SMF.XML");
// RDFExporter.save(prj);
//
// TextExtractionConfig config = new TextExtractionConfig(prj.getConceptByID("Recipe"));
// config.put("title", "/recipes/recipe/ti", true);
// config.put("ingredient_cheese", "/recipes/recipe/in", false);
// config.put("ingredient_fish", "/recipes/recipe/in", false);
// config.put("ingredient_meat", "/recipes/recipe/in", false);
// config.put("ingredient_pasta", "/recipes/recipe/in", false);
// config.put("ingredient_spices", "/recipes/recipe/in", false);
// config.put("ingredient_vegetables", "/recipes/recipe/in", false);
// config.put("preparation_steps", "/recipes/recipe/pr/step", false);
//
// ScoobieFile file = new ScoobieFile("/Users/fabian/code/myCBR/scoobie/recipes/recipesAdaptationChallenge_fixed_lowercase.xml");
//
// TextImporter importer = new TextImporter(prj.getConceptByID("Recipe"), config, file);
// importer.doImport();
// ScoobieInterface.getInstance().put(prj.getConceptByID("Recipe"), file, config);
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
// MyCbrInterface.getInstance().load("/Users/fabian/code/myCBR/projects/UsedCarsFlat/used_cars_flat.zip");
// Project prj =
// MyCbrInterface.getInstance().load("/Users/fabian/code/myCBR/scoobie/recipes/recipes_CBR_SMF.XML");
// RDFExporter.save(prj);
//
// TextExtractionConfig config = new
// TextExtractionConfig(prj.getConceptByID("Recipe"));
// config.put("title", "/recipes/recipe/ti", true);
// config.put("ingredient_cheese", "/recipes/recipe/in", false);
// config.put("ingredient_fish", "/recipes/recipe/in", false);
// config.put("ingredient_meat", "/recipes/recipe/in", false);
// config.put("ingredient_pasta", "/recipes/recipe/in", false);
// config.put("ingredient_spices", "/recipes/recipe/in", false);
// config.put("ingredient_vegetables", "/recipes/recipe/in", false);
// config.put("preparation_steps", "/recipes/recipe/pr/step",
// false);
//
// ScoobieFile file = new
// ScoobieFile("/Users/fabian/code/myCBR/scoobie/recipes/recipesAdaptationChallenge_fixed_lowercase.xml");
//
// TextImporter importer = new
// TextImporter(prj.getConceptByID("Recipe"), config, file);
// importer.doImport();
// ScoobieInterface.getInstance().put(prj.getConceptByID("Recipe"),
// file, config);
int returnCode = PlatformUI.createAndRunWorkbench(display,
new ApplicationWorkbenchAdvisor());
if (returnCode == PlatformUI.RETURN_RESTART) {
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
} finally {
display.dispose();
}
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.equinox.app.IApplication#stop()
*/
public void stop() {
// save properties
Properties.getInstance().save();
final IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench == null)
return;
......
......@@ -11,7 +11,8 @@ import org.eclipse.ui.application.WorkbenchWindowAdvisor;
public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
public ApplicationWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer configurer) {
super(configurer);
}
......@@ -29,6 +30,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
configurer.setShowProgressIndicator(true);
configurer.setShowPerspectiveBar(true);
IPreferenceStore apiStore = PlatformUI.getPreferenceStore();
apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR, IWorkbenchPreferenceConstants.TOP_RIGHT);
apiStore.setValue(IWorkbenchPreferenceConstants.DOCK_PERSPECTIVE_BAR,
IWorkbenchPreferenceConstants.TOP_RIGHT);
}
}
......@@ -28,7 +28,7 @@ public class Properties {
public List<String> getRecentProjects() {
return recentProjects;
}
public void addRecentProject(String recentProject) {
if (!hasRecentProject(recentProject)) {
recentProjects.add(recentProject);
......@@ -50,7 +50,7 @@ public class Properties {
String[] property = line.split("=");
if (property[0].equals(Property.RECENT_PROJECT.toString())) {
addRecentProject(property[1]);
}
}
line = bis.readLine();
}
is.close();
......@@ -89,7 +89,7 @@ public class Properties {
}
}
// TODO save filter!
// Close the output stream
out.close();
} catch (Exception e) {// Catch exception if any
......
......@@ -54,7 +54,8 @@ public class AttributeEditorInput implements IEditorInput {
return true;
}
if (obj instanceof AttributeEditorInput) {
return attribute.equals(((AttributeEditorInput) obj).getAttribute());
return attribute
.equals(((AttributeEditorInput) obj).getAttribute());
}
return false;
}
......
......@@ -16,7 +16,8 @@ public class AttributeFormEditor extends FormEditor {
private AttributeDesc attribute;
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
setSite(site);
setInput(input);
attribute = ((AttributeEditorInput) input).getAttribute();
......@@ -27,7 +28,7 @@ public class AttributeFormEditor extends FormEditor {
protected void addPages() {
try {
this.addPage(new GeneralPage(this));
if(attribute instanceof SymbolDesc) {
if (attribute instanceof SymbolDesc) {
this.addPage(new SymbolExplanationPage(this));
}
this.addPage(new ExplanationPage(this));
......@@ -48,7 +49,7 @@ public class AttributeFormEditor extends FormEditor {
public boolean isSaveAsAllowed() {
return false;
}
public AttributeDesc getAttribute() {
return attribute;
}
......
......@@ -21,23 +21,25 @@ public class CallAttributeEditor extends AbstractHandler implements IHandler {
// get the view
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
ProjectListView view = (ProjectListView) page.findView(ProjectListView.ID);
ProjectListView view = (ProjectListView) page
.findView(ProjectListView.ID);
// get the selection
ISelection selection = view.getSite().getSelectionProvider().getSelection();
if(selection != null && selection instanceof IStructuredSelection) {
ISelection selection = view.getSite().getSelectionProvider()
.getSelection();
if (selection != null && selection instanceof IStructuredSelection) {
Object obj = ((IStructuredSelection) selection).getFirstElement();
if(obj != null) {
if (obj != null) {
AttributeDesc attribute = (AttributeDesc) obj;
AttributeEditorInput input = new AttributeEditorInput(attribute);
try {
page.openEditor(input, AttributeFormEditor.ID);
} catch(PartInitException e) {
} catch (PartInitException e) {
e.printStackTrace();
}
}
}
return null;
}
......
......@@ -32,7 +32,7 @@ import de.dfki.mycbr.gui.attribute.editor.type.AttributeTypeEditor;
public class GeneralPage extends FormPage {
public static final String ID = "de.dfki.mycbr.gui.attribute.editor.GeneralPage";
Composite parent;
final StackLayout stackLayout = new StackLayout();
......@@ -43,10 +43,10 @@ public class GeneralPage extends FormPage {
private List<String> attributeTypes;
private AttributeTypeEditor typeEditor;
private ControlDecoration cdNameEmpty;
private ControlDecoration cdNameTaken;
public GeneralPage(FormEditor editor) {
super(editor, ID, "Attribute");
attribute = ((AttributeFormEditor) editor).getAttribute();
......@@ -57,7 +57,7 @@ public class GeneralPage extends FormPage {
managedForm.getForm().setText("Attribute");
initAttributeTypes();
findCurrentType();
this.parent = managedForm.getForm().getBody();
parent.setLayout(stackLayout);
refreshLayout();
......@@ -82,27 +82,35 @@ public class GeneralPage extends FormPage {
typeEditor = null;
for (String attrType : attributeTypes) {
if (attribute.getClass().getSimpleName().equals(attrType + "Desc")) {
Class<?> editorClass;
try {
editorClass = Class.forName("de.dfki.mycbr.gui.attribute.editor.type." + attrType + "AttributeEditor");
typeEditor = (AttributeTypeEditor) editorClass.newInstance();
Class<?> editorClass;
try {
editorClass = Class
.forName("de.dfki.mycbr.gui.attribute.editor.type."
+ attrType + "AttributeEditor");
typeEditor = (AttributeTypeEditor) editorClass
.newInstance();
typeEditor.init(attribute);
} catch (Exception ex) {
ex.printStackTrace();
}
} catch (Exception ex) {
ex.printStackTrace();
}
break;
}
}
}
private void refreshLayout() {
Composite composite = buildBaseComposite(parent);
if (typeEditor != null) {
typeEditor.buildComposite(composite);
} else {
Status status = new Status(IStatus.WARNING, "My Plug-in ID", 0,
"The type of this attribute is not supported at the moment. You can only edit the common fields.", null);
ErrorDialog.openError(Display.getCurrent().getActiveShell(), "myCBR Warning", "Warning", status);
Status status = new Status(
IStatus.WARNING,
"My Plug-in ID",
0,
"The type of this attribute is not supported at the moment. You can only edit the common fields.",
null);
ErrorDialog.openError(Display.getCurrent().getActiveShell(),
"myCBR Warning", "Warning", status);
}
stackLayout.topControl = composite;
fillModel();
......@@ -112,20 +120,23 @@ public class GeneralPage extends FormPage {
private Composite buildBaseComposite(Composite parent) {
Composite baseComposite = new Composite(parent, 0);
baseComposite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
baseComposite.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_WHITE));
// Name
Label lblName = new Label(baseComposite, SWT.NONE);
lblName.setText("Name");
txtName = new Text(baseComposite, SWT.BORDER);
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
cdNameEmpty = new ControlDecoration(txtName, SWT.LEFT | SWT.TOP);
cdNameEmpty.setDescriptionText("You have to enter a name.");
cdNameEmpty.setImage(fieldDecoration.getImage());
cdNameEmpty.hide();
cdNameTaken = new ControlDecoration(txtName, SWT.LEFT | SWT.TOP);
cdNameTaken.setDescriptionText("There is another attribute description with that name.");
cdNameTaken
.setDescriptionText("There is another attribute description with that name.");
cdNameTaken.setImage(fieldDecoration.getImage());
cdNameTaken.hide();
......@@ -135,19 +146,24 @@ public class GeneralPage extends FormPage {
txtType = new Text(baseComposite, SWT.BORDER | SWT.READ_ONLY);
txtType.setText(typeEditor.getName());
// Multiple
Label lblMultiple = new Label(baseComposite, SWT.NONE);
lblMultiple.setText("Multiple");
btnMultiple = new Button(baseComposite, SWT.CHECK);
Label shadow_sep_h = new Label(baseComposite, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL);
Label shadow_sep_h = new Label(baseComposite, SWT.SEPARATOR
| SWT.SHADOW_OUT | SWT.HORIZONTAL);
// Layout
GridLayoutFactory.fillDefaults().margins(5, 5).spacing(5, 3).numColumns(3).applyTo(baseComposite);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(2, 1).applyTo(txtName);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(2, 1).applyTo(txtType);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).span(2, 1).applyTo(btnMultiple);
GridLayoutFactory.fillDefaults().margins(5, 5).spacing(5, 3)
.numColumns(3).applyTo(baseComposite);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
.grab(true, false).span(2, 1).applyTo(txtName);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
.grab(true, false).span(2, 1).applyTo(txtType);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
.grab(true, false).span(2, 1).applyTo(btnMultiple);
GridDataFactory.fillDefaults().span(3, 1).applyTo(shadow_sep_h);
return baseComposite;
......@@ -156,7 +172,7 @@ public class GeneralPage extends FormPage {
private void fillModel() {
txtName.setText(attribute.getName());
btnMultiple.setSelection(attribute.isMultiple());
if (typeEditor != null) {
typeEditor.fillModel();
}
......@@ -166,7 +182,7 @@ public class GeneralPage extends FormPage {
txtName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
try {
if(!txtName.getText().isEmpty()) {
if (!txtName.getText().isEmpty()) {
attribute.setName(txtName.getText());
cdNameEmpty.hide();
cdNameTaken.hide();
......@@ -176,16 +192,34 @@ public class GeneralPage extends FormPage {
} catch (Exception e) {
cdNameTaken.show();
}
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
IHandlerService handlerService = (IHandlerService) getSite()
.getService(IHandlerService.class);
try {
handlerService.executeCommand("de.dfki.mycbr.gui.project.list.ProjectListRefreshHandler", null);
handlerService
.executeCommand(
"de.dfki.mycbr.gui.project.list.ProjectListRefreshHandler",
null);
} catch (Exception ex) {
throw new RuntimeException("de.dfki.mycbr.gui.project.list.ProjectListRefreshHandler not found");
throw new RuntimeException(
"de.dfki.mycbr.gui.project.list.ProjectListRefreshHandler not found");
}
setPartName(txtName.getText());
try {
if (!attribute.getOwner().getProject().getName()
.endsWith("_UNSAFED"))
attribute
.getOwner()
.getProject()
.setName(
attribute.getOwner().getProject()
.getName()
+ "_UNSAFED");