use of org.eclipse.core.runtime.QualifiedName in project che by eclipse.
the class FileStoreTextFileBuffer method cacheEncodingState.
protected void cacheEncodingState() {
fEncoding = fExplicitEncoding;
fHasBOM = false;
fIsCacheUpdated = true;
InputStream stream = null;
try {
stream = getFileContents(fFileStore);
if (stream == null)
return;
QualifiedName[] options = new QualifiedName[] { IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK };
//Platform.getContentTypeManager().getDescriptionFor(stream, fFileStore.getName(), options);
IContentDescription description = null;
if (description != null) {
fHasBOM = description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null;
if (fEncoding == null)
fEncoding = description.getCharset();
}
} catch (CoreException e) {
// do nothing
} finally /*catch (IOException e) {
// do nothing
}*/
{
try {
if (stream != null)
stream.close();
} catch (IOException ex) {
FileBuffersPlugin.getDefault().log(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.JavaTextFileBuffer_error_closeStream, ex));
}
}
// Use global default
if (fEncoding == null)
fEncoding = fManager.getDefaultEncoding();
}
use of org.eclipse.core.runtime.QualifiedName in project dbeaver by serge-rider.
the class NavigatorHandlerObjectCreateCopy method copyResource.
private void copyResource(@NotNull DBRProgressMonitor monitor, @NotNull IResource resource, @NotNull IContainer targetFolder) throws CoreException, IOException {
final IProgressMonitor nestedMonitor = RuntimeUtils.getNestedMonitor(monitor);
final String extension = resource.getFileExtension();
String targetName = resource.getName();
if (resource.getParent().equals(targetFolder)) {
String plainName = extension != null && !extension.isEmpty() && targetName.endsWith(extension) ? targetName.substring(0, targetName.length() - extension.length() - 1) : targetName;
for (int i = 1; ; i++) {
String testName = plainName + "-" + i;
if (!CommonUtils.isEmpty(extension)) {
testName += "." + extension;
}
if (targetFolder.findMember(testName) == null) {
targetName = testName;
break;
}
}
} else if (targetFolder.findMember(targetName) != null) {
throw new IOException("Target resource '" + targetName + "' already exists");
}
if (resource instanceof IFile) {
// Copy single file
final IFile targetFile = targetFolder.getFile(new Path(targetName));
if (!targetFile.exists()) {
targetFile.create(new ByteArrayInputStream(new byte[0]), true, nestedMonitor);
}
final Map<QualifiedName, String> props = resource.getPersistentProperties();
if (props != null && !props.isEmpty()) {
for (Map.Entry<QualifiedName, String> prop : props.entrySet()) {
targetFile.setPersistentProperty(prop.getKey(), prop.getValue());
}
}
try (InputStream is = ((IFile) resource).getContents()) {
targetFile.setContents(is, true, true, nestedMonitor);
}
} else if (resource instanceof IFolder) {
// Copy folder with all files and subfolders
}
}
use of org.eclipse.core.runtime.QualifiedName in project ow by vtst.
the class NatureAddingEditorCallback method afterCreatePartControl.
@Override
public void afterCreatePartControl(XtextEditor editor) {
try {
super.afterCreatePartControl(editor);
IResource resource = editor.getResource();
if (resource == null)
return;
IProject project = resource.getProject();
if (DISABLE.equals(project.getPersistentProperty(new QualifiedName(QUALIFIER, projectNature.getId()))))
return;
if (!ProjectNatureUtil.hasNature(getNature().getId(), project) && project.isAccessible()) {
MessageDialog dialog = new MessageDialog(editor.getEditorSite().getShell(), messages.format("add_nature_to_project_title", getNature().getName()), null, messages.format("add_nature_to_project_message", getNature().getName(), project.getName()), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
int ret = dialog.open();
if (ret == 0) {
ProjectNatureUtil.addNatureRequiringXtext(getNature().getId(), project);
} else if (ret == 1) {
project.setPersistentProperty(new QualifiedName(QUALIFIER, projectNature.getId()), DISABLE);
}
}
} catch (CoreException e) {
ErrorDialog.openError(editor.getSite().getShell(), messages.format("add_nature_to_project_title", getNature().getName()), messages.getString("add_nature_to_project_error"), e.getStatus());
}
}
Aggregations