private boolean canRemove(List<?> selElements) { if (selElements.size() == 0) { return false; } for (int i= 0; i < selElements.size(); i++) { Object elem= selElements.get(i); if (elem instanceof CPListElementAttribute) { CPListElementAttribute attrib= (CPListElementAttribute) elem; if (attrib.isNonModifiable()) { return false; } if (attrib.isBuiltIn()) { if (CPListElement.ACCESSRULES.equals(attrib.getKey())) { if (((IAccessRule[]) attrib.getValue()).length == 0) { return false; } } else if (attrib.getValue() == null) { return false; } } else { if (!canRemoveCustomAttribute(attrib)) { return false; } } } } return true; }
@Override public Object getParent(TreeListDialogField<CPListElement> field, Object element) { if (element instanceof CPListElementAttribute) { return ((CPListElementAttribute) element).getParent(); } return null; }
public CPListElementAttribute copy() { CPListElementAttribute result= new CPListElementAttribute(fBuiltIn); result.fParent= fParent; result.fKey= fKey; result.fValue= fValue; result.fStatus= fStatus; return result; }
@Override public Object[] getChildren(TreeListDialogField<CPListElement> field, Object element) { if (element instanceof CPListElement) { return ((CPListElement) element).getChildren(false); } else if (element instanceof CPListElementAttribute) { CPListElementAttribute attribute= (CPListElementAttribute) element; if (CPListElement.MODULE.equals(attribute.getKey())) { return (ModuleEncapsulationDetail[]) attribute.getValue(); } } return EMPTY_ARR; }
private IClasspathAttribute[] getClasspathAttributes() { ArrayList res= new ArrayList(); for (int i= 0; i < fChildren.size(); i++) { Object curr= fChildren.get(i); if (curr instanceof CPListElementAttribute) { CPListElementAttribute elem= (CPListElementAttribute) curr; if (!elem.isBuiltIn() && elem.getValue() != null) { res.add(elem.getClasspathAttribute()); } } } return (IClasspathAttribute[]) res.toArray(new IClasspathAttribute[res.size()]); }
protected boolean editCustomAttribute(Shell shell, CPListElementAttribute elem) { ClasspathAttributeConfiguration config= fAttributeDescriptors.get(elem.getKey()); if (config != null) { IClasspathAttribute result= config.performEdit(shell, elem.getClasspathAttributeAccess()); if (result != null) { elem.setValue(result.getValue()); return true; } } return false; }
public void setAttributesFromExisting(CPListElement existing) { Assert.isTrue(existing.getEntryKind() == getEntryKind()); CPListElementAttribute[] attributes= existing.getAllAttributes(); for (int i= 0; i < attributes.length; i++) { CPListElementAttribute curr= attributes[i]; CPListElementAttribute elem= findAttributeElement(curr.getKey()); if (elem == null) { createAttributeElement(curr.getKey(), curr.getValue(), curr.isBuiltIn()); } else { elem.setValue(curr.getValue()); } } }
private void editAttributeEntry(CPListElementAttribute elem) { String key= elem.getKey(); CPListElement selElement= elem.getParent(); if (key.equals(CPListElement.SOURCEATTACHMENT)) { IClasspathEntry result= BuildPathDialogAccess.configureSourceAttachment(getShell(), selElement.getClasspathEntry()); if (result != null) { selElement.setAttribute(CPListElement.SOURCEATTACHMENT, result.getSourceAttachmentPath()); fLibraryList.refresh(elem); fLibraryList.update(selElement); } } else if (key.equals(CPListElement.ACCESSRULES)) { AccessRulesDialog dialog= new AccessRulesDialog(getShell(), selElement, null, false); if (dialog.open() == Window.OK) { selElement.setAttribute(CPListElement.ACCESSRULES, dialog.getAccessRules()); fLibraryList.refresh(elem); fLibraryList.expandElement(elem, 2); } } else if (!elem.isBuiltIn()) { ClasspathAttributeConfiguration config= fAttributeDescriptors.get(key); if (config != null) { IClasspathAttribute result= config.performEdit(getShell(), elem.getClasspathAttributeAccess()); if (result != null) { elem.setValue(result.getValue()); fLibraryList.refresh(elem); } } } }
private boolean canEdit(List list) { if (list.size() != 1) return false; Object firstElement= list.get(0); if (firstElement instanceof IAccessRule) return false; if (firstElement instanceof CPListElementAttribute) { CPListElementAttribute attrib= (CPListElementAttribute) firstElement; if (!attrib.isBuiltIn()) { ClasspathAttributeConfiguration config= fAttributeDescriptors.get(attrib.getKey()); return config != null && config.canEdit(attrib.getClasspathAttributeAccess()); } } return true; }
private static boolean isFiltered(Object entry, String[] filteredKeys) { if (entry instanceof CPListElementAttribute) { CPListElementAttribute curr= (CPListElementAttribute) entry; String key= curr.getKey(); for (int i= 0; i < filteredKeys.length; i++) { if (key.equals(filteredKeys[i])) { return true; } } if (curr.isNotSupported()) { return true; } if (!curr.isBuiltIn() && !key.equals(CPListElement.JAVADOC) && !key.equals(CPListElement.NATIVE_LIB_PATH)) { return !JavaPlugin.getDefault().getClasspathAttributeConfigurationDescriptors().containsKey(key); } } return false; }
protected boolean canEditCustomAttribute(CPListElementAttribute elem) { ClasspathAttributeConfiguration config= fAttributeDescriptors.get(elem.getKey()); if (config != null) { return config.canEdit(elem.getClasspathAttributeAccess()); } return false; }
public void setAttributesFromExisting(CPListElement existing) { Assert.isTrue(existing.getEntryKind() == getEntryKind()); CPListElementAttribute[] attributes= existing.getAllAttributes(); for (int i= 0; i < attributes.length; i++) { CPListElementAttribute curr= attributes[i]; CPListElementAttribute elem= findAttributeElement(curr.getKey()); if (elem == null) { createAttributeElement(curr.getKey(), curr.getValue(), false); } else { elem.setValue(curr.getValue()); } } }
private boolean canEdit(List<?> selElements) { if (selElements.size() != 1) { return false; } Object elem= selElements.get(0); if (elem instanceof CPListElement) { return false; } if (elem instanceof CPListElementAttribute) { CPListElementAttribute attrib= (CPListElementAttribute) elem; if (attrib.isNonModifiable()) { return false; } if (!attrib.isBuiltIn()) { return canEditCustomAttribute(attrib); } if (hasRootNodes() && attrib.getKey().equals(IClasspathAttribute.MODULE)) { // module info should always be enabled. return true; } return true; } return false; }
private IStatus evaluateContainerChildStatus(CPListElementAttribute attrib) { if (fProject != null) { ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(fPath.segment(0)); if (initializer != null && initializer.canUpdateClasspathContainer(fPath, fProject)) { if (attrib.isBuiltIn()) { if (CPListElement.SOURCEATTACHMENT.equals(attrib.getKey())) { return initializer.getSourceAttachmentStatus(fPath, fProject); } else if (CPListElement.ACCESSRULES.equals(attrib.getKey())) { return initializer.getAccessRulesStatus(fPath, fProject); } } else { return initializer.getAttributeStatus(fPath, fProject, attrib.getKey()); } } return new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY, "", null); //$NON-NLS-1$ } return null; }
private boolean canEdit(List selElements) { if (selElements.size() != 1) { return false; } Object elem= selElements.get(0); if (elem instanceof CPListElement) { return false; } if (elem instanceof CPListElementAttribute) { CPListElementAttribute attrib= (CPListElementAttribute) elem; if (attrib.isNonModifiable()) { return false; } if (!attrib.isBuiltIn()) { return canEditCustomAttribute(attrib); } return true; } return false; }
private void editAttributeEntry(CPListElementAttribute elem) { String key= elem.getKey(); if (key.equals(CPListElement.ACCESSRULES)) { showAccessRestrictionDialog(elem.getParent()); } else { if (editCustomAttribute(getShell(), elem)) { fProjectsList.refresh(); fClassPathList.dialogFieldChanged(); // validate } } }
/** * Check whether the current selection is the project's * default output folder or not * * @param attrib the attribute to be checked * @return <code>true</code> if is the default output folder, * <code>false</code> otherwise. */ public static boolean isDefaultOutputFolder(CPListElementAttribute attrib) { return attrib.getValue() == null; }
elem.createAttributeElement(attrib.getName(), attrib.getValue(), false); } else if (attrib.getName().equals(MODULE)) { attribElem = new CPListElementAttribute(elem, MODULE, null, true); attribElem.setValue(getModuleAttributeValue(attribElem, attrib, extraAttributes)); elem.fChildren.add(attribElem); value= getModuleAttributeValue(attribElem, attrib, extraAttributes); attribElem.setValue(value);
public CPListElementAttribute(CPListElement parent, String key, Object value, boolean builtIn) { fKey= key; fValue= value; fParent= parent; fBuiltIn= builtIn; if (!builtIn) { Assert.isTrue(value instanceof String || value == null); } fStatus= getContainerChildStatus(); }
@Override public IClasspathAttribute getClasspathAttribute() { return CPListElementAttribute.this.getClasspathAttribute(); } @Override