Commit 7043c3af authored by Johannes Eder's avatar Johannes Eder
Browse files

changed local document uris to relative paths

refs 1007
parent 2ef47f57
......@@ -27,9 +27,9 @@ import static org.fortiss.af3.mira.model.requirementSource.RequirementSourcePack
import static org.fortiss.af3.mira.model.requirementSource.RequirementSourcePackage.Literals.FILE_ITEM__VERSION;
import static org.fortiss.af3.mira.ui.AF3MiraUIActivator.PLUGIN_ID;
import static org.fortiss.af3.mira.ui.utils.HighlightUtils.createSourceViewer;
import static org.fortiss.af3.mira.ui.utils.RequirementDocumentFileUtils.PROJECT_DOCUMENT_SUBFOLDER;
import static org.fortiss.af3.mira.ui.utils.RequirementDocumentFileUtils.editFileLink;
import static org.fortiss.af3.mira.ui.utils.RequirementDocumentFileUtils.selectLocalFile;
import static org.fortiss.af3.project.ui.utils.NewProjectUtils.getDefaultGeneralProjectName;
import static org.fortiss.tooling.kernel.ui.util.DataBindingUtils.bind;
import java.awt.Desktop;
......@@ -62,6 +62,7 @@ import org.fortiss.af3.mira.model.requirementSource.FileItem;
import org.fortiss.af3.mira.model.requirementSource.RequirementDocument;
import org.fortiss.af3.mira.model.requirementSource.RequirementSourcePackage;
import org.fortiss.af3.mira.ui.AF3MiraUIActivator;
import org.fortiss.af3.project.ui.utils.NewProjectUtils;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
......@@ -133,7 +134,7 @@ public class FilePart {
this.document = document;
this.isLocal = isLocal;
this.dbc = dbc;
this.file = new File(fileItem.getUri());
this.file = new File(NewProjectUtils.getDefaultGeneralProjectPath(), fileItem.getUri());
this.form = form;
this.registeredSourceViewers = registeredSourceViewers;
}
......@@ -162,9 +163,8 @@ public class FilePart {
singleLineLabelFactory.applyTo(linkLabel);
final Hyperlink link =
toolkit.createHyperlink(fileComposite, fileItem.isIsLocal()
? getDefaultGeneralProjectName() + "/Document/" + fileItem.getName()
: fileItem.getUri(), SWT.NONE);
toolkit.createHyperlink(fileComposite,
fileItem.isIsLocal() ? file.getAbsolutePath() : fileItem.getUri(), SWT.NONE);
singleLineInputFactory.applyTo(link);
link.addMouseListener(new MouseAdapter() {
......@@ -215,12 +215,13 @@ public class FilePart {
if(isLocal) {
final File newFile = selectLocalFile(fileComposite);
if(newFile != null && !fileItem.getUri().equals(newFile.getPath())) {
if(newFile != null && !file.getPath().equals(newFile.getPath())) {
ICommandStackService.INSTANCE.runAsCommand(fileItem, new Runnable() {
@Override
public void run() {
fileItem.setName(newFile.getName());
fileItem.setUri(newFile.getPath());
fileItem.setUri(new File(PROJECT_DOCUMENT_SUBFOLDER, newFile
.getName()).getPath());
fileItem.setDescription("");
fileItem.setVersion("");
......@@ -249,8 +250,7 @@ public class FilePart {
}
}
link.setText(fileItem.isIsLocal() ? getDefaultGeneralProjectName() + "/Document/" +
fileItem.getName() : fileItem.getUri());
link.setText(fileItem.isIsLocal() ? file.getPath() : fileItem.getUri());
fileComposite.layout(true);
fileComposite.redraw();
composite.layout();
......@@ -348,10 +348,8 @@ public class FilePart {
/** Asks the user if the passed {@link FileItem} should be deleted */
private boolean askIfDelete(FileItem item) {
return openQuestion(composite.getShell(), "Illegal file",
"The file " +
(item.isIsLocal() ? getDefaultGeneralProjectName() + "/Document/" +
fileItem.getName() : item.getUri()) + " could not be found.\n" +
return openQuestion(composite.getShell(), "Illegal file", "The file " +
(item.isIsLocal() ? file.getPath() : item.getUri()) + " could not be found.\n" +
"Do you want to delete the reference to this file?");
}
......
......@@ -17,6 +17,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.editor.requirementSource;
import static org.fortiss.af3.mira.ui.utils.RequirementDocumentFileUtils.PROJECT_DOCUMENT_SUBFOLDER;
import static org.fortiss.af3.mira.ui.utils.RequirementDocumentFileUtils.editFileLink;
import static org.fortiss.af3.mira.ui.utils.RequirementDocumentFileUtils.selectLocalFile;
import static org.fortiss.af3.mira.utils.MiraModelElementFactory.createFileItem;
......@@ -131,7 +132,9 @@ public class FileSection {
File selectedFile = selectLocalFile(composite);
if(selectedFile != null && selectedFile.exists()) {
final FileItem newItem =
createFileItem(selectedFile.getPath(), selectedFile.getName(), true);
createFileItem(
new File(PROJECT_DOCUMENT_SUBFOLDER, selectedFile.getName())
.getPath(), selectedFile.getName(), true);
ICommandStackService.INSTANCE.runAsCommand(document, new Runnable() {
@Override
public void run() {
......
......@@ -43,6 +43,8 @@ import org.eclipse.swt.widgets.Shell;
*/
public class RequirementDocumentFileUtils {
public static final String PROJECT_DOCUMENT_SUBFOLDER = "Document";
/**
* edit file link
*
......@@ -87,7 +89,8 @@ public class RequirementDocumentFileUtils {
// the file will be copied to the document folder in the AF3
// Project directory
File sourceFile = new File(filepath);
File documentFolder = new File(getDefaultGeneralProjectPath(), "Document");
File documentFolder =
new File(getDefaultGeneralProjectPath(), PROJECT_DOCUMENT_SUBFOLDER);
// create document directory if it does not exists
if(!documentFolder.exists() || !documentFolder.isDirectory())
documentFolder.mkdir();
......
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