use of org.eclipse.core.resources.IContainer in project AutoRefactor by JnRouvignac.
the class JavaCoreHelper method createFolder.
private static void createFolder(IFolder folder) throws Exception {
if (!folder.exists()) {
final IContainer parent = folder.getParent();
if (parent instanceof IFolder) {
createFolder((IFolder) parent);
}
folder.create(false, true, null);
}
}
use of org.eclipse.core.resources.IContainer 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.resources.IContainer 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.resources.IContainer in project dbeaver by serge-rider.
the class ScriptsExportWizardPage method createControl.
@Override
public void createControl(Composite parent) {
String outDir = DBeaverCore.getGlobalPreferenceStore().getString(PREF_SCRIPTS_EXPORT_OUT_DIR);
if (CommonUtils.isEmpty(outDir)) {
outDir = RuntimeUtils.getUserHomeDir().getAbsolutePath();
}
Composite placeholder = UIUtils.createPlaceholder(parent, 1);
placeholder.setLayout(new GridLayout(1, false));
// Project list
scriptsNavigator = new DatabaseNavigatorTree(placeholder, DBeaverCore.getInstance().getNavigatorModel().getRoot(), SWT.BORDER | SWT.CHECK);
GridData gd = new GridData(GridData.FILL_BOTH);
scriptsNavigator.setLayoutData(gd);
CheckboxTreeViewer viewer = (CheckboxTreeViewer) scriptsNavigator.getViewer();
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateState();
}
});
scriptsNavigator.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof DBNResource && ((DBNResource) element).getResource() instanceof IContainer;
}
});
// Output folder
Composite generalSettings = UIUtils.createPlaceholder(placeholder, 3);
generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
{
overwriteCheck = UIUtils.createCheckbox(generalSettings, CoreMessages.dialog_project_export_wizard_page_checkbox_overwrite_files, false);
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
overwriteCheck.setLayoutData(gd);
UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_project_export_wizard_page_label_directory);
directoryText = new Text(generalSettings, SWT.BORDER);
directoryText.setText(outDir);
directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
directoryText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateState();
}
});
Button openFolder = new Button(generalSettings, SWT.PUSH);
openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
openFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
dialog.setMessage(CoreMessages.dialog_project_export_wizard_page_dialog_choose_export_dir_message);
dialog.setText(CoreMessages.dialog_project_export_wizard_page_dialog_choose_export_dir_text);
String directory = directoryText.getText();
if (!CommonUtils.isEmpty(directory)) {
dialog.setFilterPath(directory);
}
directory = dialog.open();
if (directory != null) {
directoryText.setText(directory);
}
}
});
}
setControl(placeholder);
updateState();
}
use of org.eclipse.core.resources.IContainer in project dbeaver by serge-rider.
the class NavigatorHandlerObjectCreateCopy method pasteResource.
private void pasteResource(DBNResource resourceNode, DBNResource toFolder) {
final IResource resource = resourceNode.getResource();
final IResource targetResource = toFolder.getResource();
assert resource != null;
assert targetResource != null;
final IContainer targetFolder = targetResource instanceof IContainer ? (IContainer) targetResource : targetResource.getParent();
try {
DBeaverUI.runInProgressService(new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
copyResource(monitor, resource, targetFolder);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
UIUtils.showErrorDialog(null, "Copy error", "Error copying resource", e.getTargetException());
} catch (InterruptedException e) {
// ignore
}
}
Aggregations