Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
  
  package org.eclipse.xtext.ui.preferences;
  
 import java.util.Set;
 
 import  org.eclipse.core.resources.IProject;
 import  org.eclipse.core.resources.ResourcesPlugin;
 import  org.eclipse.core.runtime.IStatus;
 import  org.eclipse.jface.dialogs.Dialog;
 import  org.eclipse.jface.dialogs.IDialogSettings;
 import  org.eclipse.jface.viewers.DoubleClickEvent;
 import  org.eclipse.jface.viewers.IDoubleClickListener;
 import  org.eclipse.jface.viewers.ISelectionChangedListener;
 import  org.eclipse.jface.viewers.IStructuredSelection;
 import  org.eclipse.jface.viewers.SelectionChangedEvent;
 import  org.eclipse.jface.viewers.TableViewer;
 import  org.eclipse.jface.viewers.Viewer;
 import  org.eclipse.jface.viewers.ViewerFilter;
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.SelectionEvent;
 import  org.eclipse.swt.events.SelectionListener;
 import  org.eclipse.swt.graphics.Font;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.widgets.Button;
 import  org.eclipse.swt.widgets.Composite;
 import  org.eclipse.swt.widgets.Control;
 import  org.eclipse.swt.widgets.Shell;
 import  org.eclipse.ui.dialogs.SelectionStatusDialog;
 import  org.eclipse.ui.model.WorkbenchContentProvider;
 import  org.eclipse.ui.model.WorkbenchLabelProvider;
 import  org.eclipse.ui.views.navigator.ResourceComparator;

Initially copied from Jdt.

Author(s):
Michael Clay
Since:
2.1
 
 public class ProjectSelectionDialog extends SelectionStatusDialog {
 	private final static int SIZING_SELECTION_WIDGET_HEIGHT = 250;
 	private final static int SIZING_SELECTION_WIDGET_WIDTH = 300;
 	private final static String DIALOG_SETTINGS_SHOW_ALL = "ProjectSelectionDialog.show_all"//$NON-NLS-1$
 	private TableViewer tableViewer;
 	private Set<IProject> projectsWithSpecifics;
 	private ViewerFilter viewerFilter;
 	private final IDialogSettings dialogSettings;
 
 	public ProjectSelectionDialog(Shell parentShellSet<IProject> projectsWithSpecifics, IDialogSettings dialogSettings) {
 		super(parentShell);
 		this. = dialogSettings;
 		this. = projectsWithSpecifics;
 		 = new ViewerFilter() {
 			public boolean select(Viewer viewerObject parentElementObject element) {
 				return ProjectSelectionDialog.this..contains(element);
 			}
 		};
 	}
 
 	protected Control createDialogArea(Composite parent) {
 		Composite composite = (Composite) super.createDialogArea(parent);
 		Font font = parent.getFont();
 		composite.setFont(font);
 		createMessageArea(composite);
 		 = new TableViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
 		.addSelectionChangedListener(new ISelectionChangedListener() {
 			public void selectionChanged(SelectionChangedEvent event) {
 				doSelectionChanged(((IStructuredSelection) event.getSelection()).toArray());
 			}
 		});
 		.addDoubleClickListener(new IDoubleClickListener() {
 			public void doubleClick(DoubleClickEvent event) {
 			}
 		});
 		GridData data = new GridData(SWT.FILL, SWT.FILL, truetrue);
 		data.heightHint = ;
 		data.widthHint = ;
 		.getTable().setLayoutData(data);
 		.setContentProvider(new WorkbenchContentProvider());
 		.setLabelProvider(new WorkbenchLabelProvider());
 		.setComparator(new ResourceComparator(ResourceComparator.NAME));
 		.getControl().setFont(font);
 		Button checkbox = new Button(composite, SWT.CHECK);
 		checkbox.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, truefalse));
 		checkbox.addSelectionListener(new SelectionListener() {
			public void widgetSelected(SelectionEvent e) {
				updateFilter(((Button) e.widget).getSelection());
			}
			public void widgetDefaultSelected(SelectionEvent e) {
				updateFilter(((Button) e.widget).getSelection());
			}
		});
		boolean doFilter = !.getBoolean() && !.isEmpty();
		checkbox.setSelection(doFilter);
		updateFilter(doFilter);
		.setInput(ResourcesPlugin.getWorkspace());
		Dialog.applyDialogFont(composite);
		return composite;
	}
	protected void updateFilter(boolean selected) {
		if (selected) {
else {
		}
	}
	private void doSelectionChanged(Object[] objects) {
		if (objects.length != 1) {
			updateStatus(new StatusInfo(IStatus.ERROR, "")); //$NON-NLS-1$
else {
		}
	}
	protected void computeResult() {
	}
New to GrepCode? Check out our FAQ X