Search in sources :

Example 1 with RequirementEditingWizard

use of org.obeonetwork.tools.requirement.wizard.RequirementEditingWizard in project InformationSystem by ObeoNetwork.

the class RequirementCreationOperation method doExecute.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.workspace.AbstractEMFOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor,
 *      org.eclipse.core.runtime.IAdaptable)
 */
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    ((RequirementCreationPropertiesEditingContext) this.editingContext).preProcess();
    RequirementEditingWizard wizard = new RequirementEditingWizard(editingContext, editingContext.getAdapterFactory(), editingContext.getEObject());
    WizardDialog wDialog = new WizardDialog(EditingUtils.getShell(), wizard) {

        /**
         * {@inheritDoc}
         *
         * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
         */
        @Override
        protected Point getInitialSize() {
            Point initialSize = super.getInitialSize();
            return new Point(Math.min(UIConstants.INITIAL_WIZARD_SIZE.x, initialSize.x), Math.min(UIConstants.INITIAL_WIZARD_SIZE.y, initialSize.y));
        }
    };
    int open = wDialog.open();
    ChangeDescription description = editingContext.getChangeRecorder().endRecording();
    if (open == Window.OK) {
        Requirement requirement = (Requirement) editingContext.getEObject();
        requirement.eResource().getContents().remove(requirement);
        wizard.getOwningCategory().getRequirements().add(requirement);
        return Status.OK_STATUS;
    } else {
        description.applyAndReverse();
        return Status.CANCEL_STATUS;
    }
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) RequirementCreationPropertiesEditingContext(org.obeonetwork.tools.requirement.wizard.util.RequirementCreationPropertiesEditingContext) ChangeDescription(org.eclipse.emf.ecore.change.ChangeDescription) RequirementEditingWizard(org.obeonetwork.tools.requirement.wizard.RequirementEditingWizard) Point(org.eclipse.swt.graphics.Point) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Point(org.eclipse.swt.graphics.Point)

Example 2 with RequirementEditingWizard

use of org.obeonetwork.tools.requirement.wizard.RequirementEditingWizard in project InformationSystem by ObeoNetwork.

the class RequirementEditingOperation method doExecute.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.impl.operation.WizardEditingOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor,
 *      org.eclipse.core.runtime.IAdaptable)
 */
@Override
protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    editingContext.initializeRecorder();
    RequirementEditingWizard wizard = new RequirementEditingWizard(editingContext, editingContext.getAdapterFactory(), editingContext.getEObject());
    EEFWizardDialog wDialog = new EEFWizardDialog(EditingUtils.getShell(), wizard);
    int open = wDialog.open();
    ChangeDescription description = editingContext.getChangeRecorder().endRecording();
    if (open == Window.OK) {
        if (wizard.getOwningCategory() != null) {
            Category category = wizard.getOwningCategory();
            if (editingContext.getEObject().eContainer() != category) {
                category.getRequirements().add((Requirement) editingContext.getEObject());
            }
        }
        return Status.OK_STATUS;
    } else {
        description.applyAndReverse();
        return Status.CANCEL_STATUS;
    }
}
Also used : Category(org.obeonetwork.dsl.requirement.Category) EEFWizardDialog(org.eclipse.emf.eef.runtime.ui.wizards.EEFWizardDialog) ChangeDescription(org.eclipse.emf.ecore.change.ChangeDescription) RequirementEditingWizard(org.obeonetwork.tools.requirement.wizard.RequirementEditingWizard)

Aggregations

ChangeDescription (org.eclipse.emf.ecore.change.ChangeDescription)2 RequirementEditingWizard (org.obeonetwork.tools.requirement.wizard.RequirementEditingWizard)2 EEFWizardDialog (org.eclipse.emf.eef.runtime.ui.wizards.EEFWizardDialog)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Point (org.eclipse.swt.graphics.Point)1 Category (org.obeonetwork.dsl.requirement.Category)1 Requirement (org.obeonetwork.dsl.requirement.Requirement)1 RequirementCreationPropertiesEditingContext (org.obeonetwork.tools.requirement.wizard.util.RequirementCreationPropertiesEditingContext)1