1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

New action ToggleLinkEditor.

This commit is contained in:
Alain Magloire 2004-03-05 19:21:40 +00:00
parent a69b7ae3ae
commit 2080d7ecfb
7 changed files with 152 additions and 8 deletions

View file

@ -1,3 +1,18 @@
2004-03-05 Alain Magloire
Support for ToggleEditor link action.
This action was only in the preference page.
Now it is also in the toolbar. It permits the CView
to track the CEdito selection.
* src/org/eclipse/cdt/internal/ui/cview/CView.java
* src/org/eclipse/cdt/internal/ui/cview/CViewAction.java
* src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
* src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
* src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java
* src/org/eclipse/cdt/internal/ui/preferences/CPluginPreferencePage.java
2004-03-04 Bogdan Gheorghe
Added Hyperlinks to CEditor
Added Navigation preference page for CEditor

View file

@ -818,14 +818,23 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
if (viewer == null) return;
boolean refreshViewer = false;
String property = event.getProperty();
if (event.getProperty() == PreferenceConstants.PREF_SHOW_CU_CHILDREN) {
if (property.equals(PreferenceConstants.PREF_SHOW_CU_CHILDREN)) {
boolean showCUChildren = CPluginPreferencePage.showCompilationUnitChildren();
((CElementContentProvider) viewer.getContentProvider()).setProvideMembers(showCUChildren);
refreshViewer = true;
} else if (property.equals(PreferenceConstants.PREF_LINK_TO_EDITOR)) {
CViewActionGroup group = getActionGroup();
if (group instanceof MainActionGroup) {
boolean enable = isLinkingEnabled();
((MainActionGroup)group).toggleLinkingAction.setChecked(enable);
}
}
if (refreshViewer) viewer.refresh();
if (refreshViewer) {
viewer.refresh();
}
}
/**
@ -839,6 +848,10 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
return CPluginPreferencePage.isLinkToEditor();
}
public void setLinkingEnabled(boolean enable) {
CPluginPreferencePage.setLinkingEnabled(enable);
}
/**
* Links to editor (if option enabled)
*/

View file

@ -0,0 +1,69 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.cview;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.SelectionProviderAction;
/**
* Superclass of all actions provided by the cview.
*/
public abstract class CViewAction extends SelectionProviderAction {
private CView cview;
/**
* Creates a new instance of the class.
*/
public CViewAction(CView cview, String label) {
super(cview.getViewer(), label);
this.cview = cview;
}
/**
* Returns the cview for which this action was created.
*/
public CView getCView() {
return cview;
}
/**
* Returns the viewer
*/
protected Viewer getViewer() {
return getCView().getViewer();
}
/**
* Returns the shell to use within actions.
*/
protected Shell getShell() {
return getCView().getSite().getShell();
}
/**
* Returns the workbench.
*/
protected IWorkbench getWorkbench() {
return CUIPlugin.getDefault().getWorkbench();
}
/**
* Returns the workbench window.
*/
protected IWorkbenchWindow getWorkbenchWindow() {
return getCView().getSite().getWorkbenchWindow();
}
}

View file

@ -13,15 +13,13 @@ package org.eclipse.cdt.internal.ui.cview;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.runtime.Platform;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* This is the action group for all the view actions.
@ -57,8 +55,9 @@ public abstract class CViewActionGroup extends ActionGroup {
protected ImageDescriptor getImageDescriptor(String relativePath) {
String iconPath = "icons/full/"; //$NON-NLS-1$
try {
AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
URL installURL = plugin.getDescriptor().getInstallURL();
//AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
//URL installURL = plugin.getDescriptor().getInstallURL();
URL installURL = CUIPlugin.getDefault().getDescriptor().getInstallURL();
URL url = new URL(installURL, iconPath + relativePath);
return ImageDescriptor.createFromURL(url);
} catch (MalformedURLException e) {

View file

@ -66,6 +66,7 @@ public class MainActionGroup extends CViewActionGroup {
ShowLibrariesAction clibFilterAction;
// Collapsing
CollapseAllAction collapseAllAction;
ToggleLinkingAction toggleLinkingAction;
//Search
FileSearchAction fFileSearchAction;
@ -153,6 +154,11 @@ public class MainActionGroup extends CViewActionGroup {
collapseAllAction = new CollapseAllAction(getCView());
toggleLinkingAction = new ToggleLinkingAction(getCView(), CViewMessages.getString("ToggleLinkingAction.text")); //$NON-NLS-1$
toggleLinkingAction.setToolTipText(CViewMessages.getString("ToggleLinkingAction.toolTip")); //$NON-NLS-1$
toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$
toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
fFileSearchAction = new FileSearchAction(viewer);
fFileSearchActionInWorkingSet = new FileSearchActionInWorkingSet(viewer);
fSearchDialogAction = new SearchDialogAction(viewer, getCView().getViewSite().getWorkbenchWindow());
@ -320,11 +326,12 @@ public class MainActionGroup extends CViewActionGroup {
IToolBarManager toolBar = actionBars.getToolBarManager();
toolBar.add(new Separator());
toolBar.add(collapseAllAction);
toolBar.add(toggleLinkingAction);
IMenuManager menu = actionBars.getMenuManager();
//menu.add (clibFilterAction);
menu.add(patternFilterAction);
menu.add(toggleLinkingAction);
}
public void dispose() {

View file

@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2000, 2003 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.cview;
/**
* This action toggles whether this navigator links its selection to the active
* editor.
*
* @since 2.0
*/
public class ToggleLinkingAction extends CViewAction {
/**
* Constructs a new action.
*/
public ToggleLinkingAction(CView cview, String label) {
super(cview, label);
setChecked(cview.isLinkingEnabled());
}
/**
* Runs the action.
*/
public void run() {
getCView().setLinkingEnabled(isChecked());
}
}

View file

@ -61,6 +61,10 @@ public class CPluginPreferencePage extends FieldEditorPreferencePage implements
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_LINK_TO_EDITOR);
}
public static void setLinkingEnabled(boolean enable) {
CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.PREF_LINK_TO_EDITOR, enable);
}
public static boolean showCompilationUnitChildren() {
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
}