use of org.eclipse.jface.viewers.ICheckStateListener in project hale by halestudio.
the class LayersDialog method createDialogArea.
/**
* @see TitleAreaDialog#createDialogArea(Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
page.setLayoutData(data);
page.setLayout(new FillLayout());
CheckboxTableViewer table = CheckboxTableViewer.newCheckList(page, SWT.V_SCROLL | SWT.BORDER);
TableColumn names = new TableColumn(table.getTable(), SWT.NONE);
names.setWidth(200);
names.setText(Messages.LayersDialog_2);
TableColumn descs = new TableColumn(table.getTable(), SWT.NONE);
descs.setWidth(200);
descs.setText(Messages.LayersDialog_3);
// labels
table.setLabelProvider(new LayerLabelProvider());
table.setCheckStateProvider(new LayerCheckStateProvider());
table.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
((Layer) event.getElement()).setSelected(event.getChecked());
}
});
// content
table.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
}
@Override
public void dispose() {
// ignore
}
@Override
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
return ((List<Layer>) inputElement).toArray();
}
});
table.setInput(layers);
table.getTable().setLinesVisible(true);
table.getTable().setHeaderVisible(true);
// pack columns
names.pack();
descs.pack();
return page;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project egit by eclipse.
the class BranchSelectionDialog method createCustomArea.
@Override
protected Control createCustomArea(Composite parent) {
Composite area = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(area);
area.setLayout(new GridLayout(1, false));
if (multiMode) {
fTree = new FilteredCheckboxTree(area, null, SWT.NONE, new PatternFilter()) {
/*
* Overridden to check page when refreshing is done.
*/
@Override
protected WorkbenchJob doCreateRefreshJob() {
WorkbenchJob refreshJob = super.doCreateRefreshJob();
refreshJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
checkPage();
}
});
}
}
});
return refreshJob;
}
};
CachedCheckboxTreeViewer viewer = fTree.getCheckboxTreeViewer();
GridDataFactory.fillDefaults().grab(true, true).applyTo(fTree);
viewer.setContentProvider(new ITreeContentProvider() {
@Override
public void inputChanged(Viewer actViewer, Object oldInput, Object newInput) {
// nothing
}
@Override
public void dispose() {
// nothing
}
@Override
public boolean hasChildren(Object element) {
return false;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public Object[] getElements(Object inputElement) {
return ((List) inputElement).toArray();
}
@Override
public Object[] getChildren(Object parentElement) {
return null;
}
});
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
checkPage();
}
});
viewer.setLabelProvider(new GitLabelProvider());
viewer.setComparator(new ViewerComparator(CommonUtils.STRING_ASCENDING_COMPARATOR));
viewer.setInput(nodes);
preselectBranchMultiMode(nodes, fTree);
} else {
branchesList = new TableViewer(area, this.style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, true).applyTo(branchesList.getControl());
branchesList.setContentProvider(ArrayContentProvider.getInstance());
branchesList.setLabelProvider(new GitLabelProvider());
branchesList.setComparator(new ViewerComparator(CommonUtils.STRING_ASCENDING_COMPARATOR));
branchesList.setInput(nodes);
preselectBranchSingleMode(nodes, branchesList);
branchesList.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
checkPage();
}
});
branchesList.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
buttonPressed(OK);
}
});
}
return area;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project egit by eclipse.
the class CommitViewerComparator method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
parent.getShell().setText(UIText.CommitDialog_CommitChanges);
container = toolkit.createComposite(container);
GridDataFactory.fillDefaults().grab(true, true).applyTo(container);
toolkit.paintBordersFor(container);
GridLayoutFactory.swtDefaults().applyTo(container);
final SashForm sashForm = new SashForm(container, SWT.VERTICAL | SWT.FILL);
toolkit.adapt(sashForm, true, true);
sashForm.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
createMessageAndPersonArea(sashForm);
filesSection = createFileSection(sashForm);
sashForm.setWeights(new int[] { 50, 50 });
applyDialogFont(container);
container.pack();
commitText.setFocus();
Image titleImage = UIIcons.WIZBAN_CONNECT_REPO.createImage();
UIUtils.hookDisposal(parent, titleImage);
setTitleImage(titleImage);
setTitle(UIText.CommitDialog_Title);
if (ignoreErrors != null) {
setMessage(UIText.CommitDialog_MessageErrors, IMessageProvider.WARNING);
} else {
setMessage(UIText.CommitDialog_Message, IMessageProvider.INFORMATION);
}
filesViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateMessage();
}
});
updateFileSectionText();
return container;
}
use of org.eclipse.jface.viewers.ICheckStateListener in project egit by eclipse.
the class SourceBranchPage method createControl.
@Override
public void createControl(final Composite parent) {
final Composite panel = new Composite(parent, SWT.NULL);
final GridLayout layout = new GridLayout();
layout.numColumns = 1;
panel.setLayout(layout);
label = new Label(panel, SWT.NONE);
label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
FilteredCheckboxTree fTree = new FilteredCheckboxTree(panel, null, SWT.NONE, new PatternFilter()) {
/*
* Overridden to check page when refreshing is done.
*/
@Override
protected WorkbenchJob doCreateRefreshJob() {
WorkbenchJob refreshJob = super.doCreateRefreshJob();
refreshJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
checkPage();
}
});
}
}
});
return refreshJob;
}
};
refsViewer = fTree.getCheckboxTreeViewer();
ITreeContentProvider provider = new ITreeContentProvider() {
@Override
public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
// nothing
}
@Override
public void dispose() {
// nothing
}
@Override
public Object[] getElements(Object input) {
return ((List) input).toArray();
}
@Override
public boolean hasChildren(Object element) {
return false;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public Object[] getChildren(Object parentElement) {
return null;
}
};
refsViewer.setContentProvider(provider);
refsViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (((Ref) element).getName().startsWith(Constants.R_HEADS))
return ((Ref) element).getName().substring(Constants.R_HEADS.length());
return ((Ref) element).getName();
}
@Override
public Image getImage(Object element) {
return RepositoryTreeNodeType.REF.getIcon();
}
});
refsViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
checkPage();
}
});
final Composite bPanel = new Composite(panel, SWT.NONE);
bPanel.setLayout(new RowLayout());
selectB = new Button(bPanel, SWT.PUSH);
selectB.setText(UIText.SourceBranchPage_selectAll);
selectB.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
refsViewer.setAllChecked(true);
checkPage();
}
});
unselectB = new Button(bPanel, SWT.PUSH);
unselectB.setText(UIText.SourceBranchPage_selectNone);
unselectB.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
refsViewer.setAllChecked(false);
checkPage();
}
});
bPanel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
Dialog.applyDialogFont(panel);
setControl(panel);
checkPage();
}
use of org.eclipse.jface.viewers.ICheckStateListener in project egit by eclipse.
the class GitProjectsImportPage method createProjectsList.
/**
* Create the checkbox list for the found projects.
*
* @param workArea
*/
private void createProjectsList(Composite workArea) {
Label title = new Label(workArea, SWT.NONE);
title.setText(UIText.WizardProjectsImportPage_ProjectsListTitle);
Composite listComposite = new Composite(workArea, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 0;
layout.makeColumnsEqualWidth = false;
listComposite.setLayout(layout);
listComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
PatternFilter filter = new PatternFilter() {
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
if (getCheckedProjects().contains(element))
return true;
if (element instanceof ProjectRecord) {
ProjectRecord p = (ProjectRecord) element;
if (wordMatches(p.getProjectName()))
return true;
String projectPath = p.getProjectSystemFile().getParent();
if (projectPath.startsWith(lastPath)) {
String distinctPath = projectPath.substring(lastPath.length());
return wordMatches(distinctPath);
} else {
return wordMatches(projectPath);
}
}
return false;
}
};
filter.setIncludeLeadingWildcard(true);
FilteredCheckboxTree filteredTree = new FilteredCheckboxTree(listComposite, null, SWT.NONE, filter);
filteredTree.setInitialText(UIText.WizardProjectsImportPage_filterText);
projectsList = filteredTree.getCheckboxTreeViewer();
GridData listData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
projectsList.getControl().setLayoutData(listData);
projectsList.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
ProjectRecord element = (ProjectRecord) event.getElement();
if (isProjectInWorkspace(element.getProjectName())) {
projectsList.setChecked(element, false);
}
enableSelectAllButtons();
}
});
// a bug in the CachedCheckboxTreeView requires us to not return null
final Object[] children = new Object[0];
projectsList.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
return children;
}
@Override
public Object[] getElements(Object inputElement) {
return selectedProjects;
}
@Override
public boolean hasChildren(Object element) {
return false;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public void dispose() {
// ignore
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
}
});
projectsList.getTree().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
checkPageComplete();
}
});
projectsList.setLabelProvider(new ProjectLabelProvider());
projectsList.setInput(this);
projectsList.setComparator(new ViewerComparator());
createSelectionButtons(listComposite);
}
Aggregations