use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class LayoutMenuPopulator method menuSelected.
@Override
public void menuSelected(MenuEvent e) {
final CyApplicationManager appMgr = serviceRegistrar.getService(CyApplicationManager.class);
final DialogTaskManager tm = serviceRegistrar.getService(DialogTaskManager.class);
CyNetworkView view = appMgr.getCurrentNetworkView();
CyNetwork network = appMgr.getCurrentNetwork();
// Figure out if we have anything selected
boolean someSelected = false;
if (network != null)
someSelected = network.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0;
boolean enableMenuItem = checkEnabled();
// Get all of the algorithms
for (CyLayoutAlgorithm layout : algorithmMap.keySet()) {
Map props = algorithmMap.get(layout);
double gravity = 1000.0;
if (props.get(MENU_GRAVITY) != null)
gravity = Double.parseDouble((String) props.get(MENU_GRAVITY));
boolean separatorAfter = false;
if (props.get(INSERT_SEPARATOR_AFTER) != null)
separatorAfter = Boolean.parseBoolean((String) props.get(INSERT_SEPARATOR_AFTER));
boolean separatorBefore = false;
if (props.get(INSERT_SEPARATOR_BEFORE) != null)
separatorBefore = Boolean.parseBoolean((String) props.get(INSERT_SEPARATOR_BEFORE));
// Remove the old menu
if (menuMap.containsKey(layout)) {
layoutMenu.remove(menuMap.remove(layout));
}
boolean usesNodeAttrs = false;
if (network != null)
usesNodeAttrs = hasValidAttributes(layout.getSupportedNodeAttributeTypes(), network.getDefaultNodeTable());
boolean usesEdgeAttrs = false;
if (network != null)
usesEdgeAttrs = hasValidAttributes(layout.getSupportedEdgeAttributeTypes(), network.getDefaultEdgeTable());
boolean usesSelected = (layout.getSupportsSelectedOnly() && someSelected);
if (usesNodeAttrs || usesEdgeAttrs || usesSelected) {
JMenu newMenu = new DynamicLayoutMenu(layout, network, enableMenuItem, appMgr, tm, usesNodeAttrs, usesEdgeAttrs, usesSelected);
menuMap.put(layout, newMenu);
gravityTracker.addMenu(newMenu, gravity);
} else {
JMenuItem newMenu = new StaticLayoutMenu(layout, enableMenuItem, appMgr, tm);
menuMap.put(layout, newMenu);
gravityTracker.addMenuItem(newMenu, gravity);
}
if (separatorAfter && !separatorMap.containsKey(layout)) {
gravityTracker.addMenuSeparator(gravity + 0.0001);
separatorMap.put(layout, Boolean.TRUE);
} else if (separatorBefore && !separatorMap.containsKey(layout)) {
gravityTracker.addMenuSeparator(gravity - 0.0001);
separatorMap.put(layout, Boolean.TRUE);
}
}
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class ImportDefaultVisualStylesCommand method execute.
@Override
public void execute(final INotification notification) {
final TaskIterator iterator = new TaskIterator(new ImportDefaultVizmapTask(servicesUtil));
final DialogTaskManager taskManager = servicesUtil.get(DialogTaskManager.class);
final VizMapperProxy proxy = (VizMapperProxy) getFacade().retrieveProxy(VizMapperProxy.NAME);
proxy.setIgnoreStyleEvents(true);
taskManager.execute(iterator, new TaskObserver() {
@Override
public void taskFinished(ObservableTask task) {
}
@Override
public void allFinished(FinishStatus finishStatus) {
proxy.setIgnoreStyleEvents(false);
proxy.loadVisualStyles();
proxy.setCurrentVisualStyle(servicesUtil.get(VisualMappingManager.class).getDefaultVisualStyle());
}
});
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class RemoveLockedValuesCommand method execute.
@Override
public void execute(final INotification notification) {
final LockedValuesVO vo = (LockedValuesVO) notification.getBody();
final Set<VisualProperty<?>> visualProperties = vo.getVisualProperties();
if (visualProperties == null)
return;
CyNetworkView netView = vo.getNetworkView();
Set<View<? extends CyIdentifiable>> views = vo.getViews();
final VizMapperProxy vmProxy = (VizMapperProxy) getFacade().retrieveProxy(VizMapperProxy.NAME);
if (netView == null)
netView = vmProxy.getCurrentNetworkView();
if (netView != null && views == null) {
// Get the selected views
final Set<Class<? extends CyIdentifiable>> targetDataTypes = new HashSet<Class<? extends CyIdentifiable>>();
for (final VisualProperty<?> vp : visualProperties) targetDataTypes.add(vp.getTargetDataType());
views = new HashSet<View<? extends CyIdentifiable>>();
if (targetDataTypes.contains(CyNode.class))
views.addAll(vmProxy.getSelectedNodeViews(netView));
if (targetDataTypes.contains(CyEdge.class))
views.addAll(vmProxy.getSelectedEdgeViews(netView));
if (targetDataTypes.contains(CyNetwork.class))
views.add(netView);
}
if (views != null) {
final TaskIterator iterator = new TaskIterator(new RemoveLockedValuesTask(visualProperties, views, netView, servicesUtil));
final DialogTaskManager taskManager = servicesUtil.get(DialogTaskManager.class);
taskManager.execute(iterator);
}
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class SetLockedValuesCommand method execute.
@Override
public void execute(final INotification notification) {
final LockedValuesVO vo = (LockedValuesVO) notification.getBody();
final Map<VisualProperty<?>, Object> values = vo.getValues();
if (values == null)
return;
CyNetworkView netView = vo.getNetworkView();
Set<View<? extends CyIdentifiable>> views = vo.getViews();
final VizMapperProxy vmProxy = (VizMapperProxy) getFacade().retrieveProxy(VizMapperProxy.NAME);
if (netView == null)
netView = vmProxy.getCurrentNetworkView();
if (netView != null && views == null) {
// Get the selected views
final Set<Class<? extends CyIdentifiable>> targetDataTypes = new HashSet<Class<? extends CyIdentifiable>>();
for (final VisualProperty<?> vp : values.keySet()) targetDataTypes.add(vp.getTargetDataType());
views = new HashSet<View<? extends CyIdentifiable>>();
if (targetDataTypes.contains(CyNode.class))
views.addAll(vmProxy.getSelectedNodeViews(netView));
if (targetDataTypes.contains(CyEdge.class))
views.addAll(vmProxy.getSelectedEdgeViews(netView));
if (targetDataTypes.contains(CyNetwork.class))
views.add(netView);
}
if (views != null) {
final TaskIterator iterator = new TaskIterator(new SetLockedValuesTask(values, views, netView, servicesUtil));
final DialogTaskManager taskManager = servicesUtil.get(DialogTaskManager.class);
taskManager.execute(iterator);
}
}
use of org.cytoscape.work.swing.DialogTaskManager in project cytoscape-impl by cytoscape.
the class RemoveVisualMappingsCommand method execute.
@Override
@SuppressWarnings("unchecked")
public void execute(final INotification notification) {
final Set<VisualMappingFunction<?, ?>> set = (Set<VisualMappingFunction<?, ?>>) notification.getBody();
final VizMapperProxy proxy = (VizMapperProxy) getFacade().retrieveProxy(VizMapperProxy.NAME);
final VisualStyle style = proxy.getCurrentVisualStyle();
final TaskIterator iterator = new TaskIterator(new RemoveVisualMappingsTask(set, style, servicesUtil));
final DialogTaskManager taskManager = servicesUtil.get(DialogTaskManager.class);
taskManager.execute(iterator);
}
Aggregations