Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -103,6 +104,8 @@ public class ExperimentManagerService {
private static final String EXPERIMENTS_FOLDER = "Experiments"; //$NON-NLS-1$
private static final String TRACES_FOLDER = "Traces"; //$NON-NLS-1$
private static final String SUFFIX = "_exp"; //$NON-NLS-1$
private static final String BOOKMARKS_HIDDEN_FILE = ".bookmarks"; //$NON-NLS-1$
private static final String EXPERIMENT_EDITOR_INPUT_TYPE = "editorInputType.experiment"; //$NON-NLS-1$

/**
* Getter for the list of experiments from the trace manager
Expand Down Expand Up @@ -374,7 +377,7 @@ public Response postExperiment(@RequestBody(content = {
experiment.getNext(ctx);
ctx.dispose();

TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(ExperimentManagerService.class, experiment, null));
TmfSignalManager.dispatchSignal(new TmfTraceOpenedSignal(ExperimentManagerService.class, experiment, createBookmarksFile(resource)));

EXPERIMENTS.put(expUUID, experiment);
TRACE_INSTANCES.put(expUUID, uuidToTraceInstances);
Expand Down Expand Up @@ -495,6 +498,24 @@ private static void createSupplementaryFolder(IResource experimentResource) {
}
}

private static IFile createBookmarksFile(IResource resource) {
IFile file = ((IFolder) resource).getFile(resource.getName() + '_');
try {
if (!file.exists()) {
final IFile bookmarksFile = ((IFolder) resource.getParent()).getFile(BOOKMARKS_HIDDEN_FILE);
if (!bookmarksFile.exists()) {
final InputStream source = new ByteArrayInputStream(new byte[0]);
bookmarksFile.create(source, IResource.FORCE | IResource.HIDDEN, new NullProgressMonitor());
}
file.createLink(bookmarksFile.getLocation(), IResource.REPLACE | IResource.HIDDEN, new NullProgressMonitor());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IResource.FORCE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to createLink() Javadoc, only the mentioned flags have an effect while other flags are ignored, and FORCE is not mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the other one then TmfCommonProjectElement.java:394

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's handled in create() but ignored in createLink().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 still applies.

}
file.setPersistentProperty(TmfCommonConstants.TRACETYPE, EXPERIMENT_EDITOR_INPUT_TYPE);
} catch (CoreException e) {
Activator.getInstance().logWarning("Error creating bookmarks file", e); //$NON-NLS-1$
}
return file;
}

private static void createFolder(IFolder folder) throws CoreException {
if (!folder.exists()) {
if (folder.getParent() instanceof IFolder) {
Expand Down