org.eclipse.ui.dialogs.ListSelectionDialog Java Examples

The following examples show how to use org.eclipse.ui.dialogs.ListSelectionDialog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EPackageChooser.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public List<EPackageInfo> open() {
	final Iterable<IResource> resourcesContainingGenModels = findResourcesContainingGenModels();
	ListSelectionDialog listSelectionDialog = new ListSelectionDialog(shell, resourcesContainingGenModels,
			new ContentProvider(), new LabelProvider(), Messages.EPackageChooser_ChooseGenModel);
	int result = listSelectionDialog.open();
	if (result == Window.OK) {
		List<EPackageInfo> ePackageInfos = Lists.newArrayList();
		for (Object selection : listSelectionDialog.getResult()) {
			if (selection instanceof IFile) {
				IFile file = (IFile) selection;
				URI genModelURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
				ePackageInfos.addAll(createEPackageInfosFromGenModel(genModelURI));
			}
		}
		return ePackageInfos;
	}
	return Collections.emptyList();
}
 
Example #2
Source File: ProjectsWorkbookPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private CPListElement[] addProjectDialog() {

		try {
			Object[] selectArr= getNotYetRequiredProjects();
			new JavaElementComparator().sort(null, selectArr);

			ListSelectionDialog dialog= new ListSelectionDialog(getShell(), Arrays.asList(selectArr), new ArrayContentProvider(), new JavaUILabelProvider(), NewWizardMessages.ProjectsWorkbookPage_chooseProjects_message);
			dialog.setTitle(NewWizardMessages.ProjectsWorkbookPage_chooseProjects_title);
			dialog.setHelpAvailable(false);
			if (dialog.open() == Window.OK) {
				Object[] result= dialog.getResult();
				CPListElement[] cpElements= new CPListElement[result.length];
				for (int i= 0; i < result.length; i++) {
					IJavaProject curr= (IJavaProject) result[i];
					cpElements[i]= new CPListElement(fCurrJProject, IClasspathEntry.CPE_PROJECT, curr.getPath(), curr.getResource());
				}
				return cpElements;
			}
		} catch (JavaModelException e) {
			return null;
		}
		return null;
	}
 
Example #3
Source File: AssignWorkingSetsAction.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the dialog for working set assignment.
 *
 * @param workingSets
 *            All the working set the user should be able to select from
 * @param numberOfSelectedProjects
 *            The number of selected projects
 */
private ListSelectionDialog createDialog(Collection<WorkingSet> workingSets, int numberOfSelectedProjects) {
	// Filter 'Other Projects' working set
	List<WorkingSet> selectableWorkingSets = workingSets.stream()
			.filter(set -> !set.getId().equals(WorkingSet.OTHERS_WORKING_SET_ID)).collect(Collectors.toList());

	String message = String.format(DIALOG_SUBTITLE, numberOfSelectedProjects);

	ListSelectionDialog dialog = new NonEmptyListSelectionDialog(site.getShell(),
			selectableWorkingSets, ArrayContentProvider.getInstance(), WorkingSetLabelProvider.INSTANCE, message);

	dialog.setTitle(DIALOG_TITLE);
	return dialog;
}
 
Example #4
Source File: InputComponent.java    From corrosion with Eclipse Public License 2.0 5 votes vote down vote up
public void createProjectSelection() {
	createSelectionButton();
	browseButton.addSelectionListener(widgetSelectedAdapter(e -> {
		ListSelectionDialog dialog = new ListSelectionDialog(browseButton.getShell(),
				ResourcesPlugin.getWorkspace().getRoot(), new BaseWorkbenchContentProvider(),
				new WorkbenchLabelProvider(), this.labelString);
		dialog.setTitle(Messages.LaunchUI_selection);
		int returnCode = dialog.open();
		Object[] results = dialog.getResult();
		if (returnCode == 0 && results.length > 0) {
			text.setText(((IProject) results[0]).getName());
			editListener.modifyText(null);
		}
	}));
}
 
Example #5
Source File: SaveUtils.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
private static Object[] openSaveDialog(Shell shell, Collection<IEditorPart> editors) {
	ListSelectionDialog lsd = new ListSelectionDialog(shell, editors, new ArrayContentProvider(),
			getLabelProvider(), "Select resources to save:");
	lsd.setInitialSelections(editors.toArray());
	lsd.setTitle("Save and Launch");
	lsd.open();

	return lsd.getResult();
}
 
Example #6
Source File: IDEClassPathBlock.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private IDECPListElement[] addProjectDialog( )
{

	try
	{
		Object[] selectArr = getNotYetRequiredProjects( );
		new JavaElementComparator( ).sort( null, selectArr );

		ListSelectionDialog dialog = new ListSelectionDialog( getShell( ),
				Arrays.asList( selectArr ),
				new ArrayContentProvider( ),
				new ProjectLabelProvider( ),
				Messages.getString("IDEClassPathBlock.ProjectDialog_message") ); //$NON-NLS-1$
		dialog.setTitle( Messages.getString("IDEClassPathBlock.ProjectDialog_title") ); //$NON-NLS-1$
		dialog.setHelpAvailable( false );
		if ( dialog.open( ) == Window.OK )
		{
			Object[] result = dialog.getResult( );
			IDECPListElement[] cpElements = new IDECPListElement[result.length];
			for ( int i = 0; i < result.length; i++ )
			{
				IJavaProject curr = ( (IJavaProject) result[i] );
				cpElements[i] = new IDECPListElement( IClasspathEntry.CPE_PROJECT,
						curr.getPath( ),
						curr.getResource( ) );
			}
			return cpElements;
		}
	}
	catch ( JavaModelException e )
	{
		return null;
	}
	return null;
}
 
Example #7
Source File: SVNDecoratorPreferencesPage.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Add another variable to the given target. The variable is inserted at current position
    * A ListSelectionDialog is shown and the choose the variables to add 
 */
private void addVariables(Text target, Map bindings) {

	final List variables = new ArrayList(bindings.size());
	
	ILabelProvider labelProvider = new LabelProvider() {
		public String getText(Object element) {
			return ((StringPair)element).s1 + " - " + ((StringPair)element).s2; //$NON-NLS-1$
		}
	};
	
	IStructuredContentProvider contentsProvider = new IStructuredContentProvider() {
		public Object[] getElements(Object inputElement) {
			return variables.toArray(new StringPair[variables.size()]);
		}
		public void dispose() {}
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
	};
	
	for (Iterator it = bindings.keySet().iterator(); it.hasNext();) {
		StringPair variable = new StringPair();
		variable.s1 = (String) it.next(); // variable
		variable.s2 = (String) bindings.get(variable.s1); // description
		variables.add(variable);				
	}

	ListSelectionDialog dialog =
		new ListSelectionDialog(
			this.getShell(),
			this,
			contentsProvider,
			labelProvider,
			Policy.bind("SVNDecoratorPreferencesPage.selectVariablesToAdd")); //$NON-NLS-1$
	dialog.setTitle(Policy.bind("SVNDecoratorPreferencesPage.AddVariables")); //$NON-NLS-1$
	if (dialog.open() != ListSelectionDialog.OK)
		return;

	Object[] result = dialog.getResult();
	
	for (int i = 0; i < result.length; i++) {
		target.insert("{"+((StringPair)result[i]).s1 +"}"); //$NON-NLS-1$ //$NON-NLS-2$
	}		
}