* The label of view
*/
public TmfXmlLatencyViewOutput(String viewid, String label) {
- super(viewid);
+ super(viewid, label);
fLabel = label;
}
public abstract class AbstractXmlViewInfo {
private final String fViewId;
- private @Nullable String fViewName;
+ private @Nullable String fSubsectionName;
/**
* Constructor
*/
public AbstractXmlViewInfo(String viewId) {
fViewId = viewId;
- fViewName = null;
+ fSubsectionName = null;
}
/**
- * Set the view's name, which should correspond to a secondary ID
+ * Set the name of the view property subsection, which should correspond to a secondary ID
*
* @param name
- * The view's name
+ * The name of the view property subsection
*/
public void setName(@NonNull String name) {
- fViewName = name;
+ fSubsectionName = name;
}
/**
- * Get the name of the view, which should correspond to the view's secondary
+ * Get the name of the view property subsection, which should correspond to the view's secondary
* ID. If this name is not null, it will never be null again
*
- * @return The name of the view
+ * @return The name of the view property subsection
*/
protected @Nullable String getName() {
- return fViewName;
+ return fSubsectionName;
}
/**
throw new IllegalStateException("The persistent property section could not be added " + fViewId); //$NON-NLS-1$
}
}
- if (fViewName == null) {
+ if (fSubsectionName == null) {
return section;
}
// FIXME: when a file is removed from TraceCompass, its view section should also be deleted
- IDialogSettings subSection = section.getSection(fViewName);
+ IDialogSettings subSection = section.getSection(fSubsectionName);
if (subSection == null) {
- subSection = section.addNewSection(fViewName);
+ subSection = section.addNewSection(fSubsectionName);
if (subSection == null) {
- throw new IllegalStateException("The persistent property section could not be added: " + fViewName); //$NON-NLS-1$
+ throw new IllegalStateException("The persistent property section could not be added: " + fSubsectionName); //$NON-NLS-1$
}
}
return subSection;
private @Nullable String fAnalysisId = null;
private @Nullable String fLabel = null;
+ // If true, properties were set but not saved to persistent storage
+ private boolean fIsDirty = false;
/**
* Constructor
return fLabel;
}
+ @Override
+ public synchronized void setName(String name) {
+ super.setName(name);
+ if (fIsDirty) {
+ savePersistentData();
+ } else {
+ IDialogSettings settings = getPersistentPropertyStore();
+ fAnalysisId = settings.get(XML_LATENCY_VIEW_ANALYSIS_ID_PROPERTY);
+ fLabel = settings.get(XML_LATENCY_VIEW_LABEL_PROPERTY);
+ }
+ }
+
/**
* Set the data for this view and retrieves from it the analysis ID of the
* pattern analysis this view belongs to and the view label.
String[] idFile = data.split(TmfXmlAnalysisOutputSource.DATA_SEPARATOR);
fAnalysisId = (idFile.length > 0) ? idFile[0] : null;
fLabel = (idFile.length > 1) ? idFile[1] : null;
- savePersistentData();
+ String viewSubsectionName = getName();
+ if (viewSubsectionName != null) {
+ savePersistentData();
+ } else {
+ fIsDirty = true;
+ }
}
@Override
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.CountDownLatch;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
private static final String XML_VIEW_ID_PROPERTY = "XmlViewId"; //$NON-NLS-1$
private static final String XML_VIEW_FILE_PROPERTY = "XmlViewFile"; //$NON-NLS-1$
- /* Initialization is completed when name is set */
- private final CountDownLatch fInitialized = new CountDownLatch(1);
/** This is the ID of the view described in the XML file */
private @Nullable String fId = null;
private @Nullable String fFilePath = null;
/* Cannot get the properties yet, need to wait for the name */
}
- /**
- * Waits for the view info's initialization to be completed. This happens
- * once the name has been set
- *
- * @return Whether the initialization has completed successfully
- */
- public boolean waitForInitialization() {
- try {
- fInitialized.await();
- } catch (InterruptedException e) {
- return false;
- }
- return true;
- }
-
/**
* Set the data for this view and retrieves from it the view ID and the file
* path of the XML element this view uses.
fId = settings.get(XML_VIEW_ID_PROPERTY);
fFilePath = settings.get(XML_VIEW_FILE_PROPERTY);
}
- fInitialized.countDown();
}
@Override
package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Table;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density.AbstractSegmentStoreDensityView;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.density.AbstractSegmentStoreDensityViewer;
});
}
+ @Override
+ public void createPartControl(@Nullable Composite parent) {
+ String name = getViewSite().getSecondaryId();
+ if (name != null) {
+ /* must initialize view info before calling super */
+ fViewInfo.setName(name);
+ }
+ super.createPartControl(parent);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setPartName(fViewInfo.getLabel());
+ }
+ });
+ }
+
private void loadTableViewer() {
if (fTableViewer != null) {
fTableViewer.updateViewer(fViewInfo.getViewAnalysisId());
package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableView;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table.AbstractSegmentStoreTableViewer;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
});
}
+ @Override
+ public void createPartControl(@Nullable Composite parent) {
+ String name = getViewSite().getSecondaryId();
+ if (name != null) {
+ /* must initialize view info before calling super */
+ fViewInfo.setName(name);
+ }
+ super.createPartControl(parent);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setPartName(fViewInfo.getLabel());
+ }
+ });
+ }
+
private void loadLatencyView() {
if (fViewer != null) {
fViewer.updateViewer(fViewInfo.getViewAnalysisId());
import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlLatencyViewInfo;
import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer;
});
}
+ @Override
+ public void createPartControl(@Nullable Composite parent) {
+ String name = getViewSite().getSecondaryId();
+ if (name != null) {
+ /* must initialize view info before calling super */
+ fViewInfo.setName(name);
+ }
+ super.createPartControl(parent);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setPartName(fViewInfo.getLabel());
+ }
+ });
+ }
+
private void loadLatencyView() {
if (fViewer != null) {
fViewer.updateViewer(fViewInfo.getViewAnalysisId());
package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.statistics.AbstractSegmentsStatisticsView;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlLatencyViewInfo;
});
}
+ @Override
+ public void createPartControl(@Nullable Composite parent) {
+ String name = getViewSite().getSecondaryId();
+ if (name != null) {
+ /* must initialize view info before calling super */
+ fViewInfo.setName(name);
+ }
+ super.createPartControl(parent);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ setPartName(fViewInfo.getLabel());
+ }
+ });
+ }
+
private void loadStatisticView() {
if (fViewer != null) {
fViewer.updateViewer(fViewInfo.getViewAnalysisId());