<commit_before>/*******************************************************************************
 * Copyright (c) 2004 - 2005 University Of British Columbia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/
package org.eclipse.mylar.tasks;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.bugzilla.BugzillaContentProvider;
import org.eclipse.mylar.tasks.bugzilla.BugzillaEditingMonitor;
import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge;
import org.eclipse.mylar.tasks.bugzilla.BugzillaReferencesProvider;
import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge;
import org.eclipse.mylar.tasks.bugzilla.ui.BugzillaUiBridge;
import org.eclipse.mylar.ui.MylarUiPlugin;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * @author <NAME>
 */
public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
    
    private static MylarTasksPlugin plugin;
    private static TaskListManager taskListManager;
    private BugzillaContentProvider bugzillaProvider;
    
    public static final String FILE_EXTENSION = ".xml";
    public static final String TASK_ID = "org.eclipse.mylar.tasks.userid";
    public static final String DEFAULT_TASK_LIST_FILE = "tasklist" + FILE_EXTENSION;
    public static final String TASK_EDITOR_ID = "org.eclipse.mylar.tasks.ui.taskEditor";
    public static final String SHOW_P1_MODE = "org.eclipse.mylar.tasks.show.p1";
    public static final String SHOW_P2_MODE = "org.eclipse.mylar.tasks.show.p2";
    public static final String SHOW_P3_MODE = "org.eclipse.mylar.tasks.show.p3";
    public static final String SHOW_P4_MODE = "org.eclipse.mylar.tasks.show.p4";
    public static final String SHOW_P5_MODE = "org.eclipse.mylar.tasks.show.p5";
    public static final String FILTER_COMPLETE_MODE = "org.eclipse.mylar.tasks.filter.complete";
    public static final String FILTER_INCOMPLETE_MODE = "org.eclipse.mylar.tasks.filter.incomplete";
    
	private ResourceBundle resourceBundle;

	public enum Priority_Level {
        P1,
        P2,
        P3,
        P4,
        P5;               
        
        @Override
        public String toString() {
            switch(this) {
                case P1: return "P1";
                case P2: return "P2";
                case P3: return "P3";
                case P4: return "P4";
                case P5: return "P5";
                default: return "null";
            }
        }
        public static Priority_Level fromString(String string) {
            if (string == null) return null;
            if (string.equals("P1")) return P1;
            if (string.equals("P2")) return P2;
            if (string.equals("P3")) return P3;
            if (string.equals("P4")) return P4;
            if (string.equals("P5")) return P5;
            return null;
        }
    }
	
    /** The bridge between Bugzilla and mylar */
    private static BugzillaMylarBridge bridge = null;

    private BugzillaStructureBridge structureBridge;
    
    private static BugzillaReferencesProvider referencesProvider = new BugzillaReferencesProvider();
    
    private static ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() {

        public void taskActivated(ITask task) {
            MylarPlugin.getTaskscapeManager().taskActivated(task.getHandle(), task.getPath());
        }

        public void tasksActivated(List<ITask> tasks) {
            for (ITask task : tasks) {
                MylarPlugin.getTaskscapeManager().taskActivated(task.getHandle(), task.getPath());
            }
        }

        public void taskDeactivated(ITask task) {
            MylarPlugin.getTaskscapeManager().taskDeactivated(task.getHandle(), task.getPath());
        }

		public void taskPropertyChanged(ITask updatedTask, String property) {
			// don't care about property change	
		}
        
    };
    
    private static ShellListener SHELL_LISTENER = new ShellListener() {
        private void saveState() {
            taskListManager.saveTaskList();
            for(ITask task : taskListManager.getTaskList().getActiveTasks()) {
                MylarPlugin.getTaskscapeManager().saveTaskscape(task.getHandle(), task.getPath());
            } 
        }
        public void shellClosed(ShellEvent arg0) {
            saveState();
        }  
        public void shellDeactivated(ShellEvent arg0) { 
            saveState();
        }
        public void shellActivated(ShellEvent arg0) { }<commit_msg>lazier task list writing<commit_after>/*******************************************************************************
 * Copyright (c) 2004 - 2005 University Of British Columbia and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/
package org.eclipse.mylar.tasks;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.bugzilla.BugzillaContentProvider;
import org.eclipse.mylar.tasks.bugzilla.BugzillaEditingMonitor;
import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge;
import org.eclipse.mylar.tasks.bugzilla.BugzillaReferencesProvider;
import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge;
import org.eclipse.mylar.tasks.bugzilla.ui.BugzillaUiBridge;
import org.eclipse.mylar.ui.MylarUiPlugin;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * @author <NAME>
 */
public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
    
    private static MylarTasksPlugin plugin;
    private static TaskListManager taskListManager;
    private BugzillaContentProvider bugzillaProvider;
    
    public static final String FILE_EXTENSION = ".xml";
    public static final String TASK_ID = "org.eclipse.mylar.tasks.userid";
    public static final String DEFAULT_TASK_LIST_FILE = "tasklist" + FILE_EXTENSION;
    public static final String TASK_EDITOR_ID = "org.eclipse.mylar.tasks.ui.taskEditor";
    public static final String SHOW_P1_MODE = "org.eclipse.mylar.tasks.show.p1";
    public static final String SHOW_P2_MODE = "org.eclipse.mylar.tasks.show.p2";
    public static final String SHOW_P3_MODE = "org.eclipse.mylar.tasks.show.p3";
    public static final String SHOW_P4_MODE = "org.eclipse.mylar.tasks.show.p4";
    public static final String SHOW_P5_MODE = "org.eclipse.mylar.tasks.show.p5";
    public static final String FILTER_COMPLETE_MODE = "org.eclipse.mylar.tasks.filter.complete";
    public static final String FILTER_INCOMPLETE_MODE = "org.eclipse.mylar.tasks.filter.incomplete";
    
	private ResourceBundle resourceBundle;

	public enum Priority_Level {
        P1,
        P2,
        P3,
        P4,
        P5;               
        
        @Override
        public String toString() {
            switch(this) {
                case P1: return "P1";
                case P2: return "P2";
                case P3: return "P3";
                case P4: return "P4";
                case P5: return "P5";
                default: return "null";
            }
        }
        public static Priority_Level fromString(String string) {
            if (string == null) return null;
            if (string.equals("P1")) return P1;
            if (string.equals("P2")) return P2;
            if (string.equals("P3")) return P3;
            if (string.equals("P4")) return P4;
            if (string.equals("P5")) return P5;
            return null;
        }
    }
	
    /** The bridge between Bugzilla and mylar */
    private static BugzillaMylarBridge bridge = null;

    private BugzillaStructureBridge structureBridge;
    
    private static BugzillaReferencesProvider referencesProvider = new BugzillaReferencesProvider();
    
    private static ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() {

        public void taskActivated(ITask task) {
            MylarPlugin.getTaskscapeManager().taskActivated(task.getHandle(), task.getPath());
        }

        public void tasksActivated(List<ITask> tasks) {
            for (ITask task : tasks) {
                MylarPlugin.getTaskscapeManager().taskActivated(task.getHandle(), task.getPath());
            }
        }

        public void taskDeactivated(ITask task) {
            MylarPlugin.getTaskscapeManager().taskDeactivated(task.getHandle(), task.getPath());
        }

		public void taskPropertyChanged(ITask updatedTask, String property) {
			// don't care about property change	
		}
        
    };
    
    private static ShellListener SHELL_LISTENER = new ShellListener() {
        private void saveState() {
            taskListManager.saveTaskList();
        }
        public void shellClosed(ShellEvent arg0) {
            saveState();
            for(ITask task : taskListManager.getTaskList().getActiveTasks()) {
                MylarPlugin.getTaskscapeManager().saveTaskscape(task.getHandle(), task.getPath());
            }
        }  
        public void shellDeactivated(ShellEvent arg0) { 
            saveState();
        }
        public void shellActivated(ShellEvent arg0) { }
{'fraction_non_alphanumeric': 0.11826975725497353, 'fraction_numerical': 0.009125752874612156, 'mean_word_length': 3.143289224952741, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '7662787', 'n_tokens_mistral': 3157, 'n_tokens_neox': 3055, 'n_words': 699}