OLD | NEW |
(Empty) | |
| 1 /** |
| 2 * |
| 3 */ |
| 4 package com.xored.glance.internal.ui.sources; |
| 5 |
| 6 import org.eclipse.swt.widgets.Control; |
| 7 |
| 8 import com.xored.glance.ui.sources.ITextSource; |
| 9 import com.xored.glance.ui.sources.ITextSourceDescriptor; |
| 10 |
| 11 /** |
| 12 * @author Yuri Strot |
| 13 */ |
| 14 public class TextSourceMaker { |
| 15 |
| 16 public TextSourceMaker(ITextSourceDescriptor description, Control control) { |
| 17 this.description = description; |
| 18 this.control = control; |
| 19 } |
| 20 |
| 21 public boolean isValid() { |
| 22 return description == null ? false : description.isValid(control); |
| 23 } |
| 24 |
| 25 public ITextSource create() { |
| 26 return description == null ? null : description.createSource(control); |
| 27 } |
| 28 |
| 29 /** |
| 30 * @return the control |
| 31 */ |
| 32 public Control getControl() { |
| 33 return control; |
| 34 } |
| 35 |
| 36 @Override |
| 37 public int hashCode() { |
| 38 final int prime = 31; |
| 39 int result = 1; |
| 40 result = prime * result + ((control == null) ? 0 : control.hashCode()); |
| 41 result = prime * result + ((description == null) ? 0 : description.hashCode(
)); |
| 42 return result; |
| 43 } |
| 44 |
| 45 @Override |
| 46 public boolean equals(Object obj) { |
| 47 if (this == obj) |
| 48 return true; |
| 49 if (obj == null) |
| 50 return false; |
| 51 if (getClass() != obj.getClass()) |
| 52 return false; |
| 53 TextSourceMaker other = (TextSourceMaker) obj; |
| 54 if (control == null) { |
| 55 if (other.control != null) |
| 56 return false; |
| 57 } else if (!control.equals(other.control)) |
| 58 return false; |
| 59 if (description == null) { |
| 60 if (other.description != null) |
| 61 return false; |
| 62 } else if (!description.equals(other.description)) |
| 63 return false; |
| 64 return true; |
| 65 } |
| 66 |
| 67 private ITextSourceDescriptor description; |
| 68 private Control control; |
| 69 |
| 70 } |
OLD | NEW |