Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 JBoss Inc
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   * use this file except in compliance with the License. You may obtain a copy of
   * the License at
   * 
   * http://www.apache.org/licenses/LICENSE-2.0
   * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  * License for the specific language governing permissions and limitations under
  * the License.
  */
 package org.drools.workbench.screens.guided.dtable.client.widget.auditlog;
 
 
 import java.util.Date;

Render different HTML for different AuditLogEvents
 
 @SuppressWarnings("unused")
 public class AuditLogEntryCellHelper {
 
     interface Template
             extends
             SafeHtmlTemplates {
 
         @Template("<div>{0}</div>")
         SafeHtml commentHeaderString header );
 
         @Template("<div>{0}</div><table><tr><td><div class=\"auditLogDetailLabel\">{1}</div></td><td><div class=\"auditLogDetailValue\">{2}</div></td></tr><tr><td><div class=\"auditLogDetailLabel\">{3}</div></td><td><div class=\"auditLogDetailValue\">{4}</div></td></tr></table>")
         SafeHtml commentHeader2DetailsString header,
                                         String row1Label,
                                         String row1Value,
                                         String row2Label,
                                         String row2Value );
 
         @Template("<div>{0}</div><table><tr><td><div class=\"auditLogDetailLabel\">{1}</div></td><td><div class=\"auditLogDetailValue\">{2}</div></td></tr><tr><td><div class=\"auditLogDetailLabel\">{3}</div></td><td><div class=\"auditLogDetailValue\">{4}</div></td></tr><tr><td><div class=\"auditLogDetailLabel\">{5}</div></td><td><div class=\"auditLogDetailValue\">{6}</div></td></tr></table>")
         SafeHtml commentHeader3DetailsString header,
                                         String row1Label,
                                         String row1Value,
                                         String row2Label,
                                         String row2Value,
                                         String row3Label,
                                         String row3Value );
 
     }
 
     private static final Template TEMPLATE = GWT.createTemplate.class );
 
     private final DateTimeFormat format;
 
     public AuditLogEntryCellHelperfinal DateTimeFormat format ) {
         this. = format;
     }

    
Lookup display text for each AuditLogEntry type

Parameters:
eventType
Returns:
 
     public static String getEventTypeDisplayTextfinal String eventType ) {
         if ( eventType.equals..name() ) ) {
         } else if ( eventType.equals..name() ) ) {
         } else if ( eventType.equals..name() ) ) {
         } else if ( eventType.equals..name() ) ) {
         } else if ( eventType.equals..name() ) ) {
        }
        throw new IllegalArgumentException"Unrecognised AuditLogEntry type." );
    }
    public SafeHtml getSafeHtmlfinal AuditLogEntry event ) {
        if ( event instanceof UpdateColumnAuditLogEntry ) {
            return getSafeHtml( (UpdateColumnAuditLogEntryevent );
        } else if ( event instanceof InsertColumnAuditLogEntry ) {
            return getSafeHtml( (InsertColumnAuditLogEntryevent );
        } else if ( event instanceof DeleteColumnAuditLogEntry ) {
            return getSafeHtml( (DeleteColumnAuditLogEntryevent );
        } else if ( event instanceof InsertRowAuditLogEntry ) {
            return getSafeHtml( (InsertRowAuditLogEntryevent );
        } else if ( event instanceof DeleteRowAuditLogEntry ) {
            return getSafeHtml( (DeleteRowAuditLogEntryevent );
        }
        throw new IllegalArgumentException"Unrecognised AuditLogEntry type." );
    }
    private SafeHtml getSafeHtmlfinal InsertRowAuditLogEntry event ) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        return sb.toSafeHtml();
    }
    private SafeHtml getSafeHtmlfinal DeleteRowAuditLogEntry event ) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        return sb.toSafeHtml();
    }
    private SafeHtml getSafeHtmlfinal InsertColumnAuditLogEntry event ) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        buildColumnDetailsInsertevent.getDetails(),
                                  sb );
        return sb.toSafeHtml();
    }
    private SafeHtml getSafeHtmlfinal UpdateColumnAuditLogEntry event ) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        buildColumnDetailsUpdateevent.getDetails(),
                                  event.getOriginalDetails(),
                                  sb );
        return sb.toSafeHtml();
    }
    private SafeHtml getSafeHtmlfinal DeleteColumnAuditLogEntry event ) {
        SafeHtmlBuilder sb = new SafeHtmlBuilder();
        return sb.toSafeHtml();
    }
    private void buildColumnDetailsInsertfinal ColumnDetails details,
                                           final SafeHtmlBuilder sb ) {
        if ( details instanceof AttributeColumnDetails ) {
            buildColumnDetailsInsert( (AttributeColumnDetailsdetails,
                                      sb );
        } else if ( details instanceof MetadataColumnDetails ) {
            buildColumnDetailsInsert( (MetadataColumnDetailsdetails,
                                      sb );
        } else if ( details instanceof ConditionColumnDetails ) {
            buildColumnDetailsInsert( (ConditionColumnDetailsdetails,
                                      sb );
        } else if ( details instanceof LimitedEntryConditionColumnDetails ) {
                                      sb );
        } else if ( details instanceof ActionInsertFactColumnDetails ) {
            buildColumnDetailsInsert( (ActionInsertFactColumnDetailsdetails,
                                      sb );
        } else if ( details instanceof LimitedEntryActionInsertFactColumnDetails ) {
                                      sb );
        } else if ( details instanceof ActionSetFieldColumnDetails ) {
            buildColumnDetailsInsert( (ActionSetFieldColumnDetailsdetails,
                                      sb );
        } else if ( details instanceof LimitedEntryActionSetFieldColumnDetails ) {
                                      sb );
        } else {
        }
    }
    private void buildColumnDetailsInsertfinal AttributeColumnDetails details,
                                           final SafeHtmlBuilder sb ) {
    }
    private void buildColumnDetailsInsertfinal MetadataColumnDetails details,
                                           final SafeHtmlBuilder sb ) {
    }
    private void buildColumnDetailsInsertfinal ConditionColumnDetails details,
                                           final SafeHtmlBuilder sb ) {
                                                   ..FieldColon(),
                                                   nildetails.getFactField() ),
                                                   ..OperatorColon(),
                                                   nildetails.getOperator() ) ) );
    }
    private void buildColumnDetailsInsertfinal LimitedEntryConditionColumnDetails details,
                                           final SafeHtmlBuilder sb ) {
                                                   ..FieldColon(),
                                                   nildetails.getFactField() ),
                                                   ..OperatorColon(),
                                                   nildetails.getOperator() ),
                                                   ..ValueColon(),
                                                   nilLimitedEntryValuedetails.getValue() ) ) );
    }
    private void buildColumnDetailsInsertfinal ActionInsertFactColumnDetails details,
                                           final SafeHtmlBuilder sb ) {
                                                   ..FactTypeColon(),
                                                   nildetails.getFactType() ),
                                                   ..FieldColon(),
                                                   nildetails.getFactField() ) ) );
    }
                                           final SafeHtmlBuilder sb ) {
                                                   ..FactTypeColon(),
                                                   nildetails.getFactType() ),
                                                   ..FieldColon(),
                                                   nildetails.getFactField() ),
                                                   ..ValueColon(),
                                                   nilLimitedEntryValuedetails.getValue() ) ) );
    }
    private void buildColumnDetailsInsertfinal ActionSetFieldColumnDetails details,
                                           final SafeHtmlBuilder sb ) {
                                                   ..BoundVariableColon(),
                                                   nildetails.getBoundName() ),
                                                   ..FieldColon(),
                                                   nildetails.getFactField() ) ) );
    }
                                           final SafeHtmlBuilder sb ) {
                                                   ..BoundVariableColon(),
                                                   nildetails.getBoundName() ),
                                                   ..FieldColon(),
                                                   nildetails.getFactField() ),
                                                   ..ValueColon(),
                                                   nilLimitedEntryValuedetails.getValue() ) ) );
    }
    private void buildColumnDetailsUpdatefinal ColumnDetails details,
                                           final ColumnDetails originalDetails,
                                           final SafeHtmlBuilder sb ) {
        if ( ( details instanceof ConditionColumnDetails ) && ( originalDetails instanceof ConditionColumnDetails ) ) {
            buildColumnDetailsUpdate( (ConditionColumnDetailsdetails,
                                      (ConditionColumnDetailsoriginalDetails,
                                      sb );
        } else if ( ( details instanceof LimitedEntryConditionColumnDetails ) && ( originalDetails instanceof LimitedEntryConditionColumnDetails ) ) {
                                      (LimitedEntryConditionColumnDetailsoriginalDetails,
                                      sb );
        } else if ( ( details instanceof ActionInsertFactColumnDetails ) && ( originalDetails instanceof ActionInsertFactColumnDetails ) ) {
            buildColumnDetailsUpdate( (ActionInsertFactColumnDetailsdetails,
                                      (ActionInsertFactColumnDetailsoriginalDetails,
                                      sb );
        } else if ( ( details instanceof LimitedEntryActionInsertFactColumnDetails ) && ( originalDetails instanceof LimitedEntryActionInsertFactColumnDetails ) ) {
                                      (LimitedEntryActionInsertFactColumnDetailsoriginalDetails,
                                      sb );
        } else if ( ( details instanceof ActionSetFieldColumnDetails ) && ( originalDetails instanceof ActionSetFieldColumnDetails ) ) {
            buildColumnDetailsUpdate( (ActionSetFieldColumnDetailsdetails,
                                      (ActionSetFieldColumnDetailsoriginalDetails,
                                      sb );
        } else if ( ( details instanceof LimitedEntryActionSetFieldColumnDetails ) && ( originalDetails instanceof LimitedEntryActionSetFieldColumnDetails ) ) {
                                      (LimitedEntryActionSetFieldColumnDetailsoriginalDetails,
                                      sb );
        } else {
                                                                                                          originalDetails.getColumnHeader() ) ) );
        }
    }
    private void buildColumnDetailsUpdatefinal ConditionColumnDetails details,
                                           final ConditionColumnDetails originalDetails,
                                           final SafeHtmlBuilder sb ) {
                                                                                                                 originalDetails.getColumnHeader() ),
                                                   ..FieldColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactField() ),
                                                                                                  niloriginalDetails.getFactField() ) ),
                                                   ..OperatorColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getOperator() ),
                                                                                                  niloriginalDetails.getOperator() ) ) ) );
    }
    private void buildColumnDetailsUpdatefinal LimitedEntryConditionColumnDetails details,
                                           final LimitedEntryConditionColumnDetails originalDetails,
                                           final SafeHtmlBuilder sb ) {
                                                                                                                 originalDetails.getColumnHeader() ),
                                                   ..FieldColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactField() ),
                                                                                                  niloriginalDetails.getFactField() ) ),
                                                   ..OperatorColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getOperator() ),
                                                                                                  niloriginalDetails.getOperator() ) ),
                                                   ..ValueColon(),
                                                   ..DecisionTableAuditLog0Was1nilLimitedEntryValuedetails.getValue() ),
                                                                                                  nilLimitedEntryValueoriginalDetails.getValue() ) ) ) );
    }
    private void buildColumnDetailsUpdatefinal ActionInsertFactColumnDetails details,
                                           final ActionInsertFactColumnDetails originalDetails,
                                           final SafeHtmlBuilder sb ) {
                                                                                                              originalDetails.getColumnHeader() ),
                                                   ..FactTypeColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactType() ),
                                                                                                  niloriginalDetails.getFactType() ) ),
                                                   ..FieldColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactField() ),
                                                                                                  niloriginalDetails.getFactField() ) ) ) );
    }
                                           final LimitedEntryActionInsertFactColumnDetails originalDetails,
                                           final SafeHtmlBuilder sb ) {
                                                                                                              originalDetails.getColumnHeader() ),
                                                   ..FactTypeColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactType() ),
                                                                                                  niloriginalDetails.getFactType() ) ),
                                                   ..FieldColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactField() ),
                                                                                                  niloriginalDetails.getFactField() ) ),
                                                   ..ValueColon(),
                                                   ..DecisionTableAuditLog0Was1nilLimitedEntryValuedetails.getValue() ),
                                                                                                  nilLimitedEntryValueoriginalDetails.getValue() ) ) ) );
    }
    private void buildColumnDetailsUpdatefinal ActionSetFieldColumnDetails details,
                                           final ActionSetFieldColumnDetails originalDetails,
                                           final SafeHtmlBuilder sb ) {
                                                                                                              originalDetails.getColumnHeader() ),
                                                   ..BoundVariableColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getBoundName() ),
                                                                                                  niloriginalDetails.getBoundName() ) ),
                                                   ..FieldColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactField() ),
                                                                                                  niloriginalDetails.getFactField() ) ) ) );
    }
                                           final LimitedEntryActionSetFieldColumnDetails originalDetails,
                                           final SafeHtmlBuilder sb ) {
                                                                                                              originalDetails.getColumnHeader() ),
                                                   ..BoundVariableColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getBoundName() ),
                                                                                                  niloriginalDetails.getBoundName() ) ),
                                                   ..FieldColon(),
                                                   ..DecisionTableAuditLog0Was1nildetails.getFactField() ),
                                                                                                  niloriginalDetails.getFactField() ) ),
                                                   ..ValueColon(),
                                                   ..DecisionTableAuditLog0Was1nilLimitedEntryValuedetails.getValue() ),
                                                                                                  nilLimitedEntryValueoriginalDetails.getValue() ) ) ) );
    }
    private String nilfinal String value ) {
        return value == null ? "" : value;
    }
    private String nilLimitedEntryValuefinal DTCellValue52 value ) {
        String displayText = convertDTCellValueToStringvalue );
        return displayText == null ? "" : displayText;
    }
    private String convertDTCellValueToStringfinal DTCellValue52 dcv ) {
        switch ( dcv.getDataType() ) {
            case :
                Boolean booleanValue = dcv.getBooleanValue();
                return ( booleanValue == null ? null : booleanValue.toString() );
            case :
                Date dateValue = dcv.getDateValue();
                return ( dateValue == null ? null : .formatdcv.getDateValue() ) );
            case :
                BigDecimal numericValue = (BigDecimaldcv.getNumericValue();
                return ( numericValue == null ? null : numericValue.toPlainString() );
            case :
                BigDecimal bigDecimalValue = (BigDecimaldcv.getNumericValue();
                return ( bigDecimalValue == null ? null : bigDecimalValue.toPlainString() );
            case :
                BigInteger bigIntegerValue = (BigIntegerdcv.getNumericValue();
                return ( bigIntegerValue == null ? null : bigIntegerValue.toString() );
            case :
                Byte byteValue = (Bytedcv.getNumericValue();
                return ( byteValue == null ? null : byteValue.toString() );
            case :
                Double doubleValue = (Doubledcv.getNumericValue();
                return ( doubleValue == null ? null : doubleValue.toString() );
            case :
                Float floatValue = (Floatdcv.getNumericValue();
                return ( floatValue == null ? null : floatValue.toString() );
            case :
                Integer integerValue = (Integerdcv.getNumericValue();
                return ( integerValue == null ? null : integerValue.toString() );
            case :
                Long longValue = (Longdcv.getNumericValue();
                return ( longValue == null ? null : longValue.toString() );
            case :
                Short shortValue = (Shortdcv.getNumericValue();
                return ( shortValue == null ? null : shortValue.toString() );
            default:
                return dcv.getStringValue();
        }
    }
New to GrepCode? Check out our FAQ X