com.clustercontrol.etc.action.ShowPreferenceAction.java Source code

Java tutorial

Introduction

Here is the source code for com.clustercontrol.etc.action.ShowPreferenceAction.java

Source

/*
    
Copyright (C) 2006 NTT DATA Corporation
    
This program is free software; you can redistribute it and/or
Modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 2.
    
This program 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 General Public License for more details.
    
 */

package com.clustercontrol.etc.action;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.eclipse.ui.handlers.HandlerUtil;

/**
 * ??<BR>
 * 
 * @version 5.0.0
 * @since 1.0.0
 */
public class ShowPreferenceAction extends AbstractHandler {

    private IWorkbenchWindow window;

    /**
     * Handler execution
     */
    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        this.window = HandlerUtil.getActiveWorkbenchWindow(event);
        // In case this action has been disposed
        if (null == this.window || !isEnabled()) {
            return null;
        }

        PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, null, null, null);
        dialog.open();

        return null;
    }

    /**
     * Dispose
     */
    @Override
    public void dispose() {
        this.window = null;
    }

}