Skip to content
Permalink
Browse files
Updated interface to try and use more generic bind/unbind mechanism.
  • Loading branch information
mrg committed Jun 3, 2017
1 parent 74696f3 commit 4861004e86f324963e73346da761cd5bdf9b982f
Showing 1 changed file with 38 additions and 2 deletions.
@@ -19,11 +19,47 @@

package org.apache.cayenne.modeler.layout;

import java.util.ArrayList;
import java.util.List;

import org.apache.cayenne.modeler.adapters.CayennePropertyAdapter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public interface DetailEditorSupport<T extends CayennePropertyAdapter>
{
static final Log LOGGER = LogFactory.getLog(DetailEditorSupport.class);

default void showLayout(final T propertyAdapter)
{
setPropertyAdapter(propertyAdapter);
initializeBindings();
beginEditing();
}

default void initializeBindings()
{
// Implementors should override.
}

default List<Binding<?>> getBindings()
{
return new ArrayList<>();
}

void setPropertyAdapter(final T propertyAdapter);
void beginEditing();
void endEditing();

default void beginEditing()
{
LOGGER.debug("begin editing " + this);

getBindings().stream().forEach(binding -> binding.bind());
}

default void endEditing()
{
LOGGER.debug("end editing " + this);

getBindings().stream().forEach(binding -> binding.unbind());
}
}

0 comments on commit 4861004

Please sign in to comment.