Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2020-09-14 06:09:16 +0000
committerLars Vogel2020-09-15 05:36:03 +0000
commit43aa85f0d63da0f2101b0cd7d7ae55234cf95e6f (patch)
tree655f4ed8d12219c0f9092bcd0015274a9f206b96
parent53c59ef217ef3960e32da67c411ce9f3e7d60e22 (diff)
downloadeclipse.platform.text-43aa85f0d63da0f2101b0cd7d7ae55234cf95e6f.tar.gz
eclipse.platform.text-43aa85f0d63da0f2101b0cd7d7ae55234cf95e6f.tar.xz
eclipse.platform.text-43aa85f0d63da0f2101b0cd7d7ae55234cf95e6f.zip
Change-Id: Iede1dcb37b946485cd981a80dd796e5b14d4027e Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java24
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java28
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java35
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java46
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java38
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java32
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java33
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java12
12 files changed, 133 insertions, 181 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
index 292c04a6f8a..d48f4bcfe11 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
@@ -14,6 +14,8 @@
*******************************************************************************/
package org.eclipse.jface.internal.text.link.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import java.util.ArrayList;
import java.util.List;
@@ -126,8 +128,8 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
@Override
public boolean ownsFocusShell() {
- return Helper2.okToUse(fProposalShell) && fProposalShell.isFocusControl()
- || Helper2.okToUse(fProposalTable) && fProposalTable.isFocusControl();
+ return isValid(fProposalShell) && fProposalShell.isFocusControl()
+ || isValid(fProposalTable) && fProposalTable.isFocusControl();
}
};
@@ -177,7 +179,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
fKeyListener= new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
- if (!Helper2.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return;
if (e.character == 0 && e.keyCode == SWT.CTRL) {
@@ -190,7 +192,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
@Override
public void keyReleased(KeyEvent e) {
- if (!Helper2.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return;
if (e.character == 0 && e.keyCode == SWT.CTRL) {
@@ -268,7 +270,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
* Creates the proposal selector.
*/
private void createProposalSelector() {
- if (Helper2.okToUse(fProposalShell))
+ if (isValid(fProposalShell))
return;
Control control= fViewer.getTextWidget();
@@ -468,7 +470,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
* @return <code>true</code> if the popup has the focus
*/
public boolean hasFocus() {
- if (Helper2.okToUse(fProposalShell))
+ if (isValid(fProposalShell))
return (fProposalShell.isFocusControl() || fProposalTable.isFocusControl());
return false;
@@ -486,7 +488,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
registry.unregister(fFocusEditingSupport);
}
- if (Helper2.okToUse(fProposalShell)) {
+ if (isValid(fProposalShell)) {
fContentAssistant.removeContentAssistListener(this, ContentAssistant2.PROPOSAL_SELECTOR);
fPopupCloser.uninstall();
@@ -543,7 +545,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
* @param proposals the proposals
*/
private void setProposals(ICompletionProposal[] proposals) {
- if (Helper2.okToUse(fProposalTable)) {
+ if (isValid(fProposalTable)) {
ICompletionProposal oldProposal= getSelectedProposal();
if (oldProposal instanceof ICompletionProposalExtension2)
@@ -704,7 +706,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
// see bug 47511: setVisible may run the event loop on GTK
// and trigger a rentrant call - have to check whether we are still
// visible
- if (!Helper2.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return;
@@ -717,7 +719,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
@Override
public boolean verifyKey(VerifyEvent e) {
- if (!Helper2.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return true;
char key= e.character;
@@ -977,7 +979,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
* @since 3.0
*/
public void setFocus() {
- if (Helper2.okToUse(fProposalShell))
+ if (isValid(fProposalShell))
fProposalShell.setFocus();
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
index e41f75837ce..452455d9b22 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jface.internal.text.link.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -92,7 +94,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
*/
protected void install() {
Control w= fViewer.getTextWidget();
- if (Helper2.okToUse(w)) {
+ if (isValid(w)) {
Shell shell= w.getShell();
fShell= shell;
@@ -117,11 +119,11 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
protected void uninstall() {
Shell shell= fShell;
fShell= null;
- if (Helper2.okToUse(shell))
+ if (isValid(shell))
shell.removeControlListener(this);
Control w= fViewer.getTextWidget();
- if (Helper2.okToUse(w)) {
+ if (isValid(w)) {
w.removeMouseListener(this);
w.removeFocusListener(this);
@@ -375,14 +377,14 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
switch (type) {
case LAYOUT_PROPOSAL_SELECTOR:
if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
+ isValid(fShells[LAYOUT_CONTEXT_SELECTOR])) {
// Restore event notification to the tip popup.
addContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
}
break;
case LAYOUT_CONTEXT_SELECTOR:
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
if (fProposalPopupOrientation == PROPOSAL_STACKED)
layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
// Restore event notification to the proposal popup.
@@ -392,7 +394,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
break;
case LAYOUT_CONTEXT_INFO_POPUP:
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW)
layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
}
@@ -426,13 +428,13 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
protected void layoutProposalSelector(int offset) {
if (fContextType == LAYOUT_CONTEXT_INFO_POPUP &&
fContextInfoPopupOrientation == CONTEXT_INFO_BELOW &&
- Helper2.okToUse(fShells[LAYOUT_CONTEXT_INFO_POPUP])) {
+ isValid(fShells[LAYOUT_CONTEXT_INFO_POPUP])) {
// Stack proposal selector beneath the tip box.
Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
shell.setLocation(getStackedLocation(shell, parent));
} else if (fContextType != LAYOUT_CONTEXT_SELECTOR ||
- !Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
+ !isValid(fShells[LAYOUT_CONTEXT_SELECTOR])) {
// There are no other presentations to be concerned with,
// so place the proposal selector beneath the cursor line.
Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
@@ -469,7 +471,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
Shell shell= fShells[LAYOUT_CONTEXT_SELECTOR];
shell.setLocation(getBelowLocation(shell, offset));
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
switch (fProposalPopupOrientation) {
case PROPOSAL_REMOVE:
// Remove the proposal selector.
@@ -503,7 +505,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
// Place the popup beneath the cursor line.
Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
parent.setLocation(getBelowLocation(parent, offset));
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
// Stack the proposal selector beneath the context info popup.
Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
shell.setLocation(getStackedLocation(shell, parent));
@@ -582,12 +584,12 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
switch (type) {
case LAYOUT_PROPOSAL_SELECTOR:
if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper2.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR]))
+ isValid(fShells[LAYOUT_CONTEXT_SELECTOR]))
// Disable event notification to the tip selector.
removeContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
break;
case LAYOUT_CONTEXT_SELECTOR:
- if (Helper2.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR]))
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR]))
// Disable event notification to the proposal selector.
removeContentAssistListener((IContentAssistListener2) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
break;
@@ -826,7 +828,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
extension.appendVerifyKeyListener(fAutoAssistListener);
} else {
StyledText textWidget= fViewer.getTextWidget();
- if (Helper2.okToUse(textWidget))
+ if (isValid(textWidget))
textWidget.addVerifyKeyListener(fAutoAssistListener);
}
}
@@ -838,7 +840,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
extension.removeVerifyKeyListener(fAutoAssistListener);
} else {
StyledText textWidget= fViewer.getTextWidget();
- if (Helper2.okToUse(textWidget))
+ if (isValid(textWidget))
textWidget.removeVerifyKeyListener(fAutoAssistListener);
}
@@ -1146,7 +1148,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
private void installKeyListener() {
if (!fKeyListenerHooked) {
StyledText text= fViewer.getTextWidget();
- if (Helper2.okToUse(text)) {
+ if (isValid(text)) {
if (fViewer instanceof ITextViewerExtension) {
ITextViewerExtension e= (ITextViewerExtension) fViewer;
@@ -1214,7 +1216,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
private void uninstallKeyListener() {
if (fKeyListenerHooked) {
StyledText text= fViewer.getTextWidget();
- if (Helper2.okToUse(text)) {
+ if (isValid(text)) {
if (fViewer instanceof ITextViewerExtension) {
ITextViewerExtension e= (ITextViewerExtension) fViewer;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
index 2d2b8a52a29..3582d784ec7 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
@@ -15,6 +15,8 @@
package org.eclipse.jface.internal.text.link.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import java.util.Stack;
import org.eclipse.swt.SWT;
@@ -238,7 +240,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
* Creates the context information popup. This is the tooltip like overlay window.
*/
private void createContextInfoPopup() {
- if (Helper2.okToUse(fContextInfoPopup))
+ if (isValid(fContextInfoPopup))
return;
Control control= fViewer.getTextWidget();
@@ -279,7 +281,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
*/
private void hideContextInfoPopup() {
- if (Helper2.okToUse(fContextInfoPopup)) {
+ if (isValid(fContextInfoPopup)) {
int size= fContextFrameStack.size();
if (size > 0) {
@@ -314,7 +316,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
* at a given offset.
*/
private void createContextSelector() {
- if (Helper2.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
return;
Control control= fViewer.getTextWidget();
@@ -383,7 +385,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
* @param contexts the possible contexts
*/
private void setContexts(IContextInformation[] contexts) {
- if (Helper2.okToUse(fContextSelectorTable)) {
+ if (isValid(fContextSelectorTable)) {
fContextSelectorInput= contexts;
@@ -417,7 +419,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
* Hodes the context selector.
*/
private void hideContextSelector() {
- if (Helper2.okToUse(fContextSelectorShell)) {
+ if (isValid(fContextSelectorShell)) {
fContentAssistant.removeContentAssistListener(this, ContentAssistant2.CONTEXT_SELECTOR);
fPopupCloser.uninstall();
@@ -426,7 +428,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
fContextSelectorShell= null;
}
- if (!Helper2.okToUse(fContextInfoPopup))
+ if (!isValid(fContextInfoPopup))
fContentAssistant.contextInformationClosed();
}
@@ -436,7 +438,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
* @return <code>true</code> if teh context selector has the focus
*/
public boolean hasFocus() {
- if (Helper2.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
return (fContextSelectorShell.isFocusControl() || fContextSelectorTable.isFocusControl());
return false;
@@ -457,14 +459,14 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
* @return <code>true</code> if the context selector is active
*/
public boolean isActive() {
- return (Helper2.okToUse(fContextInfoPopup) || Helper2.okToUse(fContextSelectorShell));
+ return (isValid(fContextInfoPopup) || isValid(fContextSelectorShell));
}
@Override
public boolean verifyKey(VerifyEvent e) {
- if (Helper2.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
return contextSelectorKeyPressed(e);
- if (Helper2.okToUse(fContextInfoPopup))
+ if (isValid(fContextInfoPopup))
return contextInfoPopupKeyPressed(e);
return true;
}
@@ -573,9 +575,9 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
@Override
public void processEvent(VerifyEvent event) {
- if (Helper2.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
contextSelectorProcessEvent(event);
- if (Helper2.okToUse(fContextInfoPopup))
+ if (isValid(fContextInfoPopup))
contextInfoPopupProcessEvent(event);
}
@@ -620,7 +622,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
@Override
public void run() {
- if (Helper2.okToUse(fContextInfoPopup) && fFrame == fContextFrameStack.peek()) {
+ if (isValid(fContextInfoPopup) && fFrame == fContextFrameStack.peek()) {
int offset= fViewer.getSelectedRange().x;
if (fFrame.fValidator == null || !fFrame.fValidator.isContextInformationValid(offset)) {
hideContextInfoPopup();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java
deleted file mode 100644
index 9b9d89cb1d2..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/Helper2.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.internal.text.link.contentassist;
-
-
-
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * Helper class for testing widget state.
- */
-class Helper2 {
-
- /**
- * Returns whether the widget is <code>null</code> or disposed.
- *
- * @param widget the widget to check
- * @return <code>true</code> if the widget is neither <code>null</code> nor disposed
- */
- public static boolean okToUse(Widget widget) {
- return (widget != null && !widget.isDisposed());
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
index 1afef85422d..f3e9794cbbc 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/PopupCloser2.java
@@ -14,6 +14,8 @@
package org.eclipse.jface.internal.text.link.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.SelectionEvent;
@@ -55,9 +57,9 @@ class PopupCloser2 extends ShellAdapter implements FocusListener, SelectionListe
public void install(ContentAssistant2 contentAssistant, Table table) {
fContentAssistant= contentAssistant;
fTable= table;
- if (Helper2.okToUse(fTable)) {
+ if (isValid(fTable)) {
Shell shell= fTable.getShell();
- if (Helper2.okToUse(shell)) {
+ if (isValid(shell)) {
fShell= shell;
fShell.addShellListener(this);
}
@@ -73,12 +75,12 @@ class PopupCloser2 extends ShellAdapter implements FocusListener, SelectionListe
*/
public void uninstall() {
fContentAssistant= null;
- if (Helper2.okToUse(fShell))
+ if (isValid(fShell))
fShell.removeShellListener(this);
fShell= null;
- if (Helper2.okToUse(fScrollbar))
+ if (isValid(fScrollbar))
fScrollbar.removeSelectionListener(this);
- if (Helper2.okToUse(fTable))
+ if (isValid(fTable))
fTable.removeFocusListener(this);
}
@@ -101,7 +103,7 @@ class PopupCloser2 extends ShellAdapter implements FocusListener, SelectionListe
fScrollbarClicked= false;
Display d= fTable.getDisplay();
d.asyncExec(() -> {
- if (Helper2.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
+ if (isValid(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
fContentAssistant.popupFocusLost(e);
});
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
index b29c6b2bc06..3383c9fa67e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jface.text.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -154,7 +156,7 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
final Control control= fContentAssistSubjectControlAdapter.getControl();
- if (!Helper.okToUse(fProposalShell) && control != null && !control.isDisposed()) {
+ if (!isValid(fProposalShell) && control != null && !control.isDisposed()) {
// add the listener before computing the proposals so we don't move the caret
// when the user types fast.
fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
@@ -243,7 +245,7 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
&& fComputedProposals.size() == 1
&& remaining.get() == 0
&& canAutoInsert(fComputedProposals.get(0))) {
- if (Helper.okToUse(fProposalShell)) {
+ if (isValid(fProposalShell)) {
insertProposal(fComputedProposals.get(0), (char) 0, 0, offset);
hide();
}
@@ -268,7 +270,7 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
@Override
public String incrementalComplete() {
cancelFutures();
- if (Helper.okToUse(fProposalShell) && fFilteredProposals != null) {
+ if (isValid(fProposalShell) && fFilteredProposals != null) {
return super.incrementalComplete();
}
final Control control= fContentAssistSubjectControlAdapter.getControl();
@@ -276,7 +278,7 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
if (fKeyListener == null)
fKeyListener= new ProposalSelectionListener();
- if (!Helper.okToUse(fProposalShell) && !control.isDisposed())
+ if (!isValid(fProposalShell) && !control.isDisposed())
fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
fInvocationOffset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index 0c128250a3d..128c97ae5d6 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
@@ -18,6 +18,8 @@
*******************************************************************************/
package org.eclipse.jface.text.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -226,7 +228,7 @@ class CompletionProposalPopup implements IContentAssistListener {
final class ProposalSelectionListener implements KeyListener {
@Override
public void keyPressed(KeyEvent e) {
- if (!Helper.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return;
if (e.character == 0 && e.keyCode == SWT.CTRL) {
@@ -239,7 +241,7 @@ class CompletionProposalPopup implements IContentAssistListener {
@Override
public void keyReleased(KeyEvent e) {
- if (!Helper.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return;
if (e.character == 0 && e.keyCode == SWT.CTRL) {
@@ -260,7 +262,7 @@ class CompletionProposalPopup implements IContentAssistListener {
@Override
public void keyPressed(KeyEvent e) {
- if (!Helper.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return;
int accelerator= SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
@@ -351,7 +353,7 @@ class CompletionProposalPopup implements IContentAssistListener {
if (!fIsFilterPending.compareAndSet(true, false))
return;
- if (!Helper.okToUse(fContentAssistSubjectControlAdapter.getControl()))
+ if (!isValid(fContentAssistSubjectControlAdapter.getControl()))
return;
int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
@@ -490,7 +492,7 @@ class CompletionProposalPopup implements IContentAssistListener {
final Control control= fContentAssistSubjectControlAdapter.getControl();
- if (!Helper.okToUse(fProposalShell) && control != null && !control.isDisposed()) {
+ if (!isValid(fProposalShell) && control != null && !control.isDisposed()) {
// add the listener before computing the proposals so we don't move the caret
// when the user types fast.
fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
@@ -596,7 +598,7 @@ class CompletionProposalPopup implements IContentAssistListener {
* Creates the proposal selector.
*/
void createProposalSelector() {
- if (Helper.okToUse(fProposalShell))
+ if (isValid(fProposalShell))
return;
Control control= fContentAssistSubjectControlAdapter.getControl();
@@ -712,12 +714,12 @@ class CompletionProposalPopup implements IContentAssistListener {
*/
int getMinimalHeight() {
int height= 0;
- if (Helper.okToUse(fProposalTable)) {
+ if (isValid(fProposalTable)) {
int items= fProposalTable.getItemHeight() * 10;
Rectangle trim= fProposalTable.computeTrim(0, 0, SWT.DEFAULT, items);
height= trim.height;
}
- if (Helper.okToUse(fMessageText))
+ if (isValid(fMessageText))
height+= fMessageText.getSize().y + 1;
return height;
}
@@ -735,7 +737,7 @@ class CompletionProposalPopup implements IContentAssistListener {
private CommandKeyListener fCommandKeyListener;
@Override
public void focusGained(FocusEvent e) {
- if (Helper.okToUse(control)) {
+ if (isValid(control)) {
if (fCommandKeyListener == null) {
fCommandKeyListener= new CommandKeyListener(commandSequence);
fProposalTable.addKeyListener(fCommandKeyListener);
@@ -756,7 +758,7 @@ class CompletionProposalPopup implements IContentAssistListener {
private TraverseListener fTraverseListener;
@Override
public void focusGained(FocusEvent e) {
- if (Helper.okToUse(control)) {
+ if (isValid(control)) {
if (fTraverseListener == null) {
fTraverseListener= event -> {
if (event.detail == SWT.TRAVERSE_TAB_NEXT) {
@@ -865,7 +867,7 @@ class CompletionProposalPopup implements IContentAssistListener {
StyleRange[] styleRanges= null;
Image image= null;
try {
- if (fIsColoredLabelsSupportEnabled && current instanceof ICompletionProposalExtension7 && Helper.okToUse(fProposalShell)) {
+ if (fIsColoredLabelsSupportEnabled && current instanceof ICompletionProposalExtension7 && isValid(fProposalShell)) {
BoldStylerProvider boldStylerProvider= fContentAssistant.getBoldStylerProvider();
if (boldStylerProvider == null) {
boldStylerProvider= new BoldStylerProvider(fProposalShell.getFont());
@@ -922,7 +924,7 @@ class CompletionProposalPopup implements IContentAssistListener {
fFilterRunnable.run();
// filter runnable may have hidden the proposals
- if (!Helper.okToUse(fProposalTable))
+ if (!isValid(fProposalTable))
return null;
int i= fProposalTable.getSelectionIndex();
@@ -1043,7 +1045,7 @@ class CompletionProposalPopup implements IContentAssistListener {
* @return <code>true</code> if the popup has the focus
*/
public boolean hasFocus() {
- if (Helper.okToUse(fProposalShell)) {
+ if (isValid(fProposalShell)) {
if ((fProposalShell.getDisplay().getActiveShell() == fProposalShell))
return true;
/*
@@ -1080,7 +1082,7 @@ class CompletionProposalPopup implements IContentAssistListener {
registry.unregister(fFocusHelper);
}
- if (Helper.okToUse(fProposalShell)) {
+ if (isValid(fProposalShell)) {
fContentAssistant.removeContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR);
@@ -1163,7 +1165,7 @@ class CompletionProposalPopup implements IContentAssistListener {
if (oldProposals != fFilteredProposals) // reentrant call was first - abort
return;
- if (Helper.okToUse(fProposalTable)) {
+ if (isValid(fProposalTable)) {
if (oldProposal instanceof ICompletionProposalExtension2 && fViewer != null)
((ICompletionProposalExtension2) oldProposal).unselected(fViewer);
@@ -1220,7 +1222,7 @@ class CompletionProposalPopup implements IContentAssistListener {
*/
void displayProposals() {
- if (!Helper.okToUse(fProposalShell) || !Helper.okToUse(fProposalTable))
+ if (!isValid(fProposalShell) || !isValid(fProposalTable))
return;
if (fContentAssistant.addContentAssistListener(this, ContentAssistant.PROPOSAL_SELECTOR)) {
@@ -1257,10 +1259,10 @@ class CompletionProposalPopup implements IContentAssistListener {
*/
fProposalShell.setVisible(true); // may run event loop on GTK
// transfer focus since no verify key listener can be attached
- if (!fContentAssistSubjectControlAdapter.supportsVerifyKeyListener() && Helper.okToUse(fProposalShell))
+ if (!fContentAssistSubjectControlAdapter.supportsVerifyKeyListener() && isValid(fProposalShell))
fProposalShell.setFocus(); // may run event loop on GTK ??
- if (fAdditionalInfoController != null && Helper.okToUse(fProposalTable)) {
+ if (fAdditionalInfoController != null && isValid(fProposalTable)) {
fAdditionalInfoController.install(fProposalTable);
fAdditionalInfoController.handleTableSelectionChanged();
}
@@ -1296,7 +1298,7 @@ class CompletionProposalPopup implements IContentAssistListener {
@Override
public boolean verifyKey(VerifyEvent e) {
- if (!Helper.okToUse(fProposalShell))
+ if (!isValid(fProposalShell))
return true;
char key= e.character;
@@ -1563,7 +1565,7 @@ class CompletionProposalPopup implements IContentAssistListener {
* @since 3.0
*/
public void setFocus() {
- if (Helper.okToUse(fProposalShell)) {
+ if (isValid(fProposalShell)) {
fProposalShell.setFocus();
}
}
@@ -1596,7 +1598,7 @@ class CompletionProposalPopup implements IContentAssistListener {
* @since 3.0
*/
public String incrementalComplete() {
- if (Helper.okToUse(fProposalShell) && fFilteredProposals != null) {
+ if (isValid(fProposalShell) && fFilteredProposals != null) {
if (fLastCompletionOffset == fFilterOffset) {
handleRepeatedInvocation();
} else {
@@ -1609,7 +1611,7 @@ class CompletionProposalPopup implements IContentAssistListener {
if (fKeyListener == null)
fKeyListener= new ProposalSelectionListener();
- if (!Helper.okToUse(fProposalShell) && !control.isDisposed())
+ if (!isValid(fProposalShell) && !control.isDisposed())
fContentAssistSubjectControlAdapter.addKeyListener(fKeyListener);
BusyIndicator.showWhile(control.getDisplay(), () -> {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
index 56d7e1de8d4..e1f6e72de5a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistSubjectControlAdapter.java
@@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.jface.text.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.KeyListener;
@@ -166,7 +168,7 @@ class ContentAssistSubjectControlAdapter implements IContentAssistSubjectControl
} else {
StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget)) {
+ if (isValid(textWidget)) {
textWidget.addVerifyKeyListener(verifyKeyListener);
return true;
}
@@ -184,7 +186,7 @@ class ContentAssistSubjectControlAdapter implements IContentAssistSubjectControl
return true;
} else {
StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget)) {
+ if (isValid(textWidget)) {
textWidget.addVerifyKeyListener(verifyKeyListener);
return true;
}
@@ -201,7 +203,7 @@ class ContentAssistSubjectControlAdapter implements IContentAssistSubjectControl
extension.removeVerifyKeyListener(verifyKeyListener);
} else {
StyledText textWidget= fViewer.getTextWidget();
- if (Helper.okToUse(textWidget))
+ if (isValid(textWidget))
textWidget.removeVerifyKeyListener(verifyKeyListener);
}
}
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 4da58e27542..e88c8f03422 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
@@ -18,6 +18,8 @@
*******************************************************************************/
package org.eclipse.jface.text.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -133,7 +135,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
protected void install() {
Control control= fContentAssistSubjectControlAdapter.getControl();
fControl= control;
- if (Helper.okToUse(control)) {
+ if (isValid(control)) {
Shell shell= control.getShell();
fShell= shell;
@@ -158,12 +160,12 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
protected void uninstall() {
Control shell= fShell;
fShell= null;
- if (Helper.okToUse(shell))
+ if (isValid(shell))
shell.removeControlListener(this);
Control control= fControl;
fControl= null;
- if (Helper.okToUse(control)) {
+ if (isValid(control)) {
control.removeMouseListener(this);
control.removeFocusListener(this);
@@ -210,7 +212,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
@Override
public void focusLost(FocusEvent e) {
Control control= fControl;
- if (Helper.okToUse(control)) {
+ if (isValid(control)) {
Display d= control.getDisplay();
if (d != null) {
d.asyncExec(() -> {
@@ -444,14 +446,14 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
switch (type) {
case LAYOUT_PROPOSAL_SELECTOR:
if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
+ isValid(fShells[LAYOUT_CONTEXT_SELECTOR])) {
// Restore event notification to the tip popup.
addContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
}
break;
case LAYOUT_CONTEXT_SELECTOR:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
if (fProposalPopupOrientation == PROPOSAL_STACKED)
layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
// Restore event notification to the proposal popup.
@@ -461,7 +463,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
break;
case LAYOUT_CONTEXT_INFO_POPUP:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
if (fContextInfoPopupOrientation == CONTEXT_INFO_BELOW)
layout(LAYOUT_PROPOSAL_SELECTOR, getSelectionOffset());
}
@@ -501,13 +503,13 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
protected void layoutProposalSelector(int offset) {
if (fContextType == LAYOUT_CONTEXT_INFO_POPUP &&
fContextInfoPopupOrientation == CONTEXT_INFO_BELOW &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_INFO_POPUP])) {
+ isValid(fShells[LAYOUT_CONTEXT_INFO_POPUP])) {
// Stack proposal selector beneath the tip box.
Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
shell.setLocation(getStackedLocation(shell, parent));
} else if (fContextType != LAYOUT_CONTEXT_SELECTOR ||
- !Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR])) {
+ !isValid(fShells[LAYOUT_CONTEXT_SELECTOR])) {
// There are no other presentations to be concerned with,
// so place the proposal selector beneath the cursor line.
Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
@@ -546,7 +548,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
Shell shell= fShells[LAYOUT_CONTEXT_SELECTOR];
shell.setBounds(computeBoundsBelowAbove(shell, shell.getSize(), offset, null));
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
switch (fProposalPopupOrientation) {
case PROPOSAL_REMOVE:
// Remove the proposal selector.
@@ -580,7 +582,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
// Place the popup beneath the cursor line.
Shell parent= fShells[LAYOUT_CONTEXT_INFO_POPUP];
parent.setBounds(computeBoundsBelowAbove(parent, parent.getSize(), offset, null));
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR])) {
// Stack the proposal selector beneath the context info popup.
Shell shell= fShells[LAYOUT_PROPOSAL_SELECTOR];
shell.setLocation(getStackedLocation(shell, parent));
@@ -739,12 +741,12 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
switch (type) {
case LAYOUT_PROPOSAL_SELECTOR:
if (fContextType == LAYOUT_CONTEXT_SELECTOR &&
- Helper.okToUse(fShells[LAYOUT_CONTEXT_SELECTOR]))
+ isValid(fShells[LAYOUT_CONTEXT_SELECTOR]))
// Disable event notification to the tip selector.
removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_CONTEXT_SELECTOR], CONTEXT_SELECTOR);
break;
case LAYOUT_CONTEXT_SELECTOR:
- if (Helper.okToUse(fShells[LAYOUT_PROPOSAL_SELECTOR]))
+ if (isValid(fShells[LAYOUT_PROPOSAL_SELECTOR]))
// Disable event notification to the proposal selector.
removeContentAssistListener((IContentAssistListener) fPopups[LAYOUT_PROPOSAL_SELECTOR], PROPOSAL_SELECTOR);
break;
@@ -1541,7 +1543,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
registerHandler(SELECT_NEXT_PROPOSAL_COMMAND_ID, fProposalPopup.createProposalSelectionHandler(CompletionProposalPopup.ProposalSelectionHandler.SELECT_NEXT));
registerHandler(SELECT_PREVIOUS_PROPOSAL_COMMAND_ID, fProposalPopup.createProposalSelectionHandler(CompletionProposalPopup.ProposalSelectionHandler.SELECT_PREVIOUS));
- if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) {
+ if (isValid(fContentAssistSubjectControlAdapter.getControl())) {
fContentAssistSubjectControlShell= fContentAssistSubjectControlAdapter.getControl().getShell();
fCASCSTraverseListener= e -> {
if (e.detail == SWT.TRAVERSE_ESCAPE && isProposalPopupActive())
@@ -1577,7 +1579,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
fCloser= null;
}
- if (Helper.okToUse(fContentAssistSubjectControlShell))
+ if (isValid(fContentAssistSubjectControlShell))
fContentAssistSubjectControlShell.removeTraverseListener(fCASCSTraverseListener);
fCASCSTraverseListener= null;
fContentAssistSubjectControlShell= null;
@@ -1730,7 +1732,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*/
private void installKeyListener() {
if (!fVerifyKeyListenerHooked) {
- if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl())) {
+ if (isValid(fContentAssistSubjectControlAdapter.getControl())) {
fVerifyKeyListenerHooked= fContentAssistSubjectControlAdapter.prependVerifyKeyListener(fInternalListener);
}
}
@@ -1792,7 +1794,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*/
private void uninstallVerifyKeyListener() {
if (fVerifyKeyListenerHooked) {
- if (Helper.okToUse(fContentAssistSubjectControlAdapter.getControl()))
+ if (isValid(fContentAssistSubjectControlAdapter.getControl()))
fContentAssistSubjectControlAdapter.removeVerifyKeyListener(fInternalListener);
fVerifyKeyListenerHooked= false;
}
@@ -2396,7 +2398,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
return null;
Rectangle maxBounds= null;
- if (fContentAssistSubjectControl != null && Helper.okToUse(fContentAssistSubjectControl.getControl()))
+ if (fContentAssistSubjectControl != null && isValid(fContentAssistSubjectControl.getControl()))
maxBounds= fContentAssistSubjectControl.getControl().getDisplay().getBounds();
else {
// fallback
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 7bf6d32af33..e9d90400718 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
@@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.jface.text.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import java.util.Stack;
import org.eclipse.swt.SWT;
@@ -412,7 +414,7 @@ class ContextInformationPopup implements IContentAssistListener {
* Creates the context information popup. This is the tool tip like overlay window.
*/
private void createContextInfoPopup() {
- if (Helper.okToUse(fContextInfoPopup))
+ if (isValid(fContextInfoPopup))
return;
Control control= fContentAssistSubjectControlAdapter.getControl();
@@ -467,7 +469,7 @@ class ContextInformationPopup implements IContentAssistListener {
*/
private void hideContextInfoPopup(boolean all) {
- if (Helper.okToUse(fContextInfoPopup)) {
+ if (isValid(fContextInfoPopup)) {
int size= fContextFrameStack.size();
while (size > 0) {
@@ -508,7 +510,7 @@ class ContextInformationPopup implements IContentAssistListener {
* at a given offset.
*/
private void createContextSelector() {
- if (Helper.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
return;
Control control= fContentAssistSubjectControlAdapter.getControl();
@@ -599,7 +601,7 @@ class ContextInformationPopup implements IContentAssistListener {
*/
int getMinimalHeight() {
int height= 0;
- if (Helper.okToUse(fContextSelectorTable)) {
+ if (isValid(fContextSelectorTable)) {
int items= fContextSelectorTable.getItemHeight() * 10;
Rectangle trim= fContextSelectorTable.computeTrim(0, 0, SWT.DEFAULT, items);
height= trim.height;
@@ -638,7 +640,7 @@ class ContextInformationPopup implements IContentAssistListener {
* @param selectionIndex the index of the proposal to select
*/
private void setContexts(IContextInformation[] contexts, int selectionIndex) {
- if (Helper.okToUse(fContextSelectorTable)) {
+ if (isValid(fContextSelectorTable)) {
fContextSelectorInput= contexts;
@@ -672,7 +674,7 @@ class ContextInformationPopup implements IContentAssistListener {
* Hides the context selector.
*/
private void hideContextSelector() {
- if (Helper.okToUse(fContextSelectorShell)) {
+ if (isValid(fContextSelectorShell)) {
fContentAssistant.storeContextSelectorPopupSize();
fContentAssistant.removeContentAssistListener(this, ContentAssistant.CONTEXT_SELECTOR);
@@ -682,7 +684,7 @@ class ContextInformationPopup implements IContentAssistListener {
fContextSelectorShell= null;
}
- if (!Helper.okToUse(fContextInfoPopup))
+ if (!isValid(fContextInfoPopup))
fContentAssistant.contextInformationClosed();
}
@@ -692,7 +694,7 @@ class ContextInformationPopup implements IContentAssistListener {
* @return <code>true</code> if the context selector has the focus
*/
public boolean hasFocus() {
- if (Helper.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
return fContextSelectorShell.getDisplay().getActiveShell() == fContextSelectorShell;
return false;
@@ -713,14 +715,14 @@ class ContextInformationPopup implements IContentAssistListener {
* @return <code>true</code> if the context selector is active
*/
public boolean isActive() {
- return (Helper.okToUse(fContextInfoPopup) || Helper.okToUse(fContextSelectorShell));
+ return (isValid(fContextInfoPopup) || isValid(fContextSelectorShell));
}
@Override
public boolean verifyKey(VerifyEvent e) {
- if (Helper.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
return contextSelectorKeyPressed(e);
- if (Helper.okToUse(fContextInfoPopup))
+ if (isValid(fContextInfoPopup))
return contextInfoPopupKeyPressed(e);
return true;
}
@@ -831,9 +833,9 @@ class ContextInformationPopup implements IContentAssistListener {
@Override
public void processEvent(VerifyEvent event) {
- if (Helper.okToUse(fContextSelectorShell))
+ if (isValid(fContextSelectorShell))
contextSelectorProcessEvent(event);
- if (Helper.okToUse(fContextInfoPopup))
+ if (isValid(fContextInfoPopup))
contextInfoPopupProcessEvent(event);
}
@@ -872,7 +874,7 @@ class ContextInformationPopup implements IContentAssistListener {
* Otherwise, we'd validate the context information based on the
* pre-key-stroke state.
*/
- if (!Helper.okToUse(fContextInfoPopup))
+ if (!isValid(fContextInfoPopup))
return;
fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
@@ -886,7 +888,7 @@ class ContextInformationPopup implements IContentAssistListener {
int offset= fContentAssistSubjectControlAdapter.getSelectedRange().x;
// iterate all contexts on the stack
- while (Helper.okToUse(fContextInfoPopup) && !fContextFrameStack.isEmpty()) {
+ while (isValid(fContextInfoPopup) && !fContextFrameStack.isEmpty()) {
ContextFrame top= fContextFrameStack.peek();
if (top.fValidator == null || !top.fValidator.isContextInformationValid(offset)) {
hideContextInfoPopup(false); // loop variant: reduces the number of contexts on the stack
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java
deleted file mode 100644
index 9eb7bbcf854..00000000000
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/Helper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jface.text.contentassist;
-
-import org.eclipse.swt.widgets.Widget;
-
-
-/**
- * Helper class for testing widget state.
- */
-class Helper {
-
- /**
- * Returns whether the widget is <code>null</code> or disposed.
- *
- * @param widget the widget to check
- * @return <code>true</code> if the widget is neither <code>null</code> nor disposed
- */
- public static boolean okToUse(Widget widget) {
- return (widget != null && !widget.isDisposed());
- }
-}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
index 46a9790be1f..9aba5cea763 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/PopupCloser.java
@@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jface.text.contentassist;
+import static org.eclipse.jface.util.Util.isValid;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
@@ -92,7 +94,7 @@ class PopupCloser extends ShellAdapter implements FocusListener, SelectionListen
fTable= table;
fAdditionalInfoController= additionalInfoController;
- if (Helper.okToUse(fTable)) {
+ if (isValid(fTable)) {
fShell= fTable.getShell();
fDisplay= fShell.getDisplay();
@@ -115,12 +117,12 @@ class PopupCloser extends ShellAdapter implements FocusListener, SelectionListen
*/
public void uninstall() {
fContentAssistant= null;
- if (Helper.okToUse(fShell))
+ if (isValid(fShell))
fShell.removeShellListener(this);
fShell= null;
- if (Helper.okToUse(fScrollbar))
+ if (isValid(fScrollbar))
fScrollbar.removeSelectionListener(this);
- if (Helper.okToUse(fTable))
+ if (isValid(fTable))
fTable.removeFocusListener(this);
if (fDisplay != null && ! fDisplay.isDisposed()) {
fDisplay.removeFilter(SWT.Activate, this);
@@ -150,7 +152,7 @@ class PopupCloser extends ShellAdapter implements FocusListener, SelectionListen
fScrollbarClicked= false;
Display d= fTable.getDisplay();
d.asyncExec(() -> {
- if (Helper.okToUse(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
+ if (isValid(fTable) && !fTable.isFocusControl() && !fScrollbarClicked && fContentAssistant != null)
fContentAssistant.popupFocusLost(e);
});
}

Back to the top