mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
2005-01-20
PR 82964 * icons/full/cview16/view_menu.gif * src/org/eclipse/cdt/internal.ui/CPluginImages.java * src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties * src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java * src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java * src/org/eclipse/cdt/internal/ui/text/COperatorRule.java * src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java * src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java * src/org/eclipse/cdt/internal/ui/text/contenassist/CCompletionProcessor.java
This commit is contained in:
parent
d36d5364f7
commit
5cf93d3112
10 changed files with 265 additions and 57 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2005-01-20
|
||||||
|
PR 82964
|
||||||
|
* icons/full/cview16/view_menu.gif
|
||||||
|
* src/org/eclipse/cdt/internal.ui/CPluginImages.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
|
||||||
|
* src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/text/CCodeScanner.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/text/COperatorRule.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/text/contenassist/CCompletionProcessor.java
|
||||||
|
|
||||||
2005-01-19 Alain Magloire
|
2005-01-19 Alain Magloire
|
||||||
PR 83151
|
PR 83151
|
||||||
* src/org/eclipse/cdt/ui/CElementContentProvider.java
|
* src/org/eclipse/cdt/ui/CElementContentProvider.java
|
||||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/full/cview16/view_menu.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/cview16/view_menu.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 92 B |
|
@ -105,11 +105,13 @@ public class CPluginImages {
|
||||||
|
|
||||||
// build console
|
// build console
|
||||||
public static final String IMG_VIEW_BUILD = NAME_PREFIX + "buildconsole.gif"; //$NON-NLS-1$
|
public static final String IMG_VIEW_BUILD = NAME_PREFIX + "buildconsole.gif"; //$NON-NLS-1$
|
||||||
|
public static final String IMG_VIEW_MENU = NAME_PREFIX + "view_menu.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
// unknow type
|
// unknow type
|
||||||
public static final String IMG_OBJS_UNKNOWN = NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
|
public static final String IMG_OBJS_UNKNOWN = NAME_PREFIX + "unknown_obj.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final ImageDescriptor DESC_BUILD_CONSOLE = createManaged(T_VIEW, IMG_VIEW_BUILD);
|
public static final ImageDescriptor DESC_BUILD_CONSOLE = createManaged(T_VIEW, IMG_VIEW_BUILD);
|
||||||
|
public static final ImageDescriptor IMG_VIEW_MENU_DESC = createManaged(T_VIEW, IMG_VIEW_MENU);
|
||||||
|
|
||||||
public static final ImageDescriptor DESC_OBJS_VARIABLE= createManaged(T_OBJ, IMG_OBJS_VARIABLE);
|
public static final ImageDescriptor DESC_OBJS_VARIABLE= createManaged(T_OBJ, IMG_OBJS_VARIABLE);
|
||||||
public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
|
public static final ImageDescriptor DESC_OBJS_LOCAL_VARIABLE= createManaged(T_OBJ, IMG_OBJS_LOCAL_VARIABLE);
|
||||||
|
|
|
@ -280,3 +280,6 @@ ToggleLinkingAction.description=Link with active editor
|
||||||
IncludesGroupingAction.label=Group includes
|
IncludesGroupingAction.label=Group includes
|
||||||
IncludesGroupingAction.tooltip=Group includes statements
|
IncludesGroupingAction.tooltip=Group includes statements
|
||||||
IncludesGroupingAction.description=Group includes statements
|
IncludesGroupingAction.description=Group includes statements
|
||||||
|
|
||||||
|
COutlineInformationControl.viewMenu.remember.label=Remember size and position
|
||||||
|
COutlineInformationControl.viewMenu.move.label=Move outline
|
||||||
|
|
|
@ -65,10 +65,8 @@ public class CSourceViewer extends ProjectionViewer implements ITextViewerExtens
|
||||||
public void configure(SourceViewerConfiguration configuration)
|
public void configure(SourceViewerConfiguration configuration)
|
||||||
{
|
{
|
||||||
super.configure(configuration);
|
super.configure(configuration);
|
||||||
System.out.println("Configuration...");
|
|
||||||
if (configuration instanceof CSourceViewerConfiguration)
|
if (configuration instanceof CSourceViewerConfiguration)
|
||||||
{
|
{
|
||||||
System.out.println("configured");
|
|
||||||
fOutlinePresenter = ((CSourceViewerConfiguration) configuration).getOutlinePresenter(editor);
|
fOutlinePresenter = ((CSourceViewerConfiguration) configuration).getOutlinePresenter(editor);
|
||||||
fOutlinePresenter.install(this);
|
fOutlinePresenter.install(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@ public final class CCodeScanner extends AbstractCScanner {
|
||||||
/** Constants which are additionally colored. */
|
/** Constants which are additionally colored. */
|
||||||
private static String[] fgConstants= { "NULL", "__DATE__", "__LINE__", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
private static String[] fgConstants= { "NULL", "__DATE__", "__LINE__", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"__TIME__", "__FILE__", "__STDC__", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"__TIME__", "__FILE__", "__STDC__", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
"bool", "TRUE", "FALSE"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"bool", "TRUE", "FALSE", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
"EXT_TEXT"}; //$NON-NLS-1$
|
||||||
/** Properties for tokens. */
|
/** Properties for tokens. */
|
||||||
private static String[] fgTokenProperties= {
|
private static String[] fgTokenProperties= {
|
||||||
ICColorConstants.C_KEYWORD,
|
ICColorConstants.C_KEYWORD,
|
||||||
|
|
|
@ -25,6 +25,7 @@ public class COperatorRule extends SingleCharRule
|
||||||
{
|
{
|
||||||
return (ch == ';' || ch == '.' || ch == ':' || ch == '=' || ch == '-'
|
return (ch == ';' || ch == '.' || ch == ':' || ch == '=' || ch == '-'
|
||||||
|| ch == '+' || ch == '\\' || ch == '*' || ch == '!' || ch == '%'
|
|| ch == '+' || ch == '\\' || ch == '*' || ch == '!' || ch == '%'
|
||||||
|| ch == '^' || ch == '&' || ch == '~' || ch == '>' || ch == '<');
|
|| ch == '^' || ch == '&' || ch == '~' || ch == '>' || ch == '<')
|
||||||
|
|| ch == '|';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* COutlineInformationControl.java 2004-12-14 / 08:17:41
|
* COutlineInformationControl.java 2004-12-14 / 08:17:41
|
||||||
|
|
||||||
* $Revision: 1.1 $ $Date: 2004/12/14 18:46:19 $
|
* $Revision: 1.2 $ $Date: 2004/12/23 19:38:20 $
|
||||||
*
|
*
|
||||||
* @author P.Tomaszewski
|
* @author P.Tomaszewski
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.ui.text;
|
package org.eclipse.cdt.internal.ui.text;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.model.CElement;
|
import org.eclipse.cdt.internal.core.model.CElement;
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider;
|
import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||||
|
@ -16,7 +18,11 @@ import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
|
||||||
import org.eclipse.cdt.ui.CElementGrouping;
|
import org.eclipse.cdt.ui.CElementGrouping;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||||
import org.eclipse.jface.text.IInformationControl;
|
import org.eclipse.jface.text.IInformationControl;
|
||||||
import org.eclipse.jface.text.IInformationControlExtension;
|
import org.eclipse.jface.text.IInformationControlExtension;
|
||||||
import org.eclipse.jface.text.IInformationControlExtension3;
|
import org.eclipse.jface.text.IInformationControlExtension3;
|
||||||
|
@ -39,6 +45,8 @@ import org.eclipse.swt.events.MouseAdapter;
|
||||||
import org.eclipse.swt.events.MouseEvent;
|
import org.eclipse.swt.events.MouseEvent;
|
||||||
import org.eclipse.swt.events.MouseListener;
|
import org.eclipse.swt.events.MouseListener;
|
||||||
import org.eclipse.swt.events.MouseMoveListener;
|
import org.eclipse.swt.events.MouseMoveListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
import org.eclipse.swt.events.ShellAdapter;
|
import org.eclipse.swt.events.ShellAdapter;
|
||||||
import org.eclipse.swt.events.ShellEvent;
|
import org.eclipse.swt.events.ShellEvent;
|
||||||
|
@ -58,8 +66,12 @@ import org.eclipse.swt.widgets.Item;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Layout;
|
import org.eclipse.swt.widgets.Layout;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
import org.eclipse.swt.widgets.ToolBar;
|
||||||
|
import org.eclipse.swt.widgets.ToolItem;
|
||||||
|
import org.eclipse.swt.widgets.Tracker;
|
||||||
import org.eclipse.swt.widgets.Tree;
|
import org.eclipse.swt.widgets.Tree;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
|
|
||||||
|
@ -67,36 +79,35 @@ import org.eclipse.swt.widgets.TreeItem;
|
||||||
* Control which shows outline information in C/C++ editor. Based on
|
* Control which shows outline information in C/C++ editor. Based on
|
||||||
* AbstracInformationContol/JavaOutlineInformationControl from JDT.
|
* AbstracInformationContol/JavaOutlineInformationControl from JDT.
|
||||||
*
|
*
|
||||||
* TODO: Bounds restoring, sorting.
|
* TODO: Sorting.
|
||||||
*
|
*
|
||||||
* @author P.Tomaszewski
|
* @author P.Tomaszewski
|
||||||
*/
|
*/
|
||||||
public class COutlineInformationControl implements IInformationControl,
|
public class COutlineInformationControl implements IInformationControl,
|
||||||
IInformationControlExtension, IInformationControlExtension3 {
|
IInformationControlExtension, IInformationControlExtension3 {
|
||||||
|
|
||||||
|
/** If this option is set, location is not restored. */
|
||||||
|
private static final String STORE_RESTORE_SIZE= "ENABLE_RESTORE_SIZE"; //$NON-NLS-1$
|
||||||
|
/** If this option is set, size is not restore. */
|
||||||
|
private static final String STORE_RESTORE_LOCATION= "ENABLE_RESTORE_LOCATION"; //$NON-NLS-1$
|
||||||
|
|
||||||
/** Border thickness in pixels. */
|
/** Border thickness in pixels. */
|
||||||
private static final int BORDER = 1;
|
private static final int BORDER = 1;
|
||||||
|
|
||||||
/** Right margin in pixels. */
|
/** Right margin in pixels. */
|
||||||
private static final int RIGHT_MARGIN = 3;
|
private static final int RIGHT_MARGIN = 3;
|
||||||
|
|
||||||
/** Minimum width set by setSizeConstrains to tree viewer. */
|
/** Minimum width set by setSizeConstrains to tree viewer. */
|
||||||
private static final int MIN_WIDTH = 300;
|
private static final int MIN_WIDTH = 300;
|
||||||
|
|
||||||
/** Source viewer which shows this control. */
|
/** Source viewer which shows this control. */
|
||||||
CEditor fEditor;
|
CEditor fEditor;
|
||||||
|
|
||||||
/** Shell for this control. */
|
/** Shell for this control. */
|
||||||
Shell fShell;
|
Shell fShell;
|
||||||
|
|
||||||
/** Control's composite. */
|
/** Control's composite. */
|
||||||
Composite fComposite;
|
Composite fComposite;
|
||||||
|
|
||||||
/** Tree viewer used to display outline. */
|
/** Tree viewer used to display outline. */
|
||||||
TreeViewer fTreeViewer;
|
TreeViewer fTreeViewer;
|
||||||
|
|
||||||
/** Text control for filter. */
|
/** Text control for filter. */
|
||||||
private Text fFilterText;
|
Text fFilterText;
|
||||||
|
|
||||||
/** Content provider for tree control. */
|
/** Content provider for tree control. */
|
||||||
IContentProvider fTreeContentProvider;
|
IContentProvider fTreeContentProvider;
|
||||||
|
|
||||||
|
@ -105,25 +116,29 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
|
|
||||||
/** Control bounds. */
|
/** Control bounds. */
|
||||||
Rectangle fBounds;
|
Rectangle fBounds;
|
||||||
|
|
||||||
/** Control trim. */
|
/** Control trim. */
|
||||||
Rectangle fTrim;
|
Rectangle fTrim;
|
||||||
|
|
||||||
/** Deactivation adapter. */
|
|
||||||
private Listener fDeactivateListener;
|
|
||||||
|
|
||||||
/** This prevents to notify listener when it is adding. */
|
/** This prevents to notify listener when it is adding. */
|
||||||
boolean fIsDeactivationActive;
|
boolean fIsDeactivationActive;
|
||||||
|
|
||||||
|
/** Deactivation adapter. */
|
||||||
|
private Listener fDeactivateListener;
|
||||||
/** Shell adapter, used for control deactivation. */
|
/** Shell adapter, used for control deactivation. */
|
||||||
private ShellListener fShellListener;
|
private ShellListener fShellListener;
|
||||||
|
|
||||||
/** Control adapter for shell, used in resize action. */
|
/** Control adapter for shell, used in resize action. */
|
||||||
private ControlListener fControlListener;
|
private ControlListener fControlListener;
|
||||||
|
|
||||||
/** Should outline be sorted. */
|
/** Should outline be sorted. */
|
||||||
boolean fSort = true;
|
boolean fSort = true;
|
||||||
|
|
||||||
|
/** Tool bar displayed on the top of the outline. */
|
||||||
|
ToolBar fToolBar;
|
||||||
|
/** Composite for tool bar. */
|
||||||
|
private Composite fToolbarComposite;
|
||||||
|
/** Menu manager for options menu. */
|
||||||
|
private MenuManager fViewMenuManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new outline control.
|
* Creates new outline control.
|
||||||
*
|
*
|
||||||
|
@ -142,7 +157,7 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
this.fEditor = editor;
|
this.fEditor = editor;
|
||||||
createShell(parent, shellStyle);
|
createShell(parent, shellStyle);
|
||||||
createComposite();
|
createComposite();
|
||||||
createFilterText();
|
createToolbar();
|
||||||
createHorizontalSeparator();
|
createHorizontalSeparator();
|
||||||
createTreeeViewer(treeStyle);
|
createTreeeViewer(treeStyle);
|
||||||
}
|
}
|
||||||
|
@ -323,16 +338,27 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
|
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresLocation()
|
||||||
*/
|
*/
|
||||||
public boolean restoresLocation() {
|
public boolean restoresLocation() {
|
||||||
// TODO: To implement.
|
return getSettings().getBoolean(STORE_RESTORE_LOCATION);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
|
* @see org.eclipse.jface.text.IInformationControlExtension3#restoresSize()
|
||||||
*/
|
*/
|
||||||
public boolean restoresSize() {
|
public boolean restoresSize() {
|
||||||
// TODO: To implement.
|
return getSettings().getBoolean(STORE_RESTORE_SIZE);
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns view manager instance. If instance does not exit it is created.
|
||||||
|
* @return View manager.
|
||||||
|
*/
|
||||||
|
MenuManager getViewMenuManager() {
|
||||||
|
if (fViewMenuManager == null) {
|
||||||
|
fViewMenuManager= new MenuManager();
|
||||||
|
fViewMenuManager.add(new RememberBoundsAction());
|
||||||
|
fViewMenuManager.add(new MoveAction());
|
||||||
|
}
|
||||||
|
return fViewMenuManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -363,7 +389,7 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void createComposite() {
|
private void createComposite() {
|
||||||
fComposite = new org.eclipse.swt.widgets.Composite(fShell, SWT.RESIZE);
|
fComposite = new Composite(fShell, SWT.RESIZE);
|
||||||
GridLayout layout = new GridLayout(1, false);
|
GridLayout layout = new GridLayout(1, false);
|
||||||
fComposite.setLayout(layout);
|
fComposite.setLayout(layout);
|
||||||
fComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
fComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
@ -371,6 +397,7 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates tree viewer control.
|
* Creates tree viewer control.
|
||||||
|
* @param treeStyle Tree style.
|
||||||
*/
|
*/
|
||||||
private void createTreeeViewer(int treeStyle) {
|
private void createTreeeViewer(int treeStyle) {
|
||||||
final IWorkingCopyManager manager = CUIPlugin.getDefault()
|
final IWorkingCopyManager manager = CUIPlugin.getDefault()
|
||||||
|
@ -392,15 +419,38 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
tree.addMouseListener(createMouseListenerForTreeViewer());
|
tree.addMouseListener(createMouseListenerForTreeViewer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates horizontal separator between filter text and outline.
|
||||||
|
*/
|
||||||
|
private void createHorizontalSeparator() {
|
||||||
|
Label separator = new Label(fComposite, SWT.SEPARATOR | SWT.HORIZONTAL
|
||||||
|
| SWT.LINE_DOT);
|
||||||
|
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates toolbar.
|
||||||
|
*/
|
||||||
|
private void createToolbar() {
|
||||||
|
fToolbarComposite = new Composite(fComposite, SWT.NONE);
|
||||||
|
final GridLayout layout = new GridLayout(2, false);
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.marginWidth = 0;
|
||||||
|
fToolbarComposite.setLayout(layout);
|
||||||
|
fToolbarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||||
|
createFilterText();
|
||||||
|
createViewMenu();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates control for filter text.
|
* Creates control for filter text.
|
||||||
*/
|
*/
|
||||||
private void createFilterText() {
|
private void createFilterText() {
|
||||||
fFilterText = new Text(fComposite, SWT.NONE);
|
fFilterText = new Text(fToolbarComposite, SWT.NONE);
|
||||||
GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
final GridData data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
GC gc = new GC(fComposite);
|
final GC gc = new GC(fComposite);
|
||||||
gc.setFont(fComposite.getFont());
|
gc.setFont(fComposite.getFont());
|
||||||
FontMetrics fontMetrics = gc.getFontMetrics();
|
final FontMetrics fontMetrics = gc.getFontMetrics();
|
||||||
gc.dispose();
|
gc.dispose();
|
||||||
|
|
||||||
data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
|
data.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics, 1);
|
||||||
|
@ -413,12 +463,41 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates horizontal separator between filter text and outline.
|
* Creates view menu for toolbar. In this menu options will be displayed.
|
||||||
*/
|
*/
|
||||||
private void createHorizontalSeparator() {
|
private void createViewMenu() {
|
||||||
Label separator = new Label(fComposite, SWT.SEPARATOR | SWT.HORIZONTAL
|
fToolBar= new ToolBar(fToolbarComposite, SWT.FLAT);
|
||||||
| SWT.LINE_DOT);
|
final ToolItem viewMenuButton= new ToolItem(fToolBar, SWT.PUSH, 0);
|
||||||
separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
||||||
|
final GridData data= new GridData();
|
||||||
|
data.horizontalAlignment= GridData.END;
|
||||||
|
data.verticalAlignment= GridData.BEGINNING;
|
||||||
|
fToolBar.setLayoutData(data);
|
||||||
|
|
||||||
|
viewMenuButton.setImage(CPluginImages.get(CPluginImages.IMG_VIEW_MENU));
|
||||||
|
createSelectionListenerForOptions(viewMenuButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates selection listener for options.
|
||||||
|
* @param viewMenuButton Button to create selection adapter.
|
||||||
|
*/
|
||||||
|
private void createSelectionListenerForOptions(ToolItem viewMenuButton) {
|
||||||
|
viewMenuButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||||
|
*/
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
fIsDeactivationActive = false;
|
||||||
|
|
||||||
|
final Menu menu = getViewMenuManager().createContextMenu(fShell);
|
||||||
|
final Rectangle bounds = fToolBar.getBounds();
|
||||||
|
final Point topLeft = fShell.toDisplay(new Point(bounds.x, bounds.y + bounds.height));
|
||||||
|
menu.setLocation(topLeft.x, topLeft.y);
|
||||||
|
|
||||||
|
menu.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -446,9 +525,12 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
fEditor.setSelection(selectedElement);
|
fEditor.setSelection(selectedElement);
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
if (fComposite != null && !fComposite.isDisposed())
|
||||||
|
{
|
||||||
fBounds = fComposite.getBounds();
|
fBounds = fComposite.getBounds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return mouseListener;
|
return mouseListener;
|
||||||
}
|
}
|
||||||
|
@ -506,15 +588,14 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||||
*/
|
*/
|
||||||
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
// Does not need implementation.
|
// Does not need implementation.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
|
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
|
||||||
*/
|
*/
|
||||||
public void widgetDefaultSelected(
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
org.eclipse.swt.events.SelectionEvent e) {
|
|
||||||
final TreeItem[] selection = ((Tree) fTreeViewer.getControl())
|
final TreeItem[] selection = ((Tree) fTreeViewer.getControl())
|
||||||
.getSelection();
|
.getSelection();
|
||||||
if (selection.length > 0) {
|
if (selection.length > 0) {
|
||||||
|
@ -535,6 +616,9 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
*/
|
*/
|
||||||
private KeyListener createKeyListenerForTreeViewer() {
|
private KeyListener createKeyListenerForTreeViewer() {
|
||||||
final KeyListener listener = new KeyListener() {
|
final KeyListener listener = new KeyListener() {
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
|
||||||
|
*/
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
if (e.keyCode == 0x1B) // ESC
|
if (e.keyCode == 0x1B) // ESC
|
||||||
{
|
{
|
||||||
|
@ -542,6 +626,9 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
|
||||||
|
*/
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
// Does not need implementation.
|
// Does not need implementation.
|
||||||
}
|
}
|
||||||
|
@ -562,8 +649,7 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
if (length > 0 && text.charAt(length - 1) != '*') {
|
if (length > 0 && text.charAt(length - 1) != '*') {
|
||||||
text = text + '*';
|
text = text + '*';
|
||||||
}
|
}
|
||||||
((CContentOutlinerProvider) fTreeContentProvider)
|
((CContentOutlinerProvider) fTreeContentProvider).updateFilter(text);
|
||||||
.updateFilter(text);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return modifyListener;
|
return modifyListener;
|
||||||
|
@ -671,6 +757,21 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns setting for this control.
|
||||||
|
* @return Settings.
|
||||||
|
*/
|
||||||
|
IDialogSettings getSettings() {
|
||||||
|
final String sectionName = "org.eclipse.jdt.internal.ui.text.QuickOutline"; //$NON-NLS-1$
|
||||||
|
IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
|
||||||
|
if (settings == null)
|
||||||
|
{
|
||||||
|
settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Border fill layout. Copied from AbstractInformationControl.
|
* Border fill layout. Copied from AbstractInformationControl.
|
||||||
|
@ -729,18 +830,17 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite,
|
* @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean)
|
||||||
* boolean)
|
|
||||||
*/
|
*/
|
||||||
protected void layout(Composite composite, boolean flushCache) {
|
protected void layout(Composite composite, boolean flushCache) {
|
||||||
|
|
||||||
Control[] children = composite.getChildren();
|
final Control[] children = composite.getChildren();
|
||||||
Point minSize = new Point(composite.getClientArea().width,
|
final Point minSize = new Point(composite.getClientArea().width,
|
||||||
composite.getClientArea().height);
|
composite.getClientArea().height);
|
||||||
|
|
||||||
if (children != null) {
|
if (children != null) {
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (int i = 0; i < children.length; i++) {
|
||||||
Control child = children[i];
|
final Control child = children[i];
|
||||||
child.setSize(minSize.x - fBorderSize * 2, minSize.y
|
child.setSize(minSize.x - fBorderSize * 2, minSize.y
|
||||||
- fBorderSize * 2);
|
- fBorderSize * 2);
|
||||||
child.setLocation(fBorderSize, fBorderSize);
|
child.setLocation(fBorderSize, fBorderSize);
|
||||||
|
@ -812,4 +912,62 @@ public class COutlineInformationControl implements IInformationControl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The view menu's Remember Size and Location action.
|
||||||
|
*/
|
||||||
|
private class RememberBoundsAction extends Action {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new action.
|
||||||
|
*/
|
||||||
|
RememberBoundsAction() {
|
||||||
|
super(ActionMessages.getString("COutlineInformationControl.viewMenu.remember.label"), IAction.AS_CHECK_BOX); //$NON-NLS-1$
|
||||||
|
setChecked(getSettings().getBoolean(STORE_RESTORE_LOCATION));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.jface.action.Action#run()
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
final IDialogSettings settings = getSettings();
|
||||||
|
|
||||||
|
final boolean newValue = isChecked();
|
||||||
|
|
||||||
|
// store new value
|
||||||
|
settings.put(STORE_RESTORE_LOCATION, newValue);
|
||||||
|
settings.put(STORE_RESTORE_SIZE, newValue);
|
||||||
|
|
||||||
|
fIsDeactivationActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The view menu's Move action.
|
||||||
|
*
|
||||||
|
* @author P.Tomaszewski
|
||||||
|
*/
|
||||||
|
private class MoveAction extends Action {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new action.
|
||||||
|
*/
|
||||||
|
MoveAction() {
|
||||||
|
super(ActionMessages.getString("COutlineInformationControl.viewMenu.move.label"), IAction.AS_PUSH_BUTTON); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.jface.action.Action#run()
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
final Tracker tracker= new Tracker(fShell.getDisplay(), SWT.NONE);
|
||||||
|
tracker.setStippled(true);
|
||||||
|
final Rectangle[] r= new Rectangle[] { fFilterText.getShell().getBounds() };
|
||||||
|
tracker.setRectangles(r);
|
||||||
|
if (tracker.open()) {
|
||||||
|
fShell.setBounds(tracker.getRectangles()[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.jface.dialogs.IDialogSettings;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.DefaultInformationControl;
|
import org.eclipse.jface.text.DefaultInformationControl;
|
||||||
import org.eclipse.jface.text.IAutoIndentStrategy;
|
import org.eclipse.jface.text.IAutoIndentStrategy;
|
||||||
|
@ -121,14 +122,15 @@ public class CSourceViewerConfiguration extends SourceViewerConfiguration {
|
||||||
*/
|
*/
|
||||||
public IInformationPresenter getOutlinePresenter(CEditor editor)
|
public IInformationPresenter getOutlinePresenter(CEditor editor)
|
||||||
{
|
{
|
||||||
final InformationPresenter presenter = new InformationPresenter(getOutlineContolCreator(editor));
|
final IInformationControlCreator outlineControlCreator = getOutlineContolCreator(editor);
|
||||||
presenter.setSizeConstraints(20, 20, true, false);
|
final InformationPresenter presenter = new InformationPresenter(outlineControlCreator);
|
||||||
final IInformationProvider provider = new CElementContentProvider(getEditor());
|
final IInformationProvider provider = new CElementContentProvider(getEditor());
|
||||||
presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
|
presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
|
||||||
presenter.setInformationProvider(provider, ICPartitions.C_MULTILINE_COMMENT);
|
presenter.setInformationProvider(provider, ICPartitions.C_MULTILINE_COMMENT);
|
||||||
presenter.setInformationProvider(provider, ICPartitions.C_SINGLE_LINE_COMMENT);
|
presenter.setInformationProvider(provider, ICPartitions.C_SINGLE_LINE_COMMENT);
|
||||||
presenter.setInformationProvider(provider, ICPartitions.C_STRING);
|
presenter.setInformationProvider(provider, ICPartitions.C_STRING);
|
||||||
|
presenter.setSizeConstraints(20, 20, true, false);
|
||||||
|
presenter.setRestoreInformationControlBounds(getSettings("outline_presenter_bounds"), true, true); //$NON-NLS-1$
|
||||||
return presenter;
|
return presenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,6 +446,19 @@ public class CSourceViewerConfiguration extends SourceViewerConfiguration {
|
||||||
return conrolCreator;
|
return conrolCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the settings for the given section.
|
||||||
|
*
|
||||||
|
* @param sectionName the section name
|
||||||
|
* @return the settings
|
||||||
|
*/
|
||||||
|
private IDialogSettings getSettings(String sectionName) {
|
||||||
|
IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
|
||||||
|
if (settings == null) {
|
||||||
|
settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
@ -32,8 +33,8 @@ import org.eclipse.cdt.internal.ui.text.template.TemplateEngine;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
|
||||||
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
import org.eclipse.cdt.ui.text.ICCompletionProposal;
|
||||||
|
import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
@ -315,7 +316,7 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
||||||
fCurrentSourceUnit = unit;
|
fCurrentSourceUnit = unit;
|
||||||
fTextViewer = viewer;
|
fTextViewer = viewer;
|
||||||
|
|
||||||
ArrayList completions = new ArrayList();
|
final List completions = new Vector();
|
||||||
|
|
||||||
if (fCurrentSourceUnit == null)
|
if (fCurrentSourceUnit == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -328,11 +329,29 @@ public class CCompletionProcessor implements IContentAssistProcessor {
|
||||||
addProposalsFromSearch(fCurrentCompletionNode, completions);
|
addProposalsFromSearch(fCurrentCompletionNode, completions);
|
||||||
addProposalsFromCompletionContributors(fCurrentCompletionNode, completions);
|
addProposalsFromCompletionContributors(fCurrentCompletionNode, completions);
|
||||||
addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions);
|
addProposalsFromTemplates(viewer, fCurrentCompletionNode, completions);
|
||||||
|
removeRepeatedProposals(completions);
|
||||||
return order( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]));
|
return order( (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[0]));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes duplicated proposals.
|
||||||
|
* @param completions Completions to check.
|
||||||
|
*/
|
||||||
|
private void removeRepeatedProposals(List completions) {
|
||||||
|
final int size = completions.size();
|
||||||
|
final ICompletionProposal[] proposalsToCheck = (ICCompletionProposal[]) completions.toArray(new ICCompletionProposal[size]);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
for (int j = i + 1; j < size; j++) {
|
||||||
|
if (proposalsToCheck[i].equals(proposalsToCheck[j])) {
|
||||||
|
completions.remove(proposalsToCheck[j]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){
|
private void addProposalsFromTemplates(ITextViewer viewer, IASTCompletionNode completionNode, List completions){
|
||||||
if (completionNode == null)
|
if (completionNode == null)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue