Skip to content
Snippets Groups Projects
Select Git revision
  • 3393a064f8f5977bc741378b89015baa4e6fcfda
  • master default protected
  • emoUS
  • add_default_vectorizer_and_pretrained_loading
  • clean_code
  • readme
  • issue127
  • generalized_action_dicts
  • ppo_num_dialogues
  • crossowoz_ddpt
  • issue_114
  • robust_masking_feature
  • scgpt_exp
  • e2e-soloist
  • convlab_exp
  • change_system_act_in_env
  • pre-training
  • nlg-scgpt
  • remapping_actions
  • soloist
20 results

test_COMER_RulePolicy_TemplateNLG.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    MainPanel.java 3.96 KiB
    package de.hhu.ba.yoshikoWrapper.gui;
    
    import java.awt.Component;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.Icon;
    import javax.swing.JButton;
    import javax.swing.JFileChooser;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import org.cytoscape.application.swing.CytoPanelComponent;
    import org.cytoscape.application.swing.CytoPanelName;
    
    import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader;
    import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface;
    import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_yskInput__LibraryInput;
    import de.hhu.ba.yoshikoWrapper.swig.SWIGTYPE_p_ysk__ClusterEditingSolutions;
    
    /**This class describes the Swing Panel that the user interacts with in cytoscape
     * @author Philipp Spohr, Aug 6, 2017
     *
     */
    public class MainPanel extends JPanel implements CytoPanelComponent {
    
    	/**
    	 * Unique identifier for serialization
    	 */
    	private static final long serialVersionUID = 6214827920591046457L;
    	
    	//SYMBOLIC LINKS
    	private YoshikoLoader yoshikoLoader = YoshikoLoader.getInstance();
    	private MainPanel self = this; //for lambda function references
    	//SWING COMPONENTS
    	
    	private LibStatusPanel libStatusPanel;
    	private JButton searchLibButton;
    	private JLabel yoshikoVersionLabel;
    
    	/**
    	 * Main constructor, creates a new Panel and initializes subcomponents
    	 */
    	public MainPanel() {
    		
    		//SWING COMPONENT INITIALIZATION
    		
    		libStatusPanel = new LibStatusPanel();
    		libStatusPanel.setStyle(yoshikoLoader.isLibraryLoaded());
    		this.add(libStatusPanel);
    		
    		searchLibButton = new JButton("SHOW YOSHIKO LIB");
    		searchLibButton.addActionListener(new ActionListener() {
    
    			@Override
    			public void actionPerformed(ActionEvent e) {
    				final YLibChooser c = new YLibChooser();
    				int returnVal = c.showOpenDialog(self);
    				if (returnVal == JFileChooser.APPROVE_OPTION) {
    					yoshikoLoader.loadLibrary(c.getSelectedFile().getAbsolutePath());
    				}
    				libStatusPanel.setStyle(yoshikoLoader.isLibraryLoaded());
    				yoshikoVersionLabel.setText(LibraryInterface.getVersionString());
    			}
    			
    		});
    		this.add(searchLibButton);
    		
    		//
    		//
    		//TODO: REMOVE IN FINAL RELEASE
    		JButton debugGraphActionButton = new JButton("DO MYSTERIOUS DEBUG STUFF");
    		debugGraphActionButton.addActionListener(new ActionListener() {
    
    
    			@Override
    			public void actionPerformed(ActionEvent e) {
    				if (yoshikoLoader.isLibraryLoaded()){
    					SWIGTYPE_p_yskInput__LibraryInput instance;
    					instance = LibraryInterface.new_LibraryInput();
    					LibraryInterface.LibraryInput_setSize(instance, 4);
    					LibraryInterface.LibraryInput_addEdge(instance, 0, 1, 2);
    					LibraryInterface.LibraryInput_addEdge(instance, 1, 3, 5);
    					SWIGTYPE_p_ysk__ClusterEditingSolutions solutions = LibraryInterface.processLibraryInput(instance);
    					long numberOfSolutions = LibraryInterface.ClusterEditingSolutions_getNumberOfSolutions(solutions);
    					double totalCost = LibraryInterface.ClusterEditingSolutions_getTotalCost(solutions);
    					System.out.println();
    					JOptionPane.showMessageDialog(
    							self,
    							"YOSHIKO FOUND "+numberOfSolutions+" solutions!\n"+
    							"YOSHIKO PAID THE CRUEL PRIZE OF: "+totalCost+"\n"
    							
    							);
    					
    					//IMPORTANT: DESTROY STUFF
    					LibraryInterface.delete_LibraryInput(instance);
    					LibraryInterface.delete_ClusterEditingSolutions(solutions);
    				}
    			}
    			
    		});
    		this.add(debugGraphActionButton);
    		//
    		//
    		//
    		
    		yoshikoVersionLabel = new JLabel("YOSHIKO VERSION");
    		this.add(yoshikoVersionLabel);
    		
    		this.setVisible(true);
    	}
    
    
    	public Component getComponent() {
    		return this;
    	}
    
    
    	/* (non-Javadoc)
    	 * @see org.cytoscape.application.swing.CytoPanelComponent#getCytoPanelName()
    	 */
    	public CytoPanelName getCytoPanelName() {
    		//By convention most plugins that provide a "toolbox"-like interface use the WEST orientation
    		return CytoPanelName.WEST;
    	}
    
    	public String getTitle() {
    		//TODO: Be creative I guess
    		return "Yoshiko Wrapper Panel";
    	}
    
    
    	public Icon getIcon() {
    		//TODO: 
    		return null;
    	}
    }