mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
update cpath ui
This commit is contained in:
parent
822ad118ce
commit
6d241cf586
5 changed files with 107 additions and 8 deletions
BIN
core/org.eclipse.cdt.ui/icons/full/ovr16/path_inherit_co.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/ovr16/path_inherit_co.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 78 B |
|
@ -135,6 +135,8 @@ public class CPluginImages {
|
||||||
public static final ImageDescriptor DESC_OBJS_ORDER= createManaged(T_OBJ, IMG_OBJS_ORDER);
|
public static final ImageDescriptor DESC_OBJS_ORDER= createManaged(T_OBJ, IMG_OBJS_ORDER);
|
||||||
public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = createManaged(T_OBJ, IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
|
public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = createManaged(T_OBJ, IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
|
||||||
|
|
||||||
|
public static final ImageDescriptor DESC_OVR_PATH_INHERIT= create(T_OVR, "path_inherit_co.gif"); //$NON-NLS-1$
|
||||||
|
|
||||||
// Breakpoint image descriptors
|
// Breakpoint image descriptors
|
||||||
public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT );
|
public static final ImageDescriptor DESC_OBJS_BREAKPOINT = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT );
|
||||||
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED );
|
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED );
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class CPListElement {
|
||||||
((Boolean) getAttribute(SYSTEM_INCLUDE)).booleanValue(), exclusionPattern);
|
((Boolean) getAttribute(SYSTEM_INCLUDE)).booleanValue(), exclusionPattern);
|
||||||
case IPathEntry.CDT_MACRO:
|
case IPathEntry.CDT_MACRO:
|
||||||
exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
|
exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
|
||||||
return CoreModel.newMacroEntry(fPath, (String) getAttribute(MACRO_NAME), (String) getAttribute(MACRO_NAME), exclusionPattern);
|
return CoreModel.newMacroEntry(fPath, (String) getAttribute(MACRO_NAME), (String) getAttribute(MACRO_VALUE), exclusionPattern);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,16 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
|
||||||
List cplist = fPathList.getElements();
|
List cplist = fPathList.getElements();
|
||||||
|
|
||||||
CPListElement newPath = newCPElement(((ICElement) getSelection().get(0)).getResource());
|
CPListElement newPath = newCPElement(((ICElement) getSelection().get(0)).getResource());
|
||||||
newPath.setAttribute(CPListElement.MACRO_NAME, symbol);
|
String name, value = ""; //$NON-NLS-1$
|
||||||
|
int index = symbol.indexOf("="); //$NON-NLS-1$
|
||||||
|
if (index != -1) {
|
||||||
|
name = symbol.substring(0, index).trim();
|
||||||
|
value = symbol.substring(index + 1).trim();
|
||||||
|
} else {
|
||||||
|
name = symbol.trim();
|
||||||
|
}
|
||||||
|
newPath.setAttribute(CPListElement.MACRO_NAME, name);
|
||||||
|
newPath.setAttribute(CPListElement.MACRO_VALUE, value);
|
||||||
if (!cplist.contains(newPath)) {
|
if (!cplist.contains(newPath)) {
|
||||||
fPathList.addElement(newPath);
|
fPathList.addElement(newPath);
|
||||||
fCPathList.add(newPath);
|
fCPathList.add(newPath);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
|
import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
||||||
|
@ -36,6 +37,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.resource.CompositeImageDescriptor;
|
||||||
import org.eclipse.jface.viewers.IColorProvider;
|
import org.eclipse.jface.viewers.IColorProvider;
|
||||||
import org.eclipse.jface.viewers.ILabelProvider;
|
import org.eclipse.jface.viewers.ILabelProvider;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
@ -46,6 +48,8 @@ import org.eclipse.jface.window.Window;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.ImageData;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
import org.eclipse.swt.graphics.RGB;
|
import org.eclipse.swt.graphics.RGB;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
@ -103,22 +107,107 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
|
|
||||||
private final Color inDirect = new Color(Display.getDefault(), new RGB(170, 170, 170));
|
private final Color inDirect = new Color(Display.getDefault(), new RGB(170, 170, 170));
|
||||||
|
|
||||||
|
private class CPListImageDescriptor extends CompositeImageDescriptor {
|
||||||
|
|
||||||
|
private Image fBaseImage;
|
||||||
|
private boolean showInherited;
|
||||||
|
private Point fSize;
|
||||||
|
|
||||||
|
public CPListImageDescriptor(Image baseImage, boolean inherited) {
|
||||||
|
fBaseImage = baseImage;
|
||||||
|
showInherited = inherited;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CompositeImageDescriptor#getSize()
|
||||||
|
*/
|
||||||
|
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)
|
||||||
|
*/
|
||||||
|
public boolean equals(Object object) {
|
||||||
|
if (!(object instanceof CPListImageDescriptor)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CPListImageDescriptor other = (CPListImageDescriptor) object;
|
||||||
|
return (fBaseImage.equals(other.fBaseImage) && showInherited == other.showInherited);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Object#hashCode()
|
||||||
|
*/
|
||||||
|
public int hashCode() {
|
||||||
|
return fBaseImage.hashCode() | (showInherited ? 0x1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see CompositeImageDescriptor#drawCompositeImage(int, int)
|
||||||
|
*/
|
||||||
|
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() {
|
||||||
|
ImageData data = null;
|
||||||
|
if (showInherited) {
|
||||||
|
data = CPluginImages.DESC_OVR_PATH_INHERIT.getImageData();
|
||||||
|
drawImage(data, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSize(Point size) {
|
||||||
|
fSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
Image image = super.getImage(element);
|
||||||
|
if (isPathInherited((CPListElement) element)) {
|
||||||
|
image = new CPListImageDescriptor(image, true).createImage();
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
public Color getBackground(Object element) {
|
public Color getBackground(Object element) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getForeground(Object element) {
|
public Color getForeground(Object element) {
|
||||||
IPath resPath = ((CPListElement) element).getPath();
|
if (isPathInherited((CPListElement) element)) {
|
||||||
|
return inDirect;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isPathInherited(CPListElement element) {
|
||||||
|
IPath resPath = element.getPath();
|
||||||
List sel = getSelection();
|
List sel = getSelection();
|
||||||
if (!sel.isEmpty()) {
|
if (!sel.isEmpty()) {
|
||||||
if (sel.get(0) instanceof ICElement) {
|
if (sel.get(0) instanceof ICElement) {
|
||||||
ICElement celem = (ICElement) sel.get(0);
|
ICElement celem = (ICElement) sel.get(0);
|
||||||
if (!celem.getPath().equals(resPath)) {
|
if (!celem.getPath().equals(resPath)) {
|
||||||
return inDirect;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +269,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
protected void removePath(CPListElement element) {
|
protected void removePath(CPListElement element) {
|
||||||
ICElement celem = (ICElement) getSelection().get(0);
|
ICElement celem = (ICElement) getSelection().get(0);
|
||||||
if (!celem.getPath().equals(element.getPath())) {
|
if (!celem.getPath().equals(element.getPath())) {
|
||||||
IPath exclude = element.getPath().removeFirstSegments(element.getPath().segmentCount()).addTrailingSeparator();
|
IPath exclude = celem.getPath().removeFirstSegments(element.getPath().segmentCount()).addTrailingSeparator();
|
||||||
IPath[] exclusions = (IPath[]) element.getAttribute(CPListElement.EXCLUSION);
|
IPath[] exclusions = (IPath[]) element.getAttribute(CPListElement.EXCLUSION);
|
||||||
IPath[] newExlusions = new IPath[exclusions.length + 1];
|
IPath[] newExlusions = new IPath[exclusions.length + 1];
|
||||||
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
|
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
|
||||||
|
@ -255,8 +344,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
CPListElement element = (CPListElement) iter.next();
|
CPListElement element = (CPListElement) iter.next();
|
||||||
if (element.getPath().isPrefixOf(resPath)
|
if (element.getPath().isPrefixOf(resPath)
|
||||||
&& (element.getPath().equals(resPath)
|
&& (element.getPath().equals(resPath) || !CoreModelUtil.isExcludedPath(resPath.removeFirstSegments(1),
|
||||||
|| !CoreModelUtil.isExcludedPath(resPath.removeFirstSegments(1),
|
|
||||||
(IPath[]) element.getAttribute(CPListElement.EXCLUSION)))) {
|
(IPath[]) element.getAttribute(CPListElement.EXCLUSION)))) {
|
||||||
newList.add(element);
|
newList.add(element);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue