Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-10-06 17:19:18 -0400
committerkmoore2010-10-06 17:19:18 -0400
commitc7c47be801020d6b9e86625aed1c71b6c3b1b4fb (patch)
tree8dc75b80f33db8bb6eb1e7af108d04b8212b8dab
parenta9ebbbaf8354f15e921914d78d691e3bcb3240ae (diff)
downloadwebtools.dali-c7c47be801020d6b9e86625aed1c71b6c3b1b4fb.tar.gz
webtools.dali-c7c47be801020d6b9e86625aed1c71b6c3b1b4fb.tar.xz
webtools.dali-c7c47be801020d6b9e86625aed1c71b6c3b1b4fb.zip
326972 - Add ability to create an ORM mapping file from the 'Make Persistent' and 'New JPA Entity' wizards
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/plugin.xml4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties11
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizard.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizardPage.java109
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityClassWizardPage.java105
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizard.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizard.java31
11 files changed, 268 insertions, 96 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
index 3a91871fdc..9b14d600be 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.ui/plugin.xml
@@ -899,10 +899,6 @@
objectClass="org.eclipse.jdt.core.IJavaElement"
adaptable="true">
- <enablement>
- <test property="org.eclipse.jdt.core.inSourceFolder" value="true"/>
- </enablement>
-
<action
class="org.eclipse.jpt.ui.internal.actions.MakePersistentAction"
enablesFor="*"
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
index 1b72771a4b..c75210058f 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties
@@ -115,17 +115,18 @@ JpaFacetWizardPage_none=<None>
JpaLibraryProviderInstallPanel_includeLibraries=&Include libraries with this application
-JpaMakePersistentWizardPage_title=Make Persistent...
+JpaMakePersistentWizardPage_title=Make Persistent
JpaMakePersistentWizardPage_message=Make the selected Java classes persistent by selecting Java annotations or mapping file
JpaMakePersistentWizardPage_annotateInJavaRadioButton=Annotate in &Java
-JpaMakePersistentWizardPage_mappingFileRadioButton=Add to &ORM mapping file
-JpaMakePersistentWizardPage_mappingFileLabel=Mapping File:
+JpaMakePersistentWizardPage_mappingFileRadioButton=Add to &XML mapping file
+JpaMakePersistentWizardPage_mappingFileLink=<a>&Mapping file:</a>
JpaMakePersistentWizardPage_mappingFileBrowseButton=B&rowse...
JpaMakePersistentWizardPage_typeTableColumn=Type
JpaMakePersistentWizardPage_mappingTableColumn=Mapping
JpaMakePersistentWizardPage_listInPersistenceXmlCheckBox=&List in persistence.xml
JpaMakePersistentWizardPage_selectedTypesPersistentError=All selected types are already persistent
-JpaMakePersistentWizardPage_mappingFileDoesNotExistError=The ORM mapping file does not exist
+JpaMakePersistentWizardPage_mappingFileDoesNotExistError=The XML mapping file does not exist
+JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError=The XML mapping file is not listed in the persistence.xml
JpaPreferencesPage_Description=Expand the tree to edit preferences for a specific feature.
@@ -163,3 +164,5 @@ PersistenceItemLabelProviderFactory_persistenceLabel=Persistence
OverwriteConfirmerDialog_title=Overwrite Existing Class
OverwriteConfirmerDialog_text=Overwrite source code for the class ''{0}''?
+
+SelectJpaOrmMappingFileDialog_newButton=New...
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
index 06789e5b2c..3a15ba9c6b 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java
@@ -103,13 +103,14 @@ public class JptUiMessages {
public static String JpaMakePersistentWizardPage_message;
public static String JpaMakePersistentWizardPage_annotateInJavaRadioButton;
public static String JpaMakePersistentWizardPage_mappingFileRadioButton;
- public static String JpaMakePersistentWizardPage_mappingFileLabel;
+ public static String JpaMakePersistentWizardPage_mappingFileLink;
public static String JpaMakePersistentWizardPage_mappingFileBrowseButton;
public static String JpaMakePersistentWizardPage_typeTableColumn;
public static String JpaMakePersistentWizardPage_mappingTableColumn;
public static String JpaMakePersistentWizardPage_listInPersistenceXmlCheckBox;
public static String JpaMakePersistentWizardPage_selectedTypesPersistentError;
public static String JpaMakePersistentWizardPage_mappingFileDoesNotExistError;
+ public static String JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError;
public static String JpaStructureView_linkWithEditorDesc;
public static String JpaStructureView_linkWithEditorText;
public static String JpaStructureView_linkWithEditorTooltip;
@@ -145,6 +146,7 @@ public class JptUiMessages {
public static String JpaProblemSeveritiesPage_Ignore;
public static String JpaProblemSeveritiesPage_Info;
public static String JpaProblemSeveritiesPage_Warning;
+ public static String SelectJpaOrmMappingFileDialog_newButton;
private static final String BUNDLE_NAME = "jpt_ui"; //$NON-NLS-1$
private static final Class<?> BUNDLE_CLASS = JptUiMessages.class;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizard.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizard.java
index dafca92be9..3cf509659d 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizard.java
@@ -23,6 +23,7 @@ import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.ui.JptUiPlugin;
import org.eclipse.jpt.ui.internal.JptUiIcons;
+import org.eclipse.jpt.ui.internal.JptUiMessages;
public class JpaMakePersistentWizard extends Wizard {
@@ -39,7 +40,7 @@ public class JpaMakePersistentWizard extends Wizard {
super();
this.selectedTypes = selectedTypes;
this.resourceManager = new LocalResourceManager(JFaceResources.getResources());
- this.setWindowTitle("Make Persistent");
+ this.setWindowTitle(JptUiMessages.JpaMakePersistentWizardPage_title);
this.setDefaultPageImageDescriptor(JptUiPlugin.getImageDescriptor(JptUiIcons.ENTITY_WIZ_BANNER));
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizardPage.java
index be566c7131..3ba7579e9c 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/JpaMakePersistentWizardPage.java
@@ -9,9 +9,12 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.wizards;
+import java.io.File;
import java.io.IOException;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.ui.JavaElementComparator;
@@ -23,6 +26,7 @@ import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
@@ -34,10 +38,13 @@ import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JpaResourceType;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.MappingKeys;
+import org.eclipse.jpt.core.context.JpaRootContextNode;
import org.eclipse.jpt.core.context.PersistentType;
import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.core.context.orm.EntityMappings;
+import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.ui.JpaPlatformUi;
@@ -47,6 +54,7 @@ import org.eclipse.jpt.ui.internal.jface.XmlMappingFileViewerFilter;
import org.eclipse.jpt.ui.internal.platform.JpaPlatformUiRegistry;
import org.eclipse.jpt.ui.internal.utility.swt.SWTTools;
import org.eclipse.jpt.ui.internal.wizards.entity.EntityWizardMsg;
+import org.eclipse.jpt.ui.internal.wizards.orm.MappingFileWizard;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
@@ -57,6 +65,7 @@ import org.eclipse.jpt.utility.model.listener.PropertyChangeListener;
import org.eclipse.jpt.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.utility.model.value.WritablePropertyValueModel;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
@@ -64,7 +73,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.model.WorkbenchContentProvider;
@@ -211,8 +220,17 @@ public class JpaMakePersistentWizardPage extends WizardPage {
layout.marginLeft = 10;
composite.setLayout(layout);
- Label mappingFileLabel = new Label(composite, SWT.None);
- mappingFileLabel.setText(JptUiMessages.JpaMakePersistentWizardPage_mappingFileLabel);
+ Link mappingFileLink = new Link(composite, SWT.LEFT);
+ mappingFileLink.setText(JptUiMessages.JpaMakePersistentWizardPage_mappingFileLink);
+ mappingFileLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ mappingFileLink.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ openNewMappingFileWizard();
+ }
+ }
+ );
Text mappingFileText = this.createText(composite, 1);
SWTTools.bind(this.mappingFileModel, mappingFileText);
@@ -241,7 +259,7 @@ public class JpaMakePersistentWizardPage extends WizardPage {
}
});
- SWTTools.controlEnabledState(new ListInOrmMappingFileModel(this.annotateInJavaModel), mappingFileLabel, mappingFileText, browseButton);
+ SWTTools.controlEnabledState(new ListInOrmMappingFileModel(this.annotateInJavaModel), mappingFileLink, mappingFileText, browseButton);
return composite;
}
@@ -259,7 +277,7 @@ public class JpaMakePersistentWizardPage extends WizardPage {
ViewerFilter filter = buildMappingFileDialogViewerFilter();
ITreeContentProvider contentProvider = new WorkbenchContentProvider();
ILabelProvider labelProvider = new WorkbenchLabelProvider();
- SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), labelProvider, contentProvider);
+ SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), this.jpaProject.getProject(), labelProvider, contentProvider);
dialog.setTitle(EntityWizardMsg.MAPPING_XML_TITLE);
dialog.setMessage(EntityWizardMsg.CHOOSE_MAPPING_XML_MESSAGE);
dialog.addFilter(filter);
@@ -273,7 +291,8 @@ public class JpaMakePersistentWizardPage extends WizardPage {
}
if (dialog.open() == Window.OK) {
this.mappingFileModel.setValue(dialog.getChosenName());
- //this.model.validateProperty(IEntityDataModelProperties.XML_NAME);
+ //have to validate in case the file name did not actually change, but the xml file was created
+ validate();
}
}
@@ -285,6 +304,17 @@ public class JpaMakePersistentWizardPage extends WizardPage {
return new XmlMappingFileViewerFilter(this.jpaProject);
}
+ private void openNewMappingFileWizard() {
+ IPath path = MappingFileWizard.createNewMappingFile(
+ new StructuredSelection(this.jpaProject.getProject()),
+ getMappingFileName());
+ if (path != null) {
+ this.mappingFileModel.setValue(path.toString());
+ //have to validate in case the file name did not actually change, but the xml file was created
+ this.validate();
+ }
+ }
+
protected void createTypeTableColumn() {
TableViewerColumn column = new TableViewerColumn(this.classTableViewer, SWT.NONE);
column.getColumn().setWidth(200);
@@ -403,8 +433,14 @@ public class JpaMakePersistentWizardPage extends WizardPage {
if (this.selectedTypes.length == 0) {
errorMessage = JptUiMessages.JpaMakePersistentWizardPage_selectedTypesPersistentError;
}
- else if (this.isAddToOrmMappingFile() && getOrmXmlResource() == null) {
- errorMessage = JptUiMessages.JpaMakePersistentWizardPage_mappingFileDoesNotExistError;
+ else if (this.isAddToOrmMappingFile()) {
+ JpaXmlResource ormXmlResource = getOrmXmlResource();
+ if (ormXmlResource == null) {
+ errorMessage = JptUiMessages.JpaMakePersistentWizardPage_mappingFileDoesNotExistError;
+ }
+ else if (getJpaProject().getJpaFile(ormXmlResource.getFile()).rootStructureNodesSize() == 0) {
+ errorMessage = JptUiMessages.JpaMakePersistentWizardPage_mappingFileNotListedInPersistenceXmlError;
+ }
}
setErrorMessage(errorMessage);
setPageComplete(errorMessage == null);
@@ -433,6 +469,11 @@ public class JpaMakePersistentWizardPage extends WizardPage {
protected JpaXmlResource getOrmXmlResource() {
return getJpaProject().getMappingFileXmlResource(new Path(getMappingFileLocation()));
}
+
+ protected EntityMappings getEntityMappings() {
+ JpaXmlResource xmlResource = getOrmXmlResource();
+ return (EntityMappings) getJpaProject().getJpaFile(xmlResource.getFile()).rootStructureNodes().next();
+ }
protected boolean isListInPersistenceXml() {
return this.listInPersistenceXmlModel.getValue().booleanValue();
@@ -450,6 +491,10 @@ public class JpaMakePersistentWizardPage extends WizardPage {
return this.mappingFileModel.getValue();
}
+ protected String getMappingFileName() {
+ return new File(getMappingFileLocation()).getName();
+ }
+
private class Type {
private final IType jdtType;
@@ -480,7 +525,7 @@ public class JpaMakePersistentWizardPage extends WizardPage {
}
else {
JpaXmlResource ormXmlResource = getOrmXmlResource();
- final EntityMappings entityMappings = this.getEntityMappings();
+ final EntityMappings entityMappings = getEntityMappings();
ormXmlResource.modify(new Runnable() {
public void run() {
entityMappings.addPersistentType(Type.this.mappingKey, Type.this.jdtType.getFullyQualifiedName());
@@ -490,30 +535,6 @@ public class JpaMakePersistentWizardPage extends WizardPage {
return false;
}
-// private void addAnnotation() {
-// try {
-// jdtType.getCompilationUnit().becomeWorkingCopy(null);
-// getJavaResourcePersistentType().addAnnotation(getJavaTypeMappingDefinition(this.mappingKey).getAnnotationName());
-// }
-// catch (JavaModelException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-//
-// finally {
-// //discardWorkingCopy must be called every time becomeWorkingCopy is called.
-//// this.compilationUnit.getBuffer().setContents(doc.get());
-//// this.compilationUnit.commitWorkingCopy(true, null); // true="force"
-// try {
-// jdtType.getCompilationUnit().discardWorkingCopy();
-// }
-// catch (JavaModelException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }
-// }
-// }
-
protected Iterable<? extends MappingUiDefinition<? extends PersistentType, ?>> typeMappingUiDefinitions() {
return CollectionTools.iterable(getJpaPlatformUi().typeMappingUiDefinitions(jpaResourceType));
}
@@ -526,14 +547,24 @@ public class JpaMakePersistentWizardPage extends WizardPage {
return getJpaProject().getJavaResourcePersistentType(this.jdtType.getFullyQualifiedName());
}
- protected EntityMappings getEntityMappings() {
- JpaXmlResource xmlResource = getOrmXmlResource();
- return (EntityMappings) getJpaProject().getJpaFile(xmlResource.getFile()).rootStructureNodes().next();
- }
protected PersistenceUnit getPersistenceUnit() {
- //TODO getPersistence() can be null? or there might not be persistence units?
- return getJpaProject().getRootContextNode().getPersistenceXml().getPersistence().persistenceUnits().next();
+ Persistence p = this.getPersistence();
+ if (p == null) {
+ return null;
+ }
+ Iterator<PersistenceUnit> units = p.persistenceUnits();
+ return units.hasNext() ? units.next() : null;
+ }
+
+ protected Persistence getPersistence() {
+ PersistenceXml pxml = this.getPersistenceXml();
+ return (pxml == null) ? null : pxml.getPersistence();
+ }
+
+ protected PersistenceXml getPersistenceXml() {
+ JpaRootContextNode rcn = getJpaProject().getRootContextNode();
+ return (rcn == null) ? null : rcn.getPersistenceXml();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java
index 1eef3bd0a6..49db32f38c 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/SelectJpaOrmMappingFileDialog.java
@@ -12,14 +12,30 @@ package org.eclipse.jpt.ui.internal.wizards;
import java.io.File;
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.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.ui.JptUiPlugin;
+import org.eclipse.jpt.ui.internal.JptUiMessages;
+import org.eclipse.jpt.ui.internal.wizards.orm.MappingFileWizard;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
@@ -30,12 +46,48 @@ public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
private String xmlName = EMPTY;
+ private final IProject project;
+
+ private Label messageLabel;
+ private Tree treeWidget;
- public SelectJpaOrmMappingFileDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
- super(parent, labelProvider, contentProvider);
+ public SelectJpaOrmMappingFileDialog(Shell parent, IProject project, ILabelProvider labelProvider, ITreeContentProvider contentProvider) {
+ super(parent, labelProvider, contentProvider);
+ setAllowMultiple(false);
+ this.project = project;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ Button newButton = new Button(composite, SWT.PUSH);
+ newButton.setText(JptUiMessages.SelectJpaOrmMappingFileDialog_newButton);
+ GridData browseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_END);
+ newButton.setLayoutData(browseButtonData);
+ newButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ openNewMappingFileWizard();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+ return composite;
+ }
+
+ @Override
+ protected Label createMessageArea(Composite composite) {
+ this.messageLabel = super.createMessageArea(composite);
+ return this.messageLabel;
+ }
+
+ @Override
+ protected TreeViewer createTreeViewer(Composite parent) {
+ TreeViewer treeViewer = super.createTreeViewer(parent);
+ this.treeWidget = treeViewer.getTree();
+ return treeViewer;
}
-
-
/**
* @return the name of the alternative mapping XML
*/
@@ -79,4 +131,16 @@ public class SelectJpaOrmMappingFileDialog extends ElementTreeSelectionDialog
output = output.replace(File.separatorChar, SLASH);
return output;
}
+
+
+ private void openNewMappingFileWizard() {
+ IPath path = MappingFileWizard.createNewMappingFile(new StructuredSelection(this.project), null);
+ if (path != null) {
+ //these are disabled if the tree is empty when the dialog is created.
+ this.messageLabel.setEnabled(true);
+ this.treeWidget.setEnabled(true);
+ IFile file = JptCorePlugin.getPlatformFile(this.project, path);
+ getTreeViewer().setSelection(new StructuredSelection(file), true);
+ }
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityClassWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityClassWizardPage.java
index 501a707a52..5b3b489849 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityClassWizardPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityClassWizardPage.java
@@ -11,9 +11,11 @@
***********************************************************************/
package org.eclipse.jpt.ui.internal.wizards.entity;
+import java.io.File;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaProject;
@@ -22,6 +24,7 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.window.Window;
@@ -34,6 +37,7 @@ import org.eclipse.jpt.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.ui.internal.jface.XmlMappingFileViewerFilter;
import org.eclipse.jpt.ui.internal.wizards.SelectJpaOrmMappingFileDialog;
import org.eclipse.jpt.ui.internal.wizards.entity.data.model.IEntityDataModelProperties;
+import org.eclipse.jpt.ui.internal.wizards.orm.MappingFileWizard;
import org.eclipse.jpt.utility.internal.ArrayTools;
import org.eclipse.jst.j2ee.internal.common.operations.INewJavaClassDataModelProperties;
import org.eclipse.jst.j2ee.internal.plugin.J2EEUIMessages;
@@ -48,7 +52,7 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ISelectionStatusValidator;
@@ -72,7 +76,7 @@ public class EntityClassWizardPage
private Button entityButton;
private Button mapedAsSuperclassButton;
private Button inheritanceButton;
- private Label displayNameLabel;
+ private Link displayNameLink;
private Button xmlSupportButton;
private boolean isFirstCheck = true;
private Text ormXmlName;
@@ -93,6 +97,10 @@ public class EntityClassWizardPage
new String[] {IEntityDataModelProperties.XML_NAME, IEntityDataModelProperties.XML_SUPPORT});
}
+ private IProject getProject() {
+ return (IProject) getDataModel().getProperty(INewJavaClassDataModelProperties.PROJECT);
+ }
+
/* Create top level composite (class properties) and add the entity's specific inheritance group
* @see org.eclipse.jst.j2ee.internal.wizard.NewJavaClassWizardPage#createTopLevelComposite(org.eclipse.swt.widgets.Composite)
*/
@@ -102,7 +110,7 @@ public class EntityClassWizardPage
this.getHelpSystem().setHelp(composite, JpaHelpContextIds.NEW_JPA_ENTITY_ENTITY_CLASS);
createInheritanceControl(composite);
- inheritanceButton.addSelectionListener(new SelectionAdapter() {
+ this.inheritanceButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean isChecked = inheritanceButton.getSelection();
@@ -118,7 +126,7 @@ public class EntityClassWizardPage
}
});
createXMLstorageControl(composite);
- xmlSupportButton.addSelectionListener(new SelectionAdapter() {
+ this.xmlSupportButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean isChecked = xmlSupportButton.getSelection();
@@ -186,9 +194,9 @@ public class EntityClassWizardPage
*/
private void createInheritanceControl(Composite parent) {
Group group = createGroup(parent, EntityWizardMsg.INHERITANCE_GROUP);
- entityButton = createRadioButton(group, EntityWizardMsg.ENTITY, IEntityDataModelProperties.ENTITY);
- mapedAsSuperclassButton = createRadioButton(group, EntityWizardMsg.MAPPED_AS_SUPERCLASS, IEntityDataModelProperties.MAPPED_AS_SUPERCLASS);
- inheritanceButton = createCheckButton(group, GridData.HORIZONTAL_ALIGN_FILL, 1/*horizontal span*/, EntityWizardMsg.INHERITANCE_CHECK_BOX, IEntityDataModelProperties.INHERITANCE);
+ this.entityButton = createRadioButton(group, EntityWizardMsg.ENTITY, IEntityDataModelProperties.ENTITY);
+ this.mapedAsSuperclassButton = createRadioButton(group, EntityWizardMsg.MAPPED_AS_SUPERCLASS, IEntityDataModelProperties.MAPPED_AS_SUPERCLASS);
+ this.inheritanceButton = createCheckButton(group, GridData.HORIZONTAL_ALIGN_FILL, 1/*horizontal span*/, EntityWizardMsg.INHERITANCE_CHECK_BOX, IEntityDataModelProperties.INHERITANCE);
createComboBox(group, IEntityDataModelProperties.INHERITANCE_STRATEGY);
}
@@ -198,10 +206,10 @@ public class EntityClassWizardPage
*/
private void createXMLstorageControl(Composite parent) {
Group group = createGroup(parent, EntityWizardMsg.XML_STORAGE_GROUP);
- xmlSupportButton = createCheckButton(group, GridData.FILL_HORIZONTAL, 3/*horizontal span*/, EntityWizardMsg.XML_SUPPORT, IEntityDataModelProperties.XML_SUPPORT);
+ this.xmlSupportButton = createCheckButton(group, GridData.FILL_HORIZONTAL, 3/*horizontal span*/, EntityWizardMsg.XML_SUPPORT, IEntityDataModelProperties.XML_SUPPORT);
createBrowseGroup(group, EntityWizardMsg.CHOOSE_XML, IEntityDataModelProperties.XML_NAME);
- ormXmlName.setEnabled(false);
- browseButton.setEnabled(false);
+ this.ormXmlName.setEnabled(false);
+ this.browseButton.setEnabled(false);
}
/**
@@ -232,7 +240,7 @@ public class EntityClassWizardPage
groupGridData.horizontalSpan = 3;
button.setLayoutData(groupGridData);
button.setText(text);
- synchHelper.synchRadio(button, property, /*dependentControls*/ null);
+ this.synchHelper.synchRadio(button, property, /*dependentControls*/ null);
return button;
}
@@ -249,7 +257,7 @@ public class EntityClassWizardPage
groupGridData.horizontalSpan = horizontalSpan;
button.setLayoutData(groupGridData);
button.setText(text);
- synchHelper.synchCheckbox(button, property, /*dependentControls*/ null);
+ this.synchHelper.synchCheckbox(button, property, /*dependentControls*/ null);
return button;
}
@@ -260,14 +268,14 @@ public class EntityClassWizardPage
* @return
*/
private Combo createComboBox(Composite parent, String property) {
- inheritanceStrategyCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
+ this.inheritanceStrategyCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL);
groupGridData.horizontalSpan = 2;
- inheritanceStrategyCombo.setLayoutData(groupGridData);
- inheritanceStrategyCombo.setItems(INHERITANCE_STRATEGIES);
- synchHelper.synchCombo(inheritanceStrategyCombo, property, /*dependentControls*/ null);
- inheritanceStrategyCombo.setEnabled(false);
- return inheritanceStrategyCombo;
+ this.inheritanceStrategyCombo.setLayoutData(groupGridData);
+ this.inheritanceStrategyCombo.setItems(INHERITANCE_STRATEGIES);
+ this.synchHelper.synchCombo(this.inheritanceStrategyCombo, property, /*dependentControls*/ null);
+ this.inheritanceStrategyCombo.setEnabled(false);
+ return this.inheritanceStrategyCombo;
}
@@ -282,37 +290,62 @@ public class EntityClassWizardPage
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayout(new GridLayout(3, false));
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- displayNameLabel = new Label(composite, SWT.LEFT);
- displayNameLabel.setText(label);
- displayNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- ormXmlName = new Text(composite, SWT.SINGLE | SWT.BORDER);
- ormXmlName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- browseButton = new Button(composite, SWT.PUSH);
- browseButton.setText(EntityWizardMsg.BROWSE_BUTTON_LABEL);
+
+ this.displayNameLink = new Link(composite, SWT.LEFT);
+ this.displayNameLink.setText(label);
+ this.displayNameLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+ this.displayNameLink.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ openNewMappingFileWizard();
+ }
+ }
+ );
+
+ this.ormXmlName = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ this.ormXmlName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.browseButton = new Button(composite, SWT.PUSH);
+ this.browseButton.setText(EntityWizardMsg.BROWSE_BUTTON_LABEL);
GridData browseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
browseButtonData.horizontalSpan = 1;
- browseButton.setLayoutData(browseButtonData);
- browseButton.addSelectionListener(new SelectionListener() {
+ this.browseButton.setLayoutData(browseButtonData);
+ this.browseButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
handleChooseXmlButtonPressed();
}
public void widgetDefaultSelected(SelectionEvent e) {
- // Do nothing
+ widgetSelected(e);
}
});
- synchHelper.synchText(ormXmlName, property, /*dependentControls*/null);
+ this.synchHelper.synchText(this.ormXmlName, property, /*dependentControls*/null);
enableMappingXMLChooseGroup(false);
}
+
+ private void openNewMappingFileWizard() {
+ IProject project = getProject();
+ IPath path = MappingFileWizard.createNewMappingFile(new StructuredSelection(project), getMappingFileName());
+ if (path != null) {
+ this.model.setProperty(IEntityDataModelProperties.XML_NAME, path.toString());
+ //have to validate in case the file name did not actually change, but the xml file was created
+ validatePage();
+ }
+ }
+ protected String getMappingFileName() {
+ String mappingFileLocation = this.model.getStringProperty(IEntityDataModelProperties.XML_NAME);
+ return new File(mappingFileLocation).getName();
+ }
+
/**
* Process browsing when the Browse... button have been pressed. Allow choosing of
* XML for entity mapping registration
*
*/
private void handleChooseXmlButtonPressed() {
- IProject project = (IProject) getDataModel().getProperty(INewJavaClassDataModelProperties.PROJECT);
+ IProject project = getProject();
if (project == null) {
return;
}
@@ -320,7 +353,7 @@ public class EntityClassWizardPage
ViewerFilter filter = getDialogViewerFilter(jpaProject);
ITreeContentProvider contentProvider = new WorkbenchContentProvider();
ILabelProvider labelProvider = new WorkbenchLabelProvider();
- SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), labelProvider, contentProvider);
+ SelectJpaOrmMappingFileDialog dialog = new SelectJpaOrmMappingFileDialog(getShell(), project, labelProvider, contentProvider);
dialog.setTitle(EntityWizardMsg.MAPPING_XML_TITLE);
dialog.setMessage(EntityWizardMsg.CHOOSE_MAPPING_XML_MESSAGE);
dialog.addFilter(filter);
@@ -334,8 +367,7 @@ public class EntityClassWizardPage
dialog.setInitialSelection(initialSelection);
}
if (dialog.open() == Window.OK) {
- this.ormXmlName.setText(dialog.getChosenName());
- this.model.validateProperty(IEntityDataModelProperties.XML_NAME);
+ this.model.setProperty(IEntityDataModelProperties.XML_NAME, dialog.getChosenName());
}
}
@@ -348,10 +380,9 @@ public class EntityClassWizardPage
}
private void enableMappingXMLChooseGroup(boolean enabled) {
- displayNameLabel.setEnabled(enabled);
- ormXmlName.setEnabled(enabled);
- browseButton.setEnabled(enabled);
-
+ this.displayNameLink.setEnabled(enabled);
+ this.ormXmlName.setEnabled(enabled);
+ this.browseButton.setEnabled(enabled);
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizard.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizard.java
index 6a471d13fb..c21b3573ae 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizard.java
@@ -41,6 +41,8 @@ public class EntityWizard
protected String initialProjectName;
+ protected IStructuredSelection selection;
+
/**
* Constructs the Entity wizard
* @param model the data model
@@ -74,6 +76,10 @@ public class EntityWizard
addPage(page2);
}
+ public IStructuredSelection getSelection() {
+ return this.selection;
+ }
+
/* Return the default data model provider (EntityDataModelProvider in our case)
* @see org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard#getDefaultProvider()
*/
@@ -134,6 +140,7 @@ public class EntityWizard
* @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
this.initialProjectName = extractProjectName(selection);
getDataModel();
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java
index 38c17bff37..d05a45a9ae 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityWizardMsg.java
@@ -37,6 +37,7 @@ public class EntityWizardMsg extends NLS {
public static String MAPPING_XML_TITLE;
public static String XML_NAME_TITLE;
public static String INVALID_XML_NAME;
+ public static String MAPPING_FILE_NOT_LISTED_ERROR;
public static String CHOOSE_MAPPING_XML_MESSAGE;
public static String TYPE_DIALOG_TITLE;
public static String TYPE_DIALOG_DESCRIPTION;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java
index 02f10f9d6f..7473cf8aaa 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java
@@ -30,9 +30,9 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
import org.eclipse.jpt.core.JpaFacet;
-import org.eclipse.jpt.core.JpaFile;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JptCorePlugin;
+import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
import org.eclipse.jpt.ui.JptUiPlugin;
import org.eclipse.jpt.ui.internal.wizards.entity.EntityWizardMsg;
import org.eclipse.jpt.ui.internal.wizards.entity.data.operation.NewEntityClassOperation;
@@ -273,19 +273,26 @@ public class EntityDataModelProvider extends NewJavaClassDataModelProvider imple
if (getBooleanProperty(XML_SUPPORT)) {
String projectName = this.model.getStringProperty(PROJECT_NAME);
IProject project = ProjectUtilities.getProject(projectName);
- JpaFile jpaFile = null;
if (project != null && ! StringTools.stringIsEmpty(xmlName)) {
- //TODO need to check content type as well since user can type in a file name, should have a different error message for invalid content type
- jpaFile = JptCorePlugin.getJpaFile(project, new Path(xmlName));
- if (jpaFile == null) {
+ JpaXmlResource ormXmlResource = getOrmXmlResource(xmlName);
+ if (ormXmlResource == null) {
return new Status(
IStatus.ERROR, JptUiPlugin.PLUGIN_ID,
EntityWizardMsg.INVALID_XML_NAME);
}
+ else if (getTargetJpaProject().getJpaFile(ormXmlResource.getFile()).rootStructureNodesSize() == 0) {
+ return new Status(
+ IStatus.ERROR, JptUiPlugin.PLUGIN_ID,
+ EntityWizardMsg.MAPPING_FILE_NOT_LISTED_ERROR);
+ }
}
}
return Status.OK_STATUS;
}
+
+ protected JpaXmlResource getOrmXmlResource(String xmlName) {
+ return getTargetJpaProject().getMappingFileXmlResource(new Path(xmlName));
+ }
/**
* This method is intended for internal use only. It will be used to validate the entity fields
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizard.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizard.java
index fcd635ca1e..5f4e3c2215 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizard.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizard.java
@@ -27,8 +27,10 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jpt.core.JpaFacet;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.JpaContextNode;
@@ -38,6 +40,8 @@ import org.eclipse.jpt.core.internal.utility.PlatformTools;
import org.eclipse.jpt.ui.JptUiPlugin;
import org.eclipse.jpt.ui.internal.JptUiIcons;
import org.eclipse.jpt.ui.internal.JptUiMessages;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
@@ -188,7 +192,7 @@ public class MappingFileWizard extends Wizard
return this.firstPage.isPageComplete() && getDataModel().isValid();
}
- protected IDataModel getDataModel() {
+ public IDataModel getDataModel() {
if (this.dataModel == null) {
this.dataModel = DataModelFactory.createDataModel(getDefaultProvider());
}
@@ -315,4 +319,29 @@ public class MappingFileWizard extends Wizard
super.dispose();
getDataModel().dispose();
}
+
+ public static IPath createNewMappingFile(IStructuredSelection selection, String xmlFileName) {
+ MappingFileWizard wizard = new MappingFileWizard(DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider()));
+ wizard.getDataModel().setProperty(FILE_NAME, xmlFileName);
+ wizard.init(PlatformUI.getWorkbench(), selection);
+ WizardDialog dialog = new WizardDialog(getCurrentShell(), wizard);
+ dialog.create();
+ if (dialog.open() == Window.OK) {
+ IPath containerPath = (IPath) wizard.getDataModel().getProperty(CONTAINER_PATH);
+ String fileName = wizard.getDataModel().getStringProperty(FILE_NAME);
+ IContainer container = PlatformTools.getContainer(containerPath);
+ IPath filePath = container.getFullPath().append(fileName);
+ IProject project = container.getProject();
+ IPath runtimePath = JptCorePlugin.getResourceLocator(project).getRuntimePath(project, filePath);
+
+ return runtimePath;
+ }
+ return null;
+ }
+
+ private static Shell getCurrentShell() {
+ return Display.getCurrent().getActiveShell();
+ }
+
+
}

Back to the top