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(); }
private boolean canRemove(List<?> selected) { if (selected.size() != 1) { return false; } Object elem = selected.get(0); if (elem instanceof CPElement) { CPElement element = (CPElement) elem; if (element.getParentContainer() == null) { return element.getEntryKind() == IPathEntry.CDT_INCLUDE || element.getEntryKind() == IPathEntry.CDT_MACRO; } } else if (elem instanceof CPElementAttribute) { CPElementAttribute attrib = (CPElementAttribute) elem; if (attrib.getKey().equals(CPElement.EXCLUSION)) { if (((IPath[]) attrib.getValue()).length > 0) { return true; } } } return false; }