类org.eclipse.ui.dialogs.ListSelectionDialog源码实例Demo

下面列出了怎么用org.eclipse.ui.dialogs.ListSelectionDialog的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xtext-eclipse   文件: EPackageChooser.java
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();
}
 
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;
	}
 
源代码3 项目: n4js   文件: AssignWorkingSetsAction.java
/**
 * 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;
}
 
源代码4 项目: corrosion   文件: InputComponent.java
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);
		}
	}));
}
 
源代码5 项目: txtUML   文件: SaveUtils.java
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();
}
 
源代码6 项目: birt   文件: IDEClassPathBlock.java
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;
}
 
/**
 * 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$
	}		
}
 
 类所在包
 同包方法