use of org.eclipse.core.runtime.QualifiedName in project dbeaver by serge-rider.
the class ProjectExportWizard method saveResourceProperties.
private void saveResourceProperties(IResource resource, XMLBuilder xml) throws CoreException, IOException {
if (resource instanceof IFile) {
final IContentDescription contentDescription = ((IFile) resource).getContentDescription();
if (contentDescription != null && contentDescription.getCharset() != null) {
xml.addAttribute(ExportConstants.ATTR_CHARSET, contentDescription.getCharset());
//xml.addAttribute(ExportConstants.ATTR_CHARSET, contentDescription.getContentType());
}
} else if (resource instanceof IFolder) {
xml.addAttribute(ExportConstants.ATTR_DIRECTORY, true);
}
for (Object entry : resource.getPersistentProperties().entrySet()) {
Map.Entry<?, ?> propEntry = (Map.Entry<?, ?>) entry;
xml.startElement(ExportConstants.TAG_ATTRIBUTE);
final QualifiedName attrName = (QualifiedName) propEntry.getKey();
xml.addAttribute(ExportConstants.ATTR_QUALIFIER, attrName.getQualifier());
xml.addAttribute(ExportConstants.ATTR_NAME, attrName.getLocalName());
xml.addAttribute(ExportConstants.ATTR_VALUE, (String) propEntry.getValue());
xml.endElement();
}
}
use of org.eclipse.core.runtime.QualifiedName in project dbeaver by serge-rider.
the class ProjectImportWizard method loadResourceProperties.
private void loadResourceProperties(DBRProgressMonitor monitor, IResource resource, Element element) throws CoreException, IOException {
if (resource instanceof IFile) {
final String charset = element.getAttribute(ExportConstants.ATTR_CHARSET);
if (!CommonUtils.isEmpty(charset)) {
((IFile) resource).setCharset(charset, RuntimeUtils.getNestedMonitor(monitor));
}
}
for (Element attrElement : XMLUtils.getChildElementList(element, ExportConstants.TAG_ATTRIBUTE)) {
String qualifier = attrElement.getAttribute(ExportConstants.ATTR_QUALIFIER);
String name = attrElement.getAttribute(ExportConstants.ATTR_NAME);
String value = attrElement.getAttribute(ExportConstants.ATTR_VALUE);
if (!CommonUtils.isEmpty(qualifier) && !CommonUtils.isEmpty(name) && !CommonUtils.isEmpty(value)) {
resource.setPersistentProperty(new QualifiedName(qualifier, name), value);
}
}
}
use of org.eclipse.core.runtime.QualifiedName in project ow by vtst.
the class LessProjectPropertyPage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite composite = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH);
Label label = SWTFactory.createLabel(composite, messages.getString("LessProjectPropertyPage_includePaths"), 1);
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
includePaths.createContents(IContainer.class, composite);
label = SWTFactory.createLabel(composite, messages.getString("LessProjectPropertyPage_roots"), 1);
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
roots.createContents(IFile.class, composite);
final IContentType lessContentType = Platform.getContentTypeManager().getContentType(LessRuntimeModule.CONTENT_TYPE_ID);
final IProject project = this.getProject();
roots.setAddFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof IProject)
return project.equals(element);
else if (element instanceof IContainer)
return true;
else if (element instanceof IFile) {
IFile file = (IFile) element;
try {
if (file.getContentDescription() == null)
return false;
IContentType fileContentType = file.getContentDescription().getContentType();
if (fileContentType != null && fileContentType.isKindOf(lessContentType))
return true;
} catch (CoreException e) {
}
}
return false;
}
});
try {
includePaths.setCurrentValue(ResourceListProperty.<IContainer>get(IContainer.class, getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.INCLUDE_PATHS)));
roots.setCurrentValue(ResourceListProperty.<IFile>get(IFile.class, getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.ROOTS)));
} catch (CoreException e) {
this.setErrorMessage(e.getMessage());
}
return composite;
}
use of org.eclipse.core.runtime.QualifiedName in project ow by vtst.
the class LessProjectPropertyPage method performOk.
@Override
public boolean performOk() {
try {
ResourceListProperty.<IContainer>set(getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.INCLUDE_PATHS), includePaths.getCurrentValue());
ResourceListProperty.<IFile>set(getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.ROOTS), roots.getCurrentValue());
} catch (CoreException e) {
this.setErrorMessage(e.getMessage());
return false;
}
;
return super.performOk();
}
use of org.eclipse.core.runtime.QualifiedName in project sling by apache.
the class ProjectUtilTest method oldContentSyncRootIsMigrated.
@Test
public void oldContentSyncRootIsMigrated() throws Exception {
QualifiedName oldPropertyQName = new QualifiedName("org.apache.sling.ide.eclipse-core", "sync_root");
IPath contentSyncPath = Path.fromPortableString("src/main/content/jcr_root");
project.ensureDirectoryExists(contentSyncPath);
// simulate the old property being set
contentProject.setPersistentProperty(oldPropertyQName, contentSyncPath.toString());
// query the data through the API, old value should be obeyed
assertThat("Old sync_root not obeyed", ProjectUtil.getSyncDirectory(contentProject).getProjectRelativePath(), equalTo(contentSyncPath));
// the old store should no longer have the config value
assertThat("Old property not removed", contentProject.getPersistentProperty(oldPropertyQName), nullValue());
// a second query should work just the same, to make sure that after deleting the data from the old store we get the right value back
assertThat("sync_root not obeyed after old store for property was deleted", ProjectUtil.getSyncDirectory(contentProject).getProjectRelativePath(), equalTo(contentSyncPath));
}
Aggregations