use of org.eclipse.jface.viewers.CheckStateChangedEvent 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.CheckStateChangedEvent 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);
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project egit by eclipse.
the class PushTagsPage method createControl.
@Override
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(GridLayoutFactory.swtDefaults().spacing(LayoutConstants.getSpacing()).numColumns(2).create());
Label remoteLabel = new Label(main, SWT.NONE);
remoteLabel.setText(UIText.PushTagsPage_RemoteLabel);
RemoteSelectionCombo remoteSelectionCombo = new RemoteSelectionCombo(main, SWT.NONE, SelectionType.PUSH);
remoteSelectionCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
selectedRemoteConfig = remoteSelectionCombo.setItems(getRemoteConfigs());
remoteSelectionCombo.addRemoteSelectionListener(new RemoteSelectionCombo.IRemoteSelectionListener() {
@Override
public void remoteSelected(RemoteConfig remoteConfig) {
selectedRemoteConfig = remoteConfig;
}
});
tagsLabel = new Label(main, SWT.NONE);
tagsLabel.setText(UIText.PushTagsPage_TagsLabelNoneSelected);
tagsLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
FilteredCheckboxTree tree = new FilteredCheckboxTree(main, null, SWT.BORDER);
tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(400, 300).create());
final Button forceUpdateButton = new Button(main, SWT.CHECK);
forceUpdateButton.setText(UIText.PushTagsPage_ForceUpdateButton);
forceUpdateButton.setSelection(false);
forceUpdateButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
forceUpdateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
forceUpdateSelected = forceUpdateButton.getSelection();
}
});
final CachedCheckboxTreeViewer treeViewer = tree.getCheckboxTreeViewer();
TagsNode tagsNode = new TagsNode(null, repository);
ContentProvider contentProvider = new ContentProvider(tagsNode);
treeViewer.setContentProvider(contentProvider);
treeViewer.setLabelProvider(new RepositoriesViewStyledCellLabelProvider());
treeViewer.setComparator(new ViewerComparator(CommonUtils.STRING_ASCENDING_COMPARATOR));
treeViewer.setInput(tagsNode);
final Object[] tagNodes = contentProvider.getElements(tagsNode);
initiallySelectTags(tagNodes, treeViewer);
treeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
setSelectedTags(treeViewer.getCheckedElements());
}
});
setControl(main);
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project egit by eclipse.
the class CleanRepositoryPage method createControl.
@Override
public void createControl(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
main.setLayout(new GridLayout());
final Button radioCleanFiles = new Button(main, SWT.RADIO);
radioCleanFiles.setText(UIText.CleanRepositoryPage_cleanFiles);
GridDataFactory.fillDefaults().grab(true, false).applyTo(radioCleanFiles);
final Button radioCleanDirs = new Button(main, SWT.RADIO);
radioCleanDirs.setText(UIText.CleanRepositoryPage_cleanDirs);
GridDataFactory.fillDefaults().grab(true, false).applyTo(radioCleanDirs);
SelectionAdapter listener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
cleanDirectories = radioCleanDirs.getSelection();
updateCleanItems();
}
};
radioCleanFiles.addSelectionListener(listener);
radioCleanDirs.addSelectionListener(listener);
radioCleanFiles.setSelection(true);
final Image fileImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
final Image dirImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
cleanTable = CheckboxTableViewer.newCheckList(main, SWT.BORDER);
cleanTable.setContentProvider(ArrayContentProvider.getInstance());
cleanTable.setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
if (!(element instanceof String))
return null;
if (// $NON-NLS-1$
((String) element).endsWith("/"))
return dirImage;
else
return fileImage;
}
});
setPageComplete(false);
cleanTable.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updatePageComplete();
}
});
GridDataFactory.fillDefaults().grab(true, true).applyTo(cleanTable.getControl());
Composite lowerComp = new Composite(main, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(lowerComp);
lowerComp.setLayout(new GridLayout(3, false));
final Button checkIncludeIgnored = new Button(lowerComp, SWT.CHECK);
checkIncludeIgnored.setText(UIText.CleanRepositoryPage_includeIgnored);
GridDataFactory.fillDefaults().grab(true, false).applyTo(checkIncludeIgnored);
checkIncludeIgnored.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
includeIgnored = checkIncludeIgnored.getSelection();
updateCleanItems();
}
});
Button selAll = new Button(lowerComp, SWT.PUSH);
selAll.setText(UIText.WizardProjectsImportPage_selectAll);
GridDataFactory.defaultsFor(selAll).applyTo(selAll);
Button selNone = new Button(lowerComp, SWT.PUSH);
selNone.setText(UIText.WizardProjectsImportPage_deselectAll);
GridDataFactory.defaultsFor(selNone).applyTo(selNone);
selAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (cleanTable.getInput() instanceof Set<?>) {
Set<?> input = (Set<?>) cleanTable.getInput();
cleanTable.setCheckedElements(input.toArray());
updatePageComplete();
}
}
});
selNone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
cleanTable.setCheckedElements(new Object[0]);
updatePageComplete();
}
});
setControl(main);
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project egit by eclipse.
the class CommitSearchPage method addRepositoryControl.
private void addRepositoryControl(Composite parent) {
repositoryGroup = new Group(parent, SWT.NONE);
repositoryGroup.setBackgroundMode(SWT.INHERIT_DEFAULT);
GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(repositoryGroup);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(repositoryGroup);
this.repositoryViewer = CheckboxTableViewer.newCheckList(repositoryGroup, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
this.repositoryViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new RepositoriesViewLabelProvider()));
this.repositoryViewer.setContentProvider(new RepositoriesViewContentProvider());
this.repositoryViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
this.repositoryViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateOKStatus();
repositoryGroup.setText(getRepositoryText());
}
});
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 40).applyTo(this.repositoryViewer.getControl());
ToolBar checkBar = new ToolBar(repositoryGroup, SWT.FLAT | SWT.VERTICAL);
GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).grab(false, true).applyTo(checkBar);
ToolItem checkItem = new ToolItem(checkBar, SWT.PUSH);
checkItem.setToolTipText(UIText.CommitSearchPage_CheckAll);
Image checkImage = UIIcons.CHECK_ALL.createImage();
UIUtils.hookDisposal(checkItem, checkImage);
checkItem.setImage(checkImage);
checkItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
repositoryViewer.setAllChecked(true);
repositoryGroup.setText(getRepositoryText());
updateOKStatus();
}
});
ToolItem uncheckItem = new ToolItem(checkBar, SWT.PUSH);
uncheckItem.setToolTipText(UIText.CommitSearchPage_UncheckAll);
Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
UIUtils.hookDisposal(uncheckItem, uncheckImage);
uncheckItem.setImage(uncheckImage);
uncheckItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
repositoryViewer.setAllChecked(false);
repositoryGroup.setText(getRepositoryText());
updateOKStatus();
}
});
this.searchAllBranchesButton = new Button(repositoryGroup, SWT.CHECK);
this.searchAllBranchesButton.setText(UIText.CommitSearchPage_SearchAllBranches);
GridDataFactory.swtDefaults().grab(true, false).span(2, 1).applyTo(this.searchAllBranchesButton);
repositoryGroup.setText(getRepositoryText());
}
Aggregations