org2.eclipse.php.internal.debug.ui.preferences.phps.ShowPHPsPreferences.java Source code

Java tutorial

Introduction

Here is the source code for org2.eclipse.php.internal.debug.ui.preferences.phps.ShowPHPsPreferences.java

Source

/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * 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:
 *   Zend and IBM - Initial implementation
 *******************************************************************************/
package org2.eclipse.php.internal.debug.ui.preferences.phps;

import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.preference.IPreferenceNode;
import org.eclipse.jface.preference.IPreferencePage;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.preference.PreferenceNode;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.ui.IMarkerResolution;
import org2.eclipse.php.internal.debug.ui.PHPDebugUIMessages;

import com.aptana.php.debug.epl.PHPDebugEPLPlugin;

/**
 * Quick fix to define a new system library (none were found). 
 */
public class ShowPHPsPreferences implements IMarkerResolution {

    public ShowPHPsPreferences() {
        super();
    }

    /**
     * @see org.eclipse.ui.IMarkerResolution#run(org.eclipse.core.resources.IMarker)
     */
    public void run(IMarker marker) {
        IPreferencePage page = new PHPsPreferencePage();
        showPreferencePage(PHPsPreferencePage.ID, page);
    }

    /**
     * @see org.eclipse.ui.IMarkerResolution#getLabel()
     */
    public String getLabel() {
        return PHPDebugUIMessages.ShowPHPsPreferencePageTitle;
    }

    protected void showPreferencePage(String id, IPreferencePage page) {
        final IPreferenceNode targetNode = new PreferenceNode(id, page);

        PreferenceManager manager = new PreferenceManager();
        manager.addToRoot(targetNode);
        final PreferenceDialog dialog = new PreferenceDialog(PHPDebugEPLPlugin.getActiveWorkbenchShell(), manager);
        final boolean[] result = new boolean[] { false };
        BusyIndicator.showWhile(PHPDebugEPLPlugin.getStandardDisplay(), new Runnable() {
            public void run() {
                dialog.create();
                dialog.setMessage(targetNode.getLabelText());
                result[0] = (dialog.open() == Window.OK);
            }
        });
    }
}