/** * Handles the project browse button. */ private void handleBrowse() { FilteredItemsSelectionDialog dialog = new FilteredResourcesSelectionDialog(getShell(), false, ResourcesPlugin.getWorkspace().getRoot(), IResource.PROJECT); dialog.setTitle("Browse..."); String path = project.getText(); if (path != null && path.length() > 0 && new Path(path).lastSegment().length() > 0) { dialog.setInitialPattern(new Path(path).lastSegment()); } else { dialog.setInitialPattern("**"); } dialog.open(); if (dialog.getResult() != null && dialog.getResult().length > 0 && dialog.getResult()[0] instanceof IProject) { project.setText(((IProject)dialog.getResult()[0]).getFullPath().toString()); } }
/** * Main-method to start the dialog. * * @param params * is not used in this context. * @param manager * is not used in this context. */ @Override public void run(String[] params, ICheatSheetManager manager) { FilteredItemsSelectionDialog typeSelectionDialog = initTypeDialog(dialogTitle); int dialogResult = typeSelectionDialog.open(); if (dialogResult != Window.OK) { notifyResult(false); } else { IType type = (IType) typeSelectionDialog.getResult()[0]; Optional<ConcreteClassifier> classifier = JaMoPPRoutines.getConcreteClassifierOf(type); if (classifier.isPresent()) { processFoundClassifier(classifier.get()); notifyResult(true); } else { openErrorMessage(); notifyResult(false); } } }
private OpenResourceDialog createManageSelectionDialog(String message) { OpenResourceDialog resourceDialog = new OpenResourceDialog(EditorUtils.getShell(), selectedProject, IResource.FILE); try { //Hack warning: changing the multi internal field to false because we don't want a multiple selection //(but the OpenResourceDialog didn't make available an API to change that -- even though //it'd be possible to create a FilteredItemsSelectionDialog in single selection mode) Field field = FilteredItemsSelectionDialog.class.getDeclaredField("multi"); field.setAccessible(true); field.set(resourceDialog, false); } catch (Throwable e) { //just ignore any error here } resourceDialog.setInitialPattern("manage.py"); resourceDialog.setMessage(message); return resourceDialog; }
private OpenTypeClassHolder[] getType(Shell shell, Map<String, OpenTypeClassHolder> resources) { FilteredItemsSelectionDialog filteredDialog = new FilteredApexResourcesSelectionDialog(shell, resources); if (filteredDialog.open() == Window.OK) { Object[] selected = filteredDialog.getResult(); if (selected.length > 0) { return Arrays.copyOf(selected, selected.length, OpenTypeClassHolder[].class); } } return null; }
/** * Opens the FilteredItemSelectionDialog. * * @param dialogTitle * represent the title of the dialog. * @return returns the dialog. */ protected FilteredItemsSelectionDialog initTypeDialog(String dialogTitle) { final Shell parentShell = Display.getCurrent().getActiveShell(); final Iterable<IProject> leadingProjects = WorkspaceUtil .transformProjectNamesToProjects(CASLicenseHandlerConfiguration.getInstance().getConsolidationProject() .getLeadingProjects()); return new ScopedOpenTypeSelectionDialog(parentShell, dialogTitle, leadingProjects); }