Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2012-03-29 16:03:40 +0000
committerDani Megert2012-03-29 16:03:40 +0000
commit991951ce1916a3c4a1bab80bbc2df6fd894c1316 (patch)
tree4fa79808c3b81bb1ce3ffa6f0687975b8879696f
parenta0a4c8bf2afefe9eebf6a652367b14d6360e5f87 (diff)
downloadeclipse.platform.text-991951ce1916a3c4a1bab80bbc2df6fd894c1316.tar.gz
eclipse.platform.text-991951ce1916a3c4a1bab80bbc2df6fd894c1316.tar.xz
eclipse.platform.text-991951ce1916a3c4a1bab80bbc2df6fd894c1316.zip
checkboxes with links
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java63
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java3
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties5
3 files changed, 16 insertions, 55 deletions
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
index aac9081f79e..42e57c619af 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
@@ -19,17 +19,11 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -48,7 +42,6 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -60,7 +53,6 @@ import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.resource.StringConverter;
-import org.eclipse.jface.util.Util;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -848,8 +840,9 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
addCheckBox(appearanceComposite, showMagnet, new BooleanDomain(), 0);
label= TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharacters;
+ String linkText= TextEditorMessages.TextEditorDefaultsPreferencePage_showWhitespaceCharactersLinkText;
Preference showWhitespaceCharacters= new Preference(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_WHITESPACE_CHARACTERS, label, null);
- addCheckBoxWithLink(appearanceComposite, showWhitespaceCharacters, new BooleanDomain(), 0, new SelectionAdapter() {
+ addCheckBoxWithLink(appearanceComposite, showWhitespaceCharacters, linkText, new BooleanDomain(), 0, new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Dialog dialog= new WhitespaceCharacterPainterOptionsDialog(Display.getDefault().getActiveShell(), fOverlayStore);
dialog.open();
@@ -1137,7 +1130,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
return checkBox;
}
- Button addCheckBoxWithLink(Composite parent, final Preference preference, final Domain domain, int indentation, final SelectionListener listener) {
+ private Button addCheckBoxWithLink(Composite parent, final Preference preference, String linkText, final Domain domain, int indentation, final SelectionListener listener) {
GridData gd= new GridData(GridData.FILL, GridData.FILL, true, false);
gd.horizontalSpan= 3;
gd.horizontalIndent= indentation;
@@ -1153,63 +1146,29 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
final Button checkBox= new Button(composite, SWT.CHECK);
checkBox.setFont(JFaceResources.getDialogFont());
+ checkBox.setText(preference.getName());
gd= new GridData(GridData.FILL, GridData.CENTER, false, false);
- int offset= Util.isMac() ? -4 : Util.isLinux() ? -2 : /* Windows et al. */ 3;
- gd.widthHint= checkBox.computeSize(SWT.DEFAULT, SWT.DEFAULT).x + offset;
checkBox.setLayoutData(gd);
checkBox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
checkboxControlChanged(preference, domain, checkBox);
}
});
- checkBox.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- e.result= LegacyActionTools.removeMnemonics(preference.getName().replaceAll("</?[aA][^>]*>", "")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
gd= new GridData(GridData.FILL, GridData.CENTER, false, false);
-
Link link= new Link(composite, SWT.NONE);
- link.setText(preference.getName());
+ link.setText(linkText);
link.setLayoutData(gd);
-
- // toggle checkbox when user clicks unlinked text in link:
- final boolean[] linkSelected= { false };
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- linkSelected[0]= true;
- if (listener != null) {
+ if (listener != null) {
+ link.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
listener.widgetSelected(e);
}
- }
- });
- link.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- linkSelected[0]= false;
- }
- public void mouseUp(MouseEvent e) {
- if (!linkSelected[0]) {
- checkBox.setSelection(!checkBox.getSelection());
- checkBox.setFocus();
- linkSelected[0]= false;
- checkboxControlChanged(preference, domain, checkBox);
- }
- }
- });
- link.addTraverseListener(new TraverseListener() {
- public void keyTraversed(TraverseEvent e) {
- if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit == true) {
- e.detail= SWT.TRAVERSE_NONE;
- checkBox.setSelection(!checkBox.getSelection());
- checkBox.setFocus();
- linkSelected[0]= false;
- checkboxControlChanged(preference, domain, checkBox);
- }
- }
- });
+ });
+ }
fInitializers.add(fInitializerFactory.create(preference, checkBox));
+
return checkBox;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
index 2110f278a39..b8dc451b5d9 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -141,6 +141,7 @@ final class TextEditorMessages extends NLS {
public static String TextEditorDefaultsPreferencePage_smartHomeEnd;
public static String TextEditorDefaultsPreferencePage_warn_if_derived;
public static String TextEditorDefaultsPreferencePage_showWhitespaceCharacters;
+ public static String TextEditorDefaultsPreferencePage_showWhitespaceCharactersLinkText;
public static String TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogInvalidInput;
public static String TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogTitle;
public static String TextEditorDefaultsPreferencePage_space;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
index 2d2eba92c28..3fe2520a398 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2011 IBM Corporation and others.
+# Copyright (c) 2000, 2012 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
@@ -45,7 +45,8 @@ TextEditorDefaultsPreferencePage_lineFeed=Line Feed ( \u00b6 )
TextEditorDefaultsPreferencePage_range_indicator=Show &range indicator
TextEditorDefaultsPreferencePage_warn_if_derived= War&n before editing a derived file
TextEditorDefaultsPreferencePage_smartHomeEnd= &Smart caret positioning at line start and end
-TextEditorDefaultsPreferencePage_showWhitespaceCharacters= Sh&ow <a>whitespace characters</a>
+TextEditorDefaultsPreferencePage_showWhitespaceCharacters= Sh&ow whitespace characters
+TextEditorDefaultsPreferencePage_showWhitespaceCharactersLinkText= (<a>configure visibility</a>)
TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogInvalidInput=''{0}'' is not a valid input.
TextEditorDefaultsPreferencePage_showWhitespaceCharactersDialogTitle=Show Whitespace Characters
TextEditorDefaultsPreferencePage_space=Space ( \u00b7 )

Back to the top