Mercurial > projects > dwt-addons
comparison dwtx/jface/text/contentassist/ContextInformation.d @ 129:eb30df5ca28b
Added JFace Text sources
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 23 Aug 2008 19:10:48 +0200 |
parents | |
children | c4fb132a086c |
comparison
equal
deleted
inserted
replaced
128:8df1d4193877 | 129:eb30df5ca28b |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.jface.text.contentassist.ContextInformation; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 | |
17 | |
18 | |
19 import dwt.graphics.Image; | |
20 import dwtx.core.runtime.Assert; | |
21 | |
22 | |
23 | |
24 /** | |
25 * A default implementation of the <code>IContextInformation</code> interface. | |
26 */ | |
27 public final class ContextInformation : IContextInformation { | |
28 | |
29 /** The name of the context. */ | |
30 private final String fContextDisplayString; | |
31 /** The information to be displayed. */ | |
32 private final String fInformationDisplayString; | |
33 /** The image to be displayed. */ | |
34 private final Image fImage; | |
35 | |
36 /** | |
37 * Creates a new context information without an image. | |
38 * | |
39 * @param contextDisplayString the string to be used when presenting the context | |
40 * @param informationDisplayString the string to be displayed when presenting the context information | |
41 */ | |
42 public ContextInformation(String contextDisplayString, String informationDisplayString) { | |
43 this(null, contextDisplayString, informationDisplayString); | |
44 } | |
45 | |
46 /** | |
47 * Creates a new context information with an image. | |
48 * | |
49 * @param image the image to display when presenting the context information | |
50 * @param contextDisplayString the string to be used when presenting the context | |
51 * @param informationDisplayString the string to be displayed when presenting the context information, | |
52 * may not be <code>null</code> | |
53 */ | |
54 public ContextInformation(Image image, String contextDisplayString, String informationDisplayString) { | |
55 | |
56 Assert.isNotNull(informationDisplayString); | |
57 | |
58 fImage= image; | |
59 fContextDisplayString= contextDisplayString; | |
60 fInformationDisplayString= informationDisplayString; | |
61 } | |
62 | |
63 /* | |
64 * @see IContextInformation#equals(Object) | |
65 */ | |
66 public bool equals(Object object) { | |
67 if (object instanceof IContextInformation) { | |
68 IContextInformation contextInformation= (IContextInformation) object; | |
69 bool equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString()); | |
70 if (fContextDisplayString !is null) | |
71 equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString()); | |
72 return equals; | |
73 } | |
74 return false; | |
75 } | |
76 | |
77 /* | |
78 * @see java.lang.Object#hashCode() | |
79 * @since 3.1 | |
80 */ | |
81 public int hashCode() { | |
82 int low= fContextDisplayString !is null ? fContextDisplayString.hashCode() : 0; | |
83 return (fInformationDisplayString.hashCode() << 16) | low; | |
84 } | |
85 | |
86 /* | |
87 * @see IContextInformation#getInformationDisplayString() | |
88 */ | |
89 public String getInformationDisplayString() { | |
90 return fInformationDisplayString; | |
91 } | |
92 | |
93 /* | |
94 * @see IContextInformation#getImage() | |
95 */ | |
96 public Image getImage() { | |
97 return fImage; | |
98 } | |
99 | |
100 /* | |
101 * @see IContextInformation#getContextDisplayString() | |
102 */ | |
103 public String getContextDisplayString() { | |
104 if (fContextDisplayString !is null) | |
105 return fContextDisplayString; | |
106 return fInformationDisplayString; | |
107 } | |
108 } |