protected void newFolderButtonPressed() { NewFolderDialog dialog = new NewFolderDialog(getShell(), fSelectedContainer); if (dialog.open() == Window.OK) { TreeViewer treeViewer = getTreeViewer(); treeViewer.refresh(fSelectedContainer); Object createdFolder = dialog.getResult()[0]; treeViewer.reveal(createdFolder); treeViewer.setSelection(new StructuredSelection(createdFolder)); } }
protected void newFolderButtonPressed() { NewFolderDialog dialog= new NewFolderDialog(getShell(), fSelectedContainer); if (dialog.open() == Window.OK) { CheckboxTreeViewer treeViewer= fViewer; treeViewer.refresh(fSelectedContainer); Object createdFolder= dialog.getResult()[0]; treeViewer.reveal(createdFolder); treeViewer.setChecked(createdFolder, true); treeViewer.setSelection(new StructuredSelection(createdFolder)); updateOKStatus(); } }
private PathListElement openNewFolderDialog(PathListElement existing) { NewFolderDialog dialog = new NewFolderDialog(getShell(), project); dialog.setTitle("Create new folder..."); if (dialog.open() == Window.OK) { IResource createdFolder = (IResource) dialog.getResult()[0]; return newFolderElement(createdFolder); } return null; }
protected Object createFolder(IContainer container) { NewFolderDialog dialog= new NewFolderDialog(getShell(), container); if (dialog.open() == Window.OK) { return dialog.getResult()[0]; } return null; }
/** * Shows the UI to create a new source folder. * * @param shell The parent shell for the dialog, can be <code>null</code> * @param project the Java project to create the source folder for * @return returns the query */ public static ICreateFolderQuery getDefaultCreateFolderQuery(final Shell shell, final IJavaProject project) { return new ICreateFolderQuery() { private IFolder fNewFolder; public boolean doQuery() { final boolean[] isOK= {false}; Display.getDefault().syncExec(new Runnable() { public void run() { Shell sh= shell != null ? shell : JavaPlugin.getActiveWorkbenchShell(); NewFolderDialog dialog= new NewFolderDialog(sh, project.getProject()); isOK[0]= dialog.open() == Window.OK; if (isOK[0]) { IResource sourceContainer= (IResource) dialog.getResult()[0]; if (sourceContainer instanceof IFolder) { fNewFolder= (IFolder)sourceContainer; } else { fNewFolder= null; } } } }); return isOK[0]; } public boolean isSourceFolder() { return true; } public IFolder getCreatedFolder() { return fNewFolder; } }; }
protected void newFolderButtonPressed() { NewFolderDialog dialog= new NewFolderDialog(getShell(), fSelectedContainer); if (dialog.open() == Window.OK) { TreeViewer treeViewer= getTreeViewer(); treeViewer.refresh(fSelectedContainer); Object createdFolder= dialog.getResult()[0]; treeViewer.reveal(createdFolder); treeViewer.setSelection(new StructuredSelection(createdFolder)); } }
public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) { // 导航视图处于激活状态 IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view"); StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider() .getSelection(); if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { List<?> lstObj = ((IStructuredSelection) selection).toList(); if (lstObj == null || lstObj.size() != 1) { MessageDialog.openInformation(shell, Messages.getString("handlers.NewFolderHandler.msgTitle"), Messages.getString("handlers.NewFolderHandler.msg1")); return null; } IContainer container = null; for (Object obj : lstObj) { if (obj instanceof IFile) { IFile file = (IFile) obj; container = file.getParent(); } else if (obj instanceof IFolder) { container = (IFolder) obj; } else if (obj instanceof IProject) { container = (IProject) obj; } } ResourcesPlugin.getPlugin().getPluginPreferences().setValue(ResourcesPlugin.PREF_DISABLE_LINKING, true); NewFolderDialog dialog = new NewFolderDialog(shell, container); dialog.open(); } else { MessageDialog.openInformation(shell, Messages.getString("handlers.NewFolderHandler.msgTitle"), Messages.getString("handlers.NewFolderHandler.msg2")); return null; } } else { MessageDialog.openInformation(shell, Messages.getString("handlers.NewFolderHandler.msgTitle"), Messages.getString("handlers.NewFolderHandler.msg2")); return null; } return null; }