<commit_before>// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2007 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
// 
// http://www.apache.org/licenses/LICENSE-2.0 
//  
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
// See the License for the specific language governing permissions and 
// limitations under the License.
//
package org.pathvisio.gui.swing;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

import org.pathvisio.ApplicationEvent;
import org.pathvisio.Engine;
import org.pathvisio.Engine.ApplicationEventListener;
import org.pathvisio.data.GexManager;
import org.pathvisio.gui.BackpageTextProvider;
import org.pathvisio.gui.swing.CommonActions.ZoomAction;
import org.pathvisio.gui.swing.dialogs.PathwayElementDialog;
import org.pathvisio.gui.swing.dnd.PathwayImportHandler;
import org.pathvisio.gui.swing.propertypanel.PathwayTableModel;
import org.pathvisio.model.PathwayElement;
import org.pathvisio.view.Graphics;
import org.pathvisio.view.Handle;
import org.pathvisio.view.SelectionBox;
import org.pathvisio.view.VPathway;
import org.pathvisio.view.VPathwayElement;
import org.pathvisio.view.VPathwayEvent;
import org.pathvisio.view.VPathwayListener;

import com.mammothsoftware.frwk.ddb.DropDownButton;

public class MainPanel extends JPanel implements VPathwayListener, ApplicationEventListener {
	private static final long serialVersionUID = 1L;

	private JSplitPane splitPane;

	protected JToolBar toolBar;

	private JScrollPane pathwayScrollPane;

	private JScrollPane propertiesScrollPane;
	
	protected JTabbedPane sidebarTabbedPane;

	protected JMenuBar menuBar;

	private JTable propertyTable;

	protected BackpagePane backpagePane;
	
	protected CommonActions actions;
	
	Set<Action> hideActions;
	
	private boolean mayAddAction(Action a) {
		return hideActions == null || !hideActions.contains(a);
	}
	
	protected void addMenuActions(JMenuBar mb) {
		JMenu fileMenu = new JMenu("File");
		
		addToMenu(actions.saveAction, fileMenu);
		addToMenu(actions.saveAsAction, fileMenu);
		fileMenu.addSeparator();
		addToMenu(actions.importAction, fileMenu);
		addToMenu(actions.exportAction, fileMenu);
		fileMenu.addSeparator();
		addToMenu(actions.exitAction, fileMenu);
		
		JMenu editMenu = new JMenu("Edit");
		addToMenu(actions.undoAction, editMenu);
		addToMenu(actions.copyAction, editMenu);
		addToMenu(actions.pasteAction, editMenu);
		editMenu.addSeparator();
		
		JMenu selectionMenu = new JMenu("Selection");
		JMenu alignMenu = new JMenu("Align");
		JMenu stackMenu = new JMenu("Stack");
		
		for(Action a : actions.alignActions) addToMenu(a, alignMenu);
		for(Action a : actions.stackActions) addToMenu(a, stackMenu);
		
		selectionMenu.add(alignMenu);
		selectionMenu.add(stackMenu);
		editMenu.add (selectionMenu);
		
		JMenu viewMenu = new JMenu("View");
		JMenu zoomMenu = new JMenu("Zoom");
		viewMenu.add(zoomMenu);
		for(Action a : actions.zoomActions) addToMenu(a, zoomMenu);

		JMenu helpMenu = new JMenu("Help");
		
		mb.add(fileMenu);
		mb.add(editMenu);
		mb.add(viewMenu);
		mb.add(helpMenu);
	}

	/**
	 * Constructor for this class. Creates the main panel of this application, containing
	 * the main GUI elements (menubar, toolbar, sidepanel, drawing pane). Actions that should
	 * not be added to the menubar and toolbar should be specified in the hideActions parameter
	 * @param hideActions The {@link Action}s that should not be added to the toolbar and menubar
	 */
	public MainPanel(Set<Action> hideActions) {
		this.hideActions = hideActions;
		
		setLayout(new BorderLayout());
		setTransferHandler(new PathwayImportHandler());
		Engine.getCurrent().addApplicationEventListener(this);
		
		actions = SwingEngine.getCurrent().getActions();
		
		toolBar = new JToolBar();
		addToolBarActions(toolBar);

		add(toolBar, BorderLayout.PAGE_START);<commit_msg>Disable floatable toolbar<commit_after>// PathVisio,
// a tool for data visualization and analysis using Biological Pathways
// Copyright 2006-2007 BiGCaT Bioinformatics
//
// Licensed under the Apache License, Version 2.0 (the "License"); 
// you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at 
// 
// http://www.apache.org/licenses/LICENSE-2.0 
//  
// Unless required by applicable law or agreed to in writing, software 
// distributed under the License is distributed on an "AS IS" BASIS, 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
// See the License for the specific language governing permissions and 
// limitations under the License.
//
package org.pathvisio.gui.swing;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;

import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

import org.pathvisio.ApplicationEvent;
import org.pathvisio.Engine;
import org.pathvisio.Engine.ApplicationEventListener;
import org.pathvisio.data.GexManager;
import org.pathvisio.gui.BackpageTextProvider;
import org.pathvisio.gui.swing.CommonActions.ZoomAction;
import org.pathvisio.gui.swing.dialogs.PathwayElementDialog;
import org.pathvisio.gui.swing.dnd.PathwayImportHandler;
import org.pathvisio.gui.swing.propertypanel.PathwayTableModel;
import org.pathvisio.model.PathwayElement;
import org.pathvisio.view.Graphics;
import org.pathvisio.view.Handle;
import org.pathvisio.view.SelectionBox;
import org.pathvisio.view.VPathway;
import org.pathvisio.view.VPathwayElement;
import org.pathvisio.view.VPathwayEvent;
import org.pathvisio.view.VPathwayListener;

import com.mammothsoftware.frwk.ddb.DropDownButton;

public class MainPanel extends JPanel implements VPathwayListener, ApplicationEventListener {
	private static final long serialVersionUID = 1L;

	private JSplitPane splitPane;

	protected JToolBar toolBar;

	private JScrollPane pathwayScrollPane;

	private JScrollPane propertiesScrollPane;
	
	protected JTabbedPane sidebarTabbedPane;

	protected JMenuBar menuBar;

	private JTable propertyTable;

	protected BackpagePane backpagePane;
	
	protected CommonActions actions;
	
	Set<Action> hideActions;
	
	private boolean mayAddAction(Action a) {
		return hideActions == null || !hideActions.contains(a);
	}
	
	protected void addMenuActions(JMenuBar mb) {
		JMenu fileMenu = new JMenu("File");
		
		addToMenu(actions.saveAction, fileMenu);
		addToMenu(actions.saveAsAction, fileMenu);
		fileMenu.addSeparator();
		addToMenu(actions.importAction, fileMenu);
		addToMenu(actions.exportAction, fileMenu);
		fileMenu.addSeparator();
		addToMenu(actions.exitAction, fileMenu);
		
		JMenu editMenu = new JMenu("Edit");
		addToMenu(actions.undoAction, editMenu);
		addToMenu(actions.copyAction, editMenu);
		addToMenu(actions.pasteAction, editMenu);
		editMenu.addSeparator();
		
		JMenu selectionMenu = new JMenu("Selection");
		JMenu alignMenu = new JMenu("Align");
		JMenu stackMenu = new JMenu("Stack");
		
		for(Action a : actions.alignActions) addToMenu(a, alignMenu);
		for(Action a : actions.stackActions) addToMenu(a, stackMenu);
		
		selectionMenu.add(alignMenu);
		selectionMenu.add(stackMenu);
		editMenu.add (selectionMenu);
		
		JMenu viewMenu = new JMenu("View");
		JMenu zoomMenu = new JMenu("Zoom");
		viewMenu.add(zoomMenu);
		for(Action a : actions.zoomActions) addToMenu(a, zoomMenu);

		JMenu helpMenu = new JMenu("Help");
		
		mb.add(fileMenu);
		mb.add(editMenu);
		mb.add(viewMenu);
		mb.add(helpMenu);
	}

	/**
	 * Constructor for this class. Creates the main panel of this application, containing
	 * the main GUI elements (menubar, toolbar, sidepanel, drawing pane). Actions that should
	 * not be added to the menubar and toolbar should be specified in the hideActions parameter
	 * @param hideActions The {@link Action}s that should not be added to the toolbar and menubar
	 */
	public MainPanel(Set<Action> hideActions) {
		this.hideActions = hideActions;
		
		setLayout(new BorderLayout());
		setTransferHandler(new PathwayImportHandler());
		Engine.getCurrent().addApplicationEventListener(this);
		
		actions = SwingEngine.getCurrent().getActions();
		
		toolBar = new JToolBar();
		toolBar.setFloatable(false); // disable floatable toolbar, aka Abomination of interaction design.
		addToolBarActions(toolBar);

		add(toolBar, BorderLayout.PAGE_START);
{'fraction_non_alphanumeric': 0.09723052400876668, 'fraction_numerical': 0.002590157401872883, 'mean_word_length': 5.185459026494146, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6880285', 'n_tokens_mistral': 3203, 'n_tokens_neox': 2970, 'n_words': 786}