Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-07-30 18:32:01 +0000
committerpfullbright2010-07-30 18:32:01 +0000
commit1b54c142e7fec9ac5b8d4dab2d04d2929c6b0a81 (patch)
treee07f20e2d0cce10fdeccc5781ceeaec292f17f8f /jpa/plugins/org.eclipse.jpt.ui
parent4150fda15c5f63e3cf7852e7840189a1352355e3 (diff)
downloadwebtools.dali-1b54c142e7fec9ac5b8d4dab2d04d2929c6b0a81.tar.gz
webtools.dali-1b54c142e7fec9ac5b8d4dab2d04d2929c6b0a81.tar.xz
webtools.dali-1b54c142e7fec9ac5b8d4dab2d04d2929c6b0a81.zip
added ResourceLocator implementation
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.ui')
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui.properties6
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_persistence.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiMessages.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/persistence/details/ArchiveFileSelectionDialog.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/EntityClassWizardPage.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/EntityDataModelProvider.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileOptionsWizardPage.java125
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizard.java360
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizardPage.java283
12 files changed, 423 insertions, 459 deletions
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 304aacf4ac..e332ed55c3 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
@@ -113,8 +113,10 @@ JpaProblemSeveritiesPage_Info=Info
JpaProblemSeveritiesPage_Warning=Warning
MappingFileWizard_title=New Mapping File
-MappingFileWizardPage_title=Mapping file
-MappingFileWizardPage_desc=Specify mapping file location and properties
+MappingFileWizardPage_newFile_title=Mapping file
+MappingFileWizardPage_newFile_desc=Specify mapping file name and location
+MappingFileWizardPage_options_title=Mapping file
+MappingFileWizardPage_options_desc=Specify mapping file options
MappingFileWizardPage_projectLabel=&Project:
MappingFileWizardPage_sourceFolderLabel=Source fol&der:
MappingFileWizardPage_filePathLabel=File pat&h:
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_persistence.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_persistence.properties
index ae091e70b9..5fe073792b 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_persistence.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_persistence.properties
@@ -11,7 +11,7 @@
Boolean_False=False
Boolean_True=True
-ArchiveFileSelectionDialog_jarPathHelpLabel=The correct path to the JAR file selected will vary on your deployment environment. You may alter it here to correctly reflect your particular environment.
+ArchiveFileSelectionDialog_jarPathHelpLabel=The correct path to the JAR file selected will vary on your runtime environment. You may alter it here to correctly reflect your particular environment.
ArchiveFileSelectionDialog_jarPathLabel=JAR file path:
PersistenceEditor_page_help=Help
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 2d7c45f46a..d5b09ae423 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
@@ -97,8 +97,10 @@ public class JptUiMessages {
public static String JpaStructureView_structureNotAvailable;
public static String JpaStructureView_numItemsSelected;
public static String MappingFileWizard_title;
- public static String MappingFileWizardPage_title;
- public static String MappingFileWizardPage_desc;
+ public static String MappingFileWizardPage_newFile_title;
+ public static String MappingFileWizardPage_newFile_desc;
+ public static String MappingFileWizardPage_options_title;
+ public static String MappingFileWizardPage_options_desc;
public static String MappingFileWizardPage_projectLabel;
public static String MappingFileWizardPage_sourceFolderLabel;
public static String MappingFileWizardPage_filePathLabel;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/persistence/details/ArchiveFileSelectionDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/persistence/details/ArchiveFileSelectionDialog.java
index 1061c2d3ce..66cc4b6423 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/persistence/details/ArchiveFileSelectionDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/persistence/details/ArchiveFileSelectionDialog.java
@@ -215,7 +215,7 @@ public class ArchiveFileSelectionDialog
protected String calculatePersistenceRootRelativePath(IVirtualFile vFile) {
IProject project = vFile.getProject();
- IPath puRootPath = JptCorePlugin.getJarDeploymentRootPath(project);
+ IPath puRootPath = JptCorePlugin.getJarRuntimeRootPath(project);
IPath path = vFile.getRuntimePath().makeRelativeTo(puRootPath);
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 8fa052bc14..b7a9505797 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
@@ -1,5 +1,5 @@
/***********************************************************************
- * Copyright (c) 2008, 2009 by SAP AG, Walldorf.
+ * Copyright (c) 2008, 2010 by SAP AG, Walldorf.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,13 +12,13 @@
package org.eclipse.jpt.ui.internal.wizards.entity;
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.CoreException;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -126,7 +126,7 @@ public class EntityClassWizardPage extends NewJavaClassWizardPage{
boolean isChecked = xmlSupportButton.getSelection();
enableMappingXMLChooseGroup(isChecked);
if (isFirstCheck) {
- ormXmlName.setText(JptCorePlugin.DEFAULT_ORM_XML_FILE_PATH);
+ ormXmlName.setText(JptCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString());
isFirstCheck = false;
}
}
@@ -280,7 +280,7 @@ public class EntityClassWizardPage extends NewJavaClassWizardPage{
dialog.addFilter(filter);
String ormFileName = this.ormXmlName.getText();
- JpaXmlResource resource = jpaProject.getMappingFileXmlResource(ormFileName);
+ JpaXmlResource resource = jpaProject.getMappingFileXmlResource(new Path(ormFileName));
IFile initialSelection = (resource != null) ? resource.getFile() : null;
dialog.setInput(project);
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java
index 5937f91978..537fe9db2a 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/model/CreateEntityTemplateModel.java
@@ -1,5 +1,5 @@
/***********************************************************************
- * Copyright (c) 2008 by SAP AG, Walldorf.
+ * Copyright (c) 2008, 2010 by SAP AG, Walldorf.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -243,7 +243,7 @@ public class CreateEntityTemplateModel {
if (getMappingXMLName().equals(IEntityDataModelProperties.EMPTY_STRING)) {
return true;
}
- return getMappingXMLName().equals(JptCorePlugin.getDefaultOrmXmlDeploymentURI(getProject()));
+ return getMappingXMLName().equals(JptCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString());
}
public String getMappingXMLName() {
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 60d9ec9d48..cad057b9b6 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
@@ -1,5 +1,5 @@
/***********************************************************************
- * Copyright (c) 2008, 2009 by SAP AG, Walldorf.
+ * Copyright (c) 2008, 2010 by SAP AG, Walldorf.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,13 +11,12 @@
***********************************************************************/
package org.eclipse.jpt.ui.internal.wizards.entity.data.model;
-import com.ibm.icu.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
@@ -38,6 +37,7 @@ import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin;
+import com.ibm.icu.text.MessageFormat;
public class EntityDataModelProvider extends NewJavaClassDataModelProvider implements IEntityDataModelProperties{
@@ -189,7 +189,7 @@ public class EntityDataModelProvider extends NewJavaClassDataModelProvider imple
IProject project = ProjectUtilities.getProject(projectName);
if (project != null) {
//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 jpaFile = JptCorePlugin.getJpaFile(project, xmlName);
+ JpaFile jpaFile = JptCorePlugin.getJpaFile(project, new Path(xmlName));
if (jpaFile == null) {
return new Status(
IStatus.ERROR, JptUiPlugin.PLUGIN_ID,
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java
index 904ea25602..8fcdd0351a 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/entity/data/operation/NewEntityClassOperation.java
@@ -428,7 +428,7 @@ public class NewEntityClassOperation extends AbstractDataModelOperation {
if (model.isMappingXMLDefault()) {
return JptCorePlugin.getJpaProject(project).getDefaultOrmXmlResource();
}
- return JptCorePlugin.getJpaProject(project).getMappingFileXmlResource(model.getMappingXMLName());
+ return JptCorePlugin.getJpaProject(project).getMappingFileXmlResource(new Path(model.getMappingXMLName()));
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java
new file mode 100644
index 0000000000..78400dece1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileNewFileWizardPage.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.wizards.orm;
+
+import static org.eclipse.jpt.core.internal.operations.JpaFileCreationDataModelProperties.*;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+public class MappingFileNewFileWizardPage
+ extends WizardNewFileCreationPage {
+
+ protected IDataModel dataModel;
+
+
+ public MappingFileNewFileWizardPage(
+ String pageName, IStructuredSelection selection, IDataModel dataModel,
+ String title, String description) {
+
+ super(pageName, selection);
+ init(dataModel);
+ setTitle(title);
+ setDescription(description);
+ }
+
+
+ protected void init(IDataModel dataModel) {
+ this.dataModel = dataModel;
+ IPath containerPath = (IPath) this.dataModel.getProperty(CONTAINER_PATH);
+ if (containerPath != null) {
+ setContainerFullPath(containerPath);
+ }
+ String fileName = (String) this.dataModel.getProperty(FILE_NAME);
+ if (fileName != null) {
+ setFileName(fileName);
+ }
+ }
+
+ @Override
+ protected boolean validatePage() {
+ this.dataModel.setProperty(CONTAINER_PATH, getContainerFullPath());
+ this.dataModel.setProperty(FILE_NAME, getFileName());
+
+ boolean valid = super.validatePage();
+ if (! valid) {
+ return valid;
+ }
+
+ IStatus validationStatus = this.dataModel.validateProperty(CONTAINER_PATH);
+ if (validationStatus.isOK()) {
+ validationStatus = this.dataModel.validateProperty(FILE_NAME);
+ }
+ if (validationStatus.isOK()) {
+ setErrorMessage(null);
+ return true;
+ }
+ else if (validationStatus.getSeverity() == IStatus.WARNING) {
+ setErrorMessage(null);
+ setMessage(validationStatus.getMessage(), IStatus.WARNING);
+ return true;
+ }
+ else {
+ setErrorMessage(validationStatus.getMessage());
+ return false;
+ }
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileOptionsWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileOptionsWizardPage.java
new file mode 100644
index 0000000000..833890b8e5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileOptionsWizardPage.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 Oracle.
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.ui.internal.wizards.orm;
+
+import static org.eclipse.jpt.core.internal.operations.JpaFileCreationDataModelProperties.*;
+import static org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProperties.*;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jpt.ui.internal.JptUiMessages;
+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.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
+
+public class MappingFileOptionsWizardPage
+ extends DataModelWizardPage {
+
+ private Label accessLabel;
+
+ private Combo accessCombo;
+
+ private Button addToPersistenceUnitButton;
+
+ private Label persistenceUnitLabel;
+
+ private Combo persistenceUnitCombo;
+
+
+ public MappingFileOptionsWizardPage(
+ String pageName, IDataModel dataModel,
+ String title, String description) {
+
+ super(dataModel, pageName);
+ setTitle(title);
+ setDescription(description);
+ setPageComplete(false);
+ }
+
+
+ @Override
+ protected String[] getValidationPropertyNames() {
+ return new String[] {
+ CONTAINER_PATH,
+ FILE_NAME,
+ DEFAULT_ACCESS,
+ ADD_TO_PERSISTENCE_UNIT,
+ PERSISTENCE_UNIT
+ };
+ }
+
+ @Override
+ protected Composite createTopLevelComposite(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ composite.setLayout(layout);
+ GridData data = new GridData();
+ data.verticalAlignment = GridData.FILL;
+ data.horizontalAlignment = GridData.FILL;
+ composite.setLayoutData(data);
+
+ this.accessLabel = new Label(composite, SWT.NONE);
+ this.accessLabel.setText(JptUiMessages.MappingFileWizardPage_accessLabel);
+ data = new GridData();
+ this.accessLabel.setLayoutData(data);
+
+ this.accessCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 1;
+ data.grabExcessHorizontalSpace = true;
+ this.accessCombo.setLayoutData(data);
+ this.synchHelper.synchCombo(this.accessCombo, DEFAULT_ACCESS, null);
+ new Label(composite, SWT.NONE);
+
+ this.addToPersistenceUnitButton = new Button(composite, SWT.CHECK | SWT.BEGINNING);
+ this.addToPersistenceUnitButton.setText(JptUiMessages.MappingFileWizardPage_addToPersistenceUnitButton);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 3;
+ data.verticalIndent = 10;
+ this.addToPersistenceUnitButton.setLayoutData(data);
+ this.synchHelper.synchCheckbox(this.addToPersistenceUnitButton, ADD_TO_PERSISTENCE_UNIT, null);
+
+ this.persistenceUnitLabel = new Label(composite, SWT.NONE);
+ this.persistenceUnitLabel.setText(JptUiMessages.MappingFileWizardPage_persistenceUnitLabel);
+ data = new GridData();
+ data.horizontalIndent = 10;
+ this.persistenceUnitLabel.setLayoutData(data);
+ this.persistenceUnitLabel.setEnabled(false);
+ this.addToPersistenceUnitButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ persistenceUnitLabel.setEnabled(addToPersistenceUnitButton.getSelection());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {/*not called*/}
+ });
+
+ this.persistenceUnitCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan = 1;
+ data.grabExcessHorizontalSpace = true;
+ this.persistenceUnitCombo.setLayoutData(data);
+ this.synchHelper.synchCombo(this.persistenceUnitCombo, PERSISTENCE_UNIT, null);
+
+ new Label(composite, SWT.NONE);
+
+// classText.setFocus();
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID());
+ Dialog.applyDialogFont(parent);
+ return composite;
+ }
+}
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 2dc0c3a8a7..0988773f10 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
@@ -10,27 +10,30 @@
*******************************************************************************/
package org.eclipse.jpt.ui.internal.wizards.orm;
+import static org.eclipse.jpt.core.internal.operations.JpaFileCreationDataModelProperties.*;
+import static org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProperties.*;
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
+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.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.context.JpaContextNode;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProperties;
import org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProvider;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
+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;
@@ -40,15 +43,26 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider;
-import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard;
+import org.eclipse.wst.common.frameworks.internal.datamodel.IDataModelPausibleOperation;
+import org.eclipse.wst.common.frameworks.internal.dialog.ui.WarningDialog;
+import org.eclipse.wst.common.frameworks.internal.ui.ErrorDialog;
+import org.eclipse.wst.common.frameworks.internal.ui.WTPCommonUIResourceHandler;
-public class MappingFileWizard extends DataModelWizard
+public class MappingFileWizard extends Wizard
implements INewWizard
{
- private MappingFileWizardPage page;
+ protected IDataModel dataModel;
+
+ protected IStructuredSelection initialSelection;
+
+ protected IStructuredSelection mungedSelection;
+
+ private IWizardPage firstPage;
+
+ private IWizardPage secondPage;
public MappingFileWizard() {
@@ -56,30 +70,16 @@ public class MappingFileWizard extends DataModelWizard
}
public MappingFileWizard(IDataModel dataModel) {
- super(dataModel);
+ super();
+ this.dataModel = dataModel;
setWindowTitle(JptUiMessages.MappingFileWizard_title);
setDefaultPageImageDescriptor(JptUiPlugin.getImageDescriptor(JptUiIcons.JPA_FILE_WIZ_BANNER));
}
- @Override
- protected void doAddPages() {
- super.doAddPages();
- page = buildMappingFileWizardPage();
- addPage(page);
- }
-
- protected MappingFileWizardPage buildMappingFileWizardPage() {
- return new MappingFileWizardPage(getDataModel(), "Page_1");
- }
-
- @Override
- protected IDataModelProvider getDefaultProvider() {
- return new OrmFileCreationDataModelProvider();
- }
-
public void init(IWorkbench workbench, IStructuredSelection selection) {
- // check for project, source folder, persistence unit?
+ this.initialSelection = selection;
+
if (selection == null || selection.isEmpty()) {
return;
}
@@ -87,177 +87,213 @@ public class MappingFileWizard extends DataModelWizard
Object firstSelection = selection.getFirstElement();
PersistenceUnit pUnit = extractPersistenceUnit(firstSelection);
- IFolder sourceFolder = extractSourceFolder(pUnit, firstSelection);
- IProject project = extractProject(pUnit, sourceFolder, firstSelection);
+ IContainer container = extractContainer(pUnit, firstSelection);
- if (project != null) {
- getDataModel().setStringProperty(OrmFileCreationDataModelProperties.PROJECT_NAME, project.getName());
+ if (container != null) {
+ this.mungedSelection = new StructuredSelection(container);
}
- if (sourceFolder != null) {
- getDataModel().setStringProperty(OrmFileCreationDataModelProperties.SOURCE_FOLDER, sourceFolder.getFullPath().toPortableString());
+ else {
+ this.mungedSelection = this.initialSelection;
}
+
if (pUnit != null) {
- getDataModel().setBooleanProperty(OrmFileCreationDataModelProperties.ADD_TO_PERSISTENCE_UNIT, true);
- getDataModel().setStringProperty(OrmFileCreationDataModelProperties.PERSISTENCE_UNIT, pUnit.getName());
+ getDataModel().setBooleanProperty(ADD_TO_PERSISTENCE_UNIT, true);
+ getDataModel().setStringProperty(PERSISTENCE_UNIT, pUnit.getName());
}
}
private PersistenceUnit extractPersistenceUnit(Object selection) {
- if (selection instanceof PersistenceUnit) {
- return (PersistenceUnit) selection;
- }
- PersistenceUnit pUnit = null;
if (selection instanceof JpaContextNode) {
+ // may be null if node is above level of persistence unit, but in those cases
+ // null is the expected result
try {
- pUnit = ((JpaContextNode) selection).getPersistenceUnit();
+ return ((JpaContextNode) selection).getPersistenceUnit();
}
catch (Exception e) { /* do nothing, just continue */ }
}
- if (pUnit == null && selection instanceof IAdaptable) {
- pUnit = (PersistenceUnit) ((IAdaptable) selection).getAdapter(PersistenceUnit.class);
-
+
+ if (selection instanceof IAdaptable) {
+ JpaContextNode node = (JpaContextNode) ((IAdaptable) selection).getAdapter(JpaContextNode.class);
+ if (node != null) {
+ return node.getPersistenceUnit();
+ }
}
- return pUnit;
+ return null;
}
- private IFolder extractSourceFolder(PersistenceUnit pUnit, Object selection) {
- IJavaProject javaProject = null;
- IFolder srcFolder = null;
+ private IContainer extractContainer(PersistenceUnit pUnit, Object selection) {
if (pUnit != null) {
- javaProject = pUnit.getJpaProject().getJavaProject();
- srcFolder = findSourceFolder(javaProject, pUnit.getResource());
- if (srcFolder != null) {
- return srcFolder;
- }
-
+ return pUnit.getResource().getParent();
}
- if (selection instanceof IResource) {
- javaProject = JavaCore.create(((IResource) selection).getProject());
- if (javaProject.exists()) {
- srcFolder = findSourceFolder(javaProject, (IResource) selection);
- if (srcFolder != null) {
- return srcFolder;
- }
- }
+ if (selection instanceof IProject) {
+ return getDefaultContainer((IProject) selection);
+ }
+ if (selection instanceof IContainer) {
+ return (IContainer) selection;
+ }
+ if (selection instanceof JpaContextNode) {
+ return getDefaultContainer(((JpaContextNode) selection).getJpaProject().getProject());
}
if (selection instanceof IAdaptable) {
IResource resource = (IResource) ((IAdaptable) selection).getAdapter(IResource.class);
if (resource != null) {
- javaProject = JavaCore.create((resource).getProject());
- if (javaProject.exists()) {
- srcFolder = findSourceFolder(javaProject, resource);
- if (srcFolder != null) {
- return srcFolder;
- }
+ if (resource instanceof IProject) {
+ return getDefaultContainer((IProject) resource);
+ }
+ else if (resource instanceof IContainer) {
+ return (IContainer) resource;
}
}
+ JpaContextNode node = (JpaContextNode) ((IAdaptable) selection).getAdapter(JpaContextNode.class);
+ if (node != null) {
+ return getDefaultContainer(node.getJpaProject().getProject());
+ }
}
return null;
}
- private IFolder findSourceFolder(IJavaProject javaProject, IResource resource) {
- if (JptCorePlugin.getJpaProject(javaProject.getProject()) == null) {
- // not even a jpa project
- return null;
+ private IContainer getDefaultContainer(IProject project) {
+ if (JptCorePlugin.projectHasJpaFacet(project)) {
+ return JptCorePlugin.getResourceLocator(project).getDefaultResourceLocation(project);
}
- while (resource != null && ! (resource instanceof IFolder)) {
- resource = resource.getParent();
- }
- if (resource == null) {
- return null;
+ return project;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ this.firstPage = buildMappingFileNewFileWizardPage();
+ this.secondPage = buildMappingFileOptionsWizardPage();
+ addPage(this.firstPage);
+ addPage(this.secondPage);
+ }
+
+ protected MappingFileNewFileWizardPage buildMappingFileNewFileWizardPage() {
+ return new MappingFileNewFileWizardPage(
+ "Page_1", this.mungedSelection, getDataModel(),
+ JptUiMessages.MappingFileWizardPage_newFile_title,
+ JptUiMessages.MappingFileWizardPage_newFile_desc);
+ }
+
+ protected MappingFileOptionsWizardPage buildMappingFileOptionsWizardPage() {
+ return new MappingFileOptionsWizardPage(
+ "Page_2", getDataModel(),
+ JptUiMessages.MappingFileWizardPage_options_title,
+ JptUiMessages.MappingFileWizardPage_options_desc);
+ }
+
+ @Override
+ public boolean canFinish() {
+ // override so that visit to second page is not necessary
+ return this.firstPage.isPageComplete() && getDataModel().isValid();
+ }
+
+ protected IDataModel getDataModel() {
+ if (this.dataModel == null) {
+ this.dataModel = DataModelFactory.createDataModel(getDefaultProvider());
}
- IFolder folder = (IFolder) resource;
+ return this.dataModel;
+ }
+
+ protected IDataModelProvider getDefaultProvider() {
+ return new OrmFileCreationDataModelProvider();
+ }
+
+ protected IDataModelPausibleOperation getOperation() {
+ return (IDataModelPausibleOperation) getDataModel().getDefaultOperation();
+ }
+
+ @Override
+ public final boolean performFinish() {
try {
- IPackageFragmentRoot packageFragmentRoot = null;
- while (packageFragmentRoot == null && folder != null) {
- packageFragmentRoot = javaProject.findPackageFragmentRoot(folder.getFullPath());
- if (packageFragmentRoot == null) {
- IPackageFragment packageFragment = javaProject.findPackageFragment(folder.getFullPath());
- if (packageFragment != null) {
- packageFragmentRoot = (IPackageFragmentRoot) packageFragment.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- }
- }
- if (packageFragmentRoot == null) {
- try {
- folder = (IFolder) folder.getParent();
- }
- catch (ClassCastException cce) {
- folder = null;
- }
- }
- }
- if (packageFragmentRoot == null) {
- return null;
- }
- if (JDTTools.packageFragmentRootIsSourceFolder(packageFragmentRoot)) {
- return (IFolder) packageFragmentRoot.getResource();
+ final IStatus st = runOperations();
+
+ if (st.getSeverity() == IStatus.ERROR) {
+ JptUiPlugin.log(st);
+ Throwable t = st.getException() == null ? new CoreException(st) : st.getException();
+ ErrorDialog.openError(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}),
+ t, 0, false);
+ }
+ else if(st.getSeverity() == IStatus.WARNING){
+ WarningDialog.openWarning(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_2, new Object[]{getWindowTitle()}),
+ st.getMessage(),
+ st, IStatus.WARNING);
}
+
+ postPerformFinish();
}
- catch (JavaModelException jme) { /* do nothing, return null */ }
- return null;
+ catch (Exception e) {
+ JptUiPlugin.log(e);
+ ErrorDialog.openError(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}),
+ e, 0, false);
+ }
+ return true;
}
- private IProject extractProject(PersistenceUnit pUnit, IFolder sourceFolder, Object selection) {
- if (pUnit != null) {
- return pUnit.getJpaProject().getProject();
- }
- if (sourceFolder != null) {
- return sourceFolder.getProject();
- }
+ private IStatus runOperations() {
- IProject project = null;
- if (selection instanceof IResource) {
- project = ((IResource) selection).getProject();
- }
- if (project == null && selection instanceof IJavaElement) {
- project = ((IJavaElement) selection).getJavaProject().getProject();
- }
- if (project == null && selection instanceof JpaContextNode) {
- project = ((JpaContextNode) selection).getJpaProject().getProject();
- }
- if (project == null && selection instanceof IAdaptable) {
- project = (IProject) ((IAdaptable) selection).getAdapter(IProject.class);
- if (project == null) {
- IResource resource = (IResource) ((IAdaptable) selection).getAdapter(IResource.class);
- if (resource != null) {
- project = resource.getProject();
- }
- }
- if (project == null) {
- IJavaElement javaElement = (IJavaElement) ((IAdaptable) selection).getAdapter(IJavaElement.class);
- if (javaElement != null) {
- project = javaElement.getJavaProject().getProject();
+ class CatchThrowableRunnableWithProgress
+ implements IRunnableWithProgress {
+
+ public IStatus status = null;
+ public Throwable caught = null;
+
+ public void run(IProgressMonitor pm) {
+ try {
+ status = getOperation().execute(pm, null);
+ }
+ catch (Throwable e) {
+ caught = e;
}
}
}
- if (project != null) {
- for (DataModelPropertyDescriptor descriptor :
- getDataModel().getValidPropertyDescriptors(OrmFileCreationDataModelProperties.PROJECT_NAME)) {
- if (descriptor.getPropertyDescription().equals(project.getName())) {
- return project;
- }
- }
+ CatchThrowableRunnableWithProgress runnable = new CatchThrowableRunnableWithProgress();
+
+ try {
+ getContainer().run(true, false, runnable);
+ }
+ catch (Throwable e) {
+ runnable.caught = e;
+ }
+
+ if (runnable.caught == null) {
+ return runnable.status;
+ }
+ else {
+ JptUiPlugin.log(runnable.caught);
+ ErrorDialog.openError(
+ getShell(),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_0, new Object[]{getWindowTitle()}),
+ WTPCommonUIResourceHandler.getString(WTPCommonUIResourceHandler.WTPWizard_UI_1, new Object[]{getWindowTitle()}),
+ runnable.caught, 0, false);
+ return new Status(IStatus.ERROR, "id", 0, runnable.caught.getMessage(), runnable.caught); //$NON-NLS-1$
}
- return null;
}
- @Override
- protected void postPerformFinish() throws InvocationTargetException {
- try {
- String projectName = (String) getDataModel().getProperty(OrmFileCreationDataModelProperties.PROJECT_NAME);
- IProject project = ProjectUtilities.getProject(projectName);
- String sourceFolder = getDataModel().getStringProperty(OrmFileCreationDataModelProperties.SOURCE_FOLDER);
- String filePath = getDataModel().getStringProperty(OrmFileCreationDataModelProperties.FILE_PATH);
-
- IFile file = project.getWorkspace().getRoot().getFile(new Path(sourceFolder).append(filePath));
- openEditor(file);
- }
- catch (Exception cantOpen) {
- throw new InvocationTargetException(cantOpen);
- }
- }
+ protected void postPerformFinish()
+ throws InvocationTargetException {
+
+ try {
+ IPath containerPath = (IPath) getDataModel().getProperty(CONTAINER_PATH);
+ String fileName = getDataModel().getStringProperty(FILE_NAME);
+ IContainer container = PlatformTools.getContainer(containerPath);
+ IFile file = container.getFile(new Path(fileName));
+ openEditor(file);
+ }
+ catch (Exception cantOpen) {
+ throw new InvocationTargetException(cantOpen);
+ }
+ }
private void openEditor(final IFile file) {
if (file != null) {
@@ -274,4 +310,10 @@ public class MappingFileWizard extends DataModelWizard
});
}
}
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ getDataModel().dispose();
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizardPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizardPage.java
deleted file mode 100644
index 7ad77b4cd3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/wizards/orm/MappingFileWizardPage.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.ui.internal.wizards.orm;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFolder;
-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.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.core.internal.operations.OrmFileCreationDataModelProperties;
-import org.eclipse.jpt.core.internal.utility.jdt.JDTTools;
-import org.eclipse.jpt.ui.JptUiPlugin;
-import org.eclipse.jpt.ui.internal.JptUiMessages;
-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.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-import org.eclipse.ui.model.WorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
-import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizardPage;
-
-public class MappingFileWizardPage extends DataModelWizardPage
- implements OrmFileCreationDataModelProperties
-{
- private Label projectNameLabel;
-
- private Combo projectNameCombo;
-
- private Label sourceFolderLabel;
-
- private Text sourceFolderText;
-
- private Label filePathLabel;
-
- private Text filePathText;
-
- private Label accessLabel;
-
- private Combo accessCombo;
-
- private Button addToPersistenceUnitButton;
-
- private Label persistenceUnitLabel;
-
- private Combo persistenceUnitCombo;
-
-
- public MappingFileWizardPage(IDataModel dataModel, String pageName) {
- super(dataModel, pageName);
- setTitle(JptUiMessages.MappingFileWizardPage_title);
- setDescription(JptUiMessages.MappingFileWizardPage_desc);
- setPageComplete(false);
- }
-
-
- @Override
- protected String[] getValidationPropertyNames() {
- return new String[] {
- PROJECT_NAME,
- SOURCE_FOLDER,
- FILE_PATH,
- DEFAULT_ACCESS,
- ADD_TO_PERSISTENCE_UNIT,
- PERSISTENCE_UNIT
- };
- }
-
- @Override
- protected Composite createTopLevelComposite(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- composite.setLayout(layout);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
-
- this.projectNameLabel = new Label(composite, SWT.NONE);
- this.projectNameLabel.setText(JptUiMessages.MappingFileWizardPage_projectLabel);
- data = new GridData();
- this.projectNameLabel.setLayoutData(data);
-
- this.projectNameCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 1;
- data.grabExcessHorizontalSpace = true;
- this.projectNameCombo.setLayoutData(data);
- this.synchHelper.synchCombo(this.projectNameCombo, PROJECT_NAME, null);
- new Label(composite, SWT.NONE);
-
- this.sourceFolderLabel = new Label(composite, SWT.NONE);
- this.sourceFolderLabel.setText(JptUiMessages.MappingFileWizardPage_sourceFolderLabel);
- data = new GridData();
- this.sourceFolderLabel.setLayoutData(data);
-
- this.sourceFolderText = new Text(composite, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 1;
- data.grabExcessHorizontalSpace = true;
- this.sourceFolderText.setLayoutData(data);
- this.synchHelper.synchText(this.sourceFolderText, SOURCE_FOLDER, null);
-
- Button sourceFolderButton = new Button(composite, SWT.PUSH);
- sourceFolderButton.setText(JptUiMessages.General_browse);
- data = new GridData();
- data.horizontalSpan = 1;
- sourceFolderButton.addSelectionListener(
- new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- handleSourceFolderButtonPressed();
- }
- });
-
- Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
- data = new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1);
- data.verticalIndent = 5;
- separator.setLayoutData(data);
-
- this.filePathLabel = new Label(composite, SWT.NONE);
- this.filePathLabel.setText(JptUiMessages.MappingFileWizardPage_filePathLabel);
- data = new GridData();
- data.verticalIndent = 5;
- this.filePathLabel.setLayoutData(data);
-
- this.filePathText = new Text(composite, SWT.BORDER);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 1;
- data.verticalIndent = 5;
- data.grabExcessHorizontalSpace = true;
- this.filePathText.setLayoutData(data);
- this.synchHelper.synchText(this.filePathText, FILE_PATH, null);
- new Label(composite, SWT.NONE);
-
- this.accessLabel = new Label(composite, SWT.NONE);
- this.accessLabel.setText(JptUiMessages.MappingFileWizardPage_accessLabel);
- data = new GridData();
- this.accessLabel.setLayoutData(data);
-
- this.accessCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 1;
- data.grabExcessHorizontalSpace = true;
- this.accessCombo.setLayoutData(data);
- this.synchHelper.synchCombo(this.accessCombo, DEFAULT_ACCESS, null);
- new Label(composite, SWT.NONE);
-
- this.addToPersistenceUnitButton = new Button(composite, SWT.CHECK | SWT.BEGINNING);
- this.addToPersistenceUnitButton.setText(JptUiMessages.MappingFileWizardPage_addToPersistenceUnitButton);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 3;
- data.verticalIndent = 10;
- this.addToPersistenceUnitButton.setLayoutData(data);
- this.synchHelper.synchCheckbox(this.addToPersistenceUnitButton, ADD_TO_PERSISTENCE_UNIT, null);
-
- this.persistenceUnitLabel = new Label(composite, SWT.NONE);
- this.persistenceUnitLabel.setText(JptUiMessages.MappingFileWizardPage_persistenceUnitLabel);
- data = new GridData();
- data.horizontalIndent = 10;
- this.persistenceUnitLabel.setLayoutData(data);
- this.persistenceUnitLabel.setEnabled(false);
- this.addToPersistenceUnitButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- persistenceUnitLabel.setEnabled(addToPersistenceUnitButton.getSelection());
- }
- public void widgetDefaultSelected(SelectionEvent e) {/*not called*/}
- });
-
- this.persistenceUnitCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
- data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 1;
- data.grabExcessHorizontalSpace = true;
- this.persistenceUnitCombo.setLayoutData(data);
- this.synchHelper.synchCombo(this.persistenceUnitCombo, PERSISTENCE_UNIT, null);
-
- new Label(composite, SWT.NONE);
-
-// classText.setFocus();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, getInfopopID());
- Dialog.applyDialogFont(parent);
- return composite;
- }
-
- private void handleSourceFolderButtonPressed() {
- ISelectionStatusValidator validator = getSourceFolderDialogSelectionValidator();
- ViewerFilter filter = getSourceFolderDialogViewerFilter();
- ITreeContentProvider contentProvider = new WorkbenchContentProvider();
- ILabelProvider labelProvider = new WorkbenchLabelProvider();
- ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider);
- dialog.setValidator(validator);
- dialog.setTitle(JptUiMessages.MappingFileWizardPage_accessLabel_sourceFolderDialogTitle);
- dialog.setMessage(JptUiMessages.MappingFileWizardPage_accessLabel_sourceFolderDialogDesc);
- dialog.addFilter(filter);
- String projectName = model.getStringProperty(PROJECT_NAME);
- if (projectName==null || projectName.length()==0) {
- return;
- }
- IProject project = ProjectUtilities.getProject(projectName);
- dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
-
- if (project != null) {
- dialog.setInitialSelection(project);
- }
- if (dialog.open() == Window.OK) {
- Object element = dialog.getFirstResult();
- if (element instanceof IContainer) {
- IContainer container = (IContainer) element;
- model.setProperty(SOURCE_FOLDER, container.getFullPath().toPortableString());
- }
- }
- }
-
- private ISelectionStatusValidator getSourceFolderDialogSelectionValidator() {
- return new ISelectionStatusValidator() {
- public IStatus validate(Object[] selection) {
- if (selection != null && selection[0] != null && ! (selection[0] instanceof IProject)) {
- return Status.OK_STATUS;
- }
- return new Status(IStatus.ERROR, JptUiPlugin.PLUGIN_ID, JptUiMessages.MappingFileWizardPage_incorrectSourceFolderError);
- }
- };
- }
-
- private ViewerFilter getSourceFolderDialogViewerFilter() {
- return new ViewerFilter() {
- @Override
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IProject) {
- IProject project = (IProject) element;
- return project.getName().equals(model.getProperty(PROJECT_NAME));
- }
- else if (element instanceof IFolder) {
- IFolder folder = (IFolder) element;
- // only show source folders
- IProject project = ProjectUtilities.getProject(model.getStringProperty(PROJECT_NAME));
- IJavaProject javaProject = JavaCore.create(project);
- if (JDTTools.packageFragmentRootIsSourceFolder(javaProject.getPackageFragmentRoot(folder))) {
- return true;
- }
- }
- return false;
- }
- };
- }
-
- void init(IWorkbench workbench, IStructuredSelection selection) {
-
- }
-}

Back to the top