/** {@inheritDoc} */ public void cleanup(IResource resource, IProgressMonitor monitor) throws CoreException { if (BeansCoreUtils.isBeansConfig(resource) && resource instanceof IFile) { IBeansConfig beansConfig = BeansCorePlugin.getModel().getConfig((IFile) resource); for (IBean bean : beansConfig.getBeans()) { BeansMetadataPlugin.getMetadataModel().clearBeanMetadata(bean); BeansMetadataPlugin.getMetadataModel().clearBeanProperties(bean); } // Notify that the model has changed. // ((BeansModel) BeansCorePlugin.getModel()).notifyListeners(beansConfig, Type.CHANGED); } }
/** The user has pressed the remove button. Delete the selected configuration. */ private void handleRemoveButtonPressed() { IStructuredSelection selection = (IStructuredSelection) configsViewer.getSelection(); if (!selection.isEmpty()) { Iterator elements = selection.iterator(); while (elements.hasNext()) { IBeansConfig config = (IBeansConfig) elements.next(); project.removeConfig(config.getElementName()); } configsViewer.refresh(false); hasUserMadeChanges = true; } }
/** {@inheritDoc} */ public Set<IResource> getAffectedResources(IResource resource, int kind, int deltaKind) throws CoreException { Set<IResource> resources = new HashSet<IResource>(); if (kind != IncrementalProjectBuilder.FULL_BUILD && resource instanceof IFile && resource.getName().endsWith(JdtUtils.JAVA_FILE_EXTENSION)) { // Make sure that only a structural change to a java source file triggers a rebuild TypeStructureState structureState = context.get(TypeStructureState.class); BeansTypeHierachyState hierachyState = context.get(BeansTypeHierachyState.class); if (structureState == null || structureState.hasStructuralChanges( resource, ITypeStructureCache.FLAG_ANNOTATION | ITypeStructureCache.FLAG_ANNOTATION_VALUE)) { for (IBean bean : hierachyState.getBeansByContainingTypes(resource)) { IBeansConfig beansConfig = BeansModelUtils.getConfig(bean); resources.add(beansConfig.getElementResource()); if (affectedBeans.containsKey(beansConfig)) { affectedBeans.get(beansConfig).add(bean); } else { Set<IBean> beans = new LinkedHashSet<IBean>(); beans.add(bean); affectedBeans.put(beansConfig, beans); } } } } else if (BeansCoreUtils.isBeansConfig(resource, true)) { IBeansConfig beansConfig = (IBeansConfig) BeansModelUtils.getResourceModelElement(resource); if (beansConfig instanceof IImportedBeansConfig) { beansConfig = BeansModelUtils.getParentOfClass(beansConfig, IBeansConfig.class); } for (IBeansImport beansImport : beansConfig.getImports()) { for (IImportedBeansConfig importedBeansConfig : beansImport.getImportedBeansConfigs()) { resources.add(importedBeansConfig.getElementResource()); addBeans(importedBeansConfig); } } resources.add(beansConfig.getElementResource()); addBeans(beansConfig); } return resources; }
@Override public String getText(Object element) { String label = super.getText(element); if (element instanceof IFile) { IBeansConfig bc = BeansCorePlugin.getModel().getConfig((IFile) element, true); if (bc instanceof IImportedBeansConfig) { label += " [imported]"; } if (bc != null && bc.getType() == IBeansConfig.Type.AUTO_DETECTED) { label += " [auto detected]"; } } else if (element instanceof ZipEntryStorage) { return ((ZipEntryStorage) element).getEntryName(); } if (label != null && label.startsWith(IBeansConfig.EXTERNAL_FILE_NAME_PREFIX)) { label = label.substring(IBeansConfig.EXTERNAL_FILE_NAME_PREFIX.length()); } return label; }
public BeanReferenceXmlValidationContextHelper( BeansEditorValidator validator, AttrImpl attribute, IDOMNode node, IFile file, IBeansConfig config, IResourceModelElement contextElement, IReporter reporter, boolean reportError) { super(validator, attribute, node, file, config, contextElement, reporter, reportError); this.file = (IFile) config.getElementResource(); this.document = node.getOwnerDocument(); }