<commit_before>package org.csstudio.platform.ui.workbench;

import org.csstudio.platform.ui.internal.localization.Messages;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ContributionItemFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchConfigurer;

/**
 * An action builder for the menu bars of the control system studio.
 * 
 * @author awill
 * 
 */
public final class WorkbenchActionBuilder {
	/**
	 * The workbench window, this action builder is contributing to.
	 */
	private IWorkbenchWindow _window;

	/**
	 * A convenience variable and method so that the actionConfigurer doesn't
	 * need to get passed into registerGlobalAction every time it's called.
	 */
	private IActionBarConfigurer _actionBarConfigurer;

	/**
	 * The exit action. This action closes the workbench.
	 */
	private IWorkbenchAction _exitAction;

	/**
	 * The preferences action. This action opens the central preferences dialog.
	 */
	private IWorkbenchAction _preferencesAction;

	/**
	 * The documentation action. This action starts up the help system.
	 */
	private IWorkbenchAction _documentationAction;

	/**
	 * The about action. This action opens up the about dialog.
	 */
	private IWorkbenchAction _aboutAction;
	
	/**
	 * The save action. This action saves the current editor.
	 */
	private IWorkbenchAction _saveAction;

	/**
	 * Constructs a new action builder which contributes actions to the given
	 * window.
	 * 
	 * @param window
	 *            the _window
	 */
	public WorkbenchActionBuilder(final IWorkbenchWindow window) {
		_window = window;
	}

	/**
	 * Returns the window to which this action builder is contributing.
	 * 
	 * @return The window to which this action builder is contributing.
	 */
	private IWorkbenchWindow getWindow() {
		return _window;
	}

	/**
	 * Builds the actions and contributes them to the given _window.
	 * 
	 * @param windowConfigurer
	 *            The workbench configurer.
	 * @param actionBarConfigurer
	 *            The action bar configurer.
	 */
	public void makeAndPopulateActions(
			final IWorkbenchConfigurer windowConfigurer,
			final IActionBarConfigurer actionBarConfigurer) {
		makeActions(windowConfigurer, actionBarConfigurer);
		populateMenuBar(actionBarConfigurer);
	}

	/**
	 * Fills the menu bar with the workbench actions.
	 * 
	 * @param configurer
	 *            The action bar configurer.
	 */
	public void populateMenuBar(final IActionBarConfigurer configurer) {
		IMenuManager menubar = configurer.getMenuManager();
		menubar.add(createFileMenu());
		menubar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
		menubar.add(createCSSMenu());
		menubar.add(createWindowMenu());
		menubar.add(createHelpMenu());
	}

	/**
	 * Creates and returns the CSS menu.
	 * 
	 * @return The CSS menu.
	 */
	private MenuManager createCSSMenu() {
		MenuManager menu = new MenuManager(
				Messages.getString("WorkbenchActionBuilder.MENU_CSS"), IWorkbenchIds.MENU_CSS); //$NON-NLS-1$

		menu
				.add(new MenuManager(
						Messages
								.getString("WorkbenchActionBuilder.MENU_CSS_DISPLAY"), IWorkbenchIds.MENU_CSS_DISPLAY)); //$NON-NLS-1$
		menu
				.add(new MenuManager(
						Messages
								.getString("WorkbenchActionBuilder.MENU_CSS_ALARM"), IWorkbenchIds.MENU_CSS_ALARM)); //$NON-NLS-1$<commit_msg>Refactoring<commit_after>package org.csstudio.platform.ui.workbench;

import org.csstudio.platform.ui.internal.localization.Messages;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ContributionItemFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchConfigurer;

/**
 * An action builder for the menu bars of the control system studio.
 * 
 * @author awill
 * 
 */
public final class WorkbenchActionBuilder {
	/**
	 * The workbench window, this action builder is contributing to.
	 */
	private IWorkbenchWindow _window;

	/**
	 * A convenience variable and method so that the actionConfigurer doesn't
	 * need to get passed into registerGlobalAction every time it's called.
	 */
	private IActionBarConfigurer _actionBarConfigurer;

	/**
	 * The exit action. This action closes the workbench.
	 */
	private IWorkbenchAction _exitAction;

	/**
	 * The preferences action. This action opens the central preferences dialog.
	 */
	private IWorkbenchAction _preferencesAction;

	/**
	 * The documentation action. This action starts up the help system.
	 */
	private IWorkbenchAction _documentationAction;

	/**
	 * The about action. This action opens up the about dialog.
	 */
	private IWorkbenchAction _aboutAction;
	
	/**
	 * The save action. This action saves the current editor.
	 */
	private IWorkbenchAction _saveAction;

	/**
	 * Constructs a new action builder which contributes actions to the given
	 * window.
	 * 
	 * @param window
	 *            the _window
	 */
	public WorkbenchActionBuilder(final IWorkbenchWindow window) {
		_window = window;
	}

	/**
	 * Returns the window to which this action builder is contributing.
	 * 
	 * @return The window to which this action builder is contributing.
	 */
	private IWorkbenchWindow getWindow() {
		return _window;
	}

	/**
	 * Builds the actions and contributes them to the given _window.
	 * 
	 * @param windowConfigurer
	 *            The workbench configurer.
	 * @param actionBarConfigurer
	 *            The action bar configurer.
	 */
	public void makeAndPopulateActions(
			final IWorkbenchConfigurer windowConfigurer,
			final IActionBarConfigurer actionBarConfigurer) {
		makeActions(windowConfigurer, actionBarConfigurer);
		populateMenuBar(actionBarConfigurer);
		populateCoolBar(actionBarConfigurer);
	}

	/**
	 * Fills the menu bar with the workbench actions.
	 * 
	 * @param configurer
	 *            The action bar configurer.
	 */
	public void populateMenuBar(final IActionBarConfigurer configurer) {
		IMenuManager menubar = configurer.getMenuManager();
		menubar.add(createFileMenu());
		menubar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
		menubar.add(createCSSMenu());
		menubar.add(createWindowMenu());
		menubar.add(createHelpMenu());
	}
	
	/**
	 * Fills the cool bar with the workbench actions.
	 * 
	 * @param configurer
	 *            The action bar configurer.
	 */
	public void populateCoolBar(final IActionBarConfigurer configurer) {
		ICoolBarManager coolbar = configurer.getCoolBarManager();
		coolbar.add(_documentationAction);
	}
	

	/**
	 * Creates and returns the CSS menu.
	 * 
	 * @return The CSS menu.
	 */
	private MenuManager createCSSMenu() {
		MenuManager menu = new MenuManager(
				Messages.getString("WorkbenchActionBuilder.MENU_CSS"), IWorkbenchIds.MENU_CSS); //$NON-NLS-1$

		menu
				.add(new MenuManager(
						Messages
								.getString("WorkbenchActionBuilder.MENU_CSS_DISPLAY"), IWorkbenchIds.MENU_CSS_DISPLAY)); //$NON-NLS-1$
		menu
				.add(new MenuManager(
						Messages
								.getString("WorkbenchActionBuilder.MENU_CSS_ALARM"), IWorkbenchIds.MENU_CSS_ALARM)); //$NON-NLS-1$
{'fraction_non_alphanumeric': 0.09040474089017779, 'fraction_numerical': 0.0007565250283696885, 'mean_word_length': 4.010739102969046, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4447170', 'n_tokens_mistral': 2522, 'n_tokens_neox': 2254, 'n_words': 599}