Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2013-12-05 16:31:34 +0000
committerDani Megert2013-12-05 16:31:34 +0000
commit0fa115d5fb762bfc17fd924fb1f0e33fa877c1f8 (patch)
tree7e26eb11374bb76398a494ee9df74ece096d2e2d
parent45251cf8c259d90993dbeafc0bffda10e07024da (diff)
downloadeclipse.platform.text-0fa115d5fb762bfc17fd924fb1f0e33fa877c1f8.tar.gz
eclipse.platform.text-0fa115d5fb762bfc17fd924fb1f0e33fa877c1f8.tar.xz
eclipse.platform.text-0fa115d5fb762bfc17fd924fb1f0e33fa877c1f8.zip
Fixed bug 420662: [content assist] Context selection window should remember its sizeI20131209-0800I20131208-2000
-rw-r--r--org.eclipse.jface.text/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.jface.text/pom.xml2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java106
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java33
4 files changed, 128 insertions, 15 deletions
diff --git a/org.eclipse.jface.text/META-INF/MANIFEST.MF b/org.eclipse.jface.text/META-INF/MANIFEST.MF
index dd6f22cd7e8..0307e02263d 100644
--- a/org.eclipse.jface.text/META-INF/MANIFEST.MF
+++ b/org.eclipse.jface.text/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jface.text
-Bundle-Version: 3.8.200.qualifier
+Bundle-Version: 3.9.0.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
diff --git a/org.eclipse.jface.text/pom.xml b/org.eclipse.jface.text/pom.xml
index 76b48b8d821..8d1fb6ba8aa 100644
--- a/org.eclipse.jface.text/pom.xml
+++ b/org.eclipse.jface.text/pom.xml
@@ -18,6 +18,6 @@
</parent>
<groupId>org.eclipse.jface</groupId>
<artifactId>org.eclipse.jface.text</artifactId>
- <version>3.8.200-SNAPSHOT</version>
+ <version>3.9.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index 56a03cdb5b5..8277bfe1a68 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -831,13 +831,35 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
}
}
+
/**
- * Dialog store constants.
- *
+ * Dialog store constant for the x-size of the completion proposal pop-up
+ *
* @since 3.0
*/
public static final String STORE_SIZE_X= "size.x"; //$NON-NLS-1$
+
+ /**
+ * Dialog store constant for the y-size of the completion proposal pop-up
+ *
+ * @since 3.0
+ */
public static final String STORE_SIZE_Y= "size.y"; //$NON-NLS-1$
+
+ /**
+ * Dialog store constant for the x-size of the context selector pop-up
+ *
+ * @since 3.9
+ */
+ public static final String STORE_CONTEXT_SELECTOR_POPUP_SIZE_X= "contextSelector.size.x"; //$NON-NLS-1$
+
+ /**
+ * Dialog store constant for the y-size of the context selector pop-up
+ *
+ * @since 3.9
+ */
+ public static final String STORE_CONTEXT_SELECTOR_POPUP_SIZE_Y= "contextSelector.size.y"; //$NON-NLS-1$
+
// Content-Assist Listener types
final static int CONTEXT_SELECTOR= 0;
@@ -2081,9 +2103,11 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
* <ul>
* <li>{@link ContentAssistant#STORE_SIZE_X}</li>
* <li>{@link ContentAssistant#STORE_SIZE_Y}</li>
+ * <li>{@link ContentAssistant#STORE_CONTEXT_SELECTOR_POPUP_SIZE_X}</li>
+ * <li>{@link ContentAssistant#STORE_CONTEXT_SELECTOR_POPUP_SIZE_Y}</li>
* </ul>
* </p>
- *
+ *
* @param dialogSettings the dialog settings
* @since 3.0
*/
@@ -2093,7 +2117,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
}
/**
- * Stores the content assist pop-up's size.
+ * Stores the content assist's proposal pop-up size.
*/
protected void storeCompletionProposalPopupSize() {
if (fDialogSettings == null || fProposalPopup == null)
@@ -2108,9 +2132,26 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
}
/**
- * Restores the content assist pop-up's size.
- *
- * @return the stored size
+ * Stores the content assist's context selector pop-up size.
+ *
+ * @since 3.9
+ */
+ protected void storeContextSelectorPopupSize() {
+ if (fDialogSettings == null || fContextInfoPopup == null)
+ return;
+
+ Point size= fContextInfoPopup.getConextSelectorPopupSize();
+ if (size == null)
+ return;
+
+ fDialogSettings.put(STORE_CONTEXT_SELECTOR_POPUP_SIZE_X, size.x);
+ fDialogSettings.put(STORE_CONTEXT_SELECTOR_POPUP_SIZE_Y, size.y);
+ }
+
+ /**
+ * Restores the content assist's proposal pop-up size.
+ *
+ * @return the stored size or <code>null</code> if none
* @since 3.0
*/
protected Point restoreCompletionProposalPopupSize() {
@@ -2123,8 +2164,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
size.x= fDialogSettings.getInt(STORE_SIZE_X);
size.y= fDialogSettings.getInt(STORE_SIZE_Y);
} catch (NumberFormatException ex) {
- size.x= -1;
- size.y= -1;
+ return null;
}
// sanity check
@@ -2158,9 +2198,53 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
}
/**
+ * Restores the content assist's context selector pop-up size.
+ *
+ * @return the stored size or <code>null</code> if none
+ * @since 3.9
+ */
+ protected Point restoreContextSelectorPopupSize() {
+ if (fDialogSettings == null)
+ return null;
+
+ Point size= new Point(-1, -1);
+
+ try {
+ size.x= fDialogSettings.getInt(STORE_CONTEXT_SELECTOR_POPUP_SIZE_X);
+ size.y= fDialogSettings.getInt(STORE_CONTEXT_SELECTOR_POPUP_SIZE_Y);
+ } catch (NumberFormatException ex) {
+ return null;
+ }
+
+ // sanity check
+ if (size.x == -1 && size.y == -1)
+ return null;
+
+ Rectangle maxBounds= null;
+ Display display= Display.getCurrent();
+ if (display == null)
+ display= Display.getDefault();
+ if (display != null && !display.isDisposed())
+ maxBounds= display.getBounds();
+
+ if (size.x > -1 && size.y > -1) {
+ if (maxBounds != null) {
+ size.x= Math.min(size.x, maxBounds.width);
+ size.y= Math.min(size.y, maxBounds.height);
+ }
+
+ // Enforce an absolute minimal size
+ size.x= Math.max(size.x, 30);
+ size.y= Math.max(size.y, 30);
+ }
+
+ return size;
+ }
+
+ /**
* Sets the prefix completion property. If enabled, content assist delegates completion to
* prefix completion.
- *
+ *
* @param enabled <code>true</code> to enable prefix completion, <code>false</code> to
* disable
*/
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
index e3dd1c6c9ae..f4742bcc6ff 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyEvent;
@@ -112,6 +114,7 @@ class ContextInformationPopup implements IContentAssistListener {
private PopupCloser fPopupCloser= new PopupCloser();
private Shell fContextSelectorShell;
+ private Point fContextSelectorPopupSize;
private Table fContextSelectorTable;
private IContextInformation[] fContextSelectorInput;
private String fLineDelimiter= null;
@@ -509,6 +512,17 @@ class ContextInformationPopup implements IContentAssistListener {
fContextSelectorShell.setLayout(layout);
fContextSelectorShell.setBackground(control.getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ fContextSelectorShell.addControlListener(new ControlListener() {
+
+ public void controlMoved(ControlEvent e) {
+ }
+
+ public void controlResized(ControlEvent e) {
+ fContextSelectorPopupSize= fContextSelectorShell.getSize();
+ }
+ });
+
+
if (fViewer instanceof ITextViewerExtension) {
final ITextViewerExtension textViewerExtension= (ITextViewerExtension)fViewer;
final StyledText textWidget= fViewer.getTextWidget();
@@ -539,7 +553,11 @@ class ContextInformationPopup implements IContentAssistListener {
gd.widthHint= 300;
fContextSelectorTable.setLayoutData(gd);
- fContextSelectorShell.pack(true);
+ Point size= fContentAssistant.restoreContextSelectorPopupSize();
+ if (size != null)
+ fContextSelectorShell.setSize(size);
+ else
+ fContextSelectorShell.pack(true);
Color c= fContentAssistant.getContextSelectorBackground();
if (c == null)
@@ -585,6 +603,16 @@ class ContextInformationPopup implements IContentAssistListener {
}
/**
+ * Returns the size of the context selector pop-up.
+ *
+ * @return a Point containing the size
+ * @since 3.9
+ */
+ Point getConextSelectorPopupSize() {
+ return fContextSelectorPopupSize;
+ }
+
+ /**
* Causes the context information of the context selected in the context selector
* to be displayed in the context information popup.
*/
@@ -640,6 +668,7 @@ class ContextInformationPopup implements IContentAssistListener {
*/
private void hideContextSelector() {
if (Helper.okToUse(fContextSelectorShell)) {
+ fContentAssistant.storeContextSelectorPopupSize();
fContentAssistant.removeContentAssistListener(this, ContentAssistant.CONTEXT_SELECTOR);
fPopupCloser.uninstall();

Back to the top