Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java86
1 files changed, 86 insertions, 0 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java
new file mode 100644
index 00000000000..8dbc83dd1e4
--- /dev/null
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformation.java
@@ -0,0 +1,86 @@
+package org.eclipse.jface.text.contentassist;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+
+import org.eclipse.swt.graphics.Image;
+
+import org.eclipse.jface.util.Assert;
+
+
+/**
+ * A default implementation of the <code>IContextInformation</code> interface.
+ */
+public final class ContextInformation implements IContextInformation {
+
+ private String fContextDisplayString;
+ private String fInformationDisplayString;
+ private Image fImage;
+
+ /**
+ * Creates a new context information without an image.
+ *
+ * @param contextDisplayString the string to be used when presenting the context
+ * @param informationDisplayString the string to be displayed when presenting the context information
+ */
+ public ContextInformation(String contextDisplayString, String informationDisplayString) {
+ this(null, contextDisplayString, informationDisplayString);
+ }
+
+ /**
+ * Creates a new context information with an image.
+ *
+ * @param image the image to display when presenting the context information
+ * @param contextDisplayString the string to be used when presenting the context
+ * @param informationDisplayString the string to be displayed when presenting the context information,
+ * may not be <code>null</code>
+ */
+ public ContextInformation(Image image, String contextDisplayString, String informationDisplayString) {
+
+ Assert.isNotNull(informationDisplayString);
+
+ fImage= image;
+ fContextDisplayString= contextDisplayString;
+ fInformationDisplayString= informationDisplayString;
+ }
+
+ /*
+ * @see IContextInformation#equals
+ */
+ public boolean equals(Object object) {
+ if (object instanceof IContextInformation) {
+ IContextInformation contextInformation= (IContextInformation) object;
+ boolean equals= fInformationDisplayString.equalsIgnoreCase(contextInformation.getInformationDisplayString());
+ if (fContextDisplayString != null)
+ equals= equals && fContextDisplayString.equalsIgnoreCase(contextInformation.getContextDisplayString());
+ return equals;
+ }
+ return false;
+ }
+
+ /*
+ * @see IContextInformation#getInformationDisplayString()
+ */
+ public String getInformationDisplayString() {
+ return fInformationDisplayString;
+ }
+
+ /*
+ * @see IContextInformation#getImage()
+ */
+ public Image getImage() {
+ return fImage;
+ }
+
+ /*
+ * @see IContextInformation#getContextDisplayString()
+ */
+ public String getContextDisplayString() {
+ if (fContextDisplayString != null)
+ return fContextDisplayString;
+ return fInformationDisplayString;
+ }
+}

Back to the top