Coverage report

  %line %branch
com.bonevich.eclipse.cvsgrapher.prefs.CvsGrapherPreferencePage
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.prefs;
 59  
 
 60  
 import java.util.HashMap;
 61  
 import java.util.Map;
 62  
 
 63  
 import org.eclipse.jface.preference.BooleanFieldEditor;
 64  
 import org.eclipse.jface.preference.ColorFieldEditor;
 65  
 import org.eclipse.jface.preference.FieldEditor;
 66  
 import org.eclipse.jface.preference.PreferencePage;
 67  
 import org.eclipse.jface.preference.StringFieldEditor;
 68  
 import org.eclipse.swt.SWT;
 69  
 import org.eclipse.swt.layout.GridData;
 70  
 import org.eclipse.swt.layout.GridLayout;
 71  
 import org.eclipse.swt.widgets.Composite;
 72  
 import org.eclipse.swt.widgets.Control;
 73  
 import org.eclipse.swt.widgets.Group;
 74  
 import org.eclipse.swt.widgets.Label;
 75  
 import org.eclipse.ui.IWorkbench;
 76  
 import org.eclipse.ui.IWorkbenchPreferencePage;
 77  
 
 78  
 import com.bonevich.eclipse.cvsgrapher.CvsGraphPlugin;
 79  
 import com.bonevich.eclipse.cvsgrapher.CvsGraphPluginMessages;
 80  
 import com.bonevich.eclipse.cvsgrapher.CvsGraphPluginResources;
 81  
 
 82  
 /**
 83  
  * Preference page for the Boneclipse Logging Plugin.  Allows the user
 84  
  * to specify which logging API to use and the default name for the logging
 85  
  * field to be used.
 86  
  * 
 87  
  * @author jbonevic
 88  
  */
 89  
 public class CvsGrapherPreferencePage 
 90  
 	extends PreferencePage 
 91  
 	implements IWorkbenchPreferencePage, CvsGraphPluginResources
 92  
 {
 93  
 	private static final String PREFERENCE_PAGE_TITLE    = "CVSGrapher";
 94  
 
 95  
 	// field editor keys
 96  
 	private static final String FIELDEDITOR_COLOR_VERSION = "cvsgrapher.color.version";
 97  
 	private static final String FIELDEDITOR_COLOR_BRANCH = "cvsgrapher.color.branch";
 98  
 	
 99  
 	private static final String FIELDEDITOR_MERGETAG_SOURCE = "cvsgrapher.mergetag.pattern.source";
 100  
 	private static final String FIELDEDITOR_MERGETAG_DEST = "cvsgrapher.mergetag.pattern.destination";
 101  
 	
 102  
 	private static final String FIELDEDITOR_SHOW_AUTHOR = "cvsgrapher.show.author";
 103  
 	private static final String FIELDEDITOR_SHOW_TIMESTAMP = "cvsgrapher.show.timestamp";
 104  
 	private static final String FIELDEDITOR_SHOW_TAGS = "cvsgrapher.show.tags";
 105  
 	
 106  0
 	private Map _fieldEditors = new HashMap();
 107  
 	
 108  
 	public CvsGrapherPreferencePage()
 109  
 	{
 110  0
 		super(PREFERENCE_PAGE_TITLE);
 111  0
 	}
 112  
 
 113  
 	public void init(IWorkbench workbench)
 114  
 	{
 115  0
 		setPreferenceStore(CvsGraphPlugin.getPlugin().getPreferenceStore());
 116  0
 	}
 117  
 
 118  
 	protected Control createContents(Composite parent)
 119  
 	{
 120  0
 		Composite top = createContainerWithDescription(parent);
 121  
 
 122  0
 		createColorFieldEditors(top);
 123  0
 		createMergeTagPatternFields(top);
 124  0
 		createShowAttributesCheckboxGroup(top);
 125  
 		
 126  0
 		return top;
 127  
 	}
 128  
 
 129  
 	private void createColorFieldEditors(Composite top)
 130  
 	{
 131  0
 		Composite colorFieldCmp = new Composite(top, SWT.LEFT);
 132  0
 		colorFieldCmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 133  0
 		colorFieldCmp.setLayout(new GridLayout());
 134  
 		
 135  0
 		ColorFieldEditor versionColorField = new ColorFieldEditor(
 136  
 				CvsGraphPlugin.PREFERENCE_COLOR_VERSION,
 137  
 				CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_COLOR_VERSION_LABEL),
 138  
 				colorFieldCmp 
 139  
 		);
 140  
 
 141  0
 		ColorFieldEditor branchColorField = new ColorFieldEditor(
 142  
 				CvsGraphPlugin.PREFERENCE_COLOR_BRANCH,
 143  
 				CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_COLOR_BRANCH_LABEL),
 144  
 				colorFieldCmp 
 145  
 		);
 146  0
 		addFieldEditor(FIELDEDITOR_COLOR_BRANCH, branchColorField);
 147  0
 		addFieldEditor(FIELDEDITOR_COLOR_VERSION, versionColorField);
 148  0
 	}
 149  
 
 150  
 	private void createShowAttributesCheckboxGroup(Composite top)
 151  
 	{
 152  0
 		Group group1 = new Group(top, SWT.LEFT);
 153  0
 		group1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 154  0
 		GridLayout layout = new GridLayout();
 155  0
 		layout.marginWidth = 7;
 156  0
 		group1.setLayout(layout);
 157  0
 		group1.setText(CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_SHOW_LABEL));
 158  
 
 159  0
 		Composite group = new Composite(group1, SWT.NONE);
 160  0
 		group.setLayoutData(new GridData(GridData.CENTER));
 161  0
 		group.setLayout(new GridLayout());
 162  
 		
 163  0
 		BooleanFieldEditor useTraceConditionals = new BooleanFieldEditor(
 164  
 				CvsGraphPlugin.PREFERENCE_SHOW_AUTHOR,
 165  
 				CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_SHOW_AUTHOR_LABEL),
 166  
 				group
 167  
 		);
 168  0
 		BooleanFieldEditor useDebugConditionals = new BooleanFieldEditor(
 169  
 				CvsGraphPlugin.PREFERENCE_SHOW_TIMESTAMP,
 170  
 				CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_SHOW_TIMESTAMP_LABEL),
 171  
 				group
 172  
 		);
 173  0
 		BooleanFieldEditor useInfoConditionals = new BooleanFieldEditor(
 174  
 				CvsGraphPlugin.PREFERENCE_SHOW_TAGS,
 175  
 				CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_SHOW_TAGS_LABEL),
 176  
 				group
 177  
 		);
 178  
 
 179  0
 		addFieldEditor(FIELDEDITOR_SHOW_AUTHOR, useTraceConditionals);
 180  0
 		addFieldEditor(FIELDEDITOR_SHOW_TIMESTAMP, useDebugConditionals);
 181  0
 		addFieldEditor(FIELDEDITOR_SHOW_TAGS, useInfoConditionals);
 182  0
 	}
 183  
 
 184  
 	private void createMergeTagPatternFields(Composite top)
 185  
 	{
 186  0
 		Group group1 = new Group(top, SWT.LEFT);
 187  0
 		group1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 188  0
 		GridLayout layout = new GridLayout();
 189  0
 		layout.marginWidth = 7;
 190  0
 		group1.setLayout(layout);
 191  0
 		group1.setText(CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_MERGETAGS_LABEL));
 192  
 
 193  0
 		Composite mergeTagPatternComp = new Composite(group1, SWT.LEFT);
 194  0
 		mergeTagPatternComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 195  0
 		mergeTagPatternComp.setLayout(new GridLayout());
 196  
 		
 197  0
 		StringFieldEditor sourceMergeTagPattern = new StringFieldEditor(
 198  
 				CvsGraphPlugin.PREFERENCE_MERGETAG_SOURCE,
 199  
 				CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_MERGETAG_SOURCE_LABEL),
 200  
 				15,
 201  
 				StringFieldEditor.VALIDATE_ON_FOCUS_LOST,
 202  
 				mergeTagPatternComp
 203  
 			);
 204  0
 		sourceMergeTagPattern.setEmptyStringAllowed(true);
 205  
 
 206  0
 		StringFieldEditor destMergeTagPattern = new StringFieldEditor(
 207  
 				CvsGraphPlugin.PREFERENCE_MERGETAG_DEST,
 208  
 				CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_MERGETAG_DEST_LABEL),
 209  
 				15,
 210  
 				StringFieldEditor.VALIDATE_ON_FOCUS_LOST,
 211  
 				mergeTagPatternComp
 212  
 		);
 213  0
 		destMergeTagPattern.setEmptyStringAllowed(true);
 214  
 
 215  0
 		addFieldEditor(FIELDEDITOR_MERGETAG_SOURCE, sourceMergeTagPattern);
 216  0
 		addFieldEditor(FIELDEDITOR_MERGETAG_DEST, destMergeTagPattern);
 217  0
 	}
 218  
 
 219  
 	private Composite createContainerWithDescription(Composite parent)
 220  
 	{
 221  0
 		Composite top = new Composite(parent, SWT.LEFT);
 222  0
 		top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
 223  0
 		top.setLayout(new GridLayout());
 224  
 		
 225  0
 		Label description = new Label(top, SWT.NONE);
 226  0
 		description.setText(CvsGraphPluginMessages.bind(CVSGRAPHER_PREFS_GENERAL));
 227  0
 		return top;
 228  
 	}
 229  
 
 230  
 	private void addFieldEditor(String name, FieldEditor editor)
 231  
 	{
 232  0
 		_fieldEditors.put(name, editor);
 233  0
 		editor.setPreferencePage(this);
 234  0
 		editor.setPreferenceStore(getPreferenceStore());
 235  0
 		editor.load();
 236  0
 	}
 237  
 	
 238  
 	private FieldEditor getFieldEditor(String name)
 239  
 	{
 240  0
 		return (FieldEditor) _fieldEditors.get(name);
 241  
 	}
 242  
 
 243  
 	protected void performDefaults()
 244  
 	{
 245  0
 		super.performDefaults();
 246  
 
 247  0
 		loadDefault(FIELDEDITOR_COLOR_VERSION);
 248  0
 		loadDefault(FIELDEDITOR_COLOR_BRANCH);
 249  0
 		loadDefault(FIELDEDITOR_MERGETAG_SOURCE);
 250  0
 		loadDefault(FIELDEDITOR_MERGETAG_DEST);
 251  0
 		loadDefault(FIELDEDITOR_SHOW_AUTHOR);
 252  0
 		loadDefault(FIELDEDITOR_SHOW_TIMESTAMP);
 253  0
 		loadDefault(FIELDEDITOR_SHOW_TAGS);
 254  0
 	}
 255  
 	
 256  
 	private void loadDefault(String field)
 257  
 	{
 258  0
 		FieldEditor editor = getFieldEditor(field);
 259  0
 		editor.loadDefault();
 260  0
 	}
 261  
 
 262  
 	public boolean performOk()
 263  
 	{
 264  0
 		storeValue(FIELDEDITOR_COLOR_VERSION);
 265  0
 		storeValue(FIELDEDITOR_COLOR_BRANCH);
 266  0
 		storeValue(FIELDEDITOR_MERGETAG_SOURCE);
 267  0
 		storeValue(FIELDEDITOR_MERGETAG_DEST);
 268  0
 		storeValue(FIELDEDITOR_SHOW_AUTHOR);
 269  0
 		storeValue(FIELDEDITOR_SHOW_TIMESTAMP);
 270  0
 		storeValue(FIELDEDITOR_SHOW_TAGS);
 271  
 		
 272  0
 		return super.performOk();
 273  
 	}
 274  
 	
 275  
 	private void storeValue(String field)
 276  
 	{
 277  0
 		FieldEditor editor = getFieldEditor(field);
 278  0
 		editor.store();
 279  0
 	}
 280  
 
 281  
 }

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