1 /* 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. 3 * All rights reserved. Use is subject to license terms. 4 * 5 * This file is available and licensed under the following license: 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the distribution. 16 * - Neither the name of Oracle Corporation nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 package com.oracle.javafx.scenebuilder.kit.editor.report; 33 34 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMIntrinsic; 35 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMNode; 36 import com.oracle.javafx.scenebuilder.kit.fxom.FXOMPropertyT; 37 38 /** 39 * 40 * 41 */ 42 public class ErrorReportEntry { 43 44 public enum Type { 45 UNRESOLVED_CLASS, 46 UNRESOLVED_LOCATION, 47 UNRESOLVED_RESOURCE, 48 INVALID_CSS_CONTENT, 49 UNSUPPORTED_EXPRESSION 50 } 51 52 private final FXOMNode fxomNode; 53 private final Type type; 54 private final CSSParsingReport cssParsingReport; // relevant for INVALID_CSS_CONTENT 55 56 public ErrorReportEntry(FXOMNode fxomNode, Type type, CSSParsingReport cssParsingReport) { 57 assert fxomNode != null; 58 assert (type == Type.INVALID_CSS_CONTENT) == (cssParsingReport != null); 59 60 this.fxomNode = fxomNode; 61 this.type = type; 62 this.cssParsingReport = cssParsingReport; 63 } 64 65 public ErrorReportEntry(FXOMNode fxomNode, Type type) { 66 this(fxomNode, type, null); 67 } 68 69 public FXOMNode getFxomNode() { 70 return fxomNode; 71 } 72 73 public Type getType() { 74 return type; 75 } 76 77 public CSSParsingReport getCssParsingReport() { 78 return cssParsingReport; 79 } 80 81 /* 82 * Object 83 */ 84 85 @Override 86 public String toString() { 87 final StringBuilder result = new StringBuilder(); 88 89 result.append(getClass().getSimpleName()); 90 result.append("(fxomNode="); //NOI18N 91 result.append(fxomNode.getClass().getSimpleName()); 92 result.append(",type="); //NOI18N 93 result.append(type.toString()); 94 switch(type) { 95 case UNRESOLVED_CLASS: 96 break; 97 case UNRESOLVED_LOCATION: 98 result.append(",location="); //NOI18N 99 break; 100 case UNRESOLVED_RESOURCE: 101 result.append(",resource="); //NOI18N 102 break; 103 case INVALID_CSS_CONTENT: 104 result.append(",css file="); //NOI18N 105 break; 106 case UNSUPPORTED_EXPRESSION: 107 result.append(",expression="); //NOI18N 108 break; 109 } 110 if (fxomNode instanceof FXOMPropertyT) { 111 final FXOMPropertyT fxomProperty = (FXOMPropertyT) fxomNode; 112 result.append(fxomProperty.getValue()); 113 } else if (fxomNode instanceof FXOMIntrinsic) { 114 final FXOMIntrinsic fxomIntrinsic = (FXOMIntrinsic) fxomNode; 115 result.append(fxomIntrinsic.getSource()); 116 } else { 117 result.append("?"); //NOI18N 118 } 119 result.append(")"); //NOI18N 120 121 return result.toString(); 122 } 123 124 }