use of org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement in project tracecompass by tracecompass.
the class RemoteFetchLogWizardRemotePage method determinePageCompletion.
@Override
protected boolean determinePageCompletion() {
if (getElementViewer().getCheckedElements().length <= 0) {
return false;
}
validateProject();
if ((fExperimentName != null) && (fCreateExperimentCheckbox.getSelection())) {
String name = fExperimentNameText.getText().trim();
// verify if experiment name is empty
if (name.isEmpty()) {
setMessage(null);
setErrorMessage(RemoteMessages.RemoteFetchLogWizardRemotePage_ErrorEmptyExperimentName);
return false;
}
// verify that name is a valid resource name
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if ((workspace != null) && (!workspace.validateName(name, IResource.FILE).isOK())) {
setMessage(null);
setErrorMessage(NLS.bind(RemoteMessages.RemoteFetchLogWizardRemotePage_ErrorExperimentNameInvalid, name));
return false;
}
TmfExperimentFolder experimentFolder = fExperimentFolderElement;
if (experimentFolder != null) {
TmfExperimentElement element = experimentFolder.getExperiment(name);
// verify if experiment already exists
if (element != null) {
setMessage(null);
setErrorMessage(NLS.bind(RemoteMessages.RemoteFetchLogWizardRemotePage_ErrorExperimentAlreadyExists, name));
return false;
}
// verify if a resource already exists in the experiment folder
IFolder expResource = experimentFolder.getResource();
IResource res = expResource.findMember(name);
if (res != null) {
setMessage(null);
setErrorMessage(NLS.bind(RemoteMessages.RemoteFetchLogWizardRemotePage_ErrorResourceAlreadyExists, name));
return false;
}
}
}
return true;
}
use of org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement in project tracecompass by tracecompass.
the class SWTBotUtils method createExperiment.
/**
* Creates an experiment
*
* @param bot
* a given workbench bot
* @param projectName
* the name of the project, creates the project if needed
* @param expName
* the experiment name
*/
public static void createExperiment(SWTWorkbenchBot bot, String projectName, @NonNull final String expName) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
TmfProjectElement tmfProject = TmfProjectRegistry.getProject(project, true);
TmfExperimentFolder expFolder = tmfProject.getExperimentsFolder();
assertNotNull(expFolder);
NewExperimentOperation operation = new NewExperimentOperation(expFolder, expName);
operation.run(new NullProgressMonitor());
bot.waitUntil(new DefaultCondition() {
@Override
public boolean test() throws Exception {
TmfExperimentElement experiment = expFolder.getExperiment(expName);
return experiment != null;
}
@Override
public String getFailureMessage() {
return "Experiment (" + expName + ") couldn't be created";
}
});
}
use of org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement in project tracecompass by tracecompass.
the class ImportTraceWizardPage method validateOptionsGroup.
@Override
protected boolean validateOptionsGroup() {
if (fCreateExperimentCheckbox != null && fCreateExperimentCheckbox.getSelection()) {
String name = fExperimentNameText.getText().trim();
// verify if experiment name is empty
if (name.isEmpty()) {
setMessage(null);
setErrorMessage(Messages.ImportTraceWizard_ErrorEmptyExperimentName);
return false;
}
// verify that name is a valid resource name
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if ((workspace != null) && (!workspace.validateName(name, IResource.FILE).isOK())) {
setMessage(null);
setErrorMessage(NLS.bind(Messages.ImportTraceWizard_ErrorExperimentNameInvalid, name));
return false;
}
// verify if experiment already exists
if (fExperimentFolderElement != null) {
TmfExperimentElement element = fExperimentFolderElement.getExperiment(name);
if (element != null) {
setMessage(null);
setErrorMessage(NLS.bind(Messages.ImportTraceWizard_ErrorExperimentAlreadyExists, name));
return false;
}
IFolder expResource = fExperimentFolderElement.getResource();
IResource res = expResource.findMember(name);
if (res != null) {
setMessage(null);
setErrorMessage(NLS.bind(Messages.ImportTraceWizard_ErrorResourceAlreadyExists, name));
return false;
}
}
}
if (fTimeRangeCheckbox != null && fTimeRangeCheckbox.getSelection() && !validateTimeRange()) {
fStartTimestamp = null;
fEndTimestamp = null;
setMessage(null);
setErrorMessage(Messages.ImportTraceWizard_TimeRangeErrorMessage);
return false;
}
setErrorMessage(null);
return true;
}
use of org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement in project tracecompass by tracecompass.
the class ExportTracePackageWizardPage method createElementViewerInput.
@Override
protected Object createElementViewerInput() {
List<TracePackageTraceElement> traceElements = new ArrayList<>();
for (TmfCommonProjectElement projectElement : fSelectedTraces) {
TracePackageTraceElement traceElement;
if (projectElement instanceof TmfExperimentElement) {
TmfExperimentElement experimentElement = (TmfExperimentElement) projectElement;
traceElement = new TracePackageExperimentElement(null, experimentElement);
for (TmfTraceElement expTrace : experimentElement.getTraces()) {
((TracePackageExperimentElement) traceElement).addExpTrace(expTrace.getElementPath());
}
} else {
traceElement = new TracePackageTraceElement(null, projectElement);
}
// Trace files
TracePackageFilesElement filesElement = new TracePackageFilesElement(traceElement, projectElement.getResource());
filesElement.setChecked(true);
// Supplementary files
try {
String supplementaryFolder = projectElement.getResource().getPersistentProperty(TmfCommonConstants.TRACE_SUPPLEMENTARY_FOLDER);
TracePackageSupplFilesElement suppFilesElement = new TracePackageSupplFilesElement(null);
IResource[] supplementaryResources = projectElement.getSupplementaryResources();
for (IResource res : supplementaryResources) {
String name = supplementaryFolder == null ? res.getName() : res.getLocation().makeRelativeTo(new Path(supplementaryFolder)).toString();
new TracePackageSupplFileElement(res, name, suppFilesElement);
}
if (supplementaryFolder != null) {
// If the supplementary folder path is in a shadow project,
// the resources must be taken from the parent project.
IFolder projectSupplementaryFolder = projectElement.getProject().getSupplementaryFolder();
IPath path = new Path(supplementaryFolder).append(TmfCommonConstants.TRACE_PROPERTIES_FOLDER);
IFolder propertiesFolder = projectSupplementaryFolder.getFolder(path.makeRelativeTo(projectSupplementaryFolder.getLocation()));
if (propertiesFolder.exists()) {
for (IResource res : propertiesFolder.members()) {
String name = res.getLocation().makeRelativeTo(new Path(supplementaryFolder)).toString();
new TracePackageSupplFileElement(res, name, suppFilesElement);
}
}
}
if (suppFilesElement.getChildren().length > 0) {
traceElement.addChild(suppFilesElement);
}
} catch (CoreException e) {
// Should not happen
// $NON-NLS-1$
Activator.getDefault().logError("Error finding supplementary files", e);
}
// Bookmarks
IFile bookmarksFile = projectElement.getBookmarksFile();
if (bookmarksFile != null && bookmarksFile.exists()) {
IMarker[] findMarkers;
try {
findMarkers = bookmarksFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO);
if (findMarkers.length > 0) {
new TracePackageBookmarkElement(traceElement, null);
}
} catch (CoreException e) {
// Should not happen since we just checked bookmarksFile.exists() but log it just in case
// $NON-NLS-1$
Activator.getDefault().logError("Error finding bookmarks", e);
}
}
traceElements.add(traceElement);
}
return traceElements.toArray(new TracePackageTraceElement[] {});
}
use of org.eclipse.tracecompass.tmf.ui.project.model.TmfExperimentElement in project tracecompass by tracecompass.
the class TracePackageImportOperation method getMatchingProjectElement.
/**
* Return the matching TmfTraceElement for a given trace element.
*/
private TmfCommonProjectElement getMatchingProjectElement(TracePackageTraceElement tracePackageElement) {
if (tracePackageElement instanceof TracePackageExperimentElement) {
for (TmfExperimentElement experiment : fTmfExperimentFolder.getExperiments()) {
if (experiment.getName().equals(tracePackageElement.getImportName())) {
return experiment;
}
}
} else {
IPath tracePath = fTmfTraceFolder.getPath().append(tracePackageElement.getDestinationElementPath());
List<TmfTraceElement> traces = fTmfTraceFolder.getTraces();
for (TmfTraceElement t : traces) {
if (t.getPath().equals(tracePath)) {
return t;
}
}
}
return null;
}
Aggregations