Search in sources :

Example 1 with EnvironmentFigure

use of org.whole.lang.environment.ui.figures.EnvironmentFigure in project whole by wholeplatform.

the class EnvironmentPart method createFigure.

protected IFigure createFigure() {
    Environment entity = getModelEntity();
    return new EnvironmentFigure(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            Environment entity = getModelEntity();
            ModelTransactionCommand command = new ModelTransactionCommand(entity);
            try {
                command.begin();
                IBindingManager bm = entity.getBindingManager().getValue();
                if (Matcher.match(EnvironmentEntityDescriptorEnum.Bindings, entity.getBindings()))
                    entity.setBindings((BindingsModel) BindingManagerFactory.instance.createFlatScopedBindingsModel(bm));
                else
                    entity.setBindings((BindingsModel) BindingManagerFactory.instance.createFlatBindingsModel(bm));
                command.commit();
                getViewer().getEditDomain().getCommandStack().execute(command);
            } catch (Exception e) {
                command.rollbackIfNeeded();
            }
        }
    }, Matcher.matchImpl(EnvironmentEntityDescriptorEnum.ScopedBindings, entity.getBindings()));
}
Also used : ModelTransactionCommand(org.whole.lang.ui.commands.ModelTransactionCommand) ActionListener(org.eclipse.draw2d.ActionListener) ActionEvent(org.eclipse.draw2d.ActionEvent) IBindingManager(org.whole.lang.bindings.IBindingManager) Environment(org.whole.lang.environment.model.Environment) EnvironmentFigure(org.whole.lang.environment.ui.figures.EnvironmentFigure)

Aggregations

ActionEvent (org.eclipse.draw2d.ActionEvent)1 ActionListener (org.eclipse.draw2d.ActionListener)1 IBindingManager (org.whole.lang.bindings.IBindingManager)1 Environment (org.whole.lang.environment.model.Environment)1 EnvironmentFigure (org.whole.lang.environment.ui.figures.EnvironmentFigure)1 ModelTransactionCommand (org.whole.lang.ui.commands.ModelTransactionCommand)1