Package com.palantir.ptoss.cinch.core

Examples of com.palantir.ptoss.cinch.core.BindingException


                        }
                    };
                    model.bind(binding);
                    bindings.add(binding);
                } else {
                    throw new BindingException("Can only log a BindableModel.");
                }
            }
            return bindings;
        }
View Full Code Here


                final String to = action.to();
                final boolean invert = (action.type() == Type.INVERTED);
                try {
                    bindings.addAll(wire(to, field, context, invert));
                } catch (final Exception e) {
                    throw new BindingException("could not wire up @VisibleIf on " + field.getName(), e);
                }
            }
            return bindings;
        }
View Full Code Here

        private static Collection<Binding> wire(final String to, final Field field, final BindingContext context, final boolean invert)
            throws SecurityException, NoSuchMethodException, IllegalArgumentException, IntrospectionException {
            final Method setVisibleMethod = field.getType().getMethod("setVisible", boolean.class);
            if (setVisibleMethod == null) {
                throw new BindingException("no setVisible call on VisibleIf field: " + field);
            }
            final Object setVisibleObject = context.getFieldObject(field, Object.class);
            final ObjectFieldMethod getter = context.findGetter(to);
            if (getter == null) {
                throw new BindingException("could not find bindable property: " + to);
            }
            if (getter.getMethod().getReturnType() != boolean.class) {
                throw new BindingException("VisibleIf binding must return boolean: " + to);
            }
            final Binding binding = new Binding() {
                public <T extends Enum<?> & ModelUpdate> void update(final T... changed) {
                    try {
                        getter.getMethod().setAccessible(true);
View Full Code Here

                Action action = field.getAnnotation(Action.class);
                String call = action.call();
                try {
                    wire(call, field, context);
                } catch (Exception e) {
                    throw new BindingException("could not wire up @Action on " +
                            field.getName(), e);
                }
            }
            return ImmutableList.of();
        }
View Full Code Here

                        IllegalAccessException, InvocationTargetException {
            Method aalMethod = field.getType().getMethod("addActionListener", ActionListener.class);
            Object actionObject = context.getFieldObject(field, Object.class);
            final ObjectFieldMethod ofm = context.getBindableMethod(call);
            if (ofm == null) {
                throw new BindingException("could not find bindable method: " + call);
            }
            ActionListener actionListener = new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    try {
                        boolean accessible = ofm.getMethod().isAccessible();
View Full Code Here

            for (Field field : actions) {
                OnChange change = field.getAnnotation(OnChange.class);
                try {
                    wire(change, field, context);
                } catch (Exception e) {
                    throw new BindingException("could not wire up @OnChange on " + field.getName(), e);
                }
            }
            return ImmutableList.of();
        }
View Full Code Here

        private static void wire(final OnChange change, Field field, BindingContext context)
            throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {

            String call = change.call();
            if (call == null) {
                throw new BindingException("call on @OnChange on " + field.getName() + " must be specified");
            }
            Method _adjustMethod = null;
            try {
                _adjustMethod = field.getType().getMethod("getValueIsAdjusting");
            } catch(NoSuchMethodException nsme) {
                // not a problem, leave value as null;
            }

            final Method adjustMethod = _adjustMethod;
            final Method addChangeMethod = field.getType().getMethod("addChangeListener", ChangeListener.class);
            if (addChangeMethod != null) {
                final Object changeObject = context.getFieldObject(field, Object.class);
                final ObjectFieldMethod ofm = context.getBindableMethod(call);
                if (ofm == null) {
                    throw new BindingException("could not find bindable method: " + call);
                }
                final ChangeListener changeListener = new ChangeListener() {
                    public void stateChanged(ChangeEvent e) {
                        try {
                            if (adjustMethod != null && !change.onAdjust()) {
View Full Code Here

                        throw Throwables.throwUncheckedException(e);
                    }
                }
            });
            if (!didBind.booleanValue()) {
                throw new BindingException("don't know how to wire up @Bound field: " + field.getName());
            }
            return bindings;
        }
View Full Code Here

                return ImmutableList.of(AbstractButtonWiringHarness.bindAbstractButton(mutator, toggle));
            } else {
                return ImmutableList.of(bindJToggleButtonToBoolean(bound.value(), mutator, toggle));
            }
        } else {
            throw new BindingException("can only bind JToggleButtons to enums or booleans"); //$NON-NLS-1$
        }
    }
View Full Code Here

            for (Field field : actions) {
                OnClick onClick = field.getAnnotation(OnClick.class);
                try {
                    wire(onClick, field, context);
                } catch (Exception e) {
                    throw new BindingException("could not wire up @OnClick on " + field.getName(), e);
                }
            }
            return ImmutableList.of();
        }
View Full Code Here

TOP

Related Classes of com.palantir.ptoss.cinch.core.BindingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.