Author: scooter
Date: 2012-07-29 17:09:07 -0700 (Sun, 29 Jul 2012)
New Revision: 30035
Modified:
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/CyActivator.java
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenu.java
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
Log:
Move layout menus around a little. This is a minor step -- we need to
completely refactor LayoutMenu and LayoutMenuPopulator so that the use gravity.
Modified:
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/CyActivator.java
2012-07-30 00:04:39 UTC (rev 30034)
+++
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/CyActivator.java
2012-07-30 00:09:07 UTC (rev 30035)
@@ -182,7 +182,9 @@
VisualMappingManager visualMappingManagerServiceRef =
getService(bc, VisualMappingManager.class);
FileUtil fileUtilServiceRef = getService(bc, FileUtil.class);
- DynamicTaskFactoryProvisioner
dynamicTaskFactoryProvisionerServiceRef = getService(bc,
DynamicTaskFactoryProvisioner.class);
+
+ DynamicTaskFactoryProvisioner
dynamicTaskFactoryProvisionerServiceRef = getService(bc,
+
DynamicTaskFactoryProvisioner.class);
UndoAction undoAction = new UndoAction(undoSupportServiceRef);
@@ -199,29 +201,39 @@
CytoscapeMenuBar cytoscapeMenuBar = new CytoscapeMenuBar();
CytoscapeToolBar cytoscapeToolBar = new CytoscapeToolBar();
CytoscapeMenus cytoscapeMenus = new
CytoscapeMenus(cytoscapeMenuBar, cytoscapeToolBar);
+
ToolBarEnableUpdater toolBarEnableUpdater = new
ToolBarEnableUpdater(cytoscapeToolBar);
+
NetworkViewManager networkViewManager = new
NetworkViewManager(cyApplicationManagerServiceRef,
-
cyNetworkViewManagerServiceRef, renderingEngineManagerServiceRef,
+
cyNetworkViewManagerServiceRef,
+
renderingEngineManagerServiceRef,
cytoscapePropertiesServiceRef,
cyHelpBroker);
+
BirdsEyeViewHandler birdsEyeViewHandler = new
BirdsEyeViewHandler(cyApplicationManagerServiceRef,
dingNavigationPresentationFactoryServiceRef,
cyNetworkViewManagerServiceRef);
+
NetworkPanel networkPanel = new
NetworkPanel(cyApplicationManagerServiceRef,
cyNetworkManagerServiceRef,
cyNetworkViewManagerServiceRef,
birdsEyeViewHandler,
dialogTaskManagerServiceRef,
dynamicTaskFactoryProvisionerServiceRef);
+
CytoscapeDesktop cytoscapeDesktop = new
CytoscapeDesktop(cytoscapeMenus,
networkViewManager, networkPanel,
cytoscapeShutdownServiceRef,
cyEventHelperServiceRef,
cyServiceRegistrarServiceRef,
dialogTaskManagerServiceRef);
+
SynchronousTaskManager<?> synchronousTaskManagerServiceRef =
getService(bc, SynchronousTaskManager.class);
+
SaveSessionAsTaskFactory saveTaskFactoryServiceRef =
getService(bc, SaveSessionAsTaskFactory.class);
+
SessionStateIO sessStateIO = new SessionStateIO();
+
SessionHandler sessionHandler = new
SessionHandler(cytoscapeDesktop,
cyNetworkManagerServiceRef,
networkViewManager,
@@ -230,24 +242,38 @@
sessStateIO,
cySessionManagerServiceRef,
fileUtilServiceRef);
- PrintAction printAction = new
PrintAction(cyApplicationManagerServiceRef, cyNetworkViewManagerServiceRef,
cytoscapePropertiesServiceRef);
+
+ PrintAction printAction = new
PrintAction(cyApplicationManagerServiceRef,
+
cyNetworkViewManagerServiceRef,
+
cytoscapePropertiesServiceRef);
+
ExitAction exitAction = new ExitAction(
cytoscapeShutdownServiceRef);
+
PreferenceAction preferenceAction = new
PreferenceAction(cytoscapeDesktop,
preferencesDialogFactory,
bookmarksUtilServiceRef);
+
BookmarkAction bookmarkAction = new
BookmarkAction(cytoscapeDesktop, bookmarkDialogFactory);
- LayoutMenuPopulator layoutMenuPopulator = new
LayoutMenuPopulator(cytoscapeDesktop,
-
cyApplicationManagerServiceRef, dialogTaskManagerServiceRef);
+
+ LayoutMenuPopulator layoutMenuPopulator = new
LayoutMenuPopulator(cytoscapeMenuBar,
+
cyApplicationManagerServiceRef,
+
dialogTaskManagerServiceRef);
+
CytoscapeMenuPopulator cytoscapeMenuPopulator = new
CytoscapeMenuPopulator(cytoscapeDesktop,
dialogTaskManagerServiceRef,
panelTaskManagerServiceRef,
-
cyApplicationManagerServiceRef, cyNetworkViewManagerServiceRef,
+
cyApplicationManagerServiceRef,
+
cyNetworkViewManagerServiceRef,
cyServiceRegistrarServiceRef,
dynamicTaskFactoryProvisionerServiceRef);
+
SettingsAction settingsAction = new
SettingsAction(cyLayoutsServiceRef, cytoscapeDesktop,
-
cyApplicationManagerServiceRef, cyNetworkViewManagerServiceRef,
+
cyApplicationManagerServiceRef,
+
cyNetworkViewManagerServiceRef,
panelTaskManagerServiceRef,
-
cytoscapePropertiesServiceRef, dynamicTaskFactoryProvisionerServiceRef);
+
cytoscapePropertiesServiceRef,
+
dynamicTaskFactoryProvisionerServiceRef);
+
HelpContentsTaskFactory helpContentsTaskFactory = new
HelpContentsTaskFactory(cyHelpBroker,
cytoscapeDesktop);
HelpContactHelpDeskTaskFactory helpContactHelpDeskTaskFactory =
new HelpContactHelpDeskTaskFactory(openBrowserServiceRef);
@@ -272,15 +298,14 @@
SelectNodeViewUpdater selecteNodeViewUpdater = new
SelectNodeViewUpdater(rowViewTracker);
RowsSetViewUpdater rowsSetViewUpdater = new
RowsSetViewUpdater(cyApplicationManagerServiceRef,
- cyNetworkViewManagerServiceRef,
visualMappingManagerServiceRef, rowViewTracker);
+
cyNetworkViewManagerServiceRef,
+
visualMappingManagerServiceRef, rowViewTracker);
-
RecentSessionManager recentSessionManager = new
RecentSessionManager(recentlyOpenedTrackerServiceRef,
cyServiceRegistrarServiceRef,
cySessionManagerServiceRef,
sessionReaderManagerServiceRef,
cyApplicationManagerServiceRef);
-
registerService(bc, cyHelpBroker, CyHelpBroker.class, new
Properties());
registerService(bc, undoAction, CyAction.class, new
Properties());
Modified:
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenu.java
===================================================================
---
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenu.java
2012-07-30 00:04:39 UTC (rev 30034)
+++
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenu.java
2012-07-30 00:09:07 UTC (rev 30035)
@@ -66,19 +66,21 @@
* factors such as whether or not nodes are selected, the presence of node or
edge
* attributes, etc.
*/
+
+// This should extend CyMenuItem, I think....
public class LayoutMenu extends JMenu implements MenuListener {
private final static long serialVersionUID = 1202339874255880L;
List<CyLayoutAlgorithm> subMenuList;
private CyApplicationManager appMgr;
private DialogTaskManager tm;
- private final LayoutComparator layoutComparator = new
LayoutComparator();
+ private final LayoutComparator layoutComparator = new LayoutComparator();
/**
* Creates a new LayoutMenu object.
*
* @param menuName DOCUMENT ME!
*/
- public LayoutMenu(String menuName, CyApplicationManager
appMgr,DialogTaskManager tm) {
+ public LayoutMenu(String menuName, CyApplicationManager appMgr,
DialogTaskManager tm) {
super(menuName);
addMenuListener(this);
subMenuList = new ArrayList<CyLayoutAlgorithm>();
@@ -104,7 +106,6 @@
subMenuList.remove(layout);
}
-
/**
* DOCUMENT ME!
*
@@ -138,8 +139,8 @@
this.removeAll();
CyNetworkView view = appMgr.getCurrentNetworkView();
- if ( view == null )
- return;
+ if ( view == null )
+ return;
CyNetwork network = view.getModel();
@@ -147,23 +148,25 @@
boolean someSelected =
network.getDefaultNodeTable().countMatchingRows(CyNetwork.SELECTED, true) > 0;
boolean enableMenuItem = checkEnabled();
- Collections.sort(subMenuList,layoutComparator);
+ Collections.sort(subMenuList,layoutComparator);
for ( CyLayoutAlgorithm layout : subMenuList ) {
-
- boolean usesNodeAttrs =
hasValidAttributes(layout.getSupportedNodeAttributeTypes(),network.getDefaultNodeTable());
- boolean usesEdgeAttrs =
hasValidAttributes(layout.getSupportedEdgeAttributeTypes(),network.getDefaultEdgeTable());
+
+ boolean usesNodeAttrs =
+
hasValidAttributes(layout.getSupportedNodeAttributeTypes(),network.getDefaultNodeTable());
+ boolean usesEdgeAttrs =
+
hasValidAttributes(layout.getSupportedEdgeAttributeTypes(),network.getDefaultEdgeTable());
boolean usesSelected = (layout.getSupportsSelectedOnly() &&
someSelected);
if (usesNodeAttrs || usesEdgeAttrs || usesSelected) {
- super.add(new
DynamicLayoutMenu(layout,network,enableMenuItem,appMgr,tm,usesNodeAttrs,usesEdgeAttrs,usesSelected));
+ super.add(new
DynamicLayoutMenu(layout,network,enableMenuItem,appMgr,
+
tm,usesNodeAttrs,usesEdgeAttrs,usesSelected));
} else {
super.add(new
StaticLayoutMenu(layout,enableMenuItem,appMgr,tm));
}
}
}
-
private boolean hasValidAttributes(Set<Class<?>> typeSet, CyTable
attributes) {
for (final CyColumn column : attributes.getColumns())
if (typeSet.contains(column.getType()))
@@ -183,13 +186,13 @@
return true;
}
- private static class LayoutComparator implements
Comparator<CyLayoutAlgorithm> {
- public int compare(CyLayoutAlgorithm o1, CyLayoutAlgorithm o2) {
- return o1.toString().compareTo(o2.toString());
- }
- public boolean equals(Object obj) {
- return ( obj == this );
- }
- }
+ private static class LayoutComparator implements
Comparator<CyLayoutAlgorithm> {
+ public int compare(CyLayoutAlgorithm o1, CyLayoutAlgorithm o2) {
+ return o1.toString().compareTo(o2.toString());
+ }
+ public boolean equals(Object obj) {
+ return ( obj == this );
+ }
+ }
}
Modified:
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
===================================================================
---
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
2012-07-30 00:04:39 UTC (rev 30034)
+++
core3/impl/trunk/swing-application-impl/src/main/java/org/cytoscape/internal/layout/ui/LayoutMenuPopulator.java
2012-07-30 00:09:07 UTC (rev 30035)
@@ -37,10 +37,12 @@
package org.cytoscape.internal.layout.ui;
import org.cytoscape.view.layout.CyLayoutAlgorithm;
+import static org.cytoscape.work.ServiceProperties.*;
import org.cytoscape.work.TaskManager;
import org.cytoscape.work.swing.DialogTaskManager;
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.CySwingApplication;
+import org.cytoscape.internal.view.CytoscapeMenuBar;
import java.util.*;
@@ -51,26 +53,24 @@
private Map<String, LayoutMenu> menuMap;
private CyApplicationManager appMgr;
private DialogTaskManager tm;
- private CySwingApplication swingApp;
+ private CytoscapeMenuBar menuBar;
- public LayoutMenuPopulator(CySwingApplication swingApp,
CyApplicationManager appMgr, DialogTaskManager tm) {
+ public LayoutMenuPopulator(CytoscapeMenuBar menuBar, CyApplicationManager
appMgr, DialogTaskManager tm) {
menuAlgorithmMap = new HashMap<String,List<CyLayoutAlgorithm>>();
menuMap = new HashMap<String,LayoutMenu>();
this.appMgr = appMgr;
this.tm = tm;
- this.swingApp = swingApp;
+ this.menuBar = menuBar;
}
public void addLayout(CyLayoutAlgorithm layout, Map props) {
-
- String fullMenuName = (String)props.get("preferredMenu");
+ String fullMenuName = (String)props.get(PREFERRED_MENU);
if (fullMenuName == null )
fullMenuName = "Layout." + layout.toString();
-
String actualMenuName = fullMenuName;
if ( actualMenuName.startsWith("Layout."))
- actualMenuName = actualMenuName.substring(7);
+ actualMenuName = actualMenuName.substring(7);
// make sure the list is set up for this name
if ( !menuAlgorithmMap.containsKey(fullMenuName) ) {
@@ -85,7 +85,15 @@
if ( !menuMap.containsKey(fullMenuName) ) {
LayoutMenu menu = new LayoutMenu(actualMenuName, appMgr, tm);
menuMap.put(fullMenuName, menu);
- swingApp.getJMenu("Layout").add(menu);
+ // This needs to be done so that gravity is supported
+ menuBar.getMenu("Layout").add(menu);
+ } else {
+ // See if the menu type has changed from a Menu to a MenuItem or
visa-versa
+ // Yes, replace it.
+ LayoutMenu menu = menuMap.get(fullMenuName);
+ // if (menu.updateSubMenus()) {
+ // Update the menu
+ // }
}
// add layout to the menu for this name
@@ -93,11 +101,8 @@
}
public void removeLayout(CyLayoutAlgorithm layout, Map props) {
-
for (String menu : menuAlgorithmMap.keySet()) {
-
List<CyLayoutAlgorithm> menuList = menuAlgorithmMap.get(menu);
-
if (menuList.indexOf(layout) >= 0) {
menuList.remove(layout);
menuMap.get(menu).remove(layout);
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.