mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Added ICElement.EMPTY_ARRAY constant.
This commit is contained in:
parent
bdde88fd2a
commit
2e0bd2e95b
6 changed files with 76 additions and 84 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 QNX Software Systems and others.
|
* Copyright (c) 2000, 2013 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,23 +12,25 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common protocol for all elements provided by the C model.
|
* Common protocol for all elements provided by the C model.
|
||||||
*
|
*
|
||||||
* @noextend This interface is not intended to be extended by clients.
|
* @noextend This interface is not intended to be extended by clients.
|
||||||
* @noimplement This interface is not intended to be implemented by clients.
|
* @noimplement This interface is not intended to be implemented by clients.
|
||||||
*/
|
*/
|
||||||
public interface ICElement extends IAdaptable {
|
public interface ICElement extends IAdaptable {
|
||||||
|
public static final ICElement[] EMPTY_ARRAY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IResource from 10-20
|
* IResource from 10-20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant representing a C Root workspace (IWorkspaceRoot object).
|
* Constant representing a C Root workspace (IWorkspaceRoot object).
|
||||||
|
@ -37,19 +39,19 @@ public interface ICElement extends IAdaptable {
|
||||||
static final int C_MODEL = 10;
|
static final int C_MODEL = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant representing a C project(IProject object).
|
* Constant representing a C project (IProject object).
|
||||||
* A C element with this type can be safely cast to <code>ICProject</code>.
|
* A C element with this type can be safely cast to <code>ICProject</code>.
|
||||||
*/
|
*/
|
||||||
static final int C_PROJECT = 11;
|
static final int C_PROJECT = 11;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant representing a folder(ICContainer object).
|
* Constant representing a folder (ICContainer object).
|
||||||
* A C element with this type can be safely cast to <code>ICContainer</code>.
|
* A C element with this type can be safely cast to <code>ICContainer</code>.
|
||||||
*/
|
*/
|
||||||
static final int C_CCONTAINER = 12;
|
static final int C_CCONTAINER = 12;
|
||||||
|
|
||||||
static final int C_BINARY = 14;
|
static final int C_BINARY = 14;
|
||||||
|
|
||||||
static final int C_ARCHIVE = 18;
|
static final int C_ARCHIVE = 18;
|
||||||
/**
|
/**
|
||||||
* Virtual container serving as a place holder.
|
* Virtual container serving as a place holder.
|
||||||
|
@ -103,7 +105,7 @@ public interface ICElement extends IAdaptable {
|
||||||
* struct C;
|
* struct C;
|
||||||
*/
|
*/
|
||||||
static final int C_UNION_DECLARATION = 68;
|
static final int C_UNION_DECLARATION = 68;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant representing a union structure.
|
* Constant representing a union structure.
|
||||||
*/
|
*/
|
||||||
|
@ -163,14 +165,14 @@ public interface ICElement extends IAdaptable {
|
||||||
* a Typedef.
|
* a Typedef.
|
||||||
*/
|
*/
|
||||||
static final int C_TYPEDEF = 80;
|
static final int C_TYPEDEF = 80;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumerator.
|
* Enumerator.
|
||||||
*/
|
*/
|
||||||
static final int C_ENUMERATOR = 81;
|
static final int C_ENUMERATOR = 81;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C++ template class declaration without a definiton.
|
* C++ template class declaration without a definition.
|
||||||
*/
|
*/
|
||||||
static final int C_TEMPLATE_CLASS_DECLARATION = 82;
|
static final int C_TEMPLATE_CLASS_DECLARATION = 82;
|
||||||
|
|
||||||
|
@ -232,7 +234,7 @@ public interface ICElement extends IAdaptable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assembly label.
|
* Assembly label.
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
static final int ASM_LABEL= 94;
|
static final int ASM_LABEL= 94;
|
||||||
|
@ -243,21 +245,21 @@ public interface ICElement extends IAdaptable {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
static final int C_CLASS_CTOR = 0x100;
|
static final int C_CLASS_CTOR = 0x100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifier indicating a class destructor
|
* Modifier indicating a class destructor
|
||||||
* @deprecated use {@link IMethodDeclaration#isDestructor()}
|
* @deprecated use {@link IMethodDeclaration#isDestructor()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
static final int C_CLASS_DTOR = 0x200;
|
static final int C_CLASS_DTOR = 0x200;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifier indicating a static storage attribute
|
* Modifier indicating a static storage attribute
|
||||||
* @deprecated use {@link IDeclaration#isStatic()}
|
* @deprecated use {@link IDeclaration#isStatic()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
static final int C_STORAGE_STATIC = 0x400;
|
static final int C_STORAGE_STATIC = 0x400;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifier indicating an extern storage attribute
|
* Modifier indicating an extern storage attribute
|
||||||
* @deprecated not used anymore
|
* @deprecated not used anymore
|
||||||
|
@ -351,19 +353,19 @@ public interface ICElement extends IAdaptable {
|
||||||
ICElement getParent();
|
ICElement getParent();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path to the innermost resource enclosing this element.
|
* Returns the path to the innermost resource enclosing this element.
|
||||||
* If this element is not included in an external archive,
|
* If this element is not included in an external archive,
|
||||||
* the path returned is the full, absolute path to the underlying resource,
|
* the path returned is the full, absolute path to the underlying resource,
|
||||||
* relative to the workbench.
|
* relative to the workbench.
|
||||||
* If this element is included in an external archive,
|
* If this element is included in an external archive,
|
||||||
* the path returned is the absolute path to the archive in the file system.
|
* the path returned is the absolute path to the archive in the file system.
|
||||||
* This is a handle-only method.
|
* This is a handle-only method.
|
||||||
*/
|
*/
|
||||||
IPath getPath();
|
IPath getPath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an absolute URI corresponding to the innermost file enclosing this element.
|
* Returns an absolute URI corresponding to the innermost file enclosing this element.
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @return the URI corresponding to the location
|
* @return the URI corresponding to the location
|
||||||
*/
|
*/
|
||||||
|
@ -389,7 +391,7 @@ public interface ICElement extends IAdaptable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this C element is read-only. An element is read-only
|
* Returns whether this C element is read-only. An element is read-only
|
||||||
* if its structure cannot be modified by the C model.
|
* if its structure cannot be modified by the C model.
|
||||||
*
|
*
|
||||||
* @return {@code true} if this element is read-only
|
* @return {@code true} if this element is read-only
|
||||||
*/
|
*/
|
||||||
|
@ -409,15 +411,15 @@ public interface ICElement extends IAdaptable {
|
||||||
* exception occurs while accessing its corresponding resource
|
* exception occurs while accessing its corresponding resource
|
||||||
*/
|
*/
|
||||||
boolean isStructureKnown() throws CModelException;
|
boolean isStructureKnown() throws CModelException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accept a visitor and walk the ICElement tree with it.
|
* Accept a visitor and walk the ICElement tree with it.
|
||||||
*
|
*
|
||||||
* @param visitor
|
* @param visitor
|
||||||
* @throws CModelException
|
* @throws CModelException
|
||||||
*/
|
*/
|
||||||
void accept(ICElementVisitor visitor) throws CoreException;
|
void accept(ICElementVisitor visitor) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string representation of this element handle. The format of the
|
* Returns a string representation of this element handle. The format of the
|
||||||
* string is not specified; however, the identifier is stable across
|
* string is not specified; however, the identifier is stable across
|
||||||
|
@ -426,11 +428,10 @@ public interface ICElement extends IAdaptable {
|
||||||
* <p>
|
* <p>
|
||||||
* Some element types, like binaries, do not support handle identifiers and
|
* Some element types, like binaries, do not support handle identifiers and
|
||||||
* return {@code null}.
|
* return {@code null}.
|
||||||
* </p>
|
*
|
||||||
*
|
|
||||||
* @return the string handle identifier, or {@code null} if the element type is not supported
|
* @return the string handle identifier, or {@code null} if the element type is not supported
|
||||||
* @see CoreModel#create(java.lang.String)
|
* @see CoreModel#create(java.lang.String)
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
String getHandleIdentifier();
|
String getHandleIdentifier();
|
||||||
|
|
|
@ -657,7 +657,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
|
||||||
binaries = getBinaries(cproject);
|
binaries = getBinaries(cproject);
|
||||||
archives = getArchives(cproject);
|
archives = getArchives(cproject);
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
archives = binaries = new ICElement[0];
|
archives = binaries = ICElement.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
ISourceRoot[] roots = null;
|
ISourceRoot[] roots = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
* Anton Leherbauer (Wind River Systems)
|
* Anton Leherbauer (Wind River Systems)
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.actions;
|
package org.eclipse.cdt.internal.ui.actions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -42,9 +41,6 @@ import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
|
|
||||||
public class SelectionConverter {
|
public class SelectionConverter {
|
||||||
|
|
||||||
protected static final ICElement[] EMPTY_RESULT= new ICElement[0];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the selection provided by the given part into a structured selection.
|
* Converts the selection provided by the given part into a structured selection.
|
||||||
* The following conversion rules are used:
|
* The following conversion rules are used:
|
||||||
|
@ -70,7 +66,7 @@ public class SelectionConverter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts objects of a structured selection to c elements if possible.
|
* Converts objects of a structured selection to c elements if possible.
|
||||||
* This is a convenience method, fully equivalent to
|
* This is a convenience method, fully equivalent to
|
||||||
* <code>convertSelectionToCElements(s, false)</code>.
|
* <code>convertSelectionToCElements(s, false)</code>.
|
||||||
* @param s The structured selection
|
* @param s The structured selection
|
||||||
* @return The converted selection
|
* @return The converted selection
|
||||||
|
@ -148,7 +144,7 @@ public class SelectionConverter {
|
||||||
/**
|
/**
|
||||||
* Returns the selection adapted to IResource. Returns null if any of the
|
* Returns the selection adapted to IResource. Returns null if any of the
|
||||||
* entries are not adaptable.
|
* entries are not adaptable.
|
||||||
*
|
*
|
||||||
* @param selection
|
* @param selection
|
||||||
* the selection
|
* the selection
|
||||||
* @param resourceMask
|
* @param resourceMask
|
||||||
|
@ -232,7 +228,7 @@ public class SelectionConverter {
|
||||||
/**
|
/**
|
||||||
* Returns whether the type of the given resource is among the specified
|
* Returns whether the type of the given resource is among the specified
|
||||||
* resource types.
|
* resource types.
|
||||||
*
|
*
|
||||||
* @param resource
|
* @param resource
|
||||||
* the resource
|
* the resource
|
||||||
* @param resourceMask
|
* @param resourceMask
|
||||||
|
@ -282,12 +278,12 @@ public class SelectionConverter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EMPTY_RESULT;
|
return ICElement.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the text selection provided by the given editor a Java element by
|
* Converts the text selection provided by the given editor a Java element by
|
||||||
* asking the user if code reolve returned more than one result. If the selection
|
* asking the user if code resolve returned more than one result. If the selection
|
||||||
* doesn't cover a Java element <code>null</code> is returned.
|
* doesn't cover a Java element <code>null</code> is returned.
|
||||||
*/
|
*/
|
||||||
public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message) throws CModelException {
|
public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message) throws CModelException {
|
||||||
|
@ -300,7 +296,6 @@ public class SelectionConverter {
|
||||||
}
|
}
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the text selection provided by the given editor into an array of
|
* Converts the text selection provided by the given editor into an array of
|
||||||
|
@ -325,11 +320,10 @@ public class SelectionConverter {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canOperateOn(CEditor editor) {
|
public static boolean canOperateOn(CEditor editor) {
|
||||||
if (editor == null)
|
if (editor == null)
|
||||||
return false;
|
return false;
|
||||||
return getInput(editor) != null;
|
return getInput(editor) != null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,10 @@ public class CallHierarchyUI {
|
||||||
*/
|
*/
|
||||||
private static List<CHViewPart> fLRUCallHierarchyViews= new ArrayList<CHViewPart>();
|
private static List<CHViewPart> fLRUCallHierarchyViews= new ArrayList<CHViewPart>();
|
||||||
private static int fViewCount;
|
private static int fViewCount;
|
||||||
|
|
||||||
private static final int MAX_HISTORY_SIZE = 10;
|
private static final int MAX_HISTORY_SIZE = 10;
|
||||||
private static List<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
|
private static List<ICElement> fHistoryEntries= new ArrayList<ICElement>(MAX_HISTORY_SIZE);
|
||||||
|
|
||||||
public static void setIsJUnitTest(boolean val) {
|
public static void setIsJUnitTest(boolean val) {
|
||||||
sIsJUnitTest= val;
|
sIsJUnitTest= val;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public class CallHierarchyUI {
|
||||||
} else {
|
} else {
|
||||||
secondaryId = viewPart.getViewSite().getSecondaryId();
|
secondaryId = viewPart.getViewSite().getSecondaryId();
|
||||||
}
|
}
|
||||||
|
|
||||||
viewPart = (CHViewPart) page.showView(CUIPlugin.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
|
viewPart = (CHViewPart) page.showView(CUIPlugin.ID_CALL_HIERARCHY, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
|
||||||
viewPart.setInput(input);
|
viewPart.setInput(input);
|
||||||
return viewPart;
|
return viewPart;
|
||||||
|
@ -321,7 +321,7 @@ public class CallHierarchyUI {
|
||||||
binding instanceof IEnumerator ||
|
binding instanceof IEnumerator ||
|
||||||
binding instanceof IFunction)
|
binding instanceof IFunction)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (binding instanceof IVariable) {
|
if (binding instanceof IVariable) {
|
||||||
try {
|
try {
|
||||||
final IScope scope = binding.getScope();
|
final IScope scope = binding.getScope();
|
||||||
|
@ -356,11 +356,11 @@ public class CallHierarchyUI {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the activated view part to the head of the list.
|
* Adds the activated view part to the head of the list.
|
||||||
*
|
*
|
||||||
* @param view the Call Hierarchy view part
|
* @param view the Call Hierarchy view part
|
||||||
*/
|
*/
|
||||||
static void callHierarchyViewActivated(CHViewPart view) {
|
static void callHierarchyViewActivated(CHViewPart view) {
|
||||||
|
@ -370,26 +370,26 @@ public class CallHierarchyUI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the closed view part from the list.
|
* Removes the closed view part from the list.
|
||||||
*
|
*
|
||||||
* @param view the closed view part
|
* @param view the closed view part
|
||||||
*/
|
*/
|
||||||
static void callHierarchyViewClosed(CHViewPart view) {
|
static void callHierarchyViewClosed(CHViewPart view) {
|
||||||
fLRUCallHierarchyViews.remove(view);
|
fLRUCallHierarchyViews.remove(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the history and updates all the open views.
|
* Clears the history and updates all the open views.
|
||||||
*/
|
*/
|
||||||
static void clearHistory() {
|
static void clearHistory() {
|
||||||
setHistoryEntries(new ICElement[0]);
|
setHistoryEntries(ICElement.EMPTY_ARRAY);
|
||||||
for (CHViewPart part : fLRUCallHierarchyViews) {
|
for (CHViewPart part : fLRUCallHierarchyViews) {
|
||||||
part.setInput(null);
|
part.setInput(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the first Call Hierarchy view part instance that is not pinned.
|
* Finds the first Call Hierarchy view part instance that is not pinned.
|
||||||
*
|
*
|
||||||
* @param page the active page
|
* @param page the active page
|
||||||
* @return the Call Hierarchy view part to open or <code>null</code> if none found
|
* @return the Call Hierarchy view part to open or <code>null</code> if none found
|
||||||
*/
|
*/
|
||||||
|
@ -417,16 +417,16 @@ public class CallHierarchyUI {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ICElement[] getHistoryEntries() {
|
static public ICElement[] getHistoryEntries() {
|
||||||
return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
|
return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void setHistoryEntries(ICElement[] remaining) {
|
static public void setHistoryEntries(ICElement[] remaining) {
|
||||||
fHistoryEntries.clear();
|
fHistoryEntries.clear();
|
||||||
fHistoryEntries.addAll(Arrays.asList(remaining));
|
fHistoryEntries.addAll(Arrays.asList(remaining));
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void updateHistory(ICElement input) {
|
static public void updateHistory(ICElement input) {
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
fHistoryEntries.remove(input);
|
fHistoryEntries.remove(input);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.search.actions;
|
package org.eclipse.cdt.internal.ui.search.actions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,24 +29,24 @@ import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
||||||
import org.eclipse.cdt.internal.ui.util.Messages;
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
|
||||||
public abstract class FindInWorkingSetAction extends FindAction {
|
public abstract class FindInWorkingSetAction extends FindAction {
|
||||||
|
|
||||||
private IWorkingSet[] fWorkingSets;
|
private IWorkingSet[] fWorkingSets;
|
||||||
private String scopeDescription = ""; //$NON-NLS-1$
|
private String scopeDescription = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
public FindInWorkingSetAction(CEditor editor, String label, String tooltip, IWorkingSet[] workingSets) {
|
public FindInWorkingSetAction(CEditor editor, String label, String tooltip, IWorkingSet[] workingSets) {
|
||||||
super(editor);
|
super(editor);
|
||||||
setText(label);
|
setText(label);
|
||||||
setToolTipText(tooltip);
|
setToolTipText(tooltip);
|
||||||
fWorkingSets = workingSets;
|
fWorkingSets = workingSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindInWorkingSetAction(IWorkbenchSite site, String label, String tooltip, IWorkingSet[] workingSets){
|
public FindInWorkingSetAction(IWorkbenchSite site, String label, String tooltip, IWorkingSet[] workingSets){
|
||||||
super(site);
|
super(site);
|
||||||
setText(label);
|
setText(label);
|
||||||
setToolTipText(tooltip);
|
setToolTipText(tooltip);
|
||||||
fWorkingSets= workingSets;
|
fWorkingSets= workingSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final public void run() {
|
final public void run() {
|
||||||
IWorkingSet[] initial= fWorkingSets;
|
IWorkingSet[] initial= fWorkingSets;
|
||||||
|
@ -54,7 +54,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
||||||
fWorkingSets= askForWorkingSets();
|
fWorkingSets= askForWorkingSets();
|
||||||
}
|
}
|
||||||
if (fWorkingSets != null) {
|
if (fWorkingSets != null) {
|
||||||
scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(fWorkingSets));
|
scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(fWorkingSets));
|
||||||
super.run();
|
super.run();
|
||||||
}
|
}
|
||||||
fWorkingSets= initial;
|
fWorkingSets= initial;
|
||||||
|
@ -68,7 +68,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
||||||
@Override
|
@Override
|
||||||
final protected ICElement[] getScope() {
|
final protected ICElement[] getScope() {
|
||||||
if (fWorkingSets == null) {
|
if (fWorkingSets == null) {
|
||||||
return new ICElement[0];
|
return ICElement.EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
List<ICElement> scope = new ArrayList<ICElement>();
|
List<ICElement> scope = new ArrayList<ICElement>();
|
||||||
for (int i = 0; i < fWorkingSets.length; ++i) {
|
for (int i = 0; i < fWorkingSets.length; ++i) {
|
||||||
|
@ -79,13 +79,13 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
||||||
scope.add(element);
|
scope.add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return scope.toArray(new ICElement[scope.size()]);
|
return scope.toArray(new ICElement[scope.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IWorkingSet[] askForWorkingSets() {
|
private IWorkingSet[] askForWorkingSets() {
|
||||||
IWorkingSetManager wsm= PlatformUI.getWorkbench().getWorkingSetManager();
|
IWorkingSetManager wsm= PlatformUI.getWorkbench().getWorkingSetManager();
|
||||||
IWorkingSetSelectionDialog dlg=
|
IWorkingSetSelectionDialog dlg=
|
||||||
wsm.createWorkingSetSelectionDialog(getSite().getShell(), true);
|
wsm.createWorkingSetSelectionDialog(getSite().getShell(), true);
|
||||||
IWorkingSet[] mru= wsm.getRecentWorkingSets();
|
IWorkingSet[] mru= wsm.getRecentWorkingSets();
|
||||||
if (mru != null && mru.length > 0) {
|
if (mru != null && mru.length > 0) {
|
||||||
|
|
|
@ -24,19 +24,18 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
|
||||||
public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
||||||
|
|
||||||
public static class ClearHistoryAction extends Action {
|
|
||||||
|
|
||||||
|
public static class ClearHistoryAction extends Action {
|
||||||
private THViewPart fView;
|
private THViewPart fView;
|
||||||
|
|
||||||
public ClearHistoryAction(THViewPart view) {
|
public ClearHistoryAction(THViewPart view) {
|
||||||
super(Messages.THHistoryDropDownAction_ClearHistory);
|
super(Messages.THHistoryDropDownAction_ClearHistory);
|
||||||
fView= view;
|
fView= view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
fView.setHistoryEntries(new ICElement[0]);
|
fView.setHistoryEntries(ICElement.EMPTY_ARRAY);
|
||||||
fView.setInput(null, null);
|
fView.setInput(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,11 +44,11 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
||||||
|
|
||||||
private THViewPart fHierarchyView;
|
private THViewPart fHierarchyView;
|
||||||
private Menu fMenu;
|
private Menu fMenu;
|
||||||
|
|
||||||
public THHistoryDropDownAction(THViewPart viewPart) {
|
public THHistoryDropDownAction(THViewPart viewPart) {
|
||||||
fHierarchyView= viewPart;
|
fHierarchyView= viewPart;
|
||||||
fMenu= null;
|
fMenu= null;
|
||||||
setToolTipText(Messages.THHistoryDropDownAction_tooltip);
|
setToolTipText(Messages.THHistoryDropDownAction_tooltip);
|
||||||
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
|
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
|
||||||
setMenuCreator(this);
|
setMenuCreator(this);
|
||||||
}
|
}
|
||||||
|
@ -81,10 +80,10 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
||||||
addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
|
addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
|
||||||
return fMenu;
|
return fMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean addEntries(Menu menu, ICElement[] elements) {
|
private boolean addEntries(Menu menu, ICElement[] elements) {
|
||||||
boolean checked= false;
|
boolean checked= false;
|
||||||
|
|
||||||
int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
|
int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
|
||||||
for (int i= 0; i < min; i++) {
|
for (int i= 0; i < min; i++) {
|
||||||
THHistoryAction action= new THHistoryAction(fHierarchyView, elements[i]);
|
THHistoryAction action= new THHistoryAction(fHierarchyView, elements[i]);
|
||||||
|
@ -92,11 +91,9 @@ public class THHistoryDropDownAction extends Action implements IMenuCreator {
|
||||||
checked= checked || action.isChecked();
|
checked= checked || action.isChecked();
|
||||||
addActionToMenu(menu, action);
|
addActionToMenu(menu, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return checked;
|
return checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void addActionToMenu(Menu parent, Action action) {
|
protected void addActionToMenu(Menu parent, Action action) {
|
||||||
ActionContributionItem item= new ActionContributionItem(action);
|
ActionContributionItem item= new ActionContributionItem(action);
|
||||||
|
|
Loading…
Add table
Reference in a new issue