at.spardat.xma.guidesign.presentation.preferences.EditorPreferencePage.java Source code

Java tutorial

Introduction

Here is the source code for at.spardat.xma.guidesign.presentation.preferences.EditorPreferencePage.java

Source

/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * 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:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

/*
 * Created on 26.08.2003
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
package at.spardat.xma.guidesign.presentation.preferences;

import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

/**
 * @author S2267
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
public class EditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {

    private RadioGroupFieldEditor layoutGroup;

    /**
     *
     */
    public EditorPreferencePage() {
        super();
    }

    /* (non-Javadoc)
     * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
     */
    protected Control createContents(Composite parent) {
        Composite top = new Composite(parent, SWT.LEFT);

        // Sets the layout data for the top composite's
        // place in its parent's layout.
        top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        // Sets the layout for the top composite's
        // children to populate.
        top.setLayout(new GridLayout());

        layoutGroup = new RadioGroupFieldEditor(IPreferenceConstants.EDITOR_PREFERENCE, "Layout settings", 1,
                new String[][] { { "&One Column", IPreferenceConstants.ONE_COLUMN },
                        { "T&wo Column", IPreferenceConstants.TWO_COLUMN },
                        { "&No Layout", IPreferenceConstants.NO_LAYOUT } },
                top, true);
        layoutGroup.setPreferencePage(this);
        layoutGroup.load();

        return top;
    }

    /* (non-Javadoc)
     * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
     */
    public void init(IWorkbench workbench) {
        // TODO Prio 4: Editor Preferences init siehe emf s. 238
    }

    /* (non-Javadoc)
     * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
     */
    protected void performDefaults() {
        layoutGroup.loadDefault();
        super.performDefaults();
    }

    /* (non-Javadoc)
     * @see org.eclipse.jface.preference.IPreferencePage#performOk()
     */
    public boolean performOk() {
        layoutGroup.store();
        return super.performOk();
    }

}