Skip to content

Commit 80b4d31

Browse files
raghucssitiloveeclipse
authored andcommitted
Link with Selection Action for Help View toolbar is implemented.
This is similar to JDT Package Explorer's 'Link with Editor' Action. We will refresh the Help View input based on selection if this Action is enabled. see #1874
1 parent 1cceead commit 80b4d31

File tree

8 files changed

+355
-1
lines changed

8 files changed

+355
-1
lines changed

ua/org.eclipse.help.base/src/org/eclipse/help/internal/base/IHelpActivitySupport.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public interface IHelpActivitySupport {
5757

5858
public void setFilteringEnabled(boolean enabled);
5959

60+
public default boolean isLinkWithSelectionEnabled() {
61+
return true;
62+
}
63+
64+
public default void setLinkWithSelection(boolean enabled) {
65+
// does nothing by default
66+
}
67+
6068
public boolean isUserCanToggleFiltering();
6169

6270
/**
Lines changed: 296 additions & 0 deletions
Loading

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/HelpActivitySupport.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.eclipse.core.runtime.IProduct;
2222
import org.eclipse.core.runtime.Platform;
2323
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
24+
import org.eclipse.core.runtime.preferences.IPreferencesService;
2425
import org.eclipse.core.runtime.preferences.InstanceScope;
2526
import org.eclipse.help.internal.HelpPlugin;
2627
import org.eclipse.help.internal.base.HelpBasePlugin;
@@ -42,9 +43,12 @@ public class HelpActivitySupport implements IHelpActivitySupport {
4243
private static final String SHOW_DISABLED_ACTIVITIES_ON = "on"; //$NON-NLS-1$
4344
// private static final String SHOW_DISABLED_ACTIVITIES_ALWAYS = "always"; //$NON-NLS-1$
4445

46+
private static final String PREF_KEY_SYNC_SEL = "linkWithSelection"; //$NON-NLS-1$
47+
4548
private final IWorkbenchActivitySupport activitySupport;
4649
private boolean userCanToggleFiltering;
4750
private boolean filteringEnabled;
51+
private boolean linkWithSelection;
4852
private final ActivityDescriptor activityDescriptor;
4953

5054
static class ActivityDescriptor {
@@ -122,8 +126,9 @@ public HelpActivitySupport(IWorkbench workbench) {
122126
activitySupport = workbench.getActivitySupport();
123127
activityDescriptor = new ActivityDescriptor();
124128

129+
IPreferencesService prefService = Platform.getPreferencesService();
125130
String showDisabledActivities =
126-
Platform.getPreferencesService().getString(HelpBasePlugin.PLUGIN_ID, PREF_KEY_SHOW_DISABLED_ACTIVITIES, "", null); //$NON-NLS-1$
131+
prefService.getString(HelpBasePlugin.PLUGIN_ID, PREF_KEY_SHOW_DISABLED_ACTIVITIES, "", null); //$NON-NLS-1$
127132
userCanToggleFiltering = SHOW_DISABLED_ACTIVITIES_OFF
128133
.equalsIgnoreCase(showDisabledActivities)
129134
|| SHOW_DISABLED_ACTIVITIES_ON
@@ -136,6 +141,8 @@ public HelpActivitySupport(IWorkbench workbench) {
136141
|| SHOW_DISABLED_ACTIVITIES_NEVER
137142
.equalsIgnoreCase(showDisabledActivities);
138143
filteringEnabled = filteringEnabled && isWorkbenchFiltering();
144+
145+
linkWithSelection = prefService.getBoolean(HelpBasePlugin.PLUGIN_ID, PREF_KEY_SYNC_SEL, true, null);
139146
}
140147

141148
@Override
@@ -162,6 +169,22 @@ public void setFilteringEnabled(boolean enabled) {
162169
}
163170
}
164171

172+
@Override
173+
public boolean isLinkWithSelectionEnabled() {
174+
return linkWithSelection;
175+
}
176+
177+
@Override
178+
public void setLinkWithSelection(boolean syncSel) {
179+
this.linkWithSelection = syncSel;
180+
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(HelpBasePlugin.PLUGIN_ID);
181+
prefs.putBoolean(PREF_KEY_SYNC_SEL, syncSel);
182+
try {
183+
prefs.flush();
184+
} catch (BackingStoreException e) {
185+
}
186+
}
187+
165188
@Override
166189
public boolean isUserCanToggleFiltering() {
167190
return userCanToggleFiltering;

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/IHelpUIConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public interface IHelpUIConstants {
5555
public static final String IMAGE_CLOSE_HOT = "elcl16/close_hot.svg"; //$NON-NLS-1$
5656
public static final String IMAGE_SYNC_TOC = "elcl16/synch_toc_nav.svg"; //$NON-NLS-1$
5757
public static final String IMAGE_SHOW_ALL = "elcl16/show_all.svg"; //$NON-NLS-1$
58+
public static final String IMAGE_SYNC_SEL = "elcl16/synced.svg"; //$NON-NLS-1$
5859
public static final String IMAGE_DOC_OVR = "ovr16/doc_co.svg"; //$NON-NLS-1$
5960
public static final String IMAGE_SCOPE_SET = "obj16/scopeset_obj.svg"; //$NON-NLS-1$
6061
public static final String IMAGE_SEARCH_WIZ = "wizban/newsearch_wiz.svg"; //$NON-NLS-1$

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ private Messages() {
147147
public static String RootScopePage_desc;
148148
public static String AllTopicsPart_collapseAll_tooltip;
149149
public static String AllTopicsPart_showAll_tooltip;
150+
public static String LinkWithSelection_tooltip;
150151
public static String BookmarksPart_savedTopics;
151152
public static String BookmarksPart_delete;
152153
public static String BookmarksPart_deleteAll;

ua/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/Messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ RootScopePage_name=Na&me:
182182
RootScopePage_desc=Descri&ption:
183183
AllTopicsPart_collapseAll_tooltip=Collapse All
184184
AllTopicsPart_showAll_tooltip = Show All Topics
185+
LinkWithSelection_tooltip = Link with Selection
185186
BookmarksPart_savedTopics=Saved Topics
186187
BookmarksPart_delete=&Delete
187188
BookmarksPart_deleteAll = D&elete All

0 commit comments

Comments
 (0)