Commit 328d7b8a authored by Christoph Döbber's avatar Christoph Döbber
Browse files

working on import/export

refs 1007
parent fd8054a2
......@@ -154,9 +154,7 @@ public class ImageBox {
try {
// open the file in the system image viewer when the user
// clicks on the picture
getDesktop().open(
new File(new File(getDefaultGeneralProjectPath(), "images"), imageItem
.getUri()));
getDesktop().open(new File(getDefaultGeneralProjectPath(), imageItem.getUri()));
} catch(IOException e1) {
e1.printStackTrace();
}
......
......@@ -182,8 +182,8 @@ public class ImageSection {
ioe.printStackTrace();
return;
}
newItem.setUri(new File(PROJECT_IMAGE_SUBFOLDER, destFile.getName()).getPath());
String uri = new File(PROJECT_IMAGE_SUBFOLDER, destFile.getName()).getPath();
newItem.setUri(uri);
ICommandStackService.INSTANCE.runAsCommand(editedObject, new Runnable() {
@Override
......
......@@ -142,8 +142,8 @@ public class ImageUtils {
/**
* Returns the file with the absolute path for the image item. For the image only its name
* is saved because the location is always the image folder in the AF3
* Project directory. Like this the data can easily exchanged and the
* is saved along with the location of the image folder in the AF3
* Project directory. Like this the data can easily be exchanged and the
* system-dependent absolute path is only generated if needed.
*
* @param item
......@@ -151,7 +151,6 @@ public class ImageUtils {
* @return the absolute path
*/
public static File getImageFile(ImageItem item) {
File f1 = new File(getDefaultGeneralProjectPath(), PROJECT_IMAGE_SUBFOLDER);
return new File(f1, item.getUri());
return new File(getDefaultGeneralProjectPath(), item.getUri());
}
}
......@@ -70,7 +70,8 @@ public class AnalysisMigrationProvider implements IMigrationProvider {
migrateRequirements1057((Analysis)projectRootElement);
migrateRequirementRelations1005((Analysis)projectRootElement);
// TODO (CD) remove after release of 2.4 AUG 2013
// TODO (CD) remove after release of 2.4 AUG 2013 as well as additional attributes
// in ecore
migrateImageAndFileURIs1007((Analysis)projectRootElement);
}
......@@ -121,7 +122,8 @@ public class AnalysisMigrationProvider implements IMigrationProvider {
* @param analysis
*/
private void migrateImageAndFileURIs1007(Analysis analysis) {
String oldImagesFolder = "images";
final String PROJECT_IMAGE_SUBFOLDER = "images";
TreeIterator<EObject> iterator = analysis.eAllContents();
while(iterator.hasNext()) {
EObject object = iterator.next();
......@@ -130,7 +132,7 @@ public class AnalysisMigrationProvider implements IMigrationProvider {
if(item.getUrl() != null) {
File f = new File(item.getUrl());
if(f.exists()) {
item.setUri(new File(f.getParent(), f.getName()).getPath());
item.setUri(new File(f.getParentFile().getName(), f.getName()).getPath());
} else {
item.setUri(item.getUrl());
}
......@@ -140,7 +142,7 @@ public class AnalysisMigrationProvider implements IMigrationProvider {
if(object instanceof ImageItem) {
ImageItem item = (ImageItem)object;
if(item.getPath() != null) {
item.setUri(oldImagesFolder + item.getPath());
item.setUri(new File(PROJECT_IMAGE_SUBFOLDER, item.getPath()).getPath());
item.setPath(null);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment