Coverage report

  %line %branch
com.bonevich.eclipse.cvsgrapher.CvsGraphPlugin
0% 
0% 

 1  
 /* ====================================================================
 2  
  * The Apache Software License, Version 1.1
 3  
  *
 4  
  * Copyright (c) 2000 The Apache Software Foundation.  All rights
 5  
  * reserved.
 6  
  *
 7  
  * Redistribution and use in source and binary forms, with or without
 8  
  * modification, are permitted provided that the following conditions
 9  
  * are met:
 10  
  *
 11  
  * 1. Redistributions of source code must retain the above copyright
 12  
  *    notice, this list of conditions and the following disclaimer.
 13  
  *
 14  
  * 2. Redistributions in binary form must reproduce the above copyright
 15  
  *    notice, this list of conditions and the following disclaimer in
 16  
  *    the documentation and/or other materials provided with the
 17  
  *    distribution.
 18  
  *
 19  
  * 3. The end-user documentation included with the redistribution,
 20  
  *    if any, must include the following acknowledgment:
 21  
  *       "This product includes software developed by the
 22  
  *        Apache Software Foundation (http://www.apache.org/)."
 23  
  *    Alternately, this acknowledgment may appear in the software itself,
 24  
  *    if and wherever such third-party acknowledgments normally appear.
 25  
  *
 26  
  * 4. The names "Apache" and "Apache Software Foundation" must
 27  
  *    not be used to endorse or promote products derived from this
 28  
  *    software without prior written permission. For written
 29  
  *    permission, please contact apache@apache.org.
 30  
  *
 31  
  * 5. Products derived from this software may not be called "Apache",
 32  
  *    nor may "Apache" appear in their name, without prior written
 33  
  *    permission of the Apache Software Foundation.
 34  
  *
 35  
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36  
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37  
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38  
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39  
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40  
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41  
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42  
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43  
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44  
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45  
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46  
  * SUCH DAMAGE.
 47  
  * ====================================================================
 48  
  *
 49  
  * This software consists of voluntary contributions made by many
 50  
  * individuals on behalf of the Apache Software Foundation.  For more
 51  
  * information on the Apache Software Foundation, please see
 52  
  * <http://www.apache.org/>.
 53  
  *
 54  
  * Portions of this software are based upon public domain software
 55  
  * originally written at the National Center for Supercomputing Applications,
 56  
  * University of Illinois, Urbana-Champaign.
 57  
  */
 58  
 package com.bonevich.eclipse.cvsgrapher;
 59  
 
 60  
 import org.eclipse.core.resources.IWorkspace;
 61  
 import org.eclipse.core.resources.ResourcesPlugin;
 62  
 import org.eclipse.core.runtime.IPluginDescriptor;
 63  
 import org.eclipse.jface.preference.IPreferenceStore;
 64  
 import org.eclipse.swt.graphics.Color;
 65  
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 66  
 
 67  
 import java.util.ResourceBundle;
 68  
 import java.util.regex.Pattern;
 69  
 
 70  
 /**
 71  
  * The main plugin class to be used in the desktop.
 72  
  */
 73  
 public final class CvsGraphPlugin 
 74  
 	extends AbstractUIPlugin 
 75  
 	implements CvsGraphPluginResources
 76  
 {
 77  
 	public static final String PREFERENCE_COLOR_VERSION = "cvsgrapher.prefs.color.version";
 78  
 	public static final String PREFERENCE_COLOR_BRANCH = "cvsgrapher.prefs.color.branch";
 79  
 	public static final String PREFERENCE_MERGETAG_SOURCE = "cvsgrapher.prefs.mergetag.pattern.source";
 80  
 	public static final String PREFERENCE_MERGETAG_DEST = "cvsgrapher.prefs.mergetag.pattern.dest";
 81  
 	public static final String PREFERENCE_SHOW_AUTHOR = "cvsgrapher.prefs.show.author";
 82  
 	public static final String PREFERENCE_SHOW_TIMESTAMP = "cvsgrapher.prefs.show.timestamp";
 83  
 	public static final String PREFERENCE_SHOW_TAGS = "cvsgrapher.prefs.show.tags";
 84  
 	
 85  
 	public static final String DEFAULT_COLOR_VERSION = "211,211,211"; //lightGray
 86  
 	public static final String DEFAULT_COLOR_BRANCH = "255,255,0"; //yellow
 87  
 
 88  
 	public static final String DEFAULT_MERGETAG_SOURCE = "source_(.*)";
 89  
 	public static final String DEFAULT_MERGETAG_DEST = "merge_(.*)";
 90  
 	
 91  
 	public static final boolean DEFAULT_SHOW_AUTHOR = true;
 92  
 	public static final boolean DEFAULT_SHOW_TIMESTAMP = true;
 93  
 	public static final boolean DEFAULT_SHOW_TAGS = true;
 94  
 	
 95  
 	//The shared instance.
 96  
 	private static CvsGraphPlugin _currentInstance;
 97  
 	private ColorConverter _converter;
 98  
 	private Pattern _sourcePattern;
 99  
 	private Pattern _destPattern;
 100  
 	
 101  
 	public CvsGraphPlugin(IPluginDescriptor descriptor)
 102  
 	{
 103  0
 		super(descriptor);
 104  0
 		_currentInstance = this;
 105  0
 		_converter = new ColorConverter();
 106  0
 	}
 107  
 
 108  
 	public static CvsGraphPlugin getPlugin()
 109  
 	{
 110  0
 		return _currentInstance;
 111  
 	}
 112  
 
 113  
 	public static IWorkspace getWorkspace()
 114  
 	{
 115  0
 		return ResourcesPlugin.getWorkspace();
 116  
 	}
 117  
 
 118  
 	/**
 119  
 	 * Returns the string from the plugin's resource bundle,
 120  
 	 * or 'key' if not found.
 121  
 	 */
 122  
 	public static String getResourceString(String key)
 123  
 	{
 124  0
 		return CvsGraphPluginMessages.bind(key);
 125  
 	}
 126  
 
 127  
 	public ResourceBundle getResourceBundle()
 128  
 	{
 129  0
 		return CvsGraphPluginMessages.getResourceBundle();
 130  
 	}
 131  
 
 132  
 	protected void initializeDefaultPreferences(IPreferenceStore store)
 133  
 	{
 134  0
 		store.setDefault(PREFERENCE_COLOR_VERSION, DEFAULT_COLOR_VERSION);
 135  0
 		store.setDefault(PREFERENCE_COLOR_BRANCH, DEFAULT_COLOR_BRANCH);
 136  0
 		store.setDefault(PREFERENCE_MERGETAG_SOURCE, DEFAULT_MERGETAG_SOURCE);
 137  0
 		store.setDefault(PREFERENCE_MERGETAG_DEST, DEFAULT_MERGETAG_DEST);
 138  0
 		store.setDefault(PREFERENCE_SHOW_AUTHOR, DEFAULT_SHOW_AUTHOR);
 139  0
 		store.setDefault(PREFERENCE_SHOW_TIMESTAMP, DEFAULT_SHOW_TIMESTAMP);
 140  0
 		store.setDefault(PREFERENCE_SHOW_TAGS, DEFAULT_SHOW_TAGS);
 141  0
 	}
 142  
 	
 143  
 	public Color getVersionNodeColorPreference()
 144  
 	{
 145  0
 		return _converter.getColor(getPreferenceStore().getString(PREFERENCE_COLOR_VERSION));
 146  
 	}
 147  
 
 148  
 	public Color getBranchNodeColorPreference()
 149  
 	{
 150  0
 		return _converter.getColor(getPreferenceStore().getString(PREFERENCE_COLOR_BRANCH));
 151  
 	}
 152  
 
 153  
 	public Pattern getMergeTagSourcePreference()
 154  
 	{
 155  0
 		String patternString = getPreferenceStore().getString(PREFERENCE_MERGETAG_SOURCE);
 156  0
 		if (_sourcePattern == null || !_sourcePattern.pattern().equals(patternString))
 157  
 		{
 158  0
 			_sourcePattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE);
 159  
 		}
 160  0
 		return _sourcePattern;
 161  
 	}
 162  
 
 163  
 	public Pattern getMergeTagDestPreference()
 164  
 	{
 165  0
 		String patternString = getPreferenceStore().getString(PREFERENCE_MERGETAG_DEST);
 166  0
 		if (_destPattern == null || !_destPattern.pattern().equals(patternString))
 167  
 		{
 168  0
 			_destPattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE);
 169  
 		}
 170  0
 		return _destPattern;
 171  
 	}
 172  
 	
 173  
 	public boolean showAuthorPreference()
 174  
 	{
 175  0
 		return getPreferenceStore().getBoolean(PREFERENCE_SHOW_AUTHOR);
 176  
 	}
 177  
 	
 178  
 	public boolean showTimestampPreference()
 179  
 	{
 180  0
 		return getPreferenceStore().getBoolean(PREFERENCE_SHOW_TIMESTAMP);
 181  
 	}
 182  
 	
 183  
 	public boolean showTagsPreference()
 184  
 	{
 185  0
 		return getPreferenceStore().getBoolean(PREFERENCE_SHOW_TAGS);
 186  
 	}
 187  
 	
 188  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.