The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
-at http://www.eclipse.org/legal/epl-v10.html.
-For purposes of the EPL, "Program" will mean the Content.
-
-
If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party ("Redistributor") and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at http://www.eclipse.org.
-
-
\ No newline at end of file
diff --git a/org.eclipse.cdt.mylyn.ui/build.properties b/org.eclipse.cdt.mylyn.ui/build.properties
deleted file mode 100644
index 5fc5af2..0000000
--- a/org.eclipse.cdt.mylyn.ui/build.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-source.. = src/
-bin.includes = META-INF/,\
- .,\
- icons/,\
- plugin.properties,\
- about.html,\
- plugin.xml
diff --git a/org.eclipse.cdt.mylyn.ui/icons/elcl16/focus-disabled.gif b/org.eclipse.cdt.mylyn.ui/icons/elcl16/focus-disabled.gif
deleted file mode 100644
index 24bbeae..0000000
Binary files a/org.eclipse.cdt.mylyn.ui/icons/elcl16/focus-disabled.gif and /dev/null differ
diff --git a/org.eclipse.cdt.mylyn.ui/icons/elcl16/focus.gif b/org.eclipse.cdt.mylyn.ui/icons/elcl16/focus.gif
deleted file mode 100644
index bf8439c..0000000
Binary files a/org.eclipse.cdt.mylyn.ui/icons/elcl16/focus.gif and /dev/null differ
diff --git a/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-decrease.gif b/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-decrease.gif
deleted file mode 100644
index 645a58f..0000000
Binary files a/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-decrease.gif and /dev/null differ
diff --git a/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-folding.gif b/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-folding.gif
deleted file mode 100644
index bf8439c..0000000
Binary files a/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-folding.gif and /dev/null differ
diff --git a/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-increase.gif b/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-increase.gif
deleted file mode 100644
index 98a2586..0000000
Binary files a/org.eclipse.cdt.mylyn.ui/icons/elcl16/interest-increase.gif and /dev/null differ
diff --git a/org.eclipse.cdt.mylyn.ui/icons/elcl16/proposals-other.gif b/org.eclipse.cdt.mylyn.ui/icons/elcl16/proposals-other.gif
deleted file mode 100644
index 28f69f0..0000000
Binary files a/org.eclipse.cdt.mylyn.ui/icons/elcl16/proposals-other.gif and /dev/null differ
diff --git a/org.eclipse.cdt.mylyn.ui/plugin.properties b/org.eclipse.cdt.mylyn.ui/plugin.properties
deleted file mode 100644
index f28e866..0000000
--- a/org.eclipse.cdt.mylyn.ui/plugin.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-###############################################################################
-# Copyright (c) 2008, 2009 Red Hat 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:
-# Red Hat Inc. - initial API and implementation
-# IBM Corporation
-###############################################################################
-Bundle-Vendor = Eclipse Mylyn
-Bundle-Name = Mylyn CDT Bridge
-structureBridge.name = CDT Structure Bridge
-
-MarkLandmark.label=Mark as Landmark
-MarkLandmark.tooltip=Mark the selected element as a landmark
-RemoveFromContext.label=Remove from Context
-RemoveFromContext.tooltip=Mark selected element as uninteresting
-ShowFilteredChildren.label=Show Filtered Children
-ShowFilteredChildren.tooltip=Show filtered children of selected element, if any exist
-FocusActiveTask.label=Focus on Active Task
-FocusActiveTask.tooltip=Focus only on elements in active Mylyn task
-
-
-actionSet.label = CDT Task Context
-ToggleActiveFoldingAction.label = Focus Editor on Active Task
-ToggleActiveFoldingAction.tooltip = Automatically Fold Uninteresting Elements
-
-commands.category.description = CDT Task-Focused Interface Commands
-commands.category.name = CDT Context
-command.folding.auto.description = Toggle Active Folding
-command.folding.auto.name = Toggle Active Folding
\ No newline at end of file
diff --git a/org.eclipse.cdt.mylyn.ui/plugin.xml b/org.eclipse.cdt.mylyn.ui/plugin.xml
deleted file mode 100644
index f59e3b8..0000000
--- a/org.eclipse.cdt.mylyn.ui/plugin.xml
+++ /dev/null
@@ -1,313 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTContextLabelProvider.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTContextLabelProvider.java
deleted file mode 100644
index edd3e73..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTContextLabelProvider.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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
- *******************************************************************************/
-/*
- * Created on Aug 6, 2004
- * Modified for CDT usage Feb 28, 2008
- */
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.ProblemsLabelDecorator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.mylyn.commons.ui.CommonImages;
-import org.eclipse.mylyn.context.core.IInteractionElement;
-import org.eclipse.mylyn.context.core.IInteractionRelation;
-import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- * @author Shawn Minto
- */
-public class CDTContextLabelProvider extends AppearanceAwareLabelProvider {
-
- public CDTContextLabelProvider() {
- super();
- }
-
- @Override
- public String getText(Object object) {
- if (object instanceof IInteractionElement) {
- IInteractionElement node = (IInteractionElement) object;
- if (CDTStructureBridge.CONTENT_TYPE.equals(node.getContentType())) {
- ICElement element = CDTStructureBridge.getElementForHandle(node.getHandleIdentifier());
- if (element == null) {
- return Messages.CDTContextLabelProvider_Missing_Element;
- } else {
- return getTextForElement(element);
- }
- }
- } else if (object instanceof IInteractionRelation) {
- return getNameForRelationship(((IInteractionRelation) object).getRelationshipHandle());
- } else if (object instanceof ICElement) {
- return getTextForElement((ICElement) object);
- }
- return super.getText(object);
- }
-
- private String getTextForElement(ICElement element) {
- if (element.exists()) {
- return super.getText(element);
- } else {
- return Messages.CDTContextLabelProvider_Missing_Element;
- }
- }
-
- @Override
- public Image getImage(Object object) {
- if (object instanceof IInteractionElement) {
- IInteractionElement node = (IInteractionElement) object;
- if (node.getContentType().equals(CDTStructureBridge.CONTENT_TYPE)) {
- ICElement element = CDTStructureBridge.getElementForHandle(node.getHandleIdentifier());
- if (element != null) {
- return super.getImage(element);
- }
- return null;
- }
- } else if (object instanceof IInteractionRelation) {
- ImageDescriptor descriptor = getIconForRelationship(((IInteractionRelation) object).getRelationshipHandle());
- if (descriptor != null) {
- return CommonImages.getImage(descriptor);
- } else {
- return null;
- }
- }
- return super.getImage(object);
- }
-
- private ImageDescriptor getIconForRelationship(String relationshipHandle) {
- // We have no relation providers for the CDT
- return null;
- }
-
- @SuppressWarnings("restriction")
- private String getNameForRelationship(String relationshipHandle) {
- if (relationshipHandle.equals(InteractionContextManager.CONTAINMENT_PROPAGATION_ID)) {
- return Messages.CDTContextLabelProvider_Containment;
- } else {
- return null;
- }
- }
-
- public static AppearanceAwareLabelProvider createCDTUiLabelProvider() {
- AppearanceAwareLabelProvider cdtUiLabelProvider = new AppearanceAwareLabelProvider(
- AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
- | CElementImageProvider.SMALL_ICONS);
- cdtUiLabelProvider.addLabelDecorator(new ProblemsLabelDecorator(null));
- return cdtUiLabelProvider;
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTDeclarationsFilter.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTDeclarationsFilter.java
deleted file mode 100644
index b9d901a..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTDeclarationsFilter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import org.eclipse.cdt.core.model.IFunction;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class CDTDeclarationsFilter extends ViewerFilter {
-
- @Override
- public boolean select(Viewer viewer, Object parent, Object element) {
- return !((element instanceof IMethod || element instanceof IFunction));
- }
-
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTEditorMonitor.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTEditorMonitor.java
deleted file mode 100644
index f4a51ce..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTEditorMonitor.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import java.util.Iterator;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.mylyn.monitor.ui.AbstractUserInteractionMonitor;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class CDTEditorMonitor extends AbstractUserInteractionMonitor {
-
- protected ICElement lastSelectedElement = null;
-
- protected ICElement lastResolvedElement = null;
-
- protected CEditor currentEditor;
-
- protected StructuredSelection currentSelection = null;
-
- public CDTEditorMonitor() {
- super();
- }
-
- /**
- * Only public for testing
- */
- @Override
- public void handleWorkbenchPartSelection(IWorkbenchPart part, ISelection selection, boolean contributeToContext) {
- try {
- ICElement selectedElement = null;
- if (selection instanceof StructuredSelection) {
- StructuredSelection structuredSelection = (StructuredSelection) selection;
-
- if (structuredSelection.equals(currentSelection)) {
- return;
- }
- currentSelection = structuredSelection;
-
- // Object selectedObject =
- // structuredSelection.getFirstElement();
- for (Iterator> iterator = structuredSelection.iterator(); iterator.hasNext();) {
- Object selectedObject = iterator.next();
- if (selectedObject instanceof ICElement) {
- ICElement checkedElement = checkIfAcceptedAndPromoteIfNecessary((ICElement) selectedObject);
- if (checkedElement == null) {
- return;
- } else {
- selectedElement = checkedElement;
- }
- }
- if (selectedElement != null) {
- super.handleElementSelection(part, selectedElement, contributeToContext);
- }
- }
- } else {
- if (part instanceof CEditor) {
- currentEditor = (CEditor) part;
- selectedElement = SelectionConverter.getElementAtOffset(currentEditor);
- if (selectedElement == null) {
- return; // nothing selected
- }
-
- if (selectedElement != null) {
- if (selectedElement.equals(lastSelectedElement)) {
- super.handleElementEdit(part, selectedElement, contributeToContext);
- } else if (!selectedElement.equals(lastSelectedElement)) {
- super.handleElementSelection(part, selectedElement, contributeToContext);
- }
- }
-
- ICElement checkedElement = checkIfAcceptedAndPromoteIfNecessary(selectedElement);
- if (checkedElement == null) {
- return;
- } else {
- selectedElement = checkedElement;
- }
- }
- }
- if (selectedElement != null) {
- lastSelectedElement = selectedElement;
- }
- } catch (CModelException e) {
- // ignore, fine to fail to resolve an element if the model is not
- // up-to-date
- }
- }
-
- /**
- * @return null for elements that aren't modeled
- */
- protected ICElement checkIfAcceptedAndPromoteIfNecessary(ICElement element) {
- if (!(element instanceof IBinary)) {
- return element;
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTStructureBridge.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTStructureBridge.java
deleted file mode 100644
index 6d87400..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTStructureBridge.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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
- *******************************************************************************/
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IFunction;
-import org.eclipse.cdt.core.model.IInclude;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CElementGrouping;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.mylyn.context.core.AbstractContextStructureBridge;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionElement;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.views.markers.internal.ConcreteMarker;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class CDTStructureBridge extends AbstractContextStructureBridge {
-
- public final static String CONTENT_TYPE = "c/c++"; //$NON-NLS-1$
-
- public final static int C_SOURCEROOT = 1000;
-
- public CDTStructureBridge() {
- }
-
- @Override
- public String getContentType() {
- return CONTENT_TYPE;
- }
-
- @Override
- public Object getAdaptedParent(Object object) {
- if (object instanceof IFile) {
- IFile file = (IFile) object;
- return CoreModel.getDefault().create(file.getParent());
- } else {
- return super.getAdaptedParent(object);
- }
- }
-
- @Override
- public String getParentHandle(String handle) {
- ICElement cElement = (ICElement) getObjectForHandle(handle);
- if (cElement != null && cElement.getParent() != null) {
- return getHandleForElement(cElement.getParent());
- } else {
- return null;
- }
- }
-
- @Override
- public List getChildHandles(String handle) {
- Object object = getObjectForHandle(handle);
- if (object instanceof ICElement) {
- ICElement element = (ICElement) object;
- if (element instanceof IParent) {
- IParent parent = (IParent) element;
- ICElement[] children;
- try {
- children = parent.getChildren();
- List childHandles = new ArrayList();
- for (ICElement element2 : children) {
- String childHandle = getHandleIdentifier(element2);
- if (childHandle != null) {
- childHandles.add(childHandle);
- }
- }
- AbstractContextStructureBridge parentBridge = ContextCore.getStructureBridge(parentContentType);
- if (parentBridge != null && ContextCore.CONTENT_TYPE_RESOURCE.equals(parentBridge.getContentType())) {
- // TODO: Make sure line below is correct
- if (element.getElementType() < ICElement.C_NAMESPACE) {
- List resourceChildren = parentBridge.getChildHandles(handle);
- if (!resourceChildren.isEmpty()) {
- childHandles.addAll(resourceChildren);
- }
- }
- }
-
- return childHandles;
- } catch (CModelException e) {
- // ignore these, usually indicate no-existent element
- }
- }
- }
- return Collections.emptyList();
- }
-
- public static ICElement getElementForHandle(String handle) {
- return CoreModel.create(handle);
- }
-
- @Override
- public Object getObjectForHandle(String handle) {
- return getElementForHandle(handle);
- }
-
- // In the CDT, an ICElement does not have a handle interface like a
- // JavaElement. So, to find an element again, we save its CProject name,
- // plus its path, plus its element name. The CProject name allows us
- // to find the CProject. The path allows us to find the ITranslationUnit.
- // The element name (optional) allows us to find an element within the
- // TranslationUnit.
- public static String getHandleForElement(ICElement element) {
- String handle = element.getHandleIdentifier();
- if (handle != null && !(element instanceof ICProject)) {
- ICProject cProject = element.getCProject();
- if (cProject != null) {
- String projectHandle = getHandleForElement(cProject);
- if (handle.equals(projectHandle)) {
- // see bug 328300
- return null;
- }
- }
- }
- return handle;
- }
-
- /**
- * Uses resource-compatible path for projects
- */
- @Override
- public String getHandleIdentifier(Object object) {
- if (object instanceof ICElement) {
- return getHandleForElement((ICElement) object);
- } else {
- if (object instanceof IAdaptable) {
- Object adapter = ((IAdaptable) object).getAdapter(ICElement.class);
- if (adapter instanceof ICElement) {
- return getHandleForElement((ICElement) adapter);
- }
- }
- }
- return null;
- }
-
- @Override
- public String getLabel(Object object) {
- if (object instanceof ICElement) {
- return ((ICElement) object).getElementName();
- } else {
- return ""; //$NON-NLS-1$
- }
- }
-
- @Override
- public boolean canBeLandmark(String handle) {
- ICElement element = (ICElement) getObjectForHandle(handle);
- if ((element instanceof IMethod || element instanceof IFunction) && element.exists()) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * TODO: figure out if the non ICElement stuff is needed
- */
- @Override
- public boolean acceptsObject(Object object) {
- if (object instanceof IResource) {
- object = ((IResource) object).getAdapter(ICElement.class);
- }
-
- boolean accepts = (object instanceof ICElement && !(object instanceof IBinary))
- || object instanceof IWorkingSet || object instanceof CElementGrouping;
-
- return accepts;
- }
-
- @Override
- public boolean canFilter(Object object) {
- if (object instanceof IWorkingSet) {
- try {
- IWorkingSet workingSet = (IWorkingSet) object;
- IAdaptable[] elements = workingSet.getElements();
- for (IAdaptable adaptable : elements) {
- IInteractionElement element = ContextCore.getContextManager().getElement(
- getHandleIdentifier(adaptable));
- if (element.getInterest().isInteresting()) {
- return false;
- }
- }
- } catch (Exception e) {
- return false;
- }
- } else if (object instanceof CElementGrouping) {
- try {
- CElementGrouping grouping = (CElementGrouping) object;
- Object[] elements = grouping.getChildren(grouping);
- if (elements != null) {
- for (Object adaptable : elements) {
- IInteractionElement element = ContextCore.getContextManager().getElement(
- getHandleIdentifier(adaptable));
- if (element != null && element.getInterest().isInteresting()) {
- return false;
- }
- }
- }
- } catch (Exception e) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean isDocument(String handle) {
- ICElement element = (ICElement) getObjectForHandle(handle);
- return element instanceof ITranslationUnit;
- }
-
- @Override
- public String getHandleForOffsetInObject(Object object, int offset) {
- IMarker marker;
- int charStart = 0;
- if (object instanceof ConcreteMarker) {
- marker = ((ConcreteMarker) object).getMarker();
- }
- if (object instanceof IMarker) {
- marker = (IMarker) object;
- } else {
- return null;
- }
-
- Object attribute = marker.getAttribute(IMarker.CHAR_START, 0);
- if (attribute instanceof Integer) {
- charStart = ((Integer) attribute).intValue();
- }
-
- try {
- ITranslationUnit translationUnit = null;
- IResource resource = marker.getResource();
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
- if (CoreModel.isValidTranslationUnitName(null, file.getName())) {
- ICElement element = CoreModel.getDefault().create(file);
- translationUnit = CoreModel.getDefault().createTranslationUnitFrom(element.getCProject(),
- element.getPath());
- } else {
- return null;
- }
- }
- if (translationUnit != null) {
- ICElement cElement = translationUnit.getElementAtOffset(charStart);
- if (cElement != null) {
- if (cElement instanceof IInclude) {
- cElement = cElement.getParent().getParent();
- }
- return cElement.getElementName();
- } else {
- return null;
- }
- } else {
- return null;
- }
- } catch (CModelException e) {
- return null;
- }
- }
-
- @Override
- public String getContentType(String elementHandle) {
- return getContentType();
- }
-
- /**
- * Some copying from:
- *
- * @see org.eclipse.jdt.ui.ProblemsLabelDecorator
- */
- public boolean containsProblem(IInteractionElement node) {
- try {
- ICElement element = (ICElement) getObjectForHandle(node.getHandleIdentifier());
- switch (element.getElementType()) {
- case ICElement.C_PROJECT:
- case ICElement.C_CCONTAINER:
- case ICElement.C_VCONTAINER:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
- case ICElement.C_UNIT:
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
- case ICElement.C_USING:
- case ICElement.C_NAMESPACE:
- case ICElement.C_INCLUDE:
- case ICElement.C_TYPEDEF:
- case ICElement.C_MACRO:
- case ICElement.C_FUNCTION:
- case ICElement.C_METHOD:
- case ICElement.C_FIELD:
- case ICElement.C_VARIABLE_LOCAL:
- case ICElement.C_CLASS:
- ITranslationUnit cu = (ITranslationUnit) element.getAncestor(ICElement.C_UNIT);
- if (cu != null) {
- return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
- }
- }
- } catch (CoreException e) {
- // ignore
- }
- return false;
- }
-
- private boolean getErrorTicksFromMarkers(IResource res, int depth, ISourceReference sourceElement)
- throws CoreException {
- if (res == null || !res.isAccessible()) {
- return false;
- }
- IMarker[] markers = res.findMarkers(IMarker.PROBLEM, true, depth);
- if (markers != null) {
- for (IMarker curr : markers) {
- if (sourceElement == null) {
- int priority = curr.getAttribute(IMarker.SEVERITY, -1);
- if (priority == IMarker.SEVERITY_ERROR) {
- return true;
- }
- }
- }
- }
- return false;
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTUIBridgePlugin.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTUIBridgePlugin.java
deleted file mode 100644
index 4f985fe..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTUIBridgePlugin.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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:
- * Red Hat Inc. - modification from Java to CDT
- *******************************************************************************/
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.ui.IContextUiStartup;
-import org.eclipse.mylyn.internal.cdt.ui.contentassist.CDTContentAssistUtils;
-import org.eclipse.mylyn.internal.cdt.ui.editor.ActiveFoldingEditorTracker;
-import org.eclipse.mylyn.internal.cdt.ui.editor.ActiveFoldingListener;
-import org.eclipse.mylyn.monitor.ui.MonitorUi;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.progress.UIJob;
-import org.osgi.framework.BundleContext;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class CDTUIBridgePlugin extends AbstractUIPlugin implements IContextUiStartup {
-
- // TODO CHANGE plugin id?
- public static final String ID_PLUGIN = "org.eclipse.cdt.mylyn.ui"; //$NON-NLS-1$
-
- public static final String AUTO_FOLDING_ENABLED = "org.eclipse.mylyn.context.ui.editor.folding.enabled"; //$NON-NLS-1$
-
- private static final String MYLYN_RUN_COUNT = "org.eclipse.mylyn.cdt.ui.run.count.3_3_0"; //$NON-NLS-1$
-
- private static CDTUIBridgePlugin INSTANCE;
-
- private final LandmarkMarkerManager landmarkMarkerManager = new LandmarkMarkerManager();
-
- private CDTEditorMonitor cEditingMonitor;
-
- private final InterestUpdateDeltaListener cElementChangeListener = new InterestUpdateDeltaListener();
-
- private ActiveFoldingEditorTracker activeFoldingEditorTracker;
-
- public CDTUIBridgePlugin() {
- super();
- }
-
- /**
- * Startup order is critical.
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- INSTANCE = this;
- initializeContentAssist();
- }
-
- public void lazyStartup() {
-
- // TODO do in a UI JOB? and only on first run
- installFoldingEditorTracker(PlatformUI.getWorkbench());
-
- ContextCore.getContextManager().addListener(landmarkMarkerManager);
- cEditingMonitor = new CDTEditorMonitor();
- MonitorUi.getSelectionMonitors().add(cEditingMonitor);
- CoreModel.getDefault().addElementChangedListener(cElementChangeListener);
-
- }
-
- private void lazyStop() {
- ContextCore.getContextManager().removeListener(landmarkMarkerManager);
- MonitorUi.getSelectionMonitors().remove(cEditingMonitor);
- CoreModel.getDefault().removeElementChangedListener(cElementChangeListener);
- uninstallFoldingEditorTracker(PlatformUI.getWorkbench());
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- lazyStop();
- super.stop(context);
- INSTANCE = null;
- }
-
- private void initializeContentAssist() {
-
- int count = getPreferenceStore().getInt(MYLYN_RUN_COUNT);
- if (count < 1) {
- getPreferenceStore().setValue(MYLYN_RUN_COUNT, count + 1);
-
- new UIJob(Messages.CDTUIBridgePlugin_Initializing_Content_Assist) {
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- CDTContentAssistUtils.installContentAssist(CUIPlugin.getDefault().getPreferenceStore(), true);
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
- CDTContentAssistUtils.updateDefaultPreference(CUIPlugin.getDefault().getPreferenceStore());
- }
-
- private void uninstallFoldingEditorTracker(IWorkbench workbench) {
- if (activeFoldingEditorTracker != null) {
- activeFoldingEditorTracker.dispose(workbench);
- activeFoldingEditorTracker = null;
- }
- }
-
- private void installFoldingEditorTracker(IWorkbench workbench) {
- activeFoldingEditorTracker = new ActiveFoldingEditorTracker();
- activeFoldingEditorTracker.install(workbench);
-
- // update editors that are already opened
- for (IWorkbenchWindow w : PlatformUI.getWorkbench().getWorkbenchWindows()) {
- IWorkbenchPage page = w.getActivePage();
- if (page != null) {
- IEditorReference[] references = page.getEditorReferences();
- for (IEditorReference reference : references) {
- IEditorPart part = reference.getEditor(false);
- if (part != null && part instanceof CEditor) {
- CEditor editor = (CEditor) part;
- activeFoldingEditorTracker.registerEditor(editor);
- ActiveFoldingListener.resetProjection(editor);
- }
- }
- }
- }
- }
-
- /**
- * Returns the shared instance.
- */
- public static CDTUIBridgePlugin getDefault() {
- return INSTANCE;
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTUiBridge.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTUiBridge.java
deleted file mode 100644
index 4774bfa..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/CDTUiBridge.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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:
- * Red Hat Inc. - Initial implementation based on JavaUiBridge
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.editor.AbstractCModelOutlinePage;
-import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionElement;
-import org.eclipse.mylyn.context.ui.AbstractContextUiBridge;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- * @author Shawn Minto
- */
-public class CDTUiBridge extends AbstractContextUiBridge {
-
- private Field cOutlineField = null;
-
- public CDTUiBridge() {
- try {
- cOutlineField = AbstractCModelOutlinePage.class.getDeclaredField("fTreeViewer"); //$NON-NLS-1$
- cOutlineField.setAccessible(true);
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Unexpected error while focusing outline viewer", e)); //$NON-NLS-1$
- }
- }
-
- @Override
- public void open(IInteractionElement node) {
- try {
- ICElement cElement = CDTStructureBridge.getElementForHandle(node.getHandleIdentifier());
- if (cElement == null || !cElement.exists()) {
- return;
- }
- EditorUtility.openInEditor(cElement);
- } catch (CModelException t) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN, NLS.bind(
- "Failed to open editor for: {0}", node.getHandleIdentifier()), t)); //$NON-NLS-1$
- } catch (PartInitException t) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN, NLS.bind(
- "Failed to open editor for: {0}", node.getHandleIdentifier()), t)); //$NON-NLS-1$
- }
- }
-
- @Override
- public void close(IInteractionElement node) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if (page != null) {
- List toClose = new ArrayList(4);
- for (IEditorReference reference : page.getEditorReferences()) {
- try {
- ICElement input = (ICElement) reference.getEditorInput().getAdapter(ICElement.class);
- if (input != null
- && node.getHandleIdentifier().equals(CDTStructureBridge.getHandleForElement(input))) {
- toClose.add(reference);
- }
- } catch (PartInitException e) {
- // ignore
- }
- }
- if (toClose.size() > 0) {
- page.closeEditors(toClose.toArray(new IEditorReference[toClose.size()]), true);
- }
- }
-
- }
-
- @Override
- public boolean acceptsEditor(IEditorPart editorPart) {
- return editorPart instanceof CEditor;
- }
-
- @Override
- public IInteractionElement getElement(IEditorInput input) {
- Object adapter = input.getAdapter(ICElement.class);
- if (adapter instanceof ICElement) {
- ICElement cElement = (ICElement) adapter;
- String handle = ContextCore.getStructureBridge(cElement).getHandleIdentifier(cElement);
- return ContextCore.getContextManager().getElement(handle);
- } else {
- return null;
- }
- }
-
- @Override
- public List getContentOutlineViewers(IEditorPart editorPart) {
- if (editorPart == null || cOutlineField == null) {
- return null;
- }
- List viewers = new ArrayList();
- Object out = editorPart.getAdapter(IContentOutlinePage.class);
- if (out instanceof CContentOutlinePage) {
- CContentOutlinePage page = (CContentOutlinePage) out;
- if (page.getControl() != null) {
- try {
- viewers.add((TreeViewer) cOutlineField.get(page));
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Could not get Outline viewer.", e)); //$NON-NLS-1$
- }
- }
- }
- return viewers;
- }
-
- @Override
- public Object getObjectForTextSelection(TextSelection selection, IEditorPart editor) {
- if (editor instanceof CEditor) {
- TextSelection textSelection = selection;
- try {
- if (selection != null) {
- return SelectionConverter.getElementAtOffset(((CEditor) editor).getInputCElement(), textSelection);
- } else {
- Object element = ((CEditor) editor).getInputCElement();
- if (element instanceof ICElement) {
- return element;
- }
- }
- } catch (CModelException e) {
- // ignore
- }
- }
- return null;
- }
-
- @Override
- public String getContentType() {
- return CDTStructureBridge.CONTENT_TYPE;
- }
-
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/InterestUpdateDeltaListener.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/InterestUpdateDeltaListener.java
deleted file mode 100644
index dbe5583..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/InterestUpdateDeltaListener.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import org.eclipse.cdt.core.model.ElementChangedEvent;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionElement;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class InterestUpdateDeltaListener implements IElementChangedListener {
-
- private static boolean asyncExecMode = true;
-
- public void elementChanged(ElementChangedEvent event) {
- ICElementDelta delta = event.getDelta();
- handleDelta(delta.getAffectedChildren());
- }
-
- /**
- * Only handles first addition/removal
- */
- private void handleDelta(ICElementDelta[] delta) {
- try {
- ICElement added = null;
- ICElement removed = null;
- for (ICElementDelta child : delta) {
- if (child.getElement() instanceof ITranslationUnit) {
- // FIXME: not sure I modified this correctly from the java version
- if (((ITranslationUnit) child.getElement()).getParent() != null) {
- // see bug 195361, do not reduce interest of temporary working copy
- return;
- }
- }
-
- if (child.getKind() == ICElementDelta.ADDED) {
- if (added == null) {
- added = child.getElement();
- }
- } else if (child.getKind() == ICElementDelta.REMOVED) {
- if (removed == null) {
- removed = child.getElement();
- }
- }
- handleDelta(child.getAffectedChildren());
- }
-
- if (added != null && removed != null) {
- IInteractionElement element = ContextCore.getContextManager().getElement(
- CDTStructureBridge.getHandleForElement(removed));
- if (element != null) {
- resetHandle(element, CDTStructureBridge.getHandleForElement(added));
- }
- } else if (removed != null) {
-
- IInteractionElement element = ContextCore.getContextManager().getElement(
- CDTStructureBridge.getHandleForElement(removed));
- if (element != null) {
- delete(element);
- }
- }
- } catch (Throwable t) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Unexpected error while updating interest", t)); //$NON-NLS-1$
- }
- }
-
- private void resetHandle(final IInteractionElement element, final String newHandle) {
- if (!asyncExecMode) {
- ContextCore.getContextManager().updateHandle(element, newHandle);
- } else {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- workbench.getDisplay().asyncExec(new Runnable() {
- public void run() {
- ContextCore.getContextManager().updateHandle(element, newHandle);
- }
- });
- }
- }
- }
-
- private void delete(final IInteractionElement element) {
- if (!asyncExecMode) {
- ContextCore.getContextManager().deleteElement(element);
- } else {
- IWorkbench workbench = PlatformUI.getWorkbench();
- if (workbench != null) {
- workbench.getDisplay().asyncExec(new Runnable() {
- public void run() {
- ContextCore.getContextManager().deleteElement(element);
- }
- });
- }
- }
- }
-
- /**
- * For testing
- */
- public static void setAsyncExecMode(boolean asyncExecMode) {
- InterestUpdateDeltaListener.asyncExecMode = asyncExecMode;
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/LandmarkMarkerManager.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/LandmarkMarkerManager.java
deleted file mode 100644
index db185cd..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/LandmarkMarkerManager.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 Mylyn project committers 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
- *******************************************************************************/
-/*
- * Created on Feb 16, 2005
- */
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IFunction;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-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.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.context.core.AbstractContextListener;
-import org.eclipse.mylyn.context.core.ContextChangeEvent;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionElement;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class LandmarkMarkerManager extends AbstractContextListener {
-
- private static final String ID_MARKER_LANDMARK = "org.eclipse.mylyn.context.ui.markers.landmark"; //$NON-NLS-1$
-
- private final Map markerMap = new HashMap();
-
- public LandmarkMarkerManager() {
- super();
- }
-
- @Override
- public void contextChanged(ContextChangeEvent event) {
- switch (event.getEventKind()) {
- case PRE_ACTIVATED:
- break;
- case ACTIVATED:
- modelUpdated();
- break;
- case DEACTIVATED:
- modelUpdated();
- break;
- case CLEARED:
- modelUpdated();
- break;
- case INTEREST_CHANGED:
- break;
- case LANDMARKS_ADDED:
- for (IInteractionElement element : event.getElements()) {
- addedLandmark(element);
- }
- break;
- case LANDMARKS_REMOVED:
- for (IInteractionElement element : event.getElements()) {
- removedLandmark(element);
- }
- break;
- case ELEMENTS_DELETED:
- break;
- }
- }
-
- private void modelUpdated() {
- for (IInteractionElement node : markerMap.keySet()) {
- removedLandmark(node);
- }
- markerMap.clear();
- for (IInteractionElement node : ContextCore.getContextManager().getActiveLandmarks()) {
- addedLandmark(node);
- }
- }
-
- private void addedLandmark(final IInteractionElement node) {
- if (node == null || node.getContentType() == null) {
- return;
- }
- if (node.getContentType().equals(CDTStructureBridge.CONTENT_TYPE)) {
- final ICElement element = CDTStructureBridge.getElementForHandle(node.getHandleIdentifier());
- if (element == null || !element.exists()) {
- return;
- }
- if (element instanceof IMethod || element instanceof IFunction) {
- try {
- final ISourceRange range = ((ISourceReference) element).getSourceRange();
- final IResource resource = element.getUnderlyingResource();
- if (resource instanceof IFile) {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- IMarker marker = resource.createMarker(ID_MARKER_LANDMARK);
- if (marker != null && range != null) {
- marker.setAttribute(IMarker.CHAR_START, range.getStartPos());
- marker.setAttribute(IMarker.CHAR_END, range.getStartPos() + range.getLength());
- marker.setAttribute(IMarker.MESSAGE, Messages.LandmarkMarkerManager_Mylyn_Landmark);
- marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- markerMap.put(node, marker.getId());
- }
- }
- };
- resource.getWorkspace().run(runnable, null);
- }
- } catch (CModelException e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Unexpected error while updating landmark markers", e)); //$NON-NLS-1$
- } catch (CoreException e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Unexpected error while updating landmark markers", e)); //$NON-NLS-1$
- }
- }
- }
- }
-
- private void removedLandmark(final IInteractionElement node) {
- if (node == null) {
- return;
- }
- if (node.getContentType().equals(CDTStructureBridge.CONTENT_TYPE)) {
- ICElement element = CDTStructureBridge.getElementForHandle(node.getHandleIdentifier());
- if (element == null || !element.exists()) {
- return;
- }
- if (element.getAncestor(ICElement.C_UNIT) != null // stuff
- // from
- // .class
- // files
- && element instanceof ISourceReference) {
- try {
- final IResource resource = element.getUnderlyingResource();
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- if (resource != null) {
- try {
- if (markerMap.containsKey(node)) {
- long id = markerMap.get(node);
- IMarker marker = resource.getMarker(id);
- if (marker != null) {
- marker.delete();
- }
- }
- } catch (NullPointerException e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Could not update markers.", e)); //$NON-NLS-1$
- }
- }
- }
- };
- resource.getWorkspace().run(runnable, null);
- } catch (CModelException e) {
- // ignore the Java Model errors
- } catch (CoreException e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "could not update landmark markers", e)); //$NON-NLS-1$
- }
- }
- }
- }
-
- public void relationsChanged(IInteractionElement node) {
- // don't care when the relationships changed
- }
-
- public void elementDeleted(IInteractionElement node) {
- // don't care when a node is deleted
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/Messages.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/Messages.java
deleted file mode 100644
index ef9a246..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/Messages.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.cdt.ui.messages"; //$NON-NLS-1$
-
- public static String CDTContextLabelProvider_Containment;
-
- public static String CDTContextLabelProvider_Missing_Element;
-
- public static String CDTUIBridgePlugin_Initializing_Content_Assist;
-
- public static String LandmarkMarkerManager_Mylyn_Landmark;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/FocusCViewAction.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/FocusCViewAction.java
deleted file mode 100644
index c6e4402..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/FocusCViewAction.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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:
- * Red Hat Inc. - Modification for CDT usage
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.cview.CView;
-import org.eclipse.cdt.internal.ui.cview.ToggleLinkingAction;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.mylyn.context.ui.AbstractAutoFocusViewAction;
-import org.eclipse.mylyn.context.ui.InterestFilter;
-import org.eclipse.mylyn.internal.cdt.ui.CDTDeclarationsFilter;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IViewPart;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class FocusCViewAction extends AbstractAutoFocusViewAction {
-
- public FocusCViewAction() {
- super(new InterestFilter(), true, true, true);
- }
-
- @Override
- protected ISelection resolveSelection(IEditorPart part, ITextSelection changedSelection, StructuredViewer viewer)
- throws CoreException {
- Object elementToSelect = null;
- if (changedSelection instanceof TextSelection && part instanceof CEditor) {
- ICElement cdtElement = SelectionConverter.getElementAtOffset(((CEditor) part).getInputCElement(),
- changedSelection);
- elementToSelect = cdtElement;
- }
-
- if (elementToSelect != null) {
- StructuredSelection currentSelection = (StructuredSelection) viewer.getSelection();
- if (currentSelection.size() <= 1) {
- for (ViewerFilter filter : Arrays.asList(viewer.getFilters())) {
- if (filter instanceof CDTDeclarationsFilter && elementToSelect instanceof IMethod) {
- elementToSelect = ((IMethod) elementToSelect).getTranslationUnit();
- }
- }
- }
- return new StructuredSelection(elementToSelect);
- } else {
- return null;
- }
- }
-
- // TODO: should have better way of doing this
- @Override
- protected void setManualFilteringAndLinkingEnabled(boolean enabled) {
- IViewPart part = super.getPartForAction();
- if (part instanceof CView) {
- for (IContributionItem item : ((CView) part).getViewSite().getActionBars().getToolBarManager().getItems()) {
- if (item instanceof ActionContributionItem) {
- ActionContributionItem actionItem = (ActionContributionItem) item;
- if (actionItem.getAction() instanceof ToggleLinkingAction) {
- actionItem.getAction().setEnabled(enabled);
- }
- }
- }
- for (IContributionItem item : ((CView) part).getViewSite().getActionBars().getMenuManager().getItems()) {
- if (item instanceof ActionContributionItem) {
- ActionContributionItem actionItem = (ActionContributionItem) item;
- // TODO: file bug asking for extensibility
- if (actionItem.getAction().getClass().getSimpleName().equals("ShowFilterDialogAction")) { //$NON-NLS-1$
- actionItem.getAction().setEnabled(enabled);
- }
- }
- // NOTE: turning off dynamically contributed filter items is not currently feasible
-// else if (item instanceof ContributionItem) {
-// ContributionItem contributionItem = (ContributionItem) item;
-//
-// if (contributionItem.getClass().getSimpleName().equals("FilterActionMenuContributionItem")) {
-// try {
-// Class> clazz = contributionItem.getClass();
-// Field field = clazz.getDeclaredField("fActionGroup");
-// field.setAccessible(true);
-// Object object = field.get(contributionItem);
-// if (object instanceof CustomFiltersActionGroup) {
-// CustomFiltersActionGroup group = (CustomFiltersActionGroup) object;
-// group.setFilters(new String[] { });
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-// }
- }
- }
- }
-
- @Override
- protected void setDefaultLinkingEnabled(boolean on) {
- IViewPart part = super.getPartForAction();
- if (part instanceof CView) {
- ((CView) part).setLinkingEnabled(on);
- }
- }
-
- @Override
- protected boolean isDefaultLinkingEnabled() {
- IViewPart part = super.getPartForAction();
- if (part instanceof CView) {
- return ((CView) part).isLinkingEnabled();
- }
- return false;
- }
-
- @Override
- public List getViewers() {
- List viewers = new ArrayList();
- // TODO: get from super
- IViewPart part = super.getPartForAction();
- if (part instanceof CView) {
- viewers.add(((CView) part).getViewer());
- }
- return viewers;
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/Messages.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/Messages.java
deleted file mode 100644
index 149a2b7..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/Messages.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui.actions;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.cdt.ui.actions.messages"; //$NON-NLS-1$
-
- public static String ToggleActiveFoldingAction_Active_Folding;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/ToggleActiveFoldingAction.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/ToggleActiveFoldingAction.java
deleted file mode 100644
index bc95d46..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/ToggleActiveFoldingAction.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.cdt.ui.actions;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.mylyn.internal.cdt.ui.CDTUIBridgePlugin;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-
-/**
- * @author Mik Kersten
- * @author Shawn Minto
- */
-public class ToggleActiveFoldingAction extends Action implements IWorkbenchWindowActionDelegate, IActionDelegate2 {
-
- private static ToggleActiveFoldingAction INSTANCE;
-
- private IAction parentAction = null;
-
- public ToggleActiveFoldingAction() {
- INSTANCE = this;
- setText(Messages.ToggleActiveFoldingAction_Active_Folding);
- }
-
- public static void toggleFolding(boolean on) {
- if (INSTANCE.parentAction != null) {
- INSTANCE.valueChanged(INSTANCE.parentAction, on);
- }
- }
-
- public void run(IAction action) {
- valueChanged(action, action.isChecked());
- }
-
- private void valueChanged(IAction action, final boolean on) {
- if (on) {
- CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, true);
- }
- action.setChecked(on);
- CDTUIBridgePlugin.getDefault().getPreferenceStore().setValue(CDTUIBridgePlugin.AUTO_FOLDING_ENABLED, on);
- }
-
- public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- // don't care when the active editor changes
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // don't care when the selection changes
- }
-
- public void init(IAction action) {
- this.parentAction = action;
- valueChanged(action,
- CDTUIBridgePlugin.getDefault().getPreferenceStore().getBoolean(CDTUIBridgePlugin.AUTO_FOLDING_ENABLED));
- }
-
- public void dispose() {
- // don't need to do anything
-
- }
-
- public void runWithEvent(IAction action, Event event) {
- run(action);
- }
-
- public void init(IWorkbenchWindow window) {
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/messages.properties b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/messages.properties
deleted file mode 100644
index c0eb11d..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/actions/messages.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-###############################################################################
-# Copyright (c) 2010 Tasktop Technologies 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:
-# Tasktop Technologies - initial API and implementation
-###############################################################################
-ToggleActiveFoldingAction_Active_Folding=Active Folding
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/CCompletionProposal.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/CCompletionProposal.java
deleted file mode 100644
index ee90786..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/CCompletionProposal.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui.contentassist;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * @author Shawn Minto
- */
-public class CCompletionProposal extends org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProposal {
-
- private final ICElement cElement;
-
- // only needed until we can actually get the ICElement
- private final String bindingName;
-
- public CCompletionProposal(String replacementString, int replacementOffset, int replacementLength, Image image,
- String displayString, String idString, int relevance, ITextViewer viewer, ICElement element,
- String bindingName) {
- super(replacementString, replacementOffset, replacementLength, image, displayString, idString, relevance,
- viewer);
- this.cElement = element;
- this.bindingName = bindingName;
- }
-
- public ICElement getCElement() {
- return cElement;
- }
-
- public String getBindingName() {
- return bindingName;
- }
-
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/CDTContentAssistUtils.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/CDTContentAssistUtils.java
deleted file mode 100644
index 70893d3..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/CDTContentAssistUtils.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui.contentassist;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalCategory;
-import org.eclipse.cdt.internal.ui.text.contentassist.CompletionProposalComputerRegistry;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * @author Shawn Minto
- */
-public class CDTContentAssistUtils {
-
- private static final String SEPARATOR_CODEASSIST = "\0"; //$NON-NLS-1$
-
- public static final String ASSIST_MYLYN_TYPE = "org.eclipse.mylyn.cdt.ui.parserProposalCategory"; //$NON-NLS-1$
-
- public static final String ASSIST_CDT_TYPE = "org.eclipse.cdt.ui.parserProposalCategory"; //$NON-NLS-1$
-
- public static void installContentAssist(IPreferenceStore cdtPrefs, boolean mylynContentAssist) {
- Set disabledIds = getDisableContentAssistIds(cdtPrefs);
- if (!mylynContentAssist) {
- disabledIds.remove(ASSIST_CDT_TYPE);
- disabledIds.add(ASSIST_MYLYN_TYPE);
- } else {
- disabledIds.add(ASSIST_CDT_TYPE);
- disabledIds.remove(ASSIST_MYLYN_TYPE);
- }
- String newValue = ""; //$NON-NLS-1$
- for (String id : disabledIds) {
- newValue += id + SEPARATOR_CODEASSIST;
- }
- cdtPrefs.setValue(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, newValue);
-
- CompletionProposalComputerRegistry registry = CompletionProposalComputerRegistry.getDefault();
- List categories = registry.getProposalCategories();
-
- for (CompletionProposalCategory cat : categories) {
- if (disabledIds.contains(cat.getId())) {
- cat.setIncluded(false);
- } else {
- cat.setIncluded(true);
- }
- }
- }
-
- public static Set getDisableContentAssistIds(IPreferenceStore cdtPrefs) {
- String oldValue = cdtPrefs.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
- StringTokenizer tokenizer = new StringTokenizer(oldValue, SEPARATOR_CODEASSIST);
- Set disabledIds = new HashSet();
- while (tokenizer.hasMoreTokens()) {
- disabledIds.add((String) tokenizer.nextElement());
- }
- return disabledIds;
- }
-
- public static void updateDefaultPreference(IPreferenceStore cdtPrefs) {
- // the Task-Focused category should be disabled if the user reverts to the default
- String defaultValue = cdtPrefs.getDefaultString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
- cdtPrefs.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, defaultValue + ASSIST_MYLYN_TYPE
- + SEPARATOR_CODEASSIST);
- }
-
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/DOMCompletionProposalComputer.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/DOMCompletionProposalComputer.java
deleted file mode 100644
index 4bf16e7..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/DOMCompletionProposalComputer.java
+++ /dev/null
@@ -1,1224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.cdt.ui.contentassist;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.IPositionConverter;
-import org.eclipse.cdt.core.dom.IName;
-import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.IASTCompletionContext;
-import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
-import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
-import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
-import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.ICompositeType;
-import org.eclipse.cdt.core.dom.ast.IEnumeration;
-import org.eclipse.cdt.core.dom.ast.IEnumerator;
-import org.eclipse.cdt.core.dom.ast.IField;
-import org.eclipse.cdt.core.dom.ast.IFunction;
-import org.eclipse.cdt.core.dom.ast.IFunctionType;
-import org.eclipse.cdt.core.dom.ast.IMacroBinding;
-import org.eclipse.cdt.core.dom.ast.IParameter;
-import org.eclipse.cdt.core.dom.ast.IProblemBinding;
-import org.eclipse.cdt.core.dom.ast.IScope;
-import org.eclipse.cdt.core.dom.ast.IType;
-import org.eclipse.cdt.core.dom.ast.ITypedef;
-import org.eclipse.cdt.core.dom.ast.IVariable;
-import org.eclipse.cdt.core.dom.ast.c.ICFunctionScope;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
-import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexName;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.CoreModelUtil;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.core.parser.util.CharArrayUtils;
-import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitFunction;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitTypedef;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
-import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
-import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationContext;
-import org.eclipse.cdt.internal.ui.text.contentassist.CProposalContextInformation;
-import org.eclipse.cdt.internal.ui.text.contentassist.ParsingBasedProposalComputer;
-import org.eclipse.cdt.internal.ui.text.contentassist.RelevanceConstants;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.cdt.ui.text.ICPartitions;
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.commons.ui.CommonImages;
-import org.eclipse.mylyn.internal.cdt.ui.CDTUIBridgePlugin;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Searches the DOM (both the AST and the index) for completion proposals.
- *
- * @author Bryan Wilkinson
- */
-public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer {
- private final IProgressMonitor fMonitor;
- private ITranslationUnit fTU;
-
- /**
- * Default constructor is required (executable extension).
- */
- public DOMCompletionProposalComputer() {
- fMonitor = new NullProgressMonitor();
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- IWorkingCopy copy = null;
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- IEditorInput input = editor.getEditorInput();
- IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
- copy = manager.getWorkingCopy(input);
- fTU = copy;
- }
- }
- }
- }
-
- @Override
- protected List computeCompletionProposals(CContentAssistInvocationContext context,
- IASTCompletionNode completionNode, String prefix) throws CoreException {
-
- List proposals = new ArrayList();
-
- int indices[] = new int[200];
- for (int i = 0; i < indices.length; i++) {
- indices[i] = -1;
- }
-
- if (inPreprocessorDirective(context)) {
- if (!inPreprocessorKeyword(context)) {
- // add only macros
- if (prefix.length() == 0) {
- try {
- prefix = context.computeIdentifierPrefix().toString();
- } catch (BadLocationException exc) {
- CUIPlugin.log(exc);
- }
- }
- addMacroProposals(context, prefix, proposals);
- }
- } else {
- IASTTranslationUnit ast = completionNode.getTranslationUnit();
- String source = null;
-
- boolean handleMacros = false;
- IASTName[] names = completionNode.getNames();
-
- for (int i = 0; i < names.length; ++i) {
- if (names[i].getTranslationUnit() == null) {
- // The node isn't properly hooked up, must have backtracked out of this node
- continue;
- }
-
- IASTCompletionContext astContext = names[i].getCompletionContext();
- if (astContext == null) {
- continue;
- } else if (astContext instanceof IASTIdExpression || astContext instanceof IASTNamedTypeSpecifier) {
- // handle macros only if there is a prefix
- handleMacros = prefix.length() > 0;
- }
-
- IBinding[] bindings = astContext.findBindings(names[i], !context.isContextInformationStyle());
- if (bindings != null) {
- int index = 0;
- int index2 = 0;
- for (int j = 0; j < bindings.length; ++j) {
- handleBinding(bindings[j], context, prefix, astContext, proposals);
-
- source = computeSourceForBinding(ast, bindings[j]);
- if (source != null) {
- if (!source.contains("@class") && !source.contains("@interface")) { //$NON-NLS-1$ //$NON-NLS-2$
- if (source.contains("@internal")) { //$NON-NLS-1$
- indices[index2++] = index;
- } else if (source.contains("@privlevel") && source.contains("CORE")) { //$NON-NLS-1$ //$NON-NLS-2$
- indices[index2++] = index;
- }
- }
- index++;
- }
- }
- }
- }
-
- if (handleMacros) {
- addMacroProposals(context, prefix, proposals);
- }
- }
-
- for (int i = indices.length - 1; i > -1; i--) {
- if (indices[i] != -1) {
- proposals.remove(indices[i]);
- }
- }
-
- return proposals;
- }
-
- /**
- * Find a definition or declaration for the given binding and returns the source for it.
- * Definitions are preferred over declarations. In case of multiple definitions or declarations,
- * and the first name which yields source is taken.
- *
- * @param ast the AST of the translation unit
- * @param binding the binding
- * @return a source string or null, if no source could be computed
- * @throws CoreException if the source file could not be loaded or if there was a
- * problem with the index
- */
- private String computeSourceForBinding(IASTTranslationUnit ast, IBinding binding) throws CoreException {
- IName[] names = findDefsOrDecls(ast, binding);
-
- // in case the binding is a non-explicit specialization we need
- // to consider the original binding (bug 281396)
- if (names.length == 0 && binding instanceof ICPPSpecialization) {
- binding= ((ICPPSpecialization) binding).getSpecializedBinding();
- if (!(binding instanceof IProblemBinding)) {
- names= findDefsOrDecls(ast, binding);
- }
- }
- if (names.length > 0) {
- for (IName name : names) {
- String source= computeSourceForName(name, binding);
- if (source != null) {
- return source;
- }
- }
- }
- return null;
- }
- /**
- * Search for definitions or declarations for the given binding.
- * @param ast the AST of the translation unit
- * @param binding the binding
- * @return an array of definitions or declarations, never null
- * @throws CoreException
- */
- private IName[] findDefsOrDecls(IASTTranslationUnit ast, IBinding binding) throws CoreException {
- IName[] names= findDefinitions(ast, binding);
- if (names.length == 0) {
- names= findDeclarations(ast, binding);
- }
- return names;
- }
- /**
- * Search for definitions for the given binding.
- *
- * @param ast the AST of the translation unit
- * @param binding the binding
- * @return an array of definitions, never null
- * @throws CoreException
- */
- private IName[] findDefinitions(IASTTranslationUnit ast, IBinding binding) throws CoreException {
- IName[] declNames= ast.getDefinitionsInAST(binding);
- if (declNames.length == 0 && ast.getIndex() != null) {
- // search definitions in index
- declNames = ast.getIndex().findNames(binding, IIndex.FIND_DEFINITIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
- }
- return declNames;
- }
- /**
- * Search for declarations for the given binding.
- *
- * @param ast the AST of the translation unit
- * @param binding the binding
- * @return an array of declarations, never null
- * @throws CoreException
- */
- private IName[] findDeclarations(IASTTranslationUnit ast, IBinding binding) throws CoreException {
- IName[] declNames= ast.getDeclarationsInAST(binding);
- if (declNames.length == 0 && ast.getIndex() != null) {
- // search declarations in index
- declNames= ast.getIndex().findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
- }
- return declNames;
- }
- /**
- * Get the source for the given name from the underlying file.
- *
- * @param name the name to get the source for
- * @param binding the binding of the name
- * @return the source string or null, if the source could not be computed
- * @throws CoreException if the file could not be loaded
- */
- private String computeSourceForName(IName name, IBinding binding) throws CoreException {
- IASTFileLocation fileLocation= name.getFileLocation();
- if (fileLocation == null) {
- return null;
- }
- int nodeOffset= fileLocation.getNodeOffset();
- int nodeLength= fileLocation.getNodeLength();
-
- String fileName= fileLocation.getFileName();
- //if (DEBUG) System.out.println("[CSourceHover] Computing source for " + name + " in " + fileName); //$NON-NLS-1$//$NON-NLS-2$
- IPath location= Path.fromOSString(fileName);
- LocationKind locationKind= LocationKind.LOCATION;
- if (name instanceof IASTName && !name.isReference()) {
- IASTName astName= (IASTName)name;
- if (astName.getTranslationUnit().getFilePath().equals(fileName) && fTU.getResource() != null) {
- // reuse editor buffer for names local to the translation unit
- location= fTU.getResource().getFullPath();
- locationKind= LocationKind.IFILE;
- }
- } else {
- // try to resolve path to a resource for proper encoding (bug 221029)
- IFile file= EditorUtility.getWorkspaceFileAtLocation(location, fTU);
- if (file != null) {
- location= file.getFullPath();
- locationKind= LocationKind.IFILE;
- if (name instanceof IIndexName) {
- // need to adjust index offsets to current offsets
- // in case file has been modified since last index time
- IIndexName indexName= (IIndexName) name;
- long timestamp= indexName.getFile().getTimestamp();
- IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(file, timestamp);
- if (converter != null) {
- IRegion currentLocation= converter.historicToActual(new Region(nodeOffset, nodeLength));
- nodeOffset= currentLocation.getOffset();
- nodeLength= currentLocation.getLength();
- }
- }
- }
- }
- ITextFileBufferManager mgr= FileBuffers.getTextFileBufferManager();
- mgr.connect(location, locationKind, fMonitor);
- ITextFileBuffer buffer= mgr.getTextFileBuffer(location, locationKind);
- try {
- IRegion nameRegion= new Region(nodeOffset, nodeLength);
- final int nameOffset= nameRegion.getOffset();
- final int sourceStart;
- final int sourceEnd;
- IDocument doc= buffer.getDocument();
- if (nameOffset >= doc.getLength() || nodeLength <= 0) {
- return null;
- }
- if (binding instanceof IMacroBinding) {
- ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, nameOffset, false);
- if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
- int directiveStart= partition.getOffset();
- int commentStart= searchCommentBackward(doc, directiveStart, -1);
- if (commentStart >= 0) {
- sourceStart= commentStart;
- } else {
- sourceStart= directiveStart;
- }
- sourceEnd= directiveStart + partition.getLength();
- } else {
- return null;
- }
- } else {
- // expand source range to include preceding comment, if any
- boolean isKnR= isKnRSource(name);
- sourceStart= computeSourceStart(doc, nameOffset, binding, isKnR);
- if (sourceStart == CHeuristicScanner.NOT_FOUND) {
- return null;
- }
- sourceEnd= computeSourceEnd(doc, nameOffset + nameRegion.getLength(), binding, name.isDefinition(), isKnR);
- }
- String source= buffer.getDocument().get(sourceStart, sourceEnd - sourceStart);
- return source;
-
- } catch (BadLocationException exc) {
- // ignore - should not happen anyway
- //if (DEBUG) exc.printStackTrace();
- } finally {
- mgr.disconnect(location, LocationKind.LOCATION, fMonitor);
- }
- return null;
- }
- /**
- * Searches the start of the comment preceding the given source offset.
- * Continuous line comments are considered as one comment until a block
- * comment is reached or a non-comment partition.
- *
- * @param doc the document
- * @param start the start of the backward search
- * @param bound search boundary (exclusive)
- * @return the comment start offset or -1, if no suitable comment was found
- * @throws BadLocationException
- */
- private static int searchCommentBackward(IDocument doc, int start, int bound) throws BadLocationException {
- int firstLine= doc.getLineOfOffset(start);
- if (firstLine == 0) {
- return 0;
- }
- ITypedRegion partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, start, true);
- int currentOffset= Math.max(doc.getLineOffset(firstLine - 1), partition.getOffset() - 1);
- int commentOffset= -1;
- while (currentOffset > bound) {
- partition= TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, currentOffset, true);
- currentOffset= partition.getOffset() - 1;
- if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
- || ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
- final int partitionOffset= partition.getOffset();
- final int startLine= doc.getLineOfOffset(partitionOffset);
- final int lineOffset= doc.getLineOffset(startLine);
- if (partitionOffset == lineOffset ||
- doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
- return lineOffset;
- }
- return commentOffset;
- } else if (ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType())
- || ICPartitions.C_SINGLE_LINE_DOC_COMMENT.equals(partition.getType())) {
- final int partitionOffset= partition.getOffset();
- final int startLine= doc.getLineOfOffset(partitionOffset);
- final int lineOffset= doc.getLineOffset(startLine);
- if (partitionOffset == lineOffset ||
- doc.get(lineOffset, partitionOffset - lineOffset).trim().length() == 0) {
- commentOffset= lineOffset;
- continue;
- }
- return commentOffset;
- } else if (IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())) {
- if (doc.get(partition.getOffset(), partition.getLength()).trim().length() == 0) {
- continue;
- }
- if (commentOffset >= 0) {
- break;
- }
- } else {
- break;
- }
- }
- return commentOffset;
- }
- /**
- * Determine if the name is part of a KnR function definition.
- * @param name
- * @return true if the name is part of a KnR function
- */
- private boolean isKnRSource(IName name) {
- if (name instanceof IASTName) {
- IASTNode node= (IASTNode)name;
- while (node.getParent() != null) {
- if (node instanceof ICASTKnRFunctionDeclarator) {
- return node.getParent() instanceof IASTFunctionDefinition;
- }
- node= node.getParent();
- }
- }
- return false;
- }
- private int computeSourceStart(IDocument doc, int nameOffset, IBinding binding, boolean isKnR) throws BadLocationException {
- int sourceStart= nameOffset;
- CHeuristicScanner scanner= new CHeuristicScanner(doc);
- if (binding instanceof IParameter) {
- if (isKnR) {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
- } else {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '>', '(', ',' });
- if (sourceStart > 0 && doc.getChar(sourceStart) == '>') {
- sourceStart= scanner.findOpeningPeer(sourceStart - 1, '<', '>');
- if (sourceStart > 0) {
- sourceStart= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '(', ',' });
- }
- }
- }
- if (sourceStart == CHeuristicScanner.NOT_FOUND) {
- return sourceStart;
- }
- sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
- if (sourceStart == CHeuristicScanner.NOT_FOUND) {
- sourceStart = nameOffset;
- }
- } else if (binding instanceof ICPPTemplateParameter) {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '>', '<', ',' });
- if (sourceStart > 0 && doc.getChar(sourceStart) == '>') {
- sourceStart= scanner.findOpeningPeer(sourceStart - 1, '<', '>');
- if (sourceStart > 0) {
- sourceStart= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '<', ',' });
- }
- }
- if (sourceStart == CHeuristicScanner.NOT_FOUND) {
- return sourceStart;
- }
- sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
- if (sourceStart == CHeuristicScanner.NOT_FOUND) {
- sourceStart = nameOffset;
- }
- } else if (binding instanceof IEnumerator) {
- sourceStart= scanner.scanBackward(nameOffset, CHeuristicScanner.UNBOUND, new char[] { '{', ',' });
- if (sourceStart == CHeuristicScanner.NOT_FOUND) {
- return sourceStart;
- }
- sourceStart= scanner.findNonWhitespaceForward(sourceStart + 1, nameOffset);
- if (sourceStart == CHeuristicScanner.NOT_FOUND) {
- sourceStart = nameOffset;
- }
- } else {
- final boolean expectClosingBrace;
- IType type= null;
- try {
- if (binding instanceof ITypedef) {
- type= ((ITypedef)binding).getType();
- } else if (binding instanceof IVariable) {
- type= ((IVariable)binding).getType();
- }
- } catch (Exception exc) {
- }
- expectClosingBrace= type instanceof ICompositeType || type instanceof IEnumeration;
- final int nameLine= doc.getLineOfOffset(nameOffset);
- sourceStart= nameOffset;
- int commentBound;
- if (isKnR) {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
- } else {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '{', '}', ';' });
- }
- while (expectClosingBrace && commentBound > 0 && doc.getChar(commentBound) == '}') {
- int openingBrace= scanner.findOpeningPeer(commentBound - 1, '{', '}');
- if (openingBrace != CHeuristicScanner.NOT_FOUND) {
- sourceStart= openingBrace - 1;
- }
- if (isKnR) {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { ')', ';' });
- } else {
- commentBound= scanner.scanBackward(sourceStart, CHeuristicScanner.UNBOUND, new char[] { '{', '}', ';' });
- }
- }
- if (commentBound == CHeuristicScanner.NOT_FOUND) {
- commentBound= -1; // unbound
- }
- sourceStart= Math.min(sourceStart, doc.getLineOffset(nameLine));
- int commentStart= searchCommentBackward(doc, sourceStart, commentBound);
- if (commentStart >= 0) {
- sourceStart= commentStart;
- } else {
- int nextNonWS= scanner.findNonWhitespaceForward(commentBound+1, sourceStart);
- if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
- int nextNonWSLine= doc.getLineOfOffset(nextNonWS);
- int lineOffset= doc.getLineOffset(nextNonWSLine);
- if (doc.get(lineOffset, nextNonWS - lineOffset).trim().length() == 0) {
- sourceStart= doc.getLineOffset(nextNonWSLine);
- }
- }
- }
- }
- return sourceStart;
- }
- private int computeSourceEnd(IDocument doc, int start, IBinding binding, boolean isDefinition, boolean isKnR) throws BadLocationException {
- int sourceEnd= start;
- CHeuristicScanner scanner= new CHeuristicScanner(doc);
- // expand forward to the end of the definition/declaration
- boolean searchBrace= false;
- boolean searchSemi= false;
- boolean searchComma= false;
- if (binding instanceof ICompositeType || binding instanceof IEnumeration) {
- searchBrace= true;
- } else if (binding instanceof ICPPTemplateDefinition) {
- searchBrace= true;
- } else if (binding instanceof IFunction && isDefinition) {
- searchBrace= true;
- } else if (binding instanceof IParameter) {
- if (isKnR) {
- searchSemi= true;
- } else {
- searchComma= true;
- }
- } else if (binding instanceof IEnumerator || binding instanceof ICPPTemplateParameter) {
- searchComma= true;
- } else if (binding instanceof IVariable || binding instanceof ITypedef) {
- searchSemi= true;
- } else if (!isDefinition) {
- searchSemi= true;
- }
- if (searchBrace) {
- int brace= scanner.scanForward(start, CHeuristicScanner.UNBOUND, '{');
- if (brace != CHeuristicScanner.NOT_FOUND) {
- sourceEnd= scanner.findClosingPeer(brace + 1, '{', '}');
- if (sourceEnd == CHeuristicScanner.NOT_FOUND) {
- sourceEnd= doc.getLength();
- }
- }
- // expand region to include whole line
- IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
- sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
- } else if (searchSemi) {
- int semi= scanner.scanForward(start, CHeuristicScanner.UNBOUND, ';');
- if (semi != CHeuristicScanner.NOT_FOUND) {
- sourceEnd= semi+1;
- }
- // expand region to include whole line
- IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
- sourceEnd= lineRegion.getOffset() + lineRegion.getLength();
- } else if (searchComma) {
- int bound;
- if (binding instanceof IParameter) {
- bound= scanner.findClosingPeer(start, '(', ')');
- } else if (binding instanceof ICPPTemplateParameter) {
- bound= scanner.findClosingPeer(start, '<', '>');
- } else if (binding instanceof IEnumerator) {
- bound= scanner.findClosingPeer(start, '{', '}');
- } else {
- bound = CHeuristicScanner.NOT_FOUND;
- }
- if (bound == CHeuristicScanner.NOT_FOUND) {
- bound= Math.min(doc.getLength(), start + 100);
- }
- int comma= scanner.scanForward(start, bound, ',');
- if (comma == CHeuristicScanner.NOT_FOUND) {
- // last argument
- sourceEnd= bound;
- } else {
- sourceEnd= comma;
- // expand region to include whole line if rest is comment
- IRegion lineRegion= doc.getLineInformationOfOffset(sourceEnd);
- int lineEnd= lineRegion.getOffset() + lineRegion.getLength();
- int nextNonWS= scanner.findNonWhitespaceForwardInAnyPartition(sourceEnd + 1, lineEnd);
- if (nextNonWS != CHeuristicScanner.NOT_FOUND) {
- String contentType= TextUtilities.getContentType(doc, ICPartitions.C_PARTITIONING, nextNonWS, false);
- if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType) || ICPartitions.C_SINGLE_LINE_COMMENT.equals(contentType)) {
- sourceEnd= lineEnd;
- }
- }
- }
- }
- return sourceEnd;
- }
- /**
- * Test whether the invocation offset is inside or before the preprocessor directive keyword.
- *
- * @param context
- * the invocation context
- * @return true if the invocation offset is inside or before the directive keyword
- */
- private boolean inPreprocessorKeyword(CContentAssistInvocationContext context) {
- IDocument doc = context.getDocument();
- int offset = context.getInvocationOffset();
-
- try {
- final ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
- if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
- String ppPrefix = doc.get(partition.getOffset(), offset - partition.getOffset());
- if (ppPrefix.matches("\\s*#\\s*\\w*")) { //$NON-NLS-1$
- // we are inside the directive keyword
- return true;
- }
- }
-
- } catch (BadLocationException exc) {
- }
- return false;
- }
-
- /**
- * Check if the invocation offset is inside a preprocessor directive.
- *
- * @param context
- * the content asist invocation context
- * @return true if invocation offset is inside a preprocessor directive
- */
- private boolean inPreprocessorDirective(CContentAssistInvocationContext context) {
- IDocument doc = context.getDocument();
- int offset = context.getInvocationOffset();
-
- try {
- final ITypedRegion partition = TextUtilities.getPartition(doc, ICPartitions.C_PARTITIONING, offset, true);
- if (ICPartitions.C_PREPROCESSOR.equals(partition.getType())) {
- return true;
- }
-
- } catch (BadLocationException exc) {
- }
- return false;
- }
-
- private void addMacroProposals(CContentAssistInvocationContext context, String prefix,
- List proposals) {
- char[] prefixChars = prefix.toCharArray();
- final boolean matchPrefix = !context.isContextInformationStyle();
- IASTCompletionNode completionNode = context.getCompletionNode();
- IASTPreprocessorMacroDefinition[] macros = completionNode.getTranslationUnit().getMacroDefinitions();
- if (macros != null) {
- for (int i = 0; i < macros.length; ++i) {
- final char[] macroName = macros[i].getName().toCharArray();
- if (CharArrayUtils.equals(macroName, 0, matchPrefix ? prefixChars.length : macroName.length,
- prefixChars, true)) {
- handleMacro(macros[i], context, prefix, proposals);
- }
- }
- }
- macros = completionNode.getTranslationUnit().getBuiltinMacroDefinitions();
- if (macros != null) {
- for (int i = 0; i < macros.length; ++i) {
- final char[] macroName = macros[i].getName().toCharArray();
- if (CharArrayUtils.equals(macroName, 0, matchPrefix ? prefixChars.length : macroName.length,
- prefixChars, true)) {
- handleMacro(macros[i], context, prefix, proposals);
- }
- }
- }
- }
-
- private void handleMacro(IASTPreprocessorMacroDefinition macro, CContentAssistInvocationContext context,
- String prefix, List proposals) {
-
-//CElementHandleFactory.create;
- final String macroName = macro.getName().toString();
- final int baseRelevance = computeBaseRelevance(prefix, macroName);
-
- Image image = getImage(CElementImageProvider.getMacroImageDescriptor());
-
- if (macro instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
- IASTPreprocessorFunctionStyleMacroDefinition functionMacro = (IASTPreprocessorFunctionStyleMacroDefinition) macro;
-
- StringBuilder repStringBuff = new StringBuilder();
- repStringBuff.append(macroName);
- repStringBuff.append('(');
-
- StringBuilder args = new StringBuilder();
-
- IASTFunctionStyleMacroParameter[] params = functionMacro.getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; ++i) {
- if (i > 0) {
- args.append(", "); //$NON-NLS-1$
- }
- args.append(params[i].getParameter());
- }
- }
- String argString = args.toString();
-
- StringBuilder descStringBuff = new StringBuilder(repStringBuff.toString());
- descStringBuff.append(argString);
- descStringBuff.append(')');
-
- repStringBuff.append(')');
- String repString = repStringBuff.toString();
- String descString = descStringBuff.toString();
-
- CCompletionProposal proposal = createProposal(repString, descString, prefix.length(), image, baseRelevance
- + RelevanceConstants.MACRO_TYPE_RELEVANCE, context, getCElement(macro), macro.getName().toString());
- if (!context.isContextInformationStyle()) {
- proposal.setCursorPosition(repString.length() - 1);
- }
-
- if (argString.length() > 0) {
- CProposalContextInformation info = new CProposalContextInformation(image, descString, argString);
- info.setContextInformationPosition(context.getContextInformationOffset());
- proposal.setContextInformation(info);
- }
-
- proposals.add(proposal);
- } else {
- proposals.add(createProposal(macroName, macroName, prefix.length(), image, baseRelevance
- + RelevanceConstants.MACRO_TYPE_RELEVANCE, context, getCElement(macro), macro.getName().toString()));
- }
- }
-
- @SuppressWarnings("restriction")
- protected void handleBinding(IBinding binding, CContentAssistInvocationContext cContext, String prefix,
- IASTCompletionContext astContext, List proposals) {
-
- if ((binding instanceof CPPImplicitFunction || binding instanceof CPPImplicitTypedef)
- && !(binding instanceof CPPImplicitMethod)) {
- return;
- }
-
- if (!isAnonymousBinding(binding)) {
- final String name = binding.getName();
- final int baseRelevance = computeBaseRelevance(prefix, name);
- if (binding instanceof ICPPClassType) {
- handleClass((ICPPClassType) binding, astContext, cContext, baseRelevance, proposals);
- } else if (binding instanceof IFunction) {
- handleFunction((IFunction) binding, cContext, baseRelevance, proposals);
- } else if (!cContext.isContextInformationStyle()) {
- if (binding instanceof IVariable) {
- handleVariable((IVariable) binding, cContext, baseRelevance, proposals);
- } else if (binding instanceof ITypedef) {
- proposals.add(createProposal(name, name, getImage(binding), baseRelevance
- + RelevanceConstants.TYPEDEF_TYPE_RELEVANCE, cContext, getCElement(binding),
- binding.getName()));
- } else if (binding instanceof ICPPNamespace) {
- handleNamespace((ICPPNamespace) binding, astContext, cContext, baseRelevance, proposals);
- } else if (binding instanceof IEnumeration) {
- proposals.add(createProposal(name, name, getImage(binding), baseRelevance
- + RelevanceConstants.ENUMERATION_TYPE_RELEVANCE, cContext, getCElement(binding),
- binding.getName()));
- } else if (binding instanceof IEnumerator) {
- proposals.add(createProposal(name, name, getImage(binding), baseRelevance
- + RelevanceConstants.ENUMERATOR_TYPE_RELEVANCE, cContext, getCElement(binding),
- binding.getName()));
- } else {
- proposals.add(createProposal(name, name, getImage(binding), baseRelevance
- + RelevanceConstants.DEFAULT_TYPE_RELEVANCE, cContext, getCElement(binding),
- binding.getName()));
- }
- }
- }
- }
-
- private boolean isAnonymousBinding(IBinding binding) {
- char[] name = binding.getNameCharArray();
- return name.length == 0 || name[0] == '{';
- }
-
- private void handleClass(ICPPClassType classType, IASTCompletionContext astContext,
- CContentAssistInvocationContext context, int baseRelevance, List proposals) {
- if (context.isContextInformationStyle()) {
- try {
- ICPPConstructor[] constructors = classType.getConstructors();
- for (ICPPConstructor constructor : constructors) {
- handleFunction(constructor, context, baseRelevance, proposals);
- }
- } catch (Exception e) {
- handle(e);
- }
- } else {
- int relevance = 0;
- try {
- switch (classType.getKey()) {
- case ICPPClassType.k_class:
- relevance = RelevanceConstants.CLASS_TYPE_RELEVANCE;
- break;
- case ICompositeType.k_struct:
- relevance = RelevanceConstants.STRUCT_TYPE_RELEVANCE;
- break;
- case ICompositeType.k_union:
- relevance = RelevanceConstants.UNION_TYPE_RELEVANCE;
- break;
- }
- } catch (Exception e) {
- handle(e);
- }
- if (astContext instanceof IASTName && !(astContext instanceof ICPPASTQualifiedName)) {
- IASTName name = (IASTName) astContext;
- if (name.getParent() instanceof IASTDeclarator) {
- proposals.add(createProposal(
- classType.getName() + "::", classType.getName(), getImage(classType), baseRelevance + relevance, context, getCElement(classType), classType.getName())); //$NON-NLS-1$
- }
- }
- proposals.add(createProposal(classType.getName(), classType.getName(), getImage(classType), baseRelevance
- + RelevanceConstants.CLASS_TYPE_RELEVANCE, context, getCElement(classType), classType.getName()));
- }
- }
-
- private void handle(Exception e) {
- if (e instanceof RuntimeException) {
- throw (RuntimeException) e;
- }
- }
-
- private void handleFunction(IFunction function, CContentAssistInvocationContext context, int baseRelevance,
- List proposals) {
- Image image = getImage(function);
-
- StringBuilder repStringBuff = new StringBuilder();
- repStringBuff.append(function.getName());
- repStringBuff.append('(');
-
- StringBuilder dispargs = new StringBuilder(); // for the displayString
- StringBuilder idargs = new StringBuilder(); // for the idString
- String returnTypeStr = null;
- try {
- IParameter[] params = function.getParameters();
- if (params != null) {
- for (int i = 0; i < params.length; ++i) {
- IType paramType = params[i].getType();
- if (i > 0) {
- dispargs.append(',');
- idargs.append(',');
- }
-
- dispargs.append(ASTTypeUtil.getType(paramType, false));
- idargs.append(ASTTypeUtil.getType(paramType, false));
- String paramName = params[i].getName();
- if (paramName != null && paramName.length() > 0) {
- dispargs.append(' ');
- dispargs.append(paramName);
- }
- }
-
- if (function.takesVarArgs()) {
- if (params.length > 0) {
- dispargs.append(',');
- idargs.append(',');
- }
- dispargs.append("..."); //$NON-NLS-1$
- idargs.append("..."); //$NON-NLS-1$
- } else if (params.length == 0) { // force the void in
- dispargs.append("void"); //$NON-NLS-1$
- idargs.append("void"); //$NON-NLS-1$
- }
- }
- IFunctionType functionType = function.getType();
- if (functionType != null) {
- IType returnType = functionType.getReturnType();
- if (returnType != null) {
- returnTypeStr = ASTTypeUtil.getType(returnType, false);
- }
- }
- } catch (Exception e) {
- }
-
- String dispargString = dispargs.toString();
- String idargString = idargs.toString();
-
- StringBuilder dispStringBuff = new StringBuilder(repStringBuff.toString());
- dispStringBuff.append(dispargString);
- dispStringBuff.append(')');
- if (returnTypeStr != null && returnTypeStr.length() > 0) {
- dispStringBuff.append(" : "); //$NON-NLS-1$
- dispStringBuff.append(returnTypeStr);
- }
- String dispString = dispStringBuff.toString();
-
- StringBuilder idStringBuff = new StringBuilder(repStringBuff.toString());
- idStringBuff.append(idargString);
- idStringBuff.append(')');
- String idString = idStringBuff.toString();
-
- repStringBuff.append(')');
- String repString = repStringBuff.toString();
-
- final int relevance = function instanceof ICPPMethod
- ? RelevanceConstants.METHOD_TYPE_RELEVANCE
- : RelevanceConstants.FUNCTION_TYPE_RELEVANCE;
- CCompletionProposal proposal = createProposal(repString, dispString, idString, context.getCompletionNode()
- .getLength(), image, baseRelevance + relevance, context, getCElement(function), function.getName());
- if (!context.isContextInformationStyle()) {
- proposal.setCursorPosition(repString.length() - 1);
- }
-
- if (dispargString.length() > 0) {
- CProposalContextInformation info = new CProposalContextInformation(image, dispString, dispargString);
- info.setContextInformationPosition(context.getContextInformationOffset());
- proposal.setContextInformation(info);
- }
-
- proposals.add(proposal);
- }
-
- private void handleVariable(IVariable variable, CContentAssistInvocationContext context, int baseRelevance,
- List proposals) {
- StringBuilder repStringBuff = new StringBuilder();
- repStringBuff.append(variable.getName());
-
- String returnTypeStr = ""; //$NON-NLS-1$
- try {
- IType varType = variable.getType();
- if (varType != null) {
- returnTypeStr = ASTTypeUtil.getType(varType, false);
- }
- } catch (Exception e) {
- }
-
- StringBuilder dispStringBuff = new StringBuilder(repStringBuff.toString());
- if (returnTypeStr != null) {
- dispStringBuff.append(" : "); //$NON-NLS-1$
- dispStringBuff.append(returnTypeStr);
- }
- String dispString = dispStringBuff.toString();
-
- StringBuilder idStringBuff = new StringBuilder(repStringBuff.toString());
- String idString = idStringBuff.toString();
-
- String repString = repStringBuff.toString();
-
- Image image = getImage(variable);
- final int relevance = isLocalVariable(variable)
- ? RelevanceConstants.LOCAL_VARIABLE_TYPE_RELEVANCE
- : isField(variable)
- ? RelevanceConstants.FIELD_TYPE_RELEVANCE
- : RelevanceConstants.VARIABLE_TYPE_RELEVANCE;
- CCompletionProposal proposal = createProposal(repString, dispString, idString, context.getCompletionNode()
- .getLength(), image, baseRelevance + relevance, context, getCElement(variable), variable.getName());
- proposals.add(proposal);
- }
-
- private static boolean isField(IVariable variable) {
- return variable instanceof IField;
- }
-
- private static boolean isLocalVariable(IVariable variable) {
- try {
- return isLocalScope(variable.getScope());
- } catch (DOMException exc) {
- return false;
- }
- }
-
- private static boolean isLocalScope(IScope scope) {
- while (scope != null) {
- if (scope instanceof ICPPFunctionScope || scope instanceof ICPPBlockScope
- || scope instanceof ICFunctionScope) {
- return true;
- }
- try {
- scope = scope.getParent();
- } catch (DOMException e) {
- scope = null;
- }
- }
- return false;
- }
-
- private void handleNamespace(ICPPNamespace namespace, IASTCompletionContext astContext,
- CContentAssistInvocationContext cContext, int baseRelevance, List proposals) {
-
- if (astContext instanceof ICPPASTQualifiedName) {
- IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext).getCompletionContext();
- handleNamespace(namespace, parent, cContext, baseRelevance, proposals);
- return;
- }
-
- StringBuilder repStringBuff = new StringBuilder();
- repStringBuff.append(namespace.getName());
-
- if (!(astContext instanceof ICPPASTUsingDeclaration) && !(astContext instanceof ICPPASTUsingDirective)) {
- repStringBuff.append("::"); //$NON-NLS-1$
- }
-
- String repString = repStringBuff.toString();
- proposals.add(createProposal(repString, namespace.getName(), getImage(namespace), baseRelevance
- + RelevanceConstants.NAMESPACE_TYPE_RELEVANCE, cContext, getCElement(namespace), namespace.getName()));
- }
-
- private ICElement getCElement(ICPPNamespace namespace) {
- // ignore
- return null;
- }
-
- private ICElement getCElement(IVariable variable) {
- return null;
- }
-
- private ICElement getCElement(IFunction function) {
-
- return null;
- }
-
- private ICElement getCElement(ICPPClassType classType) {
- return null;
- }
-
- private ICElement getCElement(IASTPreprocessorMacroDefinition macro) {
- if (macro != null && macro.getFileLocation() != null) {
- try {
- return getCElement(macro.getFileLocation().getFileName(), macro.getFileLocation().getNodeOffset());
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Unable to get CElement for Macro", e)); //$NON-NLS-1$
- }
- }
- return null;
- }
-
- @SuppressWarnings("restriction")
- private ICElement getCElement(IBinding binding) {
- IASTNode definition = null;
- if (binding instanceof ICInternalBinding) {
- IASTNode[] declarations = ((ICInternalBinding) binding).getDeclarations();
- if (declarations != null && declarations.length > 0) {
- definition = declarations[0];
- }
- } else if (binding instanceof ICPPInternalBinding) {
- IASTNode[] declarations = ((ICPPInternalBinding) binding).getDeclarations();
- if (declarations != null && declarations.length > 0) {
- definition = declarations[0];
- }
- }
- if (definition != null && definition.getFileLocation() != null) {
- try {
- return getCElement(definition.getFileLocation().getFileName(), definition.getFileLocation()
- .getNodeOffset());
- } catch (CModelException e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Unable to get CElement for Binding", e)); //$NON-NLS-1$
- }
- }
- return null;
- }
-
- private ICElement getCElement(String filename, int offset) throws CModelException {
-
- IFile res = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(filename));
-
- ITranslationUnit cu = null;
- if (res instanceof IFile) {
- IFile file = res;
- if (CoreModel.isValidTranslationUnitName(null, file.getName())) {
- cu = CoreModelUtil.findTranslationUnit(file);
- } else {
- return null;
- }
- }
- if (cu != null) {
- ICElement ce = cu.getElementAtOffset(offset);
- return ce;
- } else {
- return null;
- }
- }
-
- private CCompletionProposal createProposal(String repString, String dispString, Image image, int relevance,
- CContentAssistInvocationContext context, ICElement element, String bindingName) {
- return createProposal(repString, dispString, null, context.getCompletionNode().getLength(), image, relevance,
- context, element, bindingName);
- }
-
- private CCompletionProposal createProposal(String repString, String dispString, int prefixLength, Image image,
- int relevance, CContentAssistInvocationContext context, ICElement element, String bindingName) {
- return createProposal(repString, dispString, null, prefixLength, image, relevance, context, element,
- bindingName);
- }
-
- private CCompletionProposal createProposal(String repString, String dispString, String idString, int prefixLength,
- Image image, int relevance, CContentAssistInvocationContext context, ICElement element, String bindingName) {
- int parseOffset = context.getParseOffset();
- int invocationOffset = context.getInvocationOffset();
- boolean doReplacement = !context.isContextInformationStyle();
-
- int repLength = doReplacement ? prefixLength : 0;
- int repOffset = doReplacement ? parseOffset - repLength : invocationOffset;
- repString = doReplacement ? repString : ""; //$NON-NLS-1$
-
- return new CCompletionProposal(repString, repOffset, repLength, image, dispString, idString, relevance,
- context.getViewer(), element, bindingName);
- }
-
- private Image getImage(ImageDescriptor desc) {
- return desc != null ? CommonImages.getImage(desc) : null;
- }
-
- private Image getImage(IBinding binding) {
- ImageDescriptor imageDescriptor = null;
-
- try {
- if (binding instanceof ITypedef) {
- imageDescriptor = CElementImageProvider.getTypedefImageDescriptor();
- } else if (binding instanceof ICompositeType) {
- if (((ICompositeType) binding).getKey() == ICPPClassType.k_class
- || binding instanceof ICPPClassTemplate) {
- imageDescriptor = CElementImageProvider.getClassImageDescriptor();
- } else if (((ICompositeType) binding).getKey() == ICompositeType.k_struct) {
- imageDescriptor = CElementImageProvider.getStructImageDescriptor();
- } else if (((ICompositeType) binding).getKey() == ICompositeType.k_union) {
- imageDescriptor = CElementImageProvider.getUnionImageDescriptor();
- }
- } else if (binding instanceof ICPPMethod) {
- switch (((ICPPMethod) binding).getVisibility()) {
- case ICPPMember.v_private:
- imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PRIVATE);
- break;
- case ICPPMember.v_protected:
- imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PROTECTED);
- break;
- default:
- imageDescriptor = CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PUBLIC);
- break;
- }
- } else if (binding instanceof IFunction) {
- imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
- } else if (binding instanceof ICPPField) {
- switch (((ICPPField) binding).getVisibility()) {
- case ICPPMember.v_private:
- imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PRIVATE);
- break;
- case ICPPMember.v_protected:
- imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PROTECTED);
- break;
- default:
- imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC);
- break;
- }
- } else if (binding instanceof IField) {
- imageDescriptor = CElementImageProvider.getFieldImageDescriptor(ASTAccessVisibility.PUBLIC);
- } else if (binding instanceof IVariable) {
- imageDescriptor = CElementImageProvider.getVariableImageDescriptor();
- } else if (binding instanceof IEnumeration) {
- imageDescriptor = CElementImageProvider.getEnumerationImageDescriptor();
- } else if (binding instanceof IEnumerator) {
- imageDescriptor = CElementImageProvider.getEnumeratorImageDescriptor();
- } else if (binding instanceof ICPPNamespace) {
- imageDescriptor = CElementImageProvider.getNamespaceImageDescriptor();
- } else if (binding instanceof ICPPFunctionTemplate) {
- imageDescriptor = CElementImageProvider.getFunctionImageDescriptor();
- } else if (binding instanceof ICPPUsingDeclaration) {
- IBinding[] delegates = ((ICPPUsingDeclaration) binding).getDelegates();
- if (delegates.length > 0) {
- return getImage(delegates[0]);
- }
- }
- } catch (Exception e) {
- handle(e);
- }
-
- return imageDescriptor != null ? CommonImages.getImage(imageDescriptor) : null;
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/FocusedCProposalProcessor.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/FocusedCProposalProcessor.java
deleted file mode 100644
index a4ee7f7..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/FocusedCProposalProcessor.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-package org.eclipse.mylyn.internal.cdt.ui.contentassist;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.ui.text.ICCompletionProposal;
-import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.commons.ui.CommonImages;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionElement;
-import org.eclipse.mylyn.internal.cdt.ui.CDTUIBridgePlugin;
-
-/**
- * @author Shawn Minto
- */
-public class FocusedCProposalProcessor {
-
- /**
- * Range above which elements are part of the context.
- */
- private static final int THRESHOLD_INTEREST = 10000;
-
- /**
- * Range for implicitly interesting element, such as method parameters.
- */
- private static final int THRESHOLD_IMPLICIT_INTEREST = THRESHOLD_INTEREST * 2;
-
- /**
- * Threshold for determining which JDT proposals should be implicitly interesting.
- */
- private static final int RELEVANCE_IMPLICIT_INTEREST_C = 600;
-
- /**
- * Threshold for implicit interest of IJavaElement proposals.
- */
- private static final int RELEVANCE_IMPLICIT_INTEREST_MISC = 110;
-
- private static final String IDENTIFIER_THIS = "this"; //$NON-NLS-1$
-
- public static final String LABEL_SEPARATOR = " -------------------------------------------- "; //$NON-NLS-1$
-
- public static final FocusedProposalSeparator PROPOSAL_SEPARATOR = new FocusedProposalSeparator();
-
- private final List monitoredProposalComputers = new ArrayList();
-
- private final List alreadyComputedProposals = new ArrayList();
-
- private final List alreadyContainSeparator = new ArrayList();
-
- private final List containsSingleInterestingProposal = new ArrayList();
-
- private static FocusedCProposalProcessor INSTANCE = new FocusedCProposalProcessor();
-
- private FocusedCProposalProcessor() {
- }
-
- public static FocusedCProposalProcessor getDefault() {
- return INSTANCE;
- }
-
- public void addMonitoredComputer(ICompletionProposalComputer proposalComputer) {
- monitoredProposalComputers.add(proposalComputer);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public List projectInterestModel(ICompletionProposalComputer proposalComputer, List proposals) {
- try {
- if (!ContextCore.getContextManager().isContextActive()) {
- return proposals;
- } else {
- boolean hasInterestingProposals = false;
- for (Object object : proposals) {
- if (object instanceof CCompletionProposal) {
- boolean foundInteresting = boostRelevanceWithInterest((CCompletionProposal) object);
- if (!hasInterestingProposals && foundInteresting) {
- hasInterestingProposals = true;
- }
- }
- }
-
- // NOTE: this annoying state needs to be maintainted to ensure
- // the
- // separator is added only once, and not added for single
- // proposals
- if (containsSingleInterestingProposal.size() > 0 && proposals.size() > 0) {
- proposals.add(FocusedCProposalProcessor.PROPOSAL_SEPARATOR);
- } else if (hasInterestingProposals/* && alreadyContainSeparator.isEmpty()*/) { // FIXME WHY IS THIS DIFFERENT THAN JAVA?
- if (proposals.size() == 1) {
- containsSingleInterestingProposal.add(proposalComputer);
- } else {
- proposals.add(FocusedCProposalProcessor.PROPOSAL_SEPARATOR);
- alreadyContainSeparator.add(proposalComputer);
- }
- }
-
- alreadyComputedProposals.add(proposalComputer);
- if (alreadyComputedProposals.size() == monitoredProposalComputers.size()) {
- alreadyComputedProposals.clear();
- alreadyContainSeparator.clear();
- containsSingleInterestingProposal.clear();
- }
-
- return proposals;
- }
- } catch (Throwable t) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Failed to project interest onto propsals", t)); //$NON-NLS-1$
- return proposals;
- }
- }
-
- private boolean boostRelevanceWithInterest(CCompletionProposal proposal) {
-
- boolean hasInteresting = false;
- String name = proposal.getBindingName();
-
- if (name != null) {
- IInteractionElement interactionElement = guessInteractionElement(name);
- if (interactionElement != null) {
- float interest = interactionElement.getInterest().getValue();
- if (interest > ContextCore.getCommonContextScaling().getInteresting()) {
- // TODO: losing precision here, only going to one decimal place
- proposal.setRelevance(THRESHOLD_INTEREST + (int) (interest * 10));
- hasInteresting = true;
- } else if (proposal.getRelevance() > RELEVANCE_IMPLICIT_INTEREST_C) {
- proposal.setRelevance(THRESHOLD_IMPLICIT_INTEREST + proposal.getRelevance());
- }
- } else if (proposal.getRelevance() > RELEVANCE_IMPLICIT_INTEREST_C) {
- proposal.setRelevance(THRESHOLD_IMPLICIT_INTEREST + proposal.getRelevance());
- }
- } else if (isImplicitlyInteresting(proposal)) {
- proposal.setRelevance(THRESHOLD_IMPLICIT_INTEREST + proposal.getRelevance());
- hasInteresting = true;
- }
- return hasInteresting;
-
-// FIXME ADD BACK THE RIGHT WAY TO DO THIS!
-// boolean hasInteresting = false;
-// ICElement cElement = proposal.getCElement();
-//
-// if (cElement != null) {
-// IInteractionElement interactionElement = ContextCore.getContextManager().getElement(
-// cElement.getHandleIdentifier());
-// float interest = interactionElement.getInterest().getValue();
-// if (interest > ContextCore.getCommonContextScaling().getInteresting()) {
-// // TODO: losing precision here, only going to one decimal place
-// proposal.setRelevance(THRESHOLD_INTEREST + (int) (interest * 10));
-// hasInteresting = true;
-// } else if (proposal.getRelevance() > RELEVANCE_IMPLICIT_INTEREST_C) {
-// proposal.setRelevance(THRESHOLD_IMPLICIT_INTEREST + proposal.getRelevance());
-// }
-// } else if (isImplicitlyInteresting(proposal)) {
-// proposal.setRelevance(THRESHOLD_IMPLICIT_INTEREST + proposal.getRelevance());
-// hasInteresting = true;
-// }
-// return hasInteresting;
- }
-
- private IInteractionElement guessInteractionElement(String name) {
- for (IInteractionElement element : ContextCore.getContextManager().getActiveContext().getInteresting()) {
- String handle = element.getHandleIdentifier();
- // remove any line information so we can compare the end instead of using a contains
- if (handle.contains("#")) { //$NON-NLS-1$
- handle = handle.substring(0, handle.indexOf("#"));//$NON-NLS-1$
- }
- if (handle.endsWith(name)) {
- return element;
- }
- }
- return null;
- }
-
- public boolean isImplicitlyInteresting(ICCompletionProposal proposal) {
- return proposal.getRelevance() > RELEVANCE_IMPLICIT_INTEREST_MISC
- && !IDENTIFIER_THIS.equals(proposal.getDisplayString());
- }
-
- static class FocusedProposalSeparator extends CCompletionProposal {
- public FocusedProposalSeparator() {
- super("", 0, 0, CommonImages.getImage(CommonImages.SEPARATOR_LIST), LABEL_SEPARATOR, //$NON-NLS-1$
- "", FocusedCProposalProcessor.THRESHOLD_INTEREST, null, null, null); //$NON-NLS-1$
- }
-
- @Override
- public void apply(IDocument document) {
- }
-
- @Override
- public void apply(IDocument document, char trigger, int offset) {
- }
-
- @Override
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- }
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/FocusedDOMCompletionProposalComputer.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/FocusedDOMCompletionProposalComputer.java
deleted file mode 100644
index b37154d..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/contentassist/FocusedDOMCompletionProposalComputer.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui.contentassist;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-
-/**
- * @author Shawn Minto
- */
-public class FocusedDOMCompletionProposalComputer extends DOMCompletionProposalComputer {
-
- public FocusedDOMCompletionProposalComputer() {
- super();
- FocusedCProposalProcessor.getDefault().addMonitoredComputer(this);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public List computeCompletionProposals(ContentAssistInvocationContext context,
- IProgressMonitor monitor) {
- if (shouldReturnResults()) {
- List> proposals = super.computeCompletionProposals(context, monitor);
- return FocusedCProposalProcessor.getDefault().projectInterestModel(this, proposals);
- } else {
- return Collections.emptyList();
- }
- }
-
- private boolean shouldReturnResults() {
- Set disabledIds = CDTContentAssistUtils.getDisableContentAssistIds(CUIPlugin.getDefault()
- .getPreferenceStore());
- if (!disabledIds.contains(CDTContentAssistUtils.ASSIST_CDT_TYPE)) {
- // do not return duplicates if the default parser completions is enabled
- return false;
- }
- return true;
- }
-
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/ActiveFoldingEditorTracker.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/ActiveFoldingEditorTracker.java
deleted file mode 100644
index 19a321f..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/ActiveFoldingEditorTracker.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 Mylyn project committers 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
- *******************************************************************************/
-package org.eclipse.mylyn.internal.cdt.ui.editor;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.mylyn.monitor.ui.AbstractEditorTracker;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- */
-public class ActiveFoldingEditorTracker extends AbstractEditorTracker {
-
- protected Map editorListenerMap = new HashMap();
-
- @Override
- public void editorOpened(IEditorPart part) {
- if (part instanceof CEditor)
- registerEditor((CEditor) part);
- }
-
- @Override
- public void editorClosed(IEditorPart part) {
- if (part instanceof CEditor)
- unregisterEditor((CEditor) part);
- }
-
- public void registerEditor(final CEditor editor) {
- if (editorListenerMap.containsKey(editor)) {
- return;
- } else {
- ActiveFoldingListener listener = new ActiveFoldingListener(editor);
- editorListenerMap.put(editor, listener);
- }
- }
-
- public void unregisterEditor(CEditor editor) {
- ActiveFoldingListener listener = editorListenerMap.get(editor);
- if (listener != null) {
- listener.dispose();
- }
- editorListenerMap.remove(editor);
- }
-
- /**
- * For testing.
- */
- public Map getEditorListenerMap() {
- return editorListenerMap;
- }
-
- @Override
- protected void editorBroughtToTop(IEditorPart part) {
- // ignore
- }
-
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/ActiveFoldingListener.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/ActiveFoldingListener.java
deleted file mode 100644
index de5e5c7..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/ActiveFoldingListener.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 Mylyn project committers 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
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui.editor;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
-import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.projection.ProjectionViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.mylyn.commons.core.StatusHandler;
-import org.eclipse.mylyn.context.core.AbstractContextListener;
-import org.eclipse.mylyn.context.core.ContextChangeEvent;
-import org.eclipse.mylyn.context.core.ContextCore;
-import org.eclipse.mylyn.context.core.IInteractionElement;
-import org.eclipse.mylyn.internal.cdt.ui.CDTStructureBridge;
-import org.eclipse.mylyn.internal.cdt.ui.CDTUIBridgePlugin;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.progress.UIJob;
-
-/**
- * @author Mik Kersten
- * @author Jeff Johnston
- * @author Shawn Minto
- */
-public class ActiveFoldingListener extends AbstractContextListener {
-
- private final CEditor editor;
-
- private ICFoldingStructureProvider updater;
-
- private static CDTStructureBridge bridge = (CDTStructureBridge) ContextCore.getStructureBridge(CDTStructureBridge.CONTENT_TYPE);
-
- private boolean enabled = false;
-
- private boolean isDisposed = false;
-
- private final IPropertyChangeListener PREFERENCE_LISTENER = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(CDTUIBridgePlugin.AUTO_FOLDING_ENABLED)) {
- if (Boolean.parseBoolean(event.getNewValue().toString())) {
- enabled = true;
- } else {
- enabled = false;
- }
- updateFolding();
- }
- }
- };
-
- public ActiveFoldingListener(CEditor editor) {
- this.editor = editor;
- ContextCore.getContextManager().addListener(this);
- CDTUIBridgePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(PREFERENCE_LISTENER);
-
- enabled = CDTUIBridgePlugin.getDefault()
- .getPreferenceStore()
- .getBoolean(CDTUIBridgePlugin.AUTO_FOLDING_ENABLED);
- try {
- Class clazz = CEditor.class;
- Field f = clazz.getDeclaredField("fProjectionModelUpdater"); //$NON-NLS-1$
- f.setAccessible(true);
- ICFoldingStructureProvider updater = (ICFoldingStructureProvider) f.get(editor);
- if (updater instanceof ICFoldingStructureProvider) {
- this.updater = updater;
- } else {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Could not install active folding on provider: " + clazz + ", must extend " //$NON-NLS-1$ //$NON-NLS-2$
- + ICFoldingStructureProvider.class.getName()));
- }
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN,
- "Could not install auto folding, reflection denied", e)); //$NON-NLS-1$
- }
-
- // XXX Look into this, there must be something else that we can do to handle this case
- Job j = new UIJob(Messages.ActiveFoldingListener_Updating_Folding) {
-
- @Override
- public IStatus runInUIThread(IProgressMonitor monitor) {
- // need the isDisposed since we do the folding asynchronously and the editor could have been closed
- // between the time the job was scheduled and the time it runs
- if (!isDisposed) {
- updateFolding();
- }
- return Status.OK_STATUS;
- }
-
- };
- j.schedule(1000);
- }
-
- public void dispose() {
- isDisposed = true;
- ContextCore.getContextManager().removeListener(this);
- CDTUIBridgePlugin.getDefault().getPreferenceStore().removePropertyChangeListener(PREFERENCE_LISTENER);
- }
-
- public void updateFolding() {
- if (!enabled || !ContextCore.getContextManager().isContextActive()) {
- editor.resetProjection();
- } else if (editor.getEditorInput() == null) {
- return;
- } else {
- try {
- List toExpand = new ArrayList();
- List toCollapse = new ArrayList();
-
- ICElement element = editor.getInputCElement();
- if (element instanceof ITranslationUnit) {
- ITranslationUnit compilationUnit = (ITranslationUnit) element;
- List allChildren = getAllChildren(compilationUnit);
- for (ICElement child : allChildren) {
- IInteractionElement interactionElement = ContextCore.getContextManager().getElement(
- bridge.getHandleIdentifier(child));
- if (interactionElement != null && interactionElement.getInterest().isInteresting()) {
- toExpand.add(child);
- } else {
- toCollapse.add(child);
- }
- }
- }
- if (updater != null) {
- collapseAllElements();
- Point selectedRange = editor.getViewer().getSelectedRange();
- expandElements(toExpand.toArray(new ICElement[toExpand.size()]));
- editor.getViewer().setSelectedRange(selectedRange.x, selectedRange.y);
- editor.getViewer().revealRange(selectedRange.x, selectedRange.y);
- }
- } catch (Exception e) {
- StatusHandler.log(new Status(IStatus.ERROR, CDTUIBridgePlugin.ID_PLUGIN, "Could not update folding", e)); //$NON-NLS-1$
- }
- }
- }
-
- protected void collapseElements(ICElement[] elements) {
- for (int i = 0; i < elements.length; ++i) {
- collapse(elements[i]);
- }
- }
-
- private void collapseAllElements() {
- CSourceViewer viewer = (CSourceViewer) editor.getViewer();
- if (viewer != null) {
- viewer.doOperation(ProjectionViewer.COLLAPSE_ALL);
- }
- }
-
- private void collapse(ICElement element) {
- // FIXME we do not support collapse right now
-// CSourceViewer viewer = (CSourceViewer) editor.getViewer();
-// editor.setSelection(element);
-// viewer.doOperation(ProjectionViewer.COLLAPSE);
- }
-
- protected void expandElements(ICElement[] elements) {
- for (int i = 0; i < elements.length; ++i) {
- expand(elements[i]);
- }
- }
-
- private void expand(ICElement element) {
- CSourceViewer viewer = (CSourceViewer) editor.getViewer();
- if (element instanceof ISourceReference && !(element instanceof ITranslationUnit)) {
- ISourceReference reference = (ISourceReference) element;
-
- try {
- viewer.exposeModelRange(new Region(reference.getSourceRange().getIdStartPos(), 0));
- } catch (CModelException e) {
- // ignore failures
- }
-
- // makes things jump around
-// editor.setSelection(element);
-// viewer.doOperation(ProjectionViewer.EXPAND);
- }
- }
-
- private static List getAllChildren(IParent parentElement) {
- List allChildren = new ArrayList();
- try {
- for (ICElement child : parentElement.getChildren()) {
- allChildren.add(child);
- if (child instanceof IParent) {
- allChildren.addAll(getAllChildren((IParent) child));
- }
- }
- } catch (CModelException e) {
- // ignore failures
- }
- return allChildren;
- }
-
- public void updateFolding(List elements) {
- try {
- for (IInteractionElement element : elements) {
- if (updater == null || !enabled) {
- return;
- } else {
- Object object = bridge.getObjectForHandle(element.getHandleIdentifier());
- if (object instanceof ICElement) {
- ICElement member = (ICElement) object;
- if (element.getInterest().isInteresting()) {
- expandElements(new ICElement[] { member });
- // expand the next 2 children down (e.g. anonymous types)
- if (!(member instanceof IParent)) {
- return;
- }
- ICElement[] children = ((IParent) member).getChildren();
- if (children.length == 1) {
- expandElements(new ICElement[] { children[0] });
- if (children[0] instanceof IParent) {
- ICElement[] childsChildren = ((IParent) children[0]).getChildren();
- if (childsChildren.length == 1) {
- expandElements(new ICElement[] { childsChildren[0] });
- }
- }
- }
- } else {
- collapseElements(new ICElement[] { member });
- }
- }
- }
- }
- } catch (Exception e) {
- // ignore elements that we can't resolve
- }
- }
-
- @Override
- public void contextChanged(ContextChangeEvent event) {
- switch (event.getEventKind()) {
- case ACTIVATED:
- case DEACTIVATED:
- if (CDTUIBridgePlugin.getDefault().getPreferenceStore().getBoolean(CDTUIBridgePlugin.AUTO_FOLDING_ENABLED)) {
- updateFolding();
- }
- break;
- case CLEARED:
- if (event.isActiveContext()) {
- if (CDTUIBridgePlugin.getDefault()
- .getPreferenceStore()
- .getBoolean(CDTUIBridgePlugin.AUTO_FOLDING_ENABLED)) {
- updateFolding();
- }
- }
- break;
- case INTEREST_CHANGED:
- updateFolding(event.getElements());
- break;
- }
- }
-
- public static void resetProjection(CEditor editor2) {
- // ignore
-
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/Messages.java b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/Messages.java
deleted file mode 100644
index 2be5502..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/Messages.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Tasktop Technologies 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:
- * Tasktop Technologies - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.cdt.ui.editor;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.cdt.ui.editor.messages"; //$NON-NLS-1$
-
- public static String ActiveFoldingListener_Updating_Folding;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/messages.properties b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/messages.properties
deleted file mode 100644
index afafeac..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/editor/messages.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-###############################################################################
-# Copyright (c) 2010 Tasktop Technologies 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:
-# Tasktop Technologies - initial API and implementation
-###############################################################################
-ActiveFoldingListener_Updating_Folding=Updating folding
diff --git a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/messages.properties b/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/messages.properties
deleted file mode 100644
index 946cc3f..0000000
--- a/org.eclipse.cdt.mylyn.ui/src/org/eclipse/mylyn/internal/cdt/ui/messages.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2010 Tasktop Technologies 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:
-# Tasktop Technologies - initial API and implementation
-###############################################################################
-CDTContextLabelProvider_Missing_Element=
-CDTContextLabelProvider_Containment=Containment
-CDTUIBridgePlugin_Initializing_Content_Assist=Initializing Focused CDT Content Assist
-LandmarkMarkerManager_Mylyn_Landmark=Mylyn Landmark
diff --git a/org.eclipse.cdt.mylyn/.project b/org.eclipse.cdt.mylyn/.project
deleted file mode 100644
index 94ebbb0..0000000
--- a/org.eclipse.cdt.mylyn/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- org.eclipse.cdt.mylyn
-
-
-
-
-
- org.eclipse.pde.FeatureBuilder
-
-
-
-
-
- org.eclipse.pde.FeatureNature
-
-
diff --git a/org.eclipse.cdt.mylyn/build.properties b/org.eclipse.cdt.mylyn/build.properties
deleted file mode 100644
index 694321c..0000000
--- a/org.eclipse.cdt.mylyn/build.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-bin.includes = epl-v10.html,\
- feature.properties,\
- feature.xml,\
- license.html
diff --git a/org.eclipse.cdt.mylyn/epl-v10.html b/org.eclipse.cdt.mylyn/epl-v10.html
deleted file mode 100644
index ed4b196..0000000
--- a/org.eclipse.cdt.mylyn/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-
-
-
-
-
-
-
-
-Eclipse Public License - Version 1.0
-
-
-
-
-
-
-
-
-
Eclipse Public License - v 1.0
-
-
-
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.
-
-
1. DEFINITIONS
-
-
"Contribution" means:
-
-
a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and
-b) in the case of each subsequent Contributor:
-
-
i)
-changes to the Program, and
-
-
ii)
-additions to the Program;
-
-
where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program.
-
-
"Contributor" means any person or
-entity that distributes the Program.
-
-
"Licensed Patents " mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program.
-
-
"Program" means the Contributions
-distributed in accordance with this Agreement.
-
-
"Recipient" means anyone who
-receives the Program under this Agreement, including all Contributors.
-
-
2. GRANT OF RIGHTS
-
-
a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license toreproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.
-
-
b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder.
-
-
c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.
-
-
d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement.
-
-
3. REQUIREMENTS
-
-
A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:
-
-
-
a)
-it complies with the terms and conditions of this Agreement; and
-
-
b)
-its license agreement:
-
-
i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose;
-
-
ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits;
-
-
iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and
-
-
iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.
-
-
When the Program is made available in source
-code form:
-
-
a)
-it must be made available under this Agreement; and
-
-
b) a
-copy of this Agreement must be included with each copy of the Program.
-
-
Contributors may not remove or alter any
-copyright notices contained within the Program.
-
-
Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution.
-
-
4. COMMERCIAL DISTRIBUTION
-
-
Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor ("Commercial
-Contributor") hereby agrees to defend and indemnify every other
-Contributor ("Indemnified Contributor") against any losses, damages and
-costs (collectively "Losses") arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.
-
-
For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.
-
-
5. NO WARRANTY
-
-
EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations.
-
-
6. DISCLAIMER OF LIABILITY
-
-
EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.
-
-
7. GENERAL
-
-
If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.
-
-
If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed.
-
-
All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive.
-
-
Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.
-
-
This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/org.eclipse.cdt.mylyn/feature.properties b/org.eclipse.cdt.mylyn/feature.properties
deleted file mode 100644
index 708cd80..0000000
--- a/org.eclipse.cdt.mylyn/feature.properties
+++ /dev/null
@@ -1,139 +0,0 @@
-###############################################################################
-# Copyright (c) 2009, 2010 Tasktop Technologies 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:
-# Tasktop Technologies - initial API and implementation
-###############################################################################
-featureName=Mylyn Context Connector: C/C++ Development
-description=NOTE: Installs CDT if not present. Mylyn Task-Focused UI extensions for CDT. Provides focusing of C/C++ element views and editors.
-providerName=Eclipse Mylyn
-copyright=Copyright (c) 2009, 2012 Tasktop Technologies and others. All rights reserved.
-
-license=\
-Eclipse Foundation Software User Agreement\n\
-February 1, 2011\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the\n\
-Eclipse Foundation is provided to you under the terms and conditions of\n\
-the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
-provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse Foundation source code\n\
-repository ("Repository") in software modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
-Update License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties" found within a Feature.\n\
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
-terms and conditions (or references to such terms and conditions) that\n\
-govern your use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-\n\Use of Provisioning Technology\n\
-\n\
-The Eclipse Foundation makes available provisioning software, examples of which include,\n\
-but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
-the purpose of allowing users to install software, documentation, information and/or\n\
-other materials (collectively "Installable Software"). This capability is provided with\n\
-the intent of allowing such users to install, extend and update Eclipse-based products.\n\
-Information about packaging Installable Software is available at\n\
-http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
-\n\
-You may use Provisioning Technology to allow other parties to install Installable Software.\n\
-You shall be responsible for enabling the applicable license agreements relating to the\n\
-Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
-in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
-making it available in accordance with the Specification, you further acknowledge your\n\
-agreement to, and the acquisition of all necessary rights to permit the following:\n\
-\n\
- 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
- the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
- extending or updating the functionality of an Eclipse-based product.\n\
- 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
- Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
- 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
- govern the use of the Installable Software ("Installable Software Agreement") and such\n\
- Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
- with the Specification. Such Installable Software Agreement must inform the user of the\n\
- terms and conditions that govern the Installable Software and must solicit acceptance by\n\
- the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
- indication of agreement by the user, the provisioning Technology will complete installation\n\
- of the Installable Software.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use, and\n\
-re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
diff --git a/org.eclipse.cdt.mylyn/feature.xml b/org.eclipse.cdt.mylyn/feature.xml
deleted file mode 100644
index 1fbe188..0000000
--- a/org.eclipse.cdt.mylyn/feature.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
- %description
-
-
-
- %copyright
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
diff --git a/org.eclipse.cdt.mylyn/license.html b/org.eclipse.cdt.mylyn/license.html
deleted file mode 100644
index f19c483..0000000
--- a/org.eclipse.cdt.mylyn/license.html
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-
-
-Eclipse Foundation Software User Agreement
-
-
-
-
Eclipse Foundation Software User Agreement
-
February 1, 2011
-
-
Usage Of Content
-
-
THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.
-
-
Applicable Licenses
-
-
Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.
- For purposes of the EPL, "Program" will mean the Content.
-
-
Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
- repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").
-
-
-
Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
-
Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
-
A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.
-
Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.
-
-
-
The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and
-Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:
-
-
-
The top-level (root) directory
-
Plug-in and Fragment directories
-
Inside Plug-ins and Fragments packaged as JARs
-
Sub-directories of the directory named "src" of certain Plug-ins
-
Feature directories
-
-
-
Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.
-
-
THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):
IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.
-
-
-
Use of Provisioning Technology
-
-
The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
- Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or
- other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to
- install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html
- ("Specification").
-
-
You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
- applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
- in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
- Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:
-
-
-
A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology
- on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based
- product.
-
During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
- accessed and copied to the Target Machine.
-
Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
- Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target
- Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
- the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
- indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.
-
-
-
Cryptography
-
-
Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.
-
-
Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.
-
-
1. DEFINITIONS
-
-
"Contribution" means:
-
-
a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and
-b) in the case of each subsequent Contributor:
-
-
i)
-changes to the Program, and
-
-
ii)
-additions to the Program;
-
-
where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program.
-
-
"Contributor" means any person or
-entity that distributes the Program.
-
-
"Licensed Patents " mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program.
-
-
"Program" means the Contributions
-distributed in accordance with this Agreement.
-
-
"Recipient" means anyone who
-receives the Program under this Agreement, including all Contributors.
-
-
2. GRANT OF RIGHTS
-
-
a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license toreproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.
-
-
b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder.
-
-
c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.
-
-
d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement.
-
-
3. REQUIREMENTS
-
-
A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:
-
-
-
a)
-it complies with the terms and conditions of this Agreement; and
-
-
b)
-its license agreement:
-
-
i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose;
-
-
ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits;
-
-
iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and
-
-
iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.
-
-
When the Program is made available in source
-code form:
-
-
a)
-it must be made available under this Agreement; and
-
-
b) a
-copy of this Agreement must be included with each copy of the Program.
-
-
Contributors may not remove or alter any
-copyright notices contained within the Program.
-
-
Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution.
-
-
4. COMMERCIAL DISTRIBUTION
-
-
Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor ("Commercial
-Contributor") hereby agrees to defend and indemnify every other
-Contributor ("Indemnified Contributor") against any losses, damages and
-costs (collectively "Losses") arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.
-
-
For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.
-
-
5. NO WARRANTY
-
-
EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations.
-
-
6. DISCLAIMER OF LIABILITY
-
-
EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.
-
-
7. GENERAL
-
-
If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.
-
-
If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed.
-
-
All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive.
-
-
Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.
-
-
This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/org.eclipse.cdt.platform/feature.properties b/org.eclipse.cdt.platform/feature.properties
deleted file mode 100644
index 8e5dfa7..0000000
--- a/org.eclipse.cdt.platform/feature.properties
+++ /dev/null
@@ -1,167 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2011 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
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-# features.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=C/C++ Development Platform
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse CDT
-
-# "updateSiteName" property - label for the update site
-updateSiteName=Eclipse CDT Update Site
-
-# "description" property - description of the feature
-description=Eclipse C/C++ development platform. Contains no toolchain integrations. Included in C/C++ Development Tools.
-
-# copyright
-copyright=\
-Copyright (c) 2002, 2011 QNX Software Systems and others.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-licenseURL=license.html
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-license=\
-Eclipse Foundation Software User Agreement\n\
-February 1, 2011\n\
-\n\
-Usage Of Content\n\
-\n\
-THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\
-OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\
-USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\
-AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\
-NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\
-AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\
-AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\
-OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\
-TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\
-OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\
-BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\
-\n\
-Applicable Licenses\n\
-\n\
-Unless otherwise indicated, all Content made available by the\n\
-Eclipse Foundation is provided to you under the terms and conditions of\n\
-the Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is\n\
-provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\
-For purposes of the EPL, "Program" will mean the Content.\n\
-\n\
-Content includes, but is not limited to, source code, object code,\n\
-documentation and other files maintained in the Eclipse Foundation source code\n\
-repository ("Repository") in software modules ("Modules") and made available\n\
-as downloadable archives ("Downloads").\n\
-\n\
- - Content may be structured and packaged into modules to facilitate delivering,\n\
- extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\
- plug-in fragments ("Fragments"), and features ("Features").\n\
- - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java(TM) ARchive)\n\
- in a directory named "plugins".\n\
- - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\
- Each Feature may be packaged as a sub-directory in a directory named "features".\n\
- Within a Feature, files named "feature.xml" may contain a list of the names and version\n\
- numbers of the Plug-ins and/or Fragments associated with that Feature.\n\
- - Features may also include other Features ("Included Features"). Within a Feature, files\n\
- named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\
-\n\
-The terms and conditions governing Plug-ins and Fragments should be\n\
-contained in files named "about.html" ("Abouts"). The terms and\n\
-conditions governing Features and Included Features should be contained\n\
-in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\
-Licenses may be located in any directory of a Download or Module\n\
-including, but not limited to the following locations:\n\
-\n\
- - The top-level (root) directory\n\
- - Plug-in and Fragment directories\n\
- - Inside Plug-ins and Fragments packaged as JARs\n\
- - Sub-directories of the directory named "src" of certain Plug-ins\n\
- - Feature directories\n\
-\n\
-Note: if a Feature made available by the Eclipse Foundation is installed using the\n\
-Provisioning Technology (as defined below), you must agree to a license ("Feature \n\
-Update License") during the installation process. If the Feature contains\n\
-Included Features, the Feature Update License should either provide you\n\
-with the terms and conditions governing the Included Features or inform\n\
-you where you can locate them. Feature Update Licenses may be found in\n\
-the "license" property of files named "feature.properties" found within a Feature.\n\
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the\n\
-terms and conditions (or references to such terms and conditions) that\n\
-govern your use of the associated Content in that directory.\n\
-\n\
-THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER\n\
-TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\
-SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\
-\n\
- - Eclipse Distribution License Version 1.0 (available at http://www.eclipse.org/licenses/edl-v1.0.html)\n\
- - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\
- - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\
- - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\
- - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\
- - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\
-\n\
-IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\
-TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License\n\
-is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\
-govern that particular Content.\n\
-\n\
-\n\Use of Provisioning Technology\n\
-\n\
-The Eclipse Foundation makes available provisioning software, examples of which include,\n\
-but are not limited to, p2 and the Eclipse Update Manager ("Provisioning Technology") for\n\
-the purpose of allowing users to install software, documentation, information and/or\n\
-other materials (collectively "Installable Software"). This capability is provided with\n\
-the intent of allowing such users to install, extend and update Eclipse-based products.\n\
-Information about packaging Installable Software is available at\n\
-http://eclipse.org/equinox/p2/repository_packaging.html ("Specification").\n\
-\n\
-You may use Provisioning Technology to allow other parties to install Installable Software.\n\
-You shall be responsible for enabling the applicable license agreements relating to the\n\
-Installable Software to be presented to, and accepted by, the users of the Provisioning Technology\n\
-in accordance with the Specification. By using Provisioning Technology in such a manner and\n\
-making it available in accordance with the Specification, you further acknowledge your\n\
-agreement to, and the acquisition of all necessary rights to permit the following:\n\
-\n\
- 1. A series of actions may occur ("Provisioning Process") in which a user may execute\n\
- the Provisioning Technology on a machine ("Target Machine") with the intent of installing,\n\
- extending or updating the functionality of an Eclipse-based product.\n\
- 2. During the Provisioning Process, the Provisioning Technology may cause third party\n\
- Installable Software or a portion thereof to be accessed and copied to the Target Machine.\n\
- 3. Pursuant to the Specification, you will provide to the user the terms and conditions that\n\
- govern the use of the Installable Software ("Installable Software Agreement") and such\n\
- Installable Software Agreement shall be accessed from the Target Machine in accordance\n\
- with the Specification. Such Installable Software Agreement must inform the user of the\n\
- terms and conditions that govern the Installable Software and must solicit acceptance by\n\
- the end user in the manner prescribed in such Installable Software Agreement. Upon such\n\
- indication of agreement by the user, the provisioning Technology will complete installation\n\
- of the Installable Software.\n\
-\n\
-Cryptography\n\
-\n\
-Content may contain encryption software. The country in which you are\n\
-currently may have restrictions on the import, possession, and use,\n\
-and/or re-export to another country, of encryption software. BEFORE\n\
-using any encryption software, please check the country's laws,\n\
-regulations and policies concerning the import, possession, or use, and\n\
-re-export of encryption software, to see if this is permitted.\n\
-\n\
-Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.\n
-########### end of license property ##########################################
diff --git a/org.eclipse.cdt.platform/feature.xml b/org.eclipse.cdt.platform/feature.xml
deleted file mode 100644
index 046473a..0000000
--- a/org.eclipse.cdt.platform/feature.xml
+++ /dev/null
@@ -1,273 +0,0 @@
-
-
-
-
- %description
-
-
-
- %copyright
-
-
-
- %license
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/org.eclipse.cdt.platform/license.html b/org.eclipse.cdt.platform/license.html
deleted file mode 100644
index f19c483..0000000
--- a/org.eclipse.cdt.platform/license.html
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-
-
-Eclipse Foundation Software User Agreement
-
-
-
-
Eclipse Foundation Software User Agreement
-
February 1, 2011
-
-
Usage Of Content
-
-
THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.
-
-
Applicable Licenses
-
-
Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html.
- For purposes of the EPL, "Program" will mean the Content.
-
-
Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse Foundation source code
- repository ("Repository") in software modules ("Modules") and made available as downloadable archives ("Downloads").
-
-
-
Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
-
Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
-
A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.
-
Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.
-
-
-
The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and
-Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:
-
-
-
The top-level (root) directory
-
Plug-in and Fragment directories
-
Inside Plug-ins and Fragments packaged as JARs
-
Sub-directories of the directory named "src" of certain Plug-ins
-
Feature directories
-
-
-
Note: if a Feature made available by the Eclipse Foundation is installed using the Provisioning Technology (as defined below), you must agree to a license ("Feature Update License") during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the "license" property of files named "feature.properties" found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.
-
-
THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):
IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.
-
-
-
Use of Provisioning Technology
-
-
The Eclipse Foundation makes available provisioning software, examples of which include, but are not limited to, p2 and the Eclipse
- Update Manager ("Provisioning Technology") for the purpose of allowing users to install software, documentation, information and/or
- other materials (collectively "Installable Software"). This capability is provided with the intent of allowing such users to
- install, extend and update Eclipse-based products. Information about packaging Installable Software is available at http://eclipse.org/equinox/p2/repository_packaging.html
- ("Specification").
-
-
You may use Provisioning Technology to allow other parties to install Installable Software. You shall be responsible for enabling the
- applicable license agreements relating to the Installable Software to be presented to, and accepted by, the users of the Provisioning Technology
- in accordance with the Specification. By using Provisioning Technology in such a manner and making it available in accordance with the
- Specification, you further acknowledge your agreement to, and the acquisition of all necessary rights to permit the following:
-
-
-
A series of actions may occur ("Provisioning Process") in which a user may execute the Provisioning Technology
- on a machine ("Target Machine") with the intent of installing, extending or updating the functionality of an Eclipse-based
- product.
-
During the Provisioning Process, the Provisioning Technology may cause third party Installable Software or a portion thereof to be
- accessed and copied to the Target Machine.
-
Pursuant to the Specification, you will provide to the user the terms and conditions that govern the use of the Installable
- Software ("Installable Software Agreement") and such Installable Software Agreement shall be accessed from the Target
- Machine in accordance with the Specification. Such Installable Software Agreement must inform the user of the terms and conditions that govern
- the Installable Software and must solicit acceptance by the end user in the manner prescribed in such Installable Software Agreement. Upon such
- indication of agreement by the user, the provisioning Technology will complete installation of the Installable Software.
-
-
-
Cryptography
-
-
Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.
-
-
Java and all Java-based trademarks are trademarks of Oracle Corporation in the United States, other countries, or both.
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
-at http://www.eclipse.org/legal/epl-v10.html.
-For purposes of the EPL, "Program" will mean the Content.
-
-
If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party ("Redistributor") and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at http://www.eclipse.org.
-
Third Party Content
-
The Content includes items that have been sourced from third parties as set out below. If you did not receive this Content directly from the Eclipse Foundation, the following is provided for informational purposes only, and you should look to the Redistributor’s license for terms and conditions of use.
-
Ispell 3.1.20
-
The plug-in is accompanied by software developed by Geoff Kuenning. The following files:
Your use of Ispell 3.1.20 in the plug-in is subject to the terms and conditions of the Ispell license. A copy of the Ispell license is included in about_files/ispell-license.txt and is also reproduced below:
-
Copyright 1993, Geoff Kuenning, Granada Hills, CA
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- 3. All modifications to the source code must be clearly marked as
- such. Binary redistributions based on modified source code
- must be clearly marked as modified versions in the documentation
- and/or other materials provided with the distribution.
- 4. All advertising materials mentioning features or use of this software
- must display the following acknowledgment:
- This product includes software developed by Geoff Kuenning and
- other unpaid contributors.
- 5. The name of Geoff Kuenning may not be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
- THIS SOFTWARE IS PROVIDED BY GEOFF KUENNING AND CONTRIBUTORS ``AS
- IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GEOFF
- KUENNING OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE
- * This is used for performance optimization.
- *
- */
- public static final boolean USE_TEXT_PROCESSOR;
- static {
- String testString= "args : String[]"; //$NON-NLS-1$
- USE_TEXT_PROCESSOR= testString != TextProcessor.process(testString);
- }
-
- private static final String C_ELEMENT_DELIMITERS= TextProcessor.getDefaultDelimiters() + "<>(),?{} "; //$NON-NLS-1$
-
- public static boolean startsWithIgnoreCase(CharSequence text, CharSequence prefix) {
- int textLength= text.length();
- int prefixLength= prefix.length();
- if (textLength < prefixLength)
- return false;
- for (int i= prefixLength - 1; i >= 0; i--) {
- if (Character.toLowerCase(prefix.charAt(i)) != Character.toLowerCase(text.charAt(i)))
- return false;
- }
- return true;
- }
-
- public static boolean endsWith(CharSequence containing, CharSequence contained) {
- int start = containing.length() - contained.length();
- if (start < 0)
- return false;
- for (int i = start, j = 0; i < containing.length(); i++, j++) {
- if (containing.charAt(i) != contained.charAt(j))
- return false;
- }
- return true;
- }
-
- public static String removeNewLine(String message) {
- StringBuffer result= new StringBuffer();
- int current= 0;
- int index= message.indexOf('\n', 0);
- while (index != -1) {
- result.append(message.substring(current, index));
- if (current < index && index != 0)
- result.append(' ');
- current= index + 1;
- index= message.indexOf('\n', current);
- }
- result.append(message.substring(current));
- return result.toString();
- }
-
- /**
- * Converts the given string into an array of lines. The lines
- * don't contain any line delimiter characters.
- *
- * @return the string converted into an array of strings. Returns
- * null if the input string can't be converted in an array of lines.
- */
- public static String[] convertIntoLines(String input) {
- try {
- ILineTracker tracker= new DefaultLineTracker();
- tracker.set(input);
- int size= tracker.getNumberOfLines();
- String result[]= new String[size];
- for (int i= 0; i < size; i++) {
- IRegion region= tracker.getLineInformation(i);
- int offset= region.getOffset();
- result[i]= input.substring(offset, offset + region.getLength());
- }
- return result;
- } catch (BadLocationException e) {
- return null;
- }
- }
-
- /**
- * Returns true if the given string only consists of
- * white spaces according to C. If the string is empty, true
- * is returned.
- *
- * @return true if the string only consists of white
- * spaces; otherwise false is returned
- *
- * @see java.lang.Character#isWhitespace(char)
- */
- public static boolean containsOnlyWhitespaces(String s) {
- int size= s.length();
- for (int i= 0; i < size; i++) {
- if (!Character.isWhitespace(s.charAt(i)))
- return false;
- }
- return true;
- }
-
- /**
- * Removes leading tabs and spaces from the given string. If the string
- * doesn't contain any leading tabs or spaces then the string itself is
- * returned.
- */
- public static String trimLeadingTabsAndSpaces(String line) {
- int size= line.length();
- int start= size;
- for (int i= 0; i < size; i++) {
- char c= line.charAt(i);
- if (!IndentManipulation.isIndentChar(c)) {
- start= i;
- break;
- }
- }
- if (start == 0)
- return line;
- else if (start == size)
- return ""; //$NON-NLS-1$
- else
- return line.substring(start);
- }
-
- public static String trimTrailingTabsAndSpaces(String line) {
- int size= line.length();
- int end= size;
- for (int i= size - 1; i >= 0; i--) {
- char c= line.charAt(i);
- if (IndentManipulation.isIndentChar(c)) {
- end= i;
- } else {
- break;
- }
- }
- if (end == size)
- return line;
- else if (end == 0)
- return ""; //$NON-NLS-1$
- else
- return line.substring(0, end);
- }
-
- /**
- * Returns the indent of the given string in indentation units. Odd spaces
- * are not counted.
- *
- * @param line the text line
- * @param project the project from which to get the formatter
- * preferences, or null for global preferences
- * @since 5.0
- */
- public static int computeIndentUnits(String line, ICProject project) {
- return IndentManipulation.measureIndentUnits(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
- }
-
- /**
- * Returns the indent of the given string in indentation units. Odd spaces
- * are not counted.
- *
- * @param line the text line
- * @param tabWidth the width of the '\t' character in space equivalents
- * @param indentWidth the width of one indentation unit in space equivalents
- * @since 5.0
- */
- public static int computeIndentUnits(String line, int tabWidth, int indentWidth) {
- return IndentManipulation.measureIndentUnits(line, tabWidth, indentWidth);
- }
-
- /**
- * Computes the visual length of the indentation of a
- * CharSequence, counting a tab character as the size until
- * the next tab stop and every other whitespace character as one.
- *
- * @param line the string to measure the indent of
- * @param tabSize the visual size of a tab in space equivalents
- * @return the visual length of the indentation of line
- * @since 5.0
- */
- public static int measureIndentLength(CharSequence line, int tabSize) {
- return IndentManipulation.measureIndentInSpaces(line, tabSize);
- }
-
- /**
- * Removes the given number of indents from the line. Asserts that the given line
- * has the requested number of indents. If indentsToRemove <= 0
- * the line is returned.
- *
- * @param project the project from which to get the formatter
- * preferences, or null for global preferences
- * @since 5.0
- */
- public static String trimIndent(String line, int indentsToRemove, ICProject project) {
- return IndentManipulation.trimIndent(line, indentsToRemove, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
- }
-
- /**
- * Removes the given number of indents from the line. Asserts that the given line
- * has the requested number of indents. If indentsToRemove <= 0
- * the line is returned.
- *
- * @since 5.0
- */
- public static String trimIndent(String line, int indentsToRemove, int tabWidth, int indentWidth) {
- return IndentManipulation.trimIndent(line, indentsToRemove, tabWidth, indentWidth);
- }
-
- /**
- * Removes the common number of indents from all lines. If a line
- * only consists out of white space it is ignored.
-
- * @param project the project from which to get the formatter
- * preferences, or null for global preferences
- * @since 5.0
- */
- public static void trimIndentation(String[] lines, ICProject project) {
- trimIndentation(lines, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), true);
- }
- /**
- * Removes the common number of indents from all lines. If a line
- * only consists out of white space it is ignored.
- *
- * @since 5.0
- */
- public static void trimIndentation(String[] lines, int tabWidth, int indentWidth) {
- trimIndentation(lines, tabWidth, indentWidth, true);
- }
-
- /**
- * Removes the common number of indents from all lines. If a line
- * only consists out of white space it is ignored. If
- * considerFirstLine is false the first line will be ignored.
- *
- * @param project the project from which to get the formatter
- * preferences, or null for global preferences
- * @since 5.0
- */
- public static void trimIndentation(String[] lines, ICProject project, boolean considerFirstLine) {
- trimIndentation(lines, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), considerFirstLine);
- }
-
- /**
- * Removes the common number of indents from all lines. If a line
- * only consists out of white space it is ignored. If
- * considerFirstLine is false the first line will be ignored.
- * @since 5.0
- */
- public static void trimIndentation(String[] lines, int tabWidth, int indentWidth, boolean considerFirstLine) {
- String[] toDo= new String[lines.length];
- // find indentation common to all lines
- int minIndent= Integer.MAX_VALUE; // very large
- for (int i= considerFirstLine ? 0 : 1; i < lines.length; i++) {
- String line= lines[i];
- if (containsOnlyWhitespaces(line))
- continue;
- toDo[i]= line;
- int indent= computeIndentUnits(line, tabWidth, indentWidth);
- if (indent < minIndent) {
- minIndent= indent;
- }
- }
-
- if (minIndent > 0) {
- // remove this indent from all lines
- for (int i= considerFirstLine ? 0 : 1; i < toDo.length; i++) {
- String s= toDo[i];
- if (s != null)
- lines[i]= trimIndent(s, minIndent, tabWidth, indentWidth);
- else {
- String line= lines[i];
- int indent= computeIndentUnits(line, tabWidth, indentWidth);
- if (indent > minIndent)
- lines[i]= trimIndent(line, minIndent, tabWidth, indentWidth);
- else
- lines[i]= trimLeadingTabsAndSpaces(line);
- }
- }
- }
- }
-
- /**
- * Returns that part of the indentation of line that makes up
- * a multiple of indentation units.
- *
- * @param line the line to scan
- * @param project the project from which to get the formatter
- * preferences, or null for global preferences
- * @return the indent part of line, but no odd spaces
- * @since 5.0
- */
- public static String getIndentString(String line, ICProject project) {
- return IndentManipulation.extractIndentString(line, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
- }
-
- /**
- * Returns that part of the indentation of line that makes up
- * a multiple of indentation units.
- *
- * @param line the line to scan
- * @param tabWidth the size of one tab in space equivalents
- * @param indentWidth the size of the indent in space equivalents
- * @return the indent part of line, but no odd spaces
- * @since 5.0
- */
- public static String getIndentString(String line, int tabWidth, int indentWidth) {
- return IndentManipulation.extractIndentString(line, tabWidth, indentWidth);
- }
-
- public static String[] removeTrailingEmptyLines(String[] sourceLines) {
- int lastNonEmpty= findLastNonEmptyLineIndex(sourceLines);
- String[] result= new String[lastNonEmpty + 1];
- for (int i= 0; i < result.length; i++) {
- result[i]= sourceLines[i];
- }
- return result;
- }
-
- private static int findLastNonEmptyLineIndex(String[] sourceLines) {
- for (int i= sourceLines.length - 1; i >= 0; i--) {
- if (! sourceLines[i].trim().equals(""))//$NON-NLS-1$
- return i;
- }
- return -1;
- }
-
- /**
- * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added.
- * The first line of the code will not be changed. (It is considered to have no indent as it might start in
- * the middle of a line)
- *
- * @param project the project from which to get the formatter
- * preferences, or null for global preferences
- * @since 5.0
- */
- public static String changeIndent(String code, int codeIndentLevel, ICProject project, String newIndent, String lineDelim) {
- return IndentManipulation.changeIndent(code, codeIndentLevel, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), newIndent, lineDelim);
- }
-
- /**
- * Change the indent of, possible muti-line, code range. The current indent is removed, a new indent added.
- * The first line of the code will not be changed. (It is considered to have no indent as it might start in
- * the middle of a line)
- * @since 5.0
- */
- public static String changeIndent(String code, int codeIndentLevel, int tabWidth, int indentWidth, String newIndent, String lineDelim) {
- return IndentManipulation.changeIndent(code, codeIndentLevel, tabWidth, indentWidth, newIndent, lineDelim);
- }
-
- public static String trimIndentation(String source, ICProject project, boolean considerFirstLine) {
- return trimIndentation(source, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project), considerFirstLine);
- }
-
- public static String trimIndentation(String source, int tabWidth, int indentWidth, boolean considerFirstLine) {
- try {
- ILineTracker tracker= new DefaultLineTracker();
- tracker.set(source);
- int size= tracker.getNumberOfLines();
- if (size == 1)
- return source;
- String lines[]= new String[size];
- for (int i= 0; i < size; i++) {
- IRegion region= tracker.getLineInformation(i);
- int offset= region.getOffset();
- lines[i]= source.substring(offset, offset + region.getLength());
- }
- Strings.trimIndentation(lines, tabWidth, indentWidth, considerFirstLine);
- StringBuffer result= new StringBuffer();
- int last= size - 1;
- for (int i= 0; i < size; i++) {
- result.append(lines[i]);
- if (i < last)
- result.append(tracker.getLineDelimiter(i));
- }
- return result.toString();
- } catch (BadLocationException e) {
- Assert.isTrue(false,"Can not happend"); //$NON-NLS-1$
- return null;
- }
- }
-
- /**
- * Concatenate the given strings into one strings using the passed line delimiter as a
- * delimiter. No delimiter is added to the last line.
- */
- public static String concatenate(String[] lines, String delimiter) {
- StringBuffer buffer= new StringBuffer();
- for (int i= 0; i < lines.length; i++) {
- if (i > 0)
- buffer.append(delimiter);
- buffer.append(lines[i]);
- }
- return buffer.toString();
- }
-
- public static boolean equals(String s, char[] c) {
- if (s.length() != c.length)
- return false;
-
- for (int i = c.length; --i >= 0;) {
- if (s.charAt(i) != c[i])
- return false;
- }
- return true;
- }
-
- public static String removeTrailingCharacters(String text, char toRemove) {
- int size= text.length();
- int end= size;
- for (int i= size - 1; i >= 0; i--) {
- char c= text.charAt(i);
- if (c == toRemove) {
- end= i;
- } else {
- break;
- }
- }
- if (end == size)
- return text;
- else if (end == 0)
- return ""; //$NON-NLS-1$
- else
- return text.substring(0, end);
- }
-
- /**
- * Converts tabs to spaces in a line of text.
- * @param line The line of text.
- * @param tabWidth Tabulation size.
- * @return The line with tab characters replaced by spaces.
- */
- public static String convertTabsToSpaces(String line, int tabWidth) {
- StringBuilder buf = null;
- for (int i = 0; i < line.length(); i++) {
- char c = line.charAt(i);
- if (c == '\t') {
- if (buf == null) {
- buf = new StringBuilder(line.length() * tabWidth);
- buf.append(line.subSequence(0, i));
- }
- for (int k = tabWidth - i % tabWidth; --k >= 0;) {
- buf.append(' ');
- }
- } else if (buf != null) {
- buf.append(c);
- }
- }
- return buf != null ? buf.toString() : line;
- }
-
- public static String removeMnemonicIndicator(String string) {
- return LegacyActionTools.removeMnemonics(string);
- }
-
-
- /**
- * Adds special marks so that that the given styled string is readable in a BiDi environment.
- *
- * @param styledString the styled string
- * @return the processed styled string
- */
- public static StyledString markLTR(StyledString styledString) {
-
- /*
- * NOTE: For performance reasons we do not call markLTR(styledString, null)
- */
-
- if (!USE_TEXT_PROCESSOR)
- return styledString;
-
- String inputString= styledString.getString();
- String string= TextProcessor.process(inputString);
- if (string != inputString)
- insertMarks(styledString, inputString, string);
- return styledString;
- }
-
- /**
- * Adds special marks so that that the given styled string is readable in a BiDi environment.
- *
- * @param styledString the styled string
- * @param delimiters the additional delimiters
- * @return the processed styled string
- */
- public static StyledString markLTR(StyledString styledString, String delimiters) {
- if (!USE_TEXT_PROCESSOR)
- return styledString;
-
- String inputString= styledString.getString();
- String string= TextProcessor.process(inputString, delimiters);
- if (string != inputString)
- insertMarks(styledString, inputString, string);
- return styledString;
- }
-
- /**
- * Adds special marks so that that the given string is readable in a BiDi environment.
- *
- * @param string the string
- * @return the processed styled string
- * @since 5.3
- */
- public static String markLTR(String string) {
- if (!USE_TEXT_PROCESSOR)
- return string;
-
- return TextProcessor.process(string);
- }
-
- /**
- * Adds special marks so that that the given string is readable in a BiDi environment.
- *
- * @param string the string
- * @param delimiters the delimiters
- * @return the processed styled string
- * @since 5.3
- */
- public static String markLTR(String string, String delimiters) {
- if (!USE_TEXT_PROCESSOR)
- return string;
-
- return TextProcessor.process(string, delimiters);
- }
-
- /**
- * Adds special marks so that that the given C element label is readable in a BiDi
- * environment.
- *
- * @param string the string
- * @return the processed styled string
- * @since 5.3
- */
- public static String markCElementLabelLTR(String string) {
- if (!USE_TEXT_PROCESSOR)
- return string;
-
- return TextProcessor.process(string, C_ELEMENT_DELIMITERS);
- }
-
- /**
- * Adds special marks so that that the given styled C element label is readable in a BiDi
- * environment.
- *
- * @param styledString the styled string
- * @return the processed styled string
- * @since 5.3
- */
- public static StyledString markCElementLabelLTR(StyledString styledString) {
- if (!USE_TEXT_PROCESSOR)
- return styledString;
-
- String inputString= styledString.getString();
- String string= TextProcessor.process(inputString, C_ELEMENT_DELIMITERS);
- if (string != inputString)
- insertMarks(styledString, inputString, string);
- return styledString;
- }
-
- /**
- * Inserts the marks into the given styled string.
- *
- * @param styledString the styled string
- * @param originalString the original string
- * @param processedString the processed string
- * @since 5.3
- */
- private static void insertMarks(StyledString styledString, String originalString, String processedString) {
- int originalLength= originalString.length();
- int processedStringLength= processedString.length();
- char orig= originalLength > 0 ? originalString.charAt(0) : '\0';
- for (int o= 0, p= 0; p < processedStringLength; p++) {
- char processed= processedString.charAt(p);
- if (o < originalLength) {
- if (orig == processed) {
- o++;
- if (o < originalLength)
- orig= originalString.charAt(o);
- continue;
- }
- }
- styledString.insert(processed, p);
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
deleted file mode 100644
index 9672a1c..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java
+++ /dev/null
@@ -1,784 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.IArchiveContainer;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryContainer;
-import org.eclipse.cdt.core.model.IBinaryModule;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IInclude;
-import org.eclipse.cdt.core.model.IMacro;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.INamespace;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.ui.CDTUITools;
-import org.eclipse.cdt.ui.CElementGrouping;
-import org.eclipse.cdt.ui.IncludesGrouping;
-import org.eclipse.cdt.ui.NamespacesGrouping;
-
-/**
- * A base content provider for C elements. It provides access to the
- * C element hierarchy without listening to changes in the C model.
- * Use this class when you want to present the C elements
- * in a modal dialog or wizard.
- *
- * The following C element hierarchy is surfaced by this content provider:
- *
- *
-C model (ICModel)
- C project (ICProject)
- Source root (ISourceRoot)
- C Container(folders) (ICContainer)
- Translation unit (ITranslationUnit)
- Binary file (IBinary)
- Archive file (IArchive)
- Non C Resource file (Object)
-
- *
- */
-public class BaseCElementContentProvider implements ITreeContentProvider {
-
- protected static final Object[] NO_CHILDREN= new Object[0];
-
- protected boolean fProvideMembers= false;
- protected boolean fProvideWorkingCopy= false;
- protected boolean fIncludesGrouping= false;
- protected boolean fNamespacesGrouping= false;
- protected boolean fMemberGrouping= false;
- protected boolean fMacroGrouping= false;
-
- public BaseCElementContentProvider() {
- this(false, false);
- }
-
- public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
- fProvideMembers= provideMembers;
- fProvideWorkingCopy= provideWorkingCopy;
- }
-
- /**
- * Returns whether the members are provided when asking
- * for a TU's children.
- */
- public boolean getProvideMembers() {
- return fProvideMembers;
- }
-
- /**
- * Returns whether the members are provided when asking
- * for a TU's children.
- */
- public void setProvideMembers(boolean b) {
- fProvideMembers= b;
- }
-
- /**
- * Sets whether the members are provided from
- * a working copy of a compilation unit
- */
- public void setProvideWorkingCopy(boolean b) {
- fProvideWorkingCopy= b;
- }
-
- /**
- * Returns whether the members are provided
- * from a working copy a compilation unit.
- */
- public boolean getProvideWorkingCopy() {
- return fProvideWorkingCopy;
- }
-
- /**
- * Can elements be group.
- */
- public boolean areIncludesGroup() {
- return fIncludesGrouping;
- }
-
- /**
- * Allow Elements to be group.
- * @param b
- */
- public void setIncludesGrouping(boolean b) {
- fIncludesGrouping = b;
- }
-
- /**
- * Can elements be group.
- */
- public boolean areNamespacesGroup() {
- return fNamespacesGrouping;
- }
-
- /**
- * Allow Elements to be group.
- * @param b
- */
- public void setNamespacesGrouping(boolean b) {
- fNamespacesGrouping = b;
- }
-
- /**
- * @return whether grouping of members is enabled
- */
- public boolean isMemberGroupingEnabled() {
- return fMemberGrouping;
- }
-
- /**
- * Enable/disable member grouping by common namespace.
- * @param enable
- */
- public void setMemberGrouping(boolean enable) {
- fMemberGrouping = enable;
- }
-
- /**
- * @return whether grouping of macros is enabled
- */
- public boolean isMacroGroupingEnabled() {
- return fMacroGrouping;
- }
-
- /**
- * Enable/disable marco grouping
- * @param enable
- */
- public void setMacroGrouping(boolean enable) {
- fMacroGrouping = enable;
- }
-
- /* (non-Cdoc)
- * Method declared on IContentProvider.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- /* (non-Cdoc)
- * Method declared on IContentProvider.
- */
- public void dispose() {
- }
-
- /* (non-Cdoc)
- * Method declared on IStructuredContentProvider.
- */
- public Object[] getElements(Object parent) {
- return getChildren(parent);
- }
-
- /* (non-Cdoc)
- * Method declared on ITreeContentProvider.
- */
- public Object[] getChildren(Object element) {
- if (!exists(element))
- return NO_CHILDREN;
-
- try {
- if (element instanceof ICModel) {
- return getCProjects((ICModel)element);
- } else if (element instanceof ICProject ) {
- return getSourceRoots((ICProject)element);
- } else if (element instanceof ICContainer) {
- return getCResources((ICContainer)element);
- } else if (element instanceof ITranslationUnit) {
- // if we want to get the children of a translation unit
- if (fProvideMembers) {
- // if we want to use the working copy of it
- ITranslationUnit tu = (ITranslationUnit)element;
- if (fProvideWorkingCopy){
- // if it is not already a working copy
- if (!(element instanceof IWorkingCopy)){
- // if it has a valid working copy
- IWorkingCopy copy = CDTUITools.getWorkingCopyManager().findSharedWorkingCopy(tu);
- if (copy != null) {
- tu = copy;
- }
- }
- }
- return getTranslationUnitChildren(tu);
- }
- } else if (element instanceof IBinary) {
- return ((IBinary)element).getChildren();
- } else if (element instanceof IArchive) {
- return ((IArchive)element).getChildren();
- } else if (element instanceof IBinaryModule) {
- return ((IBinaryModule)element).getChildren();
- } else if (element instanceof INamespace) {
- return getNamespaceChildren((INamespace) element);
- } else if (element instanceof ISourceReference && element instanceof IParent) {
- return ((IParent)element).getChildren();
- } else if (element instanceof IProject) {
- return getResources((IProject)element);
- } else if (element instanceof IFolder) {
- return getResources((IFolder)element);
- } else if (element instanceof CElementGrouping) {
- return ((CElementGrouping)element).getChildren(element);
- }
- } catch (CModelException e) {
- //CUIPlugin.log(e);
- return NO_CHILDREN;
- }
- return NO_CHILDREN;
- }
-
- /* (non-Cdoc)
- *
- * @see ITreeContentProvider
- */
- public boolean hasChildren(Object element) {
- if (fProvideMembers) {
- // assume TUs and binary files are never empty
- if (element instanceof IBinary || element instanceof ITranslationUnit || element instanceof IArchive) {
- return true;
- }
- } else {
- // don't allow to drill down into a compilation unit or class file
- if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive
- || element instanceof IFile) {
- return false;
- }
- }
-
- if (element instanceof ICProject) {
- ICProject cp= (ICProject)element;
- if (!cp.getProject().isOpen()) {
- return false;
- }
- return true;
- }
-
- if (element instanceof ICContainer) {
- ICContainer container= (ICContainer)element;
- IResource resource= container.getResource();
- if (resource instanceof IContainer) {
- try {
- return ((IContainer)resource).members().length > 0;
- } catch (CoreException exc) {
- return false;
- }
- }
- }
-
- if (element instanceof IParent) {
- // when we have C children return true, else we fetch all the children
- if (((IParent)element).hasChildren()) {
- return true;
- }
- }
-
- if (element instanceof CElementGrouping) {
- return true;
- }
-
- Object[] children= getChildren(element);
- return (children != null) && children.length > 0;
- }
-
- /* (non-Cdoc)
- * Method declared on ITreeContentProvider.
- */
- public Object getParent(Object element) {
- if (!exists(element)) {
- return null;
- }
- return internalGetParent(element);
- }
-
- public Object internalGetParent(Object element) {
- if (element instanceof IResource) {
- IResource parent= ((IResource)element).getParent();
- if (parent != null && parent.isAccessible()) {
- ICElement cParent= CoreModel.getDefault().create(parent);
- if (cParent != null && cParent.exists()) {
- return cParent;
- }
- }
- return parent;
- }
- Object parent = null;
- if (element instanceof ICElement) {
- if (element instanceof ISourceRoot && !CCorePlugin.showSourceRootsAtTopOfProject()) {
- parent = ((ICElement) element).getResource().getParent();
- if (parent instanceof IProject) {
- return ((ICElement) element).getCProject();
- }
- }
- else
- parent = ((ICElement)element).getParent();
- // translate working copy parent to original TU,
- // because working copies are never returned by getChildren
- // this is necessary for proper show-in-target support
- if (parent instanceof IWorkingCopy) {
- parent= ((IWorkingCopy)parent).getOriginalElement();
- }
- } else if (element instanceof IWorkbenchAdapter) {
- parent = ((IWorkbenchAdapter)element).getParent(element);
- }
-
- // if the parent is the default ISourceRoot == ICProject return the project
- if (parent instanceof ISourceRoot) {
- if (isProjectSourceRoot((ISourceRoot)parent)) {
- parent = ((ISourceRoot)parent).getCProject();
- }
- } else if (parent instanceof IBinaryContainer || parent instanceof IArchiveContainer) {
- // If the virtual container is the parent we must find the legitimate parent.
- if (element instanceof ICElement) {
- IResource res = ((ICElement)element).getResource();
- if (res != null) {
- parent = internalGetParent(res);
- }
- }
- }
- if (parent instanceof INamespace && fNamespacesGrouping) {
- final INamespace namespace = (INamespace)parent;
- final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace, fMemberGrouping);
- if (grouping.getNamespaces().length > 2) {
- parent = grouping;
- }
- }
- if (parent instanceof IMember && fMemberGrouping) {
- final IMember member = (IMember)parent;
- final String ns = getElementNamespace(member);
- if (ns != null) {
- Object parentParent = member.getParent();
- if (parentParent instanceof INamespace && fNamespacesGrouping) {
- final INamespace namespace = (INamespace)parent;
- final NamespacesGrouping grouping = new NamespacesGrouping(namespace.getTranslationUnit(), namespace);
- if (grouping.getNamespaces().length > 2) {
- parentParent = grouping;
- }
- }
- return new MembersGrouping(parentParent, ns);
- }
- }
- // if we are doing grouping for the includes return the grouping container.
- if (element instanceof IInclude && fIncludesGrouping) {
- parent = new IncludesGrouping(((IInclude)element).getTranslationUnit());
- }
- if (element instanceof IMacro && fMacroGrouping) {
- parent = new MacrosGrouping(((IMacro)element).getTranslationUnit());
- }
- return parent;
- }
-
- protected Object[] getCProjects(ICModel cModel) throws CModelException {
- Object[] objects = cModel.getCProjects();
- try {
- Object[] nonC = cModel.getNonCResources();
- if (nonC.length > 0) {
- objects = concatenate(objects, nonC);
- }
- } catch (CModelException e) {
- //
- }
- return objects;
- }
-
- protected Object[] getSourceRoots(ICProject cproject) throws CModelException {
- if (!cproject.getProject().isOpen())
- return NO_CHILDREN;
-
- List list= new ArrayList();
- ICElement[] children = cproject.getChildren();
- for (ICElement child : children) {
- if (child instanceof ISourceRoot && child.getResource().getType() == IResource.PROJECT) {
- // Was a source root at the project, get the children of this element
- ICElement[] c2 = ((ISourceRoot)child).getChildren();
- for (int k = 0; k < c2.length; ++k)
- list.add(c2[k]);
- } else if (CCorePlugin.showSourceRootsAtTopOfProject()) {
- list.add(child);
- } else if (child instanceof ISourceRoot &&
- child.getResource().getParent().equals(cproject.getProject())) {
- list.add(child);
- }
- }
-
- Object[] objects = list.toArray();
- Object[] nonC = cproject.getNonCResources();
- if (nonC != null && nonC.length > 0) {
- nonC = filterNonCResources(nonC, cproject);
- objects = concatenate(objects, nonC);
- }
-
- return objects;
- }
-
- protected Object[] getTranslationUnitChildren(ITranslationUnit unit) throws CModelException {
- Object[] children = unit.getChildren();
- if (fIncludesGrouping) {
- boolean hasInclude = false;
- ArrayList
- */
- public static final String GROUP_GOTO= ICommonMenuConstants.GROUP_GOTO;
- /**
- * Pop-up menu: name of group for open actions (value "group.open").
- *
- * Examples for open actions are:
- *
- *
Open To
- *
Open With
- *
- *
- */
- public static final String GROUP_OPEN= ICommonMenuConstants.GROUP_OPEN;
-
- /**
- * Pop-up menu: name of group for show actions (value "group.show").
- *
- * Examples for show actions are:
- *
- *
Show in Navigator
- *
Show in Type Hierarchy
- *
- *
- */
- public static final String GROUP_SHOW= ICommonMenuConstants.GROUP_SHOW;
-
- /**
- * Pop-up menu: name of group for new actions (value "group.new").
- *
- * Examples for new actions are:
- *
- *
Create new class
- *
Create new interface
- *
- *
- */
- public static final String GROUP_NEW= ICommonMenuConstants.GROUP_NEW;
-
- /**
- * Pop-up menu: name of group for build actions (value "group.build").
- */
- public static final String GROUP_BUILD= ICommonMenuConstants.GROUP_BUILD;
-
- /**
- * Pop-up menu: name of group for reorganize actions (value "group.reorganize").
- */
- public static final String GROUP_REORGANIZE= ICommonMenuConstants.GROUP_REORGANIZE;
-
- /**
- * Pop-up menu: name of group for code generation or refactoring actions (
- * value "group.generate").
- */
- public static final String GROUP_GENERATE= ICommonMenuConstants.GROUP_GENERATE;
-
- /**
- * Pop-up menu: name of group for search actions (value "group.search").
- */
- public static final String GROUP_SEARCH= ICommonMenuConstants.GROUP_SEARCH;
-
- /**
- * Pop-up menu: name of group for additional actions (value "group.additions").
- */
- public static final String GROUP_ADDITIONS= ICommonMenuConstants.GROUP_ADDITIONS;
-
- /**
- * Pop-up menu: name of group for viewer setup actions (value "group.viewerSetup").
- */
- public static final String GROUP_VIEWER_SETUP= ICommonMenuConstants.GROUP_VIEWER_SETUP;
-
- /**
- * Pop-up menu: name of group for properties actions (value "group.properties").
- */
- public static final String GROUP_PROPERTIES= ICommonMenuConstants.GROUP_PROPERTIES;
-
- /**
- * Pop-up menu: name of group for debug actions (value "group.debug").
- */
- public static final String GROUP_DEBUG= "group.debug"; //$NON-NLS-1$
-}
-
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java
deleted file mode 100644
index ea5364b..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IPaintPositionManager;
-import org.eclipse.jface.text.IPainter;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.swt.custom.LineBackgroundEvent;
-import org.eclipse.swt.custom.LineBackgroundListener;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-
-/**
- * A painter for configurable background painting a range of text lines.
- * Replicates also the functionality of the
- * {@link org.eclipse.jface.text.CursorLinePainter}
- * because only one {@link LineBackgroundListener} is allowed
- * per {@link StyledText} widget.
- *
- * @author anton.leherbauer@windriver.com
- *
- * @since 4.0
- */
-public class LineBackgroundPainter implements IPainter, LineBackgroundListener {
-
- /** The default position type for untyped positions */
- private static final String DEFAULT_TYPE= "__default__"; //$NON-NLS-1$
- /** The position type for the cursor line position */
- private static final String CURSOR_LINE_TYPE= "__cursor_line__"; //$NON-NLS-1$
-
- /** Manager for position changes */
- private IPaintPositionManager fPositionManager;
- /** Indicates whether this painter is active */
- private boolean fIsActive= false;
- /** The text viewer this painter is associated with */
- private ITextViewer fTextViewer;
- /** The viewer's widget */
- private StyledText fTextWidget;
- /** Text positions (cursor line position is always at index 0 */
- private List fPositions= new ArrayList();
- /** Cached text positions */
- private List fLastPositions= new ArrayList();
- /** Temporary changed positions */
- private List fChangedPositions= new ArrayList();
- /** Cursor line position */
- private Position fCursorLine= new TypedPosition(0, 0, CURSOR_LINE_TYPE);
- /** Saved cursor line position */
- private Position fLastCursorLine= new Position(0, 0);
- /** Enablement of the cursor line highlighting */
- private boolean fCursorLineEnabled;
- /** Whether cursor line highlighting is active */
- private boolean fCursorLineActive;
- /** Map of position type to color */
- private Map fColorMap= new HashMap();
-
- /**
- * Creates a new painter for the given text viewer.
- * @param textViewer
- */
- public LineBackgroundPainter(ITextViewer textViewer) {
- super();
- fTextViewer= textViewer;
- fTextWidget= textViewer.getTextWidget();
- fPositions.add(fCursorLine);
- fLastPositions.add(fLastCursorLine);
- }
-
- /**
- * Sets the color in which to draw the background of the given position type.
- *
- * @param positionType the position type for which to specify the background color
- * @param color the color in which to draw the background of the given position type
- */
- public void setBackgroundColor(String positionType, Color color) {
- fColorMap.put(positionType, color);
- }
-
- /**
- * Sets the color in which to draw the background of the cursor line.
- *
- * @param cursorLineColor the color in which to draw the background of the cursor line
- */
- public void setCursorLineColor(Color cursorLineColor) {
- fColorMap.put(CURSOR_LINE_TYPE, cursorLineColor);
- }
-
- /**
- * Sets the color in which to draw the background of untyped positions.
- *
- * @param color the color in which to draw the background of untyped positions
- */
- public void setDefaultColor(Color color) {
- fColorMap.put(DEFAULT_TYPE, color);
- }
-
- /**
- * Enable/disable cursor line highlighting.
- *
- * @param enable
- */
- public void enableCursorLine(boolean enable) {
- fCursorLineEnabled= enable;
- fCursorLineActive= enable;
- if (fCursorLineActive) {
- updateCursorLine();
- }
- }
-
- /**
- * Set highlight positions. It is assumed that all positions
- * are up-to-date with respect to the text viewer document.
- *
- * @param positions a list of Positions
- */
- public void setHighlightPositions(List positions) {
- boolean isActive= fIsActive;
- deactivate(isActive);
- fPositions.clear();
- fPositions.add(fCursorLine);
- fPositions.addAll(positions);
- if (isActive) {
- activate(true);
- }
- }
-
- /**
- * Add highlight positions. It is assumed that all positions
- * are up-to-date with respect to the text viewer document.
- *
- * @param positions a list of Positions
- */
- public void addHighlightPositions(List positions) {
- boolean isActive= fIsActive;
- deactivate(isActive);
- fPositions.addAll(positions);
- if (isActive) {
- activate(true);
- }
- }
-
- /**
- * Remove highlight positions by identity.
- *
- * @param positions a list of Positions
- */
- public void removeHighlightPositions(List positions) {
- boolean isActive= fIsActive;
- deactivate(isActive);
- fPositions.removeAll(positions);
- if (isActive) {
- activate(true);
- }
- }
-
- /**
- * Replace given highlight positions in one step.
- *
- * @param removePositions a list of Positions to remove
- * @param addPositions a list of Positions to add
- */
- public void replaceHighlightPositions(List removePositions, List addPositions) {
- boolean isActive= fIsActive;
- deactivate(isActive);
- fPositions.removeAll(removePositions);
- fPositions.addAll(addPositions);
- if (isActive) {
- activate(true);
- }
- }
-
- /**
- * Trigger redraw of managed positions.
- */
- public void redraw() {
- if(fIsActive) {
- fTextWidget.redraw();
- }
- }
-
- /**
- * Manage all positions.
- * @param positions
- */
- private void managePositions(List positions) {
- if (fPositionManager == null) {
- return;
- }
- int sz= fPositions.size();
- for (int i= 0; i < sz; ++i) {
- Position position= positions.get(i);
- fPositionManager.managePosition(position);
- }
- }
-
- /**
- * Unmanage all positions.
- * @param positions
- */
- private void unmanagePositions(List positions) {
- if (fPositionManager == null) {
- return;
- }
- int sz= fPositions.size();
- for (int i= 0; i < sz; ++i) {
- Position position= positions.get(i);
- fPositionManager.unmanagePosition(position);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#dispose()
- */
- public void dispose() {
- // no deactivate!
- fIsActive= false;
- fTextViewer= null;
- fTextWidget= null;
- fCursorLine= null;
- fLastCursorLine= null;
- fPositions= null;
- fLastPositions= null;
- fChangedPositions= null;
- fColorMap= null;
- }
-
- /**
- * Query whether this painter is already disposed.
- * @return true if the painter is disposed
- */
- public boolean isDisposed() {
- return fTextViewer == null;
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#paint(int)
- */
- public void paint(int reason) {
- IDocument document= fTextViewer.getDocument();
- if (document == null) {
- deactivate(false);
- return;
- }
- activate(false);
-
- if (fCursorLineEnabled) {
- // check selection
- StyledText textWidget= fTextViewer.getTextWidget();
- Point selection= textWidget.getSelection();
- int startLine= textWidget.getLineAtOffset(selection.x);
- int endLine= textWidget.getLineAtOffset(selection.y);
- if (startLine != endLine) {
- redrawPositions(Collections.singletonList(fLastCursorLine));
- fCursorLineActive= false;
- } else {
- fCursorLineActive= true;
- }
- if (fCursorLineActive) {
- // redraw in case of text changes prior to update of current cursor line
- if (!fLastCursorLine.equals(fCursorLine)) {
- redrawPositions(Collections.singletonList(fLastCursorLine));
- fLastCursorLine.offset= fCursorLine.offset;
- fLastCursorLine.length= fCursorLine.length;
- }
- updateCursorLine();
- }
- }
- List changedPositions= getChangedPositions();
- if (changedPositions != null) {
- redrawPositions(changedPositions);
- updatePositions();
- redrawPositions(changedPositions);
- }
- }
-
- /**
- * Activate the painter.
- * @param redraw
- */
- private void activate(boolean redraw) {
- if (!fIsActive) {
- fIsActive= true;
- fTextWidget.addLineBackgroundListener(this);
- if (redraw) {
- if (fCursorLineActive) {
- updateCursorLine();
- }
- updatePositions();
- redrawPositions(fPositions);
- }
- managePositions(fPositions);
- }
- }
-
- /**
- * Copy positions from the current position list to the last position list.
- */
- private void updatePositions() {
- int sz= fPositions.size();
- for (int i= 0; i < sz; ++i) {
- Position position= fPositions.get(i);
- Position copy;
- if (i == fLastPositions.size()) {
- copy= new Position(position.offset, position.length);
- copy.isDeleted= position.isDeleted;
- fLastPositions.add(copy);
- } else {
- copy= fLastPositions.get(i);
- copy.offset= position.offset;
- copy.length= position.length;
- copy.isDeleted= position.isDeleted;
- }
- position.isDeleted= false;
- }
- int diff= fLastPositions.size() - sz;
- while (diff > 0) {
- --diff;
- fLastPositions.remove(sz + diff);
- }
- }
-
- /**
- * Check which positions have changed since last redraw.
- * @return a list of changed positions or null if none changed.
- */
- private List getChangedPositions() {
- if (fLastPositions.size() != fPositions.size()) {
- return fLastPositions;
- }
- List changedPositions= null;
- for (int i= 0, sz= fPositions.size(); i < sz; ++i) {
- Position previous= fLastPositions.get(i);
- Position current= fPositions.get(i);
- if (!previous.equals(current)) {
- if (changedPositions == null) {
- changedPositions= fChangedPositions;
- changedPositions.clear();
- }
- changedPositions.add(previous);
- }
- }
- return changedPositions;
- }
-
- /**
- * Trigger redraw of given text positions.
- *
- * @param positions
- */
- private void redrawPositions(List positions) {
- // TextViewer.getTopIndexStartOffset is buggy
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=174419
-// final int minOffset= fTextViewer.getTopIndexStartOffset();
- final int minOffset= getTopIndexStartOffset();
- final int maxOffset= fTextViewer.getBottomIndexEndOffset()+3;
- Rectangle clientArea= fTextWidget.getClientArea();
- int width= clientArea.width + fTextWidget.getHorizontalPixel();
- int lineHeight= fTextWidget.getLineHeight();
- for (int i= 0, sz= positions.size(); i < sz; ++i) {
- Position position= positions.get(i);
- // if the position that is about to be drawn was deleted then we can't
- if (position.isDeleted()) {
- continue;
- }
- // check if position overlaps with visible area
- if (!position.overlapsWith(minOffset, maxOffset - minOffset + 1)) {
- continue;
- }
- int widgetOffset= getWidgetOffset(position.offset);
- if (widgetOffset < 0 || widgetOffset > fTextWidget.getCharCount()) {
- continue;
- }
- // TLETODO [performance] SyledText.getLocationAtOffset() is very expensive
- Point upperLeft= fTextWidget.getLocationAtOffset(widgetOffset);
- int upperY= Math.max(Math.min(upperLeft.y, clientArea.height), 0);
- int height;
- if (position.length == 0) {
- height= lineHeight;
- } else {
- int widgetEndOffset= Math.min(widgetOffset + position.length, fTextWidget.getCharCount());
- Point lowerRight= fTextWidget.getLocationAtOffset(widgetEndOffset);
- int lowerY= Math.min(lowerRight.y + lineHeight, clientArea.height);
- height= lowerY - upperY;
- }
- if (height > 0) {
- fTextWidget.redraw(0, upperY, width, height, false);
- }
- }
- }
-
- /**
- * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=174419
- * @return the offset of the topmost visible line
- * @see ITextViewer#getTopIndexStartOffset()
- */
- private int getTopIndexStartOffset() {
- if (fTextWidget != null) {
- int top= fTextWidget.getTopIndex();
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=183653
- top= fTextWidget.getOffsetAtLine(Math.min(fTextWidget.getLineCount() - 1, top));
- if (top >= 0) {
- return getDocumentOffset(top);
- }
- }
- return -1;
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#deactivate(boolean)
- */
- public void deactivate(boolean redraw) {
- if (fIsActive) {
- fIsActive= false;
- fTextWidget.removeLineBackgroundListener(this);
- if (redraw) {
- redrawPositions(fLastPositions);
- }
- unmanagePositions(fPositions);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager)
- */
- public void setPositionManager(IPaintPositionManager manager) {
- fPositionManager= manager;
- }
-
- /**
- * Convert a document offset to the corresponding widget offset.
- * @param documentOffset
- * @return widget offset
- */
- private int getWidgetOffset(int documentOffset) {
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)fTextViewer;
- return extension.modelOffset2WidgetOffset(documentOffset);
- }
- IRegion visible= fTextViewer.getVisibleRegion();
- int widgetOffset= documentOffset - visible.getOffset();
- if (widgetOffset > visible.getLength()) {
- return -1;
- }
- return widgetOffset;
- }
-
- /**
- * Convert a widget offset to the corresponding document offset.
- * @param widgetOffset
- * @return document offset
- */
- private int getDocumentOffset(int widgetOffset) {
- if (fTextViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)fTextViewer;
- return extension.widgetOffset2ModelOffset(widgetOffset);
- }
- IRegion visible= fTextViewer.getVisibleRegion();
- if (widgetOffset > visible.getLength()) {
- return -1;
- }
- return widgetOffset + visible.getOffset();
- }
-
- /*
- * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent)
- */
- public void lineGetBackground(LineBackgroundEvent event) {
- if (fTextWidget != null) {
- Position match= findIncludingPosition(getDocumentOffset(event.lineOffset));
- if (match != null) {
- Color color= getColorForPosition(match);
- if (color != null) {
- event.lineBackground= color;
- }
- }
- }
- }
-
- /**
- * Get the color associated with given position.
- * @param position
- * @return the color associated with the position type
- */
- private Color getColorForPosition(Position position) {
- if (position == fCursorLine) {
- if (fCursorLine.length == 0) {
- return fColorMap.get(CURSOR_LINE_TYPE);
- }
- } else {
- if (position instanceof TypedPosition) {
- String type= ((TypedPosition)position).getType();
- return fColorMap.get(type);
- }
- return fColorMap.get(DEFAULT_TYPE);
- }
- return null;
- }
-
- /**
- * Find position which includes the (document-)offset.
- * @param offset
- * @return the first position including the offset or null.
- */
- private Position findIncludingPosition(int offset) {
- // TLETODO [performance] Use binary search?
- for (int i= fCursorLineActive ? 0 : 1, sz= fPositions.size(); i < sz; ++i) {
- Position position= fPositions.get(i);
- if (position.offset == offset || position.includes(offset)) {
- return position;
- }
- }
- return null;
- }
-
- /**
- * Updates the position of the cursor line.
- */
- private void updateCursorLine() {
- try {
- IDocument document= fTextViewer.getDocument();
- if (document != null) {
- int lineNumber= document.getLineOfOffset(getDocumentOffset(fTextWidget.getCaretOffset()));
-
- fCursorLine.isDeleted= false;
- fCursorLine.offset= document.getLineOffset(lineNumber);
- fCursorLine.length= 0;
- }
- } catch (BadLocationException e) {
- // gracefully ignored
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java
deleted file mode 100644
index 4d2952d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MacrosGrouping.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Marc-Andre Laperle - Bug 233390 (adapted from IncludesGrouping)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CElementGrouping;
-
-/**
- * Grouping for macro definitions.
- *
- * @since 5.2
- */
-public class MacrosGrouping extends CElementGrouping {
- ITranslationUnit tu;
-
- public MacrosGrouping(ITranslationUnit unit) {
- super(CElementGrouping.MACROS_GROUPING);
- tu = unit;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object object) {
- try {
- return tu.getChildrenOfType(ICElement.C_MACRO).toArray();
- } catch (CModelException e) {
- }
- return super.getChildren(object);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object object) {
- return tu;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof MacrosGrouping) {
- return tu.equals(((MacrosGrouping)obj).tu) ;
- }
- return false;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java
deleted file mode 100644
index 96f89d9..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/MembersGrouping.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.INamespace;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.ui.CElementGrouping;
-import org.eclipse.cdt.ui.NamespacesGrouping;
-
-/**
- * Grouping for members in the same namespace.
- */
-public class MembersGrouping extends CElementGrouping {
-
- private final Object fParent;
- private final String fNamespace;
-
- public MembersGrouping(Object parent, String namespace) {
- super(CElementGrouping.CLASS_GROUPING);
- assert parent instanceof ICElement || parent instanceof NamespacesGrouping;
- fParent= parent;
- fNamespace= namespace;
- }
-
- @Override
- public String getLabel(Object object) {
- return fNamespace;
- }
-
- @Override
- public Object[] getChildren(Object object) {
- List nsMembers = new ArrayList();
- if (fParent instanceof IParent) {
- try {
- nsMembers.addAll(getNamespaceChildren(((IParent)fParent).getChildren()));
- } catch (CModelException exc) {
- }
- } else if (fParent instanceof NamespacesGrouping) {
- NamespacesGrouping nsGrouping = (NamespacesGrouping) fParent;
- INamespace[] namespaces = nsGrouping.getNamespaces();
- for (INamespace iNamespace : namespaces) {
- try {
- nsMembers.addAll(getNamespaceChildren(iNamespace.getChildren()));
- } catch (CModelException exc) {
- }
- }
- }
- return nsMembers.toArray();
- }
-
- /**
- * @param iNamespace
- * @return
- */
- private Collection extends ICElement> getNamespaceChildren(ICElement[] icElements) {
- List members = new ArrayList(icElements.length);
- for (ICElement icElement : icElements) {
- if (icElement instanceof IMember) {
- String name = icElement.getElementName();
- int idx = name.lastIndexOf("::"); //$NON-NLS-1$
- if (idx < 0) {
- continue;
- }
- String namespace = name.substring(0, idx);
- if (fNamespace.equals(namespace)) {
- members.add(icElement);
- }
- }
- }
- return members;
- }
-
- @Override
- public Object getParent(Object object) {
- return fParent;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof MembersGrouping) {
- final MembersGrouping other= (MembersGrouping)obj;
- return fParent.equals(other.fParent) && fNamespace.equals(other.fNamespace);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return fParent.hashCode() * 17 + fNamespace.hashCode();
- }
-
- @Override
- public String toString() {
- return fNamespace;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
deleted file mode 100644
index 547ce71..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.ui.IElementFactory;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistableElement;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-
-/**
- * The PersistableCElementFactory is used to save and recreate an ICElement object.
- * As such, it implements the IPersistableElement interface for storage
- * and the IElementFactory interface for recreation.
- *
- * @see IMemento
- * @see IPersistableElement
- * @see IElementFactory
- */
-public class PersistableCElementFactory implements IElementFactory, IPersistableElement {
-
- // These persistence constants are stored in XML. Do not
- // change them.
- private static final String TAG_PATH = "path";//$NON-NLS-1$
- private static final String TAG_TYPE = "type";//$NON-NLS-1$
-
- private static final String FACTORY_ID = "org.eclipse.cdt.ui.PersistableCElementFactory";//$NON-NLS-1$
-
- // IPersistable data.
- private ICElement fCElement;
-
- /**
- * Create a PersistableCElementFactory. This constructor is typically used
- * for our IElementFactory side.
- */
- public PersistableCElementFactory() {
- }
-
- /**
- * Create a PersistableCElementFactory. This constructor is typically used
- * for our IPersistableElement side.
- */
- public PersistableCElementFactory(ICElement input) {
- fCElement = input;
- }
-
- /**
- * @see IElementFactory
- */
- public IAdaptable createElement(IMemento memento) {
- // Get the file name.
- String fileName = memento.getString(TAG_PATH);
- if (fileName == null) {
- return null;
- }
-
- IPath elementPath= new Path(fileName);
- fCElement = CoreModel.getDefault().create(elementPath);
- if (fCElement != null && fCElement.getResource() != null) {
- IResource resource= fCElement.getResource();
- if (!resource.isAccessible()) {
- return resource;
- }
- }
- if (fCElement != null) {
- return fCElement;
- }
-
- final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- Integer elementType= memento.getInteger(TAG_TYPE);
- if (elementType == null) {
- if (elementPath.segmentCount() == 1) {
- return root.getProject(fileName);
- }
- IFolder folder= root.getFolder(elementPath);
- File osFile= folder.getLocation().toFile();
- if (osFile.isDirectory()) {
- return folder;
- }
- return root.getFile(elementPath);
- }
- switch (elementType.intValue()) {
- case IResource.ROOT:
- return root;
- case IResource.PROJECT:
- return root.getProject(fileName);
- case IResource.FOLDER:
- return root.getFolder(elementPath);
- case IResource.FILE:
- return root.getFile(elementPath);
- }
- return null;
- }
-
- /**
- * @see IPersistableElement
- */
- public String getFactoryId() {
- return FACTORY_ID;
- }
-
- /**
- * @see IPersistableElement
- */
- public void saveState(IMemento memento) {
- if (fCElement.getResource() != null) {
- memento.putString(TAG_PATH, fCElement.getResource().getFullPath().toString());
- memento.putInteger(TAG_TYPE, fCElement.getResource().getType());
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
deleted file mode 100644
index 3904942..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IAdapterFactory;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-
-public class ResourceAdapterFactory implements IAdapterFactory {
-
- private static Class>[] PROPERTIES= new Class[] {
- ICElement.class
- };
-
- //private static CElementFactory celementFactory= new CElementFactory();
- private static CoreModel celementFactory= CoreModel.getDefault();
-
- /**
- * @see IAdapterFactory#getAdapterList
- */
- public Class>[] getAdapterList() {
- return PROPERTIES;
- }
-
- /**
- * @see IAdapterFactory#getAdapter
- */
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Object element, Class key) {
- if (ICElement.class.equals(key)) {
- //try {
- if (element instanceof IFile) {
- return celementFactory.create((IFile)element);
- } else if (element instanceof IFolder) {
- return celementFactory.create((IFolder)element);
- } else if (element instanceof IProject) {
- return celementFactory.create((IProject)element);
- } else if (element instanceof IWorkspaceRoot) {
- return CoreModel.create((IWorkspaceRoot)element);
- } else if (element instanceof IResource) {
- return celementFactory.create((IResource)element);
- }
- //} catch (CoreException e) {
- // CUIPlugin.getDefault().getLog().log(e.getStatus());
- //}
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java
deleted file mode 100644
index 901dd83..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractToggleLinkingAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This is an action template for actions that toggle whether
- * it links its selection to the active editor.
- *
- * @since 3.0
- */
-public abstract class AbstractToggleLinkingAction extends Action {
-
- /**
- * Constructs a new action.
- */
- public AbstractToggleLinkingAction() {
- super(ActionMessages.ToggleLinkingAction_label);
- setDescription(ActionMessages.ToggleLinkingAction_description);
- setToolTipText(ActionMessages.ToggleLinkingAction_tooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "synced.gif"); //$NON-NLS-1$
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.LINK_EDITOR_ACTION);
- }
-
- /**
- * Runs the action.
- */
- @Override
- public abstract void run();
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java
deleted file mode 100644
index bf4d34d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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:
- * Markus Schorn - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.index.IIndexManager;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate {
-
- private ISelection fSelection;
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- public void run(IAction action) {
- if (!(fSelection instanceof IStructuredSelection))
- return;
-
- IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
- Iterator> i= cElements.iterator();
- ArrayList tuSelection= new ArrayList();
- while (i.hasNext()) {
- Object o= i.next();
- if (o instanceof ICProject || o instanceof ICContainer || o instanceof ITranslationUnit) {
- tuSelection.add((ICElement) o);
- }
- }
- ICElement[] tuArray= tuSelection.toArray(new ICElement[tuSelection.size()]);
-
- try {
- CCorePlugin.getIndexManager().update(tuArray, getUpdateOptions());
- }
- catch (CoreException e) {
- CUIPlugin.log(e);
- }
- }
-
- /**
- * Return the options to update the translation.
- * @see IIndexManager#update(ICElement[], int)
- * @since 4.0
- */
- abstract protected int getUpdateOptions();
-
- /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- fSelection = selection;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
deleted file mode 100644
index bb59cbe..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Rational Software - initial implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Class that gives access to the action messages resource bundle.
- */
-public class ActionMessages extends NLS {
- public static String SourceMenu_label;
- public static String SelectionConverter_codeResolve_failed;
- public static String OpenAction_label;
- public static String OpenAction_tooltip;
- public static String OpenAction_description;
- public static String OpenAction_declaration_label;
- public static String OpenAction_select_element;
- public static String OpenAction_error_title;
- public static String OpenAction_error_message;
- public static String OpenAction_error_messageArgs;
- public static String OpenAction_error_messageProblems;
- public static String OpenAction_error_messageBadSelection;
- public static String MemberFilterActionGroup_hide_fields_label;
- public static String MemberFilterActionGroup_hide_fields_tooltip;
- public static String MemberFilterActionGroup_hide_fields_description;
- public static String MemberFilterActionGroup_hide_static_label;
- public static String MemberFilterActionGroup_hide_static_tooltip;
- public static String MemberFilterActionGroup_hide_static_description;
- public static String MemberFilterActionGroup_hide_nonpublic_label;
- public static String MemberFilterActionGroup_hide_nonpublic_tooltip;
- public static String MemberFilterActionGroup_hide_nonpublic_description;
- public static String MemberFilterActionGroup_hide_inactive_label;
- public static String MemberFilterActionGroup_hide_inactive_tooltip;
- public static String MemberFilterActionGroup_hide_inactive_description;
- public static String ActionUtil_notOnBuildPath_title;
- public static String ActionUtil_notOnBuildPath_message;
- public static String ActionUtil_warning_derived_dontShowAgain;
- public static String ActionUtil_warning_derived_message;
- public static String ActionUtil_warning_derived_title;
- public static String SelectAllAction_label;
- public static String SelectAllAction_tooltip;
- public static String ToggleLinkingAction_label;
- public static String ToggleLinkingAction_tooltip;
- public static String ToggleLinkingAction_description;
- public static String IncludesGroupingAction_label;
- public static String IncludesGroupingAction_tooltip;
- public static String IncludesGroupingAction_description;
- public static String NamespacesGroupingAction_label;
- public static String NamespacesGroupingAction_tooltip;
- public static String NamespacesGroupingAction_description;
- public static String MemberGroupingAction_label;
- public static String MemberGroupingAction_tooltip;
- public static String MemberGroupingAction_description;
- public static String MacroGroupingAction_label;
- public static String MacroGroupingAction_tooltip;
- public static String MacroGroupingAction_description;
- public static String COutlineInformationControl_viewMenu_sort_label;
- public static String ChangeBuildConfigMenuAction_title;
- public static String ChangeBuildConfigMenuAction_text;
- public static String CreateParserLogAction_existingFile;
- public static String CreateParserLogAction_readOnlyFile;
- public static String DeleteResConfigsAction_0;
- public static String DeleteResConfigsAction_1;
- public static String ExcludeFromBuildAction_0;
- public static String ExcludeFromBuildAction_1;
- public static String BuildActiveConfigMenuAction_defaultTooltip;
- public static String BuildActiveConfigMenuAction_buildConfigTooltip;
- public static String SurroundWithTemplateMenuAction_SubMenuName;
- public static String SurroundWithTemplateMenuAction_ConfigureTemplatesActionName;
- public static String SurroundWithTemplateMenuAction_NoneApplicable;
- public static String CopyTreeAction_problem;
- public static String CopyTreeAction_clipboard_busy;
- public static String FormatAllAction_label;
- public static String FormatAllAction_tooltip;
- public static String FormatAllAction_description;
- public static String FormatAllAction_status_description;
- public static String FormatAllAction_multi_status_title;
- public static String FormatAllAction_error_title;
- public static String FormatAllAction_error_message;
- public static String FormatAllAction_operation_description;
- public static String FormatAllAction_failedvalidateedit_title;
- public static String FormatAllAction_failedvalidateedit_message;
- public static String FormatAllAction_noundo_title;
- public static String FormatAllAction_noundo_message;
-
- static {
- // Initialize resource bundle.
- NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class);
- }
-
- private ActionMessages() {
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
deleted file mode 100644
index c27f42b..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties
+++ /dev/null
@@ -1,111 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2010 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
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# Anton Leherbauer (Wind River Systems)
-# Axel Mueller - [289339] Surround with
-# Sergey Prigogin (Google)
-###############################################################################
-
-SourceMenu_label=Source
-
-SelectionConverter_codeResolve_failed=Couldn't convert text selection into a C element
-
-OpenAction_label=&Open
-OpenAction_tooltip=Open an editor on the selected element
-OpenAction_description=Open an editor on the selected element
-OpenAction_declaration_label=&Open Declaration
-OpenAction_select_element=&Select or enter the element to open:
-
-OpenAction_error_title=Open
-OpenAction_error_message=Cannot open default editor.
-OpenAction_error_messageArgs=Cannot open default editor on {0}. {1}
-OpenAction_error_messageProblems=Problems Opening Editor
-OpenAction_error_messageBadSelection=Current text selection doesn't resolve to a C element
-
-MemberFilterActionGroup_hide_fields_label=Hide Fiel&ds
-MemberFilterActionGroup_hide_fields_tooltip=Hide Fields
-MemberFilterActionGroup_hide_fields_description=Toggles the visibility of fields
-
-MemberFilterActionGroup_hide_static_label=Hide &Static Members
-MemberFilterActionGroup_hide_static_tooltip=Hide Static Members
-MemberFilterActionGroup_hide_static_description=Toggles the visibility of static members
-
-MemberFilterActionGroup_hide_nonpublic_label=Hide Non-&Public Members
-MemberFilterActionGroup_hide_nonpublic_tooltip=Hide Non-Public Members
-MemberFilterActionGroup_hide_nonpublic_description=Toggles the visibility of non-public members
-
-MemberFilterActionGroup_hide_inactive_label=Hide &Inactive Elements
-MemberFilterActionGroup_hide_inactive_tooltip=Hide Inactive Elements
-MemberFilterActionGroup_hide_inactive_description=Toggles the visibility of inactive elements
-
-ActionUtil_notOnBuildPath_title=Operation Cannot be Performed
-ActionUtil_notOnBuildPath_message=The resource is not on the build path of a Java project.
-ActionUtil_warning_derived_title=Derived File Encountered
-ActionUtil_warning_derived_message=The file ''{0}'' is derived. Do you really want to edit it?
-ActionUtil_warning_derived_dontShowAgain=In the future, never warn if editing a derived file.
-
-SelectAllAction_label= Select A&ll
-SelectAllAction_tooltip= Select All
-
-ToggleLinkingAction_label=Lin&k With Editor
-ToggleLinkingAction_tooltip=Link with Editor
-ToggleLinkingAction_description=Link with active editor
-
-IncludesGroupingAction_label=Group Includes
-IncludesGroupingAction_tooltip=Group includes statements
-IncludesGroupingAction_description=Group includes statements
-
-NamespacesGroupingAction_label=Group Namespaces
-NamespacesGroupingAction_tooltip=Group namespaces
-NamespacesGroupingAction_description=Group namespaces
-
-MemberGroupingAction_label=Group Methods
-MemberGroupingAction_tooltip=Group method definitions
-MemberGroupingAction_description=Group method definitions
-
-MacroGroupingAction_label= Group Macros
-MacroGroupingAction_tooltip= Group macro definitions
-MacroGroupingAction_description= Group macro definitions
-
-COutlineInformationControl_viewMenu_sort_label=Sort
-
-ChangeBuildConfigMenuAction_title=Sorry
-ChangeBuildConfigMenuAction_text=No way to manage configurations for selected objects.
-CreateParserLogAction_existingFile=''{0}'' already exists.\nDo you want to replace it?
-CreateParserLogAction_readOnlyFile=''{0}'' cannot be modified\!
-
-DeleteResConfigsAction_0=Select resource configurations to restore default settings
-DeleteResConfigsAction_1=Reset Resource Configurations
-
-ExcludeFromBuildAction_0=Exclude object(s) from build in the following configurations
-ExcludeFromBuildAction_1=Exclude from build
-
-BuildActiveConfigMenuAction_defaultTooltip=Build the active configurations of selected projects
-BuildActiveConfigMenuAction_buildConfigTooltip=Build ''{0}'' for project ''{1}''
-
-SurroundWithTemplateMenuAction_SubMenuName=Surround &With
-SurroundWithTemplateMenuAction_ConfigureTemplatesActionName=&Configure Templates...
-SurroundWithTemplateMenuAction_NoneApplicable=(no template applicable)
-
-CopyTreeAction_problem=Problem Copying to Clipboard
-CopyTreeAction_clipboard_busy=There was a problem when accessing the system clipboard. Retry?
-
-FormatAllAction_label=&Format
-FormatAllAction_tooltip=Format all selected C/C++ files
-FormatAllAction_description=Format all selected C/C++ files
-FormatAllAction_status_description=Problems while formatting some files. See 'Details' for more information.
-FormatAllAction_multi_status_title=Format
-FormatAllAction_error_title=Format
-FormatAllAction_error_message=Unexpected error while formatting. See log for details.
-
-FormatAllAction_operation_description=Formatting...
-FormatAllAction_failedvalidateedit_title=Format
-FormatAllAction_failedvalidateedit_message=Problems while accessing selected files.
-FormatAllAction_noundo_title=Format
-FormatAllAction_noundo_message='Undo' is not supported by this operation. Do you want to continue?
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java
deleted file mode 100644
index 258e18b..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionUtil.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.internal.corext.util.Messages;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.viewsupport.BasicElementLabels;
-
-/*
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=19104
- */
-public class ActionUtil {
-
- private ActionUtil(){
- }
-
- //bug 31998 we will have to disable renaming of linked packages (and cus)
- public static boolean mustDisableCModelAction(Shell shell, Object element) {
- return false;
-// if (!(element instanceof IPackageFragment) && !(element instanceof IPackageFragmentRoot))
-// return false;
-//
-// IResource resource= ResourceUtil.getResource(element);
-// if ((resource == null) || (! (resource instanceof IFolder)) || (! resource.isLinked()))
-// return false;
-//
-// MessageDialog.openInformation(shell, ActionMessages.ActionUtil.not_possible"), ActionMessages.ActionUtil.no_linked")); //$NON-NLS-1$ //$NON-NLS-2$
-// return true;
- }
-
- public static boolean isProcessable(CEditor editor) {
- if (editor == null)
- return true;
- Shell shell = editor.getSite().getShell();
- ICElement input= SelectionConverter.getInput(editor);
- // if a C/C++ editor doesn't have an input of type C element
- // then it is for sure not on the build path
- if (input == null) {
- MessageDialog.openInformation(shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
- ActionMessages.ActionUtil_notOnBuildPath_message);
- return false;
- }
- return isProcessable(shell, input);
- }
-
- public static boolean isProcessable(Shell shell, Object element) {
- if (!(element instanceof ICElement))
- return true;
-
- if (isOnBuildPath((ICElement) element))
- return true;
- MessageDialog.openInformation(shell,
- ActionMessages.ActionUtil_notOnBuildPath_title,
- ActionMessages.ActionUtil_notOnBuildPath_message);
- return false;
- }
-
- public static boolean isOnBuildPath(ICElement element) {
- //fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051
- if (element.getElementType() == ICElement.C_PROJECT)
- return true;
-// ICProject project= element.getCProject();
-// if (!project.isOnSourceRoot(element.getResource()))
-// return false;
- return true;
- }
-
- /**
- * Check whether editor and element are
- * processable and editable. If the editor edits the element, the validation
- * is only performed once. If necessary, ask the user whether the file(s)
- * should be edited.
- *
- * @param editor an editor, or null iff the action was not
- * executed from an editor
- * @param shell a shell to serve as parent for a dialog
- * @param element the element to check, cannot be null
- * @return true if the element can be edited,
- * false otherwise
- */
- public static boolean isEditable(CEditor editor, Shell shell, ICElement element) {
- if (editor != null) {
- ICElement input= SelectionConverter.getInput(editor);
- if (input != null && input.equals(element.getAncestor(ICElement.C_UNIT)))
- return isEditable(editor);
- else
- return isEditable(editor) && isEditable(shell, element);
- }
- return isEditable(shell, element);
- }
-
- public static boolean isEditable(CEditor editor) {
- if (!isProcessable(editor))
- return false;
-
- return editor.validateEditorInputState();
- }
-
- public static boolean isEditable(Shell shell, ICElement element) {
- if (!isProcessable(shell, element))
- return false;
-
- ICElement cu= element.getAncestor(ICElement.C_UNIT);
- if (cu != null) {
- IResource resource= cu.getResource();
- if (resource != null && resource.isDerived()) {
- // see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState()
- final String warnKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
- IPreferenceStore store= EditorsUI.getPreferenceStore();
- if (!store.getBoolean(warnKey))
- return true;
-
- MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
- shell,
- ActionMessages.ActionUtil_warning_derived_title,
- Messages.format(ActionMessages.ActionUtil_warning_derived_message, BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
- ActionMessages.ActionUtil_warning_derived_dontShowAgain,
- false,
- null,
- null);
-
- EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState());
- return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
- }
- }
- return true;
- }
-}
-
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
deleted file mode 100644
index 6b0046a..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AddBlockCommentAction.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- * Andrew Gvozdev - http://bugs.eclipse.org/236160
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.ui.text.ICPartitions;
-
-/**
- * Action that encloses the editor's current selection with C block comment terminators
- * (/* and */).
- *
- * @since 3.0
- */
-public class AddBlockCommentAction extends BlockCommentAction {
- /**
- * Creates a new instance.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in ResourceAction constructor), or
- * null if none
- * @param editor the text editor
- */
- public AddBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- @Override
- protected void runInternal(ITextSelection selection,
- IDocumentExtension3 docExtension, Edit.EditFactory factory)
- throws BadLocationException, BadPartitioningException {
-
- if ( !(docExtension instanceof IDocument) ) return;
-
- List edits= new LinkedList();
-
- ITypedRegion firstPartition = docExtension.getPartition(ICPartitions.C_PARTITIONING,
- selection.getOffset(), false);
- ITypedRegion lastPartition = docExtension.getPartition(ICPartitions.C_PARTITIONING,
- selection.getOffset() + selection.getLength() - 1, false);
-
- int commentAreaStart = selection.getOffset();
- int commentAreaEnd = selection.getOffset()+selection.getLength();
- // Include special partitions fully in the comment area
- if (isSpecialPartition(firstPartition.getType())) {
- commentAreaStart = firstPartition.getOffset();
- }
- if (isSpecialPartition(lastPartition.getType())) {
- commentAreaEnd = lastPartition.getOffset() + lastPartition.getLength();
- }
- Region estimatedCommentArea = new Region(commentAreaStart,commentAreaEnd-commentAreaStart);
-
-
- Region commentArea = handleEnclosingPartitions(estimatedCommentArea, lastPartition,
- (IDocument)docExtension, factory, edits);
-
- handleInteriorPartition(commentArea, firstPartition, docExtension, factory, edits);
-
- executeEdits(edits);
- }
-
- /**
- * Add enclosing comment tags for the whole area to be commented
- *
- * @param commentArea initial comment area which can be adjusted
- * @param lastPartition last partition
- * @param doc document
- * @param factory Edit factory
- * @param edits List of edits to update the document
- * @return new possibly adjusted comment area
- * @throws BadLocationException
- */
- private Region handleEnclosingPartitions(Region commentArea,
- ITypedRegion lastPartition, IDocument doc, Edit.EditFactory factory,
- List edits) throws BadLocationException {
-
- int commentAreaStart = commentArea.getOffset();
- int commentAreaEnd = commentArea.getOffset() + commentArea.getLength();
-
- String commentStartTag = getCommentStart(); // "/*"
- String commentEndTag = getCommentEnd(); // "*/"
-
- String startLineEOL = doc.getLineDelimiter(doc.getLineOfOffset(commentAreaStart));
- if (startLineEOL==null) startLineEOL=""; //$NON-NLS-1$
- String endLineEOL = doc.getLineDelimiter(doc.getLineOfOffset(commentAreaEnd-1));
- if (endLineEOL==null) endLineEOL=""; //$NON-NLS-1$
-
- boolean isLeftEol = commentAreaStart edits)
- throws BadLocationException, BadPartitioningException {
-
- int commentAreaEnd = commentArea.getOffset() + commentArea.getLength();
- int prevPartitionEnd = -1;
- int partitionEnd = partition.getOffset()+partition.getLength();
-
- final int startCommentTokenLength = getCommentStart().length();
- final int endCommentTokenLength = getCommentEnd().length();
-
- while (partitionEnd<=commentAreaEnd) {
- if (partition.getType() == ICPartitions.C_MULTI_LINE_COMMENT
- || partition.getType() == ICPartitions.C_MULTI_LINE_DOC_COMMENT) {
- // already in a comment - remove start/end tokens
- edits.add(factory.createEdit(partition.getOffset(), startCommentTokenLength, "")); //$NON-NLS-1$
- edits.add(factory.createEdit(partitionEnd - endCommentTokenLength, endCommentTokenLength, "")); //$NON-NLS-1$
- }
- // advance to next partition
- prevPartitionEnd = partitionEnd;
- partition= docExtension.getPartition(ICPartitions.C_PARTITIONING, partitionEnd, false);
- partitionEnd = partition.getOffset() + partition.getLength();
-
- // break the loop if we get stuck and no advance was made
- if (partitionEnd<=prevPartitionEnd) break;
- }
- }
-
- /**
- * Returns whether partType is special, i.e. a String,
- * Character, or Comment partition.
- *
- * @param partType the partition type to check
- * @return true if partType is special, false otherwise
- */
- private boolean isSpecialPartition(String partType) {
- return partType != IDocument.DEFAULT_CONTENT_TYPE;
- }
-
- @Override
- protected boolean isValidSelection(ITextSelection selection) {
- return selection != null && !selection.isEmpty() && selection.getLength() > 0;
- }
-
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java
deleted file mode 100644
index 726b84d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/BlockCommentAction.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension2;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-/**
- * Common block comment code.
- *
- * @since 3.0
- */
-public abstract class BlockCommentAction extends TextEditorAction {
- /**
- * Creates a new instance.
- * @param bundle
- * @param prefix
- * @param editor
- */
- public BlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /**
- * An edit is a kind of DocumentEvent, in this case an edit instruction, that is
- * affiliated with a Position on a document. The offset of the document event is
- * not stored statically, but taken from the affiliated Position, which gets
- * updated when other edits occur.
- */
- static class Edit extends DocumentEvent {
-
- /**
- * Factory for edits which manages the creation, installation and destruction of
- * position categories, position updaters etc. on a certain document. Once a factory has
- * been obtained, Edit objects can be obtained from it which will be linked to
- * the document by positions of one position category.
- *
Clients are required to call release once the Edits are not
- * used any more, so the positions can be discarded.
- */
- public static class EditFactory {
-
- /** The position category basename for this edits. */
- private static final String CATEGORY= "__positionalEditPositionCategory"; //$NON-NLS-1$
-
- /** The count of factories. */
- private static int fgCount= 0;
-
- /** This factory's category. */
- private final String fCategory;
- private IDocument fDocument;
- private IPositionUpdater fUpdater;
-
- /**
- * Creates a new EditFactory with an unambiguous position category name.
- * @param document the document that is being edited.
- */
- public EditFactory(IDocument document) {
- fCategory= CATEGORY + fgCount++;
- fDocument= document;
- }
-
- /**
- * Creates a new edition on the document of this factory.
- *
- * @param offset the offset of the edition at the point when is created.
- * @param length the length of the edition (not updated via the position update mechanism)
- * @param text the text to be replaced on the document
- * @return an Edit reflecting the edition on the document
- */
- public Edit createEdit(int offset, int length, String text) throws BadLocationException {
-
- if (!fDocument.containsPositionCategory(fCategory)) {
- fDocument.addPositionCategory(fCategory);
- fUpdater= new DefaultPositionUpdater(fCategory);
- fDocument.addPositionUpdater(fUpdater);
- }
-
- Position position= new Position(offset);
- try {
- fDocument.addPosition(fCategory, position);
- } catch (BadPositionCategoryException e) {
- Assert.isTrue(false);
- }
- return new Edit(fDocument, length, text, position);
- }
-
- /**
- * Releases the position category on the document and uninstalls the position updater.
- * Edits managed by this factory are not updated after this call.
- */
- public void release() {
- if (fDocument != null && fDocument.containsPositionCategory(fCategory)) {
- fDocument.removePositionUpdater(fUpdater);
- try {
- fDocument.removePositionCategory(fCategory);
- } catch (BadPositionCategoryException e) {
- Assert.isTrue(false);
- }
- fDocument= null;
- fUpdater= null;
- }
- }
- }
-
- /** The position in the document where this edit be executed. */
- private Position fPosition;
-
- /**
- * Creates a new edition on document, taking its offset from position.
- *
- * @param document the document being edited
- * @param length the length of the edition
- * @param text the replacement text of the edition
- * @param position the position keeping the edition's offset
- */
- protected Edit(IDocument document, int length, String text, Position position) {
- super(document, 0, length, text);
- fPosition= position;
- }
-
- /*
- * @see org.eclipse.jface.text.DocumentEvent#getOffset()
- */
- @Override
- public int getOffset() {
- return fPosition.getOffset();
- }
-
- /**
- * Executes the edition on document. The offset is taken from the position.
- *
- * @throws BadLocationException if the execution of the document fails.
- */
- public void perform() throws BadLocationException {
- getDocument().replace(getOffset(), getLength(), getText());
- }
-
- }
-
- @Override
- public void run() {
- if (!isEnabled())
- return;
-
- ITextEditor editor= getTextEditor();
- if (editor == null || !ensureEditable(editor))
- return;
-
- ITextSelection selection= getCurrentSelection();
- if (!isValidSelection(selection))
- return;
-
- if (!validateEditorInputState())
- return;
-
- IDocumentProvider docProvider= editor.getDocumentProvider();
- IEditorInput input= editor.getEditorInput();
- if (docProvider == null || input == null)
- return;
-
- IDocument document= docProvider.getDocument(input);
- if (document == null)
- return;
-
- IDocumentExtension3 docExtension;
- if (document instanceof IDocumentExtension3)
- docExtension= (IDocumentExtension3) document;
- else
- return;
-
- IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
- if (target != null) {
- target.beginCompoundChange();
- }
-
- Edit.EditFactory factory= new Edit.EditFactory(document);
-
- try {
- runInternal(selection, docExtension, factory);
-
- } catch (BadLocationException e) {
- // can happen on concurrent modification, deletion etc. of the document
- // -> don't complain, just bail out
- } catch (BadPartitioningException e) {
- // should not happen
- Assert.isTrue(false, "bad partitioning"); //$NON-NLS-1$
- } finally {
- factory.release();
-
- if (target != null) {
- target.endCompoundChange();
- }
- }
- }
-
- /**
- * Calls perform on all Edits in edits.
- *
- * @param edits a list of Edits
- * @throws BadLocationException if an Edit threw such an exception.
- */
- protected void executeEdits(List edits) throws BadLocationException {
- for (Iterator it= edits.iterator(); it.hasNext();) {
- Edit edit= it.next();
- edit.perform();
- }
- }
-
- /**
- * Ensures that the editor is modifyable. If the editor is an instance of
- * ITextEditorExtension2, its validateEditorInputState method
- * is called, otherwise, the result of isEditable is returned.
- *
- * @param editor the editor to be checked
- * @return true if the editor is editable, false otherwise
- */
- protected boolean ensureEditable(ITextEditor editor) {
- Assert.isNotNull(editor);
-
- if (editor instanceof ITextEditorExtension2) {
- ITextEditorExtension2 ext= (ITextEditorExtension2) editor;
- return ext.validateEditorInputState();
- }
-
- return editor.isEditable();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- @Override
- public void update() {
- super.update();
-
- if (isEnabled()) {
- if (!canModifyEditor() || !isValidSelection(getCurrentSelection()))
- setEnabled(false);
- }
- }
-
- /**
- * Returns the editor's selection, or null if no selection can be obtained or the
- * editor is null.
- *
- * @return the selection of the action's editor, or null
- */
- protected ITextSelection getCurrentSelection() {
- ITextEditor editor= getTextEditor();
- if (editor != null) {
- ISelectionProvider provider= editor.getSelectionProvider();
- if (provider != null) {
- ISelection selection= provider.getSelection();
- if (selection instanceof ITextSelection)
- return (ITextSelection) selection;
- }
- }
- return null;
- }
-
- /**
- * Runs the real command once all the editor, document, and selection checks have succeeded.
- *
- * @param selection the current selection we are being called for
- * @param docExtension the document extension where we get the partitioning from
- * @param factory the edit factory we can use to create Edits
- * @throws BadLocationException if an edition fails
- * @throws BadPartitioningException if a partitioning call fails
- */
- protected abstract void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException;
-
- /**
- * Checks whether selection is valid.
- *
- * @param selection the selection to check
- * @return true if the selection is valid, false otherwise
- */
- protected abstract boolean isValidSelection(ITextSelection selection);
-
- /**
- * Returns the text to be inserted at the selection start.
- *
- * @return the text to be inserted at the selection start
- */
- protected String getCommentStart() {
- // for now: no space story
- return "/*"; //$NON-NLS-1$
- }
-
- /**
- * Returns the text to be inserted at the selection end.
- *
- * @return the text to be inserted at the selection end
- */
- protected String getCommentEnd() {
- // for now: no space story
- return "*/"; //$NON-NLS-1$
- }
-
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java
deleted file mode 100644
index 1b33aa4..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Anton Leherbauer (Wind River Systems) - Ported to CDT
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-import org.eclipse.ui.actions.QuickMenuCreator;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.text.CWordFinder;
-
-/**
- * C/C++ editor aware quick menu creator. In the given editor, the menu will be aligned with the word
- * at the current offset.
- *
- * @since 5.2
- */
-public abstract class CDTQuickMenuCreator extends QuickMenuCreator {
-
- private final CEditor fEditor;
-
- /**
- * Create a CDT quick menu creator
- * @param editor a Java editor, or null if none
- */
- public CDTQuickMenuCreator(CEditor editor) {
- fEditor= editor;
- }
-
- @Override
- protected Point computeMenuLocation(StyledText text) {
- if (fEditor == null || text != fEditor.getViewer().getTextWidget())
- return super.computeMenuLocation(text);
- return computeWordStart();
- }
-
- private Point computeWordStart() {
- ITextSelection selection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
- IRegion textRegion= CWordFinder.findWord(fEditor.getViewer().getDocument(), selection.getOffset());
- if (textRegion == null)
- return null;
-
- IRegion widgetRegion= modelRange2WidgetRange(textRegion);
- if (widgetRegion == null)
- return null;
-
- int start= widgetRegion.getOffset();
-
- StyledText styledText= fEditor.getViewer().getTextWidget();
- Point result= styledText.getLocationAtOffset(start);
- result.y+= styledText.getLineHeight(start);
-
- if (!styledText.getClientArea().contains(result))
- return null;
- return result;
- }
-
- private IRegion modelRange2WidgetRange(IRegion region) {
- ISourceViewer viewer= fEditor.getViewer();
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5)viewer;
- return extension.modelRange2WidgetRange(region);
- }
-
- IRegion visibleRegion= viewer.getVisibleRegion();
- int start= region.getOffset() - visibleRegion.getOffset();
- int end= start + region.getLength();
- if (end > visibleRegion.getLength())
- end= visibleRegion.getLength();
-
- return new Region(start, end - start);
- }
-
- /**
- * Returns a handler that can create and open the quick menu.
- *
- * @return a handler that can create and open the quick menu
- */
- public IHandler createHandler() {
- return new AbstractHandler() {
- public Object execute(ExecutionEvent event) throws ExecutionException {
- createMenu();
- return null;
- }
- };
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java
deleted file mode 100644
index 916a0b9..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CompositeActionGroup.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionGroup;
-
-public class CompositeActionGroup extends ActionGroup {
-
- private ActionGroup[] fGroups;
-
- public CompositeActionGroup() {
- }
-
- public CompositeActionGroup(ActionGroup[] groups) {
- setGroups(groups);
- }
-
- protected void setGroups(ActionGroup[] groups) {
- Assert.isTrue(fGroups == null);
- Assert.isNotNull(groups);
- fGroups= groups;
- }
-
- public ActionGroup get(int index) {
- if (fGroups == null)
- return null;
- return fGroups[index];
- }
-
- public void addGroup(ActionGroup group) {
- if (fGroups == null) {
- fGroups= new ActionGroup[] { group };
- } else {
- ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
- System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
- newGroups[fGroups.length]= group;
- fGroups= newGroups;
- }
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].dispose();
- }
- }
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].fillActionBars(actionBars);
- }
- }
-
- @Override
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].fillContextMenu(menu);
- }
- }
-
- @Override
- public void setContext(ActionContext context) {
- super.setContext(context);
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].setContext(context);
- }
- }
-
- @Override
- public void updateActionBars() {
- super.updateActionBars();
- if (fGroups == null)
- return;
- for (int i= 0; i < fGroups.length; i++) {
- fGroups[i].updateActionBars();
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java
deleted file mode 100644
index 6410045..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CopyTreeAction.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Jesper Kamstrup Linnet (eclipse@kamstrup-linnet.dk) - initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.osgi.util.TextProcessor;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.part.ViewPart;
-
-import org.eclipse.cdt.internal.ui.util.SelectionUtil;
-
-/**
- * Copies contents of a TreeViewer to the clipboard.
- */
-public class CopyTreeAction extends Action {
- private static final char INDENTATION= '\t';
-
- private ViewPart fView;
- private TreeViewer fViewer;
-
- public CopyTreeAction(String label, ViewPart view, TreeViewer viewer) {
- super(label);
- fView= view;
- fViewer= viewer;
- }
-
- public boolean canActionBeAdded() {
- Object element= SelectionUtil.getSingleElement(getSelection());
- return element != null;
- }
-
- private ISelection getSelection() {
- ISelectionProvider provider= fView.getSite().getSelectionProvider();
-
- if (provider != null) {
- return provider.getSelection();
- }
-
- return null;
- }
-
- /*
- * @see IAction#run()
- */
- @Override
- public void run() {
- StringBuilder buf= new StringBuilder();
- addChildren(fViewer.getTree().getSelection()[0], 0, buf);
-
- TextTransfer plainTextTransfer= TextTransfer.getInstance();
- Clipboard clipboard= new Clipboard(fView.getSite().getShell().getDisplay());
- try {
- clipboard.setContents(
- new String[] { convertLineTerminators(buf.toString()) },
- new Transfer[] { plainTextTransfer });
- } catch (SWTError e) {
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
- throw e;
- if (MessageDialog.openQuestion(fView.getViewSite().getShell(),
- ActionMessages.CopyTreeAction_problem, ActionMessages.CopyTreeAction_clipboard_busy)) {
- run();
- }
- } finally {
- clipboard.dispose();
- }
- }
-
- /**
- * Adds the specified {@link TreeItem}'s text to the StringBuilder.
- *
- * @param item the tree item
- * @param indent the indent size
- * @param buf the string buffer
- */
- private void addChildren(TreeItem item, int indent, StringBuilder buf) {
- for (int i= 0; i < indent; i++) {
- buf.append(INDENTATION);
- }
-
- buf.append(TextProcessor.deprocess(item.getText()));
- buf.append('\n');
-
- if (item.getExpanded()) {
- TreeItem[] items= item.getItems();
- for (TreeItem item2 : items) {
- addChildren(item2, indent + 1, buf);
- }
- }
- }
-
- static String convertLineTerminators(String in) {
- StringWriter stringWriter= new StringWriter();
- PrintWriter printWriter= new PrintWriter(stringWriter);
- StringReader stringReader= new StringReader(in);
- BufferedReader bufferedReader= new BufferedReader(stringReader);
- try {
- String line= bufferedReader.readLine();
- while (line != null) {
- printWriter.print(line);
- line= bufferedReader.readLine();
- if (line != null && line.length() != 0)
- printWriter.println();
-
- }
- } catch (IOException e) {
- return in; // return the call hierarchy unfiltered
- }
- return stringWriter.toString();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
deleted file mode 100644
index bd047e2..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.SortedMap;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
-import org.eclipse.cdt.core.dom.ast.IASTProblem;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IProblemBinding;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexFile;
-import org.eclipse.cdt.core.index.IIndexFileLocation;
-import org.eclipse.cdt.core.index.IIndexInclude;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
-import org.eclipse.cdt.core.parser.IScannerInfoProvider;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.core.model.ASTCache;
-import org.eclipse.cdt.internal.core.model.TranslationUnit;
-import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
-import org.eclipse.cdt.internal.core.pdom.PDOM;
-import org.eclipse.cdt.internal.core.pdom.indexer.ProjectIndexerInputAdapter;
-
-import org.eclipse.cdt.internal.ui.editor.ASTProvider;
-
-@SuppressWarnings("nls")
-public class CreateParserLogAction implements IObjectActionDelegate {
-
- private static final class MyVisitor extends ASTVisitor {
- List fProblems= new ArrayList();
- List fProblemBindings= new ArrayList();
- List fExceptions= new ArrayList();
-
- MyVisitor() {
- shouldVisitProblems= true;
- shouldVisitNames= true;
- }
-
- @Override
- public int visit(IASTProblem problem) {
- fProblems.add(problem);
- return PROCESS_SKIP;
- }
-
- @Override
- public int visit(IASTName name) {
- if (name instanceof ICPPASTQualifiedName) {
- return PROCESS_CONTINUE;
- }
- try {
- IBinding binding= name.resolveBinding();
- if (binding instanceof IProblemBinding) {
- fProblemBindings.add((IProblemBinding) binding);
- }
- } catch (RuntimeException e) {
- fExceptions.add(e);
- }
- return PROCESS_CONTINUE;
- }
- }
-
- private static final Comparator COMP_INSENSITIVE= new Comparator () {
- public int compare(String o1, String o2) {
- return o1.toUpperCase().compareTo(o2.toUpperCase());
- }
- };
-
- private ISelection fSelection;
- private IWorkbenchPartSite fSite;
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fSite= targetPart.getSite();
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- fSelection = selection;
- }
-
- public void run(IAction action) {
- if (!(fSelection instanceof IStructuredSelection))
- return;
-
- final String title= action.getText().replace("&", "");
- IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
- Iterator> i= cElements.iterator();
- ArrayList tuSelection= new ArrayList();
- while (i.hasNext()) {
- Object o= i.next();
- if (o instanceof ITranslationUnit) {
- tuSelection.add((ITranslationUnit) o);
- }
- }
- ITranslationUnit[] tuArray= tuSelection.toArray(new ITranslationUnit[tuSelection.size()]);
- if (tuArray.length == 0) {
- return;
- }
- FileDialog dlg= new FileDialog(fSite.getShell(), SWT.SAVE);
- dlg.setText(title);
- dlg.setFilterExtensions(new String[]{"*.log"});
- String path= null;
- while(path == null) {
- path= dlg.open();
- if (path == null)
- return;
-
- File file= new File(path);
- if (file.exists()) {
- if (!file.canWrite()) {
- final String msg= NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path);
- MessageDialog.openError(fSite.getShell(), title, msg);
- path= null;
- }
- else {
- final String msg = NLS.bind(ActionMessages.CreateParserLogAction_existingFile, path);
- if (!MessageDialog.openQuestion(fSite.getShell(), title, msg)) {
- path= null;
- }
- }
- }
- }
-
- try {
- PrintStream out= new PrintStream(path);
- try {
- boolean needsep= false;
- for (ITranslationUnit tu : tuArray) {
- if (needsep) {
- out.println(); out.println();
- }
- createLog(out, tu, new NullProgressMonitor());
- needsep= true;
- }
- }
- finally {
- out.close();
- }
- } catch (IOException e) {
- MessageDialog.openError(fSite.getShell(), action.getText(), e.getMessage());
- }
- }
-
- private void createLog(final PrintStream out, final ITranslationUnit tu, IProgressMonitor pm) {
- try {
- tu.open(pm);
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, pm, new ASTCache.ASTRunnable() {
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
- if (ast != null)
- return createLog(out, tu, lang, ast);
- return Status.CANCEL_STATUS;
- }
- });
- }
-
- protected IStatus createLog(PrintStream out, ITranslationUnit tu, ILanguage lang, IASTTranslationUnit ast) {
- IStatus status = Status.OK_STATUS;
- final ICProject cproject = tu.getCProject();
- final String projectName= cproject == null ? null : cproject.getElementName();
- String scannerInfoProvider= "null";
- if (cproject != null) {
- IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(cproject.getProject());
- if (provider != null) {
- scannerInfoProvider= provider.getClass().getName();
- }
- }
-
- ITranslationUnit ctx= tu;
- if (tu instanceof TranslationUnit) {
- TranslationUnit itu= (TranslationUnit) tu;
- ctx= itu.getSourceContextTU(ast.getIndex(), ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT);
- }
- final ExtendedScannerInfo scfg= new ExtendedScannerInfo(ctx.getScannerInfo(true));
- final String indent= " ";
- final MyVisitor visitor= new MyVisitor();
- ast.accept(visitor);
-
- out.println("Project: " + projectName);
- out.println("Index Version: " + PDOM.versionString(PDOM.getDefaultVersion()));
- out.println("Scanner Info Provider: " + scannerInfoProvider);
- out.println("Build Configuration: " + getBuildConfig(cproject));
- out.println("File: " + tu.getLocationURI());
- out.println("Context: " + ctx.getLocationURI());
- out.println("Language: " + lang.getName());
- out.println();
- out.println("Include Search Path (option -I):");
- output(out, indent, scfg.getIncludePaths());
- out.println();
- out.println("Local Include Search Path (option -iquote):");
- output(out, indent, scfg.getLocalIncludePath());
- out.println();
- out.println("Preincluded files (option -include):");
- output(out, indent, scfg.getIncludeFiles());
- out.println();
- out.println("Preincluded macro files (option -imacros):");
- output(out, indent, scfg.getMacroFiles());
- out.println();
- out.println("Macro definitions (option -D):");
- HashSet reported= new HashSet();
- output(out, indent, scfg.getDefinedSymbols(), reported);
- out.println();
- out.println("Macro definitions (from configuration + headers in index):");
- output(out, indent, ast.getBuiltinMacroDefinitions(), reported);
- out.println();
- out.println("Macro definitions (from files actually parsed):");
- output(out, indent, ast.getMacroDefinitions(), reported);
-
- out.println();
- out.println("Unresolved includes (from headers in index):");
- try {
- outputUnresolvedIncludes(cproject, ast.getIndex(), out, indent, ast.getIncludeDirectives(), ast.getLinkage().getLinkageID());
- } catch (CoreException e) {
- status= e.getStatus();
- }
-
- out.println();
- out.println("Scanner problems:");
- output(out, indent, ast.getPreprocessorProblems());
-
- out.println();
- out.println("Parser problems:");
- output(out, indent, visitor.fProblems.toArray(new IASTProblem[visitor.fProblems.size()]));
-
- out.println();
- out.println("Unresolved names:");
- output(out, indent, visitor.fProblemBindings);
-
- out.println();
- out.println("Exceptions in name resolution:");
- output(out, visitor.fExceptions);
-
- return status;
- }
-
- private String getBuildConfig(ICProject cproject) {
- ICProjectDescriptionManager prjDescMgr= CCorePlugin.getDefault().getProjectDescriptionManager();
- ICProjectDescription prefs= prjDescMgr.getProjectDescription(cproject.getProject(), false);
- if (prefs != null) {
- ICConfigurationDescription cfg= prefs.getDefaultSettingConfiguration();
- if (cfg != null)
- return cfg.getName();
- }
- return "unknown";
- }
-
- private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, String indent,
- IASTPreprocessorIncludeStatement[] includeDirectives, int linkageID) throws CoreException {
- ASTFilePathResolver resolver= new ProjectIndexerInputAdapter(prj);
- HashSet handled= new HashSet();
- for (IASTPreprocessorIncludeStatement include : includeDirectives) {
- if (include.isActive() && include.isResolved()) {
- outputUnresolvedIncludes(index, out, indent, resolver.resolveASTPath(include.getPath()), linkageID, handled);
- }
- }
- }
-
- private void outputUnresolvedIncludes(IIndex index, PrintStream out, String indent,
- IIndexFileLocation ifl, int linkageID, HashSet handled) throws CoreException {
- if (!handled.add(ifl)) {
- return;
- }
- IIndexFile ifile= index.getFile(linkageID, ifl);
- if (ifile == null) {
- out.println(indent + ifl.getURI() + " is not indexed");
- }
- else {
- IIndexInclude[] includes = ifile.getIncludes();
- for (IIndexInclude inc : includes) {
- if (inc.isActive()) {
- if (inc.isResolved()) {
- outputUnresolvedIncludes(index, out, indent, inc.getIncludesLocation(), linkageID, handled);
- }
- else {
- out.println(indent + "Unresolved inclusion: " + inc.getFullName() + " in file " +
- inc.getIncludedByLocation().getURI());
- }
- }
- }
- }
- }
-
- private void output(PrintStream out, String indent, String[] list) {
- for (String line : list) {
- out.println(indent + line);
- }
- }
-
- private void output(PrintStream out, String indent, Map definedSymbols, HashSet reported) {
- SortedMap sorted= new TreeMap(COMP_INSENSITIVE);
- sorted.putAll(definedSymbols);
- for (Entry entry : sorted.entrySet()) {
- final String macro = entry.getKey() + '=' + entry.getValue();
- if (reported.add(macro)) {
- out.println(indent + macro);
- }
- }
- }
-
- private void output(PrintStream out, String indent, IASTPreprocessorMacroDefinition[] defs, HashSet reported) {
- SortedSet macros= new TreeSet(COMP_INSENSITIVE);
- for (IASTPreprocessorMacroDefinition def : defs) {
- macros.add(def.toString());
- }
-
- for (String macro : macros) {
- if (reported.add(macro)) {
- out.println(indent + macro);
- }
- }
- }
-
- private void output(PrintStream out, String indent, IASTProblem[] preprocessorProblems) {
- for (IASTProblem problem : preprocessorProblems) {
- out.println(indent + problem.getMessageWithLocation());
- }
- }
-
- private void output(PrintStream out, String indent, List list) {
- for (IProblemBinding problem : list) {
- String file= problem.getFileName();
- int line = problem.getLineNumber();
- out.println(indent + problem.getMessage() + " in file " + file + ':' + line);
- }
- }
-
- private void output(PrintStream out, List list) {
- for (Exception problem : list) {
- problem.printStackTrace(out);
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java
deleted file mode 100644
index 0f3322c..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Intel 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Intel Corporation - initial API and implementation
- * Nokia - converted from action to handler
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICResourceDescription;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.newui.AbstractPage;
-
-
-
-/**
- * Handler for command that deletes resource description. (If resource description is missing
- * one from parent is normally used)
- */
-public class DeleteResConfigsHandler extends AbstractHandler {
-
- protected ArrayList objects;
- private ArrayList outData;
-
- @Override
- public void setEnabled(Object context) {
- ISelection selection = getSelection(context);
- setEnabledFromSelection(selection);
- }
-
- protected ISelection getSelection(Object context) {
- Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME);
- if (s instanceof ISelection) {
- return (ISelection) s;
- }
- return null;
- }
-
- public void setEnabledFromSelection(ISelection selection) {
- objects = null;
-
- if ((selection != null) && !selection.isEmpty()) {
- // case for context menu
- Object[] obs = null;
- if (selection instanceof IStructuredSelection) {
- obs = ((IStructuredSelection)selection).toArray();
- }
- else if (selection instanceof ITextSelection) {
- IFile file = getFileFromActiveEditor();
- if (file != null)
- obs = Collections.singletonList(file).toArray();
- }
- if (obs != null && obs.length > 0) {
- for (int i=0; i();
- objects.add(res);
- break; // stop configurations scanning
- }
- }
- }
- }
- }
- }
- setBaseEnabled(objects != null);
- }
-
- private IFile getFileFromActiveEditor() {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- IEditorInput input = editor.getEditorInput();
- if (input != null)
- return (IFile) input.getAdapter(IFile.class);
- }
- }
- }
- return null;
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- openDialog();
- return null;
- }
-
- private void openDialog() {
- if (objects == null || objects.size() == 0) return;
- // create list of configurations to delete
-
- ListSelectionDialog dialog = new ListSelectionDialog(
- CUIPlugin.getActiveWorkbenchShell(),
- objects,
- createSelectionDialogContentProvider(),
- new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0);
- dialog.setTitle(ActionMessages.DeleteResConfigsAction_1);
- if (dialog.open() == Window.OK) {
- Object[] selected = dialog.getResult();
- if (selected != null && selected.length > 0) {
- for (Object element : selected) {
- ((ResCfgData)element).delete();
- AbstractPage.updateViews(((ResCfgData)element).res);
- }
- }
- }
- }
-
- // Stores data for resource description with its "parents".
- class ResCfgData {
- IResource res;
- ICProjectDescription prjd;
- ICConfigurationDescription cfgd;
- ICResourceDescription rdesc;
-
- public ResCfgData(IResource res2, ICProjectDescription prjd2,
- ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) {
- res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2;
- }
-
- // performs deletion
- public void delete() {
- try {
- cfgd.removeResourceDescription(rdesc);
- CoreModel.getDefault().setProjectDescription(res.getProject(), prjd);
- } catch (CoreException e) {}
- }
- @Override
- public String toString() {
- return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- private IStructuredContentProvider createSelectionDialogContentProvider() {
- outData = null;
-
- return new IStructuredContentProvider() {
-
- public Object[] getElements(Object inputElement) {
- if (outData != null) return outData.toArray();
-
- outData = new ArrayList();
- List> ls = (List>)inputElement;
- Iterator> it = ls.iterator();
- IProject proj = null;
- ICProjectDescription prjd = null;
- ICConfigurationDescription[] cfgds = null;
-
- // creating list of all res descs for all objects
- while (it.hasNext()) {
- IResource res = (IResource)it.next();
- IPath path = res.getProjectRelativePath();
- if (res.getProject() != proj) {
- proj = res.getProject();
- prjd = CoreModel.getDefault().getProjectDescription(proj);
- cfgds = prjd.getConfigurations();
- }
- if (cfgds != null) {
- for (ICConfigurationDescription cfgd : cfgds) {
- ICResourceDescription rd = cfgd.getResourceDescription(path, true);
- if (rd != null)
- outData.add(new ResCfgData(res, prjd, cfgd, rd));
- }
- }
- }
- return outData.toArray();
- }
- public void dispose() {}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
- };
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java
deleted file mode 100644
index fe53bae..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Intel 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Intel Corporation - initial API and implementation
- * Nokia - converted from action to handler
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ListSelectionDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
-import org.eclipse.cdt.core.settings.model.ICProjectDescription;
-import org.eclipse.cdt.core.settings.model.ICSourceEntry;
-import org.eclipse.cdt.core.settings.model.util.CDataUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.newui.AbstractPage;
-
-import org.eclipse.cdt.internal.ui.newui.Messages;
-
-
-/**
- * Handler for command that excludes resources from build.
- */
-public class ExcludeFromBuildHandler extends AbstractHandler {
-
- protected ArrayList objects;
- protected ArrayList cfgNames;
-
- @Override
- public void setEnabled(Object context) {
- ISelection selection = getSelection(context);
- setEnabledFromSelection(selection);
- }
-
- protected ISelection getSelection(Object context) {
- Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME);
- if (s instanceof ISelection) {
- return (ISelection) s;
- }
- return null;
- }
-
- public void setEnabledFromSelection(ISelection selection) {
- objects = null;
- cfgNames = null;
- boolean cfgsOK = true;
-
- if ((selection != null) && !selection.isEmpty()) {
- // case for context menu
- Object[] obs = null;
- if (selection instanceof IStructuredSelection) {
- obs = ((IStructuredSelection)selection).toArray();
- }
- else if (selection instanceof ITextSelection) {
- IFile file = getFileFromActiveEditor();
- if (file != null)
- obs = Collections.singletonList(file).toArray();
- }
- if (obs != null && obs.length > 0) {
- for (int i=0; i();
- objects.add(res);
- if (cfgNames == null) {
- cfgNames = new ArrayList(cfgds.length);
- for (int j=0; j it = objects.iterator();
- while (it.hasNext()) {
- IResource res = it.next();
- ICConfigurationDescription[] cfgds = getCfgsRead(res);
- IPath p = res.getFullPath();
- for (int i=0; i lst = new ArrayList();
- for (int i=0; i 0)
- dialog.setInitialElementSelections(lst);
-
- if (dialog.open() == Window.OK) {
- Object[] selected = dialog.getResult(); // may be empty
- Iterator it2 = objects.iterator();
- while (it2.hasNext()) {
- IResource res = it2.next();
- IProject p = res.getProject();
- if (!p.isOpen()) continue;
- // get writable description
- ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, true);
- if (prjd == null) continue;
- ICConfigurationDescription[] cfgds = prjd.getConfigurations();
- for (int i=0; ieditor. If the
- * supplied viewer is not an instance of ProjectionViewer, the
- * action group is disabled.
- *
- * @param editor the text editor to operate on
- * @param viewer the viewer of the editor
- */
- public FoldingActionGroup(final ITextEditor editor, ITextViewer viewer) {
- if (!(viewer instanceof ProjectionViewer)) {
- fToggle= null;
- fExpand= null;
- fCollapse= null;
- fExpandAll= null;
- fCollapseAll= null;
- fRestoreDefaults= null;
- fProjectionListener= null;
- return;
- }
-
- fViewer= (ProjectionViewer) viewer;
-
- fProjectionListener= new IProjectionListener() {
- public void projectionEnabled() {
- update();
- }
- public void projectionDisabled() {
- update();
- }
- };
-
- fViewer.addProjectionListener(fProjectionListener);
-
- fToggle= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); //$NON-NLS-1$
- fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE);
- editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$
-
- fExpandAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$
- fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL);
- editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$
-
- fCollapseAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, ProjectionViewer.COLLAPSE_ALL, true); //$NON-NLS-1$
- fCollapseAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL);
- editor.setAction("FoldingCollapseAll", fCollapseAll); //$NON-NLS-1$
-
- fExpand= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$
- fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND);
- editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$
-
- fCollapse= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$
- fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE);
- editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$
-
- fRestoreDefaults= new FoldingAction(FoldingMessages.getResourceBundle(), "Projection.Restore.") { //$NON-NLS-1$
- @Override
- public void run() {
- if (editor instanceof CEditor) {
- CEditor cEditor= (CEditor) editor;
- cEditor.resetProjection();
- }
- }
- };
- fRestoreDefaults.setActionDefinitionId(IFoldingCommandIds.FOLDING_RESTORE);
- editor.setAction("FoldingRestore", fRestoreDefaults); //$NON-NLS-1$
- }
-
- /**
- * Returns true if the group is enabled.
- *
- * Invariant: isEnabled() <=> fViewer and all actions are != null.
- *
- *
- * @return true if the group is enabled
- */
- protected boolean isEnabled() {
- return fViewer != null;
- }
-
- /*
- * @see org.eclipse.ui.actions.ActionGroup#dispose()
- */
- @Override
- public void dispose() {
- if (isEnabled()) {
- fViewer.removeProjectionListener(fProjectionListener);
- fViewer= null;
- }
- super.dispose();
- }
-
- /**
- * Updates the actions.
- */
- protected void update() {
- if (isEnabled()) {
- fToggle.update();
- fToggle.setChecked(fViewer.isProjectionMode());
- fExpand.update();
- fExpandAll.update();
- fCollapse.update();
- fCollapseAll.update();
- fRestoreDefaults.update();
- }
- }
-
- /**
- * Fills the menu with all folding actions.
- *
- * @param manager the menu manager for the folding submenu
- */
- public void fillMenu(IMenuManager manager) {
- if (isEnabled()) {
- update();
- manager.add(fToggle);
- manager.add(fExpandAll);
- manager.add(fExpand);
- manager.add(fCollapse);
- manager.add(fCollapseAll);
- manager.add(fRestoreDefaults);
- }
- }
-
- /*
- * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
- */
- @Override
- public void updateActionBars() {
- update();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java
deleted file mode 100644
index d42be4d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import com.ibm.icu.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Class that gives access to the folding messages resource bundle.
- */
-public class FoldingMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.cdt.internal.ui.actions.FoldingMessages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- private FoldingMessages() {
- // no instance
- }
-
- /**
- * Returns the resource string associated with the given key in the resource bundle. If there isn't
- * any value under the given key, the key is returned.
- *
- * @param key the resource key
- * @return the string
- */
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Returns the resource bundle managed by the receiver.
- *
- * @return the resource bundle
- * @since 3.0
- */
- public static ResourceBundle getResourceBundle() {
- return RESOURCE_BUNDLE;
- }
-
- /**
- * Returns the formatted resource string associated with the given key in the resource bundle.
- * MessageFormat is used to format the message. If there isn't any value
- * under the given key, the key is returned.
- *
- * @param key the resource key
- * @param arg the message argument
- * @return the string
- */
- public static String getFormattedString(String key, Object arg) {
- return getFormattedString(key, new Object[] { arg });
- }
-
- /**
- * Returns the formatted resource string associated with the given key in the resource bundle.
- * MessageFormat is used to format the message. If there isn't any value
- * under the given key, the key is returned.
- *
- * @param key the resource key
- * @param args the message arguments
- * @return the string
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.properties
deleted file mode 100644
index 7f9a9c8..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingMessages.properties
+++ /dev/null
@@ -1,39 +0,0 @@
-###############################################################################
-# Copyright (c) 2005, 2006 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
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-Projection.Toggle.label= &Enable Folding
-Projection.Toggle.tooltip= Toggles Folding
-Projection.Toggle.description= Toggles folding for the current editor
-Projection.Toggle.image=
-
-Projection.ExpandAll.label= Expand &All
-Projection.ExpandAll.tooltip= Expands All Collapsed Regions
-Projection.ExpandAll.description= Expands any collapsed regions in the current editor
-Projection.ExpandAll.image=
-
-Projection.Expand.label= E&xpand
-Projection.Expand.tooltip= Expands the Current Collapsed Region
-Projection.Expand.description= Expands the collapsed region at the current selection
-Projection.Expand.image=
-
-Projection.CollapseAll.label= Collapse A&ll
-Projection.CollapseAll.tooltip= Collapses All Expanded Regions
-Projection.CollapseAll.description= Collapse any expanded regions in the current editor
-Projection.CollapseAll.image=
-
-Projection.Collapse.label= Colla&pse
-Projection.Collapse.tooltip= Collapses the Current Region
-Projection.Collapse.description= Collapses the Current Region
-Projection.Collapse.image=
-
-Projection.Restore.label= &Reset Structure
-Projection.Restore.tooltip= Restore the Original Folding Structure
-Projection.Restore.description= Restores the original folding structure
-Projection.Restore.image=
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java
deleted file mode 100644
index ffed3d4..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FreshenIndexAction.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.cdt.core.index.IIndexManager;
-
-public class FreshenIndexAction extends AbstractUpdateIndexAction {
-
- @Override
- protected int getUpdateOptions() {
- return IIndexManager.UPDATE_ALL | IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java
deleted file mode 100644
index e854a07..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GoToNextPreviousMemberAction.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * P.Tomaszewski
- * Anton Leherbauer (Wind River Systems)
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-
-/**
- * Gives possibility to move fast between member elements of the c/c++ source.
- *
- * @author P.Tomaszewski
- */
-public class GoToNextPreviousMemberAction extends TextEditorAction {
-
- public static final String NEXT_MEMBER = "GotoNextMember"; //$NON-NLS-1$
- public static final String PREVIOUS_MEMBER = "GotoPrevMember"; //$NON-NLS-1$
-
- /** Determines should action take user to the next member or to the previous one. */
- private boolean fGotoNext;
-
- /**
- * Creates new action.
- * @param bundle Resource bundle.
- * @param prefix Prefix.
- * @param editor Editor.
- * @param gotoNext Is it go to next or previous action.
- */
- public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean gotoNext) {
- super(bundle, prefix, editor);
-
- fGotoNext = gotoNext;
- }
-
- /**
- * Creates new action.
- * @param bundle Resource bundle.
- * @param prefix Prefix.
- * @param editor Editor.
- * @param style UI style.
- * @param gotoNext Is it go to next or previous action.
- */
- public GoToNextPreviousMemberAction(ResourceBundle bundle, String prefix, ITextEditor editor, int style, boolean gotoNext) {
- super(bundle, prefix, editor, style);
-
- fGotoNext = gotoNext;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.TextEditorAction#update()
- */
- @Override
- public void update() {
- final ITextEditor editor = getTextEditor();
- setEnabled(editor instanceof CEditor && ((CEditor)editor).getInputCElement() != null);
- }
-
- /**
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- final CEditor editor = (CEditor) getTextEditor();
- final ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
- final IEditorInput editorInput = editor.getEditorInput();
- final IWorkingCopy workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput);
- if (workingCopy == null) {
- return;
- }
- try {
- ISourceReference next= fGotoNext ?
- getNextElement(workingCopy, selection.getOffset()) :
- getPrevElement(workingCopy, selection.getOffset());
- if (next != null) {
- editor.selectAndReveal(next.getSourceRange().getIdStartPos(), 0);
- }
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- }
-
- private ISourceReference getNextElement(IParent parent, int offset) throws CModelException {
- ICElement[] children= parent.getChildren();
- for (int i = 0; i < children.length; i++) {
- ICElement element = children[i];
- if (element instanceof ISourceReference) {
- final ISourceReference candidate1= (ISourceReference) element;
- final ISourceRange range= candidate1.getSourceRange();
- final int idpos1= range.getIdStartPos();
- if (element instanceof IParent && range.getStartPos() + range.getLength() > offset) {
- ISourceReference candidate2= getNextElement((IParent) element, offset);
- if (candidate2 != null) {
- final int idpos2= candidate2.getSourceRange().getIdStartPos();
- if (idpos1 <= offset || idpos1 > idpos2) {
- return candidate2;
- }
- }
- }
- if (idpos1 > offset) {
- return candidate1;
- }
- }
- }
- return null;
- }
-
- private ISourceReference getPrevElement(IParent parent, int offset) throws CModelException {
- ICElement[] children= parent.getChildren();
- for (int i= children.length-1; i >= 0; i--) {
- ICElement element = children[i];
- if (element instanceof ISourceReference) {
- final ISourceReference candidate1= (ISourceReference) element;
- final ISourceRange range= candidate1.getSourceRange();
- final int idpos1= range.getIdStartPos();
- if (element instanceof IParent && range.getStartPos() < offset) {
- ISourceReference candidate2= getPrevElement((IParent) element, offset);
- if (candidate2 != null) {
- final int idpos2= candidate2.getSourceRange().getIdStartPos();
- if (idpos1 >= offset || idpos1 < idpos2) {
- return candidate2;
- }
- }
- }
- if (idpos1 < offset) {
- return candidate1;
- }
- }
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java
deleted file mode 100644
index a041904..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Nokia 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:
- * Nokia - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.OpenStrategy;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-/**
- * Find and goto the next bookmark in the currently selected file.
- */
-public class GotoNextBookmarkAction extends TextEditorAction {
-
- public static final String NEXT_BOOKMARK = "GotoNextBookmark"; //$NON-NLS-1$
-
- /**
- * Private class to handle comparison of markers using their line numbers.
- */
- private class CompareMarker implements Comparator {
- public int compare(IMarker m1, IMarker m2) {
- int l1 = MarkerUtilities.getLineNumber(m1);
- int l2 = MarkerUtilities.getLineNumber(m2);
- if (l1 > l2) return 1;
- if (l1 < l2) return -1;
- return 0;
- }
- }
-
- /**
- * Creates new action.
- */
- public GotoNextBookmarkAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- ITextEditor editor = getTextEditor();
- if (editor == null )
- return;
-
- ISelectionProvider provider = editor.getSelectionProvider();
- if (provider == null)
- return;
-
- ITextSelection selection = (ITextSelection) provider.getSelection();
- if (selection == null || selection.isEmpty())
- return;
-
- IEditorInput input= editor.getEditorInput();
- if (input == null)
- return;
-
- IResource resource = (IResource)(input).getAdapter(IResource.class);
- if (resource == null || !(resource instanceof IFile))
- return;
-
- try {
- IMarker[] bookmarks = resource.findMarkers(IMarker.BOOKMARK, true, IResource.DEPTH_ONE);
- if (bookmarks.length == 0)
- return;
-
- // sort bookmarks by line number
- CompareMarker comparator = new CompareMarker();
- Arrays.sort(bookmarks, comparator);
-
- // marker line numbers are 1-based
- int line = selection.getStartLine() + 1;
- IMarker lastBookmark = bookmarks[bookmarks.length - 1];
-
- // start from the beginning of file if reached or went beyond last bookmark
- if (line >= MarkerUtilities.getLineNumber(lastBookmark)) {
- line = 1;
- }
-
- // find the next bookmark and goto it
- for (int i = 0; i < bookmarks.length; i++) {
- IMarker bookmark = bookmarks[i];
- if (MarkerUtilities.getLineNumber(bookmark) > line) {
- IDE.openEditor(getTextEditor().getSite().getPage(), bookmark, OpenStrategy.activateOnOpen());
- break;
- }
- }
- }
- catch (CoreException e) {
- e.printStackTrace();
- }
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java
deleted file mode 100644
index df58e6d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java
+++ /dev/null
@@ -1,572 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sergey Prigogin, Google
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension3;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.ICPartitions;
-
-import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.editor.IndentUtil;
-import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
-import org.eclipse.cdt.internal.ui.text.CIndenter;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-
-
-/**
- * Indents a line or range of lines in a C document to its correct position. No complete
- * AST must be present, the indentation is computed using heuristics. The algorithm used is fast for
- * single lines, but does not store any information and therefore not so efficient for large line
- * ranges.
- *
- * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner
- * @see org.eclipse.cdt.internal.ui.text.CIndenter
- */
-public class IndentAction extends TextEditorAction {
-
- /** The caret offset after an indent operation. */
- private int fCaretOffset;
-
- /**
- * Whether this is the action invoked by TAB. When true, indentation behaves
- * differently to accommodate normal TAB operation.
- */
- private final boolean fIsTabAction;
-
- /**
- * Creates a new instance.
- *
- * @param bundle the resource bundle
- * @param prefix the prefix to use for keys in bundle
- * @param editor the text editor
- * @param isTabAction whether the action should insert tabs if over the indentation
- */
- public IndentAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean isTabAction) {
- super(bundle, prefix, editor);
- fIsTabAction= isTabAction;
- }
-
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- // update has been called by the framework
- if (!isEnabled() || !validateEditorInputState())
- return;
-
- ITextSelection selection= getSelection();
- final IDocument document= getDocument();
-
- if (document != null) {
- final int offset= selection.getOffset();
- final int length= selection.getLength();
- final Position end= new Position(offset + length);
- final int firstLine, nLines;
- fCaretOffset= -1;
-
- try {
- firstLine= document.getLineOfOffset(offset);
- // check for marginal (zero-length) lines
- int minusOne= length == 0 ? 0 : 1;
- nLines= document.getLineOfOffset(offset + length - minusOne) - firstLine + 1;
- document.addPosition(end);
- } catch (BadLocationException e) {
- // will only happen on concurrent modification
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "", e)); //$NON-NLS-1$
- return;
- }
-
- Runnable runnable= new Runnable() {
- public void run() {
- IRewriteTarget target= (IRewriteTarget)getTextEditor().getAdapter(IRewriteTarget.class);
- if (target != null)
- target.beginCompoundChange();
-
- try {
- CHeuristicScanner scanner= new CHeuristicScanner(document);
- CIndenter indenter= new CIndenter(document, scanner, getCProject());
- final boolean multiLine= nLines > 1;
- boolean hasChanged= false;
- for (int i= 0; i < nLines; i++) {
- hasChanged |= indentLine(document, firstLine + i, offset, indenter, scanner, multiLine);
- }
-
- // update caret position: move to new position when indenting just one line
- // keep selection when indenting multiple
- int newOffset, newLength;
- if (!fIsTabAction && multiLine) {
- newOffset= offset;
- newLength= end.getOffset() - offset;
- } else {
- newOffset= fCaretOffset;
- newLength= 0;
- }
-
- // always reset the selection if anything was replaced
- // but not when we had a single line non-tab invocation
- if (newOffset != -1 && (hasChanged || newOffset != offset || newLength != length))
- selectAndReveal(newOffset, newLength);
-
- } catch (BadLocationException e) {
- // will only happen on concurrent modification
- CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$
- } finally {
- document.removePosition(end);
- if (target != null)
- target.endCompoundChange();
- }
- }
- };
-
- if (nLines > 50) {
- Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay();
- BusyIndicator.showWhile(display, runnable);
- } else {
- runnable.run();
- }
- }
- }
-
- /**
- * Selects the given range on the editor.
- *
- * @param newOffset the selection offset
- * @param newLength the selection range
- */
- private void selectAndReveal(int newOffset, int newLength) {
- Assert.isTrue(newOffset >= 0);
- Assert.isTrue(newLength >= 0);
- ITextEditor editor= getTextEditor();
- if (editor instanceof CEditor) {
- ISourceViewer viewer= ((CEditor)editor).getViewer();
- if (viewer != null)
- viewer.setSelectedRange(newOffset, newLength);
- } else {
- // this is too intrusive, but will never get called anyway
- getTextEditor().selectAndReveal(newOffset, newLength);
- }
- }
-
- /**
- * Indents a single line using the heuristic scanner. Multiline comments are
- * indented as specified by the CCommentAutoIndentStrategy.
- *
- * @param document the document
- * @param line the line to be indented
- * @param caret the caret position
- * @param indenter the indenter
- * @param scanner the heuristic scanner
- * @param multiLine true if more than one line is being indented
- * @return true if document was modified, false otherwise
- * @throws BadLocationException if the document got changed concurrently
- */
- private boolean indentLine(IDocument document, int line, int caret, CIndenter indenter, CHeuristicScanner scanner, boolean multiLine) throws BadLocationException {
- IRegion currentLine= document.getLineInformation(line);
- int offset= currentLine.getOffset();
- int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
-
- String indent= null;
- if (offset < document.getLength()) {
- ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
- ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
- String type= partition.getType();
- if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT) || type.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT)) {
- indent= computeCommentIndent(document, line, scanner, startingPartition);
- } else if (startingPartition.getType().equals(ICPartitions.C_PREPROCESSOR)) {
- indent= computePreprocessorIndent(document, line, startingPartition);
- } else if (startingPartition.getType().equals(ICPartitions.C_STRING) && offset > startingPartition.getOffset()) {
- // don't indent inside (raw-)string
- return false;
- } else if (!fIsTabAction && startingPartition.getOffset() == offset && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
- // line comment starting at position 0 -> indent inside
- if (indentInsideLineComments()) {
- int max= document.getLength() - offset;
- int slashes= 2;
- while (slashes < max - 1 && document.get(offset + slashes, 2).equals("//")) //$NON-NLS-1$
- slashes+= 2;
-
- wsStart= offset + slashes;
-
- StringBuilder computed= indenter.computeIndentation(offset);
- if (computed == null)
- computed= new StringBuilder(0);
- int tabSize= getTabSize();
- while (slashes > 0 && computed.length() > 0) {
- char c= computed.charAt(0);
- if (c == '\t') {
- if (slashes > tabSize)
- slashes-= tabSize;
- else
- break;
- } else if (c == ' ') {
- slashes--;
- } else {
- break;
- }
-
- computed.deleteCharAt(0);
- }
-
- indent= document.get(offset, wsStart - offset) + computed;
- }
- }
- }
-
- // standard C code indentation
- if (indent == null) {
- StringBuilder computed= indenter.computeIndentation(offset);
- if (computed != null)
- indent= computed.toString();
- else
- indent= ""; //$NON-NLS-1$
- }
-
- // change document:
- // get current white space
- int lineLength= currentLine.getLength();
- int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
- if (end == CHeuristicScanner.NOT_FOUND) {
- // an empty line
- end= offset + lineLength;
- if (multiLine && !indentEmptyLines())
- indent= ""; //$NON-NLS-1$
- }
- int length= end - offset;
- String currentIndent= document.get(offset, length);
-
- // if we are right before the text start / line end, and already after the insertion point
- // then just shift to the right
- if (fIsTabAction && caret == end && whiteSpaceLength(currentIndent) >= whiteSpaceLength(indent)) {
- int indentWidth= whiteSpaceLength(currentIndent) + getIndentSize();
- if (useTabsAndSpaces()) {
- currentIndent = trimSpacesRight(currentIndent);
- }
- String replacement= IndentUtil.changePrefix(currentIndent, indentWidth, getTabSize(), useSpaces());
- document.replace(offset, length, replacement);
- fCaretOffset= offset + replacement.length();
- return true;
- }
-
- // set the caret offset so it can be used when setting the selection
- if (caret >= offset && caret <= end)
- fCaretOffset= offset + indent.length();
- else
- fCaretOffset= -1;
-
- // only change the document if it is a real change
- if (!indent.equals(currentIndent)) {
- document.replace(offset, length, indent);
- return true;
- }
- return false;
- }
-
- /**
- * Strip trailing space characters.
- *
- * @param indent
- * @return string with trailing spaces removed
- */
- private String trimSpacesRight(String indent) {
- int i = indent.length() - 1;
- while (i >= 0 && indent.charAt(i) == ' ') {
- --i;
- }
- return indent.substring(0, i+1);
- }
-
- /**
- * Computes and returns the indentation for a block comment line.
- *
- * @param document the document
- * @param line the line in document
- * @param scanner the scanner
- * @param partition the comment partition
- * @return the indent, or null if not computable
- * @throws BadLocationException
- */
- private String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
- return IndentUtil.computeCommentIndent(document, line, scanner, partition);
- }
-
- /**
- * Computes and returns the indentation for a preprocessor line.
- *
- * @param document the document
- * @param line the line in document
- * @param partition the comment partition
- * @return the indent, or null if not computable
- * @throws BadLocationException
- */
- private String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition) throws BadLocationException {
- return IndentUtil.computePreprocessorIndent(document, line, partition);
- }
-
- /**
- * Returns the size in characters of a string. All characters count one, tabs count the editor's
- * preference for the tab display
- *
- * @param indent the string to be measured.
- * @return the size in characters of a string
- */
- private int whiteSpaceLength(String indent) {
- if (indent == null)
- return 0;
- return IndentUtil.computeVisualLength(indent, getTabSize());
- }
-
- /**
- * Returns whether spaces should be used exclusively for indentation, depending on the editor and
- * formatter preferences.
- *
- * @return true if only spaces should be used
- */
- private boolean useSpaces() {
- return CCorePlugin.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
- }
-
- /**
- * Returns whether mixed tabs/spaces should be used for indentation, depending on the editor and
- * formatter preferences.
- *
- * @return true if tabs and spaces should be used
- */
- private boolean useTabsAndSpaces() {
- return DefaultCodeFormatterConstants.MIXED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
- }
-
- /**
- * Returns the tab size used by the editor, which is deduced from the
- * formatter preferences.
- *
- * @return the tab size as defined in the current formatter preferences
- */
- private int getTabSize() {
- return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 4);
- }
-
- /**
- * Returns the indent size used by the editor, which is deduced from the
- * formatter preferences.
- *
- * @return the indent size as defined in the current formatter preferences
- */
- private int getIndentSize() {
- return CodeFormatterUtil.getIndentWidth(getCProject());
- }
-
- /**
- * Returns true if empty lines should be indented, false otherwise.
- *
- * @return true if empty lines should be indented, false otherwise
- */
- private boolean indentEmptyLines() {
- return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES));
- }
-
- /**
- * Returns true if line comments at column 0 should be indented inside, false otherwise.
- *
- * @return true if line comments at column 0 should be indented inside, false otherwise.
- */
- private boolean indentInsideLineComments() {
- return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS));
- }
-
- /**
- * Returns the possibly project-specific core preference defined under key.
- *
- * @param key the key of the preference
- * @return the value of the preference
- */
- private String getCoreFormatterOption(String key) {
- ICProject project= getCProject();
- if (project == null)
- return CCorePlugin.getOption(key);
- return project.getOption(key, true);
- }
-
- /**
- * Returns the possibly project-specific core preference defined under key, or
- * def if the value is not a integer.
- *
- * @param key the key of the preference
- * @param def the default value
- * @return the value of the preference
- */
- private int getCoreFormatterOption(String key, int def) {
- try {
- return Integer.parseInt(getCoreFormatterOption(key));
- } catch (NumberFormatException e) {
- return def;
- }
- }
-
- /**
- * Returns the ICProject of the current editor input, or
- * null if it cannot be found.
- *
- * @return the ICProject of the current editor input, or
- * null if it cannot be found
- */
- private ICProject getCProject() {
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return null;
-
- return EditorUtility.getCProject(editor.getEditorInput());
- }
-
- /**
- * Returns the editor's selection provider.
- *
- * @return the editor's selection provider or null
- */
- private ISelectionProvider getSelectionProvider() {
- ITextEditor editor= getTextEditor();
- if (editor != null) {
- return editor.getSelectionProvider();
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- @Override
- public void update() {
- super.update();
-
- if (isEnabled()) {
- if (fIsTabAction)
- setEnabled(canModifyEditor() && isSmartMode() && isValidSelection());
- else
- setEnabled(canModifyEditor() && !getSelection().isEmpty());
- }
- }
-
- /**
- * Returns if the current selection is valid, i.e. whether it is empty and the caret in the
- * whitespace at the start of a line, or covers multiple lines.
- *
- * @return true if the selection is valid for an indent operation
- */
- private boolean isValidSelection() {
- ITextSelection selection= getSelection();
- if (selection.isEmpty())
- return false;
-
- int offset= selection.getOffset();
- int length= selection.getLength();
-
- IDocument document= getDocument();
- if (document == null)
- return false;
-
- try {
- IRegion firstLine= document.getLineInformationOfOffset(offset);
- int lineOffset= firstLine.getOffset();
-
- // either the selection has to be empty and the caret in the WS at the line start
- // or the selection has to extend over multiple lines
- if (length == 0) {
- return document.get(lineOffset, offset - lineOffset).trim().length() == 0;
- }
-// return lineOffset + firstLine.getLength() < offset + length;
- return false; // only enable for empty selections for now
- } catch (BadLocationException e) {
- }
-
- return false;
- }
-
- /**
- * Returns the smart preference state.
- *
- * @return true if smart mode is on, false otherwise
- */
- private boolean isSmartMode() {
- ITextEditor editor= getTextEditor();
-
- if (editor instanceof ITextEditorExtension3)
- return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT;
-
- return false;
- }
-
- /**
- * Returns the document currently displayed in the editor, or null if none can be
- * obtained.
- *
- * @return the current document or null
- */
- private IDocument getDocument() {
- ITextEditor editor= getTextEditor();
- if (editor != null) {
- IDocumentProvider provider= editor.getDocumentProvider();
- IEditorInput input= editor.getEditorInput();
- if (provider != null && input != null)
- return provider.getDocument(input);
-
- }
- return null;
- }
-
- /**
- * Returns the selection on the editor or an invalid selection if none can be obtained. Returns
- * never null.
- *
- * @return the current selection, never null
- */
- private ITextSelection getSelection() {
- ISelectionProvider provider= getSelectionProvider();
- if (provider != null) {
- ISelection selection= provider.getSelection();
- if (selection instanceof ITextSelection)
- return (ITextSelection) selection;
- }
-
- // null object
- return TextSelection.emptySelection();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java
deleted file mode 100644
index cf271af..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/OpenActionUtil.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
-
-public class OpenActionUtil {
-
- private OpenActionUtil() {
- // no instance.
- }
-
- /**
- * Opens the editor on the given element and subsequently selects it.
- */
- public static void open(Object element) throws CModelException, PartInitException {
- open(element, true);
- }
-
- /**
- * Opens the editor on the given element and subsequently selects it.
- */
- public static void open(Object element, boolean activate) throws CModelException, PartInitException {
- IEditorPart part= EditorUtility.openInEditor(element, activate);
- if (element instanceof ICElement)
- EditorUtility.revealInEditor(part, (ICElement)element);
- }
-
- /**
- * Filters out source references from the given code resolve results.
- * A utility method that can be called by subclassers.
- */
- public static List filterResolveResults(ICElement[] codeResolveResults) {
- int nResults= codeResolveResults.length;
- List refs= new ArrayList(nResults);
- for (int i= 0; i < nResults; i++) {
- if (codeResolveResults[i] instanceof ISourceReference)
- refs.add((ISourceReference) codeResolveResults[i]);
- }
- return refs;
- }
-
- /**
- * Shows a dialog for resolving an ambiguous C element.
- * Utility method that can be called by subclasses.
- */
- public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message) {
- return selectCElement(elements, shell, title, message, 0, 0);
- }
-
- /**
- * Shows a dialog for resolving an ambiguous C element.
- * @see CElementLabels
- * @param elements an array of ambiguous elements.
- * @param shell parent shell for showing the dialog
- * @param title title of the dialog
- * @param message message to be shown in the dialog
- * @param textFlags text flags to change the label provider
- * @param imageFlags image flags to change the label provider
- * @return the selected element or null
- * @since 4.0
- */
- public static ICElement selectCElement(ICElement[] elements, Shell shell, String title, String message, long textFlags, int imageFlags) {
- int nResults= elements.length;
-
- if (nResults == 0)
- return null;
-
- if (nResults == 1)
- return elements[0];
-
- ILabelProvider labelProvider;
- if (textFlags == 0 && imageFlags == 0) {
- labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT | CElementLabelProvider.SHOW_QUALIFIED);
- }
- else {
- labelProvider= new CUILabelProvider(textFlags, imageFlags);
- }
-
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, labelProvider);
- dialog.setTitle(title);
- dialog.setMessage(message);
- dialog.setElements(elements);
-
- if (dialog.open() == Window.OK) {
- Object[] selection= dialog.getResult();
- if (selection != null && selection.length > 0) {
- nResults= selection.length;
- for (int i= 0; i < nResults; i++) {
- Object current= selection[i];
- if (current instanceof ICElement)
- return (ICElement) current;
- }
- }
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java
deleted file mode 100644
index a9300c6..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.ICProject;
-
-public class RebuildIndexAction implements IObjectActionDelegate {
-
- private ISelection fSelection;
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- }
-
- public void run(IAction action) {
- IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
- for (Iterator> i = cElements.iterator(); i.hasNext();) {
- Object elem = i.next();
- if (elem instanceof ICProject) {
- CCorePlugin.getIndexManager().reindex((ICProject) elem);
- }
- }
- }
-
- /**
- * @see IActionDelegate#selectionChanged(IAction, ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- fSelection= selection;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java
deleted file mode 100644
index 399c9a8..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RemoveBlockCommentAction.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Andrew Gvozdev - http://bugs.eclipse.org/236160
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.ui.text.ICPartitions;
-
-/**
- * Action that removes the enclosing comment marks from a C block comment.
- *
- * @since 3.0
- */
-public class RemoveBlockCommentAction extends BlockCommentAction {
-
- /**
- * Creates a new instance.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in ResourceAction constructor), or
- * null if none
- * @param editor the text editor
- */
- public RemoveBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- @Override
- protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadPartitioningException, BadLocationException {
- if ( !(docExtension instanceof IDocument) ) return;
-
- List edits= new LinkedList();
-
- int partitionStart = -1;
- int partitionEnd = selection.getOffset();
-
- do {
- ITypedRegion partition = docExtension.getPartition(ICPartitions.C_PARTITIONING, partitionEnd, false);
- if (partition.getOffset() <= partitionStart) {
- // If we did not advance break the loop
- break;
- }
- partitionStart = partition.getOffset();
- partitionEnd = partitionStart + partition.getLength();
- if (partition.getType() == ICPartitions.C_MULTI_LINE_COMMENT
- || partition.getType() == ICPartitions.C_MULTI_LINE_DOC_COMMENT) {
- uncommentPartition((IDocument)docExtension, factory, edits, partitionStart, partitionEnd);
- }
- } while (partitionEnd < selection.getOffset()+selection.getLength());
-
- executeEdits(edits);
- }
-
- private void uncommentPartition(IDocument doc, Edit.EditFactory factory,
- List edits, int partitionStart, int partitionEnd)
- throws BadLocationException {
-
- int startCommentTokenLength = getCommentStart().length();
- int endCommentTokenLength = getCommentEnd().length();
-
- // Remove whole line (with EOL) if it contains start or end comment tag
- // and nothing else
- if (partitionStart >= 0) {
- IRegion lineRegion = doc.getLineInformationOfOffset(partitionStart);
- String lineContent = doc.get(lineRegion.getOffset(), lineRegion.getLength());
- // start comment tag '/*'
- if (lineContent.equals(getCommentStart())) {
- String eol = doc.getLineDelimiter(doc.getLineOfOffset(partitionStart));
- if (eol!=null) {
- startCommentTokenLength = startCommentTokenLength+eol.length();
- }
- }
- }
-
- int commentContentEnd = partitionEnd - endCommentTokenLength;
- if (partitionEnd < doc.getLength()) {
- IRegion lineRegion = doc.getLineInformationOfOffset(partitionEnd);
- String lineContent = doc.get(lineRegion.getOffset(), lineRegion.getLength());
- // end comment tag '*/'
- if (lineContent.equals(getCommentEnd())) {
- String eol = doc.getLineDelimiter(doc.getLineOfOffset(partitionEnd));
- if (eol!=null) {
- endCommentTokenLength = endCommentTokenLength + eol.length();
- }
- }
- }
-
- edits.add(factory.createEdit(partitionStart, startCommentTokenLength, "")); //$NON-NLS-1$
- edits.add(factory.createEdit(commentContentEnd, endCommentTokenLength, "")); //$NON-NLS-1$
- }
-
- @Override
- protected boolean isValidSelection(ITextSelection selection) {
- return selection != null && !selection.isEmpty() && selection.getLength() > 0;
- }
-
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java
deleted file mode 100644
index 3e3652c..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectAllAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.actions.ActionMessages;
-import org.eclipse.jface.action.Action;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This action selects all entries currently showing in view.
- */
-public class SelectAllAction extends Action {
-
- private TableViewer fViewer;
-
- /**
- * Creates the action.
- */
- public SelectAllAction(TableViewer viewer) {
- super("selectAll"); //$NON-NLS-1$
- setText(ActionMessages.SelectAllAction_label);
- setToolTipText(ActionMessages.SelectAllAction_tooltip);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.SELECT_ALL_ACTION);
- Assert.isNotNull(viewer);
- fViewer= viewer;
- }
-
- /**
- * Selects all resources in the view.
- */
- @Override
- public void run() {
- fViewer.getTable().selectAll();
- // force viewer selection change
- fViewer.setSelection(fViewer.getSelection());
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
deleted file mode 100644
index 2e1d899..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SelectionConverter.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-
-public class SelectionConverter {
-
- protected static final ICElement[] EMPTY_RESULT= new ICElement[0];
-
- /**
- * Converts the selection provided by the given part into a structured selection.
- * The following conversion rules are used:
- *
- *
part instanceof CEditor: returns a structured selection
- * using code resolve to convert the editor's text selection.
- *
part instanceof IWorkbenchPart: returns the part's selection
- * if it is a structured selection.
- *
default: returns an empty structured selection.
- *
- */
- public static IStructuredSelection getStructuredSelection(IWorkbenchPart part) throws CModelException {
- if (part instanceof CEditor)
- return new StructuredSelection(codeResolve((CEditor)part));
- ISelectionProvider provider= part.getSite().getSelectionProvider();
- if (provider != null) {
- ISelection selection= provider.getSelection();
- if (selection instanceof IStructuredSelection)
- return (IStructuredSelection)selection;
- }
- return StructuredSelection.EMPTY;
- }
-
- /**
- * Converts objects of a structured selection to c elements if possible.
- * This is a convenience method, fully equivalent to
- * convertSelectionToCElements(s, false).
- * @param s The structured selection
- * @return The converted selection
- */
- public static IStructuredSelection convertSelectionToCElements(ISelection s) {
- return convertSelectionToCElements(s, false);
- }
-
- /**
- * Converts objects of a structured selection to c elements if possible.
- * @param s The structured selection
- * @param keepNonCElements Whether to keep objects in selection if they cannot be converted
- * @return The converted selection
- */
- public static IStructuredSelection convertSelectionToCElements(ISelection s,
- boolean keepNonCElements) {
- List converted = new ArrayList();
- if (s instanceof IStructuredSelection) {
- Object[] elements = ((IStructuredSelection) s).toArray();
- for (int i = 0; i < elements.length; i++) {
- Object e = elements[i];
- if (e instanceof ICElement) {
- converted.add(e);
- } else if (e instanceof IAdaptable) {
- ICElement c = (ICElement) ((IAdaptable) e).getAdapter(ICElement.class);
- if (c != null) {
- converted.add(c);
- } else if (keepNonCElements)
- converted.add(e);
- } else if (keepNonCElements)
- converted.add(e);
- }
- }
- return new StructuredSelection(converted.toArray());
- }
-
- public static IStructuredSelection convertSelectionToResources(ISelection s) {
- List converted = new ArrayList();
- if (s instanceof StructuredSelection) {
- Object[] elements = ((StructuredSelection) s).toArray();
- for (int i = 0; i < elements.length; i++) {
- Object e = elements[i];
- if (e instanceof IResource) {
- converted.add(e);
- } else if (e instanceof IAdaptable) {
- IResource r = (IResource) ((IAdaptable) e).getAdapter(IResource.class);
- if (r != null) {
- converted.add(r);
- }
- }
- }
- }
- return new StructuredSelection(converted.toArray());
- }
-
- public static boolean allResourcesAreOfType(IStructuredSelection selection, int resourceMask) {
- Iterator> resources = selection.iterator();
- while (resources.hasNext()) {
- Object next = resources.next();
- if (next instanceof IAdaptable) {
- IAdaptable element = (IAdaptable) next;
- IResource resource = (IResource) element.getAdapter(IResource.class);
-
- if (resource == null) {
- return false;
- }
- if (!resourceIsType(resource, resourceMask)) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Returns the selection adapted to IResource. Returns null if any of the
- * entries are not adaptable.
- *
- * @param selection
- * the selection
- * @param resourceMask
- * resource mask formed by bitwise OR of resource type constants
- * (defined on IResource)
- * @return IStructuredSelection or null if any of the entries are not
- * adaptable.
- * @see IResource#getType()
- */
- public static IStructuredSelection allResources(IStructuredSelection selection, int resourceMask) {
- Iterator> adaptables = selection.iterator();
- List result = new ArrayList();
- while (adaptables.hasNext()) {
- Object next = adaptables.next();
- if (next instanceof IAdaptable) {
- IResource resource = (IResource) ((IAdaptable) next).getAdapter(IResource.class);
- if (resource == null) {
- return null;
- } else if (resourceIsType(resource, resourceMask)) {
- result.add(resource);
- }
- } else {
- return null;
- }
- }
- return new StructuredSelection(result);
-
- }
-
- public static ICElement getElementAtOffset(ITextEditor editor) throws CModelException {
- return getElementAtOffset(getInput(editor), (ITextSelection) editor.getSelectionProvider().getSelection());
- }
-
- public static ICElement[] getElementsAtOffset(ITextEditor editor) throws CModelException {
- return getElementsAtOffset(getInput(editor), (ITextSelection) editor.getSelectionProvider().getSelection());
- }
-
- public static ICElement getElementAtOffset(ICElement input, ITextSelection selection) throws CModelException {
- if (input instanceof ITranslationUnit) {
- ITranslationUnit tunit = (ITranslationUnit) input;
- if (tunit.isWorkingCopy() && tunit.isOpen()) {
- synchronized (tunit) {
- if (tunit instanceof IWorkingCopy) {
- ((IWorkingCopy) tunit).reconcile();
- }
- }
- }
- ICElement ref = tunit.getElementAtOffset(selection.getOffset());
- if (ref == null)
- return input;
- return ref;
- }
- return null;
- }
-
- public static ICElement[] getElementsAtOffset(ICElement input, ITextSelection selection) throws CModelException {
- if (input instanceof ITranslationUnit) {
- ITranslationUnit tunit = (ITranslationUnit) input;
- if (tunit.isWorkingCopy() && tunit.isOpen()) {
- synchronized (tunit) {
- if (tunit instanceof IWorkingCopy) {
- ((IWorkingCopy) tunit).reconcile();
- }
- }
- }
- ICElement[] refs = tunit.getElementsAtOffset(selection.getOffset());
- if (refs == null)
- return new ICElement[] { input };
- return refs;
- }
- return null;
- }
-
- public static ICElement getInput(ITextEditor editor) {
- if (editor == null) return null;
- IEditorInput input = editor.getEditorInput();
- IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
- return manager.getWorkingCopy(input);
- }
-
- /**
- * Returns whether the type of the given resource is among the specified
- * resource types.
- *
- * @param resource
- * the resource
- * @param resourceMask
- * resource mask formed by bitwise OR of resource type constants
- * (defined on IResource)
- * @return true if the resources has a matching type, and
- * false otherwise
- * @see IResource#getType()
- */
- public static boolean resourceIsType(IResource resource, int resourceMask) {
- return (resource.getType() & resourceMask) != 0;
- }
-
- public static ICElement[] codeResolve(CEditor editor) throws CModelException {
- return codeResolve(getInput(editor), (ITextSelection)editor.getSelectionProvider().getSelection());
- }
-
- public static ICElement[] codeResolve(ICElement input, ITextSelection selection) throws CModelException {
- if (input instanceof ITranslationUnit) {
- ITranslationUnit tunit = (ITranslationUnit) input;
- if (tunit.isWorkingCopy() && tunit.isOpen()) {
- synchronized (tunit) {
- if (tunit instanceof IWorkingCopy) {
- ((IWorkingCopy) tunit).reconcile();
- }
- }
- }
- ICElement[] elems = tunit.getElementsAtOffset(selection.getOffset());
- if (elems != null) {
- for (int i = 0; i < elems.length; ++i) {
- ICElement elem = elems[i];
- if (elem instanceof ISourceReference) {
- String text = selection.getText();
- if (text.equals(elem.getElementName())) {
- return new ICElement[] { elem };
- }
- }
- }
- for (int i = 0; i < elems.length; ++i) {
- ICElement elem = elems[i];
- if (elem instanceof ISourceReference) {
- ISourceRange range = ((ISourceReference)elem).getSourceRange();
- if (range.getStartPos() == selection.getOffset()) {
- return new ICElement[] { elem };
- }
- }
- }
- }
- }
- return EMPTY_RESULT;
- }
-
- /**
- * 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
- * doesn't cover a Java element null is returned.
- */
- public static ICElement codeResolve(CEditor editor, Shell shell, String title, String message) throws CModelException {
- ICElement[] elements= codeResolve(editor);
- if (elements == null || elements.length == 0)
- return null;
- ICElement candidate= elements[0];
- if (elements.length > 1) {
- candidate= OpenActionUtil.selectCElement(elements, shell, title, message);
- }
- return candidate;
- }
-
-
- /**
- * Converts the text selection provided by the given editor into an array of
- * C elements. If the selection doesn't cover a C element and the selection's
- * length is greater than 0 the method returns the editor's input element.
- */
- public static ICElement[] codeResolveOrInput(CEditor editor) throws CModelException {
- ICElement input= getInput(editor);
- ITextSelection selection= (ITextSelection)editor.getSelectionProvider().getSelection();
- ICElement[] result= codeResolve(input, selection);
- if (result.length == 0) {
- result= new ICElement[] {input};
- }
- return result;
- }
-
- public static ICElement[] codeResolveOrInputHandled(CEditor editor, Shell shell, String title) {
- try {
- return codeResolveOrInput(editor);
- } catch(CModelException e) {
- ExceptionHandler.handle(e, shell, title, ActionMessages.SelectionConverter_codeResolve_failed);
- }
- return null;
- }
-
- public static boolean canOperateOn(CEditor editor) {
- if (editor == null)
- return false;
- return getInput(editor) != null;
-
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java
deleted file mode 100644
index a9628e4..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Tomasz Wesolowski 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:
- * Tomasz Wesolowski - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.model.ISourceRange;
-
-import org.eclipse.cdt.internal.core.model.ext.SourceRange;
-
-import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
-
-public class StructureSelectEnclosingAction extends StructureSelectionAction {
-
- public static final String PREFIX = "StructureSelectEnclosing."; //$NON-NLS-1$
-
- public StructureSelectEnclosingAction(ResourceBundle bundle, ITextEditor editor, SelectionHistory history) {
- super(bundle, PREFIX, editor, history);
- }
-
- @Override
- public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
-
- ISourceRange newSourceRange = expandToEnclosing(ast, current);
- if (newSourceRange != null) {
- history.remember(current);
- }
- return newSourceRange;
- }
-
- /**
- * Made public to serve as fallback for other expansions
- */
- public static ISourceRange expandToEnclosing(IASTTranslationUnit ast, SourceRange current) {
- final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
- IASTNode node = nodeSelector.findStrictlyEnclosingNode(current.getStartPos(), current.getLength());
- if (node == null)
- return null;
-
- final IASTFileLocation fileLocation = node.getFileLocation();
- return new SourceRange(fileLocation.getNodeOffset(), fileLocation.getNodeLength());
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java
deleted file mode 100644
index 8cc07e9..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectHistoryAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tomasz Wesolowski - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.model.ISourceRange;
-
-import org.eclipse.cdt.internal.core.model.ext.SourceRange;
-
-import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
-
-public class StructureSelectHistoryAction extends StructureSelectionAction {
-
- public static final String PREFIX = "StructureSelectHistory."; //$NON-NLS-1$
-
- public StructureSelectHistoryAction(ResourceBundle bundle, ITextEditor editor,
- SelectionHistory history) {
- super(bundle, PREFIX, editor, history);
- }
-
- @Override
- protected ISourceRange doExpand(IASTTranslationUnit ast, SourceRange currentSourceRange) {
- if (!history.isEmpty()) {
- return history.getLast();
- }
- return null;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java
deleted file mode 100644
index 6c97641..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Tomasz Wesolowski 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:
- * Tomasz Wesolowski - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.model.ISourceRange;
-
-import org.eclipse.cdt.internal.core.model.ext.SourceRange;
-
-import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
-
-public class StructureSelectNextAction extends StructureSelectionAction {
-
- public static final String PREFIX = "StructureSelectNext."; //$NON-NLS-1$
-
- public StructureSelectNextAction(ResourceBundle bundle, ITextEditor editor,
- SelectionHistory history) {
- super(bundle, PREFIX, editor, history);
- }
-
- @Override
- public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
-
- ISourceRange newSourceRange = expandToNext(ast, current);
- if (newSourceRange == null) {
- newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
- }
- if (newSourceRange != null) {
- history.remember(current);
- }
- return newSourceRange;
- }
-
- private ISourceRange expandToNext(IASTTranslationUnit ast, SourceRange current) {
-
- IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(),
- current.getLength());
- if (samePosition(enclosingNode, current)) {
- enclosingNode = enclosingNode.getParent();
- }
- if (enclosingNode == null) {
- return null;
- }
-
- // find the last child of enclosingNode containing selection end
-
- int selectionEnd = current.getStartPos()+current.getLength();
-
- int lastSelectedChildIndex = -1;
- IASTNode[] children = enclosingNode.getChildren();
- for (int i = 0; i < children.length; i++) {
- IASTNode node = children[i];
- if (nodeContains(node, selectionEnd)) {
- lastSelectedChildIndex = i;
- break;
- }
- }
-
- if (lastSelectedChildIndex != -1 && lastSelectedChildIndex+1 < children.length) {
- IASTNode nextNode = children[lastSelectedChildIndex+1];
- int endingOffset = nextNode.getFileLocation().getNodeOffset()+nextNode.getFileLocation().getNodeLength();
- return new SourceRange(current.getStartPos(),endingOffset-current.getStartPos());
- }
- return null;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java
deleted file mode 100644
index ecf7eac..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Tomasz Wesolowski 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:
- * Tomasz Wesolowski - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.model.ISourceRange;
-
-import org.eclipse.cdt.internal.core.model.ext.SourceRange;
-
-import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
-
-public class StructureSelectPreviousAction extends StructureSelectionAction {
-
- public static final String PREFIX = "StructureSelectPrevious."; //$NON-NLS-1$
-
- public StructureSelectPreviousAction(ResourceBundle bundle, ITextEditor editor,
- SelectionHistory history) {
- super(bundle, PREFIX, editor, history);
- }
-
- @Override
- public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
-
- ISourceRange newSourceRange = expandToPrevious(ast, current);
- if (newSourceRange == null) {
- newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
- }
- if (newSourceRange != null) {
- history.remember(current);
- }
- return newSourceRange;
- }
-
- private ISourceRange expandToPrevious(IASTTranslationUnit ast, SourceRange current) {
-
- IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(),
- current.getLength());
- if (samePosition(enclosingNode, current)) {
- enclosingNode = enclosingNode.getParent();
- }
- if (enclosingNode == null) {
- return null;
- }
-
- // find the first child of enclosingNode containing selection end
-
- int selectionStart = current.getStartPos();
-
- int firstSelectedChildIndex = -1;
- IASTNode[] children = enclosingNode.getChildren();
- for (int i = 0; i < children.length; i++) {
- IASTNode node = children[i];
- if (nodeContains(node, selectionStart)) {
- firstSelectedChildIndex = i;
- break;
- }
- }
-
- if (firstSelectedChildIndex != -1 && firstSelectedChildIndex-1 >= 0) {
- IASTNode prevNode = children[firstSelectedChildIndex-1];
- int endingOffset = current.getStartPos() + current.getLength();
- return new SourceRange(prevNode.getFileLocation().getNodeOffset(), endingOffset - prevNode.getFileLocation().getNodeOffset());
- }
- return null;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java
deleted file mode 100644
index 13f1aca..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectionAction.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Tomasz Wesolowski 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:
- * Tomasz Wesolowski - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.ISourceRange;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CDTUITools;
-import org.eclipse.cdt.ui.text.SharedASTJob;
-
-import org.eclipse.cdt.internal.core.model.ext.SourceRange;
-
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
-
-public abstract class StructureSelectionAction extends TextEditorAction {
-
- protected final SelectionHistory history;
-
- protected StructureSelectionAction(ResourceBundle bundle, String prefix, ITextEditor editor, SelectionHistory history) {
- super(bundle, prefix, editor);
- this.history = history;
- }
-
- private final class ExpandSelectionJob extends SharedASTJob {
- public ISourceRange newSourceRange;
- private SourceRange currentSourceRange;
-
- private ExpandSelectionJob(String name, ITranslationUnit tUnit, CEditor cEditor, SourceRange range) {
- super(name, tUnit);
- currentSourceRange = range;
- newSourceRange = null;
- }
-
- @Override
- public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException {
- newSourceRange = doExpand(ast,currentSourceRange);
- return Status.OK_STATUS;
- }
- }
-
- public static final String ENCLOSING = "StructureSelectEnclosing"; //$NON-NLS-1$
- public static final String NEXT = "StructureSelectNext"; //$NON-NLS-1$
- public static final String PREVIOUS = "StructureSelectPrevious"; //$NON-NLS-1$
- public static final String HISTORY = "StructureSelectHistory"; //$NON-NLS-1$
-
- @Override
- public void run() {
- IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- if (!(editorPart instanceof CEditor)) {
- return;
- }
- final CEditor cEditor = (CEditor) editorPart;
-
- ITranslationUnit tu = (ITranslationUnit) CDTUITools.getEditorInputCElement(cEditor.getEditorInput());
-
- ITextSelection selection;
- try {
- selection = (ITextSelection) cEditor.getSelectionProvider().getSelection();
- } catch (ClassCastException e) {
- return;
- }
-
- final int offset = selection.getOffset();
- final int length = selection.getLength();
-
- ExpandSelectionJob expandSelectionJob = new ExpandSelectionJob("expand selection", tu, cEditor, new SourceRange(offset, length)); //$NON-NLS-1$
-
- expandSelectionJob.schedule();
- try {
- expandSelectionJob.join();
- } catch (InterruptedException e) {
- return;
- }
-
- if (expandSelectionJob.newSourceRange != null) {
- history.ignoreSelectionChanges();
- cEditor.setSelection(expandSelectionJob.newSourceRange, true);
- history.listenToSelectionChanges();
- }
- }
-
- protected abstract ISourceRange doExpand(IASTTranslationUnit ast, SourceRange currentSourceRange);
-
- protected boolean nodeContains(IASTNode node, int position) {
- IASTFileLocation fl = node.getFileLocation();
- return position >= fl.getNodeOffset() && position <= fl.getNodeOffset() + fl.getNodeLength();
- }
-
- protected boolean samePosition(IASTNode node, SourceRange current) {
- IASTFileLocation fl = node.getFileLocation();
- return fl.getNodeOffset() == current.getStartPos() && fl.getNodeLength() == current.getLength();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java
deleted file mode 100644
index 087b44e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Axel Mueller - [289339] ported from JDT to CDT
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-
-public class SurroundWithActionGroup extends ActionGroup {
-
- private CEditor fEditor;
- private final String fGroup;
-
- public SurroundWithActionGroup(CEditor editor, String group) {
- fEditor= editor;
- fGroup= group;
- }
-
- /**
- * The Menu to show when right click on the editor
- * {@inheritDoc}
- */
- @Override
- public void fillContextMenu(IMenuManager menu) {
- ISelectionProvider selectionProvider= fEditor.getSelectionProvider();
- if (selectionProvider == null)
- return;
-
- ISelection selection= selectionProvider.getSelection();
- if (!(selection instanceof ITextSelection))
- return;
-
- ITextSelection textSelection= (ITextSelection)selection;
- if (textSelection.getLength() == 0)
- return;
-
- String menuText= ActionMessages.SurroundWithTemplateMenuAction_SubMenuName;
-
- MenuManager subMenu = new MenuManager(menuText, SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
- subMenu.setActionDefinitionId(SurroundWithTemplateMenuAction.SURROUND_WITH_QUICK_MENU_ACTION_ID);
- menu.appendToGroup(fGroup, subMenu);
- subMenu.add(new Action() {});
- subMenu.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- manager.removeAll();
- SurroundWithTemplateMenuAction.fillMenu(manager, fEditor);
- }
- });
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
deleted file mode 100644
index 470af5a..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Axel Mueller - [289339] ported from JDT to CDT
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IEditingSupport;
-import org.eclipse.jface.text.IEditingSupportRegistry;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
-import org.eclipse.ui.actions.QuickMenuCreator;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationContext;
-import org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer;
-
-public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownDelegate2 {
-
- public static final String SURROUND_WITH_QUICK_MENU_ACTION_ID= "org.eclipse.cdt.ui.edit.text.c.surround.with.quickMenu"; //$NON-NLS-1$
-
- private static final String C_TEMPLATE_PREFERENCE_PAGE_ID= "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
-
- private static final String TEMPLATE_GROUP= "templateGroup"; //$NON-NLS-1$
-
- private static final String CONFIG_GROUP= "configGroup"; //$NON-NLS-1$
-
- private static class ConfigureTemplatesAction extends Action {
-
- public ConfigureTemplatesAction() {
- super(ActionMessages.SurroundWithTemplateMenuAction_ConfigureTemplatesActionName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- PreferencesUtil.createPreferenceDialogOn(getShell(), C_TEMPLATE_PREFERENCE_PAGE_ID, new String[] {C_TEMPLATE_PREFERENCE_PAGE_ID}, null).open();
- }
-
- private Shell getShell() {
- return CUIPlugin.getActiveWorkbenchShell();
- }
- }
-
- private static Action NONE_APPLICABLE_ACTION= new Action(ActionMessages.SurroundWithTemplateMenuAction_NoneApplicable) {
- @Override
- public void run() {
- //Do nothing
- }
- @Override
- public boolean isEnabled() {
- return false;
- }
- };
-
- private Menu fMenu;
- private IPartService fPartService;
- private IPartListener fPartListener= new IPartListener() {
-
- public void partActivated(IWorkbenchPart part) {
- }
-
- public void partBroughtToTop(IWorkbenchPart part) {
- }
-
- public void partClosed(IWorkbenchPart part) {
- }
-
- public void partDeactivated(IWorkbenchPart part) {
- disposeMenuItems();
- }
-
- public void partOpened(IWorkbenchPart part) {
- }
- };
-
- protected void disposeMenuItems() {
- if (fMenu == null || fMenu.isDisposed()) {
- return;
- }
- MenuItem[] items = fMenu.getItems();
- for (int i= 0; i < items.length; i++) {
- MenuItem menuItem= items[i];
- if (!menuItem.isDisposed()) {
- menuItem.dispose();
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public Menu getMenu(Menu parent) {
- setMenu(new Menu(parent));
- fillMenu(fMenu);
- initMenu();
- return fMenu;
- }
-
- /**
- * {@inheritDoc}
- */
- public Menu getMenu(Control parent) {
- setMenu(new Menu(parent));
- fillMenu(fMenu);
- initMenu();
- return fMenu;
- }
-
- public static void fillMenu(IMenuManager menu, CEditor editor) {
- IAction[] actions= getTemplateActions(editor);
- if (actions == null || actions.length == 0) {
- menu.add(NONE_APPLICABLE_ACTION);
- } else {
- menu.add(new Separator(TEMPLATE_GROUP));
- for (int i= 0; i < actions.length; i++)
- menu.add(actions[i]);
- }
-
- menu.add(new Separator(CONFIG_GROUP));
- menu.add(new ConfigureTemplatesAction());
- }
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- if (fPartService != null) {
- fPartService.removePartListener(fPartListener);
- fPartService= null;
- }
- setMenu(null);
- }
-
- /**
- * {@inheritDoc}
- */
- public void init(IWorkbenchWindow window) {
- if (fPartService != null) {
- fPartService.removePartListener(fPartListener);
- fPartService= null;
- }
-
- if (window != null) {
- IPartService partService= window.getPartService();
- if (partService != null) {
- fPartService= partService;
- partService.addPartListener(fPartListener);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void run(IAction action) {
- IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
- if (!(activePart instanceof CEditor))
- return;
-
- final CEditor editor= (CEditor) activePart;
-
- new QuickMenuCreator() {
- @Override
- protected void fillMenu(IMenuManager menu) {
- SurroundWithTemplateMenuAction.fillMenu(menu, editor);
- }
- }.createMenu();
- }
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(IAction action, ISelection selection) {
- // Default do nothing
- }
-
- /**
- * The menu to show in the workbench menu
- * @param menu the menu to fill entries into it
- */
- protected void fillMenu(Menu menu) {
-
- IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart();
- if (!(activePart instanceof CEditor)) {
- ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
- item.fill(menu, -1);
- return;
- }
-
- CEditor editor= (CEditor)activePart;
- IAction[] actions= getTemplateActions(editor);
-
- if ( actions == null || actions.length <= 0) {
- ActionContributionItem item= new ActionContributionItem(NONE_APPLICABLE_ACTION);
- item.fill(menu, -1);
- } else {
- for (int i= 0; i < actions.length; i++) {
- ActionContributionItem item= new ActionContributionItem(actions[i]);
- item.fill(menu, -1);
- }
- }
-
- Separator configGroup= new Separator(CONFIG_GROUP);
- configGroup.fill(menu, -1);
-
- ActionContributionItem configAction= new ActionContributionItem(new ConfigureTemplatesAction());
- configAction.fill(menu, -1);
-
- }
-
- protected void initMenu() {
- fMenu.addMenuListener(new MenuAdapter() {
- @Override
- public void menuShown(MenuEvent e) {
- Menu m = (Menu)e.widget;
- MenuItem[] items = m.getItems();
- for (int i=0; i < items.length; i++) {
- items[i].dispose();
- }
- fillMenu(m);
- }
- });
- }
-
- private void setMenu(Menu menu) {
- if (fMenu != null) {
- fMenu.dispose();
- }
- fMenu = menu;
- }
-
- private static IAction[] getTemplateActions(CEditor editor) {
- ITextSelection textSelection= getTextSelection(editor);
- if (textSelection == null || textSelection.getLength() == 0)
- return null;
-
- ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
- if (tu == null)
- return null;
-
- TemplateCompletionProposalComputer templateComputer = new TemplateCompletionProposalComputer();
- CContentAssistInvocationContext context = new CContentAssistInvocationContext( editor.getViewer(), textSelection.getOffset(), editor, true, false );
-
- List proposals= templateComputer.computeCompletionProposals(context, null);
- if (proposals == null || proposals.isEmpty())
- return null;
-
- return getActionsFromProposals(proposals, context.getInvocationOffset(), editor.getViewer());
- }
-
- private static ITextSelection getTextSelection(CEditor editor) {
- ISelectionProvider selectionProvider= editor.getSelectionProvider();
- if (selectionProvider == null)
- return null;
-
- ISelection selection= selectionProvider.getSelection();
- if (!(selection instanceof ITextSelection))
- return null;
-
- return (ITextSelection)selection;
- }
-
- private static IAction[] getActionsFromProposals(List proposals, final int offset, final ITextViewer viewer) {
- List result= new ArrayList();
- int j = 1;
- for (Iterator it= proposals.iterator(); it.hasNext();) {
- final ICompletionProposal proposal= it.next();
-
- StringBuffer actionName= new StringBuffer();
- if (j < 10) {
- actionName.append('&').append(j).append(' ');
- }
- actionName.append(proposal.getDisplayString());
- Action action= new Action(actionName.toString()) {
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- applyProposal(proposal, viewer, (char)0, 0, offset);
- }
- };
-
- result.add(action);
- j++;
- }
- if (result.size() == 0)
- return null;
-
- return result.toArray(new IAction[result.size()]);
- }
-
- private static void applyProposal(ICompletionProposal proposal, ITextViewer viewer, char trigger, int stateMask, final int offset) {
- Assert.isTrue(proposal instanceof ICompletionProposalExtension2);
-
- IRewriteTarget target= null;
- IEditingSupportRegistry registry= null;
- IEditingSupport helper= new IEditingSupport() {
-
- public boolean isOriginator(DocumentEvent event, IRegion focus) {
- return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset;
- }
-
- public boolean ownsFocusShell() {
- return false;
- }
- };
-
- try {
- IDocument document= viewer.getDocument();
-
- if (viewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) viewer;
- target= extension.getRewriteTarget();
- }
-
- if (target != null)
- target.beginCompoundChange();
-
- if (viewer instanceof IEditingSupportRegistry) {
- registry= (IEditingSupportRegistry) viewer;
- registry.register(helper);
- }
-
- ((ICompletionProposalExtension2)proposal).apply(viewer, trigger, stateMask, offset);
-
- Point selection= proposal.getSelection(document);
- if (selection != null) {
- viewer.setSelectedRange(selection.x, selection.y);
- viewer.revealRange(selection.x, selection.y);
- }
- } finally {
- if (target != null)
- target.endCompoundChange();
-
- if (registry != null)
- registry.unregister(helper);
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java
deleted file mode 100644
index d8fbca4..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/UpdateIndexWithModifiedFilesAction.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import org.eclipse.cdt.core.index.IIndexManager;
-
-public class UpdateIndexWithModifiedFilesAction extends AbstractUpdateIndexAction {
-
- @Override
- protected int getUpdateOptions() {
- return IIndexManager.UPDATE_CHECK_TIMESTAMPS | IIndexManager.UPDATE_CHECK_CONFIGURATION |
- IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT | IIndexManager.UPDATE_CHECK_CONTENTS_HASH;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
deleted file mode 100644
index c7ac589..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.internal.ui.CUIStatus;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.IThreadListener;
-
-/**
- * An IRunnableWithProgress that adapts and IWorkspaceRunnable
- * so that is can be executed inside IRunnableContext. OperationCanceledException
- * thrown by the adapted runnable are caught and re-thrown as a InterruptedException.
- */
-public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadListener {
- private IWorkspaceRunnable fWorkspaceRunnable;
- private ISchedulingRule fRule;
- private boolean fTransfer;
-
- /**
- * Runs a workspace runnable with the workspace lock.
- */
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) {
- this(runnable, ResourcesPlugin.getWorkspace().getRoot());
- }
-
- /**
- * Runs a workspace runnable with the given lock or null to run with no lock at all.
- */
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
- }
-
- /**
- * Runs a workspace runnable with the given lock or null to run with no lock at
- * all.
- *
- * @param runnable the runnable
- * @param rule the scheduling rule, or null
- * @param transfer true iff the rule is to be transfered to the modal context
- * thread
- */
- public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable, ISchedulingRule rule, boolean transfer) {
- fWorkspaceRunnable= runnable;
- fRule= rule;
- fTransfer= transfer;
- }
-
- public ISchedulingRule getSchedulingRule() {
- return fRule;
- }
-
- public void threadChange(Thread thread) {
- if (fTransfer)
- Job.getJobManager().transferRule(fRule, thread);
- }
-
- /*
- * @see IRunnableWithProgress#run(IProgressMonitor)
- */
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- CoreModel.run(fWorkspaceRunnable, fRule, monitor);
- } catch (OperationCanceledException e) {
- throw new InterruptedException(e.getMessage());
- } catch (CoreException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- public void runAsUserJob(String name, final Object jobFamiliy) {
- Job buildJob = new Job(name){
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- WorkbenchRunnableAdapter.this.run(monitor);
- } catch (InvocationTargetException e) {
- Throwable cause= e.getCause();
- if (cause instanceof CoreException) {
- return ((CoreException) cause).getStatus();
- }
- return CUIStatus.createError(IStatus.ERROR, cause);
- } catch (InterruptedException e) {
- return Status.CANCEL_STATUS;
- } finally {
- monitor.done();
- }
- return Status.OK_STATUS;
- }
- @Override
- public boolean belongsTo(Object family) {
- return jobFamiliy == family;
- }
- };
- buildJob.setRule(fRule);
- buildJob.setUser(true);
- buildJob.schedule();
-
- // TODO: should block until user pressed 'to background'
- }
-}
-
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java
deleted file mode 100644
index 6f1a856..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/ElementSelectionDialog.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.opentype;
-
-import java.util.Arrays;
-import java.util.HashSet;
-
-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.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-
-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.IBinding;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexBinding;
-import org.eclipse.cdt.core.index.IIndexMacro;
-import org.eclipse.cdt.core.index.IndexFilter;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
-
-import org.eclipse.cdt.internal.core.browser.IndexModelUtil;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
-/**
- * A dialog to select an element from a filterable list of elements.
- *
- * @since 4.0
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class ElementSelectionDialog extends TypeSelectionDialog {
- /**
- * Job to update the element list in the background.
- */
- private class UpdateElementsJob extends Job {
- /**
- * The last used prefix to query the index. null means
- * the query result should be empty.
- */
- private volatile char[] fCurrentPrefix = null;
-
- public UpdateElementsJob(String name) {
- super(name);
- setSystem(true);
- setUser(false);
- setPriority(Job.LONG);
- }
-
- public char[] getCurrentPrefix() {
- return fCurrentPrefix;
- }
- public void scheduleQuery(char[] prefix) {
- fCurrentPrefix= prefix;
- int delay = fCurrentPrefix == null ? 0 : (fCurrentPrefix.length < 5 ? 400 : 200);
- schedule(delay);
- }
-
- @Override
- public IStatus run(final IProgressMonitor monitor) {
- monitor.beginTask(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_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);
- updateOkState();
- }
- }};
- shell.getDisplay().asyncExec(update);
- monitor.done();
- return Status.OK_STATUS;
- }
- }
- 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;
- }
-
- @Override
- 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);
- }
- }
-
- @Override
- 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(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_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 UpdateElementsJob fUpdateJob;
- private boolean fAllowEmptyPrefix= true;
- private boolean fAllowEmptyString= true;
- private ProgressMonitorPart fProgressMonitorPart;
-
- private String fHelpContextId;
-
- /**
- * Constructs an instance of OpenTypeDialog.
- * @param parent the parent shell.
- */
- public ElementSelectionDialog(Shell parent) {
- super(parent);
- setHelpContextId(ICHelpContextIds.OPEN_ELEMENT_DIALOG);
- setMatchEmptyString(false);
- fUpdateJob= new UpdateElementsJob(OpenTypeMessages.ElementSelectionDialog_UpdateElementsJob_name);
- fUpdateJob.setRule(SINGLE_INSTANCE_RULE);
- }
-
- /*
- * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#create()
- */
- @Override
- public void create() {
- super.create();
- // trigger initial query
- scheduleUpdate(getFilter());
- }
-
- /*
- * @see org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog#close()
- */
- @Override
- public boolean close() {
- fUpdateJob.cancel();
- return super.close();
- }
-
- /**
- * Configure the help context id for this dialog.
- *
- * @param helpContextId
- */
- public void setHelpContextId(String helpContextId) {
- fHelpContextId= helpContextId;
- setHelpAvailable(fHelpContextId != null);
- }
-
- /*
- * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#setMatchEmptyString(boolean)
- */
- @Override
- public void setMatchEmptyString(boolean matchEmptyString) {
- super.setMatchEmptyString(matchEmptyString);
- fAllowEmptyString= matchEmptyString;
- if (matchEmptyString) {
- setAllowEmptyPrefix(true);
- }
- }
-
- /**
- * 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()
- */
- @Override
- protected boolean showLowLevelFilter() {
- // the low-level filter is useless for us
- return false;
- }
-
- /*
- * @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public Control createDialogArea(Composite parent) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, fHelpContextId);
- return super.createDialogArea(parent);
- }
-
- /*
- * @see org.eclipse.ui.dialogs.TwoPaneElementSelector#createLowerList(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Table createLowerList(Composite parent) {
- Table table= super.createLowerList(parent);
- createProgressMonitorPart(parent);
- return table;
- }
-
- /**
- * 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);
-
- Label separator= new Label(parent.getParent(), SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- 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;
- }
- HashSet types = new HashSet();
- if (prefix != null) {
- final IndexFilter filter= new IndexFilter() {
- @Override
- public boolean acceptBinding(IBinding binding) throws CoreException {
- if (isVisibleType(IndexModelUtil.getElementType(binding))) {
- return IndexFilter.ALL_DECLARED.acceptBinding(binding);
- }
- return false;
- }
- };
- try {
- IIndex index = CCorePlugin.getIndexManager().getIndex(CoreModel.getDefault().getCModel().getCProjects());
- index.acquireReadLock();
- try {
- IIndexBinding[] bindings= index.findBindingsForPrefix(prefix, false, filter, monitor);
- for (int i= 0; i < bindings.length; i++) {
- if (i % 0x1000 == 0 && monitor.isCanceled()) {
- return null;
- }
- final IndexTypeInfo typeinfo = IndexTypeInfo.create(index, bindings[i]);
- types.add(typeinfo);
- }
-
- if (isVisibleType(ICElement.C_MACRO)) {
- IIndexMacro[] macros= index.findMacrosForPrefix(prefix, IndexFilter.ALL_DECLARED, monitor);
- for (int i= 0; i < macros.length; i++) {
- if (i % 0x1000 == 0 && monitor.isCanceled()) {
- return null;
- }
- final IndexTypeInfo typeinfo = IndexTypeInfo.create(index, macros[i]);
- types.add(typeinfo);
- }
- }
- } finally {
- index.releaseReadLock();
- }
- } catch (CoreException e) {
- CUIPlugin.log(e);
- } catch (InterruptedException e) {
- CUIPlugin.log(e);
- }
- }
- return types.toArray(new ITypeInfo[types.size()]);
- }
-
- @Override
- protected final void setListElements(Object[] elements) {
- super.setListElements(elements);
- }
-
- /**
- * @deprecated Unsupported
- */
- @Deprecated
- @Override
- public void setElements(Object[] elements) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void handleEmptyList() {
- updateOkState();
- }
-
- @Override
- 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);
- final char[] currentPrefix= fUpdateJob.getCurrentPrefix();
- final boolean equivalentPrefix= isEquivalentPrefix(currentPrefix, newPrefix);
- boolean emptyQuery= newPrefix.length == 0 && !fAllowEmptyPrefix || filterText.length() == 0 && !fAllowEmptyString;
- final int jobState = fUpdateJob.getState();
- boolean needQuery= !equivalentPrefix || (currentPrefix.length < newPrefix.length && currentPrefix.length < 5 && jobState == Job.RUNNING);
- if (emptyQuery) {
- newPrefix= null;
- needQuery= needQuery || currentPrefix != null;
- }
- if (needQuery || jobState == Job.WAITING || jobState == Job.SLEEPING) {
- fUpdateJob.cancel();
- fUpdateJob.scheduleQuery(newPrefix);
- }
- }
-
- private char[] toPrefix(String userFilter) {
- QualifiedTypeName qualifiedName= new QualifiedTypeName(userFilter);
- if (qualifiedName.segmentCount() > 1) {
- userFilter= qualifiedName.lastSegment();
- }
- if (userFilter.endsWith("<")) { //$NON-NLS-1$
- userFilter= userFilter.substring(0, userFilter.length() - 1);
- }
- int asterisk= userFilter.indexOf("*"); //$NON-NLS-1$
- int questionMark= userFilter.indexOf("?"); //$NON-NLS-1$
- int prefixEnd = asterisk < 0 ? questionMark :
- questionMark < 0 ? asterisk : Math.min(asterisk, questionMark);
- return (prefixEnd == -1 ? userFilter : userFilter.substring(0, prefixEnd)).toCharArray();
- }
-
- private boolean isEquivalentPrefix(char[] currentPrefix, char[] newPrefix) {
- if (currentPrefix == null || 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));
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java
deleted file mode 100644
index 806aee2..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Andrew Ferguson (Symbian)
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.opentype;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-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.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-
-/**
- * @noextend This class is not intended to be subclassed by clients.
- */
-public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
-
- private IWorkbenchWindow fWorkbenchWindow;
-
- public OpenTypeAction() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
- configureDialog(dialog);
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
- if (info == null)
- return;
-
- ITypeReference location = info.getResolvedReference();
- if (location == null) {
- // could not resolve location
- String title = OpenTypeMessages.OpenTypeAction_errorTitle;
- String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorTypeNotFound, info.getQualifiedTypeName().toString());
- MessageDialog.openError(getShell(), title, message);
- } else if (!openTypeInEditor(location)) {
- // error opening editor
- String title = OpenTypeMessages.OpenTypeAction_errorTitle;
- String message = NLS.bind(OpenTypeMessages.OpenTypeAction_errorOpenEditor, location.getPath().toString());
- MessageDialog.openError(getShell(), title, message);
- }
- }
-
- private void configureDialog(ElementSelectionDialog dialog) {
- dialog.setTitle(OpenTypeMessages.OpenTypeDialog_title);
- dialog.setMessage(OpenTypeMessages.OpenTypeDialog_message);
- dialog.setDialogSettings(getClass().getName());
- if (fWorkbenchWindow != null) {
- IWorkbenchPage page= fWorkbenchWindow.getActivePage();
- if (page != null) {
- IWorkbenchPart part= page.getActivePart();
- if (part instanceof ITextEditor) {
- ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
- if (sel instanceof ITextSelection) {
- String txt= ((ITextSelection) sel).getText();
- if (txt.length() > 0 && txt.length() < 80) {
- dialog.setFilter(txt, true);
- }
- }
- }
- }
- }
- }
-
- protected Shell getShell() {
- return fWorkbenchWindow.getShell();
- }
-
- /**
- * Opens an editor and displays the selected type.
- *
- * @param info Type to display.
- * @return true if succesfully displayed.
- */
- private boolean openTypeInEditor(ITypeReference location) {
- ICElement[] cElements= location.getCElements();
- try {
- if (cElements != null && cElements.length > 0) {
- IEditorPart editor= EditorUtility.openInEditor(cElements[0]);
- EditorUtility.revealInEditor(editor, cElements[0]);
- return true;
- }
- ITranslationUnit unit = location.getTranslationUnit();
- IEditorPart editorPart = null;
-
- if (unit != null)
- editorPart = EditorUtility.openInEditor(unit);
- if (editorPart == null) {
- // open as external file
- editorPart = EditorUtility.openInEditor(location.getLocation(), null);
- }
-
- // highlight the type in the editor
- if (editorPart != null && editorPart instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) editorPart;
- if( location.isLineNumber() )
- {
- IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- try
- {
- int startOffset = document.getLineOffset(location.getOffset()-1);
- int length=document.getLineLength(location.getOffset()-1);
- editor.selectAndReveal(startOffset, length);
- return true;
- }
- catch( BadLocationException ble )
- {
- return false;
- }
- }
- editor.selectAndReveal(location.getOffset(), location.getLength());
- return true;
- }
- } catch (CModelException ex) {
- ex.printStackTrace();
- return false;
- } catch (PartInitException ex) {
- ex.printStackTrace();
- return false;
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- fWorkbenchWindow= null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- fWorkbenchWindow= window;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeDialog.java
deleted file mode 100644
index 63cb95a..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeDialog.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * 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 org.eclipse.swt.widgets.Shell;
-
-
-/**
- * A dialog to select a type from a list of types.
- *
- * @deprecated Use {@link ElementSelectionDialog} instead.
- * @noextend This class is not intended to be subclassed by clients.
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-@Deprecated
-public class OpenTypeDialog extends ElementSelectionDialog {
-
- /**
- * Constructs an instance of OpenTypeDialog.
- * @param parent the parent shell.
- */
- public OpenTypeDialog(Shell parent) {
- super(parent);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.java
deleted file mode 100644
index 5241f2a..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.opentype;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class OpenTypeMessages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages";//$NON-NLS-1$
-
- private OpenTypeMessages() {
- // Do not instantiate
- }
-
- public static String OpenTypeAction_errorTitle;
- public static String OpenTypeAction_errorOpenEditor;
- public static String OpenTypeAction_errorTypeNotFound;
- public static String OpenTypeDialog_title;
- public static String OpenTypeDialog_message;
- public static String ElementSelectionDialog_UpdateElementsJob_name;
- public static String ElementSelectionDialog_UpdateElementsJob_inProgress;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, OpenTypeMessages.class);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.properties
deleted file mode 100644
index 06a7ff1..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeMessages.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2008 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
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# QNX Software Systems - Initial API and implementation
-# Anton Leherbauer (Wind River Systems)
-###############################################################################
-
-OpenTypeAction_errorTitle=Open Element
-OpenTypeAction_errorOpenEditor=Error opening editor for file \"{0}\"
-OpenTypeAction_errorTypeNotFound=Could not locate definition of element \"{0}\"
-
-OpenTypeDialog_title=Open Element
-OpenTypeDialog_message=&Choose an element (? = any character, * = any string):
-
-ElementSelectionDialog_UpdateElementsJob_name=Updating element list
-ElementSelectionDialog_UpdateElementsJob_inProgress=Updating element list...
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java
deleted file mode 100644
index 5c1f898..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/BuildPreferencePage.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2011 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- * Anton Leherbauer (Wind River Systems)
- * Sergey Prigogin (Google)
- * James Blackburn (Broadcom Corp.)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.build;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-
-import org.eclipse.cdt.core.resources.ACBuilder;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
-
-/**
- * The page for top-level build preferences
- */
-public class BuildPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
- private static final int GROUP_VINDENT = 5;
- private static final int GROUP_HINDENT = 20;
- private Button buildActive, buildAll, buildOnlyOnRefChange;
-
- public BuildPreferencePage() {
- super();
- setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
- setDescription(PreferencesMessages.CBuildPreferencePage_description);
- }
-
- @Override
- public void createControl(Composite parent) {
- super.createControl(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.C_PREF_PAGE);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite container= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= 0;
- layout.verticalSpacing= convertVerticalDLUsToPixels(10);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- container.setLayout(layout);
-
- // Build either default configuration or all.
- Group gr = addGroup(container, PreferencesMessages.CPluginPreferencePage_build_scope);
- Label l1 = new Label(gr, SWT.NONE);
- l1.setText(PreferencesMessages.CPluginPreferencePage_1);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.verticalIndent = GROUP_VINDENT;
- l1.setLayoutData(gd);
-
- boolean needAllConfigBuild = ACBuilder.needAllConfigBuild();
-
- buildActive = new Button(gr, SWT.RADIO);
- buildActive.setText(PreferencesMessages.CPluginPreferencePage_2);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.verticalIndent = GROUP_VINDENT;
- gd.horizontalIndent = GROUP_HINDENT;
- buildActive.setLayoutData(gd);
- buildActive.setSelection(!needAllConfigBuild);
-
- buildAll = new Button(gr, SWT.RADIO);
- buildAll.setText(PreferencesMessages.CPluginPreferencePage_3);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalIndent = GROUP_HINDENT;
- buildAll.setLayoutData(gd);
- buildAll.setSelection(needAllConfigBuild);
-
- addNote(gr, PreferencesMessages.CPluginPreferencePage_4);
-
- // Building project dependencies.
- Group gr2 = addGroup(container, PreferencesMessages.CPluginPreferencePage_building_configurations);
- buildOnlyOnRefChange = new Button(gr2, SWT.CHECK);
- buildOnlyOnRefChange.setText(PreferencesMessages.CPluginPreferencePage_7);
- GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);
- gd2.verticalIndent = GROUP_VINDENT;
- buildOnlyOnRefChange.setLayoutData(gd2);
- buildOnlyOnRefChange.setSelection(ACBuilder.buildConfigResourceChanges());
-
- Dialog.applyDialogFont(container);
- return container;
- }
-
- private void addNote(Group parent, String noteMessage) {
- Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), parent,
- PreferencesMessages.CPluginPreferencePage_note, noteMessage);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.verticalIndent = GROUP_VINDENT;
- noteControl.setLayoutData(gd);
- }
-
- @Override
- protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
- Composite messageComposite = super.createNoteComposite(font, composite, title, message);
- Control[] children = messageComposite.getChildren();
- if (children.length == 2 && (children[1] instanceof Label)) {
- // this is temporary fix for problem that 3 line note does not displayed properly within the group
- Label messageLabel = (Label) children[1];
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint=500;
- messageLabel.setLayoutData(gd);
- }
- return messageComposite;
- }
-
- private Group addGroup(Composite parent, String label) {
- return addGroup(parent, label, 1);
- }
-
- private Group addGroup(Composite parent, String label, int numColumns) {
- Group group = new Group(parent, SWT.NONE);
- group.setText(label);
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- group.setLayout(new GridLayout(numColumns, false));
- return group;
- }
-
- /**
- * @see IWorkbenchPreferencePage#init
- */
- public void init(IWorkbench workbench) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- @Override
- public boolean performOk() {
- if (!super.performOk())
- return false;
- // tell the Core Plugin about this preference
- ACBuilder.setAllConfigBuild(buildAll.getSelection());
- ACBuilder.setBuildConfigResourceChanges(buildOnlyOnRefChange.getSelection());
- return true;
- }
-
- @Override
- protected void performDefaults() {
- ACBuilder.setAllConfigBuild(false);
- ACBuilder.setBuildConfigResourceChanges(false);
- buildActive.setSelection(true);
- buildAll.setSelection(false);
- buildOnlyOnRefChange.setSelection(false);
- super.performDefaults();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java
deleted file mode 100644
index 025f2dc..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsole.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Red Hat Inc. - Multiple build console support
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- * Alex Collins (Broadcom Corp.) - Global build console
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.net.URL;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.ui.console.AbstractConsole;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleView;
-import org.eclipse.ui.part.IPageBookViewPage;
-
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-
-/**
- * CDT Build console.
- *
- */
-public class BuildConsole extends AbstractConsole {
-
- /**
- * Menu group identifier for the console view context menu and toolbar, for actions pertaining to
- * error navigation (value "errorGroup").
- */
- public static final String ERROR_GROUP = "errorGroup"; //$NON-NLS-1$
-
- /**
- * Property constant indicating the color of a stream has changed.
- */
- public static final String P_STREAM_COLOR = CUIPlugin.PLUGIN_ID + ".CONSOLE_P_STREAM_COLOR"; //$NON-NLS-1$
-
- /** The page containing this build console */
- private BuildConsolePage fBuildConsolePage;
- /** The page for the console currently being displayed by the UI */
- private static BuildConsolePage fCurrentBuildConsolePage;
-
- private IBuildConsoleManager fConsoleManager;
- private String fConsoleName;
- private String fConsoleId;
- private Color fBackground;
-
- /**
- * Constructor.
- *
- * @param manager - build console manager.
- * @param name - name of console to appear in the list of consoles in context menu
- * in the Console view.
- * @param contextId - context menu id in the Console view.
- */
- public BuildConsole(IBuildConsoleManager manager, String name, String contextId) {
- this(manager, name, contextId, null);
- }
-
- /**
- * Constructor.
- *
- * @param manager - build console manager.
- * @param name - name of console to appear in the list of consoles in context menu
- * in the Console view.
- * @param contextId - context menu id in the Console view.
- * @param iconUrl - a {@link URL} of the icon for the context menu of the Console
- * view. The url is expected to point to an image in eclipse OSGi bundle.
- * {@code iconUrl} can be null, in that case the default image is used.
- */
- public BuildConsole(IBuildConsoleManager manager, String name, String contextId, URL iconUrl) {
- super(name, CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_VIEW_BUILD_CONSOLE));
- if (iconUrl!=null) {
- CDTSharedImages.register(iconUrl);
- this.setImageDescriptor(CDTSharedImages.getImageDescriptor(iconUrl.toString()));
- }
- fConsoleManager = manager;
- fConsoleName = name;
- fConsoleId = contextId;
- }
-
- public IPageBookViewPage createPage(IConsoleView view) {
- fBuildConsolePage = new BuildConsolePage(view, this, fConsoleId);
- fCurrentBuildConsolePage = fBuildConsolePage;
- return fBuildConsolePage;
- }
-
- BuildConsolePage getPage() {
- return fBuildConsolePage;
- }
-
- static BuildConsolePage getCurrentPage() {
- return fCurrentBuildConsolePage;
- }
-
- static void setCurrentPage(BuildConsolePage page) {
- fCurrentBuildConsolePage = page;
- }
-
- public void setTitle(IProject project) {
- String title = fConsoleName;
- if (project != null) {
- title += " [" + project.getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- setName(title);
- }
-
- public IBuildConsoleManager getConsoleManager() {
- return fConsoleManager;
- }
-
- public void setBackground(Color background) {
- if (fBackground == null) {
- if (background == null) {
- return;
- }
- } else if (fBackground.equals(background)){
- return;
- }
- Color old = fBackground;
- fBackground = background;
- firePropertyChange(this, IConsoleConstants.P_BACKGROUND_COLOR, old, fBackground);
- }
-
- public Color getBackground() {
- return fBackground;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java
deleted file mode 100644
index 4563065..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleDocument.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.jface.text.DefaultLineTracker;
-import org.eclipse.jface.text.Document;
-
-public class BuildConsoleDocument extends Document {
-
- public BuildConsoleDocument() {
- setTextStore(new ConsoleOutputTextStore(2500));
- setLineTracker(new DefaultLineTracker());
- completeInitialization();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java
deleted file mode 100644
index 440a175..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleFactory.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Ericsson 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:
- * Ericsson - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.ui.console.IConsoleFactory;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-
-/**
- * A console factory to allow the user to open the build console
- * before actually doing a build.
- */
-public class BuildConsoleFactory implements IConsoleFactory {
- public void openConsole() {
- IBuildConsoleManager manager = CUIPlugin.getDefault().getConsoleManager();
- if (manager instanceof BuildConsoleManager) {
- ((BuildConsoleManager)manager).showConsole();
- }
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java
deleted file mode 100644
index 8d24a8c..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Red Hat Inc. - multiple build console support
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- * Alex Collins (Broadcom Corp.) - Global build console
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.net.URI;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleView;
-import org.osgi.service.prefs.Preferences;
-
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleEvent;
-import org.eclipse.cdt.ui.IBuildConsoleListener;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-
-import org.eclipse.cdt.internal.core.LocalProjectScope;
-
-import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
-
-public class BuildConsoleManager implements IBuildConsoleManager, IResourceChangeListener, IPropertyChangeListener {
- /*package*/ static final String PREF_QUALIFIER = CUIPlugin.PLUGIN_ID;
- public static final String KEY_KEEP_LOG = "keepLog"; //$NON-NLS-1$
- public static final String KEY_LOG_LOCATION = "logLocation"; //$NON-NLS-1$
- public static final boolean CONSOLE_KEEP_LOG_DEFAULT = true;
-
- private static final String BUILD_CONSOLE_NODE = "buildConsole"; //$NON-NLS-1$
- private static final String PROJECT_LOG_EXT = ".build.log"; //$NON-NLS-1$
-
- private ListenerList listeners = new ListenerList();
- /** UI console object in which per-project consoles are shown */
- private BuildConsole fConsole;
- private Map fConsoleMap = new HashMap();
- private Color infoColor;
- private Color outputColor;
- private Color errorColor;
- private Color backgroundColor;
- private Color problemHighlightedColor;
- private Color problemErrorBackgroundColor;
- private Color problemInfoBackgroundColor;
- private Color problemWarningBackgroundColor;
-
- public Color getProblemHighlightedColor() {
- return problemHighlightedColor;
- }
-
- /**
- * This function returns background color for errors only now
- */
- public Color getProblemBackgroundColor() {
- return problemErrorBackgroundColor;
- }
-
- public Color getWarningBackgroundColor() {
- return problemWarningBackgroundColor;
- }
-
- public Color getInfoBackgroundColor() {
- return problemInfoBackgroundColor;
- }
-
- private BuildConsoleStreamDecorator infoStream;
- private BuildConsoleStreamDecorator outputStream;
- private BuildConsoleStreamDecorator errorStream;
-
- private String fName;
- private String fContextMenuId;
-
- static public final int BUILD_STREAM_TYPE_INFO = 0;
- static public final int BUILD_STREAM_TYPE_OUTPUT = 1;
- static public final int BUILD_STREAM_TYPE_ERROR = 2;
-
- static public final String DEFAULT_CONTEXT_MENU_ID = CUIPlugin.PLUGIN_ID + ".CDTBuildConsole"; //$NON-NLS-1$
-
- private IProject fLastProject;
-
- /**
- * Default constructor.
- */
- public BuildConsoleManager() {
- }
-
- /**
- * Notifies the console manager that console activity has started on the
- * project The manager will open the console if the preference is set to
- * show the console, and notify listeners
- */
- protected void startConsoleActivity(IProject project) {
- Object[] list = listeners.getListeners();
- if (list.length > 0) {
- for (Object element : list) {
- IBuildConsoleListener listener = (IBuildConsoleListener)element;
- ConsoleEvent event = new ConsoleEvent(BuildConsoleManager.this, project, IBuildConsoleEvent.CONSOLE_START);
- listener.consoleChange(event);
- }
- }
- showConsole();
- }
-
- /**
- * Opens the console view. If the view is already open, it is brought to the
- * front. The console that is shown is the console that was last on top.
- */
- protected void showConsole() {
- IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IViewPart consoleView = page.findView(IConsoleConstants.ID_CONSOLE_VIEW);
- if (consoleView == null && BuildConsolePreferencePage.isAutoOpenConsole()) {
- IWorkbenchPart activePart = page.getActivePart();
- try {
- consoleView = page.showView(IConsoleConstants.ID_CONSOLE_VIEW);
- } catch (PartInitException pie) {
- CUIPlugin.log(pie);
- }
- //restore focus stolen by the creation of the
- // console
- page.activate(activePart);
- } else {
- boolean bringToTop = shouldBringToTop(consoleView);
- if (bringToTop) {
- page.bringToTop(consoleView);
- }
- }
- if (consoleView instanceof IConsoleView) {
- if (BuildConsole.getCurrentPage() == null)
- ((IConsoleView)consoleView).display(fConsole);
- else
- ((IConsoleView)consoleView).display(BuildConsole.getCurrentPage().getConsole());
- }
- }
- }
- }
-
- boolean shouldBringToTop(IViewPart consoleView) {
- boolean bringToTop = false;
- if (consoleView instanceof IConsoleView) {
- IConsoleView cView = (IConsoleView)consoleView;
- return !cView.isPinned() && BuildConsolePreferencePage.isConsoleOnTop();
- }
- return bringToTop;
- }
-
- /**
- * Traverses the delta looking for added/removed/changed launch
- * configuration files.
- *
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- IResource resource = event.getResource();
- if (resource != null && resource.getType() == IResource.PROJECT) {
- if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
- IDocumentPartitioner partioner = fConsoleMap.remove(resource);
- if (partioner != null) {
- partioner.disconnect();
- Object[] list = listeners.getListeners();
- if (list.length > 0) {
- for (Object element : list) {
- IBuildConsoleListener listener = (IBuildConsoleListener)element;
- ConsoleEvent consoleEvent = new ConsoleEvent(this, (IProject)resource, IBuildConsoleEvent.CONSOLE_CLOSE);
- listener.consoleChange(consoleEvent);
- }
- }
- }
- }
- }
- }
-
- /**
- * Release resources allocated on {@link #startup(String, String, URL)}.
- */
- public void shutdown() {
- if (infoColor != null) {
- infoColor.dispose();
- outputColor.dispose();
- errorColor.dispose();
- backgroundColor.dispose();
- problemErrorBackgroundColor.dispose();
- problemWarningBackgroundColor.dispose();
- problemInfoBackgroundColor.dispose();
- problemHighlightedColor.dispose();
- }
- ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
- CUIPlugin.getWorkspace().removeResourceChangeListener(this);
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- }
-
- private void runUI(Runnable run) {
- Display display;
- display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- display.asyncExec(run);
- } else {
- run.run();
- }
- }
-
- /**
- * Create new build console. Subclasses may override to create a specialized
- * console.
- *
- * @param name - name of console to appear in the list of consoles in context menu
- * in the Console view.
- * @param contextId - context menu id in the Console view.
- * @param iconUrl - a {@link URL} of the icon for the context menu of the Console
- * view. The url is expected to point to an image in eclipse OSGi bundle.
- * {@code iconUrl} can be null, in that case the default image is used.
- * @return newly created build console.
- */
- protected BuildConsole createBuildConsole(String name, String contextId, final URL iconUrl) {
- return new BuildConsole(this, name, contextId, iconUrl);
- }
-
- /**
- * Start console activities. This will create a new console in the Console view,
- * create streams, color resources, register listeners etc.
- * Most work is done in UI thread.
- *
- * Use {@link #shutdown()} after the console activity ends.
- *
- * @param name - name of the console to appear in the Console view.
- * @param contextId - context menu id in the Console view.
- * @param iconUrl - icon to show in the context menu.
- */
- public void startup(String name, String contextId, final URL iconUrl) {
- // Ensure global console is initialized before any other build console
- if (!(this instanceof GlobalBuildConsoleManager))
- GlobalBuildConsoleManager.startup();
-
- infoStream = new BuildConsoleStreamDecorator();
- outputStream = new BuildConsoleStreamDecorator();
- errorStream = new BuildConsoleStreamDecorator();
- fName = name;
- fContextMenuId = contextId;
-
- runUI(new Runnable() {
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Runnable#run()
- */
- public void run() {
- // add console to the Console view
- fConsole = createBuildConsole(fName, fContextMenuId, iconUrl);
- ConsolePlugin.getDefault().getConsoleManager().addConsoles(new org.eclipse.ui.console.IConsole[]{fConsole});
-
- infoStream.setConsole(fConsole);
- infoColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
- infoStream.setColor(infoColor);
- outputStream.setConsole(fConsole);
- outputColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
- outputStream.setColor(outputColor);
- errorStream.setConsole(fConsole);
- errorColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
- errorStream.setColor(errorColor);
- backgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
- fConsole.setBackground(backgroundColor);
- problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
- problemErrorBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
- problemWarningBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
- problemInfoBackgroundColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
- }
- });
- CUIPlugin.getWorkspace().addResourceChangeListener(this);
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- // colors
- if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_INFO_COLOR);
- infoStream.setColor(newColor);
- infoColor.dispose();
- infoColor = newColor;
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_OUTPUT_COLOR);
- outputStream.setColor(newColor);
- outputColor.dispose();
- outputColor = newColor;
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_ERROR_COLOR);
- errorStream.setColor(newColor);
- errorColor.dispose();
- errorColor = newColor;
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR);
- fConsole.setBackground(newColor);
- backgroundColor.dispose();
- backgroundColor = newColor;
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR)) {
- Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR);
- problemHighlightedColor.dispose();
- problemHighlightedColor = newColor;
- redrawTextViewer();
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR);
- problemErrorBackgroundColor.dispose();
- problemErrorBackgroundColor = newColor;
- redrawTextViewer();
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR);
- problemWarningBackgroundColor.dispose();
- problemWarningBackgroundColor = newColor;
- redrawTextViewer();
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR)) {
- Color newColor = createBackgroundColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR);
- problemInfoBackgroundColor.dispose();
- problemInfoBackgroundColor = newColor;
- redrawTextViewer();
- }
- }
-
- private void redrawTextViewer() {
- final BuildConsolePage p = BuildConsole.getCurrentPage();
- if ( p == null ) return;
- final BuildConsoleViewer v = p.getViewer();
- if ( v == null ) return;
- Display display = Display.getDefault();
- display.asyncExec(new Runnable() {
- public void run() {
- v.getTextWidget().redraw();
- }
- });
- }
-
- public BuildConsoleStreamDecorator getStreamDecorator(int type) throws CoreException {
- switch (type) {
- case BUILD_STREAM_TYPE_ERROR :
- return errorStream;
- case BUILD_STREAM_TYPE_INFO :
- return infoStream;
- case BUILD_STREAM_TYPE_OUTPUT :
- return outputStream;
- }
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "No Such Console", null)); //$NON-NLS-1$
- }
-
- /**
- * Returns a color instance based on data from a preference field.
- */
- private Color createColor(Display display, String preference) {
- RGB rgb = PreferenceConverter.getColor(CUIPlugin.getDefault().getPreferenceStore(), preference);
- return new Color(display, rgb);
- }
-
- /**
- * Returns a background color instance based on data from a preference field.
- * This is a workaround for black console bug 320723.
- */
- private Color createBackgroundColor(Display display, String preference) {
- IPreferenceStore preferenceStore = CUIPlugin.getDefault().getPreferenceStore();
- RGB rgb;
- if (preferenceStore.contains(preference)) {
- rgb = PreferenceConverter.getColor(preferenceStore, preference);
- } else {
- rgb = new RGB(200, 200, 200); // gray background
- }
- return new Color(display, rgb);
- }
-
- /**
- * {@inheritDoc}
- */
- public IConsole getConsole(IProject project) {
- return new MultiBuildConsoleAdapter(getProjectConsole(project), GlobalBuildConsoleManager.getGlobalConsole());
- }
-
- /**
- * {@inheritDoc}
- *
- * @return the console for the specified project. Returns {@code null}
- * if project is {@code null} or not accessible.
- */
- public IConsole getProjectConsole(IProject project) {
- if (project==null || !project.isAccessible())
- return null;
-
- fLastProject = project;
- return getProjectConsolePartioner(project).getConsole();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.IBuildConsoleManager#getLastBuiltProject()
- */
- public IProject getLastBuiltProject() {
- return fLastProject;
- }
-
- /**
- * @return the partitioner for the specified projects build console
- */
- private BuildConsolePartitioner getProjectConsolePartioner(IProject project) {
- BuildConsolePartitioner partitioner = fConsoleMap.get(project);
- if (partitioner == null) {
- partitioner = new BuildConsolePartitioner(project, this);
- fConsoleMap.put(project, partitioner);
- }
- return partitioner;
- }
-
- /**
- * @return the document backing the build console for the specified project
- */
- public IDocument getConsoleDocument(IProject project) {
- Assert.isNotNull(project);
- return getProjectConsolePartioner(project).getDocument();
- }
-
- public void addConsoleListener(IBuildConsoleListener listener) {
- listeners.add(listener);
- }
-
- public void removeConsoleListener(IBuildConsoleListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * @return logging preferences for a given project.
- * @param project to get logging preferences for, can't be {@code null}.
- */
- public Preferences getBuildLogPreferences(IProject project) {
- return new LocalProjectScope(project).getNode(PREF_QUALIFIER).node(BUILD_CONSOLE_NODE);
- }
-
- /**
- * @return default location of logs for a project.
- * @param project to get default log location for, can't be {@code null}.
- */
- public String getDefaultConsoleLogLocation(IProject project) {
- IPath defaultLogLocation = CUIPlugin.getDefault().getStateLocation().append(project.getName() + PROJECT_LOG_EXT);
- return defaultLogLocation.toOSString();
- }
-
- /**
- * Where the log for per-project console is kept.
- *
- * @param project - the project. Cannot be {@code null}.
- * @return {@link URI} of build log or {@code null} if not available.
- */
- public URI getLogURI(IProject project) {
- Assert.isNotNull(project);
-
- if (fContextMenuId!=DEFAULT_CONTEXT_MENU_ID)
- return null;
-
- URI logURI = null;
-
- Preferences prefs = getBuildLogPreferences(project);
- boolean keepLog = prefs.getBoolean(KEY_KEEP_LOG, CONSOLE_KEEP_LOG_DEFAULT);
- if (keepLog) {
- String strLocation;
- strLocation = prefs.get(KEY_LOG_LOCATION, getDefaultConsoleLogLocation(project));
- if (strLocation.trim().length()>0) {
- logURI = URIUtil.toURI(strLocation);
- }
- if (logURI==null) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,"Can't determine URI for location=["+strLocation+"]"); //$NON-NLS-1$ //$NON-NLS-2$
- CUIPlugin.log(status);
- }
- }
- return logURI;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
deleted file mode 100644
index b45a085..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
+++ /dev/null
@@ -1,645 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2011 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Red Hat Inc. - multiple build console support
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- * Save build output
- * Alex Collins (Broadcom Corp.) - Global build console
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IFindReplaceTarget;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.OpenStrategy;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleView;
-import org.eclipse.ui.console.actions.ClearOutputAction;
-import org.eclipse.ui.console.actions.TextViewerAction;
-import org.eclipse.ui.console.actions.TextViewerGotoLineAction;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.ide.ResourceUtil;
-import org.eclipse.ui.part.IPageSite;
-import org.eclipse.ui.part.Page;
-import org.eclipse.ui.texteditor.FindReplaceAction;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.IUpdate;
-
-import org.eclipse.cdt.core.ProblemMarkerInfo;
-import org.eclipse.cdt.core.model.ICModelMarker;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleEvent;
-import org.eclipse.cdt.ui.IBuildConsoleListener;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-
-import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
-
-public class BuildConsolePage extends Page
- implements
- ISelectionListener,
- IPropertyChangeListener,
- IBuildConsoleListener,
- ITextListener,
- IAdaptable {
-
- static final int POSITION_NEXT = -1;
- static final int POSITION_PREV = -2;
- static final int POSITION_FIST = -3;
-
- private BuildConsole fConsole;
- private IConsoleView fConsoleView;
- private String fContextMenuId;
- private BuildConsoleViewer fViewer;
- private IProject fProject;
-
- // text selection listener
- private ISelectionChangedListener fTextListener = new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- updateSelectionDependentActions();
- }
- };
-
- // actions
- private ClearOutputAction fClearOutputAction;
- private Map fGlobalActions = new HashMap(10);
- private List fSelectionActions = new ArrayList(3);
- private CopyBuildLogAction fSaveLogAction;
-
- // menus
- private Menu fMenu;
- private ScrollLockAction fScrollLockAction;
- private boolean fIsLocked;
- private NextErrorAction fNextErrorAction;
- private PreviousErrorAction fPreviousErrorAction;
- private ShowErrorAction fShowErrorAction;
-
- /**
- * @param view
- * @param console
- * @param contextId
- */
- public BuildConsolePage(IConsoleView view, BuildConsole console,
- String contextId) {
- fConsole = console;
- fConsoleView = view;
- fContextMenuId = contextId;
- }
-
- protected void setProject(IProject project) {
- if (fProject != project && project.isAccessible()) {
- fProject = project;
- }
- }
-
- protected IProject getProject() {
- return fProject;
- }
-
- protected BuildConsole getConsole() {
- return fConsole;
- }
-
- protected IDocument setDocument() {
- IProject project = getProject();
- if (project != null) {
- IBuildConsoleManager consoleManager = getConsole().getConsoleManager();
- IDocument document = consoleManager.getConsoleDocument(project);
- IConsole console = consoleManager.getProjectConsole(project);
- getViewer().setDocument(document);
- if (console instanceof BuildConsolePartitioner) {
- BuildConsolePartitioner par = (BuildConsolePartitioner)console;
- // Show the error, but don't show it in the editor if we are viewing the global console.
- // Prevents showing errors in the editor for projects other than the current project.
- showError(par, fShowErrorAction.isChecked() && !(getConsole() instanceof GlobalBuildConsole));
- }
- }
- return null;
- }
-
- public void consoleChange(final IBuildConsoleEvent event) {
- if (event.getType() == IBuildConsoleEvent.CONSOLE_START || event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE) {
- Control control = getControl();
- if (control != null && !control.isDisposed()) {
- Display display = control.getDisplay();
- display.asyncExec(new Runnable() {
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Runnable#run()
- */
- public void run() {
- if (isAvailable()) {
- if (event.getType() == IBuildConsoleEvent.CONSOLE_CLOSE && getProject() != event.getProject()) {
- return;
- }
- setProject(event.getProject());
- if (isAvailable()) {
- setDocument();
- getConsole().setTitle(getProject());
- }
- }
- }
- });
- }
- }
- }
-
- boolean isAvailable() {
- return getControl() != null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createControl(Composite parent) {
- fViewer = new BuildConsoleViewer(parent);
-
- MenuManager manager = new MenuManager("#MessageConsole", "#MessageConsole"); //$NON-NLS-1$ //$NON-NLS-2$
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
-
- public void menuAboutToShow(IMenuManager m) {
- contextMenuAboutToShow(m);
- }
- });
- fMenu = manager.createContextMenu(getControl());
- getControl().setMenu(fMenu);
- IPageSite site = getSite();
- site.registerContextMenu(fContextMenuId, manager, getViewer());
- site.setSelectionProvider(getViewer());
- createActions();
- configureToolBar(site.getActionBars().getToolBarManager());
- fViewer.getSelectionProvider().addSelectionChangedListener(fTextListener);
-
- JFaceResources.getFontRegistry().addListener(this);
- setFont(JFaceResources.getFont(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT));
- setTabs(CUIPlugin.getDefault().getPreferenceStore().getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
-
- getConsole().addPropertyChangeListener(this);
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
-
- fViewer.addTextListener(this);
- fViewer.getTextWidget().setBackground(getConsole().getBackground());
-
- setInitialSelection();
- }
-
- /**
- * Fill the context menu
- *
- * @param menu
- * menu
- */
- protected void contextMenuAboutToShow(IMenuManager menu) {
- menu.add(fGlobalActions.get(ActionFactory.COPY.getId()));
- menu.add(fGlobalActions.get(ActionFactory.SELECT_ALL.getId()));
- menu.add(new Separator("FIND")); //$NON-NLS-1$
- menu.add(fGlobalActions.get(ActionFactory.FIND.getId()));
- menu.add(fGlobalActions.get(ITextEditorActionConstants.GOTO_LINE));
- menu.add(fClearOutputAction);
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- final Object source = event.getSource();
- final String property = event.getProperty();
-
- if (BuildConsole.P_STREAM_COLOR.equals(property) && source instanceof BuildConsoleStreamDecorator) {
- BuildConsoleStreamDecorator stream = (BuildConsoleStreamDecorator)source;
- if (stream.getConsole().equals(getConsole()) && getControl() != null) {
- Display display = getControl().getDisplay();
- display.asyncExec(new Runnable() {
-
- public void run() {
- getViewer().getTextWidget().redraw();
- }
- });
- }
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT)) {
- setFont(JFaceResources.getFont(BuildConsolePreferencePage.PREF_BUILDCONSOLE_FONT));
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH)) {
- setTabs(CUIPlugin.getDefault().getPreferenceStore().getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
- } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) {
- fViewer.getTextWidget().setBackground(fConsole.getBackground());
- }
- }
-
- protected void createActions() {
- fClearOutputAction = new ClearOutputAction(getViewer());
- fScrollLockAction = new ScrollLockAction(getViewer());
- fScrollLockAction.setChecked(fIsLocked);
- fNextErrorAction = new NextErrorAction(this);
- fPreviousErrorAction = new PreviousErrorAction(this);
- fShowErrorAction = new ShowErrorAction(this);
- fSaveLogAction = new CopyBuildLogAction(this);
-
- getViewer().setAutoScroll(!fIsLocked);
- // In order for the clipboard actions to accessible via their shortcuts
- // (e.g., Ctrl-C, Ctrl-V), we *must* set a global action handler for
- // each action
- IActionBars actionBars = getSite().getActionBars();
- TextViewerAction action = new TextViewerAction(getViewer(), ITextOperationTarget.COPY);
- action.configureAction(ConsoleMessages.BuildConsolePage__Copy_Ctrl_C_6,
- ConsoleMessages.BuildConsolePage_Copy_7, ConsoleMessages.BuildConsolePage_Copy_7);
- action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- action.setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
- ISharedImages.IMG_TOOL_COPY_DISABLED));
- action.setHoverImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- setGlobalAction(actionBars, ActionFactory.COPY.getId(), action);
- action = new TextViewerAction(getViewer(), ITextOperationTarget.SELECT_ALL);
- action.configureAction(ConsoleMessages.BuildConsolePage_Select__All_Ctrl_A_12,
- ConsoleMessages.BuildConsolePage_Select_All,
- ConsoleMessages.BuildConsolePage_Select_All);
- setGlobalAction(actionBars, ActionFactory.SELECT_ALL.getId(), action);
- //XXX Still using "old" resource access
- ResourceBundle bundle = ResourceBundle.getBundle(ConsoleMessages.BUNDLE_NAME);
- setGlobalAction(actionBars, ActionFactory.FIND.getId(), new FindReplaceAction(bundle, "find_replace_action_", //$NON-NLS-1$
- getConsoleView()));
- action = new TextViewerGotoLineAction(getViewer());
- setGlobalAction(actionBars, ITextEditorActionConstants.GOTO_LINE, action);
- actionBars.updateActionBars();
- fSelectionActions.add(ActionFactory.COPY.getId());
- fSelectionActions.add(ActionFactory.FIND.getId());
- }
-
- protected void updateSelectionDependentActions() {
- Iterator iterator = fSelectionActions.iterator();
- while (iterator.hasNext()) {
- updateAction(iterator.next());
- }
- }
-
- protected void updateAction(String actionId) {
- IAction action = fGlobalActions.get(actionId);
- if (action instanceof IUpdate) {
- ((IUpdate)action).update();
- }
- }
-
- protected void setGlobalAction(IActionBars actionBars, String actionID, IAction action) {
- fGlobalActions.put(actionID, action);
- actionBars.setGlobalActionHandler(actionID, action);
- }
-
- protected void configureToolBar(IToolBarManager mgr) {
- mgr.insertBefore(IConsoleConstants.OUTPUT_GROUP, new GroupMarker(BuildConsole.ERROR_GROUP));
- mgr.appendToGroup(BuildConsole.ERROR_GROUP, fNextErrorAction);
- mgr.appendToGroup(BuildConsole.ERROR_GROUP, fPreviousErrorAction);
- mgr.appendToGroup(BuildConsole.ERROR_GROUP, fShowErrorAction);
- mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fSaveLogAction);
- mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fScrollLockAction);
- mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fClearOutputAction);
- }
-
- protected BuildConsoleViewer getViewer() {
- return fViewer;
- }
-
- /**
- * Returns the view this page is contained in
- *
- * @return the view this page is contained in
- */
- protected IConsoleView getConsoleView() {
- return fConsoleView;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.IPage#dispose()
- */
- @Override
- public void dispose() {
- getSite().getPage().removeSelectionListener(this);
- getConsole().getConsoleManager().removeConsoleListener(this);
- fViewer.removeTextListener(this);
- super.dispose();
- }
-
- @Override
- public void init(IPageSite pageSite) {
- super.init(pageSite);
- getSite().getPage().addSelectionListener(this);
- getConsole().getConsoleManager().addConsoleListener(this);
- }
-
- protected void setInitialSelection() {
- // Use the selection, if any
- IWorkbenchPage page= getSite().getPage();
- ISelection selection= null;
- if (page != null)
- selection= page.getSelection();
-
- if (convertSelectionToProject(selection) == null) {
- if (selection instanceof ITextSelection) {
- Object part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
- if (part instanceof IEditorPart) {
- if (setSelectionFromEditor((IEditorPart)part) == true)
- return;
- }
- }
- IProject project = getConsole().getConsoleManager().getLastBuiltProject();
- if (project != null)
- selection = new StructuredSelection(project);
- }
- selectionChanged(null, selection);
- }
-
- boolean setSelectionFromEditor(IEditorPart part) {
- if (part == null)
- return false;
- IWorkbenchPartSite site= part.getSite();
- if (site == null)
- return false;
- ISelectionProvider provider= site.getSelectionProvider();
- if (provider != null ) {
- IEditorInput ei= part.getEditorInput();
- if (ei instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)ei).getFile();
- selectionChanged(part, new StructuredSelection(file));
- return true;
- }
- }
- return false;
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- IProject newProject = convertSelectionToProject(selection);
- IProject oldProject = getProject();
- if (oldProject == null || (newProject != null && !newProject.equals(oldProject))) {
- setProject(newProject);
- setDocument();
- getConsole().setTitle(getProject());
- }
- }
-
- IProject convertSelectionToProject(ISelection selection) {
- IProject project = null;
- if (selection == null || ! (selection instanceof IStructuredSelection)) {
- return project;
- }
- IStructuredSelection ssel = (IStructuredSelection)selection;
- Object element = ssel.getFirstElement();
- if (element instanceof IAdaptable) {
- IAdaptable input = (IAdaptable)element;
- IResource resource = null;
- if (input instanceof IResource) {
- resource = (IResource)input;
- } else {
- resource = (IResource)input.getAdapter(IResource.class);
- }
- if (resource != null) {
- project = resource.getProject();
- }
- }
- return project;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.IPage#getControl()
- */
- @Override
- public Control getControl() {
- if (fViewer != null) {
- return fViewer.getControl();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.IPage#setFocus()
- */
- @Override
- public void setFocus() {
- Control control = getControl();
- if (control != null) {
- control.setFocus();
- }
- updateSelectionDependentActions();
- }
-
- /**
- * Sets the font for this page.
- *
- * @param font
- * font
- */
- protected void setFont(Font font) {
- getViewer().getTextWidget().setFont(font);
- }
-
- /**
- * Sets the tab width for this page.
- *
- * @param tabs
- * tab width
- */
- protected void setTabs(int tabs) {
- getViewer().getTextWidget().setTabs(tabs);
- }
-
- /**
- * Refreshes this page
- */
- protected void refresh() {
- getViewer().refresh();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- public Object getAdapter(Class required) {
- if (IFindReplaceTarget.class.equals(required)) {
- return getViewer().getFindReplaceTarget();
- }
- if (Widget.class.equals(required)) {
- return getViewer().getTextWidget();
- }
-// if (IShowInSource.class.equals(required)) {
-// return this;
-// }
-// if (IShowInTargetList.class.equals(required)) {
-// return this;
-// }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextListener#textChanged(org.eclipse.jface.text.TextEvent)
- */
- public void textChanged(TextEvent event) {
- // update the find replace action if the document length is > 0
- IUpdate findReplace = (IUpdate)fGlobalActions.get(ActionFactory.FIND.getId());
- if (findReplace != null) {
- findReplace.update();
- }
- }
-
- /**
- * Get the current CDT IConsole being displayed on the page
- */
- private IConsole getCurrentConsole() {
- IBuildConsoleManager consoleManager = fConsole.getConsoleManager();
- return consoleManager.getProjectConsole(getProject());
- }
-
- /**
- * Highlight next/previous error or error by console offset
- * @param position POSITION_NEXT (-1), POSITION_PREV (-2), or offset
- */
- void moveToError(int position) {
- IConsole console = getCurrentConsole();
- if (console == null) return;
- if (console instanceof BuildConsolePartitioner) {
- BuildConsolePartitioner par = (BuildConsolePartitioner)console;
- // Move to specified line in the model (BuildConsolePartitioner)
- if ( position == POSITION_NEXT ) {
- par.fDocumentMarkerManager.moveToNextError();
- } else if ( position == POSITION_PREV ) {
- par.fDocumentMarkerManager.moveToPreviousError();
- } else if ( position == POSITION_FIST ) {
- par.fDocumentMarkerManager.moveToFirstError();
- } else if ( position >= 0 ) {
- if ( ! par.fDocumentMarkerManager.moveToErrorByOffset(position) ) {
- // we haven't moved, because offset points to non-error partition
- return;
- }
- }
- showError(par, position > 0 || fShowErrorAction.isChecked() );
- }
- }
-
- /**
- * Highlight current error and show it in editor
- */
- public void showError(BuildConsolePartitioner par, boolean openInEditor) {
- // Highlight current error
- BuildConsolePartition p = par.fDocumentMarkerManager.getCurrentPartition();
- if ( p == null ) return;
- getViewer().selectPartition(par, p);
- // Show error in editor if necessary
- // (always show when absolute positioning, otherwise depends
- // on fShowErrorAction state)
- if ( openInEditor ) {
- openErrorInEditor(par.fDocumentMarkerManager.getCurrentErrorMarker());
- }
- }
-
- /**
- * Open error specified by marker in editor
- */
- public static void openErrorInEditor(ProblemMarkerInfo marker) {
- IWorkbenchWindow window = CUIPlugin.getActiveWorkbenchWindow();
-
- if ( marker == null || marker.file == null || window == null ) return;
-
- IWorkbenchPage page = window.getActivePage();
- if (page == null) return;
-
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- IEditorInput input = editor.getEditorInput();
- IFile file = ResourceUtil.getFile(input);
- if (file != null && file.equals(marker.file) && OpenStrategy.activateOnOpen()) {
- page.activate(editor);
- }
- }
-
- if ( marker.file instanceof IFile ) {
- try {
- // Find IMarker corresponding to ProblemMarkerInfo
- IMarker mrkrs[] = marker.file.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE);
- for (IMarker m: mrkrs) {
- if ( marker.lineNumber == ((Integer)m.getAttribute(IMarker.LINE_NUMBER)).intValue() &&
- marker.description.equals(m.getAttribute(IMarker.MESSAGE)) &&
- marker.severity == ((Integer)m.getAttribute(IMarker.SEVERITY)).intValue() ) {
- IDE.openEditor(page, m, OpenStrategy.activateOnOpen());
- return;
- }
- }
- } catch (PartInitException e) {
- CUIPlugin.log(e);
- } catch (CoreException e) {
- CUIPlugin.log(e);
- }
- }
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java
deleted file mode 100644
index 774f6e8..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePageParticipant.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Broadcom 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alex Collins (Broadcom Corp.) - Initial implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsolePageParticipant;
-import org.eclipse.ui.part.IPageBookViewPage;
-
-/**
- * Attached to extension point org.eclipse.ui.console.consolePageParticipants to notify
- * BuildConsole that a new page has become visible.
- */
-public class BuildConsolePageParticipant implements IConsolePageParticipant {
- private BuildConsole console;
-
- public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
- return null;
- }
-
- public void init(IPageBookViewPage page, IConsole console) {
- this.console = (BuildConsole)console;
- }
-
- public void dispose() {
- }
-
- public void activated() {
- BuildConsole.setCurrentPage(console.getPage());
- }
-
- public void deactivated() {
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java
deleted file mode 100644
index 8910664..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.cdt.core.ProblemMarkerInfo;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.text.TypedRegion;
-
-public class BuildConsolePartition extends TypedRegion {
-
- /** Associated stream */
- private BuildConsoleStreamDecorator fStream;
-
- /** Marker associated with this partition if any */
- private ProblemMarkerInfo fMarker;
-
- /** Partition type */
- public static final String CONSOLE_PARTITION_TYPE = CUIPlugin.getPluginId() + ".CONSOLE_PARTITION_TYPE"; //$NON-NLS-1$
-
- /** Partition types to report build problems in the console */
- public static final String ERROR_PARTITION_TYPE = CUIPlugin.getPluginId() + ".ERROR_PARTITION_TYPE"; //$NON-NLS-1$
- public static final String INFO_PARTITION_TYPE = CUIPlugin.getPluginId() + ".INFO_PARTITION_TYPE"; //$NON-NLS-1$
- public static final String WARNING_PARTITION_TYPE = CUIPlugin.getPluginId() + ".WARNING_PARTITION_TYPE"; //$NON-NLS-1$
-
- public BuildConsolePartition(BuildConsoleStreamDecorator stream, int offset, int length, String type) {
- super(offset, length, type);
- fStream = stream;
- }
-
- public BuildConsolePartition(BuildConsoleStreamDecorator stream, int offset, int length, String type, ProblemMarkerInfo marker) {
- super(offset, length, type);
- fStream = stream;
- fMarker = marker;
- }
-
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object partition) {
- if (super.equals(partition)) {
- return fStream.equals(((BuildConsolePartition) partition).getStream());
- }
- return false;
- }
-
- /**
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return super.hashCode() + fStream.hashCode();
- }
-
- /**
- * Returns this partition's stream
- *
- * @return this partition's stream
- */
- public BuildConsoleStreamDecorator getStream() {
- return fStream;
- }
-
- /**
- * Returns whether this partition is allowed to be combined with the given
- * partition.
- *
- * @param partition
- * @return boolean
- */
- public boolean canBeCombinedWith(BuildConsolePartition partition) {
- // Error partitions never can be combined together
- String type = getType();
- if (isProblemPartitionType(type)) {
- return false;
- }
-
- int start = getOffset();
- int end = start + getLength();
- int otherStart = partition.getOffset();
- int otherEnd = otherStart + partition.getLength();
- boolean overlap = (otherStart >= start && otherStart <= end) || (start >= otherStart && start <= otherEnd);
- return getStream() != null && overlap && type.equals(partition.getType()) && getStream().equals(partition.getStream());
- }
-
- /**
- * Returns a new partition representing this and the given parition
- * combined.
- *
- * @param partition
- * @return partition
- */
- public BuildConsolePartition combineWith(BuildConsolePartition partition) {
- int start = getOffset();
- int end = start + getLength();
- int otherStart = partition.getOffset();
- int otherEnd = otherStart + partition.getLength();
- int theStart = Math.min(start, otherStart);
- int theEnd = Math.max(end, otherEnd);
- return createNewPartition(theStart, theEnd - theStart, CONSOLE_PARTITION_TYPE);
- }
-
- /**
- * Creates a new partition of this type with the given offset, and length.
- * @param offset
- * @param length
- * @return a new partition with the given range
- */
- public BuildConsolePartition createNewPartition(int offset, int length, String type) {
- return new BuildConsolePartition(getStream(), offset, length, type, getMarker());
- }
-
- public ProblemMarkerInfo getMarker() {
- return fMarker;
- }
-
- public static boolean isProblemPartitionType(String type) {
- return type==BuildConsolePartition.ERROR_PARTITION_TYPE
- || type==BuildConsolePartition.WARNING_PARTITION_TYPE
- || type==BuildConsolePartition.INFO_PARTITION_TYPE;
- }
-
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java
deleted file mode 100644
index 648bed3..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java
+++ /dev/null
@@ -1,636 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- * Andrew Gvozdev (Quoin Inc.) - Copy build log (bug 306222)
- * Alex Collins (Broadcom Corp.) - Global console
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.console.ConsolePlugin;
-
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.ProblemMarkerInfo;
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.core.resources.ResourcesUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage;
-
-public class BuildConsolePartitioner
- implements
- IDocumentPartitioner,
- IDocumentPartitionerExtension,
- IConsole,
- IPropertyChangeListener {
-
- private IProject fProject;
-
- /**
- * List of partitions
- */
- List fPartitions = new ArrayList(5);
-
- private int fMaxLines;
-
- /**
- * The stream that was last appended to
- */
- BuildConsoleStreamDecorator fLastStream = null;
-
- BuildConsoleDocument fDocument;
- DocumentMarkerManager fDocumentMarkerManager;
- boolean killed;
- BuildConsoleManager fManager;
-
- /**
- * A queue of stream entries written to standard out and standard err.
- * Entries appended to the end of the queue and removed from the front.
- * Intentionally a vector to obtain synchronization as entries are added and
- * removed.
- */
- Vector fQueue = new Vector(5);
-
- private URI fLogURI;
- private OutputStream fLogStream;
-
- private class StreamEntry {
- static public final int EVENT_APPEND = 0;
- static public final int EVENT_OPEN_LOG = 1;
- static public final int EVENT_CLOSE_LOG = 2;
- static public final int EVENT_OPEN_APPEND_LOG = 3;
-
- /** Identifier of the stream written to. */
- private BuildConsoleStreamDecorator fStream;
- /** The text written */
- private StringBuffer fText = null;
- /** Problem marker corresponding to the line of text */
- private ProblemMarkerInfo fMarker;
- /** Type of event **/
- private int eventType;
-
- public StreamEntry(String text, BuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) {
- fText = new StringBuffer(text);
- fStream = stream;
- fMarker = marker;
- eventType = EVENT_APPEND;
- }
-
- /**
- * This constructor is used for special events such as clear console or close log.
- *
- * @param event - kind of event.
- */
- public StreamEntry(int event) {
- fText = null;
- fStream = null;
- fMarker = null;
- eventType = event;
- }
-
- /**
- * Returns the stream identifier
- */
- public BuildConsoleStreamDecorator getStream() {
- return fStream;
- }
-
- public void appendText(String text) {
- fText.append(text);
- }
-
- public int size() {
- return fText.length();
- }
-
- /**
- * Returns the text written
- */
- public String getText() {
- return fText.toString();
- }
-
- /**
- * Returns error marker
- */
- public ProblemMarkerInfo getMarker() {
- return fMarker;
- }
-
- /**
- * Returns type of event
- */
- public int getEventType() {
- return eventType;
- }
-
- }
-
- /**
- * Construct a partitioner that is not associated with a specific project
- */
- public BuildConsolePartitioner(BuildConsoleManager manager) {
- this(null, manager);
- }
-
- public BuildConsolePartitioner(IProject project, BuildConsoleManager manager) {
- fProject = project;
- fManager = manager;
- fMaxLines = BuildConsolePreferencePage.buildConsoleLines();
- fDocument = new BuildConsoleDocument();
- fDocument.setDocumentPartitioner(this);
- fDocumentMarkerManager = new DocumentMarkerManager(fDocument, this);
- connect(fDocument);
-
- fLogURI = null;
- fLogStream = null;
- }
-
- /**
- * Sets the indicator that stream was opened so logging can be started. Should be called
- * when opening the output stream.
- */
- public void setStreamOpened() {
- fQueue.add(new StreamEntry(StreamEntry.EVENT_OPEN_LOG));
- asyncProcessQueue();
- }
-
- /**
- * Open the stream for appending. Must be called after a call to setStreamOpened().
- * Can be used to reopen a stream for writing after it has been closed, without
- * emptying the log file.
- */
- public void setStreamAppend() {
- fQueue.add(new StreamEntry(StreamEntry.EVENT_OPEN_APPEND_LOG));
- asyncProcessQueue();
- }
-
- /**
- * Sets the indicator that stream was closed so logging should be stopped. Should be called when
- * build process has finished. Note that there could still be unprocessed console
- * stream entries in the queue being worked on in the background.
- */
- public void setStreamClosed() {
- fQueue.add(new StreamEntry(StreamEntry.EVENT_CLOSE_LOG));
- asyncProcessQueue();
- }
-
- /**
- * Adds the new text to the document.
- *
- * @param text - the text to append.
- * @param stream - the stream to append to.
- */
- public void appendToDocument(String text, BuildConsoleStreamDecorator stream, ProblemMarkerInfo marker) {
- boolean addToQueue = true;
- synchronized (fQueue) {
- int i = fQueue.size();
- if (i > 0) {
- StreamEntry entry = fQueue.get(i - 1);
- // if last stream is the same and we have not exceeded our
- // display write limit, append.
- if (entry.getStream()==stream && entry.getEventType()==StreamEntry.EVENT_APPEND && entry.getMarker()==marker && entry.size()<10000) {
- entry.appendText(text);
- addToQueue = false;
- }
- }
- if (addToQueue) {
- fQueue.add(new StreamEntry(text, stream, marker));
- }
- }
- if (addToQueue) {
- asyncProcessQueue();
- }
- }
-
- /**
- * Asynchronous processing of stream entries to append to console.
- * Note that all these are processed by the same thread - the user-interface thread
- * as of {@link Display#asyncExec(Runnable)}.
- */
- private void asyncProcessQueue() {
- Runnable r = new Runnable() {
- public void run() {
- StreamEntry entry;
- try {
- entry = fQueue.remove(0);
- } catch (ArrayIndexOutOfBoundsException e) {
- return;
- }
- switch (entry.getEventType()) {
- case StreamEntry.EVENT_OPEN_LOG:
- case StreamEntry.EVENT_OPEN_APPEND_LOG:
- logOpen(entry.getEventType() == StreamEntry.EVENT_OPEN_APPEND_LOG);
- break;
- case StreamEntry.EVENT_APPEND:
- fLastStream = entry.getStream();
- try {
- warnOfContentChange(fLastStream);
-
- if (fLastStream == null) {
- // special case to empty document
- fPartitions.clear();
- fDocumentMarkerManager.clear();
- fDocument.set(""); //$NON-NLS-1$
- }
- String text = entry.getText();
- if (text.length()>0) {
- addStreamEntryToDocument(entry);
- log(text);
- checkOverflow();
- }
- } catch (BadLocationException e) {
- }
- break;
- case StreamEntry.EVENT_CLOSE_LOG:
- logClose();
- break;
- }
- }
-
- /**
- * Open the log
- * @param append Set to true if the log should be opened for appending, false for overwriting.
- */
- private void logOpen(boolean append) {
- fLogURI = fManager.getLogURI(fProject);
- if (fLogURI!=null) {
- try {
- IFileStore logStore = EFS.getStore(fLogURI);
- // Ensure the directory exists before opening the file
- IFileStore dir = logStore.getParent();
- if (dir != null)
- dir.mkdir(EFS.NONE, null);
- int opts = append ? EFS.APPEND : EFS.NONE;
- fLogStream = logStore.openOutputStream(opts, null);
- } catch (CoreException e) {
- CUIPlugin.log(e);
- } finally {
- ResourcesUtil.refreshWorkspaceFiles(fLogURI);
- }
- }
- }
-
- private void log(String text) {
- if (fLogStream!=null) {
- try {
- fLogStream.write(text.getBytes());
- if (fQueue.isEmpty()) {
- fLogStream.flush();
- }
- } catch (IOException e) {
- CUIPlugin.log(e);
- } finally {
- ResourcesUtil.refreshWorkspaceFiles(fLogURI);
- }
- }
- }
-
- private void logClose() {
- if (fLogStream!=null) {
- try {
- fLogStream.close();
- } catch (IOException e) {
- CUIPlugin.log(e);
- } finally {
- ResourcesUtil.refreshWorkspaceFiles(fLogURI);
- }
- fLogStream = null;
- }
- }
-
- };
- Display display = CUIPlugin.getStandardDisplay();
- if (display != null) {
- display.asyncExec(r);
- }
- }
-
- private void addStreamEntryToDocument(StreamEntry entry) throws BadLocationException {
- ProblemMarkerInfo marker = entry.getMarker();
- if (marker==null) {
- // It is plain unmarkered console output
- addPartition(new BuildConsolePartition(fLastStream,
- fDocument.getLength(),
- entry.getText().length(),
- BuildConsolePartition.CONSOLE_PARTITION_TYPE));
- } else {
- // this text line in entry is markered with ProblemMarkerInfo,
- // create special partition for it.
- String errorPartitionType;
- if (marker.severity==IMarker.SEVERITY_INFO) {
- errorPartitionType = BuildConsolePartition.INFO_PARTITION_TYPE;
- } else if (marker.severity==IMarker.SEVERITY_WARNING) {
- errorPartitionType = BuildConsolePartition.WARNING_PARTITION_TYPE;
- } else {
- errorPartitionType = BuildConsolePartition.ERROR_PARTITION_TYPE;
- }
- addPartition(new BuildConsolePartition(fLastStream,
- fDocument.getLength(),
- entry.getText().length(),
- errorPartitionType, marker));
- }
- fDocument.replace(fDocument.getLength(), 0, entry.getText());
- }
-
- void warnOfContentChange(BuildConsoleStreamDecorator stream) {
- if (stream != null) {
- ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(stream.getConsole());
- }
- fManager.showConsole();
- }
-
- public IDocument getDocument() {
- return fDocument;
- }
-
- public void setDocumentSize(int nLines) {
- fMaxLines = nLines;
- nLines = fDocument.getNumberOfLines();
- checkOverflow();
- }
-
- public void connect(IDocument document) {
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- public void disconnect() {
- fDocument.setDocumentPartitioner(null);
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- killed = true;
- }
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- public boolean documentChanged(DocumentEvent event) {
- return documentChanged2(event) != null;
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes()
- */
- public String[] getLegalContentTypes() {
- return new String[]{BuildConsolePartition.CONSOLE_PARTITION_TYPE};
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int)
- */
- public String getContentType(int offset) {
- ITypedRegion partition = getPartition(offset);
- if (partition != null) {
- return partition.getType();
- }
- return null;
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#computePartitioning(int,
- * int)
- */
- public ITypedRegion[] computePartitioning(int offset, int length) {
- if (offset == 0 && length == fDocument.getLength()) {
- return fPartitions.toArray(new ITypedRegion[fPartitions.size()]);
- }
- int end = offset + length;
- List list = new ArrayList();
- for (int i = 0; i < fPartitions.size(); i++) {
- ITypedRegion partition = fPartitions.get(i);
- int partitionStart = partition.getOffset();
- int partitionEnd = partitionStart + partition.getLength();
- if ( (offset >= partitionStart && offset <= partitionEnd) ||
- (offset < partitionStart && end >= partitionStart)) {
- list.add(partition);
- }
- }
- return list.toArray(new ITypedRegion[list.size()]);
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
- for (int i = 0; i < fPartitions.size(); i++) {
- ITypedRegion partition = fPartitions.get(i);
- int start = partition.getOffset();
- int end = start + partition.getLength();
- if (offset >= start && offset < end) {
- return partition;
- }
- }
- return null;
- }
-
- public IRegion documentChanged2(DocumentEvent event) {
- String text = event.getText();
- if (getDocument().getLength() == 0) {
- // cleared
- fPartitions.clear();
- return new Region(0, 0);
- }
- ITypedRegion[] affectedRegions = computePartitioning(event.getOffset(), text.length());
- if (affectedRegions.length == 0) {
- return null;
- }
- if (affectedRegions.length == 1) {
- return affectedRegions[0];
- }
- int affectedLength = affectedRegions[0].getLength();
- for (int i = 1; i < affectedRegions.length; i++) {
- ITypedRegion region = affectedRegions[i];
- affectedLength += region.getLength();
- }
-
- return new Region(affectedRegions[0].getOffset(), affectedLength);
- }
-
- /**
- * Checks to see if the console buffer has overflowed, and empties the
- * overflow if needed, updating partitions and hyperlink positions.
- */
- protected void checkOverflow() {
- if (fMaxLines >= 0) {
- int nLines = fDocument.getNumberOfLines();
- if (nLines > fMaxLines + 1) {
- int overflow = 0;
- try {
- overflow = fDocument.getLineOffset(nLines - fMaxLines);
- } catch (BadLocationException e1) {
- }
- // update partitions
- List newParitions = new ArrayList(fPartitions.size());
- Iterator partitions = fPartitions.iterator();
- while (partitions.hasNext()) {
- ITypedRegion region = partitions.next();
- if (region instanceof BuildConsolePartition) {
- BuildConsolePartition messageConsolePartition = (BuildConsolePartition)region;
-
- ITypedRegion newPartition = null;
- int offset = region.getOffset();
- String type = messageConsolePartition.getType();
- if (offset < overflow) {
- int endOffset = offset + region.getLength();
- if (endOffset < overflow || BuildConsolePartition.isProblemPartitionType(type)) {
- // remove partition,
- // partitions with problem markers can't be split - remove them too
- } else {
- // split partition
- int length = endOffset - overflow;
- newPartition = messageConsolePartition.createNewPartition(0, length, type);
- }
- } else {
- // modify partition offset
- offset = messageConsolePartition.getOffset() - overflow;
- newPartition = messageConsolePartition.createNewPartition(offset, messageConsolePartition.getLength(), type);
- }
- if (newPartition != null) {
- newParitions.add(newPartition);
- }
- }
- }
- fPartitions = newParitions;
- fDocumentMarkerManager.moveToFirstError();
-
- try {
- fDocument.replace(0, overflow, ""); //$NON-NLS-1$
- } catch (BadLocationException e) {
- }
- }
- }
- }
-
- /**
- * Adds a new partition, combining with the previous partition if possible.
- */
- private BuildConsolePartition addPartition(BuildConsolePartition partition) {
- if (fPartitions.isEmpty()) {
- fPartitions.add(partition);
- } else {
- int index = fPartitions.size() - 1;
- BuildConsolePartition last = (BuildConsolePartition)fPartitions.get(index);
- if (last.canBeCombinedWith(partition)) {
- // replace with a single partition
- partition = last.combineWith(partition);
- fPartitions.set(index, partition);
- } else {
- // different kinds - add a new parition
- fPartitions.add(partition);
- }
- }
- return partition;
- }
-
- public IConsole getConsole() {
- return this;
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty() == BuildConsolePreferencePage.PREF_BUILDCONSOLE_LINES) {
- setDocumentSize(BuildConsolePreferencePage.buildConsoleLines());
- }
- }
-
- public void start(final IProject project) {
- Display display = CUIPlugin.getStandardDisplay();
- if (display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
- fLogStream = null;
- fLogURI = null;
- fManager.startConsoleActivity(project);
- }
- });
- }
-
-
- if (BuildConsolePreferencePage.isClearBuildConsole()) {
- appendToDocument("", null, null); //$NON-NLS-1$
- }
- }
-
- public ConsoleOutputStream getOutputStream() throws CoreException {
- return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_OUTPUT));
- }
-
- public ConsoleOutputStream getInfoStream() throws CoreException {
- return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_INFO));
- }
-
- public ConsoleOutputStream getErrorStream() throws CoreException {
- return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_ERROR));
- }
-
- /** This method is useful for future debugging and bug-fixing */
- @SuppressWarnings({ "unused", "nls" })
- private void printDocumentPartitioning() {
- System.out.println("Document partitioning: ");
- for (ITypedRegion tr : fPartitions) {
- BuildConsolePartition p = (BuildConsolePartition) tr;
- int start = p.getOffset();
- int end = p.getOffset() + p.getLength();
- String text;
- String isError = "U";
- String type = p.getType();
- if (type == BuildConsolePartition.ERROR_PARTITION_TYPE) {
- isError = "E";
- } else if (type == BuildConsolePartition.WARNING_PARTITION_TYPE) {
- isError = "W";
- } else if (type == BuildConsolePartition.INFO_PARTITION_TYPE) {
- isError = "I";
- } else if (type == BuildConsolePartition.CONSOLE_PARTITION_TYPE) {
- isError = "C";
- }
- try {
- text = fDocument.get(p.getOffset(), p.getLength());
- } catch (BadLocationException e) {
- text = "N/A";
- }
- if (text.endsWith("\n")) {
- text = text.substring(0, text.length() - 1);
- }
- System.out.println(" " + isError + " " + start + "-" + end + ":[" + text + "]");
- }
- }
-
- /**
- * @return {@link URI} location of log file.
- */
- public URI getLogURI() {
- return fLogURI;
- }
-
- IProject getProject() {
- return fProject;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java
deleted file mode 100644
index 363d1d0..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleStreamDecorator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.swt.graphics.Color;
-
-
-public class BuildConsoleStreamDecorator {
- private BuildConsole fConsole = null;
-
- private Color fColor = null;
-
- /**
- * Constructs a new stream connected to the given console.
- *
- */
- public BuildConsoleStreamDecorator() {
- }
-
- public void setConsole(BuildConsole console) {
- fConsole = console;
- }
-
- /**
- * Sets the color of this message stream
- *
- * @param color color of this message stream, possibly null
- */
- public void setColor(Color color) {
- Color old = fColor;
- fColor = color;
- if (fConsole != null) {
- fConsole.firePropertyChange(this, BuildConsole.P_STREAM_COLOR, old, color);
- }
- }
-
- /**
- * Returns the color of this message stream, or null
- * if default.
- *
- * @return the color of this message stream, or null
- */
- public Color getColor() {
- return fColor;
- }
-
- /**
- * Returns the console this stream is connected to.
- *
- * @return the console this stream is connected to
- */
- public BuildConsole getConsole() {
- return fConsole;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java
deleted file mode 100644
index 7b309e6..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.LineBackgroundEvent;
-import org.eclipse.swt.custom.LineBackgroundListener;
-import org.eclipse.swt.custom.LineStyleEvent;
-import org.eclipse.swt.custom.LineStyleListener;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-public class BuildConsoleViewer extends TextViewer
- implements LineStyleListener,
- LineBackgroundListener,
- MouseTrackListener,
- MouseListener {
-
- protected InternalDocumentListener fInternalDocumentListener = new InternalDocumentListener();
- /**
- * Whether the console scrolls as output is appended.
- */
- private boolean fAutoScroll = true;
- /**
- * Internal document listener.
- */
- class InternalDocumentListener implements IDocumentListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent e) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent e) {
- revealEndOfDocument();
- }
- }
-
- /**
- * Sets whether this viewer should auto-scroll as output is appended to the
- * document.
- *
- * @param scroll
- */
- public void setAutoScroll(boolean scroll) {
- fAutoScroll = scroll;
- }
-
- /**
- * Returns whether this viewer should auto-scroll as output is appended to
- * the document.
- */
- public boolean isAutoScroll() {
- return fAutoScroll;
- }
-
- /**
- * Creates a new console viewer and adds verification checking to only
- * allow text modification if the text is being modified in the editable
- * portion of the underlying document.
- *
- * @see org.eclipse.swt.events.VerifyListener
- */
- public BuildConsoleViewer(Composite parent) {
- super(parent, getSWTStyles());
- StyledText styledText = getTextWidget();
- styledText.addLineStyleListener(this);
- styledText.addLineBackgroundListener(this);
- styledText.addMouseTrackListener(this);
- styledText.setFont(parent.getFont());
- styledText.setDoubleClickEnabled(true);
- styledText.setEditable(false);
- styledText.setWordWrap(true);
- }
-
- /**
- * Returns the SWT style flags used when instantiating this viewer
- */
- private static int getSWTStyles() {
- int styles = SWT.H_SCROLL | SWT.V_SCROLL;
- return styles;
- }
-
- /**
- * Reveals (makes visible) the end of the current document
- */
- protected void revealEndOfDocument() {
- if (isAutoScroll()) {
- IDocument doc = getDocument();
- int lines = doc.getNumberOfLines();
- try {
- // lines are 0-based
- int lineStartOffset = doc.getLineOffset(lines - 1);
- StyledText widget = getTextWidget();
- if (lineStartOffset > 0) {
- widget.setCaretOffset(lineStartOffset);
- widget.showSelection();
- }
- int lineEndOffset = lineStartOffset + doc.getLineLength(lines - 1);
- if (lineEndOffset > 0) {
- widget.setCaretOffset(lineEndOffset);
- }
- } catch (BadLocationException e) {
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.ITextViewer#setDocument(org.eclipse.jface.text.IDocument)
- */
- @Override
- public void setDocument(IDocument doc) {
- IDocument oldDoc = getDocument();
- IDocument document = doc;
- if (oldDoc == null && document == null) {
- return;
- }
- if (oldDoc != null) {
- oldDoc.removeDocumentListener(fInternalDocumentListener);
- if (oldDoc.equals(document)) {
- document.addDocumentListener(fInternalDocumentListener);
- return;
- }
- }
-
- super.setDocument(document);
- if (document != null) {
- revealEndOfDocument();
- document.addDocumentListener(fInternalDocumentListener);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent)
- */
- public void lineGetStyle(LineStyleEvent event) {
- IDocument document = getDocument();
- if (document == null) return;
- BuildConsolePartitioner partitioner = (BuildConsolePartitioner) document.getDocumentPartitioner();
- if (partitioner == null) return;
-
- BuildConsolePartition p = partitioner.fDocumentMarkerManager.getCurrentPartition();
- Color problemHighlightedColor = partitioner.fManager.getProblemHighlightedColor();
-
- // Note, computePartitioning actually doesn't change anything in partitioning,
- // but only computes number of affected regions.
- ITypedRegion[] regions = partitioner.computePartitioning(event.lineOffset, event.lineText.length());
- StyleRange[] styles = new StyleRange[regions.length];
- for (int i = 0; i < regions.length; i++) {
- BuildConsolePartition partition = (BuildConsolePartition) regions[i];
- if (partition.getStream()== null) return;
-
- Color colorFG = partition.getStream().getColor();
- Color colorBG = null;
-
- // Highlight current partition
- if ( partition == p ) {
- colorFG = problemHighlightedColor;
- }
- StyleRange styleRange = new StyleRange(partition.getOffset(), partition.getLength(), colorFG, colorBG);
- styles[i] = styleRange;
- }
- event.styles = styles;
- }
-
- public void selectPartition(BuildConsolePartitioner partitioner, BuildConsolePartition p) {
- try {
- int start = partitioner.getDocument().getLineOfOffset(p.getOffset());
- int end = partitioner.getDocument().getLineOfOffset(p.getOffset()+p.getLength()-1);
-
- if ( fAutoScroll ) {
- // Check if area around this line is visible, scroll if needed
- int top = getTopIndex();
- int bottom = getBottomIndex();
- if ( start < top + 1 ) {
- setTopIndex(start - 1 > 0 ? start - 1 : 0);
- } else if ( end > bottom -1 ) {
- setTopIndex(top + start - bottom + 1);
- }
- }
-
- // Select line
- StyledText st = getTextWidget();
- st.redrawRange(0, partitioner.getDocument().getLength(), true);
-
- } catch (BadLocationException e) {
- CUIPlugin.log(e);
- }
- }
-
- public void mouseEnter(MouseEvent e) {
- getTextWidget().addMouseListener(this);
- }
-
- public void mouseExit(MouseEvent e) {
- getTextWidget().removeMouseListener(this);
- }
-
- public void mouseHover(MouseEvent e) {
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- int offset = -1;
- try {
- Point p = new Point(e.x, e.y);
- offset = getTextWidget().getOffsetAtLocation(p);
- BuildConsole.getCurrentPage().moveToError(offset);
- } catch (IllegalArgumentException ex) {
- }
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void lineGetBackground(LineBackgroundEvent event) {
- IDocument document = getDocument();
- if (document == null) return;
- BuildConsolePartitioner partitioner = (BuildConsolePartitioner) document.getDocumentPartitioner();
- if (partitioner == null) return;
-
- BuildConsolePartition partition = (BuildConsolePartition) partitioner.getPartition(event.lineOffset);
- // Set background for error partitions
- if (partition!=null) {
- String type = partition.getType();
- if (type==BuildConsolePartition.ERROR_PARTITION_TYPE) {
- event.lineBackground = partitioner.fManager.getProblemBackgroundColor();
- } else if (type==BuildConsolePartition.WARNING_PARTITION_TYPE) {
- event.lineBackground = partitioner.fManager.getWarningBackgroundColor();
- } else if (type==BuildConsolePartition.INFO_PARTITION_TYPE) {
- event.lineBackground = partitioner.fManager.getInfoBackgroundColor();
- }
- }
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java
deleted file mode 100644
index a5ce089..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildOutputStream.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- * Alex Collins (Broadcom Corp.) - Global build console
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.io.IOException;
-
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.ProblemMarkerInfo;
-
-import org.eclipse.cdt.internal.core.IErrorMarkeredOutputStream;
-
-/**
- * Output stream which put all output to BuildConsolePartitioner
- * and informs it when stream is closed
- */
-public class BuildOutputStream extends ConsoleOutputStream implements IErrorMarkeredOutputStream {
-
- final BuildConsoleStreamDecorator fStream;
- private BuildConsolePartitioner fPartitioner;
-
- public BuildOutputStream(BuildConsolePartitioner partitioner,
- BuildConsoleStreamDecorator stream) {
- fPartitioner = partitioner;
- if (fPartitioner.getProject() == null)
- // Note: The global console log stream should have been
- // opened by BuildConsoleManager.startGlobalConsole()
- fPartitioner.setStreamAppend();
- else
- fPartitioner.setStreamOpened();
- fStream = stream;
- }
-
- @Override
- public void flush() throws IOException {
- }
-
- @Override
- public void close() throws IOException {
- flush();
- fPartitioner.setStreamClosed();
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- fPartitioner.appendToDocument(new String(b, off, len), fStream, null);
- }
-
- public void write(String s, ProblemMarkerInfo marker) throws IOException {
- fPartitioner.appendToDocument(s, fStream, marker);
-
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java
deleted file mode 100644
index fb49394..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CBuildConsole.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.net.URL;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-
-import org.eclipse.cdt.internal.core.ICConsole;
-
-/**
- * CDT console adaptor providing output streams. The adaptor provides means of
- * access to UI plugin console.
- */
-public class CBuildConsole implements ICConsole {
- IProject project;
- IBuildConsoleManager fConsoleManager;
-
- /**
- * Constructor for BuildConsole.
- */
- public CBuildConsole() {
- }
-
- public void init(String contextId, String name, URL iconUrl) {
- if (contextId==null)
- fConsoleManager = CUIPlugin.getDefault().getConsoleManager();
- else
- fConsoleManager = CUIPlugin.getDefault().getConsoleManager(name, contextId, iconUrl); // careful with order of arguments
- }
-
- /**
- * Start the console for a given project.
- *
- * @param project - the project to start the console.
- */
- public void start(IProject project) {
- this.project = project;
- fConsoleManager.getConsole(project).start(project);
- }
-
- /**
- * @throws CoreException
- * @see org.eclipse.cdt.core.resources.IConsole#getOutputStream()
- */
- public ConsoleOutputStream getOutputStream() throws CoreException {
- Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First);
- return fConsoleManager.getConsole(project).getOutputStream();
- }
-
- public ConsoleOutputStream getInfoStream() throws CoreException {
- Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First);
- return fConsoleManager.getConsole(project).getInfoStream();
- }
-
- public ConsoleOutputStream getErrorStream() throws CoreException {
- Assert.isNotNull(project, ConsoleMessages.CBuildConsole_Console_Must_Be_Started_First);
- return fConsoleManager.getConsole(project).getErrorStream();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java
deleted file mode 100644
index fd84976..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleEvent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.util.EventObject;
-
-import org.eclipse.cdt.ui.IBuildConsoleEvent;
-import org.eclipse.core.resources.IProject;
-
-public class ConsoleEvent extends EventObject implements IBuildConsoleEvent {
-
- /**
- * Comment for serialVersionUID
- */
- private static final long serialVersionUID = 1L;
-
- private IProject fProject;
- private int fType;
-
- public ConsoleEvent(Object source, IProject project, int type) {
- super(source);
- fProject = project;
- fType = type;
- }
-
- public IProject getProject() {
- return fProject;
- }
-
- public int getType() {
- return fType;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java
deleted file mode 100644
index a30e5a5..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
- * Save build output
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class ConsoleMessages extends NLS {
-
- static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.buildconsole.ConsoleMessages";//$NON-NLS-1$
-
- private ConsoleMessages() {
- // Do not instantiate
- }
-
- public static String BuildConsole_GlobalConsole;
- public static String find_replace_action_label;
- public static String find_replace_action_tooltip;
- public static String find_replace_action_image;
- public static String find_replace_action_description;
- public static String BuildConsolePage__Copy_Ctrl_C_6;
- public static String BuildConsolePage_Copy_7;
- public static String BuildConsolePage_Select__All_Ctrl_A_12;
- public static String BuildConsolePage_Select_All;
- public static String ScrollLockAction_Scroll_Lock_1;
- public static String PreviousErrorAction_Tooltip;
- public static String NextErrorAction_Tooltip;
- public static String ShowErrorAction_Tooltip;
- public static String CBuildConsole_Console_Must_Be_Started_First;
- public static String CopyLog_ActionTooltip;
- public static String CopyLog_BuildNotLogged;
- public static String CopyLog_ChooseDestination;
- public static String CopyLog_ErrorCopyingFile;
- public static String CopyLog_ErrorWhileCopyingLog;
- public static String CopyLog_InvalidDestination;
- public static String CopyLog_LogFileIsNotAvailable;
- public static String CopyLog_UnableToAccess;
- public static String CopyLog_UnavailableLog;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties
deleted file mode 100644
index cc5b532..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleMessages.properties
+++ /dev/null
@@ -1,40 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2010 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
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# QNX Software Systems - Initial API and implementation
-# IBM Corporation
-###############################################################################
-
-BuildConsole_GlobalConsole=CDT Global Build Console
-
-find_replace_action_label=&Find/Replace...@Ctrl+F
-find_replace_action_tooltip=Find/Replace
-find_replace_action_image=
-find_replace_action_description=Find/Replace
-
-BuildConsolePage__Copy_Ctrl_C_6=&Copy@Ctrl+C
-BuildConsolePage_Copy_7=Copy
-BuildConsolePage_Select__All_Ctrl_A_12=Select &All@Ctrl+A
-BuildConsolePage_Select_All=Select All
-
-CBuildConsole_Console_Must_Be_Started_First=Build Console must be started with a specific project before being used.
-CopyLog_ActionTooltip=Copy Build Log
-CopyLog_BuildNotLogged=No build was logged. Build the project or/and check the Logging page in project properties.
-CopyLog_ChooseDestination=Choose Log File Destination
-CopyLog_ErrorCopyingFile=Error Copying a File
-CopyLog_ErrorWhileCopyingLog=Error while copying working log file:
-CopyLog_InvalidDestination=Destination is not valid:
-CopyLog_LogFileIsNotAvailable=Working log file is not available.
-CopyLog_UnableToAccess=Unable to access build log at
-CopyLog_UnavailableLog=Unavailable Log
-
-ScrollLockAction_Scroll_Lock_1=Scroll Lock
-
-NextErrorAction_Tooltip=Next Error
-PreviousErrorAction_Tooltip=Previous Error
-ShowErrorAction_Tooltip=Show Error In Editor
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java
deleted file mode 100644
index a1798f6..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ConsoleOutputTextStore.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.jface.text.ITextStore;
-
-public class ConsoleOutputTextStore implements ITextStore {
-
- private StringBuffer fBuffer;
-
- public ConsoleOutputTextStore(int bufferSize) {
- fBuffer = new StringBuffer(bufferSize);
- }
-
- /**
- * @see ITextStore#get(int)
- */
- public char get(int pos) {
- return fBuffer.charAt(pos);
- }
-
- /**
- * @see ITextStore#get(int, int)
- */
- public String get(int pos, int length) {
- return fBuffer.substring(pos, pos + length);
- }
-
- /**
- * @see ITextStore#getLength()
- */
- public int getLength() {
- return fBuffer.length();
- }
-
- /**
- * @see ITextStore#replace(int, int, String)
- */
- public void replace(int pos, int length, String text) {
- if (text == null) {
- text = ""; //$NON-NLS-1$
- }
- fBuffer.replace(pos, pos + length, text);
- }
-
- /**
- * @see ITextStore#set(String)
- */
- public void set(String text) {
- fBuffer = new StringBuffer(text);
- }
-
- /**
- * @see StringBuffer#ensureCapacity(int)
- */
- public void setMinimalBufferSize(int bufferSize) {
- fBuffer.ensureCapacity(bufferSize);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java
deleted file mode 100644
index 31bc00b..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/CopyBuildLogAction.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Andrew Gvozdev 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:
- * Andrew Gvozdev (Quoin Inc.) - Initial API and implementation
- * Alex Collins (Broadcom Corp.) - Global console
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.net.URI;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.core.filesystem.IFileStore;
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.core.resources.ResourcesUtil;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-
-/**
- * Action to copy build log from working file to a user selected file.
- */
-public class CopyBuildLogAction extends Action {
- private BuildConsolePage fConsolePage;
-
- public CopyBuildLogAction(BuildConsolePage page) {
- super();
- setToolTipText(ConsoleMessages.CopyLog_ActionTooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SAVE_CONSOLE);
- fConsolePage = page;
- }
-
- @Override
- public void run() {
- IBuildConsoleManager consoleManager = fConsolePage.getConsole().getConsoleManager();
- IProject project = fConsolePage.getProject();
- IConsole console = consoleManager.getProjectConsole(project);
-
- Shell shell = Display.getCurrent().getActiveShell();
-
- if (console instanceof BuildConsolePartitioner) {
- URI srcURI = ((BuildConsolePartitioner)console).getLogURI();
- if (srcURI==null) {
- MessageDialog.openWarning(shell, ConsoleMessages.CopyLog_UnavailableLog,
- ConsoleMessages.CopyLog_BuildNotLogged);
- return;
- }
-
- IFileStore srcStore = null;
- try {
- srcStore = EFS.getStore(srcURI);
- } catch (CoreException e) {
- CUIPlugin.log(e);
- MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
- ConsoleMessages.CopyLog_UnableToAccess+srcURI);
- return;
- }
-
- if (!srcStore.fetchInfo().exists()) {
- MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
- ConsoleMessages.CopyLog_LogFileIsNotAvailable);
- return;
- }
-
- // open file dialog
- FileDialog dialog = new FileDialog(shell, SWT.NONE);
- dialog.setText(ConsoleMessages.CopyLog_ChooseDestination);
-
- String destLocation = dialog.open();
- if (destLocation!=null) {
- URI destURI = URIUtil.toURI(destLocation);
- if (destURI==null) {
- MessageDialog.openError(shell, ConsoleMessages.CopyLog_UnavailableLog,
- ConsoleMessages.CopyLog_InvalidDestination+destLocation);
- return;
- }
- try {
- IFileStore destStore = EFS.getStore(destURI);
- srcStore.copy(destStore, EFS.OVERWRITE, null);
- } catch (CoreException e) {
- CUIPlugin.log(e);
- MessageDialog.openError(shell, ConsoleMessages.CopyLog_ErrorCopyingFile,
- ConsoleMessages.CopyLog_ErrorWhileCopyingLog+e.getLocalizedMessage());
- } finally {
- ResourcesUtil.refreshWorkspaceFiles(destURI);
- }
- }
- } else {
- MessageDialog.openWarning(shell, ConsoleMessages.CopyLog_UnavailableLog,
- ConsoleMessages.CopyLog_BuildNotLogged);
- }
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java
deleted file mode 100644
index 5819976..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 CodeSourcery 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:
- * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.jface.text.ITypedRegion;
-
-import org.eclipse.cdt.core.ProblemMarkerInfo;
-
-/**
- * Manages current position of highlighted error in BuildConsole
- */
-class DocumentMarkerManager {
-
- BuildConsoleDocument fDocument;
- BuildConsolePartitioner fPartitioner;
-
- int highlightedPartitionIndex = -1;
-
- DocumentMarkerManager(BuildConsoleDocument document, BuildConsolePartitioner partitioner) {
- fDocument = document;
- fPartitioner = partitioner;
- }
-
- /** Increment index */
- void moveToNextError() {
- if ( fPartitioner.fPartitions.size() == 0 ) return;
- if ( highlightedPartitionIndex == -1 ) {
- moveToFirstError();
- return;
- }
- int i = highlightedPartitionIndex + 1;
- do {
- if ( i == fPartitioner.fPartitions.size() ) {
- i = 0;
- }
- String type = fPartitioner.fPartitions.get(i).getType();
- if (BuildConsolePartition.isProblemPartitionType(type)) {
- highlightedPartitionIndex = i;
- return;
- } else {
- i++;
- }
- } while ( highlightedPartitionIndex != i);
- }
-
- /** Decrement index */
- void moveToPreviousError() {
- if ( fPartitioner.fPartitions.size() == 0 ) return;
- if ( highlightedPartitionIndex == -1 ) {
- moveToFirstError();
- return;
- }
-
- int i = highlightedPartitionIndex - 1;
- do {
- if ( i == -1 ) {
- i = fPartitioner.fPartitions.size() - 1;
- }
- String type = fPartitioner.fPartitions.get(i).getType();
- if (BuildConsolePartition.isProblemPartitionType(type)) {
- highlightedPartitionIndex = i;
- return;
- } else {
- i--;
- }
- } while ( highlightedPartitionIndex != i);
- }
-
- void moveToFirstError() {
- for (int i=0; i0) {
- logURI = URIUtil.toURI(strLocation);
- }
- if (logURI==null) {
- IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,"Can't determine URI for location=["+strLocation+"]"); //$NON-NLS-1$ //$NON-NLS-2$
- CUIPlugin.log(status);
- }
- }
- return logURI;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java
deleted file mode 100644
index 86769c0..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/MultiBuildConsoleAdapter.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Broadcom 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alex Collins (Broadcom Corp.)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.cdt.core.ConsoleOutputStream;
-import org.eclipse.cdt.core.ProblemMarkerInfo;
-import org.eclipse.cdt.core.resources.IConsole;
-
-import org.eclipse.cdt.internal.core.IErrorMarkeredOutputStream;
-
-/**
- * Adapter that wraps a project console and the global console to allow builders
- * to send their build output to a single IConsole object
- */
-class MultiBuildConsoleAdapter implements IConsole {
-
- private final IConsole fProjectConsole;
- private final IConsole fGlobalConsole;
-
- private static class BuildOutputStreamAdapter extends ConsoleOutputStream implements IErrorMarkeredOutputStream {
- private final BuildOutputStream one;
- private final BuildOutputStream two;
-
- public BuildOutputStreamAdapter(BuildOutputStream one, BuildOutputStream two) {
- this.one = one;
- this.two = two;
- }
-
- @Override
- public synchronized String readBuffer() {
- return one.readBuffer();
- }
-
- @Override
- public synchronized void write(int c) throws IOException {
- one.write(c);
- two.write(c);
- }
-
- @Override
- public synchronized void write(byte[] b, int off, int len) throws IOException {
- one.write(b, off, len);
- two.write(b, off, len);
- }
-
- public void write(String s, ProblemMarkerInfo marker) throws IOException {
- one.write(s, marker);
- two.write(s, marker);
- }
-
- @Override
- public void close() throws IOException {
- one.flush();
- two.flush();
- one.close();
- two.close();
- }
-
- }
-
- public MultiBuildConsoleAdapter(IConsole projectConsole, IConsole globalConsole) {
- fProjectConsole = projectConsole;
- fGlobalConsole = globalConsole;
- }
-
- public void start(IProject project) {
- fProjectConsole.start(project);
- }
-
- public ConsoleOutputStream getOutputStream() throws CoreException {
- return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getOutputStream(), (BuildOutputStream)fGlobalConsole.getOutputStream());
- }
-
- public ConsoleOutputStream getInfoStream() throws CoreException {
- return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getInfoStream(), (BuildOutputStream)fGlobalConsole.getInfoStream());
- }
-
- public ConsoleOutputStream getErrorStream() throws CoreException {
- return new BuildOutputStreamAdapter((BuildOutputStream)fProjectConsole.getErrorStream(), (BuildOutputStream)fGlobalConsole.getErrorStream());
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java
deleted file mode 100644
index 1fb0c0b..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/NextErrorAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 CodeSourcery 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:
- * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-
-/**
- * Advance console document to the next error reported by compiler
- */
-public class NextErrorAction extends Action {
-
- private BuildConsolePage fConsolePage;
-
- public NextErrorAction(BuildConsolePage page) {
- super(ConsoleMessages.NextErrorAction_Tooltip);
- fConsolePage = page;
- setEnabled(true);
- setToolTipText(ConsoleMessages.NextErrorAction_Tooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- @Override
- public void run() {
- fConsolePage.moveToError(BuildConsolePage.POSITION_NEXT);
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java
deleted file mode 100644
index 1c42bfa..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/PreviousErrorAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 CodeSourcery 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:
- * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
- * IBM Corporation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-
-/**
- * Retard console document to the previous error reported by compiler
- */
-public class PreviousErrorAction extends Action {
-
- private BuildConsolePage fConsolePage;
-
- public PreviousErrorAction(BuildConsolePage page) {
- super(ConsoleMessages.PreviousErrorAction_Tooltip);
- fConsolePage = page;
- setEnabled(true);
- setToolTipText(ConsoleMessages.PreviousErrorAction_Tooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- @Override
- public void run() {
- fConsolePage.moveToError(BuildConsolePage.POSITION_PREV);
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java
deleted file mode 100644
index b0a821e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ScrollLockAction.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.jface.action.Action;
-
-/**
- * Toggles console auto-scroll
- */
-
-public class ScrollLockAction extends Action {
-
- private BuildConsoleViewer fConsoleViewer;
-
- public ScrollLockAction(BuildConsoleViewer viewer) {
- super(ConsoleMessages.ScrollLockAction_Scroll_Lock_1);
- fConsoleViewer = viewer;
- setToolTipText(ConsoleMessages.ScrollLockAction_Scroll_Lock_1);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_SCROLL_LOCK);
- setChecked(false);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- @Override
- public void run() {
- fConsoleViewer.setAutoScroll(!isChecked());
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java
deleted file mode 100644
index 7fbd327..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/ShowErrorAction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 CodeSourcery 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:
- * Dmitry Kozlov (CodeSourcery) - Initial API and implementation
- * Alex Collins (Broadcom Corp.)
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.buildconsole;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-import org.eclipse.cdt.core.resources.IConsole;
-import org.eclipse.cdt.ui.IBuildConsoleManager;
-
-/**
- * Set whether to show error in editor when moving to next/prev error in Build Console
- */
-public class ShowErrorAction extends Action {
-
- private BuildConsolePage fConsolePage;
-
- public ShowErrorAction(BuildConsolePage page) {
- super(ConsoleMessages.ShowErrorAction_Tooltip);
- fConsolePage = page;
- setChecked(true);
- setToolTipText(ConsoleMessages.ShowErrorAction_Tooltip);
- ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
- setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED));
- setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_SYNCED_DISABLED));
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- @Override
- public void run() {
- super.run();
- if (isChecked()) {
- IBuildConsoleManager consoleManager = fConsolePage.getConsole().getConsoleManager();
- IProject project = fConsolePage.getProject();
- IConsole console = consoleManager.getProjectConsole(project);
- if (console instanceof BuildConsolePartitioner) {
- BuildConsolePartitioner par = (BuildConsolePartitioner)console;
- fConsolePage.showError(par, true);
- }
- }
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java
deleted file mode 100644
index d058116..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CElementSet.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
-
-public class CElementSet {
- private Set fSet= new LinkedHashSet();
- private int fHashCode;
-
- CElementSet( ICElement[] elements) {
- fSet.addAll(Arrays.asList(elements));
- fHashCode= 0;
- for (int i = 0; i < elements.length; i++) {
- fHashCode = 31*fHashCode + elements[i].hashCode();
- }
- }
-
- @Override
- public int hashCode() {
- return fHashCode;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final CElementSet other = (CElementSet) obj;
- if (fHashCode != other.fHashCode) {
- return false;
- }
- if (fSet == null) {
- if (other.fSet != null) {
- return false;
- }
- }
- else {
- if (fSet.size() != other.fSet.size()) {
- return false;
- }
- for (Iterator iter = fSet.iterator(); iter.hasNext(); ) {
- if (!other.fSet.contains(iter.next())) {
- return false;
- }
- }
- }
- return true;
- }
-
- public boolean isEmpty() {
- return fSet.isEmpty();
- }
-
- public ICElement[] getElements(WorkingSetFilterUI filter) {
- ArrayList result= new ArrayList(fSet.size());
- for (Iterator iter = fSet.iterator(); iter.hasNext(); ) {
- ICElement element = iter.next();
- if (filter == null || filter.isPartOfWorkingSet(element)) {
- result.add(element);
- }
- }
- return result.toArray(new ICElement[result.size()]);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
deleted file mode 100644
index ddbc224..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHContentProvider.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IEnumerator;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexFile;
-import org.eclipse.cdt.core.index.IIndexName;
-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.IMethod;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IVariable;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.corext.util.CModelUtil;
-
-import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
-import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
-
-/**
- * This is the content provider for the call hierarchy.
- */
-public class CHContentProvider extends AsyncTreeContentProvider {
-
- private static final IProgressMonitor NPM = new NullProgressMonitor();
- private boolean fComputeReferencedBy = true;
- private WorkingSetFilterUI fFilter;
- private CHViewPart fView;
-
- /**
- * Constructs the content provider.
- */
- public CHContentProvider(CHViewPart view, Display disp) {
- super(disp);
- fView= view;
- }
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof CHNode) {
- CHNode node = (CHNode) element;
- return node.getParent();
- }
- return super.getParent(element);
- }
-
- @Override
- protected Object[] syncronouslyComputeChildren(Object parentElement) {
- if (parentElement instanceof CHMultiDefNode) {
- return ((CHMultiDefNode) parentElement).getChildNodes();
- }
- if (parentElement instanceof CHNode) {
- CHNode node = (CHNode) parentElement;
- if (node.isRecursive() || node.getRepresentedDeclaration() == null) {
- return NO_CHILDREN;
- }
- if (fComputeReferencedBy) {
- if (node.isInitializer()) {
- return NO_CHILDREN;
- }
- }
- else if (node.isVariableOrEnumerator() || node.isMacro()) {
- return NO_CHILDREN;
- }
-
- }
- // allow for async computation
- return null;
- }
-
- @Override
- protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
- try {
- if (parentElement instanceof ICElement) {
- return asyncComputeRoot((ICElement) parentElement);
- }
-
- if (parentElement instanceof CHNode) {
- CHNode node = (CHNode) parentElement;
- if (fComputeReferencedBy) {
- return asyncronouslyComputeReferencedBy(node);
- }
- return asyncronouslyComputeRefersTo(node);
- }
- } catch (CoreException e) {
- CUIPlugin.log(e);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- return NO_CHILDREN;
- }
-
- private Object[] asyncComputeRoot(final ICElement input) throws CoreException, InterruptedException {
- IIndex index= CCorePlugin.getIndexManager().getIndex(input.getCProject());
- index.acquireReadLock();
- try {
- ICElement element= input;
- if (!IndexUI.isIndexed(index, input)) {
- getDisplay().asyncExec(new Runnable() {
- public void run() {
- fView.reportNotIndexed(input);
- }
- });
- }
- else {
- element= IndexUI.attemptConvertionToHandle(index, input);
- final ICElement finalElement= element;
- getDisplay().asyncExec(new Runnable() {
- public void run() {
- fView.reportInputReplacement(input, finalElement);
- }
- });
- }
- ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
- if (!fComputeReferencedBy && element instanceof IMethod) {
- IIndexName methodName= IndexUI.elementToName(index, element);
- if (methodName != null) {
- IBinding methodBinding= index.findBinding(methodName);
- if (methodBinding instanceof ICPPMethod) {
- ICElement[] defs= CHQueries.findOverriders(index, (ICPPMethod) methodBinding);
- if (defs != null && defs.length > 0) {
- return new Object[] { new CHMultiDefNode(null, tu, 0, defs, methodBinding.getLinkage().getLinkageID()) };
- }
- }
- }
- }
- return new Object[] { new CHNode(null, tu, 0, element, -1) };
- }
- finally {
- index.releaseReadLock();
- }
- }
-
- private Object[] asyncronouslyComputeReferencedBy(CHNode parent) throws CoreException, InterruptedException {
- ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
- index.acquireReadLock();
- try {
- return CHQueries.findCalledBy(this, parent, index, NPM);
- }
- finally {
- index.releaseReadLock();
- }
- }
-
- private Object[] asyncronouslyComputeRefersTo(CHNode parent) throws CoreException, InterruptedException {
- ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
- IIndex index= CCorePlugin.getIndexManager().getIndex(scope);
- index.acquireReadLock();
- try {
- return CHQueries.findCalls(this, parent, index, NPM);
- }
- finally {
- index.releaseReadLock();
- }
- }
-
- public void setComputeReferencedBy(boolean value) {
- fComputeReferencedBy = value;
- }
-
- public boolean getComputeReferencedBy() {
- return fComputeReferencedBy;
- }
-
- public void setWorkingSetFilter(WorkingSetFilterUI filterUI) {
- fFilter= filterUI;
- recompute();
- }
-
- CHNode[] createNodes(CHNode node, CalledByResult result) throws CoreException {
- ArrayList nodes= new ArrayList();
- ICElement[] elements= result.getElements();
- for (ICElement element : elements) {
- if (element != null) {
- if (fFilter == null || fFilter.isPartOfWorkingSet(element)) {
- IIndexName[] refs= result.getReferences(element);
- if (refs != null && refs.length > 0) {
- CHNode newNode = createRefbyNode(node, element, refs);
- nodes.add(newNode);
- }
- }
- }
- }
- return nodes.toArray(new CHNode[nodes.size()]);
- }
-
- private CHNode createRefbyNode(CHNode parent, ICElement element, IIndexName[] refs) throws CoreException {
- ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
- final IIndexFile file = refs[0].getFile();
- CHNode node= new CHNode(parent, tu, file.getTimestamp(), element, file.getLinkageID());
- if (element instanceof IVariable || element instanceof IEnumerator) {
- node.setInitializer(true);
- }
- boolean readAccess= false;
- boolean writeAccess= false;
- for (IIndexName reference : refs) {
- node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
- readAccess= (readAccess || reference.isReadAccess());
- writeAccess= (writeAccess || reference.isWriteAccess());
- }
- node.setRWAccess(readAccess, writeAccess);
- node.sortReferencesByOffset();
- return node;
- }
-
- CHNode[] createNodes(CHNode node, CallsToResult callsTo) throws CoreException {
- ITranslationUnit tu= CModelUtil.getTranslationUnit(node.getRepresentedDeclaration());
- ArrayList result= new ArrayList();
- CElementSet[] elementSets= callsTo.getElementSets();
- for (CElementSet elementSet : elementSets) {
- CElementSet set = elementSet;
- if (!set.isEmpty()) {
- IIndexName[] refs= callsTo.getReferences(set);
- ICElement[] elements= set.getElements(fFilter);
- if (elements.length > 0) {
- CHNode childNode = createReftoNode(node, tu, elements, refs);
- result.add(childNode);
- }
- }
- }
- return result.toArray(new CHNode[result.size()]);
- }
-
- private CHNode createReftoNode(CHNode parent, ITranslationUnit tu, ICElement[] elements, IIndexName[] references) throws CoreException {
- assert elements.length > 0;
-
- final IIndexFile file = references[0].getFile();
- final long timestamp= file.getTimestamp();
- final int linkageID= file.getLinkageID();
-
- CHNode node;
- if (elements.length == 1) {
- node= new CHNode(parent, tu, timestamp, elements[0], linkageID);
- } else {
- node= new CHMultiDefNode(parent, tu, timestamp, elements, linkageID);
- }
-
- boolean readAccess= false;
- boolean writeAccess= false;
- for (IIndexName reference : references) {
- node.addReference(new CHReferenceInfo(reference.getNodeOffset(), reference.getNodeLength()));
- readAccess= (readAccess || reference.isReadAccess());
- writeAccess= (writeAccess || reference.isWriteAccess());
- }
- node.sortReferencesByOffset();
- node.setRWAccess(readAccess, writeAccess);
- return node;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java
deleted file mode 100644
index 7e5eab7..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHDropTargetListener.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.DropTargetListener;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-
-public class CHDropTargetListener implements DropTargetListener {
-
- private CHViewPart fCallHierarchy;
- private ICElement fInput;
- private boolean fEnabled= true;
-
- public CHDropTargetListener(CHViewPart view) {
- fCallHierarchy= view;
- }
-
- public void setEnabled(boolean val) {
- fEnabled= val;
- }
-
- public void dragEnter(DropTargetEvent event) {
- fInput= null;
- checkOperation(event);
- if (event.detail != DND.DROP_NONE) {
- if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
- fInput= checkLocalSelection();
- if (!CallHierarchyUI.isRelevantForCallHierarchy(fInput)) {
- event.detail= DND.DROP_NONE;
- fInput= null;
- }
- }
- }
- }
-
- private ICElement checkLocalSelection() {
- ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
- if (sel instanceof IStructuredSelection) {
- for (Iterator> iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (element instanceof ICElement) {
- return (ICElement) element;
- }
- if (element instanceof IAdaptable) {
- ICElement adapter= (ICElement) ((IAdaptable) element).getAdapter(ICElement.class);
- if (adapter != null) {
- return adapter;
- }
- }
- }
- }
- return null;
- }
-
- public void dragLeave(DropTargetEvent event) {
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- checkOperation(event);
- }
-
- public void dragOver(DropTargetEvent event) {
- }
-
- public void drop(DropTargetEvent event) {
- if (fInput == null) {
- Display.getCurrent().beep();
- }
- else {
- fCallHierarchy.setInput(fInput);
- }
- }
-
- public void dropAccept(DropTargetEvent event) {
- }
-
- private void checkOperation(DropTargetEvent event) {
- if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
- event.detail= DND.DROP_COPY;
- }
- else {
- event.detail= DND.DROP_NONE;
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java
deleted file mode 100644
index 1d6c952..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-
-
-/**
- * Action used for the include browser forward / backward buttons
- */
-public class CHHistoryAction extends Action {
- final static long LABEL_OPTIONS=
- CElementLabels.M_PARAMETER_TYPES |
- CElementLabels.ALL_FULLY_QUALIFIED |
- CElementLabels.TEMPLATE_ARGUMENTS |
- CElementLabels.MF_POST_FILE_QUALIFIED;
-
- private CHViewPart fViewPart;
- private ICElement fElement;
-
- public CHHistoryAction(CHViewPart viewPart, ICElement element) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- fViewPart= viewPart;
- fElement= element;
-
- String elementName= CElementLabels.getElementLabel(element, LABEL_OPTIONS);
- setText(elementName);
- setImageDescriptor(getImageDescriptor(element));
- }
-
- private ImageDescriptor getImageDescriptor(ICElement elem) {
- CElementImageProvider imageProvider= new CElementImageProvider();
- ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
- imageProvider.dispose();
- return desc;
- }
-
- /*
- * @see Action#run()
- */
- @Override
- public void run() {
- fViewPart.setInput(fElement);
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java
deleted file mode 100644
index c732d41..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryDropDownAction.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-
-public class CHHistoryDropDownAction extends Action implements IMenuCreator {
-
- public static class ClearHistoryAction extends Action {
-
- private CHViewPart fView;
-
- public ClearHistoryAction(CHViewPart view) {
- super(CHMessages.CHHistoryDropDownAction_ClearHistory_label);
- fView= view;
- }
-
- @Override
- public void run() {
- fView.setHistoryEntries(new ICElement[0]);
- fView.setInput(null);
- }
- }
-
- public static final int RESULTS_IN_DROP_DOWN= 10;
-
- private CHViewPart fHierarchyView;
- private Menu fMenu;
-
- public CHHistoryDropDownAction(CHViewPart view) {
- fHierarchyView= view;
- fMenu= null;
- setToolTipText(CHMessages.CHHistoryDropDownAction_ShowHistoryList_tooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
- setMenuCreator(this);
- }
-
- public void dispose() {
- // action is reused, can be called several times.
- if (fMenu != null) {
- fMenu.dispose();
- fMenu= null;
- }
- }
-
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- public Menu getMenu(Control parent) {
- if (fMenu != null) {
- fMenu.dispose();
- }
- fMenu= new Menu(parent);
- ICElement[] elements= fHierarchyView.getHistoryEntries();
- addEntries(fMenu, elements);
- new MenuItem(fMenu, SWT.SEPARATOR);
- addActionToMenu(fMenu, new CHHistoryListAction(fHierarchyView));
- addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
- return fMenu;
- }
-
- private boolean addEntries(Menu menu, ICElement[] elements) {
- boolean checked= false;
-
- int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
- for (int i= 0; i < min; i++) {
- CHHistoryAction action= new CHHistoryAction(fHierarchyView, elements[i]);
- action.setChecked(elements[i].equals(fHierarchyView.getInput()));
- checked= checked || action.isChecked();
- addActionToMenu(menu, action);
- }
-
-
- return checked;
- }
-
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- @Override
- public void run() {
- (new CHHistoryListAction(fHierarchyView)).run();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java
deleted file mode 100644
index ba2d6a8..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
-
-public class CHHistoryListAction extends Action {
-
- private class HistoryListDialog extends StatusDialog {
- private ListDialogField fHistoryList;
- private IStatus fHistoryStatus;
- private ICElement fResult;
-
- private HistoryListDialog(Shell shell, ICElement[] historyEntries) {
- super(shell);
- setHelpAvailable(false);
- setTitle(CHMessages.CHHistoryListAction_HistoryDialog_title);
- String[] buttonLabels= new String[] {
- CHMessages.CHHistoryListAction_Remove_label,
- };
-
- IListAdapter adapter= new IListAdapter() {
- public void customButtonPressed(ListDialogField field, int index) {
- doCustomButtonPressed();
- }
- public void selectionChanged(ListDialogField field) {
- doSelectionChanged();
- }
-
- public void doubleClicked(ListDialogField field) {
- doDoubleClicked();
- }
- };
-
- ILabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
-
- fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
- fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label);
- fHistoryList.setElements(Arrays.asList(historyEntries));
-
- ISelection sel;
- if (historyEntries.length > 0) {
- sel= new StructuredSelection(historyEntries[0]);
- } else {
- sel= new StructuredSelection();
- }
-
- fHistoryList.selectElements(sel);
- }
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setFont(parent.getFont());
-
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
- LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
- LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null), true);
-
- applyDialogFont(composite);
- return composite;
- }
-
- /**
- * Method doCustomButtonPressed.
- */
- private void doCustomButtonPressed() {
- fHistoryList.removeElements(fHistoryList.getSelectedElements());
- }
-
- private void doDoubleClicked() {
- if (fHistoryStatus.isOK()) {
- okPressed();
- }
- }
-
- private void doSelectionChanged() {
- StatusInfo status= new StatusInfo();
- List selected= fHistoryList.getSelectedElements();
- if (selected.size() != 1) {
- status.setError(""); //$NON-NLS-1$
- fResult= null;
- } else {
- fResult= selected.get(0);
- }
- fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
- fHistoryStatus= status;
- updateStatus(status);
- }
-
- public ICElement getResult() {
- return fResult;
- }
-
- public ICElement[] getRemaining() {
- List elems= fHistoryList.getElements();
- return elems.toArray(new ICElement[elems.size()]);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#create()
- */
- @Override
- public void create() {
- setShellStyle(getShellStyle() | SWT.RESIZE);
- super.create();
- }
-
- }
-
- private CHViewPart fView;
-
- public CHHistoryListAction(CHViewPart view) {
- fView= view;
- setText(CHMessages.CHHistoryListAction_OpenHistory_label);
- }
-
- /*
- * @see IAction#run()
- */
- @Override
- public void run() {
- ICElement[] historyEntries= fView.getHistoryEntries();
- HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
- if (dialog.open() == Window.OK) {
- fView.setHistoryEntries(dialog.getRemaining());
- fView.setInput(dialog.getResult());
- }
- }
-}
-
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
deleted file mode 100644
index 663231f..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHLabelProvider.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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:
- * Markus Schorn - initial API and implementation
- * Patrick Hofer [bug 325799]
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.StyledCellLabelProvider;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.ui.CElementImageDescriptor;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
-
-public class CHLabelProvider extends AppearanceAwareLabelProvider {
- private final static long LABEL_OPTIONS_SIMPLE = CElementLabels.ALL_FULLY_QUALIFIED
- | CElementLabels.M_PARAMETER_TYPES | CElementLabels.M_APP_RETURNTYPE | CElementLabels.F_APP_TYPE_SIGNATURE | CElementLabels.TEMPLATE_ARGUMENTS;
- private final static long LABEL_OPTIONS_SHOW_FILES= LABEL_OPTIONS_SIMPLE | CElementLabels.MF_POST_FILE_QUALIFIED;
-
- private CUILabelProvider fCLabelProvider= new CUILabelProvider(LABEL_OPTIONS_SIMPLE, CElementImageProvider.OVERLAY_ICONS);
- private CHContentProvider fContentProvider;
- private HashMap fCachedImages= new HashMap();
- private Color fColorInactive;
-
- public CHLabelProvider(Display display, CHContentProvider cp) {
- fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
- fContentProvider= cp;
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- Image image= null;
- if (node.isInitializer()) {
- ImageDescriptor desc= CElementImageProvider.getFunctionImageDescriptor();
- image= CUIPlugin.getImageDescriptorRegistry().get(desc);
- }
- else {
- ICElement decl= node.getOneRepresentedDeclaration();
- if (decl != null) {
- image= fCLabelProvider.getImage(decl);
- }
- }
- if (image != null) {
- return decorateImage(image, node);
- }
- }
- return super.getImage(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- ICElement decl= node.getOneRepresentedDeclaration();
- if (decl != null) {
- String label;
- if (node.isMultiDef()) {
- long options= fCLabelProvider.getTextFlags();
- fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
- label= fCLabelProvider.getText(decl);
- fCLabelProvider.setTextFlags(options);
- }
- else {
- label= fCLabelProvider.getText(decl);
- if (node.isInitializer()) {
- label= addInitializerDecoration(label);
- }
- }
- int refCount= node.getReferenceCount();
- if (refCount > 1) {
- label += NLS.bind(" ({0} {1})", new Integer(refCount), CHMessages.CHLabelProvider_matches); //$NON-NLS-1$
- }
- return decorateText(label, element);
- }
- }
- return super.getText(element);
- }
-
- @Override
- public StyledString getStyledText(Object element) {
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- ICElement decl= node.getOneRepresentedDeclaration();
- if (decl != null) {
- StyledString label;
- if (node.isMultiDef()) {
- long options= fCLabelProvider.getTextFlags();
- fCLabelProvider.setTextFlags(LABEL_OPTIONS_SIMPLE);
- label= fCLabelProvider.getStyledText(decl);
- fCLabelProvider.setTextFlags(options);
- }
- else {
- label= fCLabelProvider.getStyledText(decl);
- if (node.isInitializer()) {
- label= addInitializerDecoration(label);
- }
- }
- int refCount= node.getReferenceCount();
- if (refCount > 1) {
- final int offset= label.length();
- label.append(NLS.bind(" ({0} {1})", new Integer(refCount), CHMessages.CHLabelProvider_matches)); //$NON-NLS-1$
- label.setStyle(offset, label.length() - offset, StyledString.COUNTER_STYLER);
-
- }
- //return label;
- String decorated= decorateText(label.getString(), element);
- if (decorated != null) {
- return StyledCellLabelProvider.styleDecoratedString(decorated, StyledString.DECORATIONS_STYLER, label);
- }
- return label;
- }
- }
- return fCLabelProvider.getStyledText(element);
- }
-
- private String addInitializerDecoration(String label) {
- int i= 0;
- char[] content= label.toCharArray();
- for (i = 0; i < content.length; i++) {
- char c = content[i];
- if (c == '-' || Character.isWhitespace(c)) {
- break;
- }
- }
- StringBuffer buf= new StringBuffer(label.length() + 10);
- buf.append("{init "); //$NON-NLS-1$
- buf.append(content, 0, i);
- buf.append("}()"); //$NON-NLS-1$
- buf.append(content, i, content.length-i);
-
- return buf.toString();
- }
-
- private StyledString addInitializerDecoration(StyledString label) {
- int i= 0;
- char[] content= label.toString().toCharArray();
- for (i = 0; i < content.length; i++) {
- char c = content[i];
- if (c == '-' || Character.isWhitespace(c)) {
- break;
- }
- }
- StyledString label2= new StyledString();
- label2.append("{init "); //$NON-NLS-1$
- i += label2.length();
- label2.append(label);
- label2.insert('}', i++);
- label2.insert('(', i++);
- label2.insert(')', i++);
- label2.setStyle(0, i, null);
- return label2;
- }
-
-
- @Override
- public void dispose() {
- fCLabelProvider.dispose();
- for (Image image : fCachedImages.values()) {
- image.dispose();
- }
- fCachedImages.clear();
- super.dispose();
- }
-
- private Image decorateImage(Image image, CHNode node) {
- int flags= 0;
- if (node.isRecursive()) {
- flags |= CElementImageDescriptor.RECURSIVE_RELATION;
- }
- else if (fContentProvider.hasChildren(node)) {
- if (fContentProvider.getComputeReferencedBy()) {
- flags |= CElementImageDescriptor.REFERENCED_BY;
- }
- else {
- if (node.isMultiDef()) {
- flags |= CElementImageDescriptor.RELATES_TO_MULTIPLE;
- }
- else {
- flags |= CElementImageDescriptor.RELATES_TO;
- }
- }
- }
- if (node.isReadAccess()) {
- flags |= CElementImageDescriptor.READ_ACCESS;
- }
- if (node.isWriteAccess()) {
- flags |= CElementImageDescriptor.WRITE_ACCESS;
- }
-
- String key= image.toString()+String.valueOf(flags);
- Image result= fCachedImages.get(key);
- if (result == null) {
- ImageDescriptor desc= new CElementImageDescriptor(
- new ImageImageDescriptor(image), flags, new Point(20,16));
- result= desc.createImage();
- fCachedImages.put(key, result);
- }
- return result;
- }
-
- @Override
- public Color getForeground(Object element) {
- if (element instanceof CHMultiDefNode) {
- return fColorInactive;
- }
- return null;
- }
-
- public void setShowFiles(boolean show) {
- fCLabelProvider.setTextFlags(show ? LABEL_OPTIONS_SHOW_FILES : LABEL_OPTIONS_SIMPLE);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java
deleted file mode 100644
index 127fcd4..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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:
- * Markus Schorn - initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.osgi.util.NLS;
-
-public class CHMessages extends NLS {
- public static String CallHierarchyUI_label;
- public static String CallHierarchyUI_openFailureMessage;
- public static String CallHierarchyUI_selectMessage;
- public static String CHHistoryListAction_HistoryDialog_title;
- public static String CHHistoryListAction_HistoryList_label;
- public static String CHHistoryListAction_OpenHistory_label;
- public static String CHHistoryListAction_Remove_label;
- public static String CHLabelProvider_matches;
- public static String CHViewPart_emptyPageMessage;
- public static String CHViewPart_FilterVariables_label;
- public static String CHViewPart_FilterVariables_tooltip;
- public static String CHViewPart_FocusOn_label;
- public static String CHViewPart_NextReference_label;
- public static String CHViewPart_NextReference_tooltip;
- public static String CHViewPart_Open_label;
- public static String CHViewPart_Open_tooltip;
- public static String CHViewPart_PreviousReference_label;
- public static String CHViewPart_PreviousReference_tooltip;
- public static String CHViewPart_Refresh_label;
- public static String CHViewPart_Refresh_tooltip;
- public static String CHViewPart_CopyCallHierarchy_label;
- public static String CHViewPart_ShowCallees_label;
- public static String CHViewPart_ShowCallees_tooltip;
- public static String CHViewPart_ShowCallers_label;
- public static String CHViewPart_ShowCallers_tooltip;
- public static String CHViewPart_ShowFiles_label;
- public static String CHViewPart_ShowFiles_tooltip;
- public static String CHViewPart_ShowReference_label;
- public static String CHViewPart_ShowReference_tooltip;
- public static String CHViewPart_Title_callees;
- public static String CHViewPart_Title_callers;
- public static String CHViewPart_WorkspaceScope;
- public static String CHHistoryDropDownAction_ClearHistory_label;
- public static String CHHistoryDropDownAction_ShowHistoryList_tooltip;
- public static String OpenCallHierarchyAction_label;
- public static String OpenCallHierarchyAction_tooltip;
- public static String OpenElementInCallHierarchyAction_errorDlgTitle;
- public static String OpenElementInCallHierarchyAction_errorNoDefinition;
- public static String OpenElementInCallHierarchyAction_message;
- public static String OpenElementInCallHierarchyAction_title;
- public static String OpenElementInCallHierarchyAction_upperListLabel;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(CHMessages.class.getName(), CHMessages.class);
- }
-
- private CHMessages() {
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties
deleted file mode 100644
index 2e8321e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties
+++ /dev/null
@@ -1,52 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2010 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:
-# Markus Schorn (Wind River Systems)
-# Sergey Prigogin (Google)
-###############################################################################
-CHViewPart_emptyPageMessage=To display the call hierarchy, select a function or method and select the 'Open Call Hierarchy' menu option.
-CHViewPart_ShowCallers_label=Show Callers
-CHViewPart_ShowCallers_tooltip=Show Callers
-CHViewPart_ShowCallees_label=Show Callees
-CHViewPart_ShowCallees_tooltip=Show Callees
-CHViewPart_ShowReference_label=Show Reference
-CHViewPart_ShowReference_tooltip=Show Reference
-CHViewPart_FilterVariables_label=Filter Variables
-CHViewPart_FilterVariables_tooltip=Hide Variables, Constants and Enumerators
-CHViewPart_ShowFiles_label=Show File Names
-CHViewPart_ShowFiles_tooltip=Show File Names
-CHViewPart_NextReference_label=Next Reference
-CHViewPart_NextReference_tooltip=Show Next Reference
-CHHistoryListAction_Remove_label=Remove
-CHViewPart_PreviousReference_label=Previous Reference
-CHViewPart_PreviousReference_tooltip=Show Previous Reference
-CHViewPart_Refresh_label=Refresh
-CHViewPart_Refresh_tooltip=Refresh View Content
-CHViewPart_WorkspaceScope=workspace
-CHViewPart_Title_callers=Callers of {0} - in {1}
-CHViewPart_Title_callees=Calls from {0} - in {1}
-CHViewPart_FocusOn_label=Focus On ''{0}''
-CHViewPart_Open_label=Open
-CHViewPart_Open_tooltip=Open
-CHViewPart_CopyCallHierarchy_label=Copy E&xpanded Hierarchy
-CHLabelProvider_matches=matches
-CHHistoryDropDownAction_ClearHistory_label=Clear History
-CHHistoryListAction_HistoryDialog_title=Call Hierarchy History
-CHHistoryListAction_HistoryList_label=Select the input for the Call Hierarchy:
-CHHistoryListAction_OpenHistory_label=Open History...
-CHHistoryDropDownAction_ShowHistoryList_tooltip=Show History List
-OpenCallHierarchyAction_label=Open Call H&ierarchy
-OpenCallHierarchyAction_tooltip=Open Call Hierarchy
-CallHierarchyUI_label=Open Call Hierarchy
-CallHierarchyUI_selectMessage=Select one element from the list
-CallHierarchyUI_openFailureMessage=Cannot resolve selected text to a defined function or member
-OpenElementInCallHierarchyAction_errorDlgTitle=Open Element in Call Hierarchy
-OpenElementInCallHierarchyAction_title=Open Element in Call Hierarchy
-OpenElementInCallHierarchyAction_upperListLabel=&Matching Elements:
-OpenElementInCallHierarchyAction_message=&Choose an element (? = any character, * = any string):
-OpenElementInCallHierarchyAction_errorNoDefinition=Could not locate definition of element ''{0}''
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java
deleted file mode 100644
index 1df96be..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefChildNode.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-/**
- * Represents a child of a node with multiple definitions.
- */
-public class CHMultiDefChildNode extends CHNode {
-
- public CHMultiDefChildNode(CHMultiDefNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl, int linkageID) {
- super(parent, fileOfReferences, timestamp, decl, linkageID);
- }
-
- @Override
- public int getReferenceCount() {
- return getParent().getReferenceCount();
- }
-
- @Override
- public CHReferenceInfo getReference(int idx) {
- return getParent().getReference(idx);
- }
-
- @Override
- public int getFirstReferenceOffset() {
- return getParent().getFirstReferenceOffset();
- }
-
- @Override
- public void addReference(CHReferenceInfo info) {
- assert false;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
deleted file mode 100644
index 868e5a8..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-import org.eclipse.cdt.internal.ui.util.CoreUtility;
-
-public class CHMultiDefNode extends CHNode {
-
- private CHNode[] fChildren;
-
- public CHMultiDefNode(CHNode parent, ITranslationUnit tu, long timestamp, ICElement[] elements, int linkageID) {
- super(parent, tu, timestamp, null, linkageID);
- if (elements.length == 0) {
- throw new IllegalArgumentException();
- }
- fHashCode+= elements[0].hashCode();
- fChildren= new CHNode[elements.length];
- for (int i = 0; i < elements.length; i++) {
- ICElement element = elements[i];
- fChildren[i]= new CHMultiDefChildNode(this, tu, timestamp, element, linkageID);
- }
- }
-
- public CHNode[] getChildNodes() {
- return fChildren;
- }
-
- @Override
- public boolean isMacro() {
- return fChildren[0].isMacro();
- }
-
- @Override
- public boolean isVariableOrEnumerator() {
- return fChildren[0].isVariableOrEnumerator();
- }
-
-
- @Override
- public ICElement getOneRepresentedDeclaration() {
- return fChildren[0].getRepresentedDeclaration();
- }
-
- @Override
- public boolean isMultiDef() {
- return true;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!super.equals(o) || !(o instanceof CHMultiDefNode))
- return false;
-
- final CHMultiDefNode rhs = (CHMultiDefNode) o;
- return CoreUtility.safeEquals(getOneRepresentedDeclaration(), rhs.getOneRepresentedDeclaration());
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
deleted file mode 100644
index 8976e9c..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IEnumerator;
-import org.eclipse.cdt.core.model.IMacro;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IVariableDeclaration;
-
-import org.eclipse.cdt.internal.ui.util.CoreUtility;
-
-/**
- * Represents a node in the include browser
- */
-public class CHNode implements IAdaptable {
- private CHNode fParent;
- private ICElement fRepresentedDecl;
- private ITranslationUnit fFileOfReferences;
- private List fReferences;
-
- protected int fHashCode;
- private long fTimestamp;
- private boolean fIsRecursive;
- private boolean fIsInitializer;
- private boolean fIsReadAccess;
- private boolean fIsWriteAccess;
- private final int fLinkageID;
-
- /**
- * Creates a new node for the include browser
- */
- public CHNode(CHNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl, int linkageID) {
- fParent= parent;
- fFileOfReferences= fileOfReferences;
- fReferences= Collections.emptyList();
- fRepresentedDecl= decl;
- fIsRecursive= computeIsRecursive(fParent, decl);
- fHashCode= computeHashCode();
- fTimestamp= timestamp;
- fLinkageID= linkageID;
- }
-
- private int computeHashCode() {
- int hashCode= 1;
- if (fParent != null) {
- hashCode= fParent.hashCode() * 31;
- }
- if (fRepresentedDecl != null) {
- hashCode+= fRepresentedDecl.hashCode();
- }
- return hashCode;
- }
-
- @Override
- public int hashCode() {
- return fHashCode;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof CHNode)) {
- return false;
- }
-
- CHNode rhs = (CHNode) o;
- if (fHashCode != rhs.fHashCode) {
- return false;
- }
-
- return CoreUtility.safeEquals(fRepresentedDecl, rhs.fRepresentedDecl);
- }
-
- private boolean computeIsRecursive(CHNode parent, ICElement decl) {
- if (parent == null || decl == null) {
- return false;
- }
- if (decl.equals(parent.fRepresentedDecl)) {
- return true;
- }
- return computeIsRecursive(parent.fParent, decl);
- }
-
- /**
- * Returns the parent node or null for the root node.
- */
- public CHNode getParent() {
- return fParent;
- }
-
- public int getLinkageID() {
- return fLinkageID;
- }
-
- public boolean isRecursive() {
- return fIsRecursive;
- }
-
- public int getReferenceCount() {
- return fReferences.size();
- }
-
- public CHReferenceInfo getReference(int idx) {
- return fReferences.get(idx);
- }
-
- public ICElement getRepresentedDeclaration() {
- return fRepresentedDecl;
- }
-
- public long getTimestamp() {
- return fTimestamp;
- }
-
- public boolean isMacro() {
- return fRepresentedDecl instanceof IMacro;
- }
-
- public boolean isVariableOrEnumerator() {
- return fRepresentedDecl instanceof IVariableDeclaration ||
- fRepresentedDecl instanceof IEnumerator;
- }
-
- public int getFirstReferenceOffset() {
- return fReferences.isEmpty() ? -1 : getReference(0).getOffset();
- }
-
- public void addReference(CHReferenceInfo info) {
- switch (fReferences.size()) {
- case 0:
- fReferences= Collections.singletonList(info);
- return;
- case 1:
- fReferences= new ArrayList(fReferences);
- break;
- }
- fReferences.add(info);
- }
-
- public ITranslationUnit getFileOfReferences() {
- return fFileOfReferences;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public Object getAdapter(Class adapter) {
- if (adapter.isAssignableFrom(ICElement.class)) {
- return getRepresentedDeclaration();
- }
- return null;
- }
-
- public boolean isMultiDef() {
- return false;
- }
-
- public ICElement getOneRepresentedDeclaration() {
- return getRepresentedDeclaration();
- }
-
- public boolean isInitializer() {
- return fIsInitializer;
- }
-
- public void setInitializer(boolean isInitializer) {
- fIsInitializer = isInitializer;
- }
-
- public void sortReferencesByOffset() {
- if (fReferences.size() > 1) {
- Collections.sort(fReferences, CHReferenceInfo.COMPARE_OFFSET);
- }
- }
-
- public void setRWAccess(boolean readAccess, boolean writeAccess) {
- fIsReadAccess= readAccess;
- fIsWriteAccess= writeAccess;
- }
-
- public boolean isReadAccess() {
- return fIsReadAccess;
- }
-
- public boolean isWriteAccess() {
- return fIsWriteAccess;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
deleted file mode 100644
index d456591..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-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.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ILinkage;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexBinding;
-import org.eclipse.cdt.core.index.IIndexName;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
-import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
-
-import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
-
-
-/**
- * Access to high level queries in the index.
- * @since 4.0
- */
-public class CHQueries {
- private static final CHNode[] EMPTY_NODES= new CHNode[0];
-
- private CHQueries() {}
-
- /**
- * Searches for functions and methods that call a given element.
- */
- public static CHNode[] findCalledBy(CHContentProvider cp, CHNode node, IIndex index, IProgressMonitor pm)
- throws CoreException {
- CalledByResult result= new CalledByResult();
- ICElement callee= node.getRepresentedDeclaration();
- if (!(callee instanceof ISourceReference)) {
- return EMPTY_NODES;
- }
- boolean done= false;
- int linkageID= node.getLinkageID();
- if (linkageID == -1) {
- final ITranslationUnit tu = ((ISourceReference) callee).getTranslationUnit();
- if (tu == null)
- return EMPTY_NODES;
-
- final String ct = tu.getContentTypeId();
- if (ct.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER)) {
- // bug 260262: in a header file we need to consider c and c++
- findCalledBy(callee, ILinkage.C_LINKAGE_ID, index, result);
- findCalledBy(callee, ILinkage.CPP_LINKAGE_ID, index, result);
- done= true;
- }
- }
- if (!done) {
- findCalledBy(callee, linkageID, index, result);
- }
- return cp.createNodes(node, result);
- }
-
- private static void findCalledBy(ICElement callee, int linkageID, IIndex index, CalledByResult result)
- throws CoreException {
- final ICProject project = callee.getCProject();
- IIndexBinding calleeBinding= IndexUI.elementToBinding(index, callee, linkageID);
- if (calleeBinding != null) {
- findCalledBy1(index, calleeBinding, true, project, result);
- if (calleeBinding instanceof ICPPMethod) {
- IBinding[] overriddenBindings= ClassTypeHelper.findOverridden((ICPPMethod) calleeBinding);
- for (IBinding overriddenBinding : overriddenBindings) {
- findCalledBy1(index, overriddenBinding, false, project, result);
- }
- }
- }
- }
-
- private static void findCalledBy1(IIndex index, IBinding callee, boolean includeOrdinaryCalls,
- ICProject project, CalledByResult result) throws CoreException {
- findCalledBy2(index, callee, includeOrdinaryCalls, project, result);
- List extends IBinding> specializations = IndexUI.findSpecializations(callee);
- for (IBinding spec : specializations) {
- findCalledBy2(index, spec, includeOrdinaryCalls, project, result);
- }
- }
-
-
- private static void findCalledBy2(IIndex index, IBinding callee, boolean includeOrdinaryCalls, ICProject project, CalledByResult result)
- throws CoreException {
- IIndexName[] names= index.findNames(callee, IIndex.FIND_REFERENCES | IIndex.SEARCH_ACROSS_LANGUAGE_BOUNDARIES);
- for (IIndexName rname : names) {
- if (includeOrdinaryCalls || rname.couldBePolymorphicMethodCall()) {
- IIndexName caller= rname.getEnclosingDefinition();
- if (caller != null) {
- ICElement elem= IndexUI.getCElementForName(project, index, caller);
- if (elem != null) {
- result.add(elem, rname);
- }
- }
- }
- }
- }
-
- /**
- * Searches for all calls that are made within a given range.
- */
- public static CHNode[] findCalls(CHContentProvider cp, CHNode node, IIndex index, IProgressMonitor pm)
- throws CoreException {
- ICElement caller= node.getRepresentedDeclaration();
- CallsToResult result= new CallsToResult();
- IIndexName callerName= IndexUI.elementToName(index, caller);
- if (callerName != null) {
- IIndexName[] refs= callerName.getEnclosedNames();
- for (IIndexName name : refs) {
- IBinding binding= index.findBinding(name);
- if (CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
- for(;;) {
- ICElement[] defs= null;
- if (binding instanceof ICPPMethod) {
- defs = findOverriders(index, (ICPPMethod) binding);
- }
- if (defs == null) {
- defs= IndexUI.findRepresentative(index, binding);
- }
- if (defs != null && defs.length > 0) {
- result.add(defs, name);
- } else if (binding instanceof ICPPSpecialization) {
- binding= ((ICPPSpecialization) binding).getSpecializedBinding();
- if (binding != null)
- continue;
- }
- break;
- }
- }
- }
- }
- return cp.createNodes(node, result);
- }
-
- /**
- * Searches for overriders of method and converts them to ICElement, returns null, if there are none.
- */
- static ICElement[] findOverriders(IIndex index, ICPPMethod binding) throws CoreException {
- IBinding[] virtualOverriders= ClassTypeHelper.findOverriders(index, binding);
- if (virtualOverriders.length > 0) {
- ArrayList list= new ArrayList();
- list.addAll(Arrays.asList(IndexUI.findRepresentative(index, binding)));
- for (IBinding overrider : virtualOverriders) {
- list.addAll(Arrays.asList(IndexUI.findRepresentative(index, overrider)));
- }
- return list.toArray(new ICElement[list.size()]);
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java
deleted file mode 100644
index bd8af5e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHReferenceInfo.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.Comparator;
-
-public class CHReferenceInfo {
- public static final Comparator COMPARE_OFFSET = new Comparator() {
- public int compare(CHReferenceInfo r1, CHReferenceInfo r2) {
- return r1.fOffset - r2.fOffset;
- }
- };
- private int fOffset;
- private int fLength;
-
- public CHReferenceInfo(int offset, int length) {
- fOffset= offset;
- fLength= length;
- }
-
- public int getOffset() {
- return fOffset;
- }
-
- public int getLength() {
- return fLength;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
deleted file mode 100644
index dc1a089..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
+++ /dev/null
@@ -1,812 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 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:
- * Markus Schorn - initial API and implementation
- * Sergey Prigogin (Google)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.contexts.IContextActivation;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.navigator.ICommonMenuConstants;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.ViewPart;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IFunction;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.CdtActionConstants;
-import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.actions.CopyTreeAction;
-import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
-import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
-import org.eclipse.cdt.internal.ui.util.CoreUtility;
-import org.eclipse.cdt.internal.ui.util.Messages;
-import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
-import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
-import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
-import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
-import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
-
-/**
- * The view part for the include browser.
- */
-public class CHViewPart extends ViewPart {
- private static final int MAX_HISTORY_SIZE = 10;
- private static final String TRUE = String.valueOf(true);
- private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
- private static final String KEY_FILTER_VARIABLES = "variableFilter"; //$NON-NLS-1$
- private static final String KEY_SHOW_FILES= "showFilesInLabels"; //$NON-NLS-1$
-
- private IMemento fMemento;
- private boolean fShowsMessage;
- private CHNode fNavigationNode;
- private int fNavigationDetail;
-
- private ArrayList fHistoryEntries= new ArrayList(MAX_HISTORY_SIZE);
-
- // widgets
- private PageBook fPagebook;
- private Composite fViewerPage;
- private Label fInfoText;
-
- // treeviewer
- private CHContentProvider fContentProvider;
- private CHLabelProvider fLabelProvider;
- private ExtendedTreeViewer fTreeViewer;
-
- // filters, sorter
- private ViewerFilter fVariableFilter;
- private ViewerComparator fSorterAlphaNumeric;
- private ViewerComparator fSorterReferencePosition;
- private WorkingSetFilterUI fWorkingSetFilterUI;
-
- // actions
- private Action fReferencedByAction;
- private Action fMakesReferenceToAction;
- private Action fFilterVariablesAction;
- private Action fShowFilesInLabelsAction;
- private Action fNextAction;
- private Action fPreviousAction;
- private Action fRefreshAction;
- private Action fHistoryAction;
- private Action fShowReference;
- private Action fOpenElement;
- private CopyTreeAction fCopyAction;
-
- // action groups
- private OpenViewActionGroup fOpenViewActionGroup;
- private SelectionSearchGroup fSelectionSearchGroup;
- private CRefactoringActionGroup fRefactoringActionGroup;
- private IContextActivation fContextActivation;
-
- @Override
- public void setFocus() {
- fPagebook.setFocus();
- }
-
- public void setMessage(String msg) {
- fInfoText.setText(msg);
- fPagebook.showPage(fInfoText);
- fShowsMessage= true;
- updateDescription();
- updateActionEnablement();
- }
-
- public void setInput(ICElement input) {
- if (input == null) {
- setMessage(CHMessages.CHViewPart_emptyPageMessage);
- fTreeViewer.setInput(null);
- return;
- }
- fShowsMessage= false;
- boolean allowsRefTo= allowsRefTo(input);
- fTreeViewer.setInput(null);
- if (!allowsRefTo && !fContentProvider.getComputeReferencedBy()) {
- fContentProvider.setComputeReferencedBy(true);
- fReferencedByAction.setChecked(true);
- fMakesReferenceToAction.setChecked(false);
- updateSorter();
- }
- fMakesReferenceToAction.setEnabled(allowsRefTo);
- fTreeViewer.setInput(input);
- fPagebook.showPage(fViewerPage);
- updateDescription();
- updateHistory(input);
- updateActionEnablement();
- }
-
- public void reportNotIndexed(ICElement input) {
- if (input != null && getInput() == input) {
- setMessage(IndexUI.getFileNotIndexedMessage(input));
- }
- }
-
- public void reportInputReplacement(ICElement input, ICElement inputHandle) {
- if (input == getInput()) {
- fTreeViewer.setInput(inputHandle);
- fTreeViewer.setExpandedState(inputHandle, true);
- }
- }
-
- private boolean allowsRefTo(ICElement element) {
- if (element instanceof IFunction || element instanceof IMethod) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public void createPartControl(Composite parent) {
- fPagebook = new PageBook(parent, SWT.NULL);
- createInfoPage();
- createViewerPage();
-
- getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, fTreeViewer));
-
- initDragAndDrop();
- createActions();
- createContextMenu();
-
- setMessage(CHMessages.CHViewPart_emptyPageMessage);
-
- initializeActionStates();
-
- IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
- if (ctxService != null) {
- fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
- }
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(fPagebook, ICHelpContextIds.CALL_HIERARCHY_VIEW);
- }
-
- @Override
- public void dispose() {
- if (fContextActivation != null) {
- IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
- if (ctxService != null) {
- ctxService.deactivateContext(fContextActivation);
- }
- }
-
- if (fOpenViewActionGroup != null) {
- fOpenViewActionGroup.dispose();
- fOpenViewActionGroup= null;
- }
- if (fSelectionSearchGroup != null) {
- fSelectionSearchGroup.dispose();
- fSelectionSearchGroup= null;
- }
- if (fRefactoringActionGroup != null) {
- fRefactoringActionGroup.dispose();
- fRefactoringActionGroup= null;
- }
- if (fWorkingSetFilterUI != null) {
- fWorkingSetFilterUI.dispose();
- fWorkingSetFilterUI= null;
- }
- super.dispose();
- }
-
- private void initializeActionStates() {
- boolean referencedBy= true;
- boolean filterVariables= false;
- boolean showFiles= false;
-
- if (fMemento != null) {
- filterVariables= TRUE.equals(fMemento.getString(KEY_FILTER_VARIABLES));
- showFiles= TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
- }
-
- fLabelProvider.setShowFiles(showFiles);
- fShowFilesInLabelsAction.setChecked(showFiles);
-
- fReferencedByAction.setChecked(referencedBy);
- fMakesReferenceToAction.setChecked(!referencedBy);
- fContentProvider.setComputeReferencedBy(referencedBy);
-
- fFilterVariablesAction.setChecked(filterVariables);
- fFilterVariablesAction.run();
- updateSorter();
- }
-
- @Override
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- fMemento= memento;
- super.init(site, memento);
- }
-
-
- @Override
- public void saveState(IMemento memento) {
- if (fWorkingSetFilterUI != null) {
- fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
- }
- memento.putString(KEY_FILTER_VARIABLES, String.valueOf(fFilterVariablesAction.isChecked()));
- memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
- super.saveState(memento);
- }
-
- private void createContextMenu() {
- MenuManager manager = new MenuManager();
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager m) {
- onContextMenuAboutToShow(m);
- }
- });
- Menu menu = manager.createContextMenu(fTreeViewer.getControl());
- fTreeViewer.getControl().setMenu(menu);
- IWorkbenchPartSite site = getSite();
- site.registerContextMenu(CUIPlugin.ID_CALL_HIERARCHY, manager, fTreeViewer);
- }
-
- private void createViewerPage() {
- Display display= getSite().getShell().getDisplay();
- fViewerPage = new Composite(fPagebook, SWT.NULL);
- fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
- fViewerPage.setSize(100, 100);
- fViewerPage.setLayout(new FillLayout());
-
- fContentProvider= new CHContentProvider(this, display);
- fLabelProvider= new CHLabelProvider(display, fContentProvider);
- fTreeViewer= new ExtendedTreeViewer(fViewerPage);
- fTreeViewer.setContentProvider(fContentProvider);
- fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(fLabelProvider));
- fTreeViewer.setAutoExpandLevel(2);
- fTreeViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- onShowSelectedReference(event.getSelection());
- }
- });
- }
-
- private void createInfoPage() {
- fInfoText = new Label(fPagebook, SWT.TOP | SWT.LEFT | SWT.WRAP);
- }
-
- private void initDragAndDrop() {
- CHDropTargetListener dropListener= new CHDropTargetListener(this);
- Transfer[] localSelectionTransfer= new Transfer[] {
- LocalSelectionTransfer.getTransfer()
- };
- DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
- dropTarget.setTransfer(localSelectionTransfer);
- dropTarget.addDropListener(dropListener);
- }
-
- private void createActions() {
- // action groups
- fOpenViewActionGroup= new OpenViewActionGroup(this);
- fOpenViewActionGroup.setSuppressCallHierarchy(true);
- fOpenViewActionGroup.setSuppressProperties(true);
- fOpenViewActionGroup.setEnableIncludeBrowser(true);
- fSelectionSearchGroup= new SelectionSearchGroup(getSite());
- fRefactoringActionGroup= new CRefactoringActionGroup(this);
-
- fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
- @Override
- protected void onWorkingSetChange() {
- updateWorkingSetFilter(this);
- }
- @Override
- protected void onWorkingSetNameChange() {
- updateDescription();
- }
- };
-
- fReferencedByAction=
- new Action(CHMessages.CHViewPart_ShowCallers_label, IAction.AS_RADIO_BUTTON) {
- @Override
- public void run() {
- if (isChecked()) {
- onSetShowReferencedBy(true);
- }
- }
- };
- fReferencedByAction.setToolTipText(CHMessages.CHViewPart_ShowCallers_tooltip);
- CPluginImages.setImageDescriptors(fReferencedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
-
- fMakesReferenceToAction=
- new Action(CHMessages.CHViewPart_ShowCallees_label, IAction.AS_RADIO_BUTTON) {
- @Override
- public void run() {
- if (isChecked()) {
- onSetShowReferencedBy(false);
- }
- }
- };
- fMakesReferenceToAction.setToolTipText(CHMessages.CHViewPart_ShowCallees_tooltip);
- CPluginImages.setImageDescriptors(fMakesReferenceToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
-
- fVariableFilter= new ViewerFilter() {
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof CHNode) {
- CHNode node= (CHNode) element;
- return !node.isVariableOrEnumerator();
- }
- return true;
- }
- };
- fFilterVariablesAction= new Action(CHMessages.CHViewPart_FilterVariables_label, IAction.AS_CHECK_BOX) {
- @Override
- public void run() {
- if (isChecked()) {
- fTreeViewer.addFilter(fVariableFilter);
- }
- else {
- fTreeViewer.removeFilter(fVariableFilter);
- }
- }
- };
- fFilterVariablesAction.setToolTipText(CHMessages.CHViewPart_FilterVariables_tooltip);
- CPluginImages.setImageDescriptors(fFilterVariablesAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
-
- fSorterAlphaNumeric= new ViewerComparator();
- fSorterReferencePosition= new ViewerComparator() {
- @Override
- public int category(Object element) {
- if (element instanceof CHNode) {
- return 0;
- }
- return 1;
- }
- @Override
- public int compare(Viewer viewer, Object e1, Object e2) {
- if (!(e1 instanceof CHNode)) {
- if (!(e2 instanceof CHNode)) {
- return 0;
- }
- return -1;
- }
- if (!(e2 instanceof CHNode)) {
- return 1;
- }
- CHNode n1= (CHNode) e1;
- CHNode n2= (CHNode) e2;
- int offset1= n1.getFirstReferenceOffset();
- int offset2= n2.getFirstReferenceOffset();
- return CoreUtility.compare(offset1, offset2);
- }
- };
-
- fShowReference= new Action(CHMessages.CHViewPart_ShowReference_label) {
- @Override
- public void run() {
- onShowSelectedReference(fTreeViewer.getSelection());
- }
- };
- fShowReference.setToolTipText(CHMessages.CHViewPart_ShowReference_tooltip);
- fOpenElement= new Action(CHMessages.CHViewPart_Open_label) {
- @Override
- public void run() {
- onOpenElement(fTreeViewer.getSelection());
- }
- };
- fOpenElement.setToolTipText(CHMessages.CHViewPart_Open_tooltip);
- fOpenElement.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
-
- fShowFilesInLabelsAction= new Action(CHMessages.CHViewPart_ShowFiles_label, IAction.AS_CHECK_BOX) {
- @Override
- public void run() {
- onShowFilesInLabels(isChecked());
- }
- };
- fShowFilesInLabelsAction.setToolTipText(CHMessages.CHViewPart_ShowFiles_tooltip);
- fNextAction = new Action(CHMessages.CHViewPart_NextReference_label) {
- @Override
- public void run() {
- onNextOrPrevious(true);
- }
- };
- fNextAction.setToolTipText(CHMessages.CHViewPart_NextReference_tooltip);
- CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
-
- fPreviousAction = new Action(CHMessages.CHViewPart_PreviousReference_label) {
- @Override
- public void run() {
- onNextOrPrevious(false);
- }
- };
- fPreviousAction.setToolTipText(CHMessages.CHViewPart_PreviousReference_tooltip);
- CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
-
- fRefreshAction = new Action(CHMessages.CHViewPart_Refresh_label) {
- @Override
- public void run() {
- onRefresh();
- }
- };
- fRefreshAction.setToolTipText(CHMessages.CHViewPart_Refresh_tooltip);
- CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
-
- fHistoryAction = new CHHistoryDropDownAction(this);
-
- fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer);
-
- // setup action bar
- // global action hooks
- IActionBars actionBars = getViewSite().getActionBars();
- fRefactoringActionGroup.fillActionBars(actionBars);
- fOpenViewActionGroup.fillActionBars(actionBars);
- fSelectionSearchGroup.fillActionBars(actionBars);
-
- actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_DECLARATION, fOpenElement);
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
- actionBars.updateActionBars();
-
- // local toolbar
- IToolBarManager tm = actionBars.getToolBarManager();
- tm.add(fNextAction);
- tm.add(fPreviousAction);
- tm.add(new Separator());
- tm.add(fFilterVariablesAction);
- tm.add(new Separator());
- tm.add(fReferencedByAction);
- tm.add(fMakesReferenceToAction);
- tm.add(fHistoryAction);
- tm.add(fRefreshAction);
-
- // local menu
- IMenuManager mm = actionBars.getMenuManager();
-
- fWorkingSetFilterUI.fillActionBars(actionBars);
- mm.add(fReferencedByAction);
- mm.add(fMakesReferenceToAction);
- mm.add(new Separator());
- mm.add(fShowFilesInLabelsAction);
- mm.add(new Separator());
- mm.add(fFilterVariablesAction);
- }
-
- private void setNextNode(boolean forward) {
- TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
- TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
- if (selectedItem == null) {
- fNavigationNode= null;
- return;
- }
-
-
- if (selectedItem.getData().equals(fNavigationNode)) {
- if (forward && fNavigationDetail < getReferenceCount(fNavigationNode)-1) {
- fNavigationDetail++;
- }
- else if (!forward && fNavigationDetail > 0) {
- fNavigationDetail--;
- }
- else {
- selectedItem= navigator.getNextSibbling(selectedItem, forward);
- fNavigationNode= selectedItem == null ? null : (CHNode) selectedItem.getData();
- initNavigationDetail(forward);
- }
- }
- else {
- fNavigationNode= (CHNode) selectedItem.getData();
- initNavigationDetail(forward);
- }
- }
-
- private void initNavigationDetail(boolean forward) {
- if (!forward && fNavigationNode != null) {
- fNavigationDetail= Math.max(0, getReferenceCount(fNavigationNode) -1);
- }
- else {
- fNavigationDetail= 0;
- }
- }
-
- protected void onShowSelectedReference(ISelection selection) {
- CHNode node= selectionToNode(selection);
- if (node != null && node == fNavigationNode && node.getReferenceCount() > 0) {
- fNavigationDetail= (fNavigationDetail + 1) % node.getReferenceCount();
- }
- else {
- fNavigationDetail= 0;
- }
- fNavigationNode= node;
- showReference();
- }
-
- protected void onOpenElement(ISelection selection) {
- CHNode node= selectionToNode(selection);
- openElement(node);
- }
-
- private void openElement(CHNode node) {
- if (node != null && !node.isMultiDef()) {
- ICElement elem= node.getRepresentedDeclaration();
- if (elem != null) {
- IWorkbenchPage page= getSite().getPage();
- try {
- EditorOpener.open(page, elem);
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- }
- }
- }
-
- protected void onNextOrPrevious(boolean forward) {
- setNextNode(forward);
- if (fNavigationNode != null) {
- StructuredSelection sel= new StructuredSelection(fNavigationNode);
- fTreeViewer.setSelection(sel);
- showReference();
- }
- }
-
- protected void onRefresh() {
- fContentProvider.recompute();
- }
-
- protected void onShowFilesInLabels(boolean show) {
- fLabelProvider.setShowFiles(show);
- fTreeViewer.refresh();
- }
-
- private void updateHistory(ICElement input) {
- if (input != null) {
- fHistoryEntries.remove(input);
- fHistoryEntries.add(0, input);
- if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
- fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
- }
- }
- }
-
- private void updateSorter() {
- if (fReferencedByAction.isChecked()) {
- fTreeViewer.setComparator(fSorterAlphaNumeric);
- }
- else {
- fTreeViewer.setComparator(fSorterReferencePosition);
- }
- }
-
- private void updateDescription() {
- String message= ""; //$NON-NLS-1$
- if (!fShowsMessage) {
- ICElement elem= getInput();
- if (elem != null) {
- String format, scope, label;
-
- // label
- label= CElementLabels.getElementLabel(elem, CHHistoryAction.LABEL_OPTIONS);
-
- // scope
- IWorkingSet workingSet= fWorkingSetFilterUI.getWorkingSet();
- if (workingSet == null) {
- scope= CHMessages.CHViewPart_WorkspaceScope;
- }
- else {
- scope= workingSet.getLabel();
- }
-
- // format
- if (fReferencedByAction.isChecked()) {
- format= CHMessages.CHViewPart_Title_callers;
- }
- else {
- format= CHMessages.CHViewPart_Title_callees;
- }
-
- // message
- message= Messages.format(format, label, scope);
- }
- }
- setContentDescription(message);
- }
-
- private void updateActionEnablement() {
- fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
- fNextAction.setEnabled(!fShowsMessage);
- fPreviousAction.setEnabled(!fShowsMessage);
- fRefreshAction.setEnabled(!fShowsMessage);
- }
-
- private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
- fContentProvider.setWorkingSetFilter(filterUI);
- }
-
- public void onSetShowReferencedBy(boolean showReferencedBy) {
- if (showReferencedBy != fContentProvider.getComputeReferencedBy()) {
- Object input= fTreeViewer.getInput();
- fTreeViewer.setInput(null);
- fContentProvider.setComputeReferencedBy(showReferencedBy);
- updateSorter();
- fTreeViewer.setInput(input);
- updateDescription();
- }
- }
-
- protected void onContextMenuAboutToShow(IMenuManager menu) {
- CUIPlugin.createStandardGroups(menu);
-
- CHNode node= selectionToNode(fTreeViewer.getSelection());
- if (node != null) {
- if (getReferenceCount(node) > 0) {
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fShowReference);
- }
- if (!node.isMultiDef()) {
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenElement);
- }
- if (node.getParent() != null) {
- final ICElement element= node.getRepresentedDeclaration();
- if (element != null) {
- String label= Messages.format(CHMessages.CHViewPart_FocusOn_label,
- CElementLabels.getTextLabel(element, CElementLabels.ALL_FULLY_QUALIFIED | CElementLabels.M_PARAMETER_TYPES));
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, new Action(label) {
- @Override
- public void run() {
- setInput(element);
- }
- });
- }
- }
- }
-
- // action groups
- ISelection selection = getSite().getSelectionProvider().getSelection();
- if (OpenViewActionGroup.canActionBeAdded(selection)){
- fOpenViewActionGroup.fillContextMenu(menu);
- }
-
- if (fCopyAction.canActionBeAdded()) {
- menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction);
- }
-
- if (SelectionSearchGroup.canActionBeAdded(selection)){
- fSelectionSearchGroup.fillContextMenu(menu);
- }
- fRefactoringActionGroup.fillContextMenu(menu);
- }
-
- private void showReference() {
- if (fNavigationNode != null) {
- ITranslationUnit file= fNavigationNode.getFileOfReferences();
- if (file != null) {
- IWorkbenchPage page= getSite().getPage();
- if (fNavigationNode.getReferenceCount() > 0) {
- long timestamp= fNavigationNode.getTimestamp();
- if (fNavigationDetail < 0) {
- fNavigationDetail= 0;
- }
- else if (fNavigationDetail >= fNavigationNode.getReferenceCount()-1) {
- fNavigationDetail= fNavigationNode.getReferenceCount()-1;
- }
-
- CHReferenceInfo ref= fNavigationNode.getReference(fNavigationDetail);
- Region region= new Region(ref.getOffset(), ref.getLength());
- EditorOpener.open(page, file, region, timestamp);
- }
- else {
- try {
- EditorOpener.open(page, fNavigationNode.getRepresentedDeclaration());
- } catch (CModelException e) {
- CUIPlugin.log(e);
- }
- }
- }
- }
- }
-
- private int getReferenceCount(CHNode node) {
- if (node != null) {
- CHNode parent = node.getParent();
- if (parent instanceof CHMultiDefNode) {
- return parent.getReferenceCount();
- }
- return node.getReferenceCount();
- }
- return 0;
- }
-
-
- private CHNode selectionToNode(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss= (IStructuredSelection) selection;
- for (Iterator> iter = ss.iterator(); iter.hasNext(); ) {
- Object cand= iter.next();
- if (cand instanceof CHNode) {
- return (CHNode) cand;
- }
- }
- }
- return null;
- }
-
- public Control getPageBook() {
- return fPagebook;
- }
-
- public ICElement[] getHistoryEntries() {
- return fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
- }
-
- public void setHistoryEntries(ICElement[] remaining) {
- fHistoryEntries.clear();
- fHistoryEntries.addAll(Arrays.asList(remaining));
- }
-
- public ICElement getInput() {
- Object input= fTreeViewer.getInput();
- if (input instanceof ICElement) {
- return (ICElement) input;
- }
- return null;
- }
-
- public TreeViewer getTreeViewer() {
- return fTreeViewer;
- }
-
- private static class CopyCallHierarchyAction extends CopyTreeAction {
- public CopyCallHierarchyAction(ViewPart view, TreeViewer viewer) {
- super(CHMessages.CHViewPart_CopyCallHierarchy_label, view, viewer);
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java
deleted file mode 100644
index a0554ce..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-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.Job;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.DOMException;
-import org.eclipse.cdt.core.dom.ast.EScopeKind;
-import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
-import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IBinding;
-import org.eclipse.cdt.core.dom.ast.IEnumerator;
-import org.eclipse.cdt.core.dom.ast.IFunction;
-import org.eclipse.cdt.core.dom.ast.IScope;
-import org.eclipse.cdt.core.dom.ast.IVariable;
-import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.index.IIndexManager;
-import org.eclipse.cdt.core.index.IIndexName;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.core.model.ext.ICElementHandle;
-import org.eclipse.cdt.internal.corext.util.CModelUtil;
-
-import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
-
-public class CallHierarchyUI {
- private static final ICElement[] NO_ELEMENTS = {};
- private static boolean sIsJUnitTest= false;
-
- public static void setIsJUnitTest(boolean val) {
- sIsJUnitTest= val;
- }
-
- public static void open(final IWorkbenchWindow window, final ICElement input) {
- if (input != null) {
- final Display display= Display.getCurrent();
-
- Job job= new Job(CHMessages.CallHierarchyUI_label) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- final ICElement[] elems= findDefinitions(input);
- if (elems != null && elems.length > 0) {
- display.asyncExec(new Runnable() {
- public void run() {
- internalOpen(window, elems);
- }});
- }
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
- }
- }
-
- private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement input) {
- IWorkbenchPage page= window.getActivePage();
- try {
- CHViewPart result= (CHViewPart)page.showView(CUIPlugin.ID_CALL_HIERARCHY);
- result.setInput(input);
- return result;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(), CHMessages.OpenCallHierarchyAction_label, null);
- }
- return null;
- }
-
- private static CHViewPart internalOpen(IWorkbenchWindow window, ICElement[] input) {
- ICElement elem = null;
- switch (input.length) {
- case 0:
- break;
- case 1:
- elem = input[0];
- break;
- default:
- if (sIsJUnitTest) {
- throw new RuntimeException("ambiguous input"); //$NON-NLS-1$
- }
- elem = OpenActionUtil.selectCElement(input, window.getShell(),
- CHMessages.CallHierarchyUI_label, CHMessages.CallHierarchyUI_selectMessage,
- CElementLabels.ALL_DEFAULT | CElementLabels.MF_POST_FILE_QUALIFIED, 0);
- break;
- }
- if (elem != null) {
- return internalOpen(window, elem);
- }
- return null;
- }
-
- public static void open(final ITextEditor editor, final ITextSelection sel) {
- if (editor != null) {
- ICElement inputCElement = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
- if (inputCElement != null) {
- final ICProject project= inputCElement.getCProject();
- final IEditorInput editorInput = editor.getEditorInput();
- final Display display= Display.getCurrent();
-
- Job job= new Job(CHMessages.CallHierarchyUI_label) {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- StatusLineHandler.clearStatusLine(editor.getSite());
- final ICElement[] elems= findDefinitions(project, editorInput, sel);
- if (elems.length > 0) {
- display.asyncExec(new Runnable() {
- public void run() {
- internalOpen(editor.getSite().getWorkbenchWindow(), elems);
- }});
- } else {
- StatusLineHandler.showStatusLineMessage(editor.getSite(),
- CHMessages.CallHierarchyUI_openFailureMessage);
- }
- return Status.OK_STATUS;
- }
- catch (CoreException e) {
- return e.getStatus();
- }
- }
- };
- job.setUser(true);
- job.schedule();
- }
- }
- }
-
- private static ICElement[] findDefinitions(ICProject project, IEditorInput editorInput, ITextSelection sel)
- throws CoreException {
- try {
- IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
-
- index.acquireReadLock();
- try {
- IASTName name= IndexUI.getSelectedName(editorInput, sel);
- if (name != null) {
- IBinding binding= name.resolveBinding();
- if (!CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
- for (IASTNode parent= name; parent != null; parent= parent.getParent()) {
- if (parent.getPropertyInParent() == IASTFunctionCallExpression.FUNCTION_NAME) {
- ICPPASTFunctionCallExpression fcall= (ICPPASTFunctionCallExpression) parent.getParent();
- if (fcall != null) {
- IASTImplicitName[] implicit = fcall.getImplicitNames();
- if (implicit.length > 0)
- binding= implicit[0].resolveBinding();
- }
- break;
- }
- }
- }
- if (CallHierarchyUI.isRelevantForCallHierarchy(binding)) {
- if (name.isDefinition()) {
- ICElement elem= IndexUI.getCElementForName(project, index, name);
- if (elem != null) {
- return new ICElement[]{elem};
- }
- return NO_ELEMENTS;
- }
-
- ICElement[] elems= IndexUI.findAllDefinitions(index, binding);
- if (elems.length != 0)
- return elems;
-
- if (name.isDeclaration()) {
- ICElementHandle elem= IndexUI.getCElementForName(project, index, name);
- if (elem != null) {
- return new ICElement[] {elem};
- }
- return NO_ELEMENTS;
- }
-
- ICElementHandle elem= IndexUI.findAnyDeclaration(index, project, binding);
- if (elem != null) {
- return new ICElement[]{elem};
- }
-
- if (binding instanceof ICPPSpecialization) {
- return findSpecializationDeclaration(binding, project, index);
- }
- return NO_ELEMENTS;
- }
- }
- }
- finally {
- index.releaseReadLock();
- }
- } catch (CoreException e) {
- CUIPlugin.log(e);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- return NO_ELEMENTS;
- }
-
- private static ICElement[] findSpecializationDeclaration(IBinding binding, ICProject project,
- IIndex index) throws CoreException {
- while (binding instanceof ICPPSpecialization) {
- IBinding original= ((ICPPSpecialization) binding).getSpecializedBinding();
- ICElementHandle[] elems= IndexUI.findAllDefinitions(index, original);
- if (elems.length == 0) {
- ICElementHandle elem= IndexUI.findAnyDeclaration(index, project, original);
- if (elem != null) {
- elems= new ICElementHandle[]{elem};
- }
- }
- if (elems.length > 0) {
- return elems;
- }
- binding= original;
- }
- return NO_ELEMENTS;
- }
-
- public static ICElement[] findDefinitions(ICElement input) {
- try {
- final ITranslationUnit tu= CModelUtil.getTranslationUnit(input);
- if (tu != null) {
- final ICProject project= tu.getCProject();
- final IIndex index= CCorePlugin.getIndexManager().getIndex(project, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);
-
- index.acquireReadLock();
- try {
- if (needToFindDefinition(input)) {
- IBinding binding= IndexUI.elementToBinding(index, input);
- if (binding != null) {
- ICElement[] result= IndexUI.findAllDefinitions(index, binding);
- if (result.length > 0) {
- return result;
- }
- }
- }
- IIndexName name= IndexUI.elementToName(index, input);
- if (name != null) {
- ICElementHandle handle= IndexUI.getCElementForName(tu, index, name);
- return new ICElement[] {handle};
- }
- }
- finally {
- index.releaseReadLock();
- }
- }
- }
- catch (CoreException e) {
- CUIPlugin.log(e);
- }
- catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- return new ICElement[] {input};
- }
-
- private static boolean needToFindDefinition(ICElement elem) {
- switch (elem.getElementType()) {
- case ICElement.C_FUNCTION_DECLARATION:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
- case ICElement.C_TEMPLATE_METHOD_DECLARATION:
- return true;
- }
- return false;
- }
-
- public static boolean isRelevantForCallHierarchy(IBinding binding) {
- if (binding instanceof ICExternalBinding ||
- binding instanceof IEnumerator ||
- binding instanceof IFunction)
- return true;
-
- if (binding instanceof IVariable) {
- try {
- final IScope scope = binding.getScope();
- if (scope != null && scope.getKind() == EScopeKind.eLocal)
- return false;
- } catch (DOMException e) {
- }
- return true;
- }
- return false;
- }
-
- public static boolean isRelevantForCallHierarchy(ICElement elem) {
- if (elem == null) {
- return false;
- }
- switch (elem.getElementType()) {
- case ICElement.C_ENUMERATOR:
- case ICElement.C_FIELD:
- case ICElement.C_FUNCTION:
- case ICElement.C_FUNCTION_DECLARATION:
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_TEMPLATE_FUNCTION:
- case ICElement.C_TEMPLATE_FUNCTION_DECLARATION:
- case ICElement.C_TEMPLATE_METHOD:
- case ICElement.C_TEMPLATE_METHOD_DECLARATION:
- case ICElement.C_TEMPLATE_VARIABLE:
- case ICElement.C_VARIABLE:
- case ICElement.C_VARIABLE_DECLARATION:
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java
deleted file mode 100644
index d649f34..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CalledByResult.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.core.index.IIndexName;
-import org.eclipse.cdt.core.model.ICElement;
-
-public class CalledByResult {
- private Map> fElementToReferences= new HashMap>();
-
- public ICElement[] getElements() {
- Set elements = fElementToReferences.keySet();
- return elements.toArray(new ICElement[elements.size()]);
- }
-
- public IIndexName[] getReferences(ICElement calledElement) {
- List references= fElementToReferences.get(calledElement);
- return references.toArray(new IIndexName[references.size()]);
- }
-
- public void add(ICElement elem, IIndexName ref) {
- List list= fElementToReferences.get(elem);
- if (list == null) {
- list= new ArrayList();
- fElementToReferences.put(elem, list);
- }
- list.add(ref);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java
deleted file mode 100644
index c61ee02..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallsToResult.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.cdt.core.index.IIndexName;
-import org.eclipse.cdt.core.model.ICElement;
-
-public class CallsToResult {
- private Map> fElementSetsToReferences= new HashMap>();
-
- public CElementSet[] getElementSets() {
- Set elementSets = fElementSetsToReferences.keySet();
- return elementSets.toArray(new CElementSet[elementSets.size()]);
- }
-
- public IIndexName[] getReferences(CElementSet elementSet) {
- List references= fElementSetsToReferences.get(elementSet);
- return references.toArray(new IIndexName[references.size()]);
- }
-
- public void add(ICElement[] elems, IIndexName ref) {
- CElementSet key= new CElementSet(elems);
- List list= fElementSetsToReferences.get(key);
- if (list == null) {
- list= new ArrayList();
- fElementSetsToReferences.put(key, list);
- }
- list.add(ref);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
deleted file mode 100644
index b6f5bec..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenCallHierarchyAction.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IEnumeration;
-import org.eclipse.cdt.core.model.IEnumerator;
-import org.eclipse.cdt.core.model.IFunctionDeclaration;
-import org.eclipse.cdt.core.model.IVariableDeclaration;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-
-
-public class OpenCallHierarchyAction extends SelectionDispatchAction {
-
- private ITextEditor fEditor;
-
- public OpenCallHierarchyAction(IWorkbenchSite site) {
- super(site);
- setText(CHMessages.OpenCallHierarchyAction_label);
- setToolTipText(CHMessages.OpenCallHierarchyAction_tooltip);
- }
-
- public OpenCallHierarchyAction(ITextEditor editor) {
- this(editor.getSite());
- fEditor= editor;
- setEnabled(fEditor != null && CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()) != null);
- }
-
- @Override
- public void run(ITextSelection sel) {
- CallHierarchyUI.open(fEditor, sel);
- }
-
- @Override
- public void run(IStructuredSelection selection) {
- if (!selection.isEmpty()) {
- Object selectedObject= selection.getFirstElement();
- ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
- if (elem != null) {
- CallHierarchyUI.open(getSite().getWorkbenchWindow(), elem);
- }
- }
- }
-
- @Override
- public void selectionChanged(ITextSelection sel) {
- }
-
- @Override
- public void selectionChanged(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- setEnabled(false);
- return;
- }
-
- Object selectedObject= selection.getFirstElement();
- ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
- if (elem != null) {
- setEnabled(isValidElement(elem));
- }
- else {
- setEnabled(false);
- }
- }
-
- private boolean isValidElement(ICElement elem) {
- if (elem instanceof IFunctionDeclaration) {
- return true;
- }
- if (elem instanceof IVariableDeclaration) {
- return !(elem instanceof IEnumeration);
- }
- if (elem instanceof IEnumerator) {
- return true;
- }
- return false;
- }
-
- @SuppressWarnings("rawtypes")
- private Object getAdapter(Object object, Class desiredClass) {
- if (desiredClass.isInstance(object)) {
- return object;
- }
- if (object instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) object;
- return adaptable.getAdapter(desiredClass);
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java
deleted file mode 100644
index 5fa962e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog;
-
-public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionDelegate {
-
- private static final int[] VISIBLE_TYPES = {
- ICElement.C_FUNCTION, ICElement.C_METHOD, ICElement.C_VARIABLE, ICElement.C_ENUMERATOR,
- ICElement.C_FUNCTION_DECLARATION, ICElement.C_METHOD_DECLARATION, ICElement.C_VARIABLE_DECLARATION };
-
- private IWorkbenchWindow fWorkbenchWindow;
-
- public OpenElementInCallHierarchyAction() {
- }
-
- public void run(IAction action) {
- ElementSelectionDialog dialog = new ElementSelectionDialog(getShell());
- configureDialog(dialog);
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
- if (info == null)
- return;
-
- ICElement[] elements= null;
- ITypeReference location = info.getResolvedReference();
- if (location != null) {
- elements= location.getCElements();
- }
- if (elements == null || elements.length == 0) {
- String title = CHMessages.OpenElementInCallHierarchyAction_errorDlgTitle;
- String message = NLS.bind(CHMessages.OpenElementInCallHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString());
- MessageDialog.openError(getShell(), title, message);
- }
- else {
- CallHierarchyUI.open(fWorkbenchWindow, elements[0]);
- }
- }
-
- private void configureDialog(ElementSelectionDialog dialog) {
- dialog.setDialogSettings(getClass().getName());
- dialog.setVisibleTypes(VISIBLE_TYPES);
- dialog.setTitle(CHMessages.OpenElementInCallHierarchyAction_title);
- dialog.setUpperListLabel(CHMessages.OpenElementInCallHierarchyAction_upperListLabel);
- dialog.setMessage(CHMessages.OpenElementInCallHierarchyAction_message);
-
- if (fWorkbenchWindow != null) {
- IWorkbenchPage page= fWorkbenchWindow.getActivePage();
- if (page != null) {
- IWorkbenchPart part= page.getActivePart();
- if (part instanceof ITextEditor) {
- ISelection sel= ((ITextEditor) part).getSelectionProvider().getSelection();
- if (sel instanceof ITextSelection) {
- String txt= ((ITextSelection) sel).getText();
- if (txt.length() > 0 && txt.length() < 80) {
- dialog.setFilter(txt, true);
- }
- }
- }
- }
- }
- }
-
- private Shell getShell() {
- return fWorkbenchWindow.getShell();
- }
-
- public void dispose() {
- fWorkbenchWindow= null;
- }
-
- public void init(IWorkbenchWindow window) {
- fWorkbenchWindow= window;
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java
deleted file mode 100644
index 3b1dcc3..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/ReferenceVisitor.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 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:
- * Markus Schorn - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.callhierarchy;
-
-import java.util.ArrayList;
-
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-
-/**
- * Visitor to find references in a given range of the source code.
- * @since 4.0
- */
-class ReferenceVisitor extends ASTVisitor {
- private ArrayList fReferences= new ArrayList();
- private int fOffset;
- private int fEndOffset;
- private String fFileName;
-
- ReferenceVisitor(String fileName, int offset, int length) {
- shouldVisitNames= true;
- shouldVisitDeclarations= true;
-
- fFileName= fileName;
- fOffset= offset;
- fEndOffset= offset+length;
- }
-
- public IASTName[] getReferences() {
- return fReferences.toArray(new IASTName[fReferences.size()]);
- }
-
- @Override
- public int visit(IASTName name) {
- if (name.isReference()) {
- IASTFileLocation loc= name.getFileLocation();
- if (!loc.getFileName().equals(fFileName)) {
- return PROCESS_SKIP;
- }
- int offset= loc.getNodeOffset();
- if (fOffset <= offset && offset+loc.getNodeLength() <= fEndOffset) {
- fReferences.add(name);
- }
- }
- return super.visit(name);
- }
-
- @Override
- public int visit(IASTDeclaration declaration) {
- IASTFileLocation loc= declaration.getFileLocation();
- if (loc != null) {
- if (!loc.getFileName().equals(fFileName)) {
- return PROCESS_SKIP;
- }
- int offset= loc.getNodeOffset();
- if (offset + loc.getNodeLength() <= fOffset || fEndOffset <= offset) {
- return PROCESS_SKIP;
- }
- }
- return PROCESS_CONTINUE;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java
deleted file mode 100644
index fbcfeb3..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AbstractMergeViewer.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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
- * Andrew Ferguson (Symbian)
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.ICColorConstants;
-import org.eclipse.cdt.ui.text.ICPartitions;
-
-
-/**
- * Abstract implementation of a merge viewer.
- */
-abstract class AbstractMergeViewer extends TextMergeViewer {
-
- private IPropertyChangeListener fPreferenceChangeListener;
- private IPreferenceStore fPreferenceStore;
-
- protected boolean fUseSystemColors;
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns null if there is no such information available.
- */
- protected static RGB createColor(IPreferenceStore store, String key) {
- if (!store.contains(key))
- return null;
- if (store.isDefault(key))
- return PreferenceConverter.getDefaultColor(store, key);
- return PreferenceConverter.getColor(store, key);
- }
-
- /**
- * Create a new merge viewer.
- *
- * @param parent
- * @param style
- * @param configuration
- */
- public AbstractMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
- super(parent, style | SWT.LEFT_TO_RIGHT, configuration);
-
- IPreferenceStore store = getPreferenceStore();
-
- fUseSystemColors= store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
- if (! fUseSystemColors) {
- RGB bg= createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
- setBackgroundColor(bg);
- RGB fg= createColor(store, ICColorConstants.C_DEFAULT);
- setForegroundColor(fg);
- }
-
- }
-
- protected IPreferenceStore getPreferenceStore() {
- if (fPreferenceStore == null) {
- fPreferenceStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
- fPreferenceChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- handlePropertyChange(event);
- }
- };
- fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
- }
- return fPreferenceStore;
- }
-
- @Override
- protected void handleDispose(DisposeEvent event) {
- if (fPreferenceChangeListener != null) {
- fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
- fPreferenceChangeListener= null;
- }
- super.handleDispose(event);
- }
-
- protected void handlePropertyChange(PropertyChangeEvent event) {
-
- String key= event.getProperty();
-
- if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) {
-
- if (!fUseSystemColors) {
- RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
- setBackgroundColor(bg);
- }
-
- } else if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
-
- fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
- if (fUseSystemColors) {
- setBackgroundColor(null);
- setForegroundColor(null);
- } else {
- RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
- setBackgroundColor(bg);
- RGB fg= createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
- setForegroundColor(fg);
- }
- } else if (key.equals(ICColorConstants.C_DEFAULT)) {
-
- if (!fUseSystemColors) {
- RGB fg= createColor(fPreferenceStore, ICColorConstants.C_DEFAULT);
- setForegroundColor(fg);
- }
- }
- }
-
- @Override
- protected String getDocumentPartitioning() {
- return ICPartitions.C_PARTITIONING;
- }
-
- @Override
- protected void configureTextViewer(TextViewer textViewer) {
- if (textViewer instanceof SourceViewer) {
- ((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
- }
- }
-
- /*
- * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#getTitle()
- */
- @Override
- public abstract String getTitle();
-
- /**
- * @return a source configuration for the viewer
- */
- protected abstract SourceViewerConfiguration getSourceViewerConfiguration();
-
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java
deleted file mode 100644
index 243627e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmContentViewerCreator.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Wind River 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IViewerCreator;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Creates a merge viewer for assembly code.
- */
-public class AsmContentViewerCreator implements IViewerCreator {
-
- /*
- * @see org.eclipse.compare.IViewerCreator#createViewer(org.eclipse.swt.widgets.Composite, org.eclipse.compare.CompareConfiguration)
- */
- public Viewer createViewer(Composite parent, CompareConfiguration config) {
- return new AsmMergeViewer(parent, SWT.NULL, config);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java
deleted file mode 100644
index 9321468..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/AsmMergeViewer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 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.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.cdt.ui.CDTUITools;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.AsmSourceViewerConfiguration;
-import org.eclipse.cdt.ui.text.ICPartitions;
-import org.eclipse.cdt.ui.text.IColorManager;
-
-/**
- * A merge viewer for assembly code.
- */
-public class AsmMergeViewer extends AbstractMergeViewer {
-
- private static final String TITLE= "AsmMergeViewer.title"; //$NON-NLS-1$
-
- AsmSourceViewerConfiguration fSourceViewerConfiguration;
-
- /**
- * Create a new assembly merge viewer.
- *
- * @param parent
- * @param style
- * @param configuration
- */
- public AsmMergeViewer(Composite parent, int style, CompareConfiguration configuration) {
- super(parent, style, configuration);
- }
-
- @Override
- protected SourceViewerConfiguration getSourceViewerConfiguration() {
- if (fSourceViewerConfiguration == null) {
- IPreferenceStore store= getPreferenceStore();
- final IColorManager colorManager = CDTUITools.getColorManager();
- fSourceViewerConfiguration= new AsmSourceViewerConfiguration(colorManager, store, null, ICPartitions.C_PARTITIONING);
- }
- return fSourceViewerConfiguration;
- }
-
- @Override
- public String getTitle() {
- return CUIPlugin.getResourceString(TITLE);
- }
-
- @Override
- protected IDocumentPartitioner getDocumentPartitioner() {
- return CDTUITools.createAsmDocumentPartitioner();
- }
-
- @Override
- protected void handlePropertyChange(PropertyChangeEvent event) {
- super.handlePropertyChange(event);
-
- if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
- fSourceViewerConfiguration.handlePropertyChangeEvent(event);
- invalidateTextPresentation();
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
deleted file mode 100644
index 9e24f2f..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CContentViewerCreator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.compare;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.IViewerCreator;
-
-
-import org.eclipse.jface.viewers.Viewer;
-
-
-/**
- * Required when creating a CMergeViewer from the plugin.xml file.
- */
-public class CContentViewerCreator implements IViewerCreator {
-
- public Viewer createViewer(Composite parent, CompareConfiguration mp) {
- return new CMergeViewer(parent, SWT.NULL, mp);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
deleted file mode 100644
index 0068174..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CMergeViewer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.compare;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.CSourceViewerConfiguration;
-import org.eclipse.cdt.ui.text.ICPartitions;
-import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
-
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
-
-/**
- * A merge viewer for C/C++ code.
- */
-public class CMergeViewer extends AbstractMergeViewer {
-
- private static final String TITLE= "CMergeViewer.title"; //$NON-NLS-1$
-
- CSourceViewerConfiguration fSourceViewerConfiguration;
-
- public CMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
- super(parent, styles, mp);
- }
-
- @Override
- protected SourceViewerConfiguration getSourceViewerConfiguration() {
- if (fSourceViewerConfiguration == null) {
- CTextTools tools= CUIPlugin.getDefault().getTextTools();
- IPreferenceStore store = getPreferenceStore();
- fSourceViewerConfiguration = new CSourceViewerConfiguration(tools.getColorManager(), store, null, ICPartitions.C_PARTITIONING);
- }
- return fSourceViewerConfiguration;
- }
-
- @Override
- protected IDocumentPartitioner getDocumentPartitioner() {
- // use workspace default for highlighting doc comments in compare viewer
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
- return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
- }
-
- @Override
- public String getTitle() {
- return CUIPlugin.getResourceString(TITLE);
- }
-
- @Override
- protected void handlePropertyChange(PropertyChangeEvent event) {
- super.handlePropertyChange(event);
-
- if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
- fSourceViewerConfiguration.handlePropertyChangeEvent(event);
- invalidateTextPresentation();
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
deleted file mode 100644
index 434cff3..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CNode.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.compare;
-
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Image;
-
-/**
- *
- */
-class CNode extends DocumentRangeNode implements ITypedElement {
-
- public CNode(DocumentRangeNode parent, int type, String id, IDocument doc, int start, int length) {
- super(parent, type, id, doc, start, length);
- if (parent != null) {
- parent.addChild(this);
- }
- }
-
- public CNode(DocumentRangeNode parent, int type, String id, int start, int length) {
- this(parent, type, id, parent.getDocument(), start, length);
- }
-
- public String getName() {
- return getId();
- }
-
- public String getType() {
- return "c2"; //$NON-NLS-1$
- }
-
- public Image getImage() {
- ImageDescriptor descriptor = CElementImageProvider.getImageDescriptor(getTypeCode());
- return CUIPlugin.getImageDescriptorRegistry().get(descriptor);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
deleted file mode 100644
index 8ae775f..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreator.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- * Anton Leherbauer (Wind River Systems)
- * Andrew Ferguson (Symbian)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.compare;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.eclipse.compare.IEncodedStreamContentAccessor;
-import org.eclipse.compare.ISharedDocumentAdapter;
-import org.eclipse.compare.IStreamContentAccessor;
-import org.eclipse.compare.ResourceNode;
-import org.eclipse.compare.contentmergeviewer.IDocumentRange;
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.compare.structuremergeviewer.IStructureComparator;
-import org.eclipse.compare.structuremergeviewer.StructureCreator;
-import org.eclipse.compare.structuremergeviewer.StructureRootNode;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.Position;
-
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ILanguage;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.parser.FileContent;
-import org.eclipse.cdt.core.parser.IScannerInfo;
-import org.eclipse.cdt.core.parser.IncludeFileContentProvider;
-import org.eclipse.cdt.core.parser.ParserUtil;
-import org.eclipse.cdt.core.parser.ScannerInfo;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.ICPartitions;
-import org.eclipse.cdt.ui.text.doctools.IDocCommentOwner;
-
-import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager;
-
-/**
- * A structure creator for C/C++ translation units.
- */
-public class CStructureCreator extends StructureCreator {
-
- private static final String NAME = "CStructureCreator.name"; //$NON-NLS-1$
-
- public CStructureCreator() {
- }
-
- public String getName() {
- return CUIPlugin.getResourceString(NAME);
- }
-
- /*
- * @see IStructureCreator#getContents
- */
- public String getContents(Object node, boolean ignoreWhitespace) {
- if (node instanceof IDocumentRange) {
- IDocumentRange documentRange= (IDocumentRange)node;
- final Position range = documentRange.getRange();
- try {
- return documentRange.getDocument().get(range.getOffset(), range.getLength());
- } catch (BadLocationException exc) {
- }
- }
- if (node instanceof IStreamContentAccessor) {
- IStreamContentAccessor sca = (IStreamContentAccessor) node;
- try {
- return readString(sca);
- } catch (CoreException ex) {
- }
- }
- return null;
- }
-
- /*
- * @see org.eclipse.compare.structuremergeviewer.StructureCreator#createStructureComparator(java.lang.Object, org.eclipse.jface.text.IDocument, org.eclipse.compare.ISharedDocumentAdapter, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- protected IStructureComparator createStructureComparator(Object element,
- IDocument document, ISharedDocumentAdapter sharedDocumentAdapter,
- IProgressMonitor monitor) throws CoreException {
-
- DocumentRangeNode root= new StructureRootNode(document, element, this, sharedDocumentAdapter);
-
- // don't follow inclusions
- IncludeFileContentProvider contentProvider = IncludeFileContentProvider.getEmptyFilesProvider();
-
- // empty scanner info
- IScannerInfo scanInfo= new ScannerInfo();
-
- FileContent content = FileContent.create("", document.get().toCharArray()); //$NON-NLS-1$
-
- // determine the language
- boolean isSource[]= {false};
- ILanguage language= determineLanguage(element, isSource);
-
- try {
- IASTTranslationUnit ast;
- int options= isSource[0] ? ILanguage.OPTION_IS_SOURCE_UNIT : 0;
- ast= language.getASTTranslationUnit(content, scanInfo, contentProvider, null, options, ParserUtil.getParserLogService());
- CStructureCreatorVisitor structureCreator= new CStructureCreatorVisitor(root);
- // build structure
- ast.accept(structureCreator);
- } catch (CoreException exc) {
- CUIPlugin.log(exc);
- }
-
- return root;
- }
-
- /**
- * Try to determine the ILanguage for the given input element.
- *
- * @param element
- * @return a language instance
- */
- private ILanguage determineLanguage(Object element, boolean[] isSource) {
- ILanguage language= null;
- if (element instanceof ResourceNode) {
- IResource resource= ((ResourceNode)element).getResource();
- if (resource.getType() == IResource.FILE) {
- ITranslationUnit tUnit= (ITranslationUnit)CoreModel.getDefault().create(resource);
- if (tUnit != null) {
- try {
- language= tUnit.getLanguage();
- isSource[0]= tUnit.isSourceUnit();
- } catch (CoreException exc) {
- // silently ignored
- }
- }
- }
- }
- if (language == null) {
- language= GPPLanguage.getDefault();
- }
- return language;
- }
-
- @Override
- protected String getDocumentPartitioning() {
- return ICPartitions.C_PARTITIONING;
- }
-
- @Override
- protected IDocumentPartitioner getDocumentPartitioner() {
- // use workspace default for highlighting doc comments in compare viewer
- IDocCommentOwner owner= DocCommentOwnerManager.getInstance().getWorkspaceCommentOwner();
- return CUIPlugin.getDefault().getTextTools().createDocumentPartitioner(owner);
- }
-
- private static String readString(IStreamContentAccessor sa) throws CoreException {
- InputStream is= sa.getContents();
- if (is != null) {
- String encoding= null;
- if (sa instanceof IEncodedStreamContentAccessor) {
- try {
- encoding= ((IEncodedStreamContentAccessor) sa).getCharset();
- } catch (Exception e) {
- }
- }
- if (encoding == null)
- encoding= ResourcesPlugin.getEncoding();
- return readString(is, encoding);
- }
- return null;
- }
-
- private static String readString(InputStream is, String encoding) {
- if (is == null)
- return null;
- BufferedReader reader= null;
- try {
- StringBuffer buffer= new StringBuffer();
- char[] part= new char[2048];
- int read= 0;
- reader= new BufferedReader(new InputStreamReader(is, encoding));
-
- while ((read= reader.read(part)) != -1)
- buffer.append(part, 0, read);
-
- return buffer.toString();
-
- } catch (IOException ex) {
- // NeedWork
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException ex) {
- // silently ignored
- }
- }
- }
- return null;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java
deleted file mode 100644
index a12e512..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/CStructureCreatorVisitor.java
+++ /dev/null
@@ -1,534 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 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.compare;
-
-import java.util.Stack;
-
-import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-
-import org.eclipse.cdt.core.dom.ast.ASTVisitor;
-import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier;
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
-import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
-import org.eclipse.cdt.core.dom.ast.IASTName;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
-import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
-import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLinkageSpecification;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceAlias;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
-import org.eclipse.cdt.core.model.ICElement;
-
-import org.eclipse.cdt.internal.core.model.ASTStringUtil;
-import org.eclipse.cdt.internal.core.model.CoreModelMessages;
-
-import org.eclipse.cdt.internal.ui.CUIMessages;
-
-/**
- * AST visitor to create compare structure.
- *
- * @since 5.0
- */
-class CStructureCreatorVisitor extends ASTVisitor {
-
- private static final String TRANSLATION_UNIT_NAME = CUIMessages.CStructureCreatorVisitor_translationUnitName;
- private static final String ANONYMOUS_NAME= CoreModelMessages.getString("CElementLabels.anonymous"); //$NON-NLS-1$
-
- private Stack fStack = new Stack();
- private IDocument fDocument;
- private String fTranslationUnitFileName;
-
- /**
- * Create visitor adding nodes to given root.
- *
- * @param root
- */
- public CStructureCreatorVisitor(DocumentRangeNode root) {
- fDocument = root.getDocument();
- fStack.clear();
- fStack.push(root);
- // visitor options
- shouldVisitTranslationUnit= true;
- shouldVisitDeclarations= true;
- shouldVisitEnumerators=true;
- shouldVisitNamespaces=true;
- }
-
- /*
- * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
- */
- @Override
- public int visit(IASTTranslationUnit tu) {
- fTranslationUnitFileName= tu.getFilePath();
-
- push(ICElement.C_UNIT, TRANSLATION_UNIT_NAME, 0);
-
- // TODO fix ordering of includes and macros
- // includes
- final IASTPreprocessorIncludeStatement[] includeDirectives= tu.getIncludeDirectives();
- for (int i= 0; i < includeDirectives.length; i++) {
- IASTPreprocessorIncludeStatement includeDirective= includeDirectives[i];
- if (isLocalToFile(includeDirective)) {
- push(ICElement.C_INCLUDE, new String(includeDirective.getName().toCharArray()), getStartOffset(includeDirective));
- pop(getEndOffset(includeDirective));
- }
- }
- // macros
- final IASTPreprocessorMacroDefinition[] macroDefinitions= tu.getMacroDefinitions();
- for (int i= 0; i < macroDefinitions.length; i++) {
- IASTPreprocessorMacroDefinition macroDefinition= macroDefinitions[i];
- if (isLocalToFile(macroDefinition)) {
- push(ICElement.C_MACRO, new String(macroDefinition.getName().toCharArray()), getStartOffset(macroDefinition));
- pop(getEndOffset(macroDefinition));
- }
- }
-
- return super.visit(tu);
- }
-
- /**
- * Test whether given AST node is local to the source file
- * and not part of an inclusion.
- *
- * @param node
- * @return true if the node is part of the source file.
- */
- private boolean isLocalToFile(IASTNode node) {
- return fTranslationUnitFileName.equals(node.getContainingFilename());
- }
-
- /**
- * Compute the start offset of given AST node.
- *
- * @param node
- * @return
- */
- private int getStartOffset(IASTNode node) {
- IASTFileLocation fileLocation= getMinFileLocation(node.getNodeLocations());
- if (fileLocation != null) {
- return fileLocation.getNodeOffset();
- }
- DocumentRangeNode container= getCurrentContainer();
- Object[] children= container.getChildren();
- if (children != null && children.length > 0) {
- Position prevRange= ((DocumentRangeNode)children[children.length - 1]).getRange();
- return prevRange.getOffset() + prevRange.getLength();
- }
- // fallback: use container range start
- Position containerRange= container.getRange();
- return containerRange.getOffset();
- }
-
- /**
- * Compute the end offset of give AST node.
- *
- * @param node
- * @return
- */
- private int getEndOffset(IASTNode node) {
- IASTFileLocation fileLocation= getMaxFileLocation(node.getNodeLocations());
- if (fileLocation != null) {
- return fileLocation.getNodeOffset() + fileLocation.getNodeLength();
- }
- // fallback: use container range end
- DocumentRangeNode container= getCurrentContainer();
- Position containerRange= container.getRange();
- return containerRange.getOffset() + containerRange.getLength();
- }
-
-/*
- * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
- */
- @Override
- public int leave(IASTTranslationUnit tu) {
- super.leave(tu);
- assert getCurrentContainer().getTypeCode() == ICElement.C_UNIT;
- pop(fDocument.getLength());
- return PROCESS_SKIP;
- }
-
- /*
- * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
- */
- @Override
- public int visit(IASTDeclaration node) {
- boolean isTemplateDecl= isTemplateDecl(node);
- final int startOffset= isTemplateDecl ? getStartOffset(node.getParent()) : getStartOffset(node);
- final int endOffset= getEndOffset(node);
- if (node instanceof IASTFunctionDefinition) {
- IASTFunctionDefinition functionDef= (IASTFunctionDefinition)node;
- final int nodeType;
- if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
- } else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
- }
- push(nodeType, getDeclaratorName(functionDef.getDeclarator()), startOffset);
- pop(endOffset);
- return PROCESS_SKIP;
- } else if (node instanceof IASTSimpleDeclaration) {
- IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)node;
- IASTDeclSpecifier declSpec= simpleDecl.getDeclSpecifier();
- if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
- ICPPASTCompositeTypeSpecifier compositeTypeSpec= (ICPPASTCompositeTypeSpecifier)declSpec;
- final String nodeName= getTypeName(compositeTypeSpec);
- final int nodeType;
- switch (compositeTypeSpec.getKey()) {
- case IASTCompositeTypeSpecifier.k_struct:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
- break;
- case IASTCompositeTypeSpecifier.k_union:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
- break;
- case ICPPASTCompositeTypeSpecifier.k_class:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
- break;
- default:
- assert false : "Unexpected composite type specifier"; //$NON-NLS-1$
- return PROCESS_CONTINUE;
- }
- push(nodeType, nodeName, startOffset);
- } else if (declSpec instanceof IASTEnumerationSpecifier) {
- IASTEnumerationSpecifier enumSpecifier= (IASTEnumerationSpecifier)declSpec;
- push(ICElement.C_ENUMERATION, getEnumerationName(enumSpecifier), startOffset);
- } else {
- IASTDeclarator[] declarators= simpleDecl.getDeclarators();
- for (int i = 0; i < declarators.length; i++) {
- IASTDeclarator declarator= declarators[i];
- int declStartOffset= declarators.length == 1 ? startOffset : getStartOffset(declarator);
- int declEndOffset= declarators.length == 1 ? endOffset : getEndOffset(declarator);
- final String nodeName = getDeclaratorName(declarator);
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
- push(ICElement.C_TYPEDEF, nodeName, declStartOffset);
- pop(declEndOffset);
- } else if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
- final int nodeType;
- if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION : ICElement.C_METHOD_DECLARATION;
- } else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION : ICElement.C_FUNCTION_DECLARATION;
- }
- push(nodeType, nodeName, declStartOffset);
- pop(declEndOffset);
- } else if (declarator != null) {
- final int nodeType;
- if (inClassBody()) {
- nodeType= ICElement.C_FIELD;
- } else {
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) {
- nodeType= ICElement.C_VARIABLE_DECLARATION;
- } else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
- }
- }
- push(nodeType, nodeName, declStartOffset);
- pop(declEndOffset);
- }
- }
- }
- } else if (node instanceof IASTASMDeclaration) {
- // ignored
- } else if (node instanceof ICPPASTVisibilityLabel) {
- // ignored
- } else if (node instanceof ICPPASTNamespaceDefinition) {
- // handled below
- } else if (node instanceof ICPPASTNamespaceAlias) {
- // ignored
- } else if (node instanceof ICPPASTUsingDeclaration) {
- ICPPASTUsingDeclaration usingDecl= (ICPPASTUsingDeclaration)node;
- push(ICElement.C_USING, ASTStringUtil.getQualifiedName(usingDecl.getName()), startOffset);
- pop(endOffset);
- } else if (node instanceof ICPPASTUsingDirective) {
- ICPPASTUsingDirective usingDirective= (ICPPASTUsingDirective)node;
- push(ICElement.C_USING, ASTStringUtil.getQualifiedName(usingDirective.getQualifiedName()), startOffset);
- pop(endOffset);
- } else if (node instanceof ICPPASTLinkageSpecification) {
- // declarations get flattened
- } else if (node instanceof ICPPASTTemplateDeclaration) {
- // handled at child declaration level
- } else if (node instanceof ICPPASTTemplateSpecialization) {
- // ignored
- } else if (node instanceof ICPPASTExplicitTemplateInstantiation) {
- // ignored
- } else if (node instanceof IASTProblemDeclaration) {
- // ignored
- }
- return super.visit(node);
- }
-
- /*
- * @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
- */
- @Override
- public int visit(ICPPASTNamespaceDefinition namespace) {
- push(ICElement.C_NAMESPACE, ASTStringUtil.getQualifiedName(namespace.getName()), getStartOffset(namespace));
- return super.visit(namespace);
- }
-
- /*
- * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
- */
- @Override
- public int visit(IASTEnumerator enumerator) {
- push(ICElement.C_ENUMERATOR, ASTStringUtil.getQualifiedName(enumerator.getName()), getStartOffset(enumerator));
- pop(getEndOffset(enumerator));
- return super.visit(enumerator);
- }
-
- /*
- * @see org.eclipse.cdt.core.dom.ast.ASTVisitor#leave(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
- */
- @Override
- public int leave(IASTDeclaration node) {
- super.leave(node);
- boolean isTemplateDecl= isTemplateDecl(node);
- final int endOffset= isTemplateDecl ? getEndOffset(node.getParent()) : getEndOffset(node);
- if (node instanceof IASTFunctionDefinition) {
- final int nodeType;
- if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD : ICElement.C_METHOD;
- } else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION : ICElement.C_FUNCTION;
- }
- assert getCurrentContainer().getTypeCode() == nodeType;
- pop(endOffset);
- } else if (node instanceof IASTSimpleDeclaration) {
- IASTSimpleDeclaration simpleDecl= (IASTSimpleDeclaration)node;
- IASTDeclSpecifier declSpec= simpleDecl.getDeclSpecifier();
- boolean isCompositeType= false;
- if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
- isCompositeType= true;
- ICPPASTCompositeTypeSpecifier compositeTypeSpec= (ICPPASTCompositeTypeSpecifier)declSpec;
- final int nodeType;
- switch (compositeTypeSpec.getKey()) {
- case IASTCompositeTypeSpecifier.k_struct:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
- break;
- case IASTCompositeTypeSpecifier.k_union:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
- break;
- case ICPPASTCompositeTypeSpecifier.k_class:
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
- break;
- default:
- assert false : "Unexpected composite type specifier"; //$NON-NLS-1$
- return PROCESS_CONTINUE;
- }
- assert getCurrentContainer().getTypeCode() == nodeType;
- pop(isTemplateDecl ? endOffset : getEndOffset(declSpec));
- } else if (declSpec instanceof IASTEnumerationSpecifier) {
- isCompositeType= true;
- assert getCurrentContainer().getTypeCode() == ICElement.C_ENUMERATION;
- pop(getEndOffset(declSpec));
- }
- if (isCompositeType) {
- IASTDeclarator[] declarators= simpleDecl.getDeclarators();
- for (int i= 0; i < declarators.length; i++) {
- IASTDeclarator declarator= declarators[i];
- final String nodeName= getDeclaratorName(declarator);
- final int declStartOffset= getStartOffset(declarator);
- final int declEndOffset= getEndOffset(declarator);
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_typedef) {
- push(ICElement.C_TYPEDEF, nodeName, declStartOffset);
- pop(declEndOffset);
- } else if (declarator instanceof IASTFunctionDeclarator && !hasNestedPointerOperators(declarator)) {
- final int nodeType;
- if (inClassBody()) {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_METHOD_DECLARATION : ICElement.C_METHOD_DECLARATION;
- } else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_FUNCTION_DECLARATION : ICElement.C_FUNCTION_DECLARATION;
- }
- push(nodeType, nodeName, declStartOffset);
- pop(declEndOffset);
- } else if (declarator != null) {
- final int nodeType;
- if (inClassBody()) {
- nodeType= ICElement.C_FIELD;
- } else {
- if (declSpec.getStorageClass() == IASTDeclSpecifier.sc_extern) {
- nodeType= ICElement.C_VARIABLE_DECLARATION;
- } else {
- nodeType= isTemplateDecl ? ICElement.C_TEMPLATE_VARIABLE : ICElement.C_VARIABLE;
- }
- }
- push(nodeType, nodeName, declStartOffset);
- pop(declEndOffset);
- }
- }
- }
- } else if (node instanceof IASTASMDeclaration) {
- // ignored
- } else if (node instanceof ICPPASTVisibilityLabel) {
- // ignored
- } else if (node instanceof ICPPASTNamespaceDefinition) {
- // handled below
- } else if (node instanceof ICPPASTNamespaceAlias) {
- // ignored
- } else if (node instanceof ICPPASTUsingDeclaration) {
- // handled in visit
- } else if (node instanceof ICPPASTUsingDirective) {
- // handled in visit
- } else if (node instanceof ICPPASTLinkageSpecification) {
- // declarations get flattened
- } else if (node instanceof ICPPASTTemplateDeclaration) {
- // handled at child declaration level
- } else if (node instanceof ICPPASTTemplateSpecialization) {
- // ignored
- } else if (node instanceof ICPPASTExplicitTemplateInstantiation) {
- // ignored
- } else if (node instanceof IASTProblemDeclaration) {
- // ignored
- }
- return PROCESS_CONTINUE;
- }
-
- /*
- * @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#leave(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
- */
- @Override
- public int leave(ICPPASTNamespaceDefinition namespace) {
- assert getCurrentContainer().getTypeCode() == ICElement.C_NAMESPACE;
- pop(getEndOffset(namespace));
- return super.leave(namespace);
- }
-
- private DocumentRangeNode getCurrentContainer() {
- return fStack.peek();
- }
-
- /**
- * Adds a new node with the given type and name to the current container.
- */
- private void push(int type, String name, int declarationStart) {
- if (name.length() == 0) {
- name= ANONYMOUS_NAME;
- }
- fStack.push(new CNode(getCurrentContainer(), type, name, declarationStart, 0));
- }
-
- /**
- * Closes the current node by setting its end position
- * and pops it off the stack.
- */
- private void pop(int declarationEnd) {
- DocumentRangeNode current= getCurrentContainer();
- current.setAppendPosition(declarationEnd);
- current.setLength(declarationEnd - current.getRange().getOffset());
- fStack.pop();
- }
-
-
- /**
- * @return true if the current container is class-like.
- */
- private boolean inClassBody() {
- int typeCode= getCurrentContainer().getTypeCode();
- return typeCode == ICElement.C_CLASS
- || typeCode == ICElement.C_TEMPLATE_CLASS
- || typeCode == ICElement.C_STRUCT
- || typeCode == ICElement.C_TEMPLATE_STRUCT
- || typeCode == ICElement.C_UNION
- || typeCode == ICElement.C_TEMPLATE_UNION;
- }
-
- /**
- * Test whether the given declaration is a templated declaration.
- *
- * @param node
- * @return true if the declaration is templated.
- */
- private boolean isTemplateDecl(IASTDeclaration node) {
- return node.getParent() instanceof ICPPASTTemplateDeclaration;
- }
-
- private boolean hasNestedPointerOperators(IASTDeclarator declarator) {
- declarator= declarator.getNestedDeclarator();
- while (declarator != null) {
- if (declarator.getPointerOperators().length > 0) {
- return true;
- }
- declarator= declarator.getNestedDeclarator();
- }
- return false;
- }
-
- private String getEnumerationName(IASTEnumerationSpecifier enumSpecifier) {
- String nodeName= ASTStringUtil.getQualifiedName(enumSpecifier.getName());
- if (nodeName.length() == 0) {
- nodeName= ANONYMOUS_NAME;
- }
- return nodeName;
- }
-
- private String getTypeName(IASTCompositeTypeSpecifier compositeTypeSpec) {
- String nodeName= ASTStringUtil.getQualifiedName(compositeTypeSpec.getName());
- if (nodeName.length() == 0) {
- nodeName= ANONYMOUS_NAME;
- }
- return nodeName;
- }
-
- private String getDeclaratorName(IASTDeclarator node) {
- node= getInnermostDeclarator(node);
- IASTName name= node.getName();
- String nodeName= ASTStringUtil.getQualifiedName(name);
- if (nodeName.length() == 0) {
- nodeName= ANONYMOUS_NAME;
- }
- return nodeName;
- }
-
- private IASTDeclarator getInnermostDeclarator(IASTDeclarator node) {
- IASTDeclarator nested= node.getNestedDeclarator();
- while (nested != null) {
- node= nested;
- nested= node.getNestedDeclarator();
- }
- return node;
- }
-
- private static IASTFileLocation getMaxFileLocation(IASTNodeLocation[] locations) {
- if (locations == null || locations.length == 0) {
- return null;
- }
- final IASTNodeLocation nodeLocation= locations[locations.length-1];
- return nodeLocation.asFileLocation();
- }
-
- private static IASTFileLocation getMinFileLocation(IASTNodeLocation[] locations) {
- if (locations == null || locations.length == 0) {
- return null;
- }
- final IASTNodeLocation nodeLocation= locations[0];
- return nodeLocation.asFileLocation();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java
deleted file mode 100644
index 1567d45..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/BuildGroup.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Alex Collins (Broadcom Corp.)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.BuildAction;
-import org.eclipse.ui.ide.IDEActionFactory;
-import org.eclipse.ui.ide.ResourceUtil;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * This is the action group for workspace actions such as Build
- */
-public class BuildGroup extends CViewActionGroup {
-
- /**
- * An internal class which overrides the 'shouldPerformResourcePruning'
- * method so that referenced projects aren't build twice . (The CDT
- * managedbuild builds CDT reference project configuration as part of
- * building the top-level project).
- *
- * Also ensure that files in referenced projects are saved automatically
- * before build.
- */
- public static class CDTBuildAction extends BuildAction {
- public CDTBuildAction(IShellProvider shell, int kind) {
- super(shell, kind);
- }
- @Override
- @SuppressWarnings("unchecked")
- public void run() {
- // Ensure we correctly save files in all referenced projects before build
- Set prjs = new HashSet();
- for (IResource resource : (List)getSelectedResources()) {
- IProject project = resource.getProject();
- if (project != null) {
- prjs.add(project);
- try {
- prjs.addAll(Arrays.asList(project.getReferencedProjects()));
- } catch (CoreException e) {
- // Project not accessible or not open
- }
- }
- }
- saveEditors(prjs);
-
- // Clear the build console, and open a stream
- CUIPlugin.getDefault().startGlobalConsole();
-
- // Now delegate to the parent
- super.run();
- }
-
- /**
- * Taken from inaccessible o.e.ui.ide.BuildUtilities.java
- *
- * Causes all editors to save any modified resources in the provided collection
- * of projects depending on the user's preference.
- * @param projects The projects in which to save editors, or null
- * to save editors in all projects.
- */
- private static void saveEditors(Collection projects) {
- if (!BuildAction.isSaveAllSet()) {
- return;
- }
- IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
- for (IWorkbenchWindow window : windows) {
- IWorkbenchPage[] pages = window.getPages();
- for (IWorkbenchPage page : pages) {
- if (projects == null) {
- page.saveAllEditors(false);
- } else {
- IEditorPart[] editors = page.getDirtyEditors();
- for (IEditorPart editor : editors) {
- IFile inputFile = ResourceUtil.getFile(editor.getEditorInput());
- if (inputFile != null) {
- if (projects.contains(inputFile.getProject())) {
- page.saveEditor(editor, false);
- }
- }
- }
- }
- }
- }
- }
- }
-
- private static class RebuildAction extends CDTBuildAction {
- public RebuildAction(IShellProvider shell) {
- super(shell, IncrementalProjectBuilder.FULL_BUILD);
- }
- @Override
- protected void invokeOperation(IResource resource, IProgressMonitor monitor)
- throws CoreException {
- // these are both async. NOT what I want.
- ((IProject) resource).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
- ((IProject) resource).build(IncrementalProjectBuilder.FULL_BUILD, monitor);
-
- }
- }
-
- private BuildAction buildAction;
- private BuildAction rebuildAction;
- private BuildAction cleanAction;
-
- // Menu tags for the build
- final String BUILD_GROUP_MARKER = "buildGroup"; //$NON-NLS-1$
- final String BUILD_GROUP_MARKER_END = "end-buildGroup"; //$NON-NLS-1$
-
- public BuildGroup(CView cview) {
- super(cview);
- }
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), buildAction);
- }
-
- /**
- * Adds the build actions to the context menu.
- *
- * The following conditions apply: build-only projects selected, auto build
- * disabled, at least one * builder present
- *
- *
- * No disabled action should be on the context menu.
- *
- *
- * @param menu
- * context menu to add actions to
- */
- @Override
- public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
- boolean isProjectSelection = true;
- boolean hasOpenProjects = false;
- boolean hasClosedProjects = false;
- boolean hasBuilder = true; // false if any project is closed or does
- // not have builder
-
- menu.add(new GroupMarker(BUILD_GROUP_MARKER));
-
- Iterator> resources = selection.iterator();
- while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
- Object next = resources.next();
- IProject project = null;
-
- if (next instanceof IProject) {
- project = (IProject) next;
- } else if (next instanceof IAdaptable) {
- IResource res = (IResource)((IAdaptable)next).getAdapter(IResource.class);
- if (res instanceof IProject) {
- project = (IProject) res;
- }
- }
-
- if (project == null) {
- isProjectSelection = false;
- continue;
- }
- if (project.isOpen()) {
- hasOpenProjects = true;
- if (hasBuilder && !hasBuilder(project)) {
- hasBuilder = false;
- }
- } else {
- hasClosedProjects = true;
- hasBuilder = false;
- }
- }
-
- if (!selection.isEmpty() && isProjectSelection && hasBuilder) {
- buildAction.selectionChanged(selection);
- menu.add(buildAction);
-// rebuildAction.selectionChanged(selection);
-// menu.add(rebuildAction);
- cleanAction.selectionChanged(selection);
- menu.add(cleanAction);
- }
- menu.add(new GroupMarker(BUILD_GROUP_MARKER_END));
- }
-
- /**
- * Handles a key pressed event by invoking the appropriate action.
- */
- @Override
- public void handleKeyPressed(KeyEvent event) {
- }
-
- /**
- * Returns whether there are builders configured on the given project.
- *
- * @return true if it has builders, false if
- * not, or if this could not be determined
- */
- boolean hasBuilder(IProject project) {
- try {
- ICommand[] commands = project.getDescription().getBuildSpec();
- if (commands.length > 0) return true;
- } catch (CoreException e) {
- // Cannot determine if project has builders. Project is closed
- // or does not exist. Fall through to return false.
- }
- return false;
- }
-
- @Override
- protected void makeActions() {
- final IWorkbenchPartSite site = getCView().getSite();
-
- buildAction = new CDTBuildAction(site, IncrementalProjectBuilder.INCREMENTAL_BUILD);
- buildAction.setText(CViewMessages.BuildAction_label);
-
- cleanAction = new CDTBuildAction(site, IncrementalProjectBuilder.CLEAN_BUILD);
- cleanAction.setText(CViewMessages.CleanAction_label);
-
- rebuildAction = new RebuildAction(site);
- rebuildAction.setText(CViewMessages.RebuildAction_label);
- }
-
- @Override
- public void updateActionBars() {
- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
- buildAction.selectionChanged(selection);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
deleted file mode 100644
index 099f7ba..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java
+++ /dev/null
@@ -1,1103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Anton Leherbauer (Wind River Systems) - Fix bug 150045
- * Ken Ryall (Nokia) - Fix bug 175144
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ResourceWorkingSetFilter;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.contexts.IContextActivation;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.part.ISetSelectionTarget;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.IShowInTarget;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.PluginTransfer;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.views.framelist.FrameList;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.IArchiveContainer;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryContainer;
-import org.eclipse.cdt.core.model.IBinaryModule;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CElementContentProvider;
-import org.eclipse.cdt.ui.CElementSorter;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.dnd.CDTViewerDragAdapter;
-import org.eclipse.cdt.internal.ui.dnd.DelegatingDropAdapter;
-import org.eclipse.cdt.internal.ui.dnd.FileTransferDragAdapter;
-import org.eclipse.cdt.internal.ui.dnd.FileTransferDropAdapter;
-import org.eclipse.cdt.internal.ui.dnd.PluginTransferDropAdapter;
-import org.eclipse.cdt.internal.ui.dnd.ResourceTransferDragAdapter;
-import org.eclipse.cdt.internal.ui.dnd.ResourceTransferDropAdapter;
-import org.eclipse.cdt.internal.ui.dnd.TransferDragSourceListener;
-import org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener;
-import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
-import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
-import org.eclipse.cdt.internal.ui.util.RemoteTreeViewer;
-import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
-
-/**
- *
- * CView
- *
- */
-public class CView extends ViewPart implements ISetSelectionTarget, IPropertyChangeListener, IShowInTarget, IShowInTargetList {
-
- ProblemTreeViewer viewer;
- IMemento memento;
-
- CViewActionGroup actionGroup;
-
- FrameList frameList;
- CViewFrameSource frameSource;
-
- ResourceWorkingSetFilter workingSetFilter = new ResourceWorkingSetFilter();
-
- protected boolean dragDetected;
- private Listener dragDetectListener;
-
- // Persistance tags.
- static final String TAG_SELECTION = "selection"; //$NON-NLS-1$
- static final String TAG_EXPANDED = "expanded"; //$NON-NLS-1$
- static final String TAG_ELEMENT = "element"; //$NON-NLS-1$
- static final String TAG_PATH = "path"; //$NON-NLS-1$
- static final String TAG_VERTICAL_POSITION = "verticalPosition"; //$NON-NLS-1$
- static final String TAG_HORIZONTAL_POSITION = "horizontalPosition"; //$NON-NLS-1$
- static final String TAG_WORKINGSET = "workingSet"; //$NON-NLS-1$
-
- //Menu tags
- final String WORKING_GROUP_MARKER = "workingSetGroup"; //$NON-NLS-1$
- final String WORKING_GROUP_MARKER_END = "end-workingSetGroup"; //$NON-NLS-1$
-
- private IPartListener partListener = new IPartListener() {
-
- public void partActivated(IWorkbenchPart part) {
- if (part instanceof IEditorPart) {
- editorActivated((IEditorPart) part);
- }
- }
-
- public void partBroughtToTop(IWorkbenchPart part) {
- }
-
- public void partClosed(IWorkbenchPart part) {
- }
-
- public void partDeactivated(IWorkbenchPart part) {
- }
-
- public void partOpened(IWorkbenchPart part) {
- }
- };
-
- private IPropertyChangeListener workingSetListener = new IPropertyChangeListener() {
-
- public void propertyChange(PropertyChangeEvent ev) {
- String property = ev.getProperty();
- Object newValue = ev.getNewValue();
- Object oldValue = ev.getOldValue();
- IWorkingSet filterWorkingSet = workingSetFilter.getWorkingSet();
-
- if (property == null) {
- return;
- }
- if (IWorkingSetManager.CHANGE_WORKING_SET_REMOVE.equals(property) && oldValue == filterWorkingSet) {
- setWorkingSet(null);
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && newValue == filterWorkingSet) {
- updateTitle();
- } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property) && newValue == filterWorkingSet) {
- getViewer().refresh();
- }
- }
- };
-
- public CView() {
- super();
- }
-
- /**
- * @see IWorkbenchPart#setFocus()
- */
- @Override
- public void setFocus() {
- viewer.getTree().setFocus();
- //composite.setFocus ();
- }
-
- /**
- * Reveal and select the passed element selection in self's visual
- * component
- *
- * @see ISetSelectionTarget#selectReveal(ISelection)
- */
- public void selectReveal(ISelection selection) {
- IStructuredSelection ssel = SelectionConverter.convertSelectionToCElements(selection, true);
- if (!ssel.isEmpty()) {
- getViewer().setSelection(ssel, true);
- }
- }
-
- private IContextActivation fContextActivation;
-
- /**
- * Handles an open event from the viewer.
- * Opens an editor on the selected file.
- *
- * @param event the open event
- */
- protected void handleOpen(OpenEvent event) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- getActionGroup().runDefaultAction(selection);
- }
-
- /**
- * Handles double clicks in viewer. Opens editor if file double-clicked.
- */
- protected void handleDoubleClick(DoubleClickEvent event) {
- IStructuredSelection s = (IStructuredSelection) event.getSelection();
- Object o = s.getFirstElement();
- if (viewer.isExpandable(o)) {
- // Do not drill in to translation units of binaries.
- if (o instanceof ITranslationUnit || o instanceof IBinary || o instanceof IArchive) {
- return;
- }
- viewer.setExpandedState(o, !viewer.getExpandedState(o));
- }
- }
-
- /**
- * Handles key events in viewer.
- */
- void handleKeyPressed(KeyEvent event) {
- if (getActionGroup() != null) {
- getActionGroup().handleKeyPressed(event);
- }
- }
-
- /**
- * Handles a key release in the viewer. Does nothing by default.
- *
- */
- protected void handleKeyReleased(KeyEvent event) {
- if (getActionGroup() != null) {
- getActionGroup().handleKeyReleased(event);
- }
- }
-
- /**
- * Handles selection changed in viewer. Updates global actions. Links to
- * editor (if option enabled)
- */
- void handleSelectionChanged(SelectionChangedEvent event) {
- final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- updateStatusLine(selection);
- updateActionBars(selection);
- dragDetected = false;
- if (isLinkingEnabled()) {
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- public void run() {
- if (dragDetected == false) {
- // only synchronize with editor when the selection is
- // not the result
- // of a drag. Fixes bug 22274.
- linkToEditor(selection);
- }
- }
- });
- }
- }
-
- /**
- * Returns the action group.
- *
- * @return the action group
- */
- protected CViewActionGroup getActionGroup() {
- return actionGroup;
- }
-
- /**
- * Sets the action group.
- *
- * @param actionGroup
- * the action group
- */
- protected void setActionGroup(CViewActionGroup actionGroup) {
- this.actionGroup = actionGroup;
- }
-
- /**
- * Answer the property defined by key.
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class key) {
- if (key.equals(ISelectionProvider.class)) {
- return viewer;
- } else if (key == IShowInSource.class) {
- return getShowInSource();
- } else if (key == IShowInTarget.class) {
- return this;
- }
- return super.getAdapter(key);
- }
-
- /*
- * (non-Javadoc) Method declared on IViewPart.
- */
- @Override
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- this.memento = memento;
- }
-
- /**
- * init the frame source and the framelist.
- */
- void initFrameList() {
- frameSource = new CViewFrameSource(this);
- frameList = new FrameList(frameSource);
- frameSource.connectTo(frameList);
- }
-
- /**
- * Initializes the sorter.
- */
- void initCElementSorter() {
- viewer.setSorter(new CElementSorter());
- }
-
- /**
- * Adds the filters to the viewer.
- *
- * @param viewer
- * the viewer
- */
- void initFilters(TreeViewer viewer) {
- viewer.addFilter(workingSetFilter);
- }
-
- /**
- * Adds drag and drop support to the navigator.
- */
- void initDragAndDrop() {
- initDrag();
- initDrop();
-
- dragDetectListener = new Listener() {
-
- public void handleEvent(Event event) {
- dragDetected = true;
- }
- };
- viewer.getControl().addListener(SWT.DragDetect, dragDetectListener);
-
- }
-
- private void initDrag() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getTransfer(),
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance(),
- };
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(viewer),
- new ResourceTransferDragAdapter(viewer),
- new FileTransferDragAdapter(viewer)
- };
- viewer.addDragSupport(ops, transfers, new CDTViewerDragAdapter(viewer, dragListeners));
- }
-
- private void initDrop() {
- int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK | DND.DROP_DEFAULT;
- Transfer[] transfers= new Transfer[] {
- LocalSelectionTransfer.getTransfer(),
- ResourceTransfer.getInstance(),
- FileTransfer.getInstance(),
- PluginTransfer.getInstance()
- };
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(viewer),
- new ResourceTransferDropAdapter(viewer),
- new FileTransferDropAdapter(viewer),
- new PluginTransferDropAdapter(viewer),
- };
- viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
- }
-
- /**
- * Initializes the default preferences
- */
- public static void initDefaults(IPreferenceStore store) {
- }
-
- /**
- * get the default preferences.
- */
- void initFilterFromPreferences() {
- }
-
- /**
- * Sets the content provider for the viewer.
- */
- void initContentProvider(TreeViewer viewer) {
- IContentProvider provider = createContentProvider();
- viewer.setContentProvider(provider);
- }
-
- /**
- * Sets the label provider for the viewer.
- */
- void initLabelProvider(TreeViewer viewer) {
- CUILabelProvider cProvider = createLabelProvider();
- viewer.setLabelProvider(new DecoratingCLabelProvider(cProvider, true));
- }
-
- /**
- * Initializes and registers the context menu.
- */
- protected void initContextMenu() {
- MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
-
- public void menuAboutToShow(IMenuManager manager) {
- CView.this.fillContextMenu(manager);
- }
- });
- TreeViewer viewer = getViewer();
- Menu menu = menuMgr.createContextMenu(viewer.getTree());
- viewer.getTree().setMenu(menu);
- getSite().registerContextMenu(menuMgr, viewer);
- }
-
- /**
- * Restores the working set filter from the persistence store.
- */
- void initWorkingSetFilter() {
- // FIXME: the memento does not work if we close the view
- // and reopen we should save this somewhere else.
- // but it goes to pretty much all the settings 8-(
- if (memento == null) {
- return;
- }
- String wsname = memento.getString(TAG_WORKINGSET);
-
- if (wsname != null && wsname.equals("") == false) { //$NON-NLS-1$
- IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
- IWorkingSet workingSet = wsmanager.getWorkingSet(wsname);
- if (workingSet != null) {
- // Only initialize filter. Don't set working set into viewer.
- // Working set is set via WorkingSetFilterActionGroup
- // during action creation.
- workingSetFilter.setWorkingSet(workingSet);
- }
- }
- }
-
- /**
- * Add listeners to the viewer.
- */
- protected void initListeners(TreeViewer viewer) {
- viewer.addDoubleClickListener(new IDoubleClickListener() {
-
- public void doubleClick(DoubleClickEvent event) {
- handleDoubleClick(event);
- }
- });
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- public void selectionChanged(SelectionChangedEvent event) {
- handleSelectionChanged(event);
- }
- });
-
- viewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- handleOpen(event);
- }
- });
-
- viewer.getControl().addKeyListener(new KeyAdapter() {
-
- @Override
- public void keyPressed(KeyEvent e) {
- handleKeyPressed(e);
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- handleKeyReleased(e);
- }
- });
- }
-
- @Override
- public void createPartControl(Composite parent) {
-
- viewer = createViewer(parent);
- viewer.setUseHashlookup(true);
- viewer.setComparer(new CViewElementComparer());
- initContentProvider(viewer);
- initLabelProvider(viewer);
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
-
- initFilters(viewer);
- initWorkingSetFilter();
- initListeners(viewer);
- initCElementSorter();
- initFrameList();
- initDragAndDrop();
- updateTitle();
-
- viewer.setInput(CoreModel.getDefault().getCModel());
-
- initContextMenu();
-
- //Add the property changes after all of the UI work has been done.
- IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
- wsmanager.addPropertyChangeListener(workingSetListener);
-
- // Needs to be done before the actions
- getSite().setSelectionProvider(viewer);
- getSite().getPage().addPartListener(partListener);
-
- // Make the Actions for the Context Menu
- makeActions();
- getActionGroup().fillActionBars(getViewSite().getActionBars());
- updateActionBars((IStructuredSelection) viewer.getSelection());
-
- if (memento != null) {
- getActionGroup().restoreFilterAndSorterState(memento);
- } else {
- initFilterFromPreferences();
- }
-
-
- if (memento != null) {
- restoreState(memento);
- }
- memento = null;
-
- IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
- if (ctxService != null) {
- fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
- }
- }
-
- protected ProblemTreeViewer createViewer(Composite parent) {
- return new RemoteTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- }
-
- protected IContentProvider createContentProvider() {
- boolean showCUChildren = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
- boolean groupIncludes = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
- boolean groupMacros = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
- CViewContentProvider provider = new CViewContentProvider(viewer, getSite(), showCUChildren, true);
- provider.setIncludesGrouping(groupIncludes);
- provider.setMacroGrouping(groupMacros);
- return provider;
- }
-
- protected CUILabelProvider createLabelProvider() {
- return new CViewLabelProvider(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS);
- }
-
- /*
- * (non-Javadoc) Method declared on IWorkbenchPart.
- */
- @Override
- public void dispose() {
- if (fContextActivation != null) {
- IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
- if (ctxService != null) {
- ctxService.deactivateContext(fContextActivation);
- }
- }
-
- getSite().getPage().removePartListener(partListener);
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- if (getActionGroup() != null) {
- getActionGroup().dispose();
- }
- IWorkingSetManager wsmanager = getViewSite().getWorkbenchWindow().getWorkbench().getWorkingSetManager();
- wsmanager.removePropertyChangeListener(workingSetListener);
-
- Control control = viewer.getControl();
- if (dragDetectListener != null && control != null && control.isDisposed() == false) {
- control.removeListener(SWT.DragDetect, dragDetectListener);
- }
-
- super.dispose();
- }
-
- /**
- * An editor has been activated. Set the selection in this navigator to be
- * the editor's input, if linking is enabled.
- */
- void editorActivated(IEditorPart editor) {
- if (!CPluginPreferencePage.isLinkToEditor()) {
- return;
- }
-
- IEditorInput input = editor.getEditorInput();
- Object linkElement = null;
- if (input instanceof IFileEditorInput) {
- CoreModel factory = CoreModel.getDefault();
- IFileEditorInput fileInput = (IFileEditorInput) input;
- IFile file = fileInput.getFile();
- ICElement celement = factory.create(file);
- if (celement != null) {
- linkElement = celement;
- } else {
- linkElement = file;
- }
- } else if (input instanceof ITranslationUnitEditorInput) {
- ITranslationUnitEditorInput tuInput = (ITranslationUnitEditorInput) input;
- linkElement = tuInput.getTranslationUnit();
- }
- if (linkElement != null) {
- ISelection newSelection = new StructuredSelection(linkElement);
- if (!viewer.getSelection().equals(newSelection)) {
- viewer.setSelection(newSelection);
- }
- }
- }
-
- /**
- * Returns the working set filter for this view.
- *
- * @return the working set
- */
- public IWorkingSet getWorkingSet() {
- return workingSetFilter.getWorkingSet();
- }
-
- /**
- * Returns the sorter.
- */
- public CElementSorter getSorter() {
- return (CElementSorter) getViewer().getSorter();
- }
-
- /**
- * Returns the tree viewer which shows the resource hierarchy.
- */
- public TreeViewer getViewer() {
- return viewer;
- }
-
- /*
- */
- public FrameList getFrameList() {
- return frameList;
- }
-
- /**
- * Create self's action objects
- */
- void makeActions() {
- setActionGroup(new MainActionGroup(this));
- }
-
- /**
- * Called when the context menu is about to open. Delegates to the action
- * group using the viewer's selection as the action context.
- *
- * @since 2.0
- */
- protected void fillContextMenu(IMenuManager menu) {
- IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();
- CViewActionGroup actionGroup = getActionGroup();
- if (actionGroup != null) {
- actionGroup.setContext(new ActionContext(selection));
- actionGroup.fillContextMenu(menu);
- actionGroup.setContext(null);
- }
- }
-
- /**
- * Returns the tool tip text for the given element.
- */
- String getToolTipText(Object element) {
- if (element instanceof IResource) {
- IPath path = ((IResource) element).getFullPath();
- if (path.isRoot()) {
- return "CVIEW"; //$NON-NLS-1$
- }
- return path.makeRelative().toString();
- }
- return ((ILabelProvider) viewer.getLabelProvider()).getText(element);
- }
-
- /**
- * Returns the message to show in the status line.
- *
- * @param selection
- * the current selection
- * @return the status line message
- */
- String getStatusLineMessage(IStructuredSelection selection) {
- if (selection.size() == 1) {
- Object o = selection.getFirstElement();
- if (o instanceof IResource) {
- return ((IResource) o).getFullPath().makeRelative().toString();
- } else if (o instanceof ICElement) {
- ICElement celement = (ICElement) o;
- IResource res = (IResource) celement.getAdapter(IResource.class);
- if (res != null) {
- return res.getFullPath().toString();
- } else if (celement.getElementType() == ICElement.C_VCONTAINER) {
- if (celement instanceof IBinaryContainer) {
- ICProject cproj = celement.getCProject();
- if (cproj != null) {
- return cproj.getPath() + CViewMessages.CView_binaries;
- }
- } else if (celement instanceof IArchiveContainer) {
- ICProject cproj = celement.getCProject();
- if (cproj != null) {
- return cproj.getPath() + CViewMessages.CView_archives;
- }
- } else if (celement instanceof IBinaryModule) {
- IBinary bin = ((IBinaryModule) celement).getBinary();
- return bin.getPath() + ":" + celement.getElementName(); //$NON-NLS-1$
- }
- } else if (celement.getElementType() > ICElement.C_UNIT) {
- return celement.getPath().toString() + " - [" + celement.getElementName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return celement.getElementName();
- } else if (o instanceof IWorkbenchAdapter) {
- IWorkbenchAdapter wAdapter = (IWorkbenchAdapter)o;
- return wAdapter.getLabel(o);
- } else {
- return "ItemSelected"; //$NON-NLS-1$
- }
- }
- if (selection.size() > 1) {
- return NLS.bind(CViewMessages.CView_statusLine,
- new String[] { Integer.toString(selection.size())});
- }
- return "";//$NON-NLS-1$
- }
-
- /**
- * Updates the action bar actions.
- *
- * @param selection
- * the current selection
- */
- protected void updateActionBars(IStructuredSelection selection) {
- CViewActionGroup group = getActionGroup();
- if (group != null) {
- group.setContext(new ActionContext(selection));
- group.updateActionBars();
- }
- }
-
- void updateTitle() {
- Object input = getViewer().getInput();
- String viewName = getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
- if (input == null || (input instanceof ICModel)) {
- setPartName(viewName);
- setTitleToolTip(""); //$NON-NLS-1$
- } else {
- ILabelProvider labelProvider = (ILabelProvider) getViewer().getLabelProvider();
- String inputText = labelProvider.getText(input);
- setPartName(inputText);
- setTitleToolTip(getToolTipText(input));
- }
- }
-
- /**
- * Updates the message shown in the status line.
- *
- * @param selection
- * the current selection
- */
- void updateStatusLine(IStructuredSelection selection) {
- String msg = getStatusLineMessage(selection);
- getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
- }
-
- /*
- */
- public void setWorkingSet(IWorkingSet workingSet) {
- TreeViewer treeViewer = getViewer();
- Object[] expanded = treeViewer.getExpandedElements();
- ISelection selection = treeViewer.getSelection();
-
- workingSetFilter.setWorkingSet(workingSet);
- /*
- * if (workingSet != null) { settings.put(STORE_WORKING_SET,
- * workingSet.getName()); } else { settings.put(STORE_WORKING_SET, "");
- * //$NON-NLS-1$ }
- */
- updateTitle();
- treeViewer.refresh();
- treeViewer.setExpandedElements(expanded);
- if (selection.isEmpty() == false && selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- treeViewer.reveal(structuredSelection.getFirstElement());
- }
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if (viewer == null) return;
-
- boolean refreshViewer = false;
- String property = event.getProperty();
-
- if (property.equals(PreferenceConstants.PREF_SHOW_CU_CHILDREN)) {
- boolean showCUChildren = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN);
- IContentProvider provider = viewer.getContentProvider();
- if (provider instanceof CElementContentProvider) {
- ((CElementContentProvider) provider).setProvideMembers(showCUChildren);
- }
- refreshViewer = true;
- } else if (property.equals(PreferenceConstants.PREF_LINK_TO_EDITOR)) {
- CViewActionGroup group = getActionGroup();
- if (group instanceof MainActionGroup) {
- boolean enable = isLinkingEnabled();
- ((MainActionGroup)group).toggleLinkingAction.setChecked(enable);
- }
- } else if (property.equals(PreferenceConstants.CVIEW_GROUP_INCLUDES)) {
- boolean groupIncludes = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES);
- IContentProvider provider = viewer.getContentProvider();
- if (provider instanceof CElementContentProvider) {
- ((CElementContentProvider) provider).setIncludesGrouping(groupIncludes);
- }
- refreshViewer = true;
- } else if (property.equals(PreferenceConstants.CVIEW_GROUP_MACROS)) {
- boolean groupMacros = PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.CVIEW_GROUP_MACROS);
- IContentProvider provider = viewer.getContentProvider();
- if (provider instanceof CElementContentProvider) {
- ((CElementContentProvider) provider).setMacroGrouping(groupMacros);
- }
- refreshViewer = true;
- }
-
- if (refreshViewer) {
- viewer.refresh();
- }
- }
-
- /**
- * Returns whether the navigator selection automatically tracks the active
- * editor.
- *
- * @return true if linking is enabled, false
- * if not
- */
- public boolean isLinkingEnabled() {
- return CPluginPreferencePage.isLinkToEditor();
- }
-
- public void setLinkingEnabled(boolean enable) {
- CPluginPreferencePage.setLinkingEnabled(enable);
- if (enable) {
- IEditorPart editor = this.getSite().getPage().getActiveEditor();
- if (editor != null) {
- editorActivated(editor);
- }
- }
- }
-
- /**
- * Links to editor (if option enabled)
- */
- void linkToEditor(IStructuredSelection selection) {
- // ignore selection changes if the package explorer is not the active
- // part.
- // In this case the selection change isn't triggered by a user.
- if (!isActivePart()) {
- return;
- }
- if (selection.size() == 1) {
- Object obj = selection.getFirstElement();
- IEditorPart part = EditorUtility.isOpenInEditor(obj);
- if (part != null) {
- IWorkbenchPage page = getSite().getPage();
- page.bringToTop(part);
- if (obj instanceof ISourceReference) {
- if (obj instanceof ICElement && !(obj instanceof ITranslationUnit)) {
- EditorUtility.revealInEditor(part, (ICElement) obj);
- }
- }
- }
- }
- }
-
- private boolean isActivePart() {
- return this == getSite().getPage().getActivePart();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- if (viewer != null) {
- return viewer.getInput();
- }
- return null;
- }
-
- public void collapseAll() {
- viewer.getControl().setRedraw(false);
- viewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS);
- viewer.getControl().setRedraw(true);
- }
-
- void restoreState(IMemento memento) {
-
- CoreModel factory = CoreModel.getDefault();
-
- getActionGroup().restoreFilterAndSorterState(memento);
-
- IMemento childMem = memento.getChild(TAG_EXPANDED);
- if (childMem != null) {
- ArrayList elements = new ArrayList();
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- for (IMemento element2 : elementMem) {
- String p = element2.getString(TAG_PATH);
- if (p != null) {
- IPath path = new Path(p);
- ICElement element = factory.create(path);
- if (element != null) {
- elements.add(element);
- }
- }
- }
- viewer.setExpandedElements(elements.toArray());
- }
- childMem = memento.getChild(TAG_SELECTION);
- if (childMem != null) {
- ArrayList list = new ArrayList();
- IMemento[] elementMem = childMem.getChildren(TAG_ELEMENT);
- for (IMemento element2 : elementMem) {
- String p = element2.getString(TAG_PATH);
- if (p != null) {
- IPath path = new Path(p);
- ICElement element = factory.create(path);
- if (element != null) {
- list.add(element);
- }
- }
- }
- viewer.setSelection(new StructuredSelection(list));
- }
-
- Tree tree = viewer.getTree();
- //save vertical position
- ScrollBar bar = tree.getVerticalBar();
- if (bar != null) {
- try {
- String posStr = memento.getString(TAG_VERTICAL_POSITION);
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- } catch (NumberFormatException e) {
- }
- }
- bar = tree.getHorizontalBar();
- if (bar != null) {
- try {
- String posStr = memento.getString(TAG_HORIZONTAL_POSITION);
- int position;
- position = new Integer(posStr).intValue();
- bar.setSelection(position);
- } catch (NumberFormatException e) {
- }
- }
- }
-
- @Override
- public void saveState(IMemento memento) {
- if (viewer == null) {
- if (this.memento != null) { //Keep the old state;
- memento.putMemento(this.memento);
- }
- return;
- }
-
- //save expanded elements
- Tree tree = viewer.getTree();
- Object expandedElements[] = viewer.getExpandedElements();
- if (expandedElements.length > 0) {
- IMemento expandedMem = memento.createChild(TAG_EXPANDED);
- for (Object expandedElement : expandedElements) {
- Object o = expandedElement;
- // Do not save expanded binary files are libraries.
- if (o instanceof IParent
- && !(o instanceof IArchiveContainer || o instanceof IBinaryContainer || o instanceof IBinary || o instanceof IArchive)) {
- IMemento elementMem = expandedMem.createChild(TAG_ELEMENT);
- ICElement e = (ICElement) o;
- IResource res = e.getResource();
- if (res != null && res.getLocation() != null) {
- elementMem.putString(TAG_PATH, res.getLocation().toOSString());
- }
- }
- }
- }
-
- //save selection
- Object elements[] = ((IStructuredSelection) viewer.getSelection()).toArray();
- if (elements.length > 0) {
- IMemento selectionMem = memento.createChild(TAG_SELECTION);
- for (Object element : elements) {
- if (element instanceof ICElement) {
- ICElement e = (ICElement) element;
- IResource r = e.getResource();
- if (r != null && r.getLocation() != null) {
- IMemento elementMem = selectionMem.createChild(TAG_ELEMENT);
- elementMem.putString(TAG_PATH, r.getLocation().toString());
- }
- }
- }
- }
-
- //save vertical position
- ScrollBar bar = tree.getVerticalBar();
- int position = bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_VERTICAL_POSITION, String.valueOf(position));
- //save horizontal position
- bar = tree.getHorizontalBar();
- position = bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_HORIZONTAL_POSITION, String.valueOf(position));
-
- getActionGroup().saveFilterAndSorterState(memento);
- //Save the working set away
- if (workingSetFilter.getWorkingSet() != null) {
- String wsname = workingSetFilter.getWorkingSet().getName();
- if (wsname != null) {
- memento.putString(TAG_WORKINGSET, wsname);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext)
- */
- public boolean show(ShowInContext context) {
- ISelection selection= context.getSelection();
- if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
- selectReveal(selection);
- return true;
- }
- IEditorInput input = (IEditorInput) context.getInput();
- if (input != null) {
- IResource res = (IResource) input.getAdapter(IResource.class);
- if (res != null) {
- selectReveal(new StructuredSelection(res));
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns the IShowInSource for this view.
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(getViewer().getInput(), getViewer().getSelection());
- }
- };
- }
-
- public String[] getShowInTargetIds() {
- return new String[]{IPageLayout.ID_RES_NAV};
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java
deleted file mode 100644
index 849811d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewAction.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.SelectionProviderAction;
-
-/**
- * Superclass of all actions provided by the cview.
- */
-public abstract class CViewAction extends SelectionProviderAction {
-
- private CView cview;
-
- /**
- * Creates a new instance of the class.
- */
- public CViewAction(CView cview, String label) {
- super(cview.getViewer(), label);
- this.cview = cview;
- }
-
- /**
- * Returns the cview for which this action was created.
- */
- public CView getCView() {
- return cview;
- }
-
- /**
- * Returns the viewer
- */
- protected Viewer getViewer() {
- return getCView().getViewer();
- }
-
- /**
- * Returns the shell to use within actions.
- */
- protected Shell getShell() {
- return getCView().getSite().getShell();
- }
-
- /**
- * Returns the workbench.
- */
- protected IWorkbench getWorkbench() {
- return CUIPlugin.getDefault().getWorkbench();
- }
-
- /**
- * Returns the workbench window.
- */
- protected IWorkbenchWindow getWorkbenchWindow() {
- return getCView().getSite().getWorkbenchWindow();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
deleted file mode 100644
index 36b3d02..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewActionGroup.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.views.navigator.SortAndFilterActionGroup;
-import org.eclipse.ui.views.navigator.WorkspaceActionGroup;
-
-/**
- * This is the action group for all the view actions.
- * It delegates to several subgroups for most of the actions.
- *
- * @see GotoActionGroup
- * @see OpenFileGroup
- * @see RefactorActionGroup
- * @see SortAndFilterActionGroup
- * @see WorkspaceActionGroup
- *
- */
-public abstract class CViewActionGroup extends ActionGroup {
-
- /**
- * The resource navigator.
- */
- protected CView cview;
-
- /**
- * Constructs a new navigator action group and creates its actions.
- *
- * @param cview the CView
- */
- public CViewActionGroup(CView cview) {
- this.cview = cview;
- makeActions();
- }
-
- /**
- * Returns the image descriptor with the given relative path.
- */
- protected ImageDescriptor getImageDescriptor(String relativePath) {
- String iconPath = "icons/"; //$NON-NLS-1$
- try {
- URL installURL = CUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$
- URL url = new URL(installURL, iconPath + relativePath);
- return ImageDescriptor.createFromURL(url);
- } catch (MalformedURLException e) {
- // should not happen
- return ImageDescriptor.getMissingImageDescriptor();
- }
- }
-
- /**
- * Returns the resource navigator.
- */
- public CView getCView() {
- return cview;
- }
-
- /**
- * Handles a key pressed event by invoking the appropriate action.
- * Does nothing by default.
- */
- public void handleKeyPressed(KeyEvent event) {
- }
-
- /**
- * Handles a key released event by invoking the appropriate action.
- * Does nothing by default.
- */
- public void handleKeyReleased(KeyEvent event) {
- }
-
- /**
- * Makes the actions contained in this action group.
- */
- protected abstract void makeActions();
-
- /**
- * Called when the context menu is about to open.
- * Override to add your own context dependent menu contributions.
- */
- @Override
- public abstract void fillContextMenu(IMenuManager menu);
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
- */
- @Override
- public abstract void fillActionBars(IActionBars actionBars);
-
- @Override
- public abstract void updateActionBars();
-
- /**
- * Runs the default action in the group.
- * Does nothing by default.
- *
- * @param selection the current selection
- */
- public void runDefaultAction(IStructuredSelection selection) {
- }
-
- public void restoreFilterAndSorterState(IMemento memento) {
- }
-
- public void saveFilterAndSorterState(IMemento memento) {
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
deleted file mode 100644
index f8ba3ad..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.IArchiveContainer;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.IBinaryContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IIncludeReference;
-import org.eclipse.cdt.core.model.ILibraryReference;
-import org.eclipse.cdt.ui.CElementContentProvider;
-
-import org.eclipse.cdt.internal.ui.util.RemoteTreeContentManager;
-import org.eclipse.cdt.internal.ui.util.RemoteTreeViewer;
-
-/**
- * CViewContentProvider
- */
-public class CViewContentProvider extends CElementContentProvider {
- private RemoteTreeContentManager fManager;
-
- public CViewContentProvider() {
- super();
- }
-
- /**
- *
- */
- public CViewContentProvider(TreeViewer viewer, IWorkbenchPartSite site) {
- super();
- fManager = createContentManager(viewer, site);
- }
-
- /**
- * @param provideMembers
- * @param provideWorkingCopy
- */
- public CViewContentProvider(TreeViewer viewer, IWorkbenchPartSite site, boolean provideMembers, boolean provideWorkingCopy) {
- super(provideMembers, provideWorkingCopy);
- fManager = createContentManager(viewer, site);
- }
-
- protected RemoteTreeContentManager createContentManager(TreeViewer viewer, IWorkbenchPartSite site) {
- if (site == null) {
- return new RemoteTreeContentManager(this, (RemoteTreeViewer)viewer, null);
- }
- return new RemoteTreeContentManager(this, (RemoteTreeViewer)viewer, site);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object element) {
- Object[] objs = null;
-
- if (fManager != null) {
- // use the the deferred manager for some cases
- if (element instanceof IBinary) {
- // It takes sometimes to parse binaries deferred it
- objs = fManager.getChildren(element);
- } else if (element instanceof IArchive) {
- // It takes sometimes to parse archives deferred it
- objs = fManager.getChildren(element);
- }
- }
-
- if (objs == null) {
- objs = super.getChildren(element);
- }
- Object[] extras = null;
- try {
- if (element instanceof ICProject) {
- extras = getProjectChildren((ICProject)element);
- } else if (element instanceof IBinaryContainer) {
- extras = getExecutables((IBinaryContainer)element);
- } else if (element instanceof IArchiveContainer) {
- extras = getArchives((IArchiveContainer)element);
- } else if (element instanceof IIncludeReference) {
- extras = getIncludeReferenceChildren((IIncludeReference)element);
- }
- /*
- * Do not to this for now, since ILibraryReference is an Archive.
- else if (element instanceof ILibraryReference) {
- extras = ((ILibraryReference)element).getChildren();
- }*/
- } catch (CModelException e) {
- }
- if (extras != null && extras.length > 0) {
- objs = concatenate(objs, extras);
- }
- return objs;
- }
-
- public Object[] getIncludeReferenceChildren(IIncludeReference ref) throws CModelException {
- // We do not want to show children for Include paths that are inside the workspace.
- // no need to that since they can access elsewhere and that simplifies the
- // CView code.
- IPath location = ref.getPath();
- IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
- for (int i = 0; i < containers.length; ++i) {
- if (containers[i].isAccessible()) {
- return NO_CHILDREN;
- }
- }
- return ref.getChildren();
- }
-
- private Object[] getProjectChildren(ICProject cproject) throws CModelException {
- Object[] extras = null;
- IArchiveContainer archive = cproject.getArchiveContainer();
- if (getArchives(archive).length > 0) {
- extras = new Object[] {archive};
- }
- IBinaryContainer bin = cproject.getBinaryContainer();
- if (getExecutables(bin).length > 0) {
- Object[] o = new Object[] {bin};
- if (extras != null && extras.length > 0) {
- extras = concatenate(extras, o);
- } else {
- extras = o;
- }
- }
- LibraryRefContainer libRefCont = new LibraryRefContainer(cproject);
- Object[] libRefs = libRefCont.getChildren(cproject);
- if (libRefs != null && libRefs.length > 0) {
- Object[] o = new Object[] {libRefCont};
- if (extras != null && extras.length > 0) {
- extras = concatenate(extras, o);
- } else {
- extras = o;
- }
- }
-
- IncludeRefContainer incRefCont = new IncludeRefContainer(cproject);
- Object[] incRefs = incRefCont.getChildren(cproject);
- if (incRefs != null && incRefs.length > 0) {
- Object[] o = new Object[] {incRefCont};
- if (extras != null && extras.length > 0) {
- extras = concatenate(extras, o);
- } else {
- extras = o;
- }
- }
- return extras;
- }
-
- protected IBinary[] getExecutables(IBinaryContainer container) throws CModelException {
- ICElement[] celements = container.getChildren();
- ArrayList list = new ArrayList(celements.length);
- for (int i = 0; i < celements.length; i++) {
- if (celements[i] instanceof IBinary) {
- IBinary bin = (IBinary)celements[i];
- if (bin.showInBinaryContainer()) {
- list.add(bin);
- }
- }
- }
- IBinary[] bins = new IBinary[list.size()];
- list.toArray(bins);
- return bins;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#internalGetParent(java.lang.Object)
- */
- @Override
- public Object internalGetParent(Object element) {
- // since we insert logical containers we have to fix
- // up the parent for {IInclude,ILibrary}Reference so that they refer
- // to the container and containers refere to the project
- Object parent = super.internalGetParent(element);
- if (element instanceof IncludeReferenceProxy) {
- parent = ((IncludeReferenceProxy)element).getIncludeRefContainer();
- } else if (element instanceof IncludeRefContainer) {
- parent = ((IncludeRefContainer)element).getCProject();
- } else if (element instanceof ILibraryReference) {
- if (parent instanceof ICProject) {
- parent = new LibraryRefContainer((ICProject)parent);
- }
- } else if (element instanceof LibraryRefContainer) {
- parent = ((LibraryRefContainer)element).getCProject();
- }
- return parent;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- @Override
- public boolean hasChildren(Object element) {
- if (fManager != null) {
- if (element instanceof IBinary) {
- return fManager.mayHaveChildren(element);
- } else if (element instanceof IArchive) {
- return fManager.mayHaveChildren(element);
- }
- }
- if (element instanceof IBinaryContainer) {
- try {
- IBinaryContainer cont = (IBinaryContainer)element;
- IBinary[] bins = getBinaries(cont);
- return (bins != null) && bins.length > 0;
- } catch (CModelException e) {
- return false;
- }
- } else if (element instanceof IArchiveContainer) {
- try {
- IArchiveContainer cont = (IArchiveContainer)element;
- IArchive[] ars = getArchives(cont);
- return (ars != null) && ars.length > 0;
- } catch (CModelException e) {
- return false;
- }
- } else if (element instanceof IncludeReferenceProxy) {
- IIncludeReference ref = ((IncludeReferenceProxy)element).getReference();
- IPath location = ref.getPath();
- IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
- for (int i = 0; i < containers.length; ++i) {
- if (containers[i].isAccessible()) {
- return false;
- }
- }
-
- }
- return super.hasChildren(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
- public void dispose() {
- if (fManager != null) {
- fManager.cancel();
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (fManager != null) {
- fManager.cancel();
- }
- super.inputChanged(viewer, oldInput, newInput);
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java
deleted file mode 100644
index 05bfd4d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewElementComparer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.jface.viewers.IElementComparer;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-
-public class CViewElementComparer implements IElementComparer {
-
- public boolean equals(Object o1, Object o2) {
- if (o1 == o2) // this handles also the case that both are null
- return true;
- if (o1 == null)
- return false; // o2 != null if we reach this point
- if (o1.equals(o2))
- return true;
-
- // Assume they are CElements
- ICElement c1= (o1 instanceof ICElement) ? (ICElement)o1 : null;
- ICElement c2= (o2 instanceof ICElement) ? (ICElement)o2 : null;
- if (c1 == null || c2 == null)
- return false;
-
- if (c1.getElementType() != c2.getElementType())
- return false;
-
- // Below is for children of TranslationUnits but we have to make sure
- // we handle the case that the child comes from the a workingCopy in that
- // case it should be equal as the original element.
- ITranslationUnit u1 = (ITranslationUnit)c1.getAncestor(ICElement.C_UNIT);
- ITranslationUnit u2 = (ITranslationUnit)c2.getAncestor(ICElement.C_UNIT);
- if (u1 == null || u2 == null) {
- return false;
- }
-
- if (u1.isWorkingCopy() && u2.isWorkingCopy() || !u1.isWorkingCopy() && !u2.isWorkingCopy()) {
- return false;
- }
- // From here on either c1 or c2 is a working copy.
- if (u1.isWorkingCopy()) {
- c1= ((IWorkingCopy)u1).getOriginal(c1);
- } else if (u2.isWorkingCopy()) {
- c2= ((IWorkingCopy)u2).getOriginal(c2);
- }
- if (c1 == null || c2 == null)
- return false;
- return c1.equals(c2);
- }
-
- public int hashCode(Object o1) {
- return o1.hashCode();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
deleted file mode 100644
index 0d77616..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewFrameSource.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.ui.views.framelist.TreeFrame;
-import org.eclipse.ui.views.framelist.TreeViewerFrameSource;
-
-public class CViewFrameSource extends TreeViewerFrameSource {
- private CView cview;
-
- @Override
- protected TreeFrame createFrame(Object input) {
- TreeFrame frame = super.createFrame(input);
- frame.setToolTipText(cview.getToolTipText(input));
- return frame;
- }
- /**
- * Also updates the title of the packages explorer
- */
- @Override
- protected void frameChanged(TreeFrame frame) {
- super.frameChanged(frame);
- cview.updateTitle();
- }
- public CViewFrameSource(CView cview) {
- super(cview.getViewer());
- this.cview = cview;
- }
-}
-
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
deleted file mode 100644
index 4d326cd..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.core.filesystem.URIUtil;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IIncludeReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CElementImageDescriptor;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.corext.util.Strings;
-
-import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-
-/*
- * CViewLabelProvider
- */
-public class CViewLabelProvider extends AppearanceAwareLabelProvider {
-
- public CViewLabelProvider(long textFlags, int imageFlags) {
- super(textFlags, imageFlags);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object element) {
- if (element instanceof IncludeReferenceProxy) {
- final IIncludeReference ref = ((IncludeReferenceProxy)element).getReference();
- final IPath uriPathLocation = ref.getPath().makeAbsolute();
- final IContainer[] containers= ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(URIUtil.toURI(uriPathLocation));
- if (containers.length > 0) {
- // bug 192707, prefer the project the reference belongs to.
- final ICProject prj= ref.getCProject();
- if (prj != null) {
- for (int i = 0; i < containers.length; i++) {
- final IContainer container = containers[i];
- final IProject project = container.getProject();
- // in case the path is empty, the container is the workspace root and project is null.
- if (project != null && project.equals(prj.getProject())) {
- return container.getFullPath().makeRelative().toString();
- }
- }
- }
- IPath p = containers[0].getFullPath();
- p = (p.isRoot()) ? uriPathLocation : p.makeRelative();
- return decorateText(p.toString(), element);
- }
- } else if (element instanceof IIncludeReference) {
- IIncludeReference ref = (IIncludeReference)element;
- Object parent = ref.getParent();
- if (parent instanceof IIncludeReference) {
- IPath p = ref.getPath();
- IPath parentLocation = ((IIncludeReference)parent).getPath();
- if (parentLocation.isPrefixOf(p)) {
- p = p.setDevice(null);
- p = p.removeFirstSegments(parentLocation.segmentCount());
- }
- return decorateText(p.toString(), element);
- }
- } else if (element instanceof ITranslationUnit) {
- ITranslationUnit unit = (ITranslationUnit)element;
- Object parent = unit.getParent();
- if (parent instanceof IIncludeReference) {
- IPath p = unit.getPath();
- IPath parentLocation = ((IIncludeReference)parent).getPath();
- if (parentLocation.isPrefixOf(p)) {
- p = p.setDevice(null);
- p = p.removeFirstSegments(parentLocation.segmentCount());
- }
- return decorateText(p.toString(), element);
- }
- }
- return super.getText(element);
- }
-
- @Override
- public StyledString getStyledText(Object element) {
- return Strings.markLTR(new StyledString(getText(element)));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(Object element) {
- if (element instanceof IncludeReferenceProxy) {
- IIncludeReference reference = ((IncludeReferenceProxy)element).getReference();
- IPath path = reference.getPath();
- IContainer container = reference.getCModel().getWorkspace().getRoot().getContainerForLocation(path);
- if (container != null && container.isAccessible()) {
- ImageDescriptor desc = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER_WORKSPACE);
- desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
- return CUIPlugin.getImageDescriptorRegistry().get(desc);
- }
- } else if (element instanceof IIncludeReference) {
- ImageDescriptor desc = CElementImageProvider.getImageDescriptor(ICElement.C_CCONTAINER);
- desc = new CElementImageDescriptor(desc, 0, CElementImageProvider.SMALL_SIZE);
- return CUIPlugin.getImageDescriptorRegistry().get(desc);
- }
- return super.getImage(element);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java
deleted file mode 100644
index e646d87..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.osgi.util.NLS;
-
-public final class CViewMessages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.cview.CViewMessages";//$NON-NLS-1$
-
- private CViewMessages() {
- // Do not instantiate
- }
-
- public static String OpenWithMenu_label;
- public static String BuildAction_label;
- public static String RebuildAction_label;
- public static String CleanAction_label;
- public static String CollapseAllAction_label;
- public static String CollapseAllAction_tooltip;
- public static String CollapseAllAction_description;
- public static String CopyAction_title;
- public static String CopyAction_toolTip;
- public static String PasteAction_title;
- public static String PasteAction_toolTip;
- public static String NewWizardsActionGroup_new;
- public static String DefaultAction_WIP;
- public static String DefaultAction_workInProgress;
- public static String CView_binaries;
- public static String CView_archives;
- public static String LibraryRefContainer_Libraries;
- public static String IncludeRefContainer_Includes;
- public static String CView_statusLine;
- public static String CopyToClipboardProblemDialog_title;
- public static String CopyToClipboardProblemDialog_message;
- public static String SelectionTransferDropAdapter_error_title;
- public static String SelectionTransferDropAdapter_error_message;
- public static String SelectionTransferDropAdapter_error_exception;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, CViewMessages.class);
- }
-}
\ No newline at end of file
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties
deleted file mode 100644
index 56993fc..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties
+++ /dev/null
@@ -1,47 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2009 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
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# Anton Leherbauer (Wind River Systems) - Fixed bug 141484
-###############################################################################
-
-
-OpenWithMenu_label=Open Wit&h
-
-BuildAction_label=&Build Project
-RebuildAction_label=Rebuild Pro&ject
-CleanAction_label=Clean Project
-
-CollapseAllAction_label=Collapse All
-CollapseAllAction_tooltip=Collapse All
-CollapseAllAction_description=Collapse All
-
-CopyAction_title = &Copy
-CopyAction_toolTip = Copy
-
-PasteAction_title=&Paste
-PasteAction_toolTip = Paste
-
-NewWizardsActionGroup_new=Ne&w
-
-DefaultAction_WIP=WIP
-DefaultAction_workInProgress=Work In Progress
-CView_binaries=\ - binaries
-CView_archives=\ - archives
-LibraryRefContainer_Libraries=Libraries
-# START NON-TRANSLATABLE
-IncludeRefContainer_Includes=Includes
-# END NON-TRANSLATABLE
-CView_statusLine = {0} items selected
-
-CopyToClipboardProblemDialog_title=Problem Copying to Clipboard
-CopyToClipboardProblemDialog_message=There was a problem when accessing the system clipboard. Retry?
-
-SelectionTransferDropAdapter_error_title=Drag and Drop Problem
-SelectionTransferDropAdapter_error_message=A problem occurred during Drag and Drop.
-SelectionTransferDropAdapter_error_exception=An unexpected exception occurred during Drag and Drop.
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java
deleted file mode 100644
index 295f6db..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMoveAction.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.MoveProjectAction;
-import org.eclipse.ui.actions.MoveResourceAction;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
-/**
- * The ResourceNavigatorMoveAction is a resource move that aso updates the navigator
- * to show the result of the move.
- * It also delegates to MoveProjectAction as needed.
- *
- * @since 2.0
- */
-public class CViewMoveAction extends MoveResourceAction {
- private StructuredViewer viewer;
- private MoveProjectAction moveProjectAction;
-
-/**
- * Create a ResourceNavigatorMoveAction and use the supplied viewer to update the UI.
- * @param shellProvider provider for the shell
- * @param structureViewer StructuredViewer
- */
-public CViewMoveAction(IShellProvider shellProvider, StructuredViewer structureViewer) {
- super(shellProvider);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.MOVE_ACTION);
- this.viewer = structureViewer;
- this.moveProjectAction = new MoveProjectAction(shellProvider);
-}
-/* (non-Javadoc)
- * Method declared on IAction.
- */
-@Override
-public void run() {
- if (moveProjectAction.isEnabled()) {
- moveProjectAction.run();
- return;
- }
-
- super.run();
- List> destinations = getDestinations();
- if (destinations != null && destinations.isEmpty() == false) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- List resources = new ArrayList();
- Iterator> iterator = destinations.iterator();
-
- while (iterator.hasNext()) {
- IResource newResource = root.findMember((IPath) iterator.next());
- if (newResource != null)
- resources.add(newResource);
- }
-
- this.viewer.setSelection(new StructuredSelection(resources), true);
- }
-
-}
-
-@Override
-protected boolean updateSelection(IStructuredSelection selection) {
- moveProjectAction.selectionChanged(selection);
- return super.updateSelection(selection) || moveProjectAction.isEnabled();
-}
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java
deleted file mode 100644
index 844890e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewRenameAction.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.RenameResourceAction;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
-
-/**
- * The ResourceNavigatorRenameAction is the rename action used by the
- * ResourceNavigator that also allows updating after rename.
- * @since 2.0
- */
-public class CViewRenameAction extends RenameResourceAction {
- private TreeViewer viewer;
- /**
- * Create a ResourceNavigatorRenameAction and use the tree of the supplied viewer
- * for editing.
- * @param shell Shell
- * @param treeViewer TreeViewer
- * @deprecated
- */
- @Deprecated
- public CViewRenameAction(Shell shell, TreeViewer treeViewer) {
- super(shell, treeViewer.getTree());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(
- this,
- ICHelpContextIds.RENAME_ACTION);
- this.viewer = treeViewer;
- }
- /**
- * Create a ResourceNavigatorRenameAction and use the tree of the supplied viewer
- * for editing.
- * @param shellProvider a provider for a shell
- * @param treeViewer TreeViewer
- */
- public CViewRenameAction(IShellProvider shellProvider, TreeViewer treeViewer) {
- super(shellProvider, treeViewer.getTree());
- PlatformUI.getWorkbench().getHelpSystem().setHelp(
- this,
- ICHelpContextIds.RENAME_ACTION);
- this.viewer = treeViewer;
- }
-
- /* (non-Javadoc)
- * Run the action to completion using the supplied path.
- */
- @Override
- protected void runWithNewPath(IPath path, IResource resource) {
- IWorkspaceRoot root = resource.getProject().getWorkspace().getRoot();
- super.runWithNewPath(path, resource);
- if (this.viewer != null) {
- IResource newResource = root.findMember(path);
- if (newResource != null)
- this.viewer.setSelection(new StructuredSelection(newResource), true);
- }
- }
- /**
- * Handle the key release
- */
- public void handleKeyReleased(KeyEvent event) {
- if (event.keyCode == SWT.F2 && event.stateMask == 0 && isEnabled()) {
- run();
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java
deleted file mode 100644
index 8f06d23..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Collapse all nodes.
- */
-class CollapseAllAction extends Action {
-
- private CView cview;
-
- CollapseAllAction(CView part) {
- super(CViewMessages.CollapseAllAction_label);
- setDescription(CViewMessages.CollapseAllAction_description);
- setToolTipText(CViewMessages.CollapseAllAction_tooltip);
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_COLLAPSE_ALL);
- cview = part;
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COLLAPSE_ALL_ACTION);
- }
-
- @Override
- public void run() {
- cview.collapseAll();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java
deleted file mode 100644
index 33f0839..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CopyAction.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.SelectionListenerAction;
-import org.eclipse.ui.part.ResourceTransfer;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
-/**
- * Standard action for copying the currently selected resources to the clipboard.
- *
- * This class may be instantiated; it is not intended to be subclassed.
- *
- *
- * @since 2.0
- */
-public class CopyAction extends SelectionListenerAction {
-
- /**
- * The id of this action.
- */
- public static final String ID = PlatformUI.PLUGIN_ID + ".CopyAction"; //$NON-NLS-1$
-
- /**
- * The shell in which to show any dialogs.
- */
- private Shell shell;
-
- /**
- * System clipboard
- */
- private Clipboard clipboard;
-
- /**
- * Associated paste action. May be null
- */
- private PasteAction pasteAction;
-
- /**
- * Creates a new action.
- *
- * @param shell the shell for any dialogs
- * @param clipboard a platform clipboard
- */
- public CopyAction(Shell shell, Clipboard clipboard) {
- super(CViewMessages.CopyAction_title);
- Assert.isNotNull(shell);
- Assert.isNotNull(clipboard);
- this.shell = shell;
- this.clipboard = clipboard;
- setToolTipText(CViewMessages.CopyAction_toolTip);
- setId(CopyAction.ID);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COPY_ACTION);
-
- }
- /**
- * Creates a new action.
- *
- * @param shell the shell for any dialogs
- * @param clipboard a platform clipboard
- * @param pasteAction a paste action
- *
- * @since 2.0
- */
- public CopyAction(Shell shell, Clipboard clipboard, PasteAction pasteAction) {
- this(shell, clipboard);
- this.pasteAction = pasteAction;
- }
- /**
- * The CopyAction implementation of this method defined
- * on IAction copies the selected resources to the
- * clipboard.
- */
- @Override
- public void run() {
- List> selectedResources = getSelectedResources();
- IResource[] resources = selectedResources.toArray(new IResource[selectedResources.size()]);
-
- // Get the file names and a string representation
- final int length = resources.length;
- int actualLength = 0;
- String[] fileNames = new String[length];
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < length; i++) {
- IPath location = resources[i].getLocation();
- // location may be null. See bug 29491.
- if (location != null)
- fileNames[actualLength++] = location.toOSString();
- if (i > 0)
- buf.append("\n"); //$NON-NLS-1$
- buf.append(resources[i].getName());
- }
- // was one or more of the locations null?
- if (actualLength < length) {
- String[] tempFileNames = fileNames;
- fileNames = new String[actualLength];
- for (int i = 0; i < actualLength; i++)
- fileNames[i] = tempFileNames[i];
- }
- setClipboard(resources, fileNames, buf.toString());
-
- // update the enablement of the paste action
- // workaround since the clipboard does not suppot callbacks
- if (pasteAction != null && pasteAction.getStructuredSelection() != null)
- pasteAction.selectionChanged(pasteAction.getStructuredSelection());
- }
- /**
- * Set the clipboard contents. Prompt to retry if clipboard is busy.
- *
- * @param resources the resources to copy to the clipboard
- * @param fileNames file names of the resources to copy to the clipboard
- * @param names string representation of all names
- */
- private void setClipboard(IResource[] resources, String[] fileNames, String names) {
- try {
- // set the clipboard contents
- if (fileNames.length > 0) {
- clipboard.setContents(
- new Object[] { resources, fileNames, names },
- new Transfer[] { ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance()});
- } else {
- clipboard.setContents(
- new Object[] { resources, names },
- new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance()});
- }
- } catch (SWTError e) {
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
- throw e;
- if (MessageDialog.openQuestion(shell, CViewMessages.CopyToClipboardProblemDialog_title, CViewMessages.CopyToClipboardProblemDialog_message))
- setClipboard(resources, fileNames, names);
- }
- }
- /**
- * The CopyAction implementation of this
- * SelectionListenerAction method enables this action if
- * one or more resources of compatible types are selected.
- */
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- if (!super.updateSelection(selection))
- return false;
-
- if (getSelectedNonResources().size() > 0)
- return false;
-
- List> selectedResources = getSelectedResources();
- if (selectedResources.size() == 0)
- return false;
-
- boolean projSelected = selectionIsOfType(IResource.PROJECT);
- boolean fileFoldersSelected = selectionIsOfType(IResource.FILE | IResource.FOLDER);
- if (!projSelected && !fileFoldersSelected)
- return false;
-
- // selection must be homogeneous
- if (projSelected && fileFoldersSelected)
- return false;
-
- // must have a common parent
- IContainer firstParent = ((IResource) selectedResources.get(0)).getParent();
- if (firstParent == null)
- return false;
-
- Iterator> resourcesEnum = selectedResources.iterator();
- while (resourcesEnum.hasNext()) {
- IResource currentResource = (IResource) resourcesEnum.next();
- if (!currentResource.getParent().equals(firstParent))
- return false;
- // resource location must exist
- if (currentResource.getLocationURI() == null)
- return false;
- }
-
- return true;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
deleted file mode 100644
index 4c90350..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/DefaultAction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-
-import org.eclipse.swt.widgets.MessageBox;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.SWT;
-
-public class DefaultAction extends Action {
-
- Shell shell;
-
- DefaultAction (Shell shell, String s) {
- super (s);
- this.shell = shell;
- }
-
- @Override
- public void run() {
- MessageBox errorMsg = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
- errorMsg.setText(CViewMessages.DefaultAction_WIP);
- errorMsg.setMessage (CViewMessages.DefaultAction_workInProgress);
- errorMsg.open();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java
deleted file mode 100644
index 74803f4..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/GotoActionGroup.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.views.framelist.BackAction;
-import org.eclipse.ui.views.framelist.ForwardAction;
-import org.eclipse.ui.views.framelist.FrameList;
-import org.eclipse.ui.views.framelist.GoIntoAction;
-import org.eclipse.ui.views.framelist.UpAction;
-
-/**
- * This is the action group for the goto actions.
- */
-public class GotoActionGroup extends CViewActionGroup {
-
- private BackAction backAction;
- private ForwardAction forwardAction;
- private GoIntoAction goIntoAction;
- private UpAction upAction;
-
- public GotoActionGroup(CView cview) {
- super(cview);
- }
-
- @Override
- public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
- IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
- if (selection.size() == 1) {
- if (SelectionConverter.allResourcesAreOfType(selection, IResource.FOLDER)) {
- menu.add(goIntoAction);
- } else {
- IStructuredSelection resourceSelection = SelectionConverter.allResources(selection, IResource.PROJECT);
- if (resourceSelection != null && !resourceSelection.isEmpty()) {
- IProject project = (IProject) resourceSelection.getFirstElement();
- if (project.isOpen()) {
- menu.add(goIntoAction);
- }
- }
- }
- }
- }
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, goIntoAction);
- actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), backAction);
- actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), forwardAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, upAction);
-
- IToolBarManager toolBar = actionBars.getToolBarManager();
- toolBar.add(backAction);
- toolBar.add(forwardAction);
- toolBar.add(upAction);
- }
-
- @Override
- protected void makeActions() {
- FrameList frameList = getCView().getFrameList();
- goIntoAction = new GoIntoAction(frameList);
- backAction = new BackAction(frameList);
- forwardAction = new ForwardAction(frameList);
- upAction = new UpAction(frameList);
- }
-
- /* (non-Javadoc)
- */
- @Override
- public void updateActionBars() {
- ActionContext context = getContext();
- boolean enable = false;
-
- // Fix for bug 26126. Resource change listener could call
- // updateActionBars without a context being set.
- // This should never happen because resource navigator sets
- // context immediately after this group is created.
- if (context != null) {
- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
- if (selection.size() == 1) {
- Object object = selection.getFirstElement();
- if (object instanceof IAdaptable) {
- IResource resource = (IResource)((IAdaptable)object).getAdapter(IResource.class);
- if (resource instanceof IProject) {
- enable = ((IProject) resource).isOpen();
- } else if (resource instanceof IFolder) {
- enable = true;
- }
- }
- }
- }
- goIntoAction.setEnabled(enable);
- // the rest of the actions update by listening to frame list changes
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
deleted file mode 100644
index 6b7aee0..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeRefContainer.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.cview;
-
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IIncludeReference;
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CElementGrouping;
-
-/**
- * IncludeRefContainer
- */
-public class IncludeRefContainer extends CElementGrouping {
-
- ICProject fCProject;
-
- /**
- *
- */
- public IncludeRefContainer(ICProject cproject) {
- super(INCLUDE_REF_CONTAINER);
- fCProject = cproject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class) {
- return this;
- }
- if (adapter == ICProject.class) {
- return fCProject;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object o) {
- try {
- IIncludeReference[] references = fCProject.getIncludeReferences();
- IncludeReferenceProxy[] proxies = new IncludeReferenceProxy[references.length];
- for (int i = 0; i < proxies.length; ++i) {
- proxies[i] = new IncludeReferenceProxy(this, references[i]);
- }
- return proxies;
- } catch (CModelException e) {
- }
- return NO_CHILDREN;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- @Override
- public ImageDescriptor getImageDescriptor(Object object) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
- */
- @Override
- public String getLabel(Object o) {
- return CViewMessages.IncludeRefContainer_Includes;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object o) {
- return getCProject();
- }
-
- public ICProject getCProject() {
- return fCProject;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof IncludeRefContainer) {
- IncludeRefContainer other = (IncludeRefContainer)obj;
- return fCProject.equals(other.getCProject());
- }
- return super.equals(obj);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- if (fCProject != null) {
- return fCProject.hashCode();
- }
- return super.hashCode();
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
deleted file mode 100644
index 80855bb..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/IncludeReferenceProxy.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IIncludeReference;
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CElementGrouping;
-
-/**
- * @author User
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class IncludeReferenceProxy extends CElementGrouping {
-
- IncludeRefContainer includeRefContainer;
- IIncludeReference reference;
-
- public IncludeReferenceProxy(IncludeRefContainer parent, IIncludeReference reference) {
- super(0);
- this.reference = reference;
- this.includeRefContainer = parent;
- }
-
- public IIncludeReference getReference() {
- return reference;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object object) {
- try {
- return reference.getChildren();
- } catch (CModelException e) {
- // We should log the error.
- }
- return NO_CHILDREN;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- @Override
- public ImageDescriptor getImageDescriptor(Object object) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object object) {
- return getIncludeRefContainer();
- }
-
- public IncludeRefContainer getIncludeRefContainer() {
- return includeRefContainer;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof IncludeReferenceProxy)) {
- return false;
- }
- IncludeReferenceProxy other = (IncludeReferenceProxy) obj;
- return reference.equals(other.reference);
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return reference.hashCode();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return reference.toString();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java
deleted file mode 100644
index 1abcb89..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/LibraryRefContainer.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ILibraryReference;
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CElementGrouping;
-
-/**
- * VirtualGrouping
- */
-public class LibraryRefContainer extends CElementGrouping {
-
- private Object[] EMPTY = new Object[0];
- private ICProject fCProject;
-
- /**
- *
- */
- public LibraryRefContainer(ICProject cproject) {
- super(LIBRARY_REF_CONTAINER);
- fCProject = cproject;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IWorkbenchAdapter.class) {
- return this;
- }
- if (adapter == ICProject.class) {
- return fCProject;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object o) {
- try {
- ILibraryReference[] references = fCProject.getLibraryReferences();
- ArrayList list = new ArrayList(references.length);
- for (ILibraryReference reference : references) {
- IPath path = reference.getPath();
- IFile file = reference.getCModel().getWorkspace().getRoot().getFileForLocation(path);
- if (file == null || !file.isAccessible()) {
- list.add(reference);
- }
- }
- return list.toArray();
- } catch (CModelException e) {
- }
- return EMPTY;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- @Override
- public ImageDescriptor getImageDescriptor(Object object) {
- return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
- */
- @Override
- public String getLabel(Object o) {
- return CViewMessages.LibraryRefContainer_Libraries;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object o) {
- return getCProject();
- }
-
- public ICProject getCProject() {
- return fCProject;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
deleted file mode 100644
index fbc2489..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.IShellProvider;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.AddBookmarkAction;
-import org.eclipse.ui.actions.AddTaskAction;
-import org.eclipse.ui.actions.ExportResourcesAction;
-import org.eclipse.ui.actions.ImportResourcesAction;
-import org.eclipse.ui.actions.NewWizardMenu;
-import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
-import org.eclipse.ui.ide.IDEActionFactory;
-
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
-import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
-
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
-import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
-
-/**
- * The main action group for the cview. This contains a few actions and several
- * subgroups.
- */
-public class MainActionGroup extends CViewActionGroup {
-
- // Actions for Menu context.
- AddBookmarkAction addBookmarkAction;
- AddTaskAction addTaskAction;
-
- ImportResourcesAction importAction;
- ExportResourcesAction exportAction;
-
- // CElement action
- OpenIncludeAction openIncludeAction;
-
- // Collapsing
- CollapseAllAction collapseAllAction;
- ToggleLinkingAction toggleLinkingAction;
-
-
- BuildGroup buildGroup;
- OpenFileGroup openFileGroup;
- GotoActionGroup gotoGroup;
- RefactorActionGroup refactorGroup;
- OpenProjectGroup openProjectGroup;
- WorkingSetFilterActionGroup workingSetGroup;
- CustomFiltersActionGroup fCustomFiltersActionGroup;
-
- SelectionSearchGroup selectionSearchGroup;
-
- OpenViewActionGroup openViewActionGroup;
- CRefactoringActionGroup crefactoringActionGroup;
-
- private NewWizardMenu newWizardMenu;
-
- public MainActionGroup(CView cview) {
- super(cview);
- }
-
- /**
- * Handles key events in viewer.
- */
- @Override
- public void handleKeyPressed(KeyEvent event) {
- refactorGroup.handleKeyPressed(event);
- openFileGroup.handleKeyPressed(event);
- openProjectGroup.handleKeyPressed(event);
- gotoGroup.handleKeyPressed(event);
- buildGroup.handleKeyPressed(event);
- }
-
- /**
- * Handles key events in viewer.
- */
- @Override
- public void handleKeyReleased(KeyEvent event) {
- refactorGroup.handleKeyReleased(event);
- openFileGroup.handleKeyReleased(event);
- openProjectGroup.handleKeyReleased(event);
- gotoGroup.handleKeyReleased(event);
- buildGroup.handleKeyReleased(event);
- }
-
- @Override
- protected void makeActions() {
- final Viewer viewer = getCView().getViewer();
- IShellProvider shellProvider = getCView().getViewSite();
- Shell shell = shellProvider.getShell();
-
- openFileGroup = new OpenFileGroup(getCView());
- openProjectGroup = new OpenProjectGroup(getCView());
- gotoGroup = new GotoActionGroup(getCView());
- buildGroup = new BuildGroup(getCView());
- refactorGroup = new RefactorActionGroup(getCView());
-
- newWizardMenu = new NewWizardMenu(getCView().getSite().getWorkbenchWindow());
-
- openIncludeAction = new OpenIncludeAction(viewer);
-
- //sortByNameAction = new SortViewAction(this, false);
- //sortByTypeAction = new SortViewAction(this, true);
-
- IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
-
- if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) {
- Object newValue = event.getNewValue();
-
- if (newValue instanceof IWorkingSet) {
- getCView().setWorkingSet((IWorkingSet) newValue);
- } else if (newValue == null) {
- getCView().setWorkingSet(null);
- }
- }
- }
- };
- workingSetGroup = new WorkingSetFilterActionGroup(shell, workingSetUpdater);
- workingSetGroup.setWorkingSet(getCView().getWorkingSet());
- fCustomFiltersActionGroup= new CustomFiltersActionGroup(getCView(), getCView().getViewer());
-
- addBookmarkAction = new AddBookmarkAction(shellProvider, true);
- addTaskAction = new AddTaskAction(shellProvider);
-
- // Importing/exporting.
- importAction = new ImportResourcesAction(getCView().getSite().getWorkbenchWindow());
- exportAction = new ExportResourcesAction(getCView().getSite().getWorkbenchWindow());
-
- collapseAllAction = new CollapseAllAction(getCView());
-
- toggleLinkingAction = new ToggleLinkingAction(getCView());
- toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$
-// toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
-
- selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
- openViewActionGroup= new OpenViewActionGroup(getCView());
- crefactoringActionGroup= new CRefactoringActionGroup(getCView());
- }
-
- /**
- * Called when the context menu is about to open. Override to add your own
- * context dependent menu contributions.
- */
- @Override
- public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection celements = (IStructuredSelection) getCView().getViewer().getSelection();
- IStructuredSelection resources = SelectionConverter.convertSelectionToResources(celements);
-
- addNewMenu(menu, resources);
-
- if (resources.isEmpty()) {
- menu.add(new Separator(IContextMenuConstants.GROUP_GOTO));
- menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
- menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
- menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
- menu.add(new Separator("group.private1")); //$NON-NLS-1$
- importAction.selectionChanged(resources);
- menu.add(importAction);
- exportAction.selectionChanged(resources);
- menu.add(exportAction);
- menu.add(new Separator("group.private2")); //$NON-NLS-1$
- //Can be added once support for manually adding external files to index is established
- /*menu.add(new Separator());
- menu.add(addToIndexAction);*/
- menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
- addSearchMenu(menu, celements);
- menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
- menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS + "-end")); //$NON-NLS-1$
- menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
-
- openViewActionGroup.fillContextMenu(menu);
- crefactoringActionGroup.fillContextMenu(menu);
-
- if (OpenIncludeAction.canActionBeAdded(celements)) {
- menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, openIncludeAction);
- }
-
- return;
- }
-
- menu.add(new Separator(IContextMenuConstants.GROUP_GOTO));
- gotoGroup.fillContextMenu(menu);
- menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
- openFileGroup.fillContextMenu(menu);
- menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
- buildGroup.fillContextMenu(menu);
- menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
- refactorGroup.fillContextMenu(menu);
- menu.add(new Separator("group.private1")); //$NON-NLS-1$
- importAction.selectionChanged(resources);
- menu.add(importAction);
- exportAction.selectionChanged(resources);
- menu.add(exportAction);
- menu.add(new Separator("group.private2")); //$NON-NLS-1$
- openProjectGroup.fillContextMenu(menu);
- addBookMarkMenu(menu, resources);
- menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
- menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS + "-end")); //$NON-NLS-1$
- menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
-
- openViewActionGroup.fillContextMenu(menu);
- crefactoringActionGroup.fillContextMenu(menu);
- }
- /**
- * Extends the superclass implementation to set the context in the
- * subgroups.
- */
- @Override
- public void setContext(ActionContext context) {
- super.setContext(context);
- gotoGroup.setContext(context);
- openFileGroup.setContext(context);
- openProjectGroup.setContext(context);
- refactorGroup.setContext(context);
- buildGroup.setContext(context);
- openViewActionGroup.setContext(context);
- crefactoringActionGroup.setContext(context);
- //sortAndFilterGroup.setContext(context);
- //workspaceGroup.setContext(context);
- }
-
- void addNewMenu(IMenuManager menu, IStructuredSelection selection) {
- MenuManager newMenu = new MenuManager(CViewMessages.NewWizardsActionGroup_new);
- menu.add(newMenu);
- newMenu.add(newWizardMenu);
- }
-
- void addBookMarkMenu(IMenuManager menu, IStructuredSelection selection) {
- Object obj = selection.getFirstElement();
- if (obj instanceof IAdaptable) {
- IAdaptable element = (IAdaptable) obj;
- IResource resource = (IResource) element.getAdapter(IResource.class);
- if (resource instanceof IFile) {
- addBookmarkAction.selectionChanged(selection);
- menu.add(addBookmarkAction);
- }
- }
- }
-
- void addSearchMenu(IMenuManager menu, IStructuredSelection selection) {
- IAdaptable element = (IAdaptable) selection.getFirstElement();
-
- if (element instanceof ITranslationUnit || element instanceof ICProject) {
- return;
- }
-
- if (SelectionSearchGroup.canActionBeAdded(selection)){
- selectionSearchGroup.fillContextMenu(menu);
- }
- }
-
- @Override
- public void runDefaultAction(IStructuredSelection selection) {
- openFileGroup.runDefaultAction(selection);
- openProjectGroup.runDefaultAction(selection);
- gotoGroup.runDefaultAction(selection);
- buildGroup.runDefaultAction(selection);
- refactorGroup.runDefaultAction(selection);
- //workingSetGroup.runDefaultAction(selection);
- }
-
- /**
- * Updates all actions with the given selection. Necessary when popping up
- * a menu, because some of the enablement criteria may have changed, even
- * if the selection in the viewer hasn't. E.g. A project was opened or
- * closed.
- */
- @Override
- public void updateActionBars() {
- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
-
- //sortByTypeAction.selectionChanged(selection);
- //sortByNameAction.selectionChanged(selection);
- addBookmarkAction.selectionChanged(selection);
- addTaskAction.selectionChanged(selection);
-
- openFileGroup.updateActionBars();
- openProjectGroup.updateActionBars();
- gotoGroup.updateActionBars();
- buildGroup.updateActionBars();
- refactorGroup.updateActionBars();
- workingSetGroup.updateActionBars();
- fCustomFiltersActionGroup.updateActionBars();
-
- openViewActionGroup.updateActionBars();
- crefactoringActionGroup.updateActionBars();
- }
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction);
- actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction);
-
- workingSetGroup.fillActionBars(actionBars);
- fCustomFiltersActionGroup.fillActionBars(actionBars);
- gotoGroup.fillActionBars(actionBars);
- refactorGroup.fillActionBars(actionBars);
- openFileGroup.fillActionBars(actionBars);
- openProjectGroup.fillActionBars(actionBars);
- buildGroup.fillActionBars(actionBars);
-
- openViewActionGroup.fillActionBars(actionBars);
- crefactoringActionGroup.fillActionBars(actionBars);
-
- IToolBarManager toolBar = actionBars.getToolBarManager();
- toolBar.add(new Separator());
- toolBar.add(collapseAllAction);
- toolBar.add(toggleLinkingAction);
-
- IMenuManager menu = actionBars.getMenuManager();
- //menu.add (clibFilterAction);
- //menu.add(fCustomFiltersActionGroup);
- menu.add(toggleLinkingAction);
- }
-
- //---- Persistent state -----------------------------------------------------------------------
-
- @Override
- public void restoreFilterAndSorterState(IMemento memento) {
- //fWorkingSetFilterActionGroup.restoreState(memento);
- fCustomFiltersActionGroup.restoreState(memento);
- }
-
- @Override
- public void saveFilterAndSorterState(IMemento memento) {
- //fWorkingSetFilterActionGroup.saveState(memento);
- fCustomFiltersActionGroup.saveState(memento);
- }
-
- public CustomFiltersActionGroup getCustomFilterActionGroup() {
- return fCustomFiltersActionGroup;
- }
-
- @Override
- public void dispose() {
- importAction.dispose();
- exportAction.dispose();
- refactorGroup.dispose();
- openFileGroup.dispose();
- openProjectGroup.dispose();
- gotoGroup.dispose();
- buildGroup.dispose();
- newWizardMenu.dispose();
- openViewActionGroup.dispose();
- crefactoringActionGroup.dispose();
- super.dispose();
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java
deleted file mode 100644
index 2f81a17..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenFileGroup.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.OpenFileAction;
-import org.eclipse.ui.actions.OpenInNewWindowAction;
-import org.eclipse.ui.actions.OpenWithMenu;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-
-/**
- * This is the action group for the open actions.
- */
-public class OpenFileGroup extends CViewActionGroup {
-
- private OpenFileAction openFileAction;
-
- public OpenFileGroup(CView cview) {
- super(cview);
- }
-
- @Override
- protected void makeActions() {
- openFileAction = new OpenFileAction(getCView().getSite().getPage());
- }
-
- @Override
- public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
- IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
- boolean anyResourceSelected = !selection.isEmpty()
- && SelectionConverter.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE);
- boolean onlyFilesSelected = !selection.isEmpty() && SelectionConverter.allResourcesAreOfType(selection, IResource.FILE);
-
- if (onlyFilesSelected) {
- openFileAction.selectionChanged(selection);
- menu.add(openFileAction);
- fillOpenWithMenu(menu, selection);
- }
-
- if (anyResourceSelected) {
- addNewWindowAction(menu, selection);
- }
- }
-
- /**
- * Adds the OpenWith submenu to the context menu.
- *
- * @param menu
- * the context menu
- * @param selection
- * the current selection
- */
- private void fillOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
- // Only supported if exactly one file is selected.
- if (selection.size() != 1) {
- return;
- }
- Object element = selection.getFirstElement();
- if (!(element instanceof IFile)) {
- return;
- }
-
- MenuManager submenu = new MenuManager(CViewMessages.OpenWithMenu_label);
- submenu.add(new OpenWithMenu(getCView().getSite().getPage(), (IFile) element));
- menu.add(submenu);
- }
-
- /**
- * Adds the Open in New Window action to the context menu.
- *
- * @param menu
- * the context menu
- * @param selection
- * the current selection
- */
- private void addNewWindowAction(IMenuManager menu, IStructuredSelection selection) {
-
- // Only supported if exactly one container (i.e open project or folder) is selected.
- if (selection.size() != 1) {
- return;
- }
- Object element = selection.getFirstElement();
- if (!(element instanceof IContainer)) {
- return;
- }
- if (element instanceof IProject && !(((IProject) element).isOpen())) {
- return;
- }
-
- menu.add(new OpenInNewWindowAction(getCView().getSite().getWorkbenchWindow(), (IContainer) element));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
- */
- @Override
- public void fillActionBars(IActionBars actionBars) {
- }
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
- */
- @Override
- public void updateActionBars() {
- }
-
- /**
- * Runs the default action (open file).
- */
- @Override
- public void runDefaultAction(IStructuredSelection selection) {
- Object obj = selection.getFirstElement();
- if (obj instanceof ICElement) {
- ICElement celement = (ICElement) obj;
- //System.out.println ("Double click on " + element);
- try {
- IEditorPart part = EditorUtility.openInEditor(celement);
- if (part != null) {
- IWorkbenchPage page = getCView().getSite().getPage();
- page.bringToTop(part);
- if (celement instanceof ISourceReference && !(celement instanceof ITranslationUnit)) {
- EditorUtility.revealInEditor(part, celement);
- }
- }
- } catch (Exception e) {
- }
- } else if (obj instanceof IAdaptable) {
- IResource element = (IResource)((IAdaptable)obj).getAdapter(IResource.class);
- if (element instanceof IFile) {
- openFileAction.selectionChanged(selection);
- openFileAction.run();
- }
- else if(element instanceof IProject){
- try {
- ((IProject)element).open(null);
- } catch (CoreException e) {
- CUIPlugin.log(e);
- }
- }
- }
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java
deleted file mode 100644
index 2fee3f2..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/OpenProjectGroup.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.CloseResourceAction;
-import org.eclipse.ui.actions.OpenResourceAction;
-import org.eclipse.ui.actions.RefreshAction;
-import org.eclipse.ui.ide.IDEActionFactory;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * This is the action group for actions such as Refresh Local, and Open/Close
- * Project.
- */
-public class OpenProjectGroup extends CViewActionGroup {
-
- private OpenResourceAction openProjectAction;
- private CloseResourceAction closeProjectAction;
- private RefreshAction refreshAction;
-
- public OpenProjectGroup(CView cview) {
- super(cview);
- }
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
- actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction);
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction);
- }
-
- /**
- * Adds the open project, close project and refresh resource actions to the
- * context menu.
- *
- * refresh-no closed project selected
- *
- *
- * Both the open project and close project action may be on the menu at the
- * same time.
- *
- *
- * No disabled action should be on the context menu.
- *
- *
- * @param menu
- * context menu to add actions to
- */
- @Override
- public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
- boolean isProjectSelection = true;
- boolean hasOpenProjects = false;
- boolean hasClosedProjects = false;
- Iterator> resources = selection.iterator();
-
- while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || isProjectSelection)) {
- Object next = resources.next();
- IProject project = null;
-
- if (next instanceof IProject) {
- project = (IProject) next;
- } else if (next instanceof IAdaptable) {
- IResource res = (IResource) ((IAdaptable) next).getAdapter(IResource.class);
- if (res instanceof IProject) {
- project = (IProject)res;
- }
- }
-
- if (project == null) {
- isProjectSelection = false;
- continue;
- }
- if (project.isOpen()) {
- hasOpenProjects = true;
- } else {
- hasClosedProjects = true;
- }
- }
- if (!hasClosedProjects) {
- refreshAction.selectionChanged(selection);
- menu.add(refreshAction);
- }
- if (isProjectSelection) {
- if (hasClosedProjects) {
- openProjectAction.selectionChanged(selection);
- menu.add(openProjectAction);
- }
- if (hasOpenProjects) {
- closeProjectAction.selectionChanged(selection);
- menu.add(closeProjectAction);
- }
- }
- }
-
- /**
- * Handles a key pressed event by invoking the appropriate action.
- */
- @Override
- public void handleKeyPressed(KeyEvent event) {
- if (event.keyCode == SWT.F5 && event.stateMask == 0) {
- if (refreshAction.isEnabled()) {
- refreshAction.refreshAll();
- }
- // Swallow the event
- event.doit = false;
- }
- }
-
- @Override
- protected void makeActions() {
- final IWorkbenchPartSite site= getCView().getSite();
- IWorkspace workspace = CUIPlugin.getWorkspace();
-
- openProjectAction = new OpenResourceAction(site);
- workspace.addResourceChangeListener(openProjectAction, IResourceChangeEvent.POST_CHANGE);
- closeProjectAction = new CloseResourceAction(site);
- workspace.addResourceChangeListener(closeProjectAction, IResourceChangeEvent.POST_CHANGE);
- refreshAction = new RefreshAction(site);
- refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$
- refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));//$NON-NLS-1$
-// refreshAction.setHoverImageDescriptor(getImageDescriptor("clcl16/refresh_nav.gif"));//$NON-NLS-1$
- }
-
- @Override
- public void updateActionBars() {
- IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
- refreshAction.selectionChanged(selection);
- openProjectAction.selectionChanged(selection);
- closeProjectAction.selectionChanged(selection);
- }
-
- @Override
- public void dispose() {
- IWorkspace workspace = CUIPlugin.getWorkspace();
- workspace.removeResourceChangeListener(closeProjectAction);
- workspace.removeResourceChangeListener(openProjectAction);
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
deleted file mode 100644
index 90b2dbf..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/PasteAction.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
-import org.eclipse.ui.actions.CopyProjectOperation;
-import org.eclipse.ui.actions.SelectionListenerAction;
-import org.eclipse.ui.part.ResourceTransfer;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-
-/**
- * Standard action for pasting resources on the clipboard to the selected resource's location.
- *
- * This class may be instantiated; it is not intended to be subclassed.
- *
- *
- * @since 2.0
- */
-/*package*/
-public class PasteAction extends SelectionListenerAction {
-
- /**
- * The id of this action.
- */
- public static final String ID = PlatformUI.PLUGIN_ID + ".PasteAction"; //$NON-NLS-1$
-
- /**
- * The shell in which to show any dialogs.
- */
- private Shell shell;
-
- /**
- * System clipboard
- */
- Clipboard clipboard;
-
- /**
- * Creates a new action.
- *
- * @param shell the shell for any dialogs
- */
- public PasteAction(Shell shell, Clipboard clipboard) {
- super(CViewMessages.PasteAction_title);
- Assert.isNotNull(shell);
- Assert.isNotNull(clipboard);
- this.shell = shell;
- this.clipboard = clipboard;
- setToolTipText(CViewMessages.PasteAction_toolTip);
- setId(PasteAction.ID);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.PASTE_ACTION);
- }
- /**
- * Returns the actual target of the paste action. Returns null
- * if no valid target is selected.
- *
- * @return the actual target of the paste action
- */
- private IResource getTarget() {
- List> selectedResources = getSelectedResources();
-
- for (int i = 0; i < selectedResources.size(); i++) {
- IResource resource = (IResource) selectedResources.get(i);
-
- if (resource instanceof IProject && !((IProject) resource).isOpen())
- return null;
- if (resource.getType() == IResource.FILE)
- resource = resource.getParent();
- if (resource != null)
- return resource;
- }
- return null;
- }
- /**
- * Returns whether any of the given resources are linked resources.
- *
- * @param resources resource to check for linked type. may be null
- * @return true=one or more resources are linked. false=none of the
- * resources are linked
- */
- private boolean isLinked(IResource[] resources) {
- if (resources != null) {
- for (int i = 0; i < resources.length; i++) {
- if (resources[i].isLinked()) {
- return true;
- }
- }
- }
- return false;
- }
- /**
- * Implementation of method defined on IAction.
- */
- @Override
- public void run() {
- // try a resource transfer
- ResourceTransfer resTransfer = ResourceTransfer.getInstance();
- IResource[] resourceData = (IResource[]) clipboard.getContents(resTransfer);
-
- if (resourceData != null && resourceData.length > 0) {
- if (resourceData[0].getType() == IResource.PROJECT) {
- // enablement checks for all projects
- for (int i = 0; i < resourceData.length; i++) {
- CopyProjectOperation operation = new CopyProjectOperation(this.shell);
- operation.copyProject((IProject) resourceData[i]);
- }
- } else {
- // enablement should ensure that we always have access to a container
- IContainer container = getContainer();
-
- CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(this.shell);
- operation.copyResources(resourceData, container);
- }
- return;
- }
-
- // try a file transfer
- FileTransfer fileTransfer = FileTransfer.getInstance();
- String[] fileData = (String[]) clipboard.getContents(fileTransfer);
-
- if (fileData != null) {
- // enablement should ensure that we always have access to a container
- IContainer container = getContainer();
-
- CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(this.shell);
- operation.copyFiles(fileData, container);
- }
- }
- /**
- * Returns the container to hold the pasted resources.
- */
- private IContainer getContainer() {
- List> selection = getSelectedResources();
- if (selection.get(0) instanceof IFile)
- return ((IFile) selection.get(0)).getParent();
- return (IContainer) selection.get(0);
- }
- /**
- * The PasteAction implementation of this
- * SelectionListenerAction method enables this action if
- * a resource compatible with what is on the clipboard is selected.
- */
- @Override
- protected boolean updateSelection(IStructuredSelection selection) {
- if (!super.updateSelection(selection))
- return false;
-
- final IResource[][] clipboardData = new IResource[1][];
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- // clipboard must have resources or files
- ResourceTransfer resTransfer = ResourceTransfer.getInstance();
- clipboardData[0] = (IResource[])clipboard.getContents(resTransfer);
- }
- });
- IResource[] resourceData = clipboardData[0];
- if (resourceData != null && resourceData.length > 0 && resourceData[0].getType() == IResource.PROJECT) {
- for (int i = 0; i < resourceData.length; i++) {
- // make sure all resource data are open projects
- // can paste open projects regardless of selection
- if (resourceData[i].getType() != IResource.PROJECT || ((IProject) resourceData[i]).isOpen() == false)
- return false;
- }
- return true;
- }
-
- // can paste files and folders to a single selection (project must be open)
- // or multiple file selection with the same parent
- if (getSelectedNonResources().size() > 0)
- return false;
-
- // targetResource is null if no valid target is selected or
- // selection is empty
- IResource targetResource = getTarget();
- if (targetResource == null)
- return false;
-
- // can paste files and folders to a single selection (file, folder,
- // open project) or multiple file selection with the same parent
- List> selectedResources = getSelectedResources();
- if (selectedResources.size() > 1) {
- // if more than one resource is selected the selection has
- // to be all files with the same parent
- for (int i = 0; i < selectedResources.size(); i++) {
- IResource resource = (IResource) selectedResources.get(i);
- if (resource.getType() != IResource.FILE)
- return false;
- if (!targetResource.equals(resource.getParent()))
- return false;
- }
- }
-
- if (resourceData != null) {
- // linked resources can only be pasted into projects
- if (isLinked(resourceData) && targetResource.getType() != IResource.PROJECT)
- return false;
-
- if (targetResource.getType() == IResource.FOLDER) {
- // don't try to copy folder to self
- for (int i = 0; i < resourceData.length; i++) {
- if (targetResource.equals(resourceData[i]))
- return false;
- }
- }
- return true;
- }
-
- TransferData[] transfers = clipboard.getAvailableTypes();
- FileTransfer fileTransfer = FileTransfer.getInstance();
- for (int i = 0; i < transfers.length; i++) {
- if (fileTransfer.isSupportedType(transfers[i]))
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java
deleted file mode 100644
index b035163..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/RefactorActionGroup.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Markus Schorn (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.DeleteResourceAction;
-import org.eclipse.ui.actions.TextActionHandler;
-
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-
-/**
- * This is the action group for refactor actions,
- * including global action handlers for copy, paste and delete.
- *
- */
-public class RefactorActionGroup extends CViewActionGroup {
-
- private Clipboard clipboard;
-
- private CopyAction copyAction;
- private DeleteResourceAction deleteAction;
- private PasteAction pasteAction;
- private CViewRenameAction renameAction;
- private CViewMoveAction moveAction;
- private TextActionHandler textActionHandler;
-
- public RefactorActionGroup(CView cview) {
- super(cview);
- }
-
- @Override
- public void dispose() {
- if (clipboard != null) {
- clipboard.dispose();
- clipboard = null;
- }
- super.dispose();
- }
-
- @Override
- public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
- IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
-
- boolean anyResourceSelected = !selection.isEmpty()
- && SelectionConverter.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE);
-
- copyAction.selectionChanged(selection);
- menu.add(copyAction);
- pasteAction.selectionChanged(selection);
- menu.add(pasteAction);
-
- if (anyResourceSelected) {
- deleteAction.selectionChanged(selection);
- menu.add(deleteAction);
- moveAction.selectionChanged(selection);
- menu.add(moveAction);
- renameAction.selectionChanged(selection);
- menu.add(renameAction);
- }
- }
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
- textActionHandler = new TextActionHandler(actionBars); // hooks handlers
- textActionHandler.setCopyAction(copyAction);
- textActionHandler.setPasteAction(pasteAction);
- textActionHandler.setDeleteAction(deleteAction);
- renameAction.setTextActionHandler(textActionHandler);
-
- actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction);
- actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
- }
-
- /**
- * Handles a key pressed event by invoking the appropriate action.
- */
- @Override
- public void handleKeyPressed(KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- if (deleteAction.isEnabled()) {
- deleteAction.run();
- }
- // Swallow the event.
- event.doit = false;
- } else if (event.keyCode == SWT.F2 && event.stateMask == 0) {
- if (renameAction.isEnabled()) {
- renameAction.run();
- }
- // Swallow the event.
- event.doit = false;
- }
- }
-
- @Override
- protected void makeActions() {
- TreeViewer treeViewer = getCView().getViewer();
- final IWorkbenchPartSite site = getCView().getSite();
- Shell shell = site.getShell();
- clipboard = new Clipboard(shell.getDisplay());
-
- pasteAction = new PasteAction(shell, clipboard);
- ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
- pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
- pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
- pasteAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
-
- copyAction = new CopyAction(shell, clipboard, pasteAction);
- copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
- copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- copyAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
-
- moveAction = new CViewMoveAction(site, treeViewer);
- renameAction = new CViewRenameAction(site, treeViewer);
-
- deleteAction = new DeleteResourceAction(site);
- deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
- deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
- deleteAction.setHoverImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
- }
-
- @Override
- public void updateActionBars() {
- IStructuredSelection celements = (IStructuredSelection) getContext().getSelection();
- IStructuredSelection selection = SelectionConverter.convertSelectionToResources(celements);
-
- copyAction.selectionChanged(selection);
- pasteAction.selectionChanged(selection);
- deleteAction.selectionChanged(selection);
- moveAction.selectionChanged(selection);
- renameAction.selectionChanged(selection);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java
deleted file mode 100644
index d2f9976..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDragAdapter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ISourceReference;
-
-import org.eclipse.cdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
-
-public class SelectionTransferDragAdapter extends BasicSelectionTransferDragAdapter {
-
- public SelectionTransferDragAdapter(ISelectionProvider provider) {
- super(provider);
- }
-
- @Override
- protected boolean isDragable(ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- for (Iterator> iter= ((IStructuredSelection)selection).iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof ICElement) {
- if (!(element instanceof ISourceReference)) {
- return false;
- }
- }
- }
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java
deleted file mode 100644
index d40789b..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/SelectionTransferDropAdapter.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- * Anton Leherbauer (Wind River Systems) - Fixed bug 141484
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.cview;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Shell;
-
-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.ISourceReference;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-
-import org.eclipse.cdt.internal.ui.dnd.CDTViewerDropAdapter;
-import org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-
-public class SelectionTransferDropAdapter extends CDTViewerDropAdapter implements TransferDropTargetListener {
-
- private List> fElements;
- private ICElement[] fMoveData;
- private ICElement[] fCopyData;
-
- private static final long DROP_TIME_DIFF_TRESHOLD= 150;
-
- public SelectionTransferDropAdapter(StructuredViewer viewer) {
- super(viewer, DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND);
- }
-
- //---- TransferDropTargetListener interface ---------------------------------------
-
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getTransfer();
- }
-
- public boolean isEnabled(DropTargetEvent event) {
- Object target= event.item != null ? event.item.getData() : null;
- if (target == null) {
- return false;
- }
- return target instanceof ISourceReference;
- }
-
- //---- Actual DND -----------------------------------------------------------------
-
- @Override
- public void dragEnter(DropTargetEvent event) {
- clear();
- super.dragEnter(event);
- }
-
- @Override
- public void dragLeave(DropTargetEvent event) {
- clear();
- super.dragLeave(event);
- }
-
- private void clear() {
- fElements = null;
- fMoveData = null;
- fCopyData = null;
- }
-
- @Override
- public void validateDrop(Object target, DropTargetEvent event, int operation) {
- event.detail= DND.DROP_NONE;
-
- if (tooFast(event)) {
- return;
- }
-
- initializeSelection();
-
- try {
- switch(operation) {
- case DND.DROP_DEFAULT:
- event.detail= handleValidateDefault(target, event);
- break;
- case DND.DROP_COPY:
- event.detail= handleValidateCopy(target, event);
- break;
- case DND.DROP_MOVE:
- event.detail= handleValidateMove(target, event);
- break;
- case DND.DROP_LINK:
- event.detail= handleValidateLink(target, event);
- break;
- }
- } catch (CModelException e){
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message);
- event.detail= DND.DROP_NONE;
- }
- }
-
- protected void initializeSelection(){
- if (fElements != null) {
- return;
- }
- ISelection s= LocalSelectionTransfer.getTransfer().getSelection();
- if (!(s instanceof IStructuredSelection)) {
- return;
- }
- fElements = ((IStructuredSelection)s).toList();
- }
-
- private boolean tooFast(DropTargetEvent event) {
- return Math.abs(LocalSelectionTransfer.getTransfer().getSelectionSetTime() - (event.time & 0xFFFFFFFFL)) < DROP_TIME_DIFF_TRESHOLD;
- }
-
- @Override
- public void drop(Object target, DropTargetEvent event) {
- try {
- switch(event.detail) {
- case DND.DROP_MOVE:
- handleDropMove(target, event);
- break;
- case DND.DROP_COPY:
- handleDropCopy(target, event);
- break;
- case DND.DROP_LINK:
- handleDropLink(target, event);
- break;
- }
- } catch (CModelException e){
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_message);
- } catch(InvocationTargetException e) {
- ExceptionHandler.handle(e, CViewMessages.SelectionTransferDropAdapter_error_title, CViewMessages.SelectionTransferDropAdapter_error_exception);
- } catch (InterruptedException e) {
- //ok
- } finally {
- // The drag source listener must not perform any operation
- // since this drop adapter did the remove of the source even
- // if we moved something.
- event.detail= DND.DROP_NONE;
- }
- }
-
- private int handleValidateDefault(Object target, DropTargetEvent event) throws CModelException {
- if (target == null) {
- return DND.DROP_NONE;
- }
- return handleValidateMove(target, event);
- }
-
- private int handleValidateMove(Object target, DropTargetEvent event) throws CModelException {
- if (target == null || fElements.contains(target)) {
- return DND.DROP_NONE;
- }
- if (fMoveData == null) {
- ICElement[] cElements= getCElements(fElements);
- if (cElements != null && cElements.length > 0) {
- fMoveData = cElements;
- }
- }
-
- if (!canMoveElements()) {
- return DND.DROP_NONE;
- }
-
- if (target instanceof ISourceReference) {
- return DND.DROP_MOVE;
- }
- return DND.DROP_NONE;
- }
-
- private boolean canMoveElements() {
- if (fMoveData != null) {
- return hasCommonParent(fMoveData);
- }
- return false;
- }
-
- private boolean hasCommonParent(ICElement[] elements) {
- if (elements.length > 1) {
- ICElement parent = elements[0];
- for (int i = 0; i < elements.length; ++i) {
- ICElement p = elements[i].getParent();
- if (parent == null) {
- if (p != null) {
- return false;
- }
- } else if (!parent.equals(p)){
- return false;
- }
- }
- }
- return true;
- }
-
- private void handleDropLink(Object target, DropTargetEvent event) {
- }
-
- private int handleValidateLink(Object target, DropTargetEvent event) {
- return DND.DROP_NONE;
- }
-
- private void handleDropMove(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
- final ICElement[] cElements= getCElements(fElements);
-
- if (target instanceof ICElement) {
- ICElement cTarget = (ICElement)target;
- ICElement parent = cTarget;
- boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
- if (!isTargetTranslationUnit) {
- parent = cTarget.getParent();
- }
- final ICElement[] containers = new ICElement[cElements.length];
- for (int i = 0; i < containers.length; ++i) {
- containers[i] = parent;
- }
- ICElement[] neighbours = null;
- if (!isTargetTranslationUnit) {
- neighbours = new ICElement[cElements.length];
- for (int i = 0; i < neighbours.length; ++i) {
- neighbours[i] = cTarget;
- }
- }
- final ICElement[] siblings = neighbours;
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- CoreModel.getDefault().getCModel().move(cElements, containers, siblings, null, false, monitor);
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- }
- }
- };
- run(runnable);
- }
- }
-
- private int handleValidateCopy(Object target, DropTargetEvent event) throws CModelException{
- if (target == null) {
- return DND.DROP_NONE;
- }
-
- if (fCopyData == null) {
- ICElement[] cElements= getCElements(fElements);
- if (cElements != null && cElements.length > 0) {
- fCopyData= cElements;
- }
- }
-
- if (!canCopyElements())
- return DND.DROP_NONE;
-
- if (target instanceof ISourceReference) {
- return DND.DROP_COPY;
- }
- return DND.DROP_NONE;
- }
-
- private boolean canCopyElements() {
- if (fCopyData != null) {
- return hasCommonParent(fCopyData);
- }
- return false;
- }
-
- private void handleDropCopy(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{
- final ICElement[] cElements= getCElements(fElements);
-
- if (target instanceof ICElement) {
- ICElement cTarget = (ICElement)target;
- ICElement parent = cTarget;
- boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit;
- if (!isTargetTranslationUnit) {
- parent = cTarget.getParent();
- }
- final ICElement[] containers = new ICElement[cElements.length];
- for (int i = 0; i < containers.length; ++i) {
- containers[i] = parent;
- }
- ICElement[] neighbours = null;
- if (!isTargetTranslationUnit) {
- neighbours = new ICElement[cElements.length];
- for (int i = 0; i < neighbours.length; ++i) {
- neighbours[i] = cTarget;
- }
- }
- final ICElement[] siblings = neighbours;
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- CoreModel.getDefault().getCModel().copy(cElements, containers, siblings, null, false, monitor);
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- }
- }
- };
- run(runnable);
- }
- }
-
- private Shell getShell() {
- return getViewer().getControl().getShell();
- }
-
- public void run(IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException {
- IRunnableContext context= new ProgressMonitorDialog(getShell());
- context.run(true, true, runnable);
- }
-
- public static ICElement[] getCElements(List> elements) {
- List resources= new ArrayList(elements.size());
- for (Iterator> iter= elements.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof ITranslationUnit) {
- continue;
- }
- if (element instanceof ICElement)
- resources.add((ICElement) element);
- }
- return resources.toArray(new ICElement[resources.size()]);
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java
deleted file mode 100644
index ab292b6..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/ToggleLinkingAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.cview;
-
-import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
-
-/**
- * This action toggles whether this navigator links its selection to the active
- * editor.
- *
- * @since 2.0
- */
-public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- CView fCView;
-
- /**
- * Constructs a new action.
- */
- public ToggleLinkingAction(CView cView) {
- fCView = cView;
- setChecked(cView.isLinkingEnabled());
- }
-
- /**
- * Runs the action.
- */
- @Override
- public void run() {
- fCView.setLinkingEnabled(isChecked());
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
deleted file mode 100644
index 2ad44ec..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/AbstractElementListSelectionDialog.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A class to select one or more elements out of an indexed property
- */
-public abstract class AbstractElementListSelectionDialog extends SelectionStatusDialog {
-
- private ILabelProvider fRenderer;
- private boolean fIgnoreCase;
- private boolean fIsMultipleSelection;
-
- private SelectionList fSelectionList;
- private Label fMessage;
- private ISelectionValidator fValidator;
-
- private String fMessageText;
- private String fEmptyListMessage;
- private String fNothingSelectedMessage;
-
- private StatusInfo fCurrStatus;
-
- /*
- * @private
- */
- protected void access$superOpen() {
- super.open();
- }
- /*
- * @private
- * @see Dialog#cancelPressed
- */
- @Override
- protected void cancelPressed() {
- setResult(null);
- super.cancelPressed();
- }
- protected Point computeInitialSize() {
- return new Point(convertWidthInCharsToPixels(60), convertHeightInCharsToPixels(18));
- }
- /*
- * @private
- * @see Window#createDialogArea(Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite contents= (Composite)super.createDialogArea(parent);
-
- fMessage= createMessage(contents);
-
- int flags= fIsMultipleSelection ? SWT.MULTI : SWT.SINGLE;
- fSelectionList= new SelectionList(contents, flags | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL,
- fRenderer, fIgnoreCase);
-
- fSelectionList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- handleDoubleClick();
- }
- public void widgetSelected(SelectionEvent e) {
- verifyCurrentSelection();
- }
- });
-
- GridData spec= new GridData();
- Point initialSize= computeInitialSize();
- spec.widthHint= initialSize.x;
- spec.heightHint= initialSize.y;
- spec.grabExcessVerticalSpace= true;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.FILL;
- fSelectionList.setLayoutData(spec);
-
- return contents;
- }
- /**
- * Creates the message text widget and sets layout data.
- */
- protected Label createMessage(Composite parent) {
- Label text= new Label(parent, SWT.NULL);
- text.setText(fMessageText);
- GridData spec= new GridData();
- spec.grabExcessVerticalSpace= false;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.BEGINNING;
- text.setLayoutData(spec);
- return text;
- }
- /*
- * @private
- * @see Window#create(Shell)
- */
- @Override
- public void create() {
- super.create();
- if (isEmptyList()) {
- fMessage.setEnabled(false);
- fSelectionList.setEnabled(false);
- } else {
- verifyCurrentSelection();
- fSelectionList.selectFilterText();
- fSelectionList.setFocus();
- }
- }
- /**
- * Returns the currently used filter text.
- */
- protected String getFilter() {
- return fSelectionList.getFilter();
- }
- /**
- * Returns the selection indices.
- */
- protected int[] getSelectionIndices() {
- return fSelectionList.getSelectionIndices();
- }
- /**
- * Returns the widget selection. Returns empty list when the widget is not
- * usable.
- */
- protected List> getWidgetSelection() {
- if (fSelectionList == null || fSelectionList.isDisposed())
- return Collections.emptyList();
- return fSelectionList.getSelection();
- }
- /**
- * An element as been selected in the list by double clicking on it.
- * Emulate a OK button pressed to close the dialog.
- */
- protected abstract void handleDoubleClick();
- /**
- * Checks whether the list of elements is empty or not.
- */
- protected boolean isEmptyList() {
- if (fSelectionList == null)
- return true;
- return fSelectionList.isEmptyList();
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
- */
- protected AbstractElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- super(parent);
- setTitle(title);
- setImage(image);
- fRenderer= renderer;
- fIgnoreCase= ignoreCase;
- fIsMultipleSelection= multipleSelection;
-
- fMessageText= ""; //$NON-NLS-1$
-
- fCurrStatus= new StatusInfo();
-
- fValidator= null;
- fEmptyListMessage= ""; //$NON-NLS-1$
- fNothingSelectedMessage= ""; //$NON-NLS-1$
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
- */
- protected AbstractElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
- }
- /*
- * @private
- */
- @Override
- public int open() {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- access$superOpen();
- }
- });
- return getReturnCode() ;
- }
- /**
- * Refilters the current list according to the filter entered into the
- * text edit field.
- */
- protected void refilter() {
- fSelectionList.filter(true);
- }
- /**
- * If a empty-list message is set, a error message is shown
- * Must be set before widget creation
- */
- public void setEmptyListMessage(String message) {
- fEmptyListMessage= message;
- }
- /**
- * Sets the filter text to the given value.
- */
- protected void setFilter(String text, boolean refilter) {
- fSelectionList.setFilter(text, refilter);
- }
- /**
- * Sets the message to be shown above the match text field.
- * Must be set before widget creation
- */
- @Override
- public void setMessage(String message) {
- fMessageText= message;
- }
- /**
- * If the selection is empty, this message is shown
- */
- public void setNothingSelectedMessage(String message) {
- fNothingSelectedMessage= message;
- }
- /**
- * Selects the elements in the list determined by the given
- * selection indices.
- */
- protected void setSelection(int[] selection) {
- fSelectionList.setSelection(selection);
- }
- /**
- * Initializes the selection list widget with the given list of
- * elements.
- */
- protected void setSelectionListElements(List> elements, boolean refilter) {
- fSelectionList.setElements(elements, refilter);
- }
- /**
- * A validator can be set to check if the current selection
- * is valid
- */
- public void setValidator(ISelectionValidator validator) {
- fValidator= validator;
- }
- /**
- * Verifies the current selection and updates the status line
- * accordingly.
- */
- protected boolean verifyCurrentSelection() {
- List> sel= getWidgetSelection();
- int length= sel.size();
- if (length > 0) {
- if (fValidator != null) {
- fValidator.isValid(sel.toArray(), fCurrStatus);
- } else {
- fCurrStatus.setOK();
- }
- } else {
- if (isEmptyList()) {
- fCurrStatus.setError(fEmptyListMessage);
- } else {
- fCurrStatus.setError(fNothingSelectedMessage);
- }
- }
- updateStatus(fCurrStatus);
- return fCurrStatus.isOK();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
deleted file mode 100644
index 2471501..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ElementListSelectionDialog.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A class to select one or more elements out of an indexed property
- */
-public class ElementListSelectionDialog extends AbstractElementListSelectionDialog {
-
- private List> fElements;
-
- /*
- * @private
- */
- @Override
- protected void computeResult() {
- setResult(getWidgetSelection());
- }
- /*
- * @private
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Control result= super.createDialogArea(parent);
-
- setSelectionListElements(fElements, false);
- //a little trick to make the window come up faster
- String initialFilter= null;
- if (getPrimaryInitialSelection() instanceof String)
- initialFilter= (String)getPrimaryInitialSelection();
- if (initialFilter != null)
- setFilter(initialFilter, true);
- else
- refilter();
-
- return result;
- }
- public Object getSelectedElement() {
- return getPrimaryResult();
- }
- public Object[] getSelectedElements() {
- return getResult();
- }
- /*
- * @private
- */
- @Override
- protected void handleDoubleClick() {
- if (verifyCurrentSelection()) {
- buttonPressed(IDialogConstants.OK_ID);
- }
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upper case
- * @param multipleSelection Allow multiple selection
- */
- public ElementListSelectionDialog(Shell parent, String title, Image image, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- super (parent, title, image, renderer, ignoreCase, multipleSelection);
- }
- /**
- * Constructs a list selection dialog.
- * @param renderer The label renderer used
- * @param ignoreCase Decides if the match string ignores lower/upppr case
- * @param multipleSelection Allow multiple selection
- */
- public ElementListSelectionDialog(Shell parent, ILabelProvider renderer, boolean ignoreCase, boolean multipleSelection) {
- this(parent, "", null, renderer, ignoreCase, multipleSelection); //$NON-NLS-1$
- }
- public int open(Object[] elements) {
- return open(Arrays.asList(elements));
- }
- public int open(Object[] elements, String initialSelection) {
- return open(Arrays.asList(elements), initialSelection);
- }
- /**
- * Open the dialog.
- * @param elements The elements to show in the list
- * @return Returns OK or CANCEL
- */
- public int open(List> elements) {
- setElements(elements);
- return open();
- }
- /**
- * Open the dialog.
- * @param elements The elements to show in the list
- * @param initialSelection The initial content of the match text box.
- * @return Returns OK or CANCEL
- */
- public int open(List> elements, String initialSelection) {
- setElements(elements);
- setInitialSelection(initialSelection);
- return open();
- }
- /**
- * Sets the elements presented by this dialog.
- */
- public void setElements(List> elements) {
- fElements= elements;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java
deleted file mode 100644
index de9ff24..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/ISelectionValidator.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-public interface ISelectionValidator {
- void isValid(Object[] selection, StatusInfo res);
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
deleted file mode 100644
index 9b88bd1..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/IStatusChangeListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-
-public interface IStatusChangeListener {
-
- /**
- * Called to announce that the given status has changed.
- */
- void statusChanged(IStatus status);
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
deleted file mode 100644
index 9b51869..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/MessageLine.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A message line. It distinguishes between "normal" messages and errors.
- * Setting an error message hides a currently displayed message until
- * clearErrorMessage is called.
- */
-public class MessageLine extends CLabel {
- private String fMessageText;
- private String fErrorText;
-
- private Color fDefaultColor;
- private RGB fErrorRGB;
- protected Color fErrorColor;
-
- private static RGB fgErrorRGB= new RGB(200, 0, 0);
-
- /**
- * Clears the currently displayed error message and redisplays
- * the message which was active before the error message was set.
- */
- public void clearErrorMessage() {
- setErrorMessage(null);
- }
- /**
- * Clears the currently displayed message.
- */
- public void clearMessage() {
- setMessage(null);
- }
- /**
- * Get the currently displayed error text.
- * @return The error message. If no error message is displayed null is returned.
- */
- public String getErrorMessage() {
- return fErrorText;
- }
- /**
- * Get the currently displayed message.
- * @return The message. If no message is displayed null is returned.
- */
- public String getMessage() {
- return fMessageText;
- }
- /**
- * Creates a new message line as a child of the parent and with the given SWT style bits.
- * Error message will be shown with in the given RGB color.
- */
- public MessageLine(Composite parent, int style, RGB errorRGB) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= errorRGB;
- }
- /**
- * Creates a new message line as a child of the parent and with the given SWT style bits.
- * Error message will be shown with in the RGB color 200,0,0.
- */
- public MessageLine(Composite parent, int style) {
- super(parent, style);
- fDefaultColor= getForeground();
- fErrorRGB= fgErrorRGB;
- }
- /**
- * Creates a new message line as a child of the given parent.
- * Error message will be shown with in the RGB color 200,0,0.
- */
- public MessageLine(Composite parent) {
- this(parent, SWT.LEFT);
- }
- /**
- * Sets the default error color used by all message lines.
- * Note: a call to this method only affects newly created MessageLines not existing ones.
- */
- public static void setErrorColor(RGB color) {
- fgErrorRGB= color;
- }
- /**
- * Display the given error message. A currently displayed message
- * is saved and will be redisplayed when the error message is cleared.
- */
- public void setErrorMessage(String message) {
- fErrorText= message;
-
- if (message == null) {
- setMessage(fMessageText);
- } else {
- if (fErrorColor == null) {
- fErrorColor= new Color(getDisplay(), fErrorRGB);
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fErrorColor.dispose();
- }
- });
- }
- setForeground(fErrorColor);
- setText(message);
- }
- }
- /**
- * Set the message text. If the message line currently displays an error,
- * the message is stored and will be shown after a call to clearErrorMessage
- */
- public void setMessage(String message) {
- fMessageText= message;
- if (message == null)
- message= ""; //$NON-NLS-1$
- if (fErrorText == null) {
- setForeground(fDefaultColor);
- setText(message);
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java
deleted file mode 100644
index 2c6fe84..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/OptionalMessageDialog.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.CUIMessages;
-
-/**
- * This is a MessageDialog which allows the user
- * to choose that the dialog isn't shown again the next time.
- */
-public class OptionalMessageDialog extends MessageDialog {
- // Dialog store id constants
- private static final String STORE_ID= "OptionalMessageDialog.hide."; //$NON-NLS-1$
- private static final String KEY_DETAIL = ".detail"; //$NON-NLS-1$
-
- public static final int NOT_SHOWN= IDialogConstants.CLIENT_ID + 1;
- public static final int NO_DETAIL= -1;
-
- private Button fHideDialogCheckBox;
- private String fId;
- private String fHideMessage;
-
- /**
- * Opens the dialog but only if the user hasn't chosen to hide it.
- * Returns NOT_SHOWN if the dialog was not shown.
- */
- public static int open(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
- if (!isDialogEnabled(id))
- return OptionalMessageDialog.NOT_SHOWN;
-
- MessageDialog dialog= new OptionalMessageDialog(id, parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
- return dialog.open();
- }
-
- protected OptionalMessageDialog(String id, Shell parent, String title, Image titleImage, String message, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
- super(parent, title, titleImage, message, dialogType, buttonLabels, defaultButtonIndex);
- fId= id;
- switch(dialogType) {
- case QUESTION:
- case QUESTION_WITH_CANCEL:
- fHideMessage= CUIMessages.OptionalMessageDialog_rememberDecision;
- break;
- default:
- fHideMessage= CUIMessages.OptionalMessageDialog_dontShowAgain;
- }
- }
-
- @Override
- protected Control createCustomArea(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
- layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
- layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fHideDialogCheckBox= new Button(composite, SWT.CHECK | SWT.LEFT);
- fHideDialogCheckBox.setText(fHideMessage);
- fHideDialogCheckBox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setDialogEnabled(fId, !((Button)e.widget).getSelection());
- }
- });
- applyDialogFont(fHideDialogCheckBox);
- return fHideDialogCheckBox;
- }
-
- //--------------- Configuration handling --------------
-
- /**
- * Returns this dialog
- *
- * @return the settings to be used
- */
- private static IDialogSettings getDialogSettings() {
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- settings= settings.getSection(STORE_ID);
- if (settings == null)
- settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
- return settings;
- }
-
- /**
- * Answers whether the optional dialog is enabled and should be shown.
- */
- public static boolean isDialogEnabled(String key) {
- IDialogSettings settings= getDialogSettings();
- return !settings.getBoolean(key);
- }
-
- /**
- * Sets a detail for the dialog.
- */
- public static void setDialogDetail(String key, int detail) {
- IDialogSettings settings= getDialogSettings();
- settings.put(key+KEY_DETAIL, detail);
- }
-
- /**
- * Returns the detail for this dialog, or NO_DETAIL, if none.
- */
- public static int getDialogDetail(String key) {
- IDialogSettings settings= getDialogSettings();
- try {
- return settings.getInt(key+KEY_DETAIL);
- } catch (NumberFormatException e) {
- return NO_DETAIL;
- }
- }
-
- /**
- * Sets whether the optional dialog is enabled and should be shown.
- */
- public static void setDialogEnabled(String key, boolean isEnabled) {
- IDialogSettings settings= getDialogSettings();
- settings.put(key, !isEnabled);
- }
-
- /**
- * Clears all remembered information about hidden dialogs
- */
- public static void clearAllRememberedStates() {
- IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings();
- settings.addNewSection(STORE_ID);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
deleted file mode 100644
index f2cbe9e..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionList.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-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.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.cdt.internal.ui.util.StringMatcher;
-import org.eclipse.cdt.internal.ui.util.TwoArrayQuickSort;
-
-/**
- * A selection widget that consists of a list and a text entry field. The list
- * of elements presented are limited to the pattern entered into the text entry
- * field.
- */
-public class SelectionList extends Composite {
-
- // State
- private Object[] fElements;
- protected ILabelProvider fRenderer;
- private boolean fIgnoreCase;
-
- // Implementation details
- private String[] fRenderedStrings;
- private int[] fFilteredElements;
- private String fRememberedMatchText;
-
- // SWT widgets
- private Table fList;
- private Text fText;
-
- /**
- * Adds a selection change listener to this widget.
- */
- public void addSelectionListener(SelectionListener listener) {
- fList.addSelectionListener(listener);
- }
- private void createList(int style) {
- fList= new Table(this, style);
- fList.setLayoutData(new GridData(GridData.FILL_BOTH));
- fList.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- fRenderer.dispose();
- }
- });
- }
- private void createText() {
- fText= new Text(this, SWT.BORDER);
- GridData spec= new GridData();
- spec.grabExcessVerticalSpace= false;
- spec.grabExcessHorizontalSpace= true;
- spec.horizontalAlignment= GridData.FILL;
- spec.verticalAlignment= GridData.BEGINNING;
- fText.setLayoutData(spec);
- Listener l= new Listener() {
- public void handleEvent(Event evt) {
- filter(false);
- }
- };
- fText.addListener(SWT.Modify, l);
- }
- /**
- * Filters the list of elements according to the pattern entered
- * into the text entry field.
- */
- public void filter(boolean forceUpdate) {
- int k= 0;
- String text= fText.getText();
- if (!forceUpdate && text.equals(fRememberedMatchText))
- return;
- fRememberedMatchText= text;
- StringMatcher matcher= new StringMatcher(text+"*", fIgnoreCase, false); //$NON-NLS-1$
- for (int i= 0; i < fElements.length; i++) {
- if (matcher.match(fRenderedStrings[i])) {
- fFilteredElements[k]= i;
- k++;
- }
- }
- fFilteredElements[k]= -1;
- updateListWidget(fFilteredElements, k);
- }
- /**
- * Returns the currently used filter text.
- */
- public String getFilter() {
- return fText.getText();
- }
- /**
- * Returns the selection indices.
- */
- public int[] getSelectionIndices() {
- return fList.getSelectionIndices();
- }
- /**
- * Returns a list of selected elements. Note that the type of the elements
- * returned in the list are the same as the ones passed to the selection list
- * via setElements. The list doesn't contain the rendered strings.
- */
- public List> getSelection() {
- if (fList == null || fList.isDisposed() || fList.getSelectionCount() == 0)
- return Collections.emptyList();
- int[] listSelection= fList.getSelectionIndices();
- List selected= new ArrayList(listSelection.length);
- for (int i= 0; i < listSelection.length; i++) {
- selected.add(fElements[fFilteredElements[listSelection[i]]]);
- }
- return selected;
- }
- /**
- * Returns true when the list of elements is empty.
- */
- public boolean isEmptyList() {
- return fElements == null || fElements.length == 0;
- }
- /**
- * Creates new instance of the widget.
- */
- public SelectionList(Composite parent, int style, ILabelProvider renderer, boolean ignoreCase) {
- super(parent, SWT.NONE);
- fRenderer= renderer;
- fIgnoreCase= ignoreCase;
- GridLayout layout= new GridLayout();
- layout.marginHeight= 0; layout.marginWidth= 0;
- //XXX: 1G9V58A: ITPUI:WIN2000 - Dialog.convert* methods should be static
- setLayout(layout);
- createText();
- createList(style);
- }
- /**
- * Removes a selection change listener to this widget.
- */
- public void removeSelectionListener(SelectionListener listener) {
- fList.removeSelectionListener(listener);
- }
- private String[] renderStrings() {
- String[] strings= new String[fElements.length];
- for (int i= 0; i < strings.length; i++) {
- strings[i]= fRenderer.getText(fElements[i]);
- }
- TwoArrayQuickSort.sort(strings, fElements, fIgnoreCase);
- return strings;
- }
- /**
- * Select the pattern text.
- */
- public void selectFilterText() {
- fText.selectAll();
- }
- /**
- * Sets the list of elements presented in the widget.
- */
- public void setElements(List> elements, boolean refilter) {
- // We copy the list since we sort it.
- if (elements == null)
- fElements= new Object[0];
- else
- fElements= elements.toArray();
- fFilteredElements= new int[fElements.length+1];
- fRenderedStrings= renderStrings();
- if (refilter)
- filter(true);
- }
- /*
- * Non Java-doc
- */
- @Override
- public void setEnabled(boolean enable) {
- super.setEnabled(enable);
- fText.setEnabled(enable);
- fList.setEnabled(enable);
- }
- /**
- * Sets the filter pattern. Current only prefix filter pattern are supported.
- */
- public void setFilter(String pattern, boolean refilter) {
- fText.setText(pattern);
- if (refilter)
- filter(true);
- }
- /*
- * Non Java-doc
- */
- @Override
- public boolean setFocus() {
- return fText.setFocus();
- }
- /*
- * Non Java-doc
- */
- @Override
- public void setFont(Font font) {
- super.setFont(font);
- fText.setFont(font);
- fList.setFont(font);
- }
- /**
- * Selects the elements in the list determined by the given
- * selection indices.
- */
- protected void setSelection(int[] selection) {
- fList.setSelection(selection);
- }
- private void updateListWidget(int[] indices, int size) {
- if (fList == null || fList.isDisposed())
- return;
- fList.setRedraw(false);
- int itemCount= fList.getItemCount();
- if (size < itemCount) {
- fList.remove(0, itemCount-size-1);
- }
-
- TableItem[] items= fList.getItems();
- for (int i= 0; i < size; i++) {
- TableItem ti= null;
- if (i < itemCount) {
- ti= items[i];
- } else {
- ti= new TableItem(fList, i);
- }
- ti.setText(fRenderedStrings[indices[i]]);
- Image img= fRenderer.getImage(fElements[indices[i]]);
- if (img != null)
- ti.setImage(img);
- }
- if (fList.getItemCount() > 0) {
- fList.setSelection(0);
- }
-
- fList.setRedraw(true);
- Event event= new Event();
- fList.notifyListeners(SWT.Selection, event);
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
deleted file mode 100644
index 4683df3..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/SelectionStatusDialog.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-/**
- * An abstract base class for dialogs with a status bar and ok/cancel buttons.
- * The status message must be passed over as StatusInfo object and can be
- * an error, warning or ok. The OK button is enabled / disabled depending
- * on the status.
- */
-public abstract class SelectionStatusDialog extends SelectionDialog {
-
- private MessageLine fStatusLine;
- private IStatus fLastStatus;
- private Image fImage;
- private boolean fInitialSelectionSet;
- private boolean fStatusLineAboveButtons= false;
-
-
- /**
- * Compute the result and return it.
- */
- protected abstract void computeResult();
- /* (non-Javadoc)
- * Method declared in Window.
- */
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if (fImage != null)
- shell.setImage(fImage);
- }
- /* (non-Javadoc)
- * Method declared in Dialog.
- */
- @Override
- protected Control createButtonBar(Composite parent) {
- Composite composite= new Composite(parent, SWT.NULL);
- GridLayout layout= new GridLayout();
- if (fStatusLineAboveButtons) {
- layout.verticalSpacing= 0;
- } else {
- layout.numColumns= 2;
- }
- layout.marginHeight= 0; layout.marginWidth= 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- fStatusLine= new MessageLine(composite);
- fStatusLine.setAlignment(SWT.LEFT);
- fStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fStatusLine.setMessage(""); //$NON-NLS-1$
-
- super.createButtonBar(composite);
- return composite;
- }
- /* (non-Javadoc)
- * Method declared in Dialog.
- */
- @Override
- public void create() {
- super.create();
- if (fLastStatus != null) {
- updateStatus(fLastStatus);
- }
- }
- /**
- * Returns the first element of the initial selection or null
- * if there isn't any initial selection.
- * @return the first element of the initial selection.
- */
- protected Object getPrimaryInitialSelection() {
- List> result= getInitialElementSelections();
- if (result == null || result.size() == 0)
- return null;
- return result.get(0);
- }
- /**
- * Returns the first element from the list of results. Returns null
- * if no element has been selected.
- *
- * @return the first result element if one exists. Otherwise null is
- * returned.
- */
- public Object getPrimaryResult() {
- Object[] result= getResult();
- if (result == null || result.length == 0)
- return null;
- return result[0];
- }
- public SelectionStatusDialog(Shell parent) {
- super(parent);
- fInitialSelectionSet= false;
- }
- /* (non-Javadoc)
- * Method declared in Dialog.
- */
- @Override
- protected void okPressed() {
- computeResult();
- super.okPressed();
- }
- /**
- * Sets the image for this dialog.
- *
- * @param image the dialog's image
- */
- public void setImage(Image image) {
- fImage= image;
- }
- protected void setInitialSelection(int position, Object element) {
- @SuppressWarnings("unchecked")
- List l= getInitialElementSelections();
- l.set(position, element);
- fInitialSelectionSet= true;
- }
- /**
- * Sets the initial selection to the given element.
- */
- public void setInitialSelection(Object element) {
- // Allow clients to use set their own initial selection(s)
- if (fInitialSelectionSet && element != null && element.equals("A")) //$NON-NLS-1$
- return;
-
- if (element != null) {
- setInitialSelections(new Object[] { element });
- } else {
- setInitialSelections(new Object[0]);
- }
- }
- @Override
- public void setInitialSelections(Object[] selectedElements) {
- super.setInitialSelections(selectedElements);
- fInitialSelectionSet= true;
- }
- /**
- * Sets a result element at the given position.
- */
- protected void setResult(int position, Object element) {
- Object[] result= getResult();
- result[position]= element;
- setResult(Arrays.asList(result));
- }
- /**
- * Controls whether status line appears to the left of the buttons (default)
- * or above them.
- *
- * @param aboveButtons if true status line is placed above buttons; if
- * false to the right
- */
- public void setStatusLineAboveButtons(boolean aboveButtons) {
- fStatusLineAboveButtons= aboveButtons;
- }
- /**
- * Update the status of the ok button to reflect the given status. Subclasses
- * may override this method to update additional buttons.
- */
- protected void updateButtonsEnableState(IStatus status) {
- Button okButton= getOkButton();
- if (okButton != null && !okButton.isDisposed())
- okButton.setEnabled(!status.matches(IStatus.ERROR));
- }
- /**
- * Update the dialog's status line to reflect the given status. It is safe to call
- * this method before the dialog has been opened.
- */
- protected void updateStatus(IStatus status) {
- fLastStatus= status;
- if (fStatusLine != null && !fStatusLine.isDisposed()) {
- updateButtonsEnableState(status);
- StatusTool.applyToStatusLine(fStatusLine, status);
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java
deleted file mode 100644
index 1f42b00..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusDialog.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * @deprecated. This class is deprecated since CDT 6.1. Use {@link org.eclipse.jface.dialogs.StatusDialog} instead.
- *
- * An abstract base class for dialogs with a status bar and ok/cancel buttons.
- * The status message must be passed over as StatusInfo object and can be
- * an error, warning or ok. The OK button is enabled or disabled depending
- * on the status.
- */
-@Deprecated
-public abstract class StatusDialog extends org.eclipse.jface.dialogs.StatusDialog {
- public StatusDialog(Shell parent) {
- super(parent);
- setHelpAvailable(false);
- }
-}
-
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
deleted file mode 100644
index 9a92cbd..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusInfo.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software System
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * A settable IStatus
- * Can be an error, warning, info or ok. For error, info and warning states,
- * a message describes the problem
- */
-public class StatusInfo implements IStatus {
-
- public static final IStatus OK_STATUS= new StatusInfo();
-
- private String fStatusMessage;
- private int fSeverity;
-
- /**
- * Creates a status set to OK (no message)
- */
- public StatusInfo() {
- this(OK, null);
- }
-
- /**
- * Creates a status.
- * @param severity The status severity: ERROR, WARNING, INFO and OK.
- * @param message The message of the status. Applies only for ERROR,
- * WARNING and INFO.
- */
- public StatusInfo(int severity, String message) {
- fStatusMessage= message;
- fSeverity= severity;
- }
-
- /**
- * @see IStatus#getChildren()
- */
- public IStatus[] getChildren() {
- return new IStatus[0];
- }
- /**
- * @see IStatus#getCode()
- */
- public int getCode() {
- return fSeverity;
- }
- /**
- * @see IStatus#getException()
- */
- public Throwable getException() {
- return null;
- }
- /**
- * @see IStatus#getMessage
- */
- public String getMessage() {
- return fStatusMessage;
- }
- /**
- * @see IStatus#getPlugin()
- */
- public String getPlugin() {
- return CUIPlugin.PLUGIN_ID;
- }
- /**
- * @see IStatus#getSeverity()
- */
- public int getSeverity() {
- return fSeverity;
- }
- public boolean isError() {
- return fSeverity == IStatus.ERROR;
- }
- public boolean isInfo() {
- return fSeverity == IStatus.INFO;
- }
- /**
- * @see IStatus#isMultiStatus()
- */
- public boolean isMultiStatus() {
- return false;
- }
- public boolean isOK() {
- return fSeverity == IStatus.OK;
- }
- public boolean isWarning() {
- return fSeverity == IStatus.WARNING;
- }
- /**
- * @see IStatus#matches(int)
- */
- public boolean matches(int severityMask) {
- return (fSeverity & severityMask) != 0;
- }
- public void setError(String errorMessage) {
- fStatusMessage= errorMessage;
- fSeverity= IStatus.ERROR;
- }
- public void setInfo(String infoMessage) {
- fStatusMessage= infoMessage;
- fSeverity= IStatus.INFO;
- }
- public void setOK() {
- fStatusMessage= null;
- fSeverity= IStatus.OK;
- }
- public void setWarning(String warningMessage) {
- fStatusMessage= warningMessage;
- fSeverity= IStatus.WARNING;
- }
-
- /**
- * Returns a string representation of the status, suitable
- * for debugging purposes only.
- */
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("StatusInfo "); //$NON-NLS-1$
- if (fSeverity == OK) {
- buf.append("OK"); //$NON-NLS-1$
- } else if (fSeverity == ERROR) {
- buf.append("ERROR"); //$NON-NLS-1$
- } else if (fSeverity == WARNING) {
- buf.append("WARNING"); //$NON-NLS-1$
- } else if (fSeverity == INFO) {
- buf.append("INFO"); //$NON-NLS-1$
- } else {
- buf.append("severity="); //$NON-NLS-1$
- buf.append(fSeverity);
- }
- buf.append(": "); //$NON-NLS-1$
- buf.append(fStatusMessage);
- return buf.toString();
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
deleted file mode 100644
index 32e9036..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusTool.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jface.dialogs.DialogPage;
-
-public class StatusTool {
- /**
- * Applies the status to the status line of a dialog page
- */
- public static void applyToStatusLine(MessageLine messageLine, IStatus status) {
- String[] messages= getErrorMessages(status);
- messageLine.setErrorMessage(messages[0]);
- messageLine.setMessage(messages[1]);
- }
-
- /**
- * Applies the status to the status line of a dialog page
- */
- public static void applyToStatusLine(DialogPage page, IStatus status) {
- String[] messages= getErrorMessages(status);
- page.setErrorMessage(messages[0]);
- page.setMessage(messages[1]);
- }
-
- /**
- * Returns error-message / warning-message for a status
- */
- public static String[] getErrorMessages(IStatus status) {
- String message= status.getMessage();
- if (status.matches(IStatus.ERROR) && !"".equals(message)) { //$NON-NLS-1$
- return new String[] { message, null };
- } else if (status.matches(IStatus.WARNING | IStatus.INFO)) {
- return new String[] { null, message };
- } else {
- return new String[] { null, null };
- }
- }
-
- /**
- * Compare two IStatus. The more severe is returned:
- * An error is more severe than a warning, and a warning is more severe
- * than ok.
- */
- public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
- if (s1.getSeverity() > s2.getSeverity()) {
- return s1;
- }
- return s2;
- }
-
- /**
- * Finds the most severe status from a array of status
- * An error is more severe than a warning, and a warning is more severe
- * than ok.
- */
- public static IStatus getMostSevere(IStatus[] status) {
- IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
- if (curr.matches(IStatus.ERROR)) {
- return curr;
- }
- if (max == null || curr.getSeverity() > max.getSeverity()) {
- max= curr;
- }
- }
- return max;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
deleted file mode 100644
index 4b5e291..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/StatusUtil.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IMessageProvider;
-
-/**
- * A utility class to work with IStatus.
- */
-public class StatusUtil {
- /**
- * Compares two instances of IStatus. The more severe is returned:
- * An error is more severe than a warning, and a warning is more severe
- * than ok. If the two statuses have the same severity, the second is returned.
- */
- public static IStatus getMoreSevere(IStatus s1, IStatus s2) {
- if (s1.getSeverity() > s2.getSeverity()) {
- return s1;
- }
- return s2;
- }
-
- /**
- * Finds the most severe status from a array of statuses.
- * An error is more severe than a warning, and a warning is more severe
- * than ok.
- */
- public static IStatus getMostSevere(IStatus[] status) {
- IStatus max= null;
- for (int i= 0; i < status.length; i++) {
- IStatus curr= status[i];
- if (curr.matches(IStatus.ERROR)) {
- return curr;
- }
- if (max == null || curr.getSeverity() > max.getSeverity()) {
- max= curr;
- }
- }
- return max;
- }
-
- /**
- * Applies the status to the status line of a dialog page.
- */
- public static void applyToStatusLine(DialogPage page, IStatus status) {
- String message= status.getMessage();
- switch (status.getSeverity()) {
- case IStatus.OK:
- page.setMessage(message, IMessageProvider.NONE);
- page.setErrorMessage(null);
- break;
- case IStatus.WARNING:
- page.setMessage(message, IMessageProvider.WARNING);
- page.setErrorMessage(null);
- break;
- case IStatus.INFO:
- page.setMessage(message, IMessageProvider.INFORMATION);
- page.setErrorMessage(null);
- break;
- default:
- if (message.length() == 0) {
- message= null;
- }
- page.setMessage(null);
- page.setErrorMessage(message);
- break;
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java
deleted file mode 100644
index fdb6e2c..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedElementSelectionValidator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import java.util.Collection;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-
-
-/**
- * Implementation of a ISelectionValidator to validate the
- * type of an element.
- * Empty selections are not accepted.
- */
-public class TypedElementSelectionValidator implements ISelectionStatusValidator {
-
- private IStatus fgErrorStatus= new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
- private IStatus fgOKStatus= new StatusInfo();
-
- private Class>[] fAcceptedTypes;
- private boolean fAllowMultipleSelection;
- private Collection> fRejectedElements;
-
- /**
- * @param acceptedTypes The types accepted by the validator
- * @param allowMultipleSelection If set to true, the validator
- * allows multiple selection.
- */
- public TypedElementSelectionValidator(Class>[] acceptedTypes, boolean allowMultipleSelection) {
- this(acceptedTypes, allowMultipleSelection, null);
- }
-
- /**
- * @param acceptedTypes The types accepted by the validator
- * @param allowMultipleSelection If set to true, the validator
- * allows multiple selection.
- * @param rejectedElements A list of elements that are not accepted
- */
- public TypedElementSelectionValidator(Class>[] acceptedTypes, boolean allowMultipleSelection, Collection rejectedElements) {
- Assert.isNotNull(acceptedTypes);
- fAcceptedTypes= acceptedTypes;
- fAllowMultipleSelection= allowMultipleSelection;
- fRejectedElements= rejectedElements;
- }
-
- /*
- * @see org.eclipse.ui.dialogs.ISelectionValidator#isValid(java.lang.Object)
- */
- public IStatus validate(Object[] elements) {
- if (isValid(elements)) {
- return fgOKStatus;
- }
- return fgErrorStatus;
- }
-
- private boolean isOfAcceptedType(Object o) {
- for (int i= 0; i < fAcceptedTypes.length; i++) {
- if (fAcceptedTypes[i].isInstance(o)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isRejectedElement(Object elem) {
- return (fRejectedElements != null) && fRejectedElements.contains(elem);
- }
-
- private boolean isValid(Object[] selection) {
- if (selection.length == 0) {
- return false;
- }
-
- if (!fAllowMultipleSelection && selection.length != 1) {
- return false;
- }
-
- for (int i= 0; i < selection.length; i++) {
- Object o= selection[i];
- if (!isOfAcceptedType(o) || isRejectedElement(o)) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java
deleted file mode 100644
index 4c2e850..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/TypedViewerFilter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-/**
- * Viewer filter used in selection dialogs.
- */
-public class TypedViewerFilter extends ViewerFilter {
-
- private Class>[] fAcceptedTypes;
- private Object[] fRejectedElements;
-
- /**
- * Creates a filter that only allows elements of gives types.
- * @param acceptedTypes The types of accepted elements
- */
- public TypedViewerFilter(Class>[] acceptedTypes) {
- this(acceptedTypes, null);
- }
-
- /**
- * Creates a filter that only allows elements of gives types, but not from a
- * list of rejected elements.
- * @param acceptedTypes Accepted elements must be of this types
- * @param rejectedElements Element equals to the rejected elements are
- * filtered out
- */
- public TypedViewerFilter(Class>[] acceptedTypes, Object[] rejectedElements) {
- Assert.isNotNull(acceptedTypes);
- fAcceptedTypes= acceptedTypes;
- fRejectedElements= rejectedElements;
- }
-
- /**
- * @see ViewerFilter#select
- */
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (fRejectedElements != null) {
- for (int i= 0; i < fRejectedElements.length; i++) {
- if (element.equals(fRejectedElements[i])) {
- return false;
- }
- }
- }
- for (int i= 0; i < fAcceptedTypes.length; i++) {
- if (fAcceptedTypes[i].isInstance(element)) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
deleted file mode 100644
index 35ffc65..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-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.ICModelStatus;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
-import org.eclipse.cdt.ui.dialogs.ICOptionPage;
-import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
-
-import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
-import org.eclipse.cdt.internal.ui.util.CoreUtility;
-
-/**
- * Abstract block for C/C++ Project Paths page for 3.X projects.
- *
- * @deprecated as of CDT 4.0. This option block was used to set preferences/properties
- * for 3.X style projects.
- */
-@Deprecated
-abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock implements ICOptionContainer {
-
- private StatusInfo fCPathStatus;
- private StatusInfo fBuildPathStatus;
-
- private ICElement fCurrCElement;
-
- private String fUserSettingsTimeStamp;
- private long fFileTimeStamp;
-
- private int fPageIndex, fPageCount;
- private CPathBasePage fCurrPage;
-
- private IStatusChangeListener fContext;
-
- public AbstractPathOptionBlock(IStatusChangeListener context, int pageToShow) {
- super(false);
-
- fContext = context;
- fPageIndex = pageToShow;
-
- fCPathStatus = new StatusInfo();
- fBuildPathStatus = new StatusInfo();
-
- setOptionContainer(this);
- }
-
- // -------- public api --------
-
- /**
- * @return Returns the current class path (raw). Note that the entries
- * returned must not be valid.
- */
- public IPathEntry[] getRawCPath() throws CModelException{
- List elements = getCPaths();
-
- IPathEntry[] entries = getCProject().getRawPathEntries();
- List cpath = new ArrayList(elements.size() + entries.length);
-
- int[] applyTypes = getAppliedFilteredTypes();
- // create and set the paths
- for (int i = 0; i < elements.size(); i++) {
- CPElement entry = (elements.get(i));
- for (int applyType : applyTypes) {
- if (entry.getEntryKind() == applyType) {
- cpath.add(entry.getPathEntry());
- break;
- }
- }
- }
-
- // add entries which do not match type being applyed by the ui block
- for (IPathEntry entrie : entries) {
- int pathType = entrie.getEntryKind();
- boolean found = false;
- for (int applyType : applyTypes) {
- if (pathType == applyType) {
- found = true;
- break;
- }
- }
- if (!found) {
- cpath.add(entrie);
- }
- }
-
- return cpath.toArray(new IPathEntry[cpath.size()]);
- }
-
- /**
- * Initializes the paths for the given project. Multiple calls to init are
- * allowed, but all existing settings will be cleared and replace by the
- * given or default paths.
- *
- * @param element
- * The C/C++ project to configure. Does not have to exist.
- * @param cpathEntries
- * The path entries to be set in the page. If null is
- * passed, jdt default settings are used, or - if the project is an
- * existing Java project - the path entries of the existing project
- */
- public void init(ICElement element, IPathEntry[] cpathEntries) {
- setCElement(element);
- List newCPath = null;
-
- if (cpathEntries == null) {
- try {
- cpathEntries = getCProject().getRawPathEntries();
- } catch (CModelException e) {
- }
-
- }
- if (cpathEntries != null) {
- newCPath = getFilteredElements(cpathEntries, getFilteredTypes());
- } else {
- newCPath = new ArrayList();
- }
- initialize(element, newCPath);
- }
-
- abstract protected int[] getFilteredTypes(); // path type which block would like access to
- abstract protected int[] getAppliedFilteredTypes(); // path type which block modifies
-
- abstract protected void initialize(ICElement element, List cPaths);
-
- protected ArrayList getFilteredElements(IPathEntry[] cPathEntries, int[] types) {
- ArrayList newCPath = new ArrayList();
- for (IPathEntry curr : cPathEntries) {
- if (contains(types, curr.getEntryKind())) {
- newCPath.add(CPElement.createFromExisting(curr, getCElement()));
- }
- }
- return newCPath;
- }
-
- // returns true if set contains elem
- private boolean contains(int[] set, int elem) {
- if (set == null)
- return false;
- for (int i = 0; i < set.length; ++i) {
- if (set[i] == elem)
- return true;
- }
- return false;
- }
-
- abstract protected List getCPaths();
-
- private String getEncodedSettings() {
- StringBuffer buf = new StringBuffer();
-
- List elements = getCPaths();
- int nElements = elements.size();
- buf.append('[').append(nElements).append(']');
- for (int i = 0; i < nElements; i++) {
- CPElement elem = elements.get(i);
- elem.appendEncodedSettings(buf);
- }
- return buf.toString();
- }
-
- public boolean hasChangesInDialog() {
- String currSettings = getEncodedSettings();
- return !currSettings.equals(fUserSettingsTimeStamp);
- }
-
- public boolean hasChangesInCPathFile() {
- IFile file = getProject().getFile(".cdtproject"); //$NON-NLS-1$
- return fFileTimeStamp != file.getModificationStamp();
- }
-
- public void initializeTimeStamps() {
- IFile file = getProject().getFile(".cdtproject"); //$NON-NLS-1$
- fFileTimeStamp = file.getModificationStamp();
- fUserSettingsTimeStamp = getEncodedSettings();
- }
-
- @Override
- abstract protected void addTabs();
-
- protected void setCElement(ICElement element) {
- fCurrCElement = element;
- }
-
- protected ICElement getCElement() {
- return fCurrCElement;
- }
-
- protected ICProject getCProject() {
- return fCurrCElement.getCProject();
- }
-
- public IProject getProject() {
- return getCProject().getProject();
- }
-
- protected void doStatusLineUpdate() {
- IStatus res = findMostSevereStatus();
- fContext.statusChanged(res);
- }
-
- private IStatus findMostSevereStatus() {
- return StatusUtil.getMostSevere(new IStatus[] { fCPathStatus, fBuildPathStatus});
- }
-
- protected StatusInfo getPathStatus() {
- return fCPathStatus;
- }
-
- // -------- tab switching ----------
-
- @Override
- public void setCurrentPage(ICOptionPage page) {
- super.setCurrentPage(page);
- CPathBasePage newPage = (CPathBasePage) page;
- if (fCurrPage != null) {
- List> selection = fCurrPage.getSelection();
- if (!selection.isEmpty()) {
- newPage.setSelection(selection);
- }
- }
- fCurrPage = (CPathBasePage) page;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#updateContainer()
- */
- public void updateContainer() {
- update();
- }
-
- protected void updateBuildPathStatus() {
- List elements = getCPaths();
- IPathEntry[] entries = new IPathEntry[elements.size()];
-
- for (int i = elements.size() - 1; i >= 0; i--) {
- CPElement currElement = elements.get(i);
- entries[i] = currElement.getPathEntry();
- }
-
- ICModelStatus status = CoreModel.validatePathEntries(getCProject(), entries);
- if (!status.isOK()) {
- fBuildPathStatus.setError(status.getMessage());
- return;
- }
- fBuildPathStatus.setOK();
- }
-
- public Preferences getPreferences() {
- return null;
- }
-
- protected void addPage(CPathBasePage page) {
- addTab(page);
- if (fPageIndex == fPageCount) {
- fCurrPage = page;
- }
- fPageCount++;
- }
-
- @Override
- protected ICOptionPage getStartPage() {
- if (fCurrPage == null) {
- return super.getStartPage();
- }
- return fCurrPage;
- }
-
- protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException,
- InterruptedException {
- // 10 monitor steps to go
-
- monitor.worked(2);
-
- IPathEntry[] entries = getCProject().getRawPathEntries();
-
- List cpath = new ArrayList(cPathEntries.size() + entries.length);
-
- int[] applyTypes = getAppliedFilteredTypes();
- // create and set the paths
- for (int i = 0; i < cPathEntries.size(); i++) {
- CPElement entry = (cPathEntries.get(i));
- for (int applyType : applyTypes) {
- if (entry.getEntryKind() == applyType) {
- IResource res = entry.getResource();
- if ((res instanceof IFolder) && !res.exists()) {
- CoreUtility.createFolder((IFolder) res, true, true, null);
- }
- cpath.add(entry.getPathEntry());
- break;
- }
- }
- }
-
- // add entries which do not match type being applyed by the ui block
- for (IPathEntry entrie : entries) {
- int pathType = entrie.getEntryKind();
- boolean found = false;
- for (int applyType : applyTypes) {
- if (pathType == applyType) {
- found = true;
- break;
- }
- }
- if (!found) {
- cpath.add(entrie);
- }
- }
- monitor.worked(1);
-
- getCProject().setRawPathEntries(cpath.toArray(new IPathEntry[cpath.size()]),
- new SubProgressMonitor(monitor, 7));
- }
-
- // -------- creation -------------------------------
-
- public void configureCProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
- monitor.setTaskName(CPathEntryMessages.CPathsBlock_operationdesc_c);
- monitor.beginTask("", 10); //$NON-NLS-1$
-
- try {
- internalConfigureCProject(getCPaths(), monitor);
- initializeTimeStamps();
- } finally {
- monitor.done();
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java
deleted file mode 100644
index f324ce7..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ArchiveFileFilter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-/**
- * Viewer filter for archive selection dialogs.
- * Archives are files with file extension "a", "dll", "so.
- * The filter is not case sensitive.
- *
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-public class ArchiveFileFilter extends ViewerFilter {
-
- private static final String[] fgArchiveExtensions= { "a", "so", "dll" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- private List fExcludes;
- private boolean fRecursive;
-
- /**
- * @param excludedFiles Excluded files will not pass the filter.
- * null is allowed if no files should be excluded.
- * @param recusive Folders are only shown if, searched recursivly, contain
- * an archive
- */
- public ArchiveFileFilter(IFile[] excludedFiles, boolean recusive) {
- if (excludedFiles != null) {
- fExcludes= Arrays.asList(excludedFiles);
- } else {
- fExcludes= null;
- }
- fRecursive= recusive;
- }
-
- /*
- * @see ViewerFilter#select
- */
- @Override
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof IFile) {
- if (fExcludes != null && fExcludes.contains(element)) {
- return false;
- }
- return isArchivePath(((IFile)element).getFullPath());
- } else if (element instanceof IContainer) { // IProject, IFolder
- if (!fRecursive) {
- return true;
- }
- try {
- IResource[] resources= ((IContainer)element).members();
- for (int i= 0; i < resources.length; i++) {
- // recursive! Only show containers that contain an archive
- if (select(viewer, parent, resources[i])) {
- return true;
- }
- }
- } catch (CoreException e) {
- CUIPlugin.log(e.getStatus());
- }
- }
- return false;
- }
-
- public static boolean isArchivePath(IPath path) {
- String ext= path.getFileExtension();
- if (ext != null && ext.length() != 0) {
- return isArchiveFileExtension(ext);
- }
- return false;
- }
-
- public static boolean isArchiveFileExtension(String ext) {
- for (int i= 0; i < fgArchiveExtensions.length; i++) {
- if (ext.equalsIgnoreCase(fgArchiveExtensions[i])) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java
deleted file mode 100644
index 0f8157a..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElement.java
+++ /dev/null
@@ -1,794 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-
-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.IIncludeEntry;
-import org.eclipse.cdt.core.model.IIncludeFileEntry;
-import org.eclipse.cdt.core.model.ILibraryEntry;
-import org.eclipse.cdt.core.model.IMacroEntry;
-import org.eclipse.cdt.core.model.IMacroFileEntry;
-import org.eclipse.cdt.core.model.IOutputEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.core.model.IPathEntryContainerExtension;
-import org.eclipse.cdt.core.model.ISourceEntry;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-/**
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-public class CPElement {
- public static final String SOURCEATTACHMENT = "sourcepath"; //$NON-NLS-1$
- public static final String SOURCEATTACHMENTROOT = "rootpath"; //$NON-NLS-1$
- public static final String EXCLUSION = "exclusion"; //$NON-NLS-1$
- public static final String INCLUDE = "includepath"; //$NON-NLS-1$
- public static final String LIBRARY = "librarypath"; //$NON-NLS-1$
- public static final String SYSTEM_INCLUDE = "systeminclude"; //$NON-NLS-1$
- public static final String MACRO_NAME = "macroname"; //$NON-NLS-1$
- public static final String MACRO_VALUE = "macrovalue"; //$NON-NLS-1$
- public static final String BASE_REF = "base-ref"; //$NON-NLS-1$
- public static final String BASE = "base-path"; //$NON-NLS-1$
- public static final String PARENT = "parent"; //$NON-NLS-1$
- public static final String PARENT_CONTAINER = "parent-container"; //$NON-NLS-1$
- public static final String INCLUDE_FILE = "includefile"; //$NON-NLS-1$
- public static final String MACROS_FILE = "macrosfile"; //$NON-NLS-1$
-
- private final int fEntryKind;
- private final IPath fPath;
- private final ICProject fCProject;
- private final IResource fResource;
- private final ArrayList fChildren = new ArrayList(1);
-
- private boolean fIsExported;
-
- private IPathEntry fCachedEntry;
- private CPElement Inherited; // used when the path is duplicated on a child
- // resource but is inherited from a parent
- // resource these are not real path entries
-
- private IStatus fStatus;
-
- // create a inherited element and apply to path/resource
- public CPElement(CPElement element, IPath path, IResource res) {
- this(element.getCProject(), element.getEntryKind(), path, res);
- setExported(element.isExported());
- fChildren.clear();
- for(int i = 0; i < element.fChildren.size(); i++) {
- CPElementAttribute attrib = (CPElementAttribute)element.fChildren.get(i);
- fChildren.add(new CPElementAttribute(this, attrib.getKey(), attrib.getValue()));
- }
- Inherited = element;
- }
-
- public CPElement(ICProject project, int entryKind, IPath path, IResource res) {
- fCProject = project;
- fEntryKind = entryKind;
- fPath = path;
- fResource = res;
-
- fIsExported = false;
- fCachedEntry = null;
-
- switch (entryKind) {
- case IPathEntry.CDT_OUTPUT:
- createAttributeElement(EXCLUSION, new Path[0]);
- break;
- case IPathEntry.CDT_SOURCE:
- createAttributeElement(EXCLUSION, new Path[0]);
- break;
- case IPathEntry.CDT_LIBRARY:
- createAttributeElement(LIBRARY, new Path("")); //$NON-NLS-1$
- createAttributeElement(SOURCEATTACHMENT, null);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_INCLUDE:
- createAttributeElement(INCLUDE, new Path("")); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(SYSTEM_INCLUDE, Boolean.valueOf(true));
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- createAttributeElement(INCLUDE_FILE, new Path("")); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_MACRO:
- createAttributeElement(MACRO_NAME, ""); //$NON-NLS-1$
- createAttributeElement(MACRO_VALUE, ""); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_MACRO_FILE:
- createAttributeElement(MACROS_FILE, new Path("")); //$NON-NLS-1$
- createAttributeElement(EXCLUSION, new Path[0]);
- createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
- createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
- break;
- case IPathEntry.CDT_CONTAINER:
- try {
- IPathEntryContainer container = CoreModel.getPathEntryContainer(fPath, fCProject);
- if (container != null) {
- IPathEntry[] entries = null;
- if (container instanceof IPathEntryContainerExtension &&
- res instanceof IFile) {
- IPathEntryContainerExtension extContainer = (IPathEntryContainerExtension) container;
- entries = extContainer.getPathEntries(res.getFullPath(),
- IPathEntry.CDT_INCLUDE | IPathEntry.CDT_MACRO |
- IPathEntry.CDT_INCLUDE_FILE | IPathEntry.CDT_MACRO_FILE);
- } else {
- entries = container.getPathEntries();
- }
- for (IPathEntry entrie : entries) {
- CPElement curr = createFromExisting(entrie, fCProject);
- curr.createAttributeElement(PARENT_CONTAINER, this);
- CPElementGroup group = new CPElementGroup(this, curr.getEntryKind());
- int indx = fChildren.indexOf(group);
- if (indx == -1) {
- fChildren.add(group);
- } else {
- group = (CPElementGroup)fChildren.get(indx);
- }
- group.addChild(curr);
- }
- }
- } catch (CModelException e) {
- }
- break;
- default:
- break;
- }
- }
-
- public IPathEntry getPathEntry() {
- if (Inherited != null) {
- return null;
- }
- if (fCachedEntry == null) {
- fCachedEntry = newPathEntry();
- }
- return fCachedEntry;
- }
-
- private IPathEntry newPathEntry() {
- IPath[] exclusionPattern = (IPath[])getAttribute(EXCLUSION);
- IPath base = (IPath)getAttribute(BASE);
- IPath baseRef = (IPath)getAttribute(BASE_REF);
- switch (fEntryKind) {
- case IPathEntry.CDT_OUTPUT:
- return CoreModel.newOutputEntry(fPath, exclusionPattern);
- case IPathEntry.CDT_SOURCE:
- return CoreModel.newSourceEntry(fPath, exclusionPattern);
- case IPathEntry.CDT_LIBRARY:
- IPath libraryPath = (IPath)getAttribute(LIBRARY);
- IPath attach = (IPath)getAttribute(SOURCEATTACHMENT);
- if (!baseRef.isEmpty()) {
- return CoreModel.newLibraryRefEntry(fPath, baseRef, libraryPath);
- }
- return CoreModel.newLibraryEntry(fPath, base, libraryPath, attach, null, null, isExported());
- case IPathEntry.CDT_PROJECT:
- return CoreModel.newProjectEntry(fPath, isExported());
- case IPathEntry.CDT_CONTAINER:
- return CoreModel.newContainerEntry(fPath, isExported());
- case IPathEntry.CDT_INCLUDE:
- IPath include = (IPath)getAttribute(INCLUDE);
- if (!baseRef.isEmpty()) {
- return CoreModel.newIncludeRefEntry(fPath, baseRef, include);
- }
- return CoreModel.newIncludeEntry(fPath, base, include, ((Boolean)getAttribute(SYSTEM_INCLUDE)).booleanValue(),
- exclusionPattern, isExported());
- case IPathEntry.CDT_INCLUDE_FILE:
- IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
- return CoreModel.newIncludeFileEntry(fPath, baseRef, base, includeFile,
- exclusionPattern, isExported());
- case IPathEntry.CDT_MACRO:
- String macroName = (String)getAttribute(MACRO_NAME);
- String macroValue = (String)getAttribute(MACRO_VALUE);
- if (!baseRef.isEmpty()) {
- return CoreModel.newMacroRefEntry(fPath, baseRef, macroName);
- }
- return CoreModel.newMacroEntry(fPath, macroName, macroValue, exclusionPattern, isExported());
- case IPathEntry.CDT_MACRO_FILE:
- IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
- return CoreModel.newMacroFileEntry(fPath, baseRef, base, macrosFile,
- exclusionPattern, isExported());
- default:
- return null;
- }
- }
-
- public static StringBuffer appendEncodePath(IPath path, StringBuffer buf) {
- if (path != null) {
- String str = path.toString();
- buf.append('[').append(str.length()).append(']').append(str);
- } else {
- buf.append('[').append(']');
- }
- return buf.append(';');
- }
-
- public StringBuffer appendEncodedSettings(StringBuffer buf) {
- buf.append(fEntryKind).append(';');
- appendEncodePath(fPath, buf).append(';');
- buf.append(Boolean.valueOf(fIsExported)).append(';');
- switch (fEntryKind) {
- case IPathEntry.CDT_OUTPUT:
- case IPathEntry.CDT_SOURCE:
- case IPathEntry.CDT_INCLUDE:
- case IPathEntry.CDT_INCLUDE_FILE:
- case IPathEntry.CDT_MACRO:
- case IPathEntry.CDT_MACRO_FILE:
- IPath[] exclusion = (IPath[])getAttribute(EXCLUSION);
- buf.append('[').append(exclusion.length).append(']');
- for (IPath element : exclusion) {
- appendEncodePath(element, buf);
- }
- switch (fEntryKind) {
- case IPathEntry.CDT_INCLUDE:
- IPath baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- IPath base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- IPath include = (IPath)getAttribute(INCLUDE);
- appendEncodePath(include, buf);
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- IPath includeFile = (IPath)getAttribute(INCLUDE_FILE);
- appendEncodePath(includeFile, buf);
- break;
- case IPathEntry.CDT_MACRO:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- String symbol = (String)getAttribute(MACRO_NAME);
- buf.append(symbol).append(';');
- break;
- case IPathEntry.CDT_MACRO_FILE:
- baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- IPath macrosFile = (IPath)getAttribute(MACROS_FILE);
- appendEncodePath(macrosFile, buf);
- break;
- default:
- break;
- }
- break;
- case IPathEntry.CDT_LIBRARY:
- IPath baseRef = (IPath)getAttribute(BASE_REF);
- appendEncodePath(baseRef, buf);
- IPath base = (IPath)getAttribute(BASE);
- appendEncodePath(base, buf);
- IPath sourceAttach = (IPath)getAttribute(SOURCEATTACHMENT);
- appendEncodePath(sourceAttach, buf);
- IPath library = (IPath)getAttribute(LIBRARY);
- appendEncodePath(library, buf);
- break;
- default:
- break;
- }
- buf.setLength(buf.length() - 1);
- return buf;
- }
-
- /**
- * Gets the path entry path.
- *
- * @see IPathEntry#getPath()
- */
- public IPath getPath() {
- return fPath;
- }
-
- /**
- * Gets the classpath entry kind.
- *
- * @see IPathEntry#getEntryKind()
- */
- public int getEntryKind() {
- return fEntryKind;
- }
-
- /**
- * Entries without resource are either non existing or a variable entry
- * External jars do not have a resource
- */
- public IResource getResource() {
- return fResource;
- }
-
- public CPElement getParentContainer() {
- CPElementAttribute attribute = findAttributeElement(PARENT_CONTAINER);
- if (attribute != null) {
- return (CPElement)attribute.getValue();
- }
- return null;
- }
-
- public void setParent(CPElementGroup group) {
- CPElementAttribute attribute = findAttributeElement(PARENT);
- if (attribute == null) {
- if (group != null) {
- createAttributeElement(PARENT, group);
- }
- } else {
- attribute.setValue(group);
- }
- }
-
- public CPElementGroup getParent() {
- CPElementAttribute attribute = findAttributeElement(PARENT);
- if (attribute != null) {
- return (CPElementGroup)attribute.getValue();
- }
- return null;
- }
-
- public CPElementAttribute setAttribute(String key, Object value) {
- CPElementAttribute attribute = findAttributeElement(key);
- if (attribute == null) {
- return null;
- }
- attribute.setValue(value);
- attributeChanged(key);
- return attribute;
- }
-
- private CPElementAttribute findAttributeElement(String key) {
- for (int i = 0; i < fChildren.size(); i++) {
- Object curr = fChildren.get(i);
- if (curr instanceof CPElementAttribute) {
- CPElementAttribute elem = (CPElementAttribute)curr;
- if (key.equals(elem.getKey())) {
- return elem;
- }
- }
- }
- return null;
- }
-
- public Object getAttribute(String key) {
- CPElementAttribute attrib = findAttributeElement(key);
- if (attrib != null) {
- return attrib.getValue();
- }
- return null;
- }
-
- private void createAttributeElement(String key, Object value) {
- fChildren.add(new CPElementAttribute(this, key, value));
- }
-
- public Object[] getChildren() {
- switch (fEntryKind) {
- case IPathEntry.CDT_OUTPUT:
- case IPathEntry.CDT_SOURCE:
- case IPathEntry.CDT_INCLUDE:
- case IPathEntry.CDT_INCLUDE_FILE:
- case IPathEntry.CDT_MACRO:
- case IPathEntry.CDT_MACRO_FILE:
- if (getInherited() == null && getParentContainer() == null) {
- return new Object[]{findAttributeElement(EXCLUSION)};
- }
- break;
- // case IPathEntry.CDT_LIBRARY:
- // return new Object[] { findAttributeElement(SOURCEATTACHMENT) };
-
- case IPathEntry.CDT_CONTAINER: {
- List list = new ArrayList();
- for (int i = 0; i < fChildren.size(); i++) {
- Object curr = fChildren.get(i);
- if (curr instanceof CPElementGroup) {
- list.add(curr);
- }
- }
- return list.toArray();
- }
- }
- return new Object[0];
- }
-
- private void attributeChanged(String key) {
- fCachedEntry = null;
- fStatus = null;
- }
-
- /*
- * @see Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object other) {
- if (other != null && other.getClass().equals(getClass())) {
- CPElement elem = (CPElement)other;
- if (elem.fEntryKind != fEntryKind || !elem.fPath.equals(fPath)) {
- return false;
- }
- switch (fEntryKind) {
- case IPathEntry.CDT_LIBRARY:
- return (getAttribute(LIBRARY).equals(elem.getAttribute(LIBRARY))
- && getAttribute(BASE).equals(elem.getAttribute(BASE)) && getAttribute(BASE_REF).equals(
- elem.getAttribute(BASE_REF)));
- case IPathEntry.CDT_INCLUDE:
- return (getAttribute(INCLUDE).equals(elem.getAttribute(INCLUDE))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
- case IPathEntry.CDT_INCLUDE_FILE:
- return (getAttribute(INCLUDE_FILE).equals(elem.getAttribute(INCLUDE_FILE))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
- case IPathEntry.CDT_MACRO:
- return (getAttribute(MACRO_NAME).equals(elem.getAttribute(MACRO_NAME))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
- case IPathEntry.CDT_MACRO_FILE:
- return (getAttribute(MACROS_FILE).equals(elem.getAttribute(MACROS_FILE))
- && getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) && getAttribute(BASE).equals(
- elem.getAttribute(BASE)));
- }
- return true;
- }
- return false;
- }
-
- /*
- * @see Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int HASH_FACTOR = 89;
- int hashCode = fPath.hashCode() + fEntryKind;
- switch (fEntryKind) {
- case IPathEntry.CDT_LIBRARY:
- hashCode = hashCode * HASH_FACTOR + getAttribute(LIBRARY).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- break;
- case IPathEntry.CDT_INCLUDE:
- hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- hashCode = hashCode * HASH_FACTOR + getAttribute(INCLUDE_FILE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
- case IPathEntry.CDT_MACRO:
- hashCode = hashCode * HASH_FACTOR + getAttribute(MACRO_NAME).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
- case IPathEntry.CDT_MACRO_FILE:
- hashCode = hashCode * HASH_FACTOR + getAttribute(MACROS_FILE).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE_REF).hashCode();
- hashCode = hashCode * HASH_FACTOR + getAttribute(BASE).hashCode();
- break;
- }
- return hashCode;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return getPathEntry().toString();
- }
-
- /**
- * Returns if a entry is missing.
- *
- * @return Returns a boolean
- */
- public IStatus getStatus() {
- if (Inherited != null) {
- return Inherited.getStatus();
- }
- if (fStatus == null) {
- fStatus = Status.OK_STATUS;
- IResource res = null;
- IPath path;
- IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
- IPathEntry entry = getPathEntry();
- switch (getEntryKind()) {
- case IPathEntry.CDT_CONTAINER:
- try {
- if ((CoreModel.getPathEntryContainer(fPath, fCProject) == null)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1,
- CPathEntryMessages.CPElement_status_pathContainerMissing, null);
- }
- } catch (CModelException e) {
- }
- break;
- case IPathEntry.CDT_LIBRARY:
- if (!((ILibraryEntry)entry).getFullLibraryPath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_libraryPathNotFound, null);
- }
- break;
- case IPathEntry.CDT_SOURCE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_sourcePathMissing, null);
- }
- break;
- case IPathEntry.CDT_OUTPUT:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_outputPathMissing, null);
- }
- break;
- case IPathEntry.CDT_INCLUDE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
- }
- if (!((IIncludeEntry) entry).getFullIncludePath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_includePathNotFound, null);
- }
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
- }
- if (!((IIncludeFileEntry)entry).getFullIncludeFilePath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_includeFilePathNotFound, null);
- }
- break;
- case IPathEntry.CDT_MACRO:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
- }
- break;
- case IPathEntry.CDT_MACRO_FILE:
- path = fPath.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- if (res != null && res.getType() != IResource.ROOT && res.getType() != IResource.PROJECT && fCProject != null) {
- if (!fCProject.isOnSourceRoot(res)) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_notOnSourcePath, null);
- }
- }
- if (!((IMacroFileEntry)entry).getFullMacroFilePath().toFile().exists()) {
- fStatus = new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_macrosFilePathNotFound, null);
- }
- break;
- case IPathEntry.CDT_PROJECT:
- res = root.findMember(fPath);
- if (res == null) {
- fStatus = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, CPathEntryMessages.CPElement_status_missingProjectPath, null);
- }
- break;
- }
- }
- return fStatus;
- }
-
- /**
- * Returns if a entry is exported (only applies to libraries)
- *
- * @return Returns a boolean
- */
- public boolean isExported() {
- return fIsExported;
- }
-
- /**
- * Sets the export state of the entry.
- */
- public void setExported(boolean isExported) {
- if (isExported != fIsExported) {
- fIsExported = isExported;
-
- attributeChanged(null);
- }
- }
-
- public CPElement getInherited() {
- return Inherited;
- }
-
- /**
- * Gets the project.
- *
- * @return Returns a ICProject
- */
- public ICProject getCProject() {
- return fCProject;
- }
-
- public static CPElement createFromExisting(IPathEntry curr, ICElement element) {
- IPath path = curr.getPath();
- IWorkspaceRoot root = CUIPlugin.getWorkspace().getRoot();
- IPath sourceAttachment = null;
- IPath[] exclusion = null;
- IPath include = null;
- IPath includeFile = null;
- IPath library = null;
- String macroName = null;
- String macroValue = null;
- IPath macrosFile = null;
- boolean sysInclude = false;
- IPath baseRef = null;
- IPath base = null;
-
- // get the resource
- IResource res = null;
-
- switch (curr.getEntryKind()) {
- case IPathEntry.CDT_CONTAINER:
- res = (element instanceof ICProject) ? null : element.getResource();
- break;
- case IPathEntry.CDT_LIBRARY:
- library = ((ILibraryEntry)curr).getLibraryPath();
- sourceAttachment = ((ILibraryEntry)curr).getSourceAttachmentPath();
- base = ((ILibraryEntry)curr).getBasePath();
- baseRef = ((ILibraryEntry)curr).getBaseReference();
- break;
- case IPathEntry.CDT_SOURCE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((ISourceEntry)curr).getExclusionPatterns();
- break;
- case IPathEntry.CDT_OUTPUT:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((IOutputEntry)curr).getExclusionPatterns();
- break;
- case IPathEntry.CDT_INCLUDE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((IIncludeEntry)curr).getExclusionPatterns();
- sysInclude = ((IIncludeEntry)curr).isSystemInclude();
- baseRef = ((IIncludeEntry)curr).getBaseReference();
- base = ((IIncludeEntry)curr).getBasePath();
- include = ((IIncludeEntry)curr).getIncludePath();
- break;
- case IPathEntry.CDT_INCLUDE_FILE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((IIncludeFileEntry)curr).getExclusionPatterns();
- includeFile = ((IIncludeFileEntry)curr).getIncludeFilePath();
- baseRef = ((IIncludeFileEntry)curr).getBaseReference();
- base = ((IIncludeFileEntry)curr).getBasePath();
- break;
- case IPathEntry.CDT_MACRO:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((IMacroEntry)curr).getExclusionPatterns();
- macroName = ((IMacroEntry)curr).getMacroName();
- macroValue = ((IMacroEntry)curr).getMacroValue();
- baseRef = ((IMacroEntry)curr).getBaseReference();
- base = ((IMacroEntry)curr).getBasePath();
- break;
- case IPathEntry.CDT_MACRO_FILE:
- path = path.removeTrailingSeparator();
- res = root.findMember(path);
- if (res == null) {
- if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) {
- res = root.getFolder(path);
- }
- }
- exclusion = ((IMacroFileEntry)curr).getExclusionPatterns();
- macrosFile = ((IMacroFileEntry)curr).getMacroFilePath();
- baseRef = ((IMacroFileEntry)curr).getBaseReference();
- base = ((IMacroFileEntry)curr).getBasePath();
- break;
- case IPathEntry.CDT_PROJECT:
- res = root.findMember(path);
- break;
- }
- CPElement elem = new CPElement((element == null) ? null : element.getCProject(), curr.getEntryKind(), path, res);
- elem.setAttribute(SOURCEATTACHMENT, sourceAttachment);
- elem.setAttribute(EXCLUSION, exclusion);
- elem.setAttribute(INCLUDE, include);
- elem.setAttribute(INCLUDE_FILE, includeFile);
- elem.setAttribute(LIBRARY, library);
- elem.setAttribute(MACRO_NAME, macroName);
- elem.setAttribute(MACRO_VALUE, macroValue);
- elem.setAttribute(MACROS_FILE, macrosFile);
- elem.setAttribute(SYSTEM_INCLUDE, Boolean.valueOf(sysInclude));
- elem.setAttribute(BASE_REF, baseRef);
- elem.setAttribute(BASE, base);
- elem.setExported(curr.isExported());
- return elem;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java
deleted file mode 100644
index 6236ff5..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementAttribute.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-/**
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-public class CPElementAttribute {
-
- private CPElement fParent;
- private String fKey;
- private Object fValue;
-
- public CPElementAttribute(CPElement parent, String key, Object value) {
- fKey = key;
- fValue = value;
- fParent = parent;
- }
-
- public CPElement getParent() {
- return fParent;
- }
-
- /**
- * Returns the key.
- *
- * @return String
- */
- public String getKey() {
- return fKey;
- }
-
- /**
- * Returns the value.
- *
- * @return Object
- */
- public Object getValue() {
- return fValue;
- }
-
- /**
- * Returns the value.
- */
- public void setValue(Object value) {
- fValue = value;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java
deleted file mode 100644
index ff680a8..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementFilter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-/**
- * Viewer filter for archive selection dialogs. Archives are files with file extension '.so', '.dll' and '.a'. The filter is not
- * case sensitive.
- *
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-public class CPElementFilter extends ViewerFilter {
-
- protected List fExcludes;
- protected int[] fKind;
- protected boolean fExportedOnly;
- protected boolean fShowInherited;
-
- /**
- * @param excludedElements
- * Excluded paths will not pass the filter. null is allowed if no files should be excluded.
- */
- public CPElementFilter(Object[] excludedElements, int[] kind, boolean exportedOnly, boolean showInherited) {
- if (excludedElements != null) {
- fExcludes = Arrays.asList(excludedElements);
- }
- fKind = kind;
- fExportedOnly = exportedOnly;
- fShowInherited = showInherited;
- }
-
- public CPElementFilter(int[] kind, boolean exportedOnly, boolean showInherited) {
- this(null, kind, exportedOnly, showInherited);
- }
-
- /*
- * @see ViewerFilter#select
- */
- @Override
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof CPElement) {
- for (int i = 0; i < fKind.length; i++) {
- if ( ((CPElement)element).getEntryKind() == fKind[i]) {
- if (fExcludes == null || !fExcludes.contains(element)) {
- if (fExportedOnly == true) {
- if ( !fShowInherited ) {
- return ((CPElement)element).getInherited() == null && ((CPElement)element).isExported();
- }
- return ((CPElement)element).isExported();
- }
- if ( !fShowInherited ) {
- return ((CPElement)element).getInherited() == null;
- }
- return true;
- }
- }
- }
- } else if (element instanceof IPathEntry) {
- for (int i = 0; i < fKind.length; i++) {
- if ( ((IPathEntry)element).getEntryKind() == fKind[i]) {
- if (fExcludes == null || !fExcludes.contains(element)) {
- if (fExportedOnly == true) {
- return ((IPathEntry)element).isExported();
- }
- return true;
- }
- }
- }
- } else if (element instanceof CPElementGroup) {
- for (int i = 0; i < fKind.length; i++) {
- if ( ((CPElementGroup)element).getEntryKind() == fKind[i]) {
- return true;
- }
- }
- } else {
- return true;
- }
- return false;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java
deleted file mode 100644
index d95475d..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementGroup.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-public class CPElementGroup {
-
- private CPElement parent;
- private final int kind;
- private IResource resource;
- private Map> childrenListMap;
- private List childrenList;
-
- public CPElementGroup(IResource resource) {
- this.kind = -1;
- this.resource = resource;
- this.childrenListMap = new LinkedHashMap>(2);
- }
-
- public CPElementGroup(CPElement parent, int kind) {
- this.parent = parent;
- this.kind = kind;
- this.childrenList = new ArrayList();
- }
-
- public IResource getResource() {
- return resource;
- }
-
- public IPath getPath() {
- return resource != null ? resource.getFullPath() : parent.getPath();
- }
-
- public CPElement getParent() {
- return parent;
- }
-
- public int getEntryKind() {
- return kind;
- }
-
- @Override
- public boolean equals(Object arg0) {
- if (arg0 == this) {
- return true;
- }
- if (arg0 instanceof CPElementGroup) {
- CPElementGroup other = (CPElementGroup)arg0;
- return (kind == other.kind && ( (parent == null && other.parent == null) || parent.equals(other.parent)) && ( (resource == null && other.resource == null) || resource.equals(other.resource)));
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- int hashCode = parent != null ? parent.hashCode() : 0;
- hashCode += resource != null ? resource.hashCode() : 0;
- return hashCode + kind;
- }
-
- public int indexof(CPElement element) {
- List children = getChildrenList(element.getEntryKind(), false);
- return children != null ? children.indexOf(element) : -1;
- }
-
- public void addChild(CPElement element, int insertIndex) {
- List children = getChildrenList(element.getEntryKind(), true);
- children.add(insertIndex, element);
- element.setParent(this);
- }
-
- public void addChild(CPElement element) {
- List children = getChildrenList(element.getEntryKind(), true);
- int indx = children.indexOf(element);
- if (indx == -1) {
- indx = children.size();
- if (element.getInherited() == null) {
- for (int i = 0; i < children.size(); i++) {
- CPElement next = children.get(i);
- if (next.getInherited() != null) {
- indx = i;
- break;
- }
- }
- }
- children.add(indx, element);
- element.setParent(this);
- } else { // add element with closes matching resource path.
- CPElement other = children.get(indx);
- if (other.getInherited() != null && element.getInherited() != null) {
- IPath otherPath = other.getInherited().getPath();
- IPath elemPath = element.getInherited().getPath();
- if (!otherPath.equals(elemPath) && otherPath.isPrefixOf(elemPath)) {
- children.remove(indx);
- other.setParent(null);
- children.add(element);
- element.setParent(this);
- }
- }
- }
- }
-
- public void setChildren(CPElement[] elements) {
- if (elements.length > 0) {
- if (childrenListMap != null) {
- childrenListMap.put(new Integer(elements[0].getEntryKind()), new ArrayList(Arrays.asList(elements)));
- } else {
- childrenList = new ArrayList(Arrays.asList(elements));
- }
- }
- }
-
- public void addChildren(CPElement[] elements) {
- for (CPElement element : elements) {
- addChild(element);
- }
- }
-
- public boolean removeChild(CPElement element) {
- List children = getChildrenList(element.getEntryKind(), false);
- if (children == null) {
- return false;
- }
- boolean removed = children.remove(element);
- if (removed) {
- element.setParent(null);
- }
- return removed;
- }
-
- public CPElement[] getChildren(int kind) {
- List children = getChildrenList(kind, true);
- return children.toArray(new CPElement[children.size()]);
- }
-
- public CPElement[] getChildren() {
- if (childrenList != null) {
- return childrenList.toArray(new CPElement[childrenList.size()]);
- }
- Collection> lists = childrenListMap.values();
- Iterator> iter = lists.iterator();
- List children = new ArrayList();
- while (iter.hasNext()) {
- children.addAll(iter.next());
- }
- return children.toArray(new CPElement[children.size()]);
- }
-
- public boolean contains(CPElement element) {
- List children = getChildrenList(element.getEntryKind(), false);
- if (children == null) {
- return false;
- }
- return children.contains(element);
- }
-
- public void replaceChild(CPElement element, CPElement replaceWith) {
- List children = getChildrenList(element.getEntryKind(), false);
- if (children == null) {
- return;
- }
- int idx = children.indexOf(element);
- if (idx != -1) {
- children.remove(idx);
- children.add(idx, replaceWith);
- }
- }
-
- private List getChildrenList(int kind, boolean create) {
- List children = null;
- if (childrenList != null) {
- children = childrenList;
- } else {
- children = childrenListMap.get(new Integer(kind));
- if (children == null && create) {
- children = new ArrayList();
- childrenListMap.put(new Integer(kind), children);
- }
- }
- return children;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java
deleted file mode 100644
index 3649aac..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementLabelProvider.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.core.model.IPathEntryContainer;
-import org.eclipse.cdt.ui.CDTSharedImages;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
-
-/**
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-class CPElementLabelProvider extends LabelProvider implements IColorProvider {
-
- private Color inDirect = new Color(Display.getDefault(), new RGB(170, 170, 170));
-
- private String fNewLabel, fCreateLabel;
- private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon;
- private ImageDescriptor fQuoteIncludeIcon, fIncludeFileIcon, fMacrosFileIcon;
- private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage;
- private boolean bShowExported;
- private boolean bShowParentInfo;
- private ImageDescriptorRegistry fRegistry;
-
- public CPElementLabelProvider() {
- this(true, false);
- }
-
- public CPElementLabelProvider(boolean showExported, boolean showParentInfo) {
- fNewLabel = CPathEntryMessages.CPElementLabelProvider_new;
- fCreateLabel = CPathEntryMessages.CPElementLabelProvider_willbecreated;
- fRegistry = CUIPlugin.getImageDescriptorRegistry();
-
- fLibIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
- fLibWSrcIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_ARCHIVE);
- fIncludeIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCLUDES_FOLDER);
- fQuoteIncludeIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_QUOTE_INCLUDES_FOLDER);
- fIncludeFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
- fMacroIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
- fMacrosFileIcon = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_TUNIT_HEADER);
- fFolderImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ROOT);
- fOutputImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CONTAINER);
- fContainerImage = CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_LIBRARY);
-
- IWorkbench workbench = CUIPlugin.getDefault().getWorkbench();
-
- fProjectImage = workbench.getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
- bShowExported = showExported;
- bShowParentInfo = showParentInfo;
- }
-
- /*
- * @see org.eclipse.jface.viewers.BaseLabelProvider#dispose()
- */
- @Override
- public void dispose() {
- inDirect.dispose();
- inDirect= null;
- super.dispose();
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof CPElement) {
- return getCPElementText((CPElement)element);
- } else if (element instanceof CPElementAttribute) {
- return getCPElementAttributeText((CPElementAttribute)element);
- } else if (element instanceof IPathEntry) {
- return getCPElementText(CPElement.createFromExisting((IPathEntry)element, null));
- } else if (element instanceof CPElementGroup) {
- return (getCPContainerGroupText((CPElementGroup)element));
- }
- return super.getText(element);
- }
-
- private String getCPContainerGroupText(CPElementGroup group) {
- switch (group.getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- return CPathEntryMessages.CPElementLabelProvider_Includes;
- case IPathEntry.CDT_INCLUDE_FILE :
- return CPathEntryMessages.CPElementLabelProvider_IncludeFiles;
- case IPathEntry.CDT_MACRO :
- return CPathEntryMessages.CPElementLabelProvider_PreprocessorSymbols;
- case IPathEntry.CDT_MACRO_FILE :
- return CPathEntryMessages.CPElementLabelProvider_MacrosFiles;
- case IPathEntry.CDT_LIBRARY :
- return CPathEntryMessages.CPElementLabelProvider_Libraries;
- case -1 :
- if (group.getResource().getType() == IResource.PROJECT) {
- return group.getResource().getName();
- }
- StringBuffer label = new StringBuffer(group.getResource().getProjectRelativePath().toString());
- if (!group.getResource().exists()) {
- label.append(fCreateLabel);
- }
- return label.toString();
- }
- return ""; //$NON-NLS-1$
- }
-
- public String getCPElementAttributeText(CPElementAttribute attrib) {
- String notAvailable = CPathEntryMessages.CPElementLabelProvider_none;
- StringBuffer buf = new StringBuffer();
- String key = attrib.getKey();
- if (key.equals(CPElement.SOURCEATTACHMENT)) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_label);
- IPath path = (IPath)attrib.getValue();
- if (path != null && !path.isEmpty()) {
- buf.append(getPathString(path, path.getDevice() != null));
- } else {
- buf.append(notAvailable);
- }
- } else if (key.equals(CPElement.SOURCEATTACHMENTROOT)) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_source_attachment_root_label);
- IPath path = (IPath)attrib.getValue();
- if (path != null && !path.isEmpty()) {
- buf.append(path.toString());
- } else {
- buf.append(notAvailable);
- }
- }
- if (key.equals(CPElement.EXCLUSION)) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_label);
- IPath[] patterns = (IPath[])attrib.getValue();
- if (patterns != null && patterns.length > 0) {
- for (int i = 0; i < patterns.length; i++) {
- if (i > 0) {
- buf.append(CPathEntryMessages.CPElementLabelProvider_exclusion_filter_separator);
- }
- buf.append(patterns[i].toString());
- }
- } else {
- buf.append(notAvailable);
- }
- }
- return buf.toString();
- }
-
- public String getCPElementText(CPElement cpentry) {
- IPath path = cpentry.getPath();
- switch (cpentry.getEntryKind()) {
- case IPathEntry.CDT_LIBRARY : {
- IPath libPath = (IPath)cpentry.getAttribute(CPElement.LIBRARY);
- StringBuffer str = new StringBuffer();
- addBaseString(libPath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_PROJECT :
- return path.lastSegment();
- case IPathEntry.CDT_INCLUDE : {
- IPath incPath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE));
- StringBuffer str = new StringBuffer();
- addBaseString(incPath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_INCLUDE_FILE : {
- IPath incFilePath = ((IPath)cpentry.getAttribute(CPElement.INCLUDE_FILE));
- StringBuffer str = new StringBuffer();
- addBaseString(incFilePath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_MACRO : {
- StringBuffer str = new StringBuffer((String)cpentry.getAttribute(CPElement.MACRO_NAME) + "=" //$NON-NLS-1$
- + (String)cpentry.getAttribute(CPElement.MACRO_VALUE));
- addBaseString(null, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_MACRO_FILE : {
- IPath macroFilePath = ((IPath)cpentry.getAttribute(CPElement.MACROS_FILE));
- StringBuffer str = new StringBuffer();
- addBaseString(macroFilePath, cpentry, str);
- addExport(cpentry, str);
- addParentInfo(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_CONTAINER : {
- StringBuffer str = new StringBuffer(path.toString());
- try {
- IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
- if (container != null) {
- str.setLength(0);
- str.append(container.getDescription());
- }
- } catch (CModelException e) {
- }
- addExport(cpentry, str);
- return str.toString();
- }
- case IPathEntry.CDT_SOURCE :
- case IPathEntry.CDT_OUTPUT : {
- StringBuffer buf = new StringBuffer(path.makeRelative().toString());
- IResource resource = cpentry.getResource();
- if (resource != null && !resource.exists()) {
- buf.append(' ');
- if (cpentry.getStatus().getSeverity() != IStatus.OK) { // only valid error for src/output would missing path...
- buf.append(fCreateLabel);
- } else {
- buf.append(fNewLabel);
- }
- }
- return buf.toString();
- }
- default :
- // pass
- }
- return CPathEntryMessages.CPElementLabelProvider_unknown_element_label;
- }
- /**
- * @param cpentry
- * @param str
- */
- private void addParentInfo(CPElement cpentry, StringBuffer str) {
- if (bShowParentInfo) {
- CPElement parent = cpentry.getParentContainer();
- if (parent != null) {
- str.append(" ["); //$NON-NLS-1$
- try {
- IPathEntryContainer container = CoreModel.getPathEntryContainer(cpentry.getPath(), cpentry.getCProject());
- if (container != null) {
- str.append(container.getDescription());
- }
- } catch (CModelException e) {
- str.append(parent.getPath());
- }
- str.append(']');
- }
- }
- }
-
- private void addExport(CPElement cpentry, StringBuffer str) {
- if (bShowExported && cpentry.isExported()) {
- str.append(' ');
- str.append(CPathEntryMessages.CPElementLabelProvider_export_label);
- }
- }
-
- private void addBaseString(IPath endPath, CPElement cpentry, StringBuffer str) {
- IPath baseRef = (IPath)cpentry.getAttribute(CPElement.BASE_REF);
- if (!baseRef.isEmpty()) {
- if (baseRef.isAbsolute()) {
- // str.append("From project ");
- IPath path = baseRef;
- if (endPath != null) {
- path = path.append(endPath);
- }
- str.append(path.makeRelative().toOSString());
- } else {
- // str.append("From contribution ");
- IPathEntryContainer container;
- if (endPath != null) {
- str.append(endPath.toOSString());
- }
- str.append(" - ("); //$NON-NLS-1$
- try {
- container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject());
- if (container != null) {
- str.append(container.getDescription());
- }
- } catch (CModelException e1) {
- }
- str.append(')');
- }
- } else {
- IPath path = (IPath)cpentry.getAttribute(CPElement.BASE);
- if (!path.isEmpty()) {
- if (endPath != null) {
- path = path.append(endPath);
- }
- str.insert(0, path.toOSString());
- } else if (endPath != null) {
- str.insert(0, endPath.toOSString());
- }
- }
-
- }
-
- private String getPathString(IPath path, boolean isExternal) {
- // if (ArchiveFileFilter.isArchivePath(path)) {
- // IPath appendedPath = path.removeLastSegments(1);
- // String appended = isExternal ? appendedPath.toOSString() :
- // appendedPath.makeRelative().toString();
- // return
- // CPathEntryMessages.getFormattedString("CPListLabelProvider.twopart",
- // //$NON-NLS-1$
- // new String[] { path.lastSegment(), appended});
- // } else {
- return isExternal ? path.toOSString() : path.makeRelative().toString();
- // }
- }
-
- private ImageDescriptor getCPElementBaseImage(CPElement cpentry) {
- switch (cpentry.getEntryKind()) {
- case IPathEntry.CDT_OUTPUT :
- if (cpentry.getPath().segmentCount() == 1) {
- return fProjectImage;
- }
- return fOutputImage;
- case IPathEntry.CDT_SOURCE :
- if (cpentry.getPath().segmentCount() == 1) {
- return fProjectImage;
- }
- return fFolderImage;
- case IPathEntry.CDT_LIBRARY :
- IPath path = (IPath)cpentry.getAttribute(CPElement.SOURCEATTACHMENT);
- if (path == null || path.isEmpty()) {
- return fLibIcon;
- }
- return fLibWSrcIcon;
- case IPathEntry.CDT_PROJECT :
- return fProjectImage;
- case IPathEntry.CDT_CONTAINER :
- return fContainerImage;
- case IPathEntry.CDT_INCLUDE :
- if (((Boolean)cpentry.getAttribute(CPElement.SYSTEM_INCLUDE)).booleanValue())
- return fIncludeIcon;
- return fQuoteIncludeIcon;
- case IPathEntry.CDT_INCLUDE_FILE :
- return fIncludeFileIcon;
- case IPathEntry.CDT_MACRO :
- return fMacroIcon;
- case IPathEntry.CDT_MACRO_FILE :
- return fMacrosFileIcon;
- default :
- return null;
- }
- }
-
- private static final Point SMALL_SIZE = new Point(16, 16);
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof CPElement) {
- CPElement cpentry = (CPElement)element;
- ImageDescriptor imageDescriptor = getCPElementBaseImage(cpentry);
- if (imageDescriptor != null) {
- switch (cpentry.getStatus().getSeverity()) {
- case IStatus.WARNING :
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
- break;
- case IStatus.ERROR :
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.ERROR, SMALL_SIZE);
- break;
- }
- if (cpentry.getInherited() != null) {
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.PATH_INHERIT, SMALL_SIZE);
- }
- return fRegistry.get(imageDescriptor);
- }
- } else if (element instanceof CPElementAttribute) {
- String key = ((CPElementAttribute)element).getKey();
- if (key.equals(CPElement.SOURCEATTACHMENT)) {
- return fRegistry.get(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_SOURCE_ATTACH_ATTRIB));
- } else if (key.equals(CPElement.EXCLUSION)) {
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_EXCLUSION_FILTER_ATTRIB);
- }
- } else if (element instanceof IPathEntry) {
- return getImage(CPElement.createFromExisting((IPathEntry)element, null));
- } else if (element instanceof CPElementGroup) {
- switch ( ((CPElementGroup)element).getEntryKind()) {
- case IPathEntry.CDT_INCLUDE :
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDES_CONTAINER);
- case IPathEntry.CDT_MACRO :
- return fRegistry.get(fMacroIcon);
- case IPathEntry.CDT_INCLUDE_FILE :
- case IPathEntry.CDT_MACRO_FILE :
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_INCLUDE);
- case IPathEntry.CDT_LIBRARY :
- return CDTSharedImages.getImage(CDTSharedImages.IMG_OBJS_LIBRARY);
- case -1 :
- IResource res = ((CPElementGroup)element).getResource();
- IWorkbenchAdapter adapter = (IWorkbenchAdapter)res.getAdapter(IWorkbenchAdapter.class);
- ImageDescriptor imageDescriptor = adapter.getImageDescriptor(res);
- if (!res.exists()) {
- imageDescriptor = new CPListImageDescriptor(imageDescriptor, CPListImageDescriptor.WARNING, SMALL_SIZE);
- }
- return fRegistry.get(imageDescriptor);
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- if (element instanceof CPElement) {
- if ( ((CPElement)element).getInherited() != null) {
- return inDirect;
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
- */
- public Color getBackground(Object element) {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java
deleted file mode 100644
index c717442..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPElementSorter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-import org.eclipse.cdt.core.model.IPathEntry;
-
-/**
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-public class CPElementSorter extends ViewerSorter {
-
- private static final int SOURCE = 0;
- private static final int PROJECT = 1;
- private static final int LIBRARY = 2;
- private static final int CONTAINER = 3;
- private static final int OTHER = 5;
-
- /*
- * @see ViewerSorter#category(Object)
- */
- @Override
- public int category(Object obj) {
- if (obj instanceof CPElement) {
- switch ( ((CPElement)obj).getEntryKind()) {
- case IPathEntry.CDT_LIBRARY :
- return LIBRARY;
- case IPathEntry.CDT_PROJECT :
- return PROJECT;
- case IPathEntry.CDT_SOURCE :
- return SOURCE;
- case IPathEntry.CDT_CONTAINER :
- return CONTAINER;
- }
- } else if (obj instanceof CPElementGroup) {
- switch ( ((CPElementGroup)obj).getEntryKind()) {
- case IPathEntry.CDT_LIBRARY :
- return LIBRARY;
- case IPathEntry.CDT_PROJECT :
- return PROJECT;
- case IPathEntry.CDT_SOURCE :
- return SOURCE;
- case IPathEntry.CDT_CONTAINER :
- return CONTAINER;
- case -1 :
- if ( ((CPElementGroup)obj).getResource() instanceof IProject) {
- return PROJECT;
- }
- }
- }
- return OTHER;
- }
-
- @Override
- public void sort(Viewer viewer, Object[] elements) {
- // include paths and symbol definitions must not be sorted
- List sort = new ArrayList(elements.length);
- List includes = new ArrayList(elements.length);
- List syms = new ArrayList(elements.length);
- for (Object element : elements) {
- if (element instanceof CPElement) {
- CPElement cpelement = (CPElement)element;
- if (cpelement.getEntryKind() == IPathEntry.CDT_INCLUDE) {
- includes.add(cpelement);
- } else if (cpelement.getEntryKind() == IPathEntry.CDT_MACRO) {
- syms.add(cpelement);
- } else {
- sort.add(cpelement);
- }
- } else {
- sort.add(element);
- }
- }
- System.arraycopy(sort.toArray(), 0, elements, 0, sort.size());
- super.sort(viewer, elements);
- System.arraycopy(includes.toArray(), 0, elements, sort.size(), includes.size());
- System.arraycopy(syms.toArray(), 0, elements, sort.size() + includes.size(), syms.size());
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java
deleted file mode 100644
index 8f20e10..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListImageDescriptor.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-
-/**
- * @deprecated as of CDT 4.0. This class was used for property pages
- * for 3.X style projects.
- */
-@Deprecated
-public class CPListImageDescriptor extends CompositeImageDescriptor {
-
- /** Flag to render the waring adornment */
- public final static int WARNING= 0x1;
-
- /** Flag to render the inherited adornment */
- public final static int ERROR= 0x2;
-
- /** Flag to render the inherited adornment */
- public final static int PATH_INHERIT= 0x4;
-
- private ImageDescriptor fBaseImage;
- private int flags;
- private Point fSize;
-
- public CPListImageDescriptor(ImageDescriptor baseImage, int flags, Point size) {
- fBaseImage = baseImage;
- this.flags = flags;
- fSize = size;
- }
-
- /**
- * @see CompositeImageDescriptor#getSize()
- */
- @Override
- protected Point getSize() {
- if (fSize == null) {
- ImageData data = fBaseImage.getImageData();
- setSize(new Point(data.width, data.height));
- }
- return fSize;
- }
-
- /**
- * @see Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object object) {
- if (!(object instanceof CPListImageDescriptor)) {
- return false;
- }
-
- CPListImageDescriptor other = (CPListImageDescriptor) object;
- return fBaseImage.equals(other.fBaseImage) && flags == other.flags && fSize.equals(other.fSize);
- }
-
- /**
- * @see Object#hashCode()
- */
- @Override
- public int hashCode() {
- return fBaseImage.hashCode() & flags | fSize.hashCode();
- }
-
- /**
- * @see CompositeImageDescriptor#drawCompositeImage(int, int)
- */
- @Override
- protected void drawCompositeImage(int width, int height) {
- ImageData bg = fBaseImage.getImageData();
- if (bg == null) {
- bg = DEFAULT_IMAGE_DATA;
- }
- drawImage(bg, 0, 0);
- drawOverlays();
- }
-
- /**
- * Add any overlays to the image as specified in the flags.
- */
- protected void drawOverlays() {
- Point size= getSize();
- ImageData data = null;
- int x= getSize().x;
- if ((flags & PATH_INHERIT) == PATH_INHERIT) {
- data = CPluginImages.DESC_OVR_PATH_INHERIT.getImageData();
- drawImage(data, x, 0);
- }
- x= 0;
- if ((flags & ERROR) != 0) {
- data= CPluginImages.DESC_OVR_ERROR.getImageData();
- drawImage(data, x, size.y - data.height);
- x+= data.width;
- }
- if ((flags & WARNING) != 0) {
- data= CPluginImages.DESC_OVR_WARNING.getImageData();
- drawImage(data, x, size.y - data.height);
- x+= data.width;
- }
- }
-
- protected void setSize(Point size) {
- fSize = size;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
deleted file mode 100644
index 66396b6..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.cdt.core.model.CoreModelUtil;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
-
-/**
- * Abstract Option Page for C/C++ Project Paths page for 3.X projects.
- *
- * @deprecated as of CDT 4.0. This page was used to set preferences/properties
- * for 3.X style projects.
- */
-@Deprecated
-public abstract class CPathBasePage extends AbstractCOptionPage {
-
- public CPathBasePage(String title) {
- super(title);
- }
-
- public CPathBasePage(String title, ImageDescriptor image) {
- super(title, image);
- }
-
- protected void fixNestingConflicts(List newEntries, List existingList, Set modifiedSourceEntries) {
- ArrayList existing = new ArrayList(existingList);
- for (int i = 0; i < newEntries.size(); i++) {
- CPElement curr = newEntries.get(i);
- addExclusionPatterns(curr, existing, modifiedSourceEntries);
- // add the entry to the existing list so it can be analyse also.
- existing.add(curr);
- }
- }
-
- private void addExclusionPatterns(CPElement newEntry, List existing, Set modifiedEntries) {
- IPath entryPath = newEntry.getPath();
- for (int i = 0; i < existing.size(); i++) {
- CPElement curr = existing.get(i);
- if (curr.getEntryKind() == IPathEntry.CDT_SOURCE) {
- IPath currPath = curr.getPath();
- if (currPath.isPrefixOf(entryPath) && !currPath.equals(entryPath)) {
- IPath[] exclusionFilters = (IPath[]) curr.getAttribute(CPElement.EXCLUSION);
- if (!CoreModelUtil.isExcludedPath(entryPath.removeFirstSegments(1), exclusionFilters)) {
- IPath pathToExclude = entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator();
- IPath[] newExclusionFilters = new IPath[exclusionFilters.length + 1];
- System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length);
- newExclusionFilters[exclusionFilters.length] = pathToExclude;
- curr.setAttribute(CPElement.EXCLUSION, newExclusionFilters);
- modifiedEntries.add(curr);
- }
- }
- }
- }
- }
-
- public abstract List> getSelection();
-
- public abstract void setSelection(List> selection);
-
- public abstract boolean isEntryKind(int kind);
-
- protected List filterList(List cpelements) {
- ArrayList filtered = new ArrayList();
-
- for (int i = 0; i < cpelements.size(); i++) {
- CPElement cpe = cpelements.get(i);
- if (isEntryKind(cpe.getEntryKind())) {
- filtered.add(cpe);
- }
- }
- return filtered;
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java
deleted file mode 100644
index 6b106db..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDefaultPage.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.ArrayList;
-
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringDialogField;
-import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * @deprecated as of CDT 4.0. This class was used for property pages/wizards
- * for 3.X style projects.
- */
-@Deprecated
-public class CPathContainerDefaultPage extends NewElementWizardPage implements IPathEntryContainerPage {
- private StringDialogField fEntryField;
- private ArrayList fUsedPaths;
-
- /**
- * Constructor for ClasspathContainerDefaultPage.
- */
- public CPathContainerDefaultPage() {
- super("CPathContainerDefaultPage"); //$NON-NLS-1$
- setTitle(CPathEntryMessages.CPathContainerDefaultPage_title);
- setDescription(CPathEntryMessages.CPathContainerDefaultPage_description);
- setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
-
- fUsedPaths= new ArrayList();
-
- fEntryField= new StringDialogField();
- fEntryField.setLabelText(CPathEntryMessages.CPathContainerDefaultPage_path_label);
- fEntryField.setDialogFieldListener(new IDialogFieldListener() {
- public void dialogFieldChanged(DialogField field) {
- validatePath();
- }
- });
- validatePath();
- }
-
- protected void validatePath() {
- StatusInfo status= new StatusInfo();
- String str= fEntryField.getText();
- if (str.length() == 0) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_enterpath);
- } else if (!Path.ROOT.isValidPath(str)) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_invalidpath);
- } else {
- IPath path= new Path(str);
- if (path.segmentCount() == 0) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_needssegment);
- } else if (fUsedPaths.contains(path)) {
- status.setError(CPathEntryMessages.CPathContainerDefaultPage_path_error_alreadyexists);
- }
- }
- updateStatus(status);
- }
-
- /* (non-Javadoc)
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 1;
- composite.setLayout(layout);
-
- fEntryField.doFillIntoGrid(composite, 2);
- LayoutUtil.setHorizontalGrabbing(fEntryField.getTextControl(null), true);
-
- fEntryField.setFocus();
-
- setControl(composite);
- Dialog.applyDialogFont(composite);
-// WorkbenchHelp.setHelp(composite, IJavaHelpContextIds.CLASSPATH_CONTAINER_DEFAULT_PAGE);
- }
-
- /* (non-Javadoc)
- * @see IClasspathContainerPage#finish()
- */
- public boolean finish() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see IClasspathContainerPage#getSelection()
- */
- public IContainerEntry[] getNewContainers() {
- return new IContainerEntry[] {CoreModel.newContainerEntry(new Path(fEntryField.getText()))};
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension#initialize(org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathEntry)
- */
- public void initialize(ICProject project, IPathEntry[] currentEntries) {
- for (int i= 0; i < currentEntries.length; i++) {
- IPathEntry curr= currentEntries[i];
- if (curr.getEntryKind() == IPathEntry.CDT_CONTAINER) {
- fUsedPaths.add(curr.getPath());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see IClasspathContainerPage#setSelection(IClasspathEntry)
- */
- public void setSelection(IContainerEntry containerEntry) {
- if (containerEntry != null) {
- fUsedPaths.remove(containerEntry.getPath());
- fEntryField.setText(containerEntry.getPath().toString());
- } else {
- fEntryField.setText(""); //$NON-NLS-1$
- }
- }
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java
deleted file mode 100644
index 4b8e20a..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.osgi.framework.Bundle;
-
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.wizards.IPathEntryContainerPage;
-
-import org.eclipse.cdt.internal.ui.util.CoreUtility;
-
-/**
- * @deprecated as of CDT 4.0. This wizard was used in property pages/wizards
- * for 3.X style projects.
- */
-@Deprecated
-public class CPathContainerDescriptor implements IContainerDescriptor {
-
-
- /**
- * Adapter class to adapter deprecated ICPathContainerPage to new IPathEntryContainerPage
- * @author Dave
- * @deprecated
- */
- @Deprecated
- public static class PathEntryContainerPageAdapter implements IPathEntryContainerPage {
- public static IPathEntryContainerPage createAdapter(Object elem) {
- if (elem instanceof org.eclipse.cdt.ui.wizards.ICPathContainerPage) {
- return new PathEntryContainerPageAdapter((org.eclipse.cdt.ui.wizards.ICPathContainerPage) elem);
- }
- return null;
- }
-
-
- private final org.eclipse.cdt.ui.wizards.ICPathContainerPage fPage;
- protected PathEntryContainerPageAdapter(org.eclipse.cdt.ui.wizards.ICPathContainerPage page) {
- fPage = page;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#initialize(org.eclipse.cdt.core.model.ICProject, org.eclipse.cdt.core.model.IPathEntry[])
- */
- public void initialize(ICProject project, IPathEntry[] currentEntries) {
- fPage.initialize(project, currentEntries);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#finish()
- */
- public boolean finish() {
- return fPage.finish();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#getNewContainers()
- */
- public IContainerEntry[] getNewContainers() {
- IPathEntry[] entries = fPage.getContainerEntries();
- IContainerEntry[] containers = new IContainerEntry[entries.length];
- System.arraycopy(entries, 0, containers, 0, entries.length);
- return containers;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.ui.wizards.IPathEntryContainerPage#setSelection(org.eclipse.cdt.core.model.IContainerEntry)
- */
- public void setSelection(IContainerEntry containerEntry) {
- fPage.setSelection(containerEntry);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- fPage.createControl(parent);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#canFlipToNextPage()
- */
- public boolean canFlipToNextPage() {
- return fPage.canFlipToNextPage();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#getName()
- */
- public String getName() {
- return fPage.getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
- */
- public IWizardPage getNextPage() {
- return fPage.getNextPage();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#getPreviousPage()
- */
- public IWizardPage getPreviousPage() {
- return fPage.getPreviousPage();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#getWizard()
- */
- public IWizard getWizard() {
- return fPage.getWizard();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
- */
- public boolean isPageComplete() {
- return fPage.isPageComplete();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#setPreviousPage(org.eclipse.jface.wizard.IWizardPage)
- */
- public void setPreviousPage(IWizardPage page) {
- fPage.setPreviousPage(page);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.wizard.IWizardPage#setWizard(org.eclipse.jface.wizard.IWizard)
- */
- public void setWizard(IWizard newWizard) {
- fPage.setWizard(newWizard);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
- */
- public void dispose() {
- fPage.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getControl()
- */
- public Control getControl() {
- return fPage.getControl();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getDescription()
- */
- public String getDescription() {
- return fPage.getDescription();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getErrorMessage()
- */
- public String getErrorMessage() {
- return fPage.getErrorMessage();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getImage()
- */
- public Image getImage() {
- return fPage.getImage();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getMessage()
- */
- public String getMessage() {
- return fPage.getMessage();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#getTitle()
- */
- public String getTitle() {
- return fPage.getTitle();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#performHelp()
- */
- public void performHelp() {
- fPage.performHelp();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setDescription(java.lang.String)
- */
- public void setDescription(String description) {
- fPage.setDescription(description);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
- */
- public void setImageDescriptor(ImageDescriptor image) {
- fPage.setImageDescriptor(image);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setTitle(java.lang.String)
- */
- public void setTitle(String title) {
- fPage.setTitle(title);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- fPage.setVisible(visible);
- }
-
- }
- private IConfigurationElement fConfigElement;
-
- private static final String ATT_EXTENSION = "PathContainerPage"; //$NON-NLS-1$
-
- private static final String ATT_ID = "id"; //$NON-NLS-1$
- private static final String ATT_NAME = "name"; //$NON-NLS-1$
- private static final String ATT_ICON = "icon"; //$NON-NLS-1$
- private static final String ATT_PAGE_CLASS = "class"; //$NON-NLS-1$
-
- private Image pageImage;
-
- public CPathContainerDescriptor(IConfigurationElement configElement) throws CoreException {
- super();
- fConfigElement = configElement;
-
- String id = fConfigElement.getAttribute(ATT_ID);
- String name = configElement.getAttribute(ATT_NAME);
- String pageClassName = configElement.getAttribute(ATT_PAGE_CLASS);
-
- if (name == null) {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0, "Invalid extension (missing name): " + id, //$NON-NLS-1$
- null));
- }
- if (pageClassName == null) {
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
- "Invalid extension (missing page class name): " + id, null)); //$NON-NLS-1$
- }
- }
-
- public IPathEntryContainerPage createPage() throws CoreException {
- Object elem = CoreUtility.createExtension(fConfigElement, ATT_PAGE_CLASS);
- if (elem instanceof IPathEntryContainerPage) {
- return (IPathEntryContainerPage) elem;
- }
- IPathEntryContainerPage result= PathEntryContainerPageAdapter.createAdapter(elem);
- if (result != null) {
- return result;
- }
- String id = fConfigElement.getAttribute(ATT_ID);
- throw new CoreException(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, 0,
- "Invalid extension (page not of type IClasspathContainerPage): " + id, null)); //$NON-NLS-1$
- }
-
- public String getName() {
- return fConfigElement.getAttribute(ATT_NAME);
- }
-
- public Image getImage() {
- if (pageImage == null) {
- String imageName = fConfigElement.getAttribute(ATT_ICON);
- if (imageName != null) {
- IExtension extension = fConfigElement.getDeclaringExtension();
- String plugin = extension.getContributor().getName();
- Image image = getImageFromPlugin(plugin, imageName);
- pageImage = image;
- }
- }
- return pageImage;
- }
-
- public Image getImageFromPlugin(String plugin, String subdirectoryAndFilename) {
- Bundle bundle = Platform.getBundle(plugin);
- URL iconURL = bundle.getEntry("/"); //$NON-NLS-1$
- return getImageFromURL(iconURL, subdirectoryAndFilename);
- }
-
- public Image getImageFromURL(URL installURL, String subdirectoryAndFilename) {
- Image image = null;
- try {
- URL newURL = new URL(installURL, subdirectoryAndFilename);
- ImageDescriptor desc = ImageDescriptor.createFromURL(newURL);
- image = desc.createImage();
- } catch (MalformedURLException e) {
- } catch (SWTException e) {
- }
- return image;
- }
-
- public String getPageClass() {
- return fConfigElement.getAttribute(ATT_PAGE_CLASS);
- }
-
- public boolean canEdit(IPathEntry entry) {
- String id = fConfigElement.getAttribute(ATT_ID);
- if (entry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
- String type = entry.getPath().segment(0);
- return id.equals(type);
- }
- return false;
- }
-
- public static IContainerDescriptor[] getDescriptors() {
- ArrayList containers = new ArrayList();
-
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(CUIPlugin.PLUGIN_ID, ATT_EXTENSION);
- if (extensionPoint != null) {
- IContainerDescriptor defaultPage = null;
- String defaultPageName = CPathContainerDefaultPage.class.getName();
-
- IConfigurationElement[] elements = extensionPoint.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- try {
- CPathContainerDescriptor curr = new CPathContainerDescriptor(element);
- if (defaultPageName.equals(curr.getPageClass())) {
- defaultPage = curr;
- } else {
- containers.add(curr);
- }
- } catch (CoreException e) {
- CUIPlugin.log(e);
- }
- }
- if (defaultPageName != null && containers.isEmpty()) {
- // default page only added if no other extensions found
- containers.add(defaultPage);
- }
- }
- return containers.toArray(new CPathContainerDescriptor[containers.size()]);
- }
-
-}
diff --git a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java b/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
deleted file mode 100644
index 2687d72..0000000
--- a/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerEntryPage.java
+++ /dev/null
@@ -1,479 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.dialogs.cpaths;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.layout.PixelConverter;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IContainerEntry;
-import org.eclipse.cdt.core.model.IPathEntry;
-import org.eclipse.cdt.ui.CUIPlugin;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
-
-/**
- * Path Containers tab for C/C++ Project Paths page for 3.X projects.
- *
- * @deprecated as of CDT 4.0. This tab was used to set preferences/properties
- * for 3.X style projects.
- */
-@Deprecated
-public class CPathContainerEntryPage extends CPathBasePage {
- private ListDialogField fCPathList;
- private ICProject fCurrCProject;
-
- private TreeListDialogField fContainersList;
-
- private final int IDX_ADD = 0;
-
- private final int IDX_EDIT = 2;
- private final int IDX_REMOVE = 3;
- private final int IDX_EXPORT = 5;
-
- public CPathContainerEntryPage(ListDialogField cPathList) {
- super(CPathEntryMessages.ContainerEntryPage_title);
- fCPathList = cPathList;
-
- String[] buttonLabels = new String[]{
- CPathEntryMessages.ContainerEntryPage_add_button,
- /* */null,
- CPathEntryMessages.ContainerEntryPage_edit_button,
- CPathEntryMessages.ContainerEntryPage_remove_button,
- null,
- CPathEntryMessages.ContainerEntryPage_export_button
- };
-
- ContainersAdapter adapter = new ContainersAdapter();
-
- fContainersList = new TreeListDialogField(adapter, buttonLabels, new CPElementLabelProvider());
- fContainersList.setDialogFieldListener(adapter);
- fContainersList.setLabelText(CPathEntryMessages.ContainerEntryPage_libraries_label);
-
- fContainersList.enableButton(IDX_REMOVE, false);
- fContainersList.enableButton(IDX_EDIT, false);
- fContainersList.enableButton(IDX_EXPORT, false);
- fContainersList.setTreeExpansionLevel(2);
-
- fContainersList.setViewerComparator(new CPElementSorter());
-
- }
-
- public void init(ICProject jproject) {
- fCurrCProject = jproject;
- updateLibrariesList();
- }
-
- private void updateLibrariesList() {
- List cpelements = fCPathList.getElements();
- List libelements = new ArrayList(cpelements.size());
-
- int nElements = cpelements.size();
- for (int i = 0; i < nElements; i++) {
- CPElement cpe = cpelements.get(i);
- if (isEntryKind(cpe.getEntryKind())) {
- libelements.add(cpe);
- }
- }
- fContainersList.setElements(libelements);
- }
-
- // -------- ui creation
-
- @Override
- public void createControl(Composite parent) {
- PixelConverter converter = new PixelConverter(parent);
-
- Composite composite = new Composite(parent, SWT.NONE);
-
- LayoutUtil.doDefaultLayout(composite, new DialogField[]{fContainersList}, true);
- LayoutUtil.setHorizontalGrabbing(fContainersList.getTreeControl(null), true);
-
- int buttonBarWidth = converter.convertWidthInCharsToPixels(24);
- fContainersList.setButtonsMinWidth(buttonBarWidth);
-
- fContainersList.getTreeViewer().addFilter(new ViewerFilter() {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getChildren().length != 0;
- }
- return true;
- }
- });
-
- setControl(composite);
-
- CUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.PROJECT_PATHS_CONTAINERS);
- }
-
- private class ContainersAdapter implements IDialogFieldListener, ITreeListAdapter {
-
- private final Object[] EMPTY_ARR = new Object[0];
-
- // -------- IListAdapter --------
- public void customButtonPressed(TreeListDialogField field, int index) {
- containerPageCustomButtonPressed(field, index);
- }
-
- public void selectionChanged(TreeListDialogField field) {
- containerPageSelectionChanged(field);
- }
-
- public void doubleClicked(TreeListDialogField field) {
- containerPageDoubleClicked(field);
- }
-
- public void keyPressed(TreeListDialogField field, KeyEvent event) {
- containerPageKeyPressed(field, event);
- }
-
- public Object[] getChildren(TreeListDialogField field, Object element) {
- if (element instanceof CPElement) {
- return ((CPElement)element).getChildren();
- } else if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getChildren();
- }
- return EMPTY_ARR;
- }
-
- public Object getParent(TreeListDialogField field, Object element) {
- if (element instanceof CPElementAttribute) {
- return ((CPElementAttribute)element).getParent();
- } else if (element instanceof CPElementGroup) {
- return ((CPElementGroup)element).getParent();
- }
- return null;
- }
-
- public boolean hasChildren(TreeListDialogField field, Object element) {
- if (element instanceof CPElementGroup) {
- return true;
- } else if (element instanceof CPElement) {
- return ((CPElement)element).getChildren().length != 0;
- }
- return false;
-
- }
-
- // ---------- IDialogFieldListener --------
-
- public void dialogFieldChanged(DialogField field) {
- containerPageDialogFieldChanged(field);
- }
- }
-
- void containerPageCustomButtonPressed(DialogField field, int index) {
- CPElement[] containers = null;
- switch (index) {
- case IDX_ADD :
- /* add container */
- containers = openContainerSelectionDialog(null);
- break;
- case IDX_EDIT :
- /* edit */
- editEntry();
- return;
- case IDX_REMOVE :
- /* remove */
- removeEntry();
- return;
- case IDX_EXPORT :
- /* export */
- exportEntry();
- return;
- }
- if (containers != null) {
- int nElementsChosen = containers.length;
- // remove duplicates
- List cplist = fContainersList.getElements();
- List