<commit_before>package de.ptb.epics.eve.editor.views.eventcomposite;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CompoundContributionItem;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter;

import de.ptb.epics.eve.data.EventImpacts;
import de.ptb.epics.eve.data.EventTypes;
import de.ptb.epics.eve.data.measuringstation.event.Event;
import de.ptb.epics.eve.data.scandescription.Chain;
import de.ptb.epics.eve.data.scandescription.ScanDescription;
import de.ptb.epics.eve.data.scandescription.ScanModule;
import de.ptb.epics.eve.editor.Activator;
import de.ptb.epics.eve.editor.gef.ScanDescriptionEditor;
import static de.ptb.epics.eve.editor.views.eventcomposite.EventMenuContributionHelper.*;

/**
 * <code>EventMenuContributionSchedule</code>.
 * 
 * @author <NAME>
 * @since 1.1
 */
public class EventMenuContributionSchedule extends CompoundContributionItem {
	private static Logger logger = Logger
			.getLogger(EventMenuContributionSchedule.class.getName());

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected IContributionItem[] getContributionItems() {
		ArrayList<IContributionItem> result = new ArrayList<IContributionItem>();
		ScanDescription sd = ((ScanDescriptionEditor) Activator.getDefault()
				.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActiveEditor()).getContent();
		
		{
			Event startEvent = sd.getDefaultStartEvent();

			Map<String, String> params = new HashMap<String, String>();
			params.put("de.ptb.epics.eve.editor.command.AddEvent.EventId",
					startEvent.getId());
			params.put("de.ptb.epics.eve.editor.command.AddEvent.EventType",
					EventTypes.SCHEDULE.toString());
			EventImpacts eventImpact = determineEventImpact();
			if (eventImpact == null) {
				logger.warn("EventImpact not found.");
				return result.toArray(new IContributionItem[0]);
			}
			params.put("de.ptb.epics.eve.editor.command.AddEvent.EventImpact",
					eventImpact.toString());
			IViewPart activePart = getActiveViewPart();
			if (activePart == null) {
				logger.warn("active part is not a view.");
				return result.toArray(new IContributionItem[0]);
			}
			params.put("de.ptb.epics.eve.editor.command.AddEvent.ActivePart",
					activePart.getViewSite().getId());
			CommandContributionItemParameter p = new CommandContributionItemParameter(
					PlatformUI.getWorkbench().getActiveWorkbenchWindow(), "",
					"de.ptb.epics.eve.editor.command.addevent", SWT.PUSH);
			p.label = startEvent.getName();
			p.parameters = params;
			CommandContributionItem item = new CommandContributionItem(p);
			item.setVisible(true);
			result.add(item);
		}
		
		for (Chain chain : sd.getChains()) {
			for (ScanModule sm : chain.getScanModules()) {
				String eventId = "S-" + chain.getId() + "-" + sm.getId() + "-"
						+ "E";
				Map<String, String> params = new HashMap<String, String>();
				params.put("de.ptb.epics.eve.editor.command.AddEvent.EventId",
						eventId);
				params.put(
						"de.ptb.epics.eve.editor.command.AddEvent.EventType",
						EventTypes.SCHEDULE.toString());
				EventImpacts eventImpact = determineEventImpact();
				if (eventImpact == null) {
					logger.warn("EventImpact not found.");
					return result.toArray(new IContributionItem[0]);
				}
				params.put(
						"de.ptb.epics.eve.editor.command.AddEvent.EventImpact",
						eventImpact.toString());
				IViewPart activePart = getActiveViewPart();
				if (activePart == null) {
					logger.warn("active part is not a view.");
					return result.toArray(new IContributionItem[0]);
				}
				params.put(
						"de.ptb.epics.eve.editor.command.AddEvent.ActivePart",
						activePart.getViewSite().getId());
				CommandContributionItemParameter p = new CommandContributionItemParameter(
						PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
						"", "de.ptb.epics.eve.editor.command.addevent",
						SWT.PUSH);
				p.label = "Schedule " + "( " + eventId + " )";
				p.parameters = params;
				CommandContributionItem item = new CommandContributionItem(p);
				item.setVisible(true);
				result.add(item);
			}
		}
		return result.toArray(new IContributionItem[0]);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean isDynamic() {
		return true;
	}
}<commit_msg>schedule event menu no longer shows the module itself<commit_after>package de.ptb.epics.eve.editor.views.eventcomposite;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CompoundContributionItem;
import org.eclipse.ui.menus.CommandContributionItem;
import org.eclipse.ui.menus.CommandContributionItemParameter;

import de.ptb.epics.eve.data.EventImpacts;
import de.ptb.epics.eve.data.EventTypes;
import de.ptb.epics.eve.data.measuringstation.event.Event;
import de.ptb.epics.eve.data.scandescription.Chain;
import de.ptb.epics.eve.data.scandescription.ScanDescription;
import de.ptb.epics.eve.data.scandescription.ScanModule;
import de.ptb.epics.eve.editor.Activator;
import de.ptb.epics.eve.editor.gef.ScanDescriptionEditor;
import de.ptb.epics.eve.editor.views.scanmoduleview.ScanModuleView;

import static de.ptb.epics.eve.editor.views.eventcomposite.EventMenuContributionHelper.*;

/**
 * <code>EventMenuContributionSchedule</code>.
 * 
 * @author <NAME>
 * @since 1.1
 */
public class EventMenuContributionSchedule extends CompoundContributionItem {
	private static Logger logger = Logger
			.getLogger(EventMenuContributionSchedule.class.getName());

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected IContributionItem[] getContributionItems() {
		ArrayList<IContributionItem> result = new ArrayList<IContributionItem>();
		ScanDescription sd = ((ScanDescriptionEditor) Activator.getDefault()
				.getWorkbench().getActiveWorkbenchWindow().getActivePage()
				.getActiveEditor()).getContent();
		ScanModule viewModule  = null;
		if (Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().
				getActivePage().getActivePart() instanceof ScanModuleView) {
			viewModule = ((ScanModuleView)Activator.getDefault().getWorkbench().
					getActiveWorkbenchWindow().getActivePage().getActivePart()).
					getCurrentScanModule();
		}
		
		{
			Event startEvent = sd.getDefaultStartEvent();

			Map<String, String> params = new HashMap<String, String>();
			params.put("de.ptb.epics.eve.editor.command.AddEvent.EventId",
					startEvent.getId());
			params.put("de.ptb.epics.eve.editor.command.AddEvent.EventType",
					EventTypes.SCHEDULE.toString());
			EventImpacts eventImpact = determineEventImpact();
			if (eventImpact == null) {
				logger.warn("EventImpact not found.");
				return result.toArray(new IContributionItem[0]);
			}
			params.put("de.ptb.epics.eve.editor.command.AddEvent.EventImpact",
					eventImpact.toString());
			IViewPart activePart = getActiveViewPart();
			if (activePart == null) {
				logger.warn("active part is not a view.");
				return result.toArray(new IContributionItem[0]);
			}
			params.put("de.ptb.epics.eve.editor.command.AddEvent.ActivePart",
					activePart.getViewSite().getId());
			CommandContributionItemParameter p = new CommandContributionItemParameter(
					PlatformUI.getWorkbench().getActiveWorkbenchWindow(), "",
					"de.ptb.epics.eve.editor.command.addevent", SWT.PUSH);
			p.label = startEvent.getName();
			p.parameters = params;
			CommandContributionItem item = new CommandContributionItem(p);
			item.setVisible(true);
			result.add(item);
		}
		
		for (Chain chain : sd.getChains()) {
			for (ScanModule sm : chain.getScanModules()) {
				if (viewModule != null && viewModule.equals(sm)) {
					continue;
				}
				String eventId = "S-" + chain.getId() + "-" + sm.getId() + "-"
						+ "E";
				Map<String, String> params = new HashMap<String, String>();
				params.put("de.ptb.epics.eve.editor.command.AddEvent.EventId",
						eventId);
				params.put(
						"de.ptb.epics.eve.editor.command.AddEvent.EventType",
						EventTypes.SCHEDULE.toString());
				EventImpacts eventImpact = determineEventImpact();
				if (eventImpact == null) {
					logger.warn("EventImpact not found.");
					return result.toArray(new IContributionItem[0]);
				}
				params.put(
						"de.ptb.epics.eve.editor.command.AddEvent.EventImpact",
						eventImpact.toString());
				IViewPart activePart = getActiveViewPart();
				if (activePart == null) {
					logger.warn("active part is not a view.");
					return result.toArray(new IContributionItem[0]);
				}
				params.put(
						"de.ptb.epics.eve.editor.command.AddEvent.ActivePart",
						activePart.getViewSite().getId());
				CommandContributionItemParameter p = new CommandContributionItemParameter(
						PlatformUI.getWorkbench().getActiveWorkbenchWindow(),
						"", "de.ptb.epics.eve.editor.command.addevent",
						SWT.PUSH);
				p.label = "Schedule " + "( " + eventId + " )";
				p.parameters = params;
				CommandContributionItem item = new CommandContributionItem(p);
				item.setVisible(true);
				result.add(item);
			}
		}
		return result.toArray(new IContributionItem[0]);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean isDynamic() {
		return true;
	}
}
{'fraction_non_alphanumeric': 0.13656433978132884, 'fraction_numerical': 0.001682085786375105, 'mean_word_length': 4.270360110803324, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7156918', 'n_tokens_mistral': 3560, 'n_tokens_neox': 3034, 'n_words': 469}