import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.layout.GridDataFactory;
import org.simantics.browsing.ui.common.processors.IsExpandedProcessor;
import org.simantics.browsing.ui.common.processors.NoSelectionRequestProcessor;
import org.simantics.browsing.ui.common.processors.ProcessorLifecycle;
+import org.simantics.browsing.ui.common.state.ExplorerStates;
import org.simantics.browsing.ui.content.ImageDecorator;
import org.simantics.browsing.ui.content.Imager;
import org.simantics.browsing.ui.content.LabelDecorator;
import org.simantics.utils.threads.ThreadUtils;
import org.simantics.utils.ui.AdaptionUtils;
import org.simantics.utils.ui.ISelectionUtils;
+import org.simantics.utils.ui.SWTUtils;
import org.simantics.utils.ui.jface.BasePostSelectionProvider;
import gnu.trove.map.hash.THashMap;
private void initializeState() {
if (persistor == null)
return;
+ ExplorerStates.scheduleRead(getRoot(), persistor)
+ .thenAccept(state -> SWTUtils.asyncExec(viewer.getTree(), () -> restoreState(state)));
+ }
- ExplorerState state = persistor.deserialize(
- Platform.getStateLocation(Activator.getDefault().getBundle()).toFile(),
- getRoot());
-
-
+ private void restoreState(ExplorerState state) {
Object processor = getPrimitiveProcessor(BuiltinKeys.IS_EXPANDED);
if (processor instanceof DefaultIsExpandedProcessor) {
DefaultIsExpandedProcessor isExpandedProcessor = (DefaultIsExpandedProcessor)processor;
for(NodeContext expanded : state.expandedNodes) {
- isExpandedProcessor.setExpanded(expanded, true);
+ isExpandedProcessor.replaceExpanded(expanded, true);
}
}
}
private void doSetColumns(Column[] cols, Consumer<Map<Column, Object>> callback) {
// Attempt to keep previous column widths.
- Map<String, Integer> prevWidths = new HashMap<String, Integer>();
-
+ Map<String, Integer> prevWidths = new HashMap<>();
for (TreeViewerColumn c : treeViewerColumns) {
- prevWidths.put(c.getColumn().getText(), c.getColumn().getWidth());
- c.getColumn().dispose();
+ Column col = (Column) (c.getColumn().getData());
+ if (col != null)
+ prevWidths.put(col.getKey(), c.getColumn().getWidth());
+ c.getColumn().dispose();
}
-
+
treeViewerColumns.clear();
HashMap<String, Integer> keyToIndex = new HashMap<String, Integer>();
int cw = column.getWidth();
// Try to keep previous widths
- Integer w = prevWidths.get(column);
+ Integer w = prevWidths.get(column.getKey());
if (w != null)
c.setWidth(w);
else if (cw != Column.DEFAULT_CONTROL_WIDTH)
return context == null;
}
- @SuppressWarnings("rawtypes")
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == NodeContext.class)
- return context;
+ return (T) context;
return context.getAdapter(adapter);
}
* store the key, this is not used.
*/
NodeContext getNC = new NodeContext() {
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
+ @Override
+ public <T> T getAdapter(Class<T> adapter) {
return null;
}