<commit_before>package org.cytoscape.ding.action;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

import javax.swing.KeyStroke;
import javax.swing.event.MenuEvent;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.ding.DVisualLexicon;
import org.cytoscape.ding.ShowGraphicsDetailsTaskFactory;
import org.cytoscape.ding.impl.DRenderingEngine;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.CyNetworkViewManager;
import org.cytoscape.work.swing.DialogTaskManager;

/*
 * #%L
 * Cytoscape Ding View/Presentation Impl (ding-presentation-impl)
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2006 - 2017 The Cytoscape Consortium
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 2.1 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
 * #L%
 */

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

	private ShowGraphicsDetailsTaskFactory taskFactory;
	private final CyServiceRegistrar serviceRegistrar;

	public GraphicsDetailAction(
			float gravity,
			String preferredMenu,
			ShowGraphicsDetailsTaskFactory taskFactory,
			CyServiceRegistrar serviceRegistrar
	) {
		super(
				"Always Show Graphics Details",
				serviceRegistrar.getService(CyApplicationManager.class),
				"networkAndView",
				serviceRegistrar.getService(CyNetworkViewManager.class)
		);

		this.taskFactory = taskFactory;
		this.serviceRegistrar = serviceRegistrar;
		
		if (preferredMenu != null) {
			setPreferredMenu(preferredMenu);
			setAcceleratorKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_D,
					Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() + InputEvent.SHIFT_MASK));
		}
		
		setMenuGravity(gravity);
		useCheckBoxMenuItem = true;
	}
	
	/**
	 * Toggles the Show/Hide state.
	 * @param ev Triggering event - not used.
	 */
	@Override
	public void actionPerformed(ActionEvent ev) {
		CyNetworkView view = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
		
		if (taskFactory.isReady(view))
			serviceRegistrar.getService(DialogTaskManager.class).execute(taskFactory.createTaskIterator(view));
	}

	@Override
	public void menuSelected(MenuEvent me) {
		updateEnableState();
		CyNetworkView view = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
		
		if (view instanceof DRenderingEngine && isEnabled())
			putValue(SELECTED_KEY, view.getVisualProperty(DVisualLexicon.NETWORK_FORCE_HIGH_DETAIL));
		else
			putValue(SELECTED_KEY, false);
	}
	
	@Override
	public void updateEnableState() {
		CyNetworkView view = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
		setEnabled(taskFactory.isReady(view));
	}
}<commit_msg>Fixes checkbox menu item for Graphics Details Action with the new Ding.<commit_after>package org.cytoscape.ding.action;

import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

import javax.swing.KeyStroke;
import javax.swing.event.MenuEvent;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.ding.DVisualLexicon;
import org.cytoscape.ding.ShowGraphicsDetailsTaskFactory;
import org.cytoscape.service.util.CyServiceRegistrar;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.CyNetworkViewManager;
import org.cytoscape.work.swing.DialogTaskManager;

/*
 * #%L
 * Cytoscape Ding View/Presentation Impl (ding-presentation-impl)
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2006 - 2017 The Cytoscape Consortium
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 2.1 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
 * #L%
 */

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

	private ShowGraphicsDetailsTaskFactory taskFactory;
	private final CyServiceRegistrar serviceRegistrar;

	public GraphicsDetailAction(
			float gravity,
			String preferredMenu,
			ShowGraphicsDetailsTaskFactory taskFactory,
			CyServiceRegistrar serviceRegistrar
	) {
		super(
				"Always Show Graphics Details",
				serviceRegistrar.getService(CyApplicationManager.class),
				"networkAndView",
				serviceRegistrar.getService(CyNetworkViewManager.class)
		);

		this.taskFactory = taskFactory;
		this.serviceRegistrar = serviceRegistrar;
		
		if (preferredMenu != null) {
			setPreferredMenu(preferredMenu);
			setAcceleratorKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_D,
					Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() + InputEvent.SHIFT_MASK));
		}
		
		setMenuGravity(gravity);
		useCheckBoxMenuItem = true;
	}
	
	/**
	 * Toggles the Show/Hide state.
	 * @param ev Triggering event - not used.
	 */
	@Override
	public void actionPerformed(ActionEvent ev) {
		CyNetworkView view = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
		
		if (taskFactory.isReady(view))
			serviceRegistrar.getService(DialogTaskManager.class).execute(taskFactory.createTaskIterator(view));
	}

	@Override
	public void menuSelected(MenuEvent me) {
		updateEnableState();
		CyNetworkView view = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
		
		if (view != null && isEnabled())
			putValue(SELECTED_KEY, Boolean.TRUE == view.getVisualProperty(DVisualLexicon.NETWORK_FORCE_HIGH_DETAIL));
		else
			putValue(SELECTED_KEY, false);
	}
	
	@Override
	public void updateEnableState() {
		CyNetworkView view = serviceRegistrar.getService(CyApplicationManager.class).getCurrentNetworkView();
		setEnabled(taskFactory.isReady(view));
	}
}
{'fraction_non_alphanumeric': 0.0898375736668104, 'fraction_numerical': 0.0034497628288055198, 'mean_word_length': 5.168439716312057, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6546390', 'n_tokens_mistral': 2262, 'n_tokens_neox': 2016, 'n_words': 495}