Commit 55891baf authored by Liana Soima's avatar Liana Soima
Browse files

Merge branch 'master' of https://git.fortiss.org/af3/af3.git into 3979

parents c64521a2 daa66ef9
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package test.org.fortiss.af3.component.library; package test.org.fortiss.af3.component.library;
import static org.fortiss.af3.component.utils.ComponentLibraryModelElementFactory.createLibraryComponentPackage; import static org.fortiss.af3.component.utils.ComponentLibraryModelElementFactory.createLibraryComponentPackage;
import static org.fortiss.af3.project.utils.FileUtils.saveFileLibrary;
import static org.fortiss.af3.project.utils.LibraryModelElementFactory.createFileLibrary; import static org.fortiss.af3.project.utils.LibraryModelElementFactory.createFileLibrary;
import static org.fortiss.tooling.kernel.utils.PrototypesUtils.findPrototypeComposableWith; import static org.fortiss.tooling.kernel.utils.PrototypesUtils.findPrototypeComposableWith;
...@@ -29,6 +28,7 @@ import org.fortiss.af3.component.model.Component; ...@@ -29,6 +28,7 @@ import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentRef; import org.fortiss.af3.component.model.ComponentRef;
import org.fortiss.af3.component.model.LibraryComponentPackage; import org.fortiss.af3.component.model.LibraryComponentPackage;
import org.fortiss.af3.project.model.FileLibrary; import org.fortiss.af3.project.model.FileLibrary;
import org.fortiss.af3.project.utils.ProjectUtils;
import org.fortiss.tooling.base.library.ModelElementLibraryService; import org.fortiss.tooling.base.library.ModelElementLibraryService;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement; import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.extension.data.Prototype; import org.fortiss.tooling.kernel.extension.data.Prototype;
...@@ -96,7 +96,7 @@ public class LibraryTestBase { ...@@ -96,7 +96,7 @@ public class LibraryTestBase {
FileLibrary fileLibrary = createFileLibrary(libName); FileLibrary fileLibrary = createFileLibrary(libName);
LibraryComponentPackage libraryComponentPackage = createLibraryComponentPackage(packName); LibraryComponentPackage libraryComponentPackage = createLibraryComponentPackage(packName);
fileLibrary.getRootElements().add(libraryComponentPackage); fileLibrary.getRootElements().add(libraryComponentPackage);
saveFileLibrary(fileLibrary); ProjectUtils.saveFileLibrary(fileLibrary);
sleep(); sleep();
} }
......
ImageBox.java 7ad103552d87ea816caaef06a179c15a3b46e9ea GREEN ImageBox.java 24860c6f9f2652cee7f8b1d81f1fff1f199b0383 GREEN
ImageSection.java 470d2d525a02444e9f169e50e07a56d8c5707b04 GREEN ImageSection.java acaeba2f544bf128b09bf0c9ea8a9815dcaaebef GREEN
...@@ -21,7 +21,7 @@ import static org.conqat.lib.commons.string.StringUtils.concat; ...@@ -21,7 +21,7 @@ import static org.conqat.lib.commons.string.StringUtils.concat;
import static org.eclipse.jface.layout.GridDataFactory.swtDefaults; import static org.eclipse.jface.layout.GridDataFactory.swtDefaults;
import static org.fortiss.af3.mira.ui.utils.HighlightUtils.createSourceViewer; import static org.fortiss.af3.mira.ui.utils.HighlightUtils.createSourceViewer;
import static org.fortiss.af3.mira.ui.utils.ImageUtils.getImageFile; import static org.fortiss.af3.mira.ui.utils.ImageUtils.getImageFile;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.getDefaultGeneralProjectPath; import static org.fortiss.af3.project.utils.FileUtils.getDefaultGeneralProjectPath;
import static org.fortiss.tooling.kernel.model.FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME; import static org.fortiss.tooling.kernel.model.FortissToolingKernelPackage.Literals.INAMED_ELEMENT__NAME;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind; import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
......
...@@ -22,7 +22,7 @@ import static org.eclipse.jface.layout.GridDataFactory.swtDefaults; ...@@ -22,7 +22,7 @@ import static org.eclipse.jface.layout.GridDataFactory.swtDefaults;
import static org.fortiss.af3.mira.ui.utils.ImageUtils.PROJECT_IMAGE_SUBFOLDER; import static org.fortiss.af3.mira.ui.utils.ImageUtils.PROJECT_IMAGE_SUBFOLDER;
import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.multiLineLabelFactory; import static org.fortiss.af3.mira.ui.utils.MiraLayoutUtils.multiLineLabelFactory;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createImageItem; import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createImageItem;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.getDefaultGeneralProjectPath; import static org.fortiss.af3.project.utils.FileUtils.getDefaultGeneralProjectPath;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
......
ContextUtils.java 273aa06af2c15073bbbdd6f1a8112190732eaa9b GREEN ContextUtils.java 273aa06af2c15073bbbdd6f1a8112190732eaa9b GREEN
HighlightUtils.java 9797de10e9c1fd6475bd1eda4d9a55746c17a219 GREEN HighlightUtils.java 9797de10e9c1fd6475bd1eda4d9a55746c17a219 GREEN
ImageUtils.java b87b930301c11cce514b9fb38e148bd00fe60d68 GREEN ImageUtils.java 9e4c005c0793353ac1b6c6e138f1c1d6a65c393c GREEN
ListenerUtils.java f05728d39167b85752ee577a73e265d2764693f8 GREEN ListenerUtils.java f05728d39167b85752ee577a73e265d2764693f8 GREEN
MiraLayoutUtils.java 0ed0d5731be847edb8454acc27de691ac3ee28e9 GREEN MiraLayoutUtils.java 0ed0d5731be847edb8454acc27de691ac3ee28e9 GREEN
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.utils; package org.fortiss.af3.mira.ui.utils;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.getDefaultGeneralProjectPath; import static org.fortiss.af3.project.utils.FileUtils.getDefaultGeneralProjectPath;
import static org.fortiss.tooling.base.ui.editpart.ExtendedLayerRootEditPart.LABEL_LAYER; import static org.fortiss.tooling.base.ui.editpart.ExtendedLayerRootEditPart.LABEL_LAYER;
import java.io.File; import java.io.File;
......
ExportProjectUtils.java 95b02d271335e46ce89f78c912f85236fc852988 GREEN ExportProjectUtils.java 95b02d271335e46ce89f78c912f85236fc852988 GREEN
FileNameValidatorUtil.java cb737c96ba0e7e77ae10bb763044b7164353b22a GREEN FileNameValidatorUtil.java c566595d083e756c20c919458d81e8a91ab0e10e GREEN
FolderOrProjectDialogUtils.java 14823ea1da085d019e21e50703f6f4e3fff8aa83 GREEN FolderOrProjectDialogUtils.java 14823ea1da085d019e21e50703f6f4e3fff8aa83 GREEN
ImportProjectUtils.java 991176c27182bcee524d9f2c742fc5f5b7c050da GREEN ImportProjectUtils.java 87216991e47e14846f7affb49139a3dd2a71aba3 GREEN
NewProjectUtils.java 408f1a6766e8045fb150e34637999115dedddfd1 GREEN NewProjectUiUtils.java cd17cec67769d1c62c9923869c43293036d103e4 GREEN
ParsingUtils.java 7bbc27436511ee9d88f8a31f0b19462406d01517 GREEN ParsingUtils.java 7bbc27436511ee9d88f8a31f0b19462406d01517 GREEN
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
package org.fortiss.af3.project.ui.utils; package org.fortiss.af3.project.ui.utils;
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace; import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.getDefaultGeneralProjectName; import static org.fortiss.af3.project.utils.FileUtils.getDefaultGeneralProjectName;
import java.io.File; import java.io.File;
import java.util.regex.Pattern; import java.util.regex.Pattern;
......
...@@ -15,40 +15,29 @@ ...@@ -15,40 +15,29 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.project.ui.utils; package org.fortiss.af3.project.ui.utils;
import static org.conqat.lib.commons.filesystem.FileSystemUtils.copyFiles;
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace; import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.eclipse.emf.common.util.URI.createFileURI; import static org.eclipse.emf.common.util.URI.createURI;
import static org.eclipse.jface.dialogs.MessageDialog.openInformation;
import static org.eclipse.ui.PlatformUI.getWorkbench; import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.fortiss.af3.project.AF3Project.AF3_PRJ_SUFFIX;
import static org.fortiss.af3.project.storage.LocationProvider.AF3_20_TO_22_PROJECT_FILES_EXTENSION; import static org.fortiss.af3.project.storage.LocationProvider.AF3_20_TO_22_PROJECT_FILES_EXTENSION;
import static org.fortiss.af3.project.storage.LocationProvider.CURRENT_AF3_PROJECT_FILES_EXTENSION; import static org.fortiss.af3.project.storage.LocationProvider.CURRENT_AF3_PROJECT_FILES_EXTENSION;
import static org.fortiss.af3.project.ui.AF3ProjectUIActivator.getDefault; import static org.fortiss.af3.project.ui.AF3ProjectUIActivator.getDefault;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.createNewGeneralProject; import static org.fortiss.af3.project.ui.utils.NewProjectUiUtils.requestFileNameDialog;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.generalProjectExists; import static org.fortiss.af3.project.utils.FileUtils.getDefaultGeneralProjectURI;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.getDefaultGeneralProjectURI;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.requestFileNameDialog;
import static org.fortiss.af3.project.utils.ExternalFileUtils.doCopyExternalDocuments;
import static org.fortiss.af3.project.utils.FileUtils.LIBRARY_LOCATION;
import static org.fortiss.af3.project.utils.ProjectUtils.saveProject;
import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showErrorInUIThread; import static org.fortiss.tooling.kernel.ui.util.MessageUtilsExtended.showErrorInUIThread;
import static org.fortiss.tooling.kernel.utils.EMFResourceUtils.loadModelFromFileWithUnknownFeatures;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.copy;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error; import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showError;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.showInfo;
import java.io.File; import java.io.File;
import java.util.Map; import java.io.IOException;
import org.conqat.lib.commons.collections.Pair;
import org.conqat.lib.commons.filesystem.FileOnlyFilter;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI; import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.fortiss.af3.project.model.FileProject; import org.fortiss.af3.project.utils.ProjectUtils;
/** /**
* Utility methods for importing projects into workspace. * Utility methods for importing projects into workspace.
...@@ -75,60 +64,90 @@ public class ImportProjectUtils { ...@@ -75,60 +64,90 @@ public class ImportProjectUtils {
return fd.open(); return fd.open();
} }
/**
* Tests if a file with the given name exists in the workspace. If yes, the user is
* asked for another name for the file.
*
* @param targetFileName
* name of the AF3 project file to be imported. If this location is occupied, the
* user is asked for another file name.
*
* @return a URI to the new user defined file, or {@code null} in case the user cancelled the
* import. This file doesn't exist at this moment.
*/
public static URI determineTargetFileLocation(String targetFileName) {
URI targetURI = getDefaultGeneralProjectURI().appendSegment(targetFileName)
.appendFileExtension(AF3_PRJ_SUFFIX);
return determineTargetFileLocation(targetURI);
}
/** /**
* Tests if a file at the given URI exists already. If yes, the user is * Tests if a file at the given URI exists already. If yes, the user is
* asked for another name for the file. * asked for another name for the file.
* *
* @param initialFileURI * @param fileURI
* the initial URI of the location to which the file should be * the initial URI of the location to which the file should be
* imported. If this location is not free, the user is asked for * imported. If this location is not free, the user is asked for
* another file name. * another file name.
* *
* @return a URI to the new user defined file, or * @return a URI to the new user defined file, or {@code null} in case the user cancelled the
* {@code null in case the user cancelled the import}. This file doesn't exist at * import. This file doesn't exist at this moment.
* this moment.
*/ */
private static URI determineTargetFileLocation(URI initialFileURI) { public static URI determineTargetFileLocation(URI fileURI) {
// The file name that may be changed by the user.
String targetFileName = initialFileURI.lastSegment();
// Create file handler. // Create file handler.
File targetFile = getTargetFile(targetFileName); File targetFile = new File(fileURI.toFileString());
// If a file with this name already exists in the AF3 workspace, ask the // If a file with this name already exists in the AF3 workspace, ask the
// user for another file name. // user for another file name.
if(targetFile.exists()) { if(targetFile.exists()) {
targetFileName = requestFileNameDialog(targetFile); // The dialog ensures, existing file names cannot be chosen.
String targetFileName = requestFileNameDialog(targetFile);
if(targetFileName == null) { if(targetFileName == null) {
return null; return null;
} }
targetFile = getTargetFile(targetFileName); fileURI = createURI(fileURI.toString().replace(fileURI.lastSegment(), targetFileName));
} }
return createFileURI(targetFile.toString()); return fileURI;
} }
/** Returns the target {@link File} for the given {@code targetFileName}. */ /**
private static File getTargetFile(String targetFileName) { * Imports the given {@link File} at the given {@link URI}. Resources that are referenced from
return new File(getDefaultGeneralProjectURI().appendSegment(targetFileName).toFileString()); * the project are also copied to the target location.
* NOTE: Libraries are ignored during the import.
*
* @param sourceFileURI
* {@link File} that will be imported.
* @throws IOException
* if any error occurred when writing to the target location or inconsistencies in
* the project file w.r.t. to referenced files were detected.
*/
public static void importFileProject(URI sourceFileURI) throws IOException {
// Isolate the file name from the path to it.
String sourceFileName = sourceFileURI.lastSegment();
// Determine the file location of the target file.
URI targetFileURI = determineTargetFileLocation(
getDefaultGeneralProjectURI().appendSegment(sourceFileName));
ProjectUtils.importFileProject(sourceFileURI, targetFileURI);
} }
/** /**
* Imports a selected file into the AF3 workspace (by file copying). * Imports a selected file into the AF3 workspace.
* *
* @param sourceFileURI * @param sourceFileURI
* the URI of the file that should be imported * the URI of the file that should be imported
*/ */
public static void importFileCopy(URI sourceFileURI) { public static void importUISelectedFile(URI sourceFileURI) {
File sourceFile = new File(sourceFileURI.toFileString()); File sourceFile = new File(sourceFileURI.toString());
// Check if really an af3_2x project is given. // Check if really an af3_2x project is given.
Path sourcePath = new Path(sourceFile.getPath()); Path sourcePath = new Path(sourceFile.getPath());
// @CodeFormatterOff // @CodeFormatterOff
if( ! ( sourcePath.getFileExtension().equals(CURRENT_AF3_PROJECT_FILES_EXTENSION) if( ! ( sourcePath.getFileExtension().equals(CURRENT_AF3_PROJECT_FILES_EXTENSION)
|| sourcePath.getFileExtension().equals(AF3_20_TO_22_PROJECT_FILES_EXTENSION))) { || sourcePath.getFileExtension().equals(AF3_20_TO_22_PROJECT_FILES_EXTENSION))) {
openInformation(Display.getDefault().getActiveShell(), "Invalid AF3 project file", showInfo("Invalid AF3 project file: " + sourcePath.toString() + " is not an AF3 project!");
sourcePath.toString() + " is not an AF3 project!");
return; return;
} }
// @CodeFormatterOn // @CodeFormatterOn
...@@ -138,58 +157,28 @@ public class ImportProjectUtils { ...@@ -138,58 +157,28 @@ public class ImportProjectUtils {
URI projectURI = getDefaultGeneralProjectURI(); URI projectURI = getDefaultGeneralProjectURI();
URI sourceDir = sourceFileURI.trimSegments(1); URI sourceDir = sourceFileURI.trimSegments(1);
if(sourceDir.equals(projectURI)) { if(sourceDir.equals(projectURI)) {
showErrorInUIThread("Cannot import Project", showError("The selected project is located in the AF3 workspace" +
"The selected project is located in the AF3 workspace" + " folder. AF3 does not support importing AF3 projects" +
" folder. AF3 does not support importing AF3 projects" + " from this folder. Export the selected project to a" +
" from this folder. Export the selected project to a" + " different location first.");
" different location first.");
return; return;
} }
// If the general project doesn't exist, create one.
if(!generalProjectExists()) {
createNewGeneralProject();
}
// Isolate the file name from the path to it. // Isolate the file name from the path to it.
String sourceFileName = sourceFileURI.lastSegment(); String sourceFileName = sourceFileURI.lastSegment();
// Determine the file location of the target file. // Determine the file location of the target file.
URI targetFileURI = determineTargetFileLocation( URI targetFileURI = determineTargetFileLocation(
getDefaultGeneralProjectURI().appendSegment(sourceFileName)); getDefaultGeneralProjectURI().appendSegment(sourceFileName));
if(targetFileURI == null) { if(targetFileURI == null) {
// User cancelled // Operation was cancelled --> No log message.
return; return;
} }
// Copy the file. // Copy the file, its associated library, and external documents.
try { try {
// Load project to import (and adapt project name). ProjectUtils.importFileProject(sourceFileURI, targetFileURI);
Pair<EObject, Map<EObject, AnyType>> loadOutcome = } catch(IOException e) {
loadModelFromFileWithUnknownFeatures(createFileURI(sourceFile.toString()));
FileProject sourceFileProject = (FileProject)loadOutcome.getFirst();
// use a copy of EMF object to avoid the need for transaction
FileProject fpCopy = copy(sourceFileProject);
// delete file extension ".af3_2x" from file-name and set this as project name
fpCopy.setName(
targetFileURI.lastSegment().replace("." + targetFileURI.fileExtension(), ""));
saveProject(fpCopy, targetFileURI);
// check whether the imported project has some libraries attached to it it
String srcLibFolderPath = sourceFile.getParent() + File.separator + LIBRARY_LOCATION;
File sourceDirectory = new File(srcLibFolderPath);
if(sourceDirectory.exists()) {
File targetFile = new File(targetFileURI.toFileString());
String targetLibFolderPath =
targetFile.getParent() + File.separator + LIBRARY_LOCATION;
File targetDirectory = new File(targetLibFolderPath);
copyFiles(sourceDirectory, targetDirectory, new FileOnlyFilter());
}
// Copy referenced external documents along accordingly.
doCopyExternalDocuments(sourceFileProject, sourceFileURI, targetFileURI);
} catch(Exception e) {
error(getDefault(), "Error, cannot import AF3 project!", e); error(getDefault(), "Error, cannot import AF3 project!", e);
showErrorInUIThread("Error, cannot import AF3 project!", showErrorInUIThread("Error, cannot import AF3 project!",
"File '" + sourceFileName + "' is invalid"); "File '" + sourceFileName + "' is invalid");
......
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.project.ui.utils;
import java.io.File;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.fortiss.af3.project.storage.LocationProvider;
/**
* Provides methods for creating new AF3 projects.
*
* @author becker
* @author diewald
*/
public class NewProjectUiUtils {
/**
* Asks the user for another filename, if a file with the current name
* already exists.
*
* @param AF3Project
* the current file handler
* @return the new unique name
*/
static public String requestFileNameDialog(File AF3Project) {
String fileName = AF3Project.getName();
fileName = fileName.replace("." + LocationProvider.CURRENT_AF3_PROJECT_FILES_EXTENSION, "");
fileName = fileName.replace(" ", "_");
InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "",
"The project already exists, please choose a different name", fileName,
new FileNameValidatorUtil());
// If user clicked OK, update the file name to be unique.
if(dlg.open() == Window.OK) {
return dlg.getValue() + "." + LocationProvider.CURRENT_AF3_PROJECT_FILES_EXTENSION;
}
return null;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.project.ui.utils;
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.eclipse.emf.common.util.URI.createFileURI;
import static org.eclipse.jface.dialogs.MessageDialog.openError;
import static org.eclipse.jface.dialogs.MessageDialog.openInformation;
import static org.eclipse.ui.PlatformUI.getWorkbench;
import static org.eclipse.ui.ide.undo.WorkspaceUndoUtil.getUIInfoAdapter;
import static org.fortiss.af3.project.utils.FileUtils.AF3_PROJECT_DIRECTORY_NAME;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.info;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import org.eclipse.core.internal.resources.Project;
import org.eclipse.core.internal.resources.Workspace;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ide.undo.CreateProjectOperation;
import org.eclipse.ui.internal.wizards.newresource.ResourceMessages;
import org.fortiss.af3.project.AF3ProjectActivator;
import org.fortiss.af3.project.storage.LocationProvider;
import org.fortiss.af3.project.utils.FileUtils;
/**
* Provides methods for creating new AF3 projects.
*
* @author becker
*/
@SuppressWarnings("restriction")
public class NewProjectUtils {
/** The current workspace root. */
static private final IWorkspaceRoot workspaceRoot = getWorkspace().getRoot();
/** The File handler of the general project. */
static private final File GeneralProject = new File(
workspaceRoot.getLocation() + File.separator + FileUtils.AF3_PROJECT_DIRECTORY_NAME);
/** The default content of a general eclipse project file '.project'. */
// @CodeFormatterOff
static private final String defaultGeneralProjectFile =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<projectDescription>"
+ "<name>"
+ FileUtils.AF3_PROJECT_DIRECTORY_NAME
+ "</name>"
+ "<comment></comment>"
+ "<projects></projects>"
+ "<buildSpec></buildSpec>"
+ "<natures></natures>"
+ "</projectDescription>";
// @CodeFormatterOn
/** General Project. */
static private class GeneralProject extends Project {
/** Constructor. */