001    package nl.cwi.sen1.error.model;
002    
003    import nl.cwi.sen1.error.viewer.ErrorViewerBridge;
004    import nl.cwi.sen1.gui.Studio;
005    import errorapi.types.Error;
006    import errorapi.types.Location;
007    
008    public class ErrorNode extends SelectableNode {
009        private String producer;
010    
011        private String id;
012    
013        private Error error;
014    
015        private Location location;
016    
017        public ErrorNode(Error error, String producer, String id) {
018            super(error);
019            this.id = id;
020            this.producer = producer;
021            this.error = error;
022        }
023    
024        public String getProducer() {
025            return producer;
026        }
027    
028        public Location getLocation() {
029            return location;
030        }
031    
032        public String getId() {
033            return id;
034        }
035    
036        public String toString() {
037            return error.getDescription();
038        }
039    
040        public void setLocation(Location location) {
041            this.location = location;
042        }
043    
044        public void selected(Studio studio, ErrorViewerBridge bridge) {
045            if (location != null) {
046                bridge.postEvent(studio.getATermFactory().make(
047                        "location-selected(<term>)", location.toTerm()));
048            }
049        }
050    
051        public boolean isError() {
052            return error.isError();
053        }
054    
055        public boolean isWarning() {
056            return error.isWarning();
057        }
058    
059        public boolean isFatal() {
060            return error.isFatal();
061        }
062    
063        public boolean isInfo() {
064            return error.isInfo();
065        }
066    }