ViewerPreferencePage.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.viewer.util;
00002 
00003 import org.eclipse.jface.preference.*;
00004 import org.eclipse.jface.util.IPropertyChangeListener;
00005 import org.eclipse.swt.graphics.FontData;
00006 import org.eclipse.ui.IWorkbenchPreferencePage;
00007 import org.eclipse.ui.IWorkbench;
00008 import org.eclipse.ui.IWorkbenchWindow;
00009 import org.eclipse.ui.preferences.ScopedPreferenceStore;
00010 
00011 import edu.rice.cs.hpc.viewer.experiment.ExperimentManager;
00012 import edu.rice.cs.hpc.viewer.framework.Activator;
00013 import edu.rice.cs.hpc.viewer.graph.GraphEditor;
00014 import edu.rice.cs.hpc.viewer.scope.ScopeActions;
00015 
00030 public class ViewerPreferencePage
00031     extends FieldEditorPreferencePage
00032     implements IWorkbenchPreferencePage, IPropertyChangeListener  {
00033 
00034     private IWorkbenchWindow objWindow;
00038     public ViewerPreferencePage() {
00039         super(GRID);
00040         setPreferenceStore(Activator.getDefault().getPreferenceStore());
00041     }
00042     
00049     public void createFieldEditors() {
00050         
00051         //----------------------------------------------------------------------
00052         // option to show the caller view
00053         //----------------------------------------------------------------------
00054         BooleanFieldEditor objCallerViewFlag = new BooleanFieldEditor(PreferenceConstants.P_CALLER_VIEW,
00055                 "Show caller view", getFieldEditorParent());
00056         addField(objCallerViewFlag);
00057         
00058         //----------------------------------------------------------------------
00059         // option the location of the default directory
00060         //----------------------------------------------------------------------
00061         DirectoryFieldEditor objDirectory = new DirectoryFieldEditor(PreferenceConstants.P_PATH, 
00062                 "&Default database directory:", getFieldEditorParent()); 
00063         addField(objDirectory); 
00064         
00065         //----------------------------------------------------------------------
00066         // option the threshold of hot call path
00067         //----------------------------------------------------------------------
00068         StringFieldEditor objThreshold = new StringFieldEditor(PreferenceConstants.P_THRESHOLD,
00069                 "&Threshold for hot call path\n(fraction from parent metric value, between 0.0 and 1.0)", 
00070                 this.getFieldEditorParent());
00071         objThreshold.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST);
00072         objThreshold.setEmptyStringAllowed(true);
00073         objThreshold.setStringValue(String.valueOf(ScopeActions.fTHRESHOLD));
00074         addField(objThreshold);
00075         
00076         //----------------------------------------------------------------------
00077         // options for fonts 
00078         //----------------------------------------------------------------------
00079         FontFieldEditor objFontMetric = new FontFieldEditor(PreferenceConstants.P_FONT_METRIC,
00080                 "Font for metric columns", getFieldEditorParent());
00081         addField(objFontMetric);
00082         FontFieldEditor objFontGeneric = new FontFieldEditor(PreferenceConstants.P_FONT_GENERIC,
00083                 "Font for view/editor", getFieldEditorParent());
00084         
00085         addField(objFontGeneric);
00086         
00087         //----------------------------------------------------------------------
00088         // option for the size of the dot in the graph
00089         //----------------------------------------------------------------------
00090         StringFieldEditor objGraphDotDiameter = new StringFieldEditor(PreferenceConstants.P_GRAPH_DOT_DIAMETER, "Graph dot diameter",
00091                 this.getFieldEditorParent());
00092         addField(objGraphDotDiameter);
00093 
00094     }
00095 
00096 
00097     /* (non-Javadoc)
00098      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
00099      */
00100     public void init(IWorkbench workbench) {
00101         this.objWindow = workbench.getActiveWorkbenchWindow();
00102     }
00103 
00104     /* (non-Javadoc)
00105      */
00106     protected void performApply() {
00107         this.performOk();
00108     }
00109     
00110     /* (non-Javadoc)
00111      */
00112     public boolean performOk() {
00113         
00114         ScopedPreferenceStore objPref = (ScopedPreferenceStore)Activator.getDefault().getPreferenceStore();
00115 
00116         // ---------------------------------------------
00117         // store the new value
00118         // ---------------------------------------------
00119         super.performOk();
00120 
00121         // ---------------------------------------------
00122         // notify the changes if necessary
00123         // ---------------------------------------------
00124 
00125         // get the threshold
00126         double fThreshold = objPref.getDouble(PreferenceConstants.P_THRESHOLD);
00127         ScopeActions.fTHRESHOLD = fThreshold;
00128         // get the font for metrics columns
00129         FontData []objFontsMetric = PreferenceConverter.getFontDataArray(objPref, PreferenceConstants.P_FONT_METRIC);
00130         FontData []objFontsGeneric = PreferenceConverter.getFontDataArray(objPref, PreferenceConstants.P_FONT_GENERIC);
00131         Utilities.setFontMetric(this.objWindow, objFontsMetric, objFontsGeneric);
00132 
00133         ExperimentManager.sLastPath = objPref.getString(PreferenceConstants.P_PATH);
00134         
00135         int size = objPref.getInt(PreferenceConstants.P_GRAPH_DOT_DIAMETER);
00136         GraphEditor.setSymbolSize(size);
00137         
00138         return true;
00139     }
00140 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1