Skip to content

Commit

Permalink
Bug 579875: Set the ScriptedTimeGraphView title to the DP name
Browse files Browse the repository at this point in the history
Change-Id: I55ccb3079febab046bb355506380ba8fa05b44bc
Signed-off-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/193301
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
  • Loading branch information
bhufmann committed May 16, 2022
1 parent 84c41e3 commit 43838ed
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 École Polytechnique de Montréal
* Copyright (c) 2019, 2022 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -140,4 +140,33 @@ public void traceClosed(final TmfTraceClosedSignal signal) {
}).start();
}

/**
* Constructs a scripted data provider ID from the provider name:
* "PROVIDER_ID:dpName"
*
* @param providerName
* the secondary ID string
* @return scripted data provider ID
*/
public static String createProviderId(String providerName) {
return PROVIDER_ID + DataProviderConstants.ID_SEPARATOR + providerName;
}

/**
* This method extracts the data provider name from provider IDs.
*
* Scripted data provider have the data provider name encoded in the
* data provider ID: "PROVIDER_ID:dpName".
*
* @param providerId the input data provider ID
*
* @return the data provider secondary name or null
*/
public static @Nullable String extractProviderName(String providerId) {
int index = providerId.indexOf(DataProviderConstants.ID_SEPARATOR);
if ((index > 0) && index < providerId.length() - 1) {
return providerId.substring(index + 1);
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 École Polytechnique de Montréal
* Copyright (c) 2019, 2022 École Polytechnique de Montréal and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -229,7 +229,7 @@ public class DataProviderScriptingModule {
DataDrivenOutputEntry entry = new DataDrivenOutputEntry(Collections.emptyList(), path, null, true,
display, id, parent, name, DisplayType.ABSOLUTE);

ITimeGraphDataProvider<TimeGraphEntryModel> provider = DataDrivenTimeGraphProviderFactory.create(trace, stateSystems, Collections.singletonList(entry), Collections.emptyList(), ScriptingDataProviderManager.PROVIDER_ID + DataProviderConstants.ID_SEPARATOR + analysisName);
ITimeGraphDataProvider<TimeGraphEntryModel> provider = DataDrivenTimeGraphProviderFactory.create(trace, stateSystems, Collections.singletonList(entry), Collections.emptyList(), ScriptingDataProviderManager.createProviderId(analysisName));
ScriptingDataProviderManager.getInstance().registerDataProvider(trace, provider);
return provider;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 École Polytechnique de Montréal
* Copyright (c) 2019, 2022 École Polytechnique de Montréal and 0thers
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand All @@ -16,7 +16,10 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.common.core.NonNullUtils;
import org.eclipse.tracecompass.incubator.internal.scripting.core.data.provider.ScriptedTimeGraphDataProvider;
import org.eclipse.tracecompass.incubator.internal.scripting.core.data.provider.ScriptingDataProviderManager;
import org.eclipse.tracecompass.tmf.core.component.DataProviderConstants;
import org.eclipse.tracecompass.tmf.core.dataprovider.DataProviderManager;
import org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphDataProvider;
Expand Down Expand Up @@ -55,6 +58,15 @@ public ScriptedTimeGraphView() {
super(ID, new BasePresentationProvider(), ScriptedTimeGraphDataProvider.ID);
}

@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
String title = ScriptingDataProviderManager.extractProviderName(NonNullUtils.nullToEmptyString(getProviderId()));
if (title != null) {
setPartName(title);
}
}

@Override
protected String getProviderId() {
String secondaryId = getViewSite().getSecondaryId();
Expand Down Expand Up @@ -88,5 +100,4 @@ protected void buildEntryList(@NonNull ITmfTrace trace, @NonNull ITmfTrace paren
fProvider = dataProvider;
super.buildEntryList(trace, parentTrace, monitor);
}

}

0 comments on commit 43838ed

Please sign in to comment.