Search in sources :

Example 1 with OutputStyleModel

use of org.eclipse.tracecompass.tmf.core.model.OutputStyleModel in project tracecompass by tracecompass.

the class BaseXYPresentationProvider method fetchStyles.

/**
 * Use the
 * {@link IOutputStyleProvider#fetchStyle(Map, org.eclipse.core.runtime.IProgressMonitor)}
 * to fetch the appropriate style for a specific provider ID given by
 * getProviderId. Everything is stored in a map of styles where the keys are
 * string that will be used in states and the value are
 * {@link OutputElementStyle}
 *
 * @return The style map
 */
private Map<@NonNull String, @NonNull OutputElementStyle> fetchStyles() {
    Map<String, OutputElementStyle> stylesMap = fStylesMap;
    if (stylesMap == null) {
        stylesMap = new LinkedHashMap<>();
        synchronized (fProviders) {
            for (ITmfTreeXYDataProvider<?> provider : fProviders) {
                if (provider instanceof IOutputStyleProvider) {
                    TmfModelResponse<@NonNull OutputStyleModel> styleResponse = ((IOutputStyleProvider) provider).fetchStyle(getStyleParameters(), null);
                    OutputStyleModel styleModel = styleResponse.getModel();
                    if (styleModel != null) {
                        for (Entry<String, OutputElementStyle> entry : styleModel.getStyles().entrySet()) {
                            OutputElementStyle style = entry.getValue();
                            // Make sure the style values map is mutable
                            stylesMap.put(entry.getKey(), new OutputElementStyle(style.getParentKey(), Maps.newHashMap(style.getStyleValues())));
                        }
                    }
                }
            }
        }
        fStylesMap = stylesMap;
    }
    return stylesMap;
}
Also used : OutputStyleModel(org.eclipse.tracecompass.tmf.core.model.OutputStyleModel) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) IOutputStyleProvider(org.eclipse.tracecompass.tmf.core.model.IOutputStyleProvider)

Example 2 with OutputStyleModel

use of org.eclipse.tracecompass.tmf.core.model.OutputStyleModel in project tracecompass by tracecompass.

the class BaseDataProviderTimeGraphPresentationProvider method fetchStyles.

/**
 * Use the
 * {@link IOutputStyleProvider#fetchStyle(Map, org.eclipse.core.runtime.IProgressMonitor)}
 * to fetch the appropriate style for a specific provider ID given by
 * getProviderId. Everything is stored in a map of styles where the keys are
 * string that will be used in states and the value are
 * {@link OutputElementStyle}
 *
 * @return The style map
 */
private Map<@NonNull String, @NonNull OutputElementStyle> fetchStyles() {
    Map<String, OutputElementStyle> stylesMap = fStylesMap;
    if (stylesMap == null) {
        stylesMap = new LinkedHashMap<>();
        synchronized (fProviders) {
            for (ITimeGraphDataProvider<?> provider : fProviders.keySet()) {
                if (provider instanceof IOutputStyleProvider) {
                    TmfModelResponse<@NonNull OutputStyleModel> styleResponse = ((IOutputStyleProvider) provider).fetchStyle(getStyleParameters(), null);
                    OutputStyleModel styleModel = styleResponse.getModel();
                    if (styleModel != null) {
                        for (Entry<String, OutputElementStyle> entry : styleModel.getStyles().entrySet()) {
                            OutputElementStyle style = entry.getValue();
                            // Make sure the style values map is mutable
                            stylesMap.put(entry.getKey(), new OutputElementStyle(style.getParentKey(), Maps.newHashMap(style.getStyleValues())));
                        }
                    }
                }
            }
        }
        fStylesMap = stylesMap;
    }
    return stylesMap;
}
Also used : OutputStyleModel(org.eclipse.tracecompass.tmf.core.model.OutputStyleModel) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) IOutputStyleProvider(org.eclipse.tracecompass.tmf.core.model.IOutputStyleProvider)

Example 3 with OutputStyleModel

use of org.eclipse.tracecompass.tmf.core.model.OutputStyleModel in project tracecompass by tracecompass.

the class TmfTimeGraphCompositeDataProvider method fetchStyle.

@Override
public TmfModelResponse<OutputStyleModel> fetchStyle(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    Map<String, OutputElementStyle> styles = new HashMap<>();
    for (P dataProvider : getProviders()) {
        if (dataProvider instanceof IOutputStyleProvider) {
            TmfModelResponse<OutputStyleModel> response = ((IOutputStyleProvider) dataProvider).fetchStyle(fetchParameters, monitor);
            OutputStyleModel model = response.getModel();
            if (model != null) {
                styles.putAll(model.getStyles());
            }
        }
    }
    if (styles.isEmpty()) {
        return new TmfModelResponse<>(null, ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
    }
    return new TmfModelResponse<>(new OutputStyleModel(styles), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
}
Also used : OutputStyleModel(org.eclipse.tracecompass.tmf.core.model.OutputStyleModel) OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IOutputStyleProvider(org.eclipse.tracecompass.tmf.core.model.IOutputStyleProvider) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)

Aggregations

IOutputStyleProvider (org.eclipse.tracecompass.tmf.core.model.IOutputStyleProvider)3 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)3 OutputStyleModel (org.eclipse.tracecompass.tmf.core.model.OutputStyleModel)3 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)1