uk.ac.diamond.scisoft.analysis.rcp.preference.DiffractionViewerPreferencesHandler.java Source code

Java tutorial

Introduction

Here is the source code for uk.ac.diamond.scisoft.analysis.rcp.preference.DiffractionViewerPreferencesHandler.java

Source

/*
 * Copyright (c) 2012 Diamond Light Source Ltd.
 *
 * 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
 */

package uk.ac.diamond.scisoft.analysis.rcp.preference;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;

public class DiffractionViewerPreferencesHandler extends AbstractHandler implements IHandler {

    private static final String DIFFRACTION_PAGE_ID = "uk.ac.diamond.scisoft.analysis.rcp.diffractionViewerPreferencePage";

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DIFFRACTION_PAGE_ID, null, null);
        if (pref != null)
            pref.open();
        return Boolean.TRUE;
    }
}