Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbridgha2005-04-06 21:42:40 +0000
committercbridgha2005-04-06 21:42:40 +0000
commit862a8b343f8a8ce8fdada331a37c2bfa37d8bc26 (patch)
treece722faf528f76a3bbe01b3236d002dafe94c58b
parentff81da7d6f7f9717b81dddef5309f7062a243b39 (diff)
downloadwebtools.javaee-862a8b343f8a8ce8fdada331a37c2bfa37d8bc26.tar.gz
webtools.javaee-862a8b343f8a8ce8fdada331a37c2bfa37d8bc26.tar.xz
webtools.javaee-862a8b343f8a8ce8fdada331a37c2bfa37d8bc26.zip
*** empty log message ***
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/IJavaProjectCreationProperties.java37
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModel.java6
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModelProvider.java46
-rw-r--r--plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationOp.java112
4 files changed, 197 insertions, 4 deletions
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/IJavaProjectCreationProperties.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/IJavaProjectCreationProperties.java
new file mode 100644
index 000000000..90a0d4bbc
--- /dev/null
+++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/IJavaProjectCreationProperties.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.common.jdt.internal.integration;
+
+import org.eclipse.wst.common.frameworks.internal.operations.IProjectCreationProperties;
+
+public interface IJavaProjectCreationProperties extends IProjectCreationProperties {
+
+ /**
+ * Optional, type String []. These names are relative.
+ */
+ public static final String SOURCE_FOLDERS = "JavaProjectCreationDataModel.SOURCE_FOLDERS"; //$NON-NLS-1$
+ /**
+ * Optional, type Boolean default is True
+ */
+ public static final String CREATE_SOURCE_FOLDERS = "JavaProjectCreationDataModel.CREATE_SOURCE_FOLDERS"; //$NON-NLS-1$
+
+
+ /**
+ * Optional, type IClasspathEntry[]
+ */
+ public static final String CLASSPATH_ENTRIES = "JavaProjectCreationDataModel.CLASSPATH_ENTRIES"; //$NON-NLS-1$
+
+ /**
+ * Optional, type String
+ */
+ public static final String OUTPUT_LOCATION = "JavaProjectCreationDataModel.OUTPUT_LOCATION"; //$NON-NLS-1$
+
+}
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModel.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModel.java
index b6dec4de7..85c47c9d4 100644
--- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModel.java
+++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModel.java
@@ -26,10 +26,8 @@ import org.eclipse.wst.common.frameworks.internal.operations.WTPOperation;
/**
- * @author jsholl
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * @deprecated
+ * @see org.eclipse.jst.common.jdt.internal.integration.IJavaProjectCreationProperties
*/
public class JavaProjectCreationDataModel extends ProjectCreationDataModel {
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModelProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModelProvider.java
new file mode 100644
index 000000000..2939fae68
--- /dev/null
+++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationDataModelProvider.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jst.common.jdt.internal.integration;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation;
+import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationDataModelProvider;
+
+public class JavaProjectCreationDataModelProvider extends ProjectCreationDataModelProvider implements IJavaProjectCreationProperties {
+
+
+ public String[] getPropertyNames() {
+ return combineProperties(super.getPropertyNames(), new String[]{OUTPUT_LOCATION, SOURCE_FOLDERS, CLASSPATH_ENTRIES, CREATE_SOURCE_FOLDERS});
+ }
+
+ public IDataModelOperation getDefaultOperation() {
+ return new JavaProjectCreationOp(model);
+ }
+
+ public Object getDefaultProperty(String propertyName) {
+ // TODO pull these from the java preferences
+ if (propertyName.equals(OUTPUT_LOCATION)) {
+ return "bin"; //$NON-NLS-1$
+ }
+ if (propertyName.equals(SOURCE_FOLDERS)) {
+ return new String[0];
+ }
+ if (propertyName.equals(CREATE_SOURCE_FOLDERS))
+ return Boolean.TRUE;
+ return null;
+ }
+
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationOp.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationOp.java
new file mode 100644
index 000000000..7697f9dff
--- /dev/null
+++ b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectCreationOp.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on Nov 4, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.jst.common.jdt.internal.integration;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+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.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.frameworks.internal.WTPProjectUtilities;
+import org.eclipse.wst.common.frameworks.internal.operations.ProjectCreationOp;
+
+public class JavaProjectCreationOp extends ProjectCreationOp {
+
+ public JavaProjectCreationOp(IDataModel dataModel) {
+ super(dataModel);
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ super.execute(monitor, info);
+ try {
+ createJavaProject(monitor);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return OK_STATUS;
+ }
+
+ private void createJavaProject(IProgressMonitor monitor) throws CoreException {
+ IProject project = (IProject) model.getProperty(IJavaProjectCreationProperties.PROJECT);
+ WTPProjectUtilities.addNatureToProjectLast(project, JavaCore.NATURE_ID);
+ IJavaProject javaProject = JavaCore.create(project);
+ javaProject.setOutputLocation(getOutputPath(project), monitor);
+ javaProject.setRawClasspath(getClasspathEntries(project), monitor);
+ if (model.getBooleanProperty(IJavaProjectCreationProperties.CREATE_SOURCE_FOLDERS)) {
+ String[] sourceFolders = (String[]) model.getProperty(IJavaProjectCreationProperties.SOURCE_FOLDERS);
+ IFolder folder = null;
+ for (int i = 0; i < sourceFolders.length; i++) {
+ folder = project.getFolder(sourceFolders[i]);
+ folder.create(true, true, monitor);
+ }
+ }
+ }
+
+ private IPath getOutputPath(IProject project) {
+ String outputLocation = model.getStringProperty(IJavaProjectCreationProperties.OUTPUT_LOCATION);
+ return project.getFullPath().append(outputLocation);
+ }
+
+ private IClasspathEntry[] getClasspathEntries(IProject project) {
+ IClasspathEntry[] entries = (IClasspathEntry[]) model.getProperty(IJavaProjectCreationProperties.CLASSPATH_ENTRIES);
+ IClasspathEntry[] sourceEntries = null;
+ if (model.getBooleanProperty(IJavaProjectCreationProperties.CREATE_SOURCE_FOLDERS))
+ sourceEntries = getSourceClasspathEntries(project);
+ return combineArrays(sourceEntries, entries);
+ }
+
+ private IClasspathEntry[] getSourceClasspathEntries(IProject project) {
+ String[] sourceFolders = (String[]) model.getProperty(IJavaProjectCreationProperties.SOURCE_FOLDERS);
+ ArrayList list = new ArrayList();
+ for (int i = 0; i < sourceFolders.length; i++) {
+ list.add(JavaCore.newSourceEntry(project.getFullPath().append(sourceFolders[i])));
+ }
+ IClasspathEntry[] classpath = new IClasspathEntry[list.size()];
+ for (int i = 0; i < classpath.length; i++) {
+ classpath[i] = (IClasspathEntry) list.get(i);
+ }
+ return classpath;
+ }
+
+ private IClasspathEntry[] combineArrays(IClasspathEntry[] sourceEntries, IClasspathEntry[] entries) {
+ if (sourceEntries != null) {
+ if (entries == null)
+ return sourceEntries;
+ return doCombineArrays(sourceEntries, entries);
+ } else if (entries != null)
+ return entries;
+ return new IClasspathEntry[0];
+ }
+
+ private IClasspathEntry[] doCombineArrays(IClasspathEntry[] sourceEntries, IClasspathEntry[] entries) {
+ IClasspathEntry[] result = new IClasspathEntry[sourceEntries.length + entries.length];
+ System.arraycopy(sourceEntries, 0, result, 0, sourceEntries.length);
+ System.arraycopy(entries, 0, result, sourceEntries.length, entries.length);
+ return result;
+ }
+
+} \ No newline at end of file

Back to the top