/******************************************************************************* * Copyright (c) 2011 Gluster, Inc. * This file is part of Gluster Management Console. * * Gluster Management Console is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Gluster Management Console is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License * for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see * . *******************************************************************************/ package com.gluster.storage.management.console.preferences; import java.util.List; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IntegerFieldEditor; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import com.gluster.storage.management.client.ClustersClient; import com.gluster.storage.management.console.Activator; /** * This class represents a preference page that * is contributed to the Preferences dialog. By * subclassing FieldEditorPreferencePage, we * can use the field support built into JFace that allows * us to create a page that is small and knows how to * save, restore and apply itself. *

* This page is used to modify preferences only. They * are stored in the preference store that belongs to * the main plug-in class. That way, preferences can * be accessed directly via the preference store. */ public class GlusterPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { private List clusterNames; public GlusterPreferencePage() { super(GRID); setPreferenceStore(Activator.getDefault().getPreferenceStore()); setDescription("Gluster Management Console"); } /** * Creates the field editors. Field editors are abstractions of * the common GUI blocks needed to manipulate various types * of preferences. Each field editor knows how to save and * restore itself. */ public void createFieldEditors() { addField( new BooleanFieldEditor( PreferenceConstants.P_SHOW_CLUSTER_SELECTION_DIALOG, "&Show Cluster Selection Dialog on Login:", getFieldEditorParent())); String[][] clusterNamesArr = new String[clusterNames.size()][2]; for(int i = 0; i < clusterNames.size(); i++) { String clusterName = clusterNames.get(i); clusterNamesArr[i][0] = clusterName; clusterNamesArr[i][1] = clusterName; } addField(new ComboFieldEditor(PreferenceConstants.P_DEFAULT_CLUSTER_NAME, "Default &Cluster to manage:", clusterNamesArr, getFieldEditorParent())); addField(new IntegerFieldEditor(PreferenceConstants.P_DATA_SYNC_INTERVAL, "&Refresh Interval (sec):", getFieldEditorParent())); } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ public void init(IWorkbench workbench) { clusterNames = new ClustersClient().getClusterNames(); } }