Skip to content

Commit

Permalink
BZ-1064237 Add support for @ClassReactive and @PropertyReactive annot…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
wmedvede committed Feb 13, 2014
1 parent 42fd6b2 commit 4965afd
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 33 deletions.
Expand Up @@ -48,7 +48,11 @@ public class AnnotationDefinitionTO {
public static final String DESCRIPTION_ANNOTATION = "org.kie.api.definition.type.Description";

public static final String KEY_ANNOTATION = "org.kie.api.definition.type.Key";


public static final String PROPERTY_REACTIVE_ANNOTATION = "org.kie.api.definition.type.PropertyReactive";

public static final String CLASS_REACTIVE_ANNOTATION = "org.kie.api.definition.type.ClassReactive";

public static final String VALUE_PARAM = "value";

private List<AnnotationMemberDefinitionTO> annotationMembers = new ArrayList<AnnotationMemberDefinitionTO>();
Expand Down
Expand Up @@ -131,6 +131,14 @@ public interface Constants extends Messages {

public String objectEditor_roleHelp();

public String objectEditor_classReactiveLabel();

public String objectEditor_classReactiveLabelHelp();

public String objectEditor_propertyReactiveLabel();

public String objectEditor_propertyReactiveLabelHelp();

public String objectFieldEditor_nameLabel();

public String objectFieldEditor_labelLabel();
Expand All @@ -141,6 +149,8 @@ public interface Constants extends Messages {

public String objectFieldEditor_equalsLabel();

public String objectFieldEditor_equalsHelp();

public String objectFieldEditor_positionLabel();

public String objectFieldEditor_positionHelp();
Expand Down
Expand Up @@ -21,14 +21,12 @@
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.*;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
Expand Down Expand Up @@ -96,9 +94,21 @@ interface DataObjectDetailEditorUIBinder
@UiField
ListBox roleSelector;

@UiField
CheckBox classReactiveSelector;

@UiField
CheckBox propertyReactiveSelector;

@UiField
Icon roleHelpIcon;

@UiField
Icon classReactiveHelpIcon;

@UiField
Icon propertyReactiveHelpIcon;

@Inject
Event<DataModelerEvent> dataModelerEvent;

Expand All @@ -116,8 +126,12 @@ interface DataObjectDetailEditorUIBinder
public DataObjectEditor() {
initWidget( uiBinder.createAndBindUi( this ) );

roleHelpIcon.getElement().getStyle().setPaddingLeft( 4, Style.Unit.PX );
//roleHelpIcon.getElement().getStyle().setPaddingLeft( 4, Style.Unit.PX );
roleHelpIcon.getElement().getStyle().setCursor( Style.Cursor.POINTER );
//classReactiveHelpIcon.getElement().getStyle().setPaddingLeft( 4, Style.Unit.PX );
classReactiveHelpIcon.getElement().getStyle().setCursor( Style.Cursor.POINTER );
//propertyReactiveHelpIcon.getElement().getStyle().setPaddingLeft( 4, Style.Unit.PX );
propertyReactiveHelpIcon.getElement().getStyle().setCursor( Style.Cursor.POINTER );
}

@PostConstruct
Expand Down Expand Up @@ -183,7 +197,8 @@ private void setReadonly(boolean readonly) {
packageSelector.setEnabled( value );
superclassSelector.setEnabled( value );
roleSelector.setEnabled( value );
roleHelpIcon.setVisible( value );
propertyReactiveSelector.setEnabled( value );
classReactiveSelector.setEnabled( value );
}

private boolean isReadonly() {
Expand Down Expand Up @@ -218,6 +233,16 @@ private void loadDataObject( DataObjectTO dataObject ) {
roleSelector.setSelectedValue( value );
}

annotation = dataObject.getAnnotation( AnnotationDefinitionTO.PROPERTY_REACTIVE_ANNOTATION );
if ( annotation != null ) {
propertyReactiveSelector.setValue( Boolean.TRUE );
}

annotation = dataObject.getAnnotation( AnnotationDefinitionTO.CLASS_REACTIVE_ANNOTATION );
if ( annotation != null ) {
classReactiveSelector.setValue( Boolean.TRUE );
}

if ( ! dataObject.isExternallyModified() ) {
setReadonly( false );
}
Expand Down Expand Up @@ -485,6 +510,54 @@ void roleChanged( final ChangeEvent event ) {
notifyObjectChange( AnnotationDefinitionTO.ROLE_ANNOTATION, oldValue, _role );
}

@UiHandler("propertyReactiveSelector")
void propertyReactiveChanged(final ClickEvent event) {
if ( getDataObject() == null ) return;

Boolean oldValue = null;
AnnotationTO annotation = getDataObject().getAnnotation(AnnotationDefinitionTO.PROPERTY_REACTIVE_ANNOTATION);
oldValue = annotation != null;

final Boolean isChecked = propertyReactiveSelector.getValue();

if ( annotation != null && !isChecked ) {
getDataObject().removeAnnotation( annotation );
} else if ( annotation == null && isChecked ) {
getDataObject().addAnnotation( new AnnotationTO( getContext().getAnnotationDefinitions().get( AnnotationDefinitionTO.PROPERTY_REACTIVE_ANNOTATION ) ) );
}

if ( isChecked ) {
getDataObject().removeAnnotation( new AnnotationTO( getContext().getAnnotationDefinitions().get( AnnotationDefinitionTO.CLASS_REACTIVE_ANNOTATION ) ) );
classReactiveSelector.setValue( false );
}
//TODO check if this event is needed and add validation, this annotation cannot coexist with the ClassReactiveAnnotation
notifyObjectChange( AnnotationDefinitionTO.PROPERTY_REACTIVE_ANNOTATION, oldValue, isChecked );
}

@UiHandler("classReactiveSelector")
void classReactiveChanged(final ClickEvent event) {
if ( getDataObject() == null ) return;

Boolean oldValue = null;
AnnotationTO annotation = getDataObject().getAnnotation( AnnotationDefinitionTO.CLASS_REACTIVE_ANNOTATION );
oldValue = annotation != null;

final Boolean isChecked = classReactiveSelector.getValue();

if ( annotation != null && !isChecked ) {
getDataObject().removeAnnotation( annotation );
} else if ( annotation == null && isChecked ) {
getDataObject().addAnnotation( new AnnotationTO( getContext().getAnnotationDefinitions().get( AnnotationDefinitionTO.CLASS_REACTIVE_ANNOTATION ) ) );
}

if ( isChecked ) {
getDataObject().removeAnnotation( new AnnotationTO( getContext().getAnnotationDefinitions().get( AnnotationDefinitionTO.PROPERTY_REACTIVE_ANNOTATION ) ) );
propertyReactiveSelector.setValue( false );
}
//TODO check if this event is needed and add validation, this annotation cannot coexist with the PropertyReactiveAnnotation
notifyObjectChange( AnnotationDefinitionTO.CLASS_REACTIVE_ANNOTATION, oldValue, isChecked );
}

private void clean() {
nameLabel.setStyleName(DEFAULT_LABEL_CLASS);
name.setText( null );
Expand All @@ -495,5 +568,7 @@ private void clean() {
// TODO superclassLabel when its validation is put in place
superclassSelector.setDataObject( null );
roleSelector.setSelectedValue( NOT_SELECTED );
classReactiveSelector.setValue( false );
propertyReactiveSelector.setValue( false );
}
}
Expand Up @@ -29,8 +29,8 @@

<style>
.propertiesTable2 {
min-height: 310px !Important;
min-width: 285px !Important;
min-height: 320px !Important;
min-width: 300px !Important;
overflow: hidden;
}

Expand All @@ -51,15 +51,17 @@
<table class="row-fluid span12" style="padding: 4px;">

<tr>
<td style="white-space: nowrap; vertical-align: top;">
<td style="white-space: nowrap; vertical-align: top; min-width:110px;">
<gwt:Label ui:field="nameLabel" text="{i18n.objectEditor_nameLabel}"/>
</td>
<td style="padding-left: 4px;">
<b:TextBox ui:field="name" styleName="span10"></b:TextBox>
</td>
<td style="padding-left: 4px;">
</td>
</tr>
<tr>
<td colspan="2" style="padding: 3px;"></td>
<td colspan="3" style="padding: 3px;"></td>
</tr>
<tr>
<td style="white-space: nowrap; vertical-align: top;">
Expand All @@ -68,9 +70,11 @@
<td style="padding-left: 4px;">
<b:TextBox ui:field="label" styleName="span10"></b:TextBox>
</td>
<td style="padding-left: 4px;">
</td>
</tr>
<tr>
<td colspan="2" style="padding: 3px;"></td>
<td colspan="3" style="padding: 3px;"></td>
</tr>
<tr>
<td style="white-space: nowrap; vertical-align: top;">
Expand All @@ -79,9 +83,11 @@
<td style="padding-left: 4px;">
<b:TextArea ui:field="description" styleName="span10"></b:TextArea>
</td>
<td style="padding-left: 4px;">
</td>
</tr>
<tr>
<td colspan="2" style="padding: 3px;"></td>
<td colspan="3" style="padding: 3px;"></td>
</tr>
<tr>
<td style="white-space: nowrap; vertical-align: top;">
Expand All @@ -92,9 +98,11 @@

</gwt:SimplePanel>
</td>
<td style="padding-left: 4px;">
</td>
</tr>
<tr>
<td colspan="2" style="padding: 3px;"></td>
<td colspan="3" style="padding: 3px;"></td>
</tr>
<tr>
<td style="white-space: nowrap; vertical-align: top;">
Expand All @@ -103,21 +111,57 @@
<td style="padding-left: 4px;">
<datamodeler:SuperclassSelector ui:field="superclassSelector" styleName="span10"></datamodeler:SuperclassSelector>
</td>
<td style="padding-left: 4px;">
</td>
</tr>
<tr>
<td colspan="2" style="padding: 3px;"></td>
<td colspan="3" style="padding: 3px;"></td>
</tr>
<tr>
<td style="white-space: nowrap; vertical-align: top;">
<gwt:Label ui:field="roleLabel" text="{i18n.objectEditor_roleLabel}"/>
</td>
<td style="padding-left: 4px;">
<b:ListBox ui:field="roleSelector" styleName="span10"></b:ListBox>
<b:Popover placement="LEFT" trigger="HOVER" heading="{i18n.objectEditor_roleLabel}" text="{i18n.objectEditor_roleHelp}">
</td>
<td style="padding-left: 4px;">
<b:Popover placement="LEFT" trigger="HOVER" heading="{i18n.objectEditor_roleLabel}" text="{i18n.objectEditor_roleHelp}" >
<b:Icon ui:field="roleHelpIcon" type="QUESTION_SIGN"></b:Icon>
</b:Popover>
</td>
</tr>
<tr>
<td colspan="3" style="padding: 3px;"></td>
</tr>
<tr>
<td style="white-space: nowrap; vertical-align: top;">
<gwt:Label ui:field="classReactiveLabel" text="{i18n.objectEditor_classReactiveLabel}" />
</td>
<td style="padding-left: 4px;">
<b:CheckBox ui:field="classReactiveSelector"></b:CheckBox>
</td>
<td style="padding-left: 4px;">
<b:Popover placement="LEFT" trigger="HOVER" heading="{i18n.objectEditor_classReactiveLabel}" text="{i18n.objectEditor_classReactiveLabelHelp}">
<b:Icon ui:field="classReactiveHelpIcon" type="QUESTION_SIGN"></b:Icon>
</b:Popover>
</td>
</tr>
<tr>
<td colspan="3" style="padding: 3px;"></td>
</tr>
<tr>
<td style="white-space: nowrap; vertical-align: top;">
<gwt:Label ui:field="propertyReactiveLabel" text="{i18n.objectEditor_propertyReactiveLabel}"/>
</td>
<td style="padding-left: 4px;">
<b:CheckBox ui:field="propertyReactiveSelector"></b:CheckBox>
</td>
<td style="padding-left: 4px;">
<b:Popover placement="LEFT" trigger="HOVER" heading="{i18n.objectEditor_propertyReactiveLabel}" text="{i18n.objectEditor_propertyReactiveLabelHelp}">
<b:Icon ui:field="propertyReactiveHelpIcon" type="QUESTION_SIGN"></b:Icon>
</b:Popover>
</td>
</tr>

</table>

Expand Down
Expand Up @@ -95,6 +95,9 @@ interface DataObjectFieldEditorUIBinder
@UiField
CheckBox equalsSelector;

@UiField
Icon equalsHelpIcon;

@UiField
Label positionLabel;

Expand Down Expand Up @@ -136,8 +139,10 @@ public void onChange(ChangeEvent event) {
}
});

positionHelpIcon.getElement().getStyle().setPaddingLeft(4, Style.Unit.PX);
//positionHelpIcon.getElement().getStyle().setPaddingLeft(4, Style.Unit.PX);
positionHelpIcon.getElement().getStyle().setCursor(Style.Cursor.POINTER);
//equalsHelpIcon.getElement().getStyle().setPaddingLeft(4, Style.Unit.PX);
equalsHelpIcon.getElement().getStyle().setCursor(Style.Cursor.POINTER);

setReadonly(true);
}
Expand Down Expand Up @@ -180,7 +185,6 @@ private void setReadonly(boolean readonly) {
description.setEnabled(value);
typeSelector.setEnabled(value);
equalsSelector.setEnabled(value);
positionHelpIcon.setVisible(value);
positionSelector.setEnabled(value);
}

Expand Down

0 comments on commit 4965afd

Please sign in to comment.