Skip to content

Commit

Permalink
panel will not launch with cytoscape
Browse files Browse the repository at this point in the history
  • Loading branch information
yihangx committed Mar 19, 2024
1 parent f72f2d1 commit 506889d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/main/java/org/nrnb/gsoc/enrichment/CyActivator.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void start(BundleContext context) throws Exception {
CySwingApplication swingApplication = registrar.getService(CySwingApplication.class);
CytoPanel cytoPanel = swingApplication.getCytoPanel(CytoPanelName.SOUTH);
CytoPanelComponent2 enrichmentPanel = new EnrichmentCytoPanel(registrar,false,null);
registrar.registerService(enrichmentPanel, CytoPanelComponent.class,new Properties());
registrar.registerService(enrichmentPanel, SelectedNodesAndEdgesListener.class, new Properties());
registrar.registerService(enrichmentPanel, NetworkAboutToBeDestroyedListener.class, new Properties());
registrar.registerService(enrichmentPanel, SessionLoadedListener.class, new Properties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@
import static org.nrnb.gsoc.enrichment.utils.IconUtil.APP_ICON_LAYERS;

import java.awt.event.ActionEvent;
import java.util.Properties;

import org.cytoscape.application.events.SetCurrentNetworkListener;
import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.application.swing.CyAction;
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanel;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CytoPanelComponent2;
import org.cytoscape.application.swing.CytoPanelName;
import org.cytoscape.application.swing.CytoPanelState;
import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
import org.cytoscape.model.events.SelectedNodesAndEdgesListener;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.session.events.SessionLoadedListener;
import org.cytoscape.util.swing.TextIcon;
import org.cytoscape.work.TaskFactory;
import org.nrnb.gsoc.enrichment.tasks.EnrichmentTaskFactory;
import org.nrnb.gsoc.enrichment.ui.EnrichmentCytoPanel;
import org.nrnb.gsoc.enrichment.utils.IconUtil;

@SuppressWarnings("serial")
public class ShowAppTableAction extends AbstractCyAction {

private final CyServiceRegistrar serviceRegistrar;
CytoPanelComponent2 enrichmentPanel;

public ShowAppTableAction(CyServiceRegistrar serviceRegistrar) {
super("Enrichment Table");
Expand All @@ -35,12 +48,28 @@ public ShowAppTableAction(CyServiceRegistrar serviceRegistrar) {

@Override
public void actionPerformed(ActionEvent e) {
var swingApp = serviceRegistrar.getService(CySwingApplication.class);
var cytoPanel = swingApp.getCytoPanel(CytoPanelName.SOUTH);

CySwingApplication swingApplication = serviceRegistrar.getService(CySwingApplication.class);
CytoPanel cytoPanel = swingApplication.getCytoPanel(CytoPanelName.SOUTH);
if (enrichmentPanel == null){
enrichmentPanel = new EnrichmentCytoPanel(serviceRegistrar,false,null);
serviceRegistrar.registerService(enrichmentPanel, CytoPanelComponent.class,new Properties());
serviceRegistrar.registerService(enrichmentPanel, SelectedNodesAndEdgesListener.class, new Properties());
serviceRegistrar.registerService(enrichmentPanel, NetworkAboutToBeDestroyedListener.class, new Properties());
serviceRegistrar.registerService(enrichmentPanel, SessionLoadedListener.class, new Properties());
serviceRegistrar.registerService(enrichmentPanel, SetCurrentNetworkListener.class, new Properties());
//registrar.registerService(enrichmentPanel, SetCurrentNetworkListener.class, new Properties());
//registrar.registerService(enrichmentPanel, NetworkAddedListener.class, new Properties());
if (cytoPanel.getState() == CytoPanelState.HIDE)
cytoPanel.setState(CytoPanelState.DOCK);
cytoPanel.setSelectedIndex(
cytoPanel.indexOfComponent("org.nrnb.gsoc.enrichment"));

} else {
if (cytoPanel.getState() == CytoPanelState.HIDE)
cytoPanel.setState(CytoPanelState.DOCK);
cytoPanel.setSelectedIndex(
cytoPanel.indexOfComponent("org.nrnb.gsoc.enrichment"));

cytoPanel.setSelectedIndex(cytoPanel.indexOfComponent("org.nrnb.gsoc.enrichment"));
}
}
}

0 comments on commit 506889d

Please sign in to comment.