/** * Creates a new folder resource in the selected container and with the * selected name. Creates any missing resource containers along the path; * does nothing if the container resources already exist. * <p> * In normal usage, this method is invoked after the user has pressed Finish * on the wizard; the enablement of the Finish button implies that all * controls on this page currently contain valid values. * </p> * <p> * Note that this page caches the new folder once it has been successfully * created; subsequent invocations of this method will answer the same * folder resource without attempting to create it again. * </p> * <p> * This method should be called within a workspace modify operation since it * creates resources. * </p> * * @return the created folder resource, or <code>null</code> if the folder * was not created */ public IFolder createNewFolder(String containerName, String folderName, IProgressMonitor monitor) { // create the new folder and cache it if successful final IPath containerPath = new Path(containerName); IPath newFolderPath = containerPath.append(folderName); final IFolder newFolderHandle = createFolderHandle(newFolderPath); AbstractOperation op; op = new CreateFolderOperation(newFolderHandle, null, false, null, "New Folder"); try { op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(getShell())); } catch (final ExecutionException e) { getContainer().getShell().getDisplay().syncExec( new Runnable() { public void run() { if (e.getCause() instanceof CoreException) { ErrorDialog.openError(getContainer().getShell(), "Creation Problems", null, ((CoreException) e.getCause()).getStatus()); } else { MessageDialog.openError(getContainer().getShell(), "Creation problems", NLS.bind("Eclipse Internal error: {0}", e.getCause().getMessage())); } } }); } return newFolderHandle; }
/** * closes the shell and adds new constraint to the feature model if possible * * @param featureModel * @param constraint */ private void addConstraint() { final NodeReader nodeReader = new NodeReader(); final String input = constraintText.getText().trim(); final FeatureModel featureModel = featureController.getFeatureModel(); final Node propNode = nodeReader.stringToNode(input, featureModel.getFeatureNames()); AbstractOperation op = null; if (constraint != null && featureModel.getConstraints().contains(constraint)) { int index = 0; for (Constraint c : featureModel.getConstraints()) { if (c == constraint) { op = new ConstraintEditOperation(propNode, featureModel, index); break; } index++; } } if (op == null) { op = new ConstraintCreateOperation(propNode, featureModel); } op.addContext((IUndoContext) featureModel.getUndoContext()); featureController.addFeatureExpression(input); }
private IProject renameProjectTo( IProject project, String name ) throws ExecutionException { IProject result = project.getWorkspace().getRoot().getProject( name ); IPath path = result.getFullPath(); AbstractOperation operation = new MoveResourcesOperation( project, path, "Rename project" ); operation.execute( new NullProgressMonitor(), null ); renamedProjects.add( result ); return result; }
private void duplicateCurrentSelection(KeyEvent e) { ISelection selection = treeViewer.getSelection(); if (selection.isEmpty()) { return; // nothing to do } PlanStructureModifier modifier = getStructureModifier(); PlanTransferable source = modifier.getTransferable(selection); PlanTransferable copy = (PlanTransferable)modifier.copy(source); IStructureLocation location = modifier.getInsertionLocation(copy, selection, InsertionSemantics.AFTER); AbstractOperation op = new PlanAddOperation(copy, modifier, location); op.setLabel("Duplicate element(s)"); WidgetUtils.execute(op, getUndoContext(), e.widget, getSite()); }