mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Fix for 182294: Open Type should allow to open functions and variables
This commit is contained in:
parent
30322c916c
commit
1f5832d033
10 changed files with 579 additions and 225 deletions
|
@ -0,0 +1,333 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Wind River Systems, Inc. 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.browser.opentype;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
|
||||
import org.eclipse.jface.wizard.ProgressMonitorPart;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.dialogs.FilteredList;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.IndexTypeInfo;
|
||||
import org.eclipse.cdt.core.browser.QualifiedTypeName;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoMessages;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
|
||||
|
||||
import org.eclipse.cdt.internal.core.browser.util.IndexModelUtil;
|
||||
|
||||
/**
|
||||
* A dialog to select a element from a filterable list of elements.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ElementSelectionDialog extends TypeSelectionDialog {
|
||||
|
||||
/**
|
||||
* Job to update the element list in the background.
|
||||
*/
|
||||
private class UpdateElementsJob extends Job {
|
||||
|
||||
public UpdateElementsJob(String name) {
|
||||
super(name);
|
||||
setSystem(true);
|
||||
setUser(false);
|
||||
setPriority(Job.LONG);
|
||||
}
|
||||
|
||||
public IStatus run(final IProgressMonitor monitor) {
|
||||
monitor.beginTask(TypeInfoMessages.OpenSymbolDialog_UpdateSymbolsJob_inProgress, IProgressMonitor.UNKNOWN);
|
||||
final ITypeInfo[] elements= getElementsByPrefix(fCurrentPrefix, monitor);
|
||||
if (elements != null && !monitor.isCanceled()) {
|
||||
final Shell shell= getShell();
|
||||
if (shell != null && !shell.isDisposed()) {
|
||||
Runnable update= new Runnable() {
|
||||
public void run() {
|
||||
if (!shell.isDisposed() && !monitor.isCanceled()) {
|
||||
setListElements(elements);
|
||||
done(Status.OK_STATUS);
|
||||
updateOkState();
|
||||
}
|
||||
}};
|
||||
shell.getDisplay().asyncExec(update);
|
||||
monitor.done();
|
||||
return Job.ASYNC_FINISH;
|
||||
}
|
||||
}
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A job listener for simple job status reporting.
|
||||
*/
|
||||
private final class UpdateJobListener extends JobChangeAdapter {
|
||||
|
||||
boolean fDone;
|
||||
private IProgressMonitor fMonitor;
|
||||
|
||||
private UpdateJobListener(IProgressMonitor monitor) {
|
||||
fMonitor= monitor;
|
||||
}
|
||||
|
||||
public void done(IJobChangeEvent event) {
|
||||
fDone= true;
|
||||
final Shell shell= getShell();
|
||||
if (shell != null && !shell.isDisposed()) {
|
||||
Runnable update= new Runnable() {
|
||||
public void run() {
|
||||
if (!shell.isDisposed() && fDone) {
|
||||
fMonitor.done();
|
||||
}
|
||||
}};
|
||||
shell.getDisplay().asyncExec(update);
|
||||
}
|
||||
}
|
||||
|
||||
public void running(final IJobChangeEvent event) {
|
||||
fDone= false;
|
||||
final Shell shell= getShell();
|
||||
if (shell != null && !shell.isDisposed()) {
|
||||
Runnable update= new Runnable() {
|
||||
public void run() {
|
||||
if (!shell.isDisposed() && !fDone) {
|
||||
fMonitor.beginTask(TypeInfoMessages.OpenSymbolDialog_UpdateSymbolsJob_inProgress, IProgressMonitor.UNKNOWN);
|
||||
}
|
||||
}};
|
||||
shell.getDisplay().asyncExec(update);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final ISchedulingRule SINGLE_INSTANCE_RULE = new ISchedulingRule() {
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
return rule == this;
|
||||
}
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
return rule == this;
|
||||
}};
|
||||
|
||||
private char[] fCurrentPrefix= {};
|
||||
private Job fUpdateJob;
|
||||
private boolean fAllowEmptyPrefix;
|
||||
private ProgressMonitorPart fProgressMonitorPart;
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>OpenTypeDialog</code>.
|
||||
* @param parent the parent shell.
|
||||
*/
|
||||
public ElementSelectionDialog(Shell parent) {
|
||||
super(parent);
|
||||
fUpdateJob= new UpdateElementsJob(TypeInfoMessages.OpenSymbolDialog_UpdateSymbolsJob_name);
|
||||
fUpdateJob.setRule(SINGLE_INSTANCE_RULE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#create()
|
||||
*/
|
||||
public void create() {
|
||||
super.create();
|
||||
// trigger initial query
|
||||
scheduleUpdate(getFilter());
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#close()
|
||||
*/
|
||||
public boolean close() {
|
||||
fUpdateJob.cancel();
|
||||
return super.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#setMatchEmptyString(boolean)
|
||||
*/
|
||||
public void setMatchEmptyString(boolean matchEmptyString) {
|
||||
super.setMatchEmptyString(matchEmptyString);
|
||||
setAllowEmptyPrefix(matchEmptyString);
|
||||
}
|
||||
/**
|
||||
* Set whether an empty prefix should be allowed for queries.
|
||||
*
|
||||
* @param allowEmptyPrefix
|
||||
*/
|
||||
public void setAllowEmptyPrefix(boolean allowEmptyPrefix) {
|
||||
fAllowEmptyPrefix = allowEmptyPrefix;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#showLowLevelFilter()
|
||||
*/
|
||||
protected boolean showLowLevelFilter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#createFilteredList(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected FilteredList createFilteredList(Composite parent) {
|
||||
FilteredList list= super.createFilteredList(parent);
|
||||
createProgressMonitorPart(parent);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the control for progress reporting.
|
||||
* @param parent
|
||||
*/
|
||||
private void createProgressMonitorPart(Composite parent) {
|
||||
fProgressMonitorPart= new ProgressMonitorPart(parent, new GridLayout(2, false));
|
||||
GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
|
||||
gridData.horizontalIndent= 0;
|
||||
gridData.verticalAlignment= GridData.BEGINNING;
|
||||
fProgressMonitorPart.setLayoutData(gridData);
|
||||
fUpdateJob.addJobChangeListener(new UpdateJobListener(fProgressMonitorPart));
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the elements for the given prefix.
|
||||
*
|
||||
* @param prefix
|
||||
* @param monitor
|
||||
*/
|
||||
protected ITypeInfo[] getElementsByPrefix(char[] prefix, IProgressMonitor monitor) {
|
||||
if (monitor.isCanceled()) {
|
||||
return null;
|
||||
}
|
||||
List types = new ArrayList();
|
||||
if(prefix.length > 0 || fAllowEmptyPrefix) {
|
||||
try {
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
|
||||
try {
|
||||
index.acquireReadLock();
|
||||
IBinding[] bindings= index.findBindingsForPrefix(prefix, false, IndexFilter.ALL);
|
||||
// IBinding[] bindings= index.findBindingsForPrefix(prefix, false, IndexFilter.ALL, monitor);
|
||||
for(int i=0; i<bindings.length; i++) {
|
||||
if ((i % 100) == 0 && monitor.isCanceled()) {
|
||||
return null;
|
||||
}
|
||||
IBinding binding = bindings[i];
|
||||
try {
|
||||
String[] fqn;
|
||||
|
||||
if(binding instanceof ICPPBinding) {
|
||||
fqn= ((ICPPBinding)binding).getQualifiedName();
|
||||
} else {
|
||||
fqn = new String[] {binding.getName()};
|
||||
}
|
||||
final int elementType = IndexModelUtil.getElementType(binding);
|
||||
if (isVisibleType(elementType)) {
|
||||
if (binding instanceof IFunction) {
|
||||
final IFunction function = (IFunction)binding;
|
||||
final String[] paramTypes = IndexModelUtil.extractParameterTypes(function);
|
||||
final String returnType= IndexModelUtil.extractReturnType(function);
|
||||
types.add(new IndexTypeInfo(fqn, elementType, paramTypes, returnType, index));
|
||||
} else {
|
||||
types.add(new IndexTypeInfo(fqn, elementType, index));
|
||||
}
|
||||
}
|
||||
} catch(DOMException de) {
|
||||
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
} catch(InterruptedException ie) {
|
||||
CCorePlugin.log(ie);
|
||||
}
|
||||
}
|
||||
return (ITypeInfo[])types.toArray(new ITypeInfo[types.size()]);
|
||||
}
|
||||
|
||||
protected final void setListElements(Object[] elements) {
|
||||
super.setListElements(elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Unsupported
|
||||
*/
|
||||
public void setElements(Object[] elements) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
protected void handleEmptyList() {
|
||||
updateOkState();
|
||||
}
|
||||
|
||||
protected Text createFilterText(Composite parent) {
|
||||
final Text result = super.createFilterText(parent);
|
||||
Listener listener = new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
scheduleUpdate(result.getText());
|
||||
}
|
||||
};
|
||||
result.addListener(SWT.Modify, listener);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void scheduleUpdate(String filterText) {
|
||||
char[] newPrefix= toPrefix(filterText);
|
||||
if (!isEquivalentPrefix(fCurrentPrefix, newPrefix)) {
|
||||
fUpdateJob.cancel();
|
||||
fCurrentPrefix= newPrefix;
|
||||
fUpdateJob.schedule(200);
|
||||
}
|
||||
}
|
||||
|
||||
private char[] toPrefix(String userFilter) {
|
||||
QualifiedTypeName qualifiedName= new QualifiedTypeName(userFilter);
|
||||
if (qualifiedName.segmentCount() > 1) {
|
||||
userFilter= qualifiedName.lastSegment();
|
||||
}
|
||||
userFilter= userFilter.trim().replaceAll("^(\\*)*", ""); //$NON-NLS-1$//$NON-NLS-2$
|
||||
int asterix= userFilter.indexOf("*"); //$NON-NLS-1$
|
||||
return (asterix==-1 ? userFilter : userFilter.substring(0, asterix)).toCharArray();
|
||||
}
|
||||
|
||||
private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) {
|
||||
if (currentPrefix.length == 0 || currentPrefix.length > newPrefix.length) {
|
||||
return false;
|
||||
} else if (newPrefix.length == currentPrefix.length) {
|
||||
return Arrays.equals(currentPrefix, newPrefix);
|
||||
}
|
||||
return new String(currentPrefix).equals(new String(newPrefix, 0, currentPrefix.length));
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2007 QNX Software Systems 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
|
||||
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.browser.opentype;
|
||||
|
||||
|
@ -48,7 +49,7 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
|
|||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void run(IAction action) {
|
||||
OpenTypeDialog dialog = new OpenTypeDialog(getShell());
|
||||
ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
|
||||
configureDialog(dialog);
|
||||
int result = dialog.open();
|
||||
if (result != IDialogConstants.OK_ID)
|
||||
|
@ -72,7 +73,9 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private void configureDialog(OpenTypeDialog dialog) {
|
||||
private void configureDialog(ElementSelectionDialog dialog) {
|
||||
dialog.setTitle(OpenTypeMessages.getString("OpenTypeDialog.title")); //$NON-NLS-1$
|
||||
dialog.setMessage(OpenTypeMessages.getString("OpenTypeDialog.message")); //$NON-NLS-1$
|
||||
dialog.setDialogSettings(getClass().getName());
|
||||
if (fWorkbenchWindow != null) {
|
||||
IWorkbenchPage page= fWorkbenchWindow.getActivePage();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 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
|
||||
|
@ -9,40 +9,19 @@
|
|||
* IBM Corporation - initial API and implementation
|
||||
* QNX Software Systems - adapted for use in CDT
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.browser.opentype;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.IndexTypeInfo;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
|
||||
|
||||
import org.eclipse.cdt.internal.core.browser.util.IndexModelUtil;
|
||||
|
||||
/**
|
||||
* A dialog to select a type from a list of types. The selected type will be
|
||||
* opened in the editor.
|
||||
* A dialog to select a type from a list of types.
|
||||
*
|
||||
* @deprecated Use {@link ElementSelectionDialog} instead.
|
||||
*/
|
||||
public class OpenTypeDialog extends TypeSelectionDialog {
|
||||
|
||||
private static final String DIALOG_SETTINGS= OpenTypeDialog.class.getName();
|
||||
public class OpenTypeDialog extends ElementSelectionDialog {
|
||||
|
||||
/**
|
||||
* Constructs an instance of <code>OpenTypeDialog</code>.
|
||||
|
@ -50,83 +29,5 @@ public class OpenTypeDialog extends TypeSelectionDialog {
|
|||
*/
|
||||
public OpenTypeDialog(Shell parent) {
|
||||
super(parent);
|
||||
setTitle(OpenTypeMessages.getString("OpenTypeDialog.title")); //$NON-NLS-1$
|
||||
setMessage(OpenTypeMessages.getString("OpenTypeDialog.message")); //$NON-NLS-1$
|
||||
setDialogSettings(DIALOG_SETTINGS);
|
||||
|
||||
}
|
||||
|
||||
|
||||
char[] toPrefix(String userFilter) {
|
||||
userFilter= userFilter.trim().replaceAll("^(\\*)*", ""); //$NON-NLS-1$//$NON-NLS-2$
|
||||
int asterix= userFilter.indexOf("*"); //$NON-NLS-1$
|
||||
return (asterix==-1 ? userFilter : userFilter.substring(0, asterix)).toCharArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the list of elements in AbstractElementListSelectionDialog
|
||||
*
|
||||
* Filtering on wildcards and types is done by the superclass - we just provide
|
||||
* a good starting point
|
||||
* @param userFilter
|
||||
*/
|
||||
public void update(String userFilter) {
|
||||
char[] prefix = toPrefix(userFilter);
|
||||
List types = new ArrayList();
|
||||
if(prefix.length>0)
|
||||
try {
|
||||
IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
|
||||
try {
|
||||
index.acquireReadLock();
|
||||
IBinding[] bindings= index.findBindingsForPrefix(prefix, false, IndexFilter.ALL);
|
||||
for(int i=0; i<bindings.length; i++) {
|
||||
IBinding binding = bindings[i];
|
||||
try {
|
||||
String[] fqn;
|
||||
|
||||
if(binding instanceof ICPPBinding) {
|
||||
fqn= ((ICPPBinding)binding).getQualifiedName();
|
||||
} else {
|
||||
fqn = new String[] {binding.getName()};
|
||||
}
|
||||
types.add(new IndexTypeInfo(fqn, IndexModelUtil.getElementType(binding), index));
|
||||
} catch(DOMException de) {
|
||||
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
} catch(InterruptedException ie) {
|
||||
CCorePlugin.log(ie);
|
||||
}
|
||||
setListElements(types.toArray(new ITypeInfo[types.size()]));
|
||||
}
|
||||
|
||||
protected void setListElements(Object[] elements) {
|
||||
super.setListElements(elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public void setElements(Object[] elements) {
|
||||
}
|
||||
|
||||
protected void handleEmptyList() {
|
||||
update(getFilter());
|
||||
}
|
||||
|
||||
protected Text createFilterText(Composite parent) {
|
||||
final Text result = super.createFilterText(parent);
|
||||
Listener listener = new Listener() {
|
||||
public void handleEvent(Event e) {
|
||||
update(result.getText());
|
||||
}
|
||||
};
|
||||
result.addListener(SWT.Modify, listener);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,19 +7,20 @@
|
|||
#
|
||||
# Contributors:
|
||||
# QNX Software Systems - Initial API and implementation
|
||||
# Anton Leherbauer (Wind River Systems)
|
||||
###############################################################################
|
||||
|
||||
OpenTypeAction.exception.title=Exception
|
||||
OpenTypeAction.exception.message=Unexpected exception. See log for details.
|
||||
OpenTypeAction.notypes.title=Type Selection
|
||||
OpenTypeAction.notypes.message=No types available.
|
||||
OpenTypeAction.description=Open a type in the editor
|
||||
OpenTypeAction.tooltip=Open a Type
|
||||
OpenTypeAction.label=Open Type...
|
||||
OpenTypeAction.errorTitle=Open Type
|
||||
OpenTypeAction.notypes.title=Element Selection
|
||||
OpenTypeAction.notypes.message=No elements available.
|
||||
OpenTypeAction.description=Open an element in an Editor
|
||||
OpenTypeAction.tooltip=Open an Element
|
||||
OpenTypeAction.label=Open Element...
|
||||
OpenTypeAction.errorTitle=Open Element
|
||||
OpenTypeAction.errorOpenEditor=Error opening editor for file \"{0}\"
|
||||
OpenTypeAction.errorTypeNotFound=Could not locate definition of type \"{0}\"
|
||||
OpenTypeAction.errorTypeNotFound=Could not locate definition of element \"{0}\"
|
||||
|
||||
OpenTypeDialog.title=Open Type
|
||||
OpenTypeDialog.message=&Choose a type (? = any character, * = any string):
|
||||
OpenTypeDialog.title=Open Element
|
||||
OpenTypeDialog.message=&Choose an element (? = any character, * = any string):
|
||||
OpenTypeDialog.filter=
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2007 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
|
||||
|
@ -9,6 +9,7 @@
|
|||
* IBM Corporation - initial API and implementation
|
||||
* QNX Software Systems - adapted for use in CDT
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.browser.typeinfo;
|
||||
|
||||
|
@ -17,21 +18,28 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
import org.eclipse.cdt.core.browser.IFunctionInfo;
|
||||
import org.eclipse.cdt.core.browser.IQualifiedTypeName;
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.ITypeReference;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||
|
||||
import org.eclipse.cdt.internal.core.model.FunctionDeclaration;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
|
||||
public class TypeInfoLabelProvider extends LabelProvider {
|
||||
|
||||
public static final int SHOW_TYPE_ONLY= 0x01;
|
||||
public static final int SHOW_NAME_ONLY= 0x01;
|
||||
public static final int SHOW_ENCLOSING_TYPE_ONLY= 0x02;
|
||||
public static final int SHOW_FULLY_QUALIFIED= 0x04;
|
||||
public static final int SHOW_PATH= 0x08;
|
||||
public static final int SHOW_PARAMETERS= 0x10;
|
||||
public static final int SHOW_RETURN_TYPE= 0x20;
|
||||
|
||||
private static final Image HEADER_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT_HEADER);
|
||||
private static final Image SOURCE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT);
|
||||
|
@ -42,6 +50,8 @@ public class TypeInfoLabelProvider extends LabelProvider {
|
|||
private static final Image TYPEDEF_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TYPEDEF);
|
||||
private static final Image UNION_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_UNION);
|
||||
private static final Image ENUM_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_ENUMERATION);
|
||||
private static final Image FUNCTION_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_FUNCTION);
|
||||
private static final Image VARIABLE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_VARIABLE);
|
||||
private static final Image UNKNOWN_TYPE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_UNKNOWN_TYPE);
|
||||
|
||||
private int fFlags;
|
||||
|
@ -61,12 +71,12 @@ public class TypeInfoLabelProvider extends LabelProvider {
|
|||
if (! (element instanceof ITypeInfo))
|
||||
return super.getText(element);
|
||||
|
||||
ITypeInfo typeRef= (ITypeInfo) element;
|
||||
IQualifiedTypeName qualifiedName = typeRef.getQualifiedTypeName();
|
||||
ITypeInfo typeInfo= (ITypeInfo) element;
|
||||
IQualifiedTypeName qualifiedName = typeInfo.getQualifiedTypeName();
|
||||
|
||||
StringBuffer buf= new StringBuffer();
|
||||
if (isSet(SHOW_TYPE_ONLY)) {
|
||||
String name= typeRef.getName();
|
||||
if (isSet(SHOW_NAME_ONLY)) {
|
||||
String name= typeInfo.getName();
|
||||
if (name != null && name.length() > 0)
|
||||
buf.append(name);
|
||||
} else if (isSet(SHOW_ENCLOSING_TYPE_ONLY)) {
|
||||
|
@ -74,25 +84,68 @@ public class TypeInfoLabelProvider extends LabelProvider {
|
|||
if (parentName != null) {
|
||||
buf.append(parentName.getFullyQualifiedName());
|
||||
} else {
|
||||
buf.append(TypeInfoMessages.getString("TypeInfoLabelProvider.globalScope")); //$NON-NLS-1$
|
||||
buf.append(TypeInfoMessages.TypeInfoLabelProvider_globalScope);
|
||||
}
|
||||
} else if (isSet(SHOW_FULLY_QUALIFIED)) {
|
||||
if (qualifiedName.isGlobal()) {
|
||||
buf.append(TypeInfoMessages.TypeInfoLabelProvider_globalScope);
|
||||
buf.append(' ');
|
||||
}
|
||||
buf.append(qualifiedName.getFullyQualifiedName());
|
||||
}
|
||||
|
||||
if (isSet(SHOW_PARAMETERS) && typeInfo.getCElementType() == ICElement.C_FUNCTION) {
|
||||
if (typeInfo instanceof IFunctionInfo) {
|
||||
IFunctionInfo functionInfo= (IFunctionInfo)typeInfo;
|
||||
String[] params= functionInfo.getParameters();
|
||||
if (params != null) {
|
||||
buf.append(FunctionDeclaration.getParameterClause(params));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSet(SHOW_RETURN_TYPE)) {
|
||||
switch(typeInfo.getCElementType()) {
|
||||
case ICElement.C_FUNCTION:
|
||||
if (typeInfo instanceof IFunctionInfo) {
|
||||
IFunctionInfo functionInfo= (IFunctionInfo)typeInfo;
|
||||
String returnType= functionInfo.getReturnType();
|
||||
if (returnType != null && returnType.length() > 0) {
|
||||
buf.append(TypeInfoMessages.TypeInfoLabelProvider_colon);
|
||||
buf.append(returnType);
|
||||
}
|
||||
}
|
||||
case ICElement.C_VARIABLE:
|
||||
ITypeReference ref= typeInfo.getResolvedReference();
|
||||
if (ref != null) {
|
||||
ICElement[] cElements= ref.getCElements();
|
||||
if (cElements != null && cElements.length > 0) {
|
||||
String returnType= null;
|
||||
if (cElements[0] instanceof IVariableDeclaration) {
|
||||
try {
|
||||
returnType= ((IVariableDeclaration)cElements[0]).getTypeName();
|
||||
} catch (CModelException exc) {
|
||||
}
|
||||
}
|
||||
if (returnType != null && returnType.length() > 0) {
|
||||
buf.append(TypeInfoMessages.TypeInfoLabelProvider_colon);
|
||||
buf.append(returnType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSet(SHOW_PATH)) {
|
||||
IPath path = null;
|
||||
ITypeReference ref = typeRef.getResolvedReference();
|
||||
ITypeReference ref = typeInfo.getResolvedReference();
|
||||
if (ref != null) {
|
||||
path = ref.getPath();
|
||||
} else {
|
||||
ICProject project = typeRef.getEnclosingProject();
|
||||
ICProject project = typeInfo.getEnclosingProject();
|
||||
if (project != null) {
|
||||
path = project.getProject().getFullPath();
|
||||
}
|
||||
}
|
||||
if (path != null) {
|
||||
buf.append(TypeInfoMessages.getString("TypeInfoLabelProvider.dash"));//$NON-NLS-1$
|
||||
buf.append(TypeInfoMessages.TypeInfoLabelProvider_dash);
|
||||
buf.append(path.toString());
|
||||
}
|
||||
}
|
||||
|
@ -156,6 +209,12 @@ public class TypeInfoLabelProvider extends LabelProvider {
|
|||
case ICElement.C_TYPEDEF:
|
||||
return TYPEDEF_ICON;
|
||||
|
||||
case ICElement.C_FUNCTION:
|
||||
return FUNCTION_ICON;
|
||||
|
||||
case ICElement.C_VARIABLE:
|
||||
return VARIABLE_ICON;
|
||||
|
||||
default:
|
||||
return UNKNOWN_TYPE_ICON;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2006 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2007 QNX Software Systems 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
|
||||
|
@ -7,44 +7,40 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.browser.typeinfo;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class TypeInfoMessages {
|
||||
public final class TypeInfoMessages extends NLS {
|
||||
|
||||
private static final String RESOURCE_BUNDLE= TypeInfoMessages.class.getName();
|
||||
|
||||
private static ResourceBundle fgResourceBundle;
|
||||
static {
|
||||
try {
|
||||
fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||
} catch (MissingResourceException x) {
|
||||
fgResourceBundle = null;
|
||||
}
|
||||
}
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.browser.typeinfo.TypeInfoMessages";//$NON-NLS-1$
|
||||
|
||||
private TypeInfoMessages() {
|
||||
// Do not instantiate
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
try {
|
||||
return fgResourceBundle.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return '!' + key + '!';
|
||||
} catch (NullPointerException e) {
|
||||
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
public static String OpenSymbolDialog_UpdateSymbolsJob_name;
|
||||
public static String OpenSymbolDialog_UpdateSymbolsJob_inProgress;
|
||||
public static String TypeSelectionDialog_lowerLabel;
|
||||
public static String TypeSelectionDialog_upperLabel;
|
||||
public static String TypeSelectionDialog_filterLabel;
|
||||
public static String TypeSelectionDialog_filterNamespaces;
|
||||
public static String TypeSelectionDialog_filterClasses;
|
||||
public static String TypeSelectionDialog_filterStructs;
|
||||
public static String TypeSelectionDialog_filterTypedefs;
|
||||
public static String TypeSelectionDialog_filterEnums;
|
||||
public static String TypeSelectionDialog_filterUnions;
|
||||
public static String TypeSelectionDialog_filterFunctions;
|
||||
public static String TypeSelectionDialog_filterVariables;
|
||||
public static String TypeSelectionDialog_filterLowLevelTypes;
|
||||
public static String TypeInfoLabelProvider_default_filename;
|
||||
public static String TypeInfoLabelProvider_globalScope;
|
||||
public static String TypeInfoLabelProvider_dash;
|
||||
public static String TypeInfoLabelProvider_colon;
|
||||
|
||||
static {
|
||||
NLS.initializeMessages(BUNDLE_NAME, TypeInfoMessages.class);
|
||||
}
|
||||
|
||||
public static String getFormattedString(String key, String arg) {
|
||||
return getFormattedString(key, new String[] { arg });
|
||||
}
|
||||
|
||||
public static String getFormattedString(String key, String[] args) {
|
||||
return MessageFormat.format(getString(key), args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,19 +7,26 @@
|
|||
#
|
||||
# Contributors:
|
||||
# QNX Software Systems - Initial API and implementation
|
||||
# Anton Leherbauer (Wind River Systems)
|
||||
###############################################################################
|
||||
|
||||
TypeSelectionDialog.lowerLabel=&Qualifier:
|
||||
TypeSelectionDialog.upperLabel=&Matching types:
|
||||
TypeSelectionDialog.filterLabel=Visible types:
|
||||
TypeSelectionDialog.filterNamespaces=namespace
|
||||
TypeSelectionDialog.filterClasses=class
|
||||
TypeSelectionDialog.filterStructs=struct
|
||||
TypeSelectionDialog.filterTypedefs=typedef
|
||||
TypeSelectionDialog.filterEnums=enum
|
||||
TypeSelectionDialog.filterUnions=union
|
||||
TypeSelectionDialog.filterLowLevelTypes=Show low-level types
|
||||
TypeSelectionDialog_lowerLabel=&Qualified name and location:
|
||||
TypeSelectionDialog_upperLabel=&Matching elements:
|
||||
TypeSelectionDialog_filterLabel=Visible element types:
|
||||
TypeSelectionDialog_filterNamespaces=&Namespace
|
||||
TypeSelectionDialog_filterClasses=&Class
|
||||
TypeSelectionDialog_filterStructs=&Struct
|
||||
TypeSelectionDialog_filterTypedefs=&Typedef
|
||||
TypeSelectionDialog_filterEnums=&Enumeration
|
||||
TypeSelectionDialog_filterUnions=&Union
|
||||
TypeSelectionDialog_filterFunctions=&Function
|
||||
TypeSelectionDialog_filterVariables=&Variable
|
||||
TypeSelectionDialog_filterLowLevelTypes=Show &low-level elements (names beginning with '_')
|
||||
|
||||
TypeInfoLabelProvider.default_filename=default
|
||||
TypeInfoLabelProvider.globalScope=(global)
|
||||
TypeInfoLabelProvider.dash=\ -
|
||||
TypeInfoLabelProvider_default_filename=default
|
||||
TypeInfoLabelProvider_globalScope=(global)
|
||||
TypeInfoLabelProvider_dash=\ -\
|
||||
TypeInfoLabelProvider_colon=:\
|
||||
|
||||
OpenSymbolDialog_UpdateSymbolsJob_name=Updating Element List
|
||||
OpenSymbolDialog_UpdateSymbolsJob_inProgress=Updating Element List...
|
|
@ -9,6 +9,7 @@
|
|||
* IBM Corporation - initial API and implementation
|
||||
* QNX Software Systems - adapted for use in CDT
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui.browser.typeinfo;
|
||||
|
||||
|
@ -202,20 +203,26 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
private static final String SETTINGS_SHOW_TYPEDEFS = "show_typedefs"; //$NON-NLS-1$
|
||||
private static final String SETTINGS_SHOW_ENUMS = "show_enums"; //$NON-NLS-1$
|
||||
private static final String SETTINGS_SHOW_UNIONS = "show_unions"; //$NON-NLS-1$
|
||||
private static final String SETTINGS_SHOW_FUNCTIONS = "show_functions"; //$NON-NLS-1$
|
||||
private static final String SETTINGS_SHOW_VARIABLES = "show_variables"; //$NON-NLS-1$
|
||||
private static final String SETTINGS_SHOW_LOWLEVEL = "show_lowlevel"; //$NON-NLS-1$
|
||||
|
||||
private static final TypeInfoLabelProvider fElementRenderer = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY);
|
||||
private static final TypeInfoLabelProvider fQualifierRenderer = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_ENCLOSING_TYPE_ONLY + TypeInfoLabelProvider.SHOW_PATH);
|
||||
private static final TypeInfoLabelProvider fElementRenderer = new TypeInfoLabelProvider(
|
||||
TypeInfoLabelProvider.SHOW_NAME_ONLY);
|
||||
private static final TypeInfoLabelProvider fQualifierRenderer = new TypeInfoLabelProvider(
|
||||
TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED |
|
||||
TypeInfoLabelProvider.SHOW_PARAMETERS |
|
||||
TypeInfoLabelProvider.SHOW_PATH);
|
||||
|
||||
private static final StringComparator fStringComparator = new StringComparator();
|
||||
|
||||
private static final int[] fAllTypes = { ICElement.C_NAMESPACE, ICElement.C_CLASS,
|
||||
private static final int[] ALL_TYPES = { ICElement.C_NAMESPACE, ICElement.C_CLASS,
|
||||
ICElement.C_STRUCT, ICElement.C_TYPEDEF, ICElement.C_ENUMERATION,
|
||||
ICElement.C_UNION };
|
||||
ICElement.C_UNION, ICElement.C_FUNCTION, ICElement.C_VARIABLE };
|
||||
|
||||
// the filter matcher contains state information, must not be static
|
||||
private final TypeFilterMatcher fFilterMatcher = new TypeFilterMatcher();
|
||||
private Set fKnownTypes = new HashSet(fAllTypes.length);
|
||||
private Set fKnownTypes = new HashSet(ALL_TYPES.length);
|
||||
private Text fTextWidget;
|
||||
private boolean fSelectFilterText = false;
|
||||
private FilteredList fNewFilteredList;
|
||||
|
@ -230,9 +237,9 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
public TypeSelectionDialog(Shell parent) {
|
||||
super(parent, fElementRenderer, fQualifierRenderer);
|
||||
setMatchEmptyString(false);
|
||||
setUpperListLabel(TypeInfoMessages.getString("TypeSelectionDialog.upperLabel")); //$NON-NLS-1$
|
||||
setLowerListLabel(TypeInfoMessages.getString("TypeSelectionDialog.lowerLabel")); //$NON-NLS-1$
|
||||
setVisibleTypes(fAllTypes);
|
||||
setUpperListLabel(TypeInfoMessages.TypeSelectionDialog_upperLabel);
|
||||
setLowerListLabel(TypeInfoMessages.TypeSelectionDialog_lowerLabel);
|
||||
setVisibleTypes(ALL_TYPES);
|
||||
setDialogSettings(DIALOG_SETTINGS);
|
||||
}
|
||||
|
||||
|
@ -259,6 +266,18 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Answer whether the given type is visible in the dialog.
|
||||
*
|
||||
* @param type
|
||||
* the type constant, see {@link ICElement}
|
||||
* @return <code>true</code> if the given type is visible,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
protected boolean isVisibleType(int type) {
|
||||
return fKnownTypes.contains(new Integer(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets section name to use when storing the dialog settings.
|
||||
*
|
||||
|
@ -295,8 +314,8 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
*/
|
||||
public void create() {
|
||||
super.create();
|
||||
if (!fSelectFilterText)
|
||||
fTextWidget.setSelection(0,0);
|
||||
if (fSelectFilterText)
|
||||
fTextWidget.selectAll();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -323,22 +342,28 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
int type = typeObject.intValue();
|
||||
switch (type) {
|
||||
case ICElement.C_NAMESPACE:
|
||||
name = TypeInfoMessages.getString("TypeSelectionDialog.filterNamespaces"); //$NON-NLS-1$
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterNamespaces;
|
||||
break;
|
||||
case ICElement.C_CLASS:
|
||||
name = TypeInfoMessages.getString("TypeSelectionDialog.filterClasses"); //$NON-NLS-1$
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterClasses;
|
||||
break;
|
||||
case ICElement.C_STRUCT:
|
||||
name = TypeInfoMessages.getString("TypeSelectionDialog.filterStructs"); //$NON-NLS-1$
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterStructs;
|
||||
break;
|
||||
case ICElement.C_TYPEDEF:
|
||||
name = TypeInfoMessages.getString("TypeSelectionDialog.filterTypedefs"); //$NON-NLS-1$
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterTypedefs;
|
||||
break;
|
||||
case ICElement.C_ENUMERATION:
|
||||
name = TypeInfoMessages.getString("TypeSelectionDialog.filterEnums"); //$NON-NLS-1$
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterEnums;
|
||||
break;
|
||||
case ICElement.C_UNION:
|
||||
name = TypeInfoMessages.getString("TypeSelectionDialog.filterUnions"); //$NON-NLS-1$
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterUnions;
|
||||
break;
|
||||
case ICElement.C_FUNCTION:
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterFunctions;
|
||||
break;
|
||||
case ICElement.C_VARIABLE:
|
||||
name = TypeInfoMessages.TypeSelectionDialog_filterVariables;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
@ -379,10 +404,11 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
* @param parent area to create controls in
|
||||
*/
|
||||
private void createTypeFilterArea(Composite parent) {
|
||||
createLabel(parent, TypeInfoMessages.getString("TypeSelectionDialog.filterLabel")); //$NON-NLS-1$
|
||||
createLabel(parent, TypeInfoMessages.TypeSelectionDialog_filterLabel);
|
||||
|
||||
Composite upperRow = new Composite(parent, SWT.NONE);
|
||||
GridLayout upperLayout = new GridLayout(3, true);
|
||||
int columns= fKnownTypes.size() > 6 ? 4 : 3;
|
||||
GridLayout upperLayout = new GridLayout(columns, true);
|
||||
upperLayout.verticalSpacing = 2;
|
||||
upperLayout.marginHeight = 0;
|
||||
upperLayout.marginWidth = 0;
|
||||
|
@ -390,39 +416,41 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
|
||||
// the for loop is here to guarantee we always
|
||||
// create the checkboxes in the same order
|
||||
for (int i = 0; i < fAllTypes.length; ++i) {
|
||||
Integer typeObject = new Integer(fAllTypes[i]);
|
||||
for (int i = 0; i < ALL_TYPES.length; ++i) {
|
||||
Integer typeObject = new Integer(ALL_TYPES[i]);
|
||||
if (fKnownTypes.contains(typeObject))
|
||||
createTypeCheckbox(upperRow, typeObject);
|
||||
}
|
||||
|
||||
Composite lowerRow = new Composite(parent, SWT.NONE);
|
||||
GridLayout lowerLayout = new GridLayout(1, true);
|
||||
lowerLayout.verticalSpacing = 2;
|
||||
lowerLayout.marginHeight = 0;
|
||||
upperLayout.marginWidth = 0;
|
||||
lowerRow.setLayout(lowerLayout);
|
||||
if (showLowLevelFilter()) {
|
||||
Composite lowerRow = new Composite(parent, SWT.NONE);
|
||||
GridLayout lowerLayout = new GridLayout(1, true);
|
||||
lowerLayout.verticalSpacing = 2;
|
||||
lowerLayout.marginHeight = 0;
|
||||
upperLayout.marginWidth = 0;
|
||||
lowerRow.setLayout(lowerLayout);
|
||||
|
||||
Composite composite = new Composite(lowerRow, SWT.NONE);
|
||||
GridLayout layout= new GridLayout(2, false);
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
composite.setLayout(layout);
|
||||
Composite composite = new Composite(lowerRow, SWT.NONE);
|
||||
GridLayout layout= new GridLayout(2, false);
|
||||
layout.marginHeight = 0;
|
||||
layout.marginWidth = 0;
|
||||
composite.setLayout(layout);
|
||||
|
||||
String name = TypeInfoMessages.getString("TypeSelectionDialog.filterLowLevelTypes"); //$NON-NLS-1$
|
||||
Button checkbox = new Button(composite, SWT.CHECK);
|
||||
checkbox.setFont(composite.getFont());
|
||||
checkbox.setText(name);
|
||||
checkbox.setSelection(fFilterMatcher.getShowLowLevelTypes());
|
||||
checkbox.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (e.widget instanceof Button) {
|
||||
Button button = (Button) e.widget;
|
||||
fFilterMatcher.setShowLowLevelTypes(button.getSelection());
|
||||
updateElements();
|
||||
String name = TypeInfoMessages.TypeSelectionDialog_filterLowLevelTypes;
|
||||
Button checkbox = new Button(composite, SWT.CHECK);
|
||||
checkbox.setFont(composite.getFont());
|
||||
checkbox.setText(name);
|
||||
checkbox.setSelection(fFilterMatcher.getShowLowLevelTypes());
|
||||
checkbox.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (e.widget instanceof Button) {
|
||||
Button button = (Button) e.widget;
|
||||
fFilterMatcher.setShowLowLevelTypes(button.getSelection());
|
||||
updateElements();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -466,6 +494,8 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
section.put(SETTINGS_SHOW_TYPEDEFS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_TYPEDEF)));
|
||||
section.put(SETTINGS_SHOW_ENUMS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_ENUMERATION)));
|
||||
section.put(SETTINGS_SHOW_UNIONS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_UNION)));
|
||||
section.put(SETTINGS_SHOW_FUNCTIONS, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_FUNCTION)));
|
||||
section.put(SETTINGS_SHOW_VARIABLES, fFilterMatcher.getVisibleTypes().contains(new Integer(ICElement.C_VARIABLE)));
|
||||
section.put(SETTINGS_SHOW_LOWLEVEL, fFilterMatcher.getShowLowLevelTypes());
|
||||
}
|
||||
|
||||
|
@ -479,6 +509,8 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
section.put(SETTINGS_SHOW_TYPEDEFS, true);
|
||||
section.put(SETTINGS_SHOW_ENUMS, true);
|
||||
section.put(SETTINGS_SHOW_UNIONS, true);
|
||||
section.put(SETTINGS_SHOW_FUNCTIONS, true);
|
||||
section.put(SETTINGS_SHOW_VARIABLES, true);
|
||||
section.put(SETTINGS_SHOW_LOWLEVEL, false);
|
||||
}
|
||||
|
||||
|
@ -529,9 +561,30 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
|
|||
if (fKnownTypes.contains(typeObject))
|
||||
fFilterMatcher.getVisibleTypes().add(typeObject);
|
||||
}
|
||||
fFilterMatcher.setShowLowLevelTypes(section.getBoolean(SETTINGS_SHOW_LOWLEVEL));
|
||||
if (section.getBoolean(SETTINGS_SHOW_FUNCTIONS)) {
|
||||
Integer typeObject = new Integer(ICElement.C_FUNCTION);
|
||||
if (fKnownTypes.contains(typeObject))
|
||||
fFilterMatcher.getVisibleTypes().add(typeObject);
|
||||
}
|
||||
if (section.getBoolean(SETTINGS_SHOW_VARIABLES)) {
|
||||
Integer typeObject = new Integer(ICElement.C_VARIABLE);
|
||||
if (fKnownTypes.contains(typeObject))
|
||||
fFilterMatcher.getVisibleTypes().add(typeObject);
|
||||
}
|
||||
if (showLowLevelFilter()) {
|
||||
fFilterMatcher.setShowLowLevelTypes(section.getBoolean(SETTINGS_SHOW_LOWLEVEL));
|
||||
} else {
|
||||
fFilterMatcher.setShowLowLevelTypes(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether the low level filter checkbox should be shown
|
||||
*/
|
||||
protected boolean showLowLevelFilter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* (non-Cdoc)
|
||||
* @see org.eclipse.jface.window.Window#getInitialSize()
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
# Contributors:
|
||||
# IBM Corporation - initial API and implementation
|
||||
# Markus Schorn (Wind River Systems)
|
||||
# Anton Leherbauer (Wind River Systems)
|
||||
###############################################################################
|
||||
pluginName=C/C++ Development Tools UI
|
||||
providerName=Eclipse.org
|
||||
|
@ -192,11 +193,11 @@ CEditorPresentationActionSet.description=Actions to customize the C/C++ editor p
|
|||
searchMenu.label= Se&arch
|
||||
refactoringMenu.label= Re&factor
|
||||
|
||||
# Open Type
|
||||
OpenTypeAction.label= Open &Type...
|
||||
OpenTypeAction.tooltip= Open Type
|
||||
ActionDefinition.openType.name= Open Type
|
||||
ActionDefinition.openType.description= Open a type in a C editor
|
||||
# Open Element
|
||||
OpenTypeAction.label= Open &Element...
|
||||
OpenTypeAction.tooltip= Open Element
|
||||
ActionDefinition.openType.name= Open Element
|
||||
ActionDefinition.openType.description= Open an element in an Editor
|
||||
|
||||
#Add include
|
||||
ActionDefinition.addInclude.name= Add Include
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2007 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
|
||||
|
@ -273,7 +273,7 @@ public class AddIncludeOnSelectionAction extends Action implements IUpdate {
|
|||
|
||||
if (pdomNames.size() > 1)
|
||||
{
|
||||
ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY));
|
||||
ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_NAME_ONLY));
|
||||
dialog.setElements(pdomNames.toArray());
|
||||
dialog.setTitle(CEditorMessages.getString("AddIncludeOnSelection.label")); //$NON-NLS-1$
|
||||
dialog.setMessage(CEditorMessages.getString("AddIncludeOnSelection.description")); //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue