at.spardat.xma.guidesign.presentation.dialog.compprops.CompPropertyDialog.java Source code

Java tutorial

Introduction

Here is the source code for at.spardat.xma.guidesign.presentation.dialog.compprops.CompPropertyDialog.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
 *******************************************************************************/

/*
 * @(#)
 *
 *
 *
 *
 *
 */
package at.spardat.xma.guidesign.presentation.dialog.compprops;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;

import at.spardat.xma.guidesign.XMAComponent;
import at.spardat.xma.guidesign.presentation.GuidesignEditor;
import at.spardat.xma.guidesign.presentation.dialog.XMADialog;

/**
 *
 *
 * @author s1462
 * @since guidesign.editor
 */
public class CompPropertyDialog extends XMADialog {

    /**
     * remember the composite that holds the widgets
     */
    private CompPropertyDialogComposite propertyComp;

    /**
     * @param shell
     * @param _object
     * @param _feature
     * @param _name
     * @param _editor
     */
    public CompPropertyDialog(Shell shell, EObject _object, EReference _feature, String _name,
            GuidesignEditor _editor) {
        super(shell, _object, _feature, _name, _editor);
    }

    /**
     * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
     */
    protected void configureShell(Shell shell) {
        super.configureShell(shell, 0, 0);
        shell.setText(getText("_UI_CompPropertyDialog_title"));
        shell.setImage(lblProvider.getImage(object));
    }

    /* (non-Javadoc)
     * @see at.spardat.xma.guidesign.presentation.dialog.XMADialog#isDialogComplete()
     */
    protected boolean isDialogComplete() {
        if (propertyComp.isCompositeComplete()) {
            return true;
        }
        return false;
    }

    /* (non-Javadoc)
     * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
     */
    protected Control createDialogArea(Composite parent) {
        super.createDialogArea(parent);
        propertyComp = new CompPropertyDialogComposite();
        //the editing commands are executed in the composite
        propertyComp.setEditor(editor);
        propertyComp.setFeature(feature);
        propertyComp.createComposite(content);
        propertyComp.addListener(this);
        initControls();
        return content;
    }

    /**
     *
     */
    private void initControls() {
        propertyComp.setControls((XMAComponent) object);
        setTitle(getText("_UI_CompPropertyDialog_title"));
        setMessage(getText("_UI_CompPropertyDialog_description"));
    }

    /* (non-Javadoc)
     * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
     */
    protected void createButtonsForButtonBar(Composite parent) {
        // create OK and Cancel buttons by default
        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
    }
}