Java tutorial
/******************************************************************************* * Copyright (c) 2016, 2017 Trig Chen, Dr. Philip Wenig. * * 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: * Trig Chen - initial API and implementation * Dr. Philip Wenig - initial API and implementation *******************************************************************************/ package cn.edu.xmu.tidems.control.ui.preferences; import java.util.Arrays; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import cn.edu.xmu.tidems.control.preferences.PreferenceSupplier; import cn.edu.xmu.tidems.control.ui.Activator; public class PreferencePageTideMS extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public PreferencePageTideMS() { super(GRID); } @Override protected void createFieldEditors() { final StringFieldEditor field = new StringFieldEditor(PreferenceSupplier.P_MZ_CALIBRATION_FACTOR, "Calibration factors (a, b, c):", getFieldEditorParent()); final double[] mzCalibrationFactor = PreferenceSupplier.getMZCalibrationFactor(); String str = Arrays.toString(mzCalibrationFactor); str = str.substring(1, str.length() - 1).replace(",", ", "); field.setStringValue(str); addField(field); } @Override public void init(final IWorkbench workbench) { setPreferenceStore(Activator.getDefault().getPreferenceStore()); setDescription( "XMU Tide Mass Spectrometer\n\n\nm/z calibration: mz = a + b*TOF + c*TOF*TOF, TOF unit is nanosecond."); } }