blob: 7fac02edc4051709c3f4e0a1cb0432695b2e3a21 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2006, 2015 THALES GLOBAL SERVICES.
* 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:
* Thales - initial API and implementation
*******************************************************************************/
package org.eclipse.amalgam.explorer.activity.internal.preferences;
import java.io.IOException;
import org.eclipse.amalgam.explorer.activity.ActivityExplorerActivator;
import org.eclipse.amalgam.explorer.activity.api.preferences.PreferenceConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
/**
*
*/
public class ActivityExplorerPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
/**
* Constructor
*/
public ActivityExplorerPreferencePage() {
super();
setDescription(Messages.ActivityExplorerPreferencePage_0);
}
/**
* @see org.eclipse.jface.preference.PreferencePage#performDefaults()
*/
@Override
protected void performDefaults() {
super.performDefaults();
}
/**
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
*/
@Override
public boolean performOk() {
boolean ok = super.performOk();
IPreferenceStore store = getPreferenceStore();
if (store instanceof IPersistentPreferenceStore) {
try {
((IPersistentPreferenceStore) store).save();
} catch (IOException e) {
MessageDialog.openError(getShell(), Messages.ActivityExplorerPreferencePage_1, e.getMessage());
return false;
}
}
return ok;
}
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
*/
@Override
public void createFieldEditors() {
FieldEditor viewpointsSelection = new BooleanFieldEditor(PreferenceConstants.P_OPEN_ACTIVITY_EXPLORER,
Messages.ActivityExplorerPreferencePage_2, getFieldEditorParent());
addField(viewpointsSelection);
}
/**
* Initialize the Store.
*/
public void init(IWorkbench workbench) {
setPreferenceStore(ActivityExplorerActivator.getDefault().getPreferenceStore());
}
}