use of org.eclipse.jface.viewers.ICheckStateListener 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.ICheckStateListener 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.ICheckStateListener 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());
}
use of org.eclipse.jface.viewers.ICheckStateListener in project InformationSystem by ObeoNetwork.
the class ChooseTypesAndReferencesPage method createControl.
/**
* Create contents of the wizard.
* @param parent
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NULL);
setControl(container);
container.setLayout(new GridLayout(2, true));
Label lblTypes = new Label(container, SWT.NONE);
lblTypes.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
lblTypes.setText("Types :");
Label lblReferences = new Label(container, SWT.NONE);
lblReferences.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
lblReferences.setText("References :");
typesTreeViewer = new CheckboxTreeViewer(container, SWT.BORDER);
typesTreeViewer.setUseHashlookup(true);
final Tree typesTree = typesTreeViewer.getTree();
typesTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
typesTreeViewer.setContentProvider(new StructuredTypesContentProvider(sourceTypeName));
typesTreeViewer.setLabelProvider(labelProvider);
typesTreeViewer.setSorter(new ViewerSorter());
referencesTreeViewer = new CheckboxTreeViewer(container, SWT.BORDER);
referencesTreeViewer.setUseHashlookup(true);
Tree referencesTree = referencesTreeViewer.getTree();
referencesTree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
referencesTreeViewer.setContentProvider(new ArrayTreeContentProvider());
referenceLabelProvider = new ReferenceLabelProvider();
referencesTreeViewer.setLabelProvider(referenceLabelProvider);
referencesTreeViewer.setSorter(new ViewerSorter());
typesTreeViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
// Check/uncheck all subtree
typesTreeViewer.setSubtreeChecked(event.getElement(), event.getChecked());
Collection<StructuredType> checkedTypes = getCheckedTypes();
setPageComplete(!checkedTypes.isEmpty());
List<Reference> references = referencesServices.getReferencesBetweenTypes(checkedTypes);
referencesTreeViewer.setInput(references);
}
});
initContents();
}
use of org.eclipse.jface.viewers.ICheckStateListener in project InformationSystem by ObeoNetwork.
the class UserStoriesView method createPartControl.
/**
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
public void createPartControl(Composite parent) {
viewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.setUseHashlookup(true);
viewer.setContentProvider(new UserStoriesContentProvider());
viewer.setLabelProvider(new UserStoryLabelProvider(this, adapterFactory));
viewer.setCheckStateProvider(new UserStoriesCheckStateProvider(viewer));
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getElement() instanceof UserStory) {
UserStory story = (UserStory) event.getElement();
if (viewer.getInput() instanceof UserStoryElement) {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(viewer.getInput());
if (editingDomain != null) {
if (event.getChecked()) {
LinkStory command = new LinkStory(story, (UserStoryElement) viewer.getInput());
editingDomain.getCommandStack().execute(command);
} else {
UnlinkStory command = new UnlinkStory(story, (UserStoryElement) viewer.getInput());
editingDomain.getCommandStack().execute(command);
}
}
} else if (viewer.getInput() instanceof Collection<?>) {
List<UserStoryElement> selection = new ArrayList<UserStoryElement>();
for (Object next : (Collection<?>) viewer.getInput()) {
if (next instanceof UserStoryElement) {
selection.add((UserStoryElement) next);
}
}
if (!selection.isEmpty()) {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(selection.get(0));
if (editingDomain != null) {
if (event.getChecked()) {
LinkStory command = new LinkStory(story, selection);
editingDomain.getCommandStack().execute(command);
} else {
UnlinkStory command = new UnlinkStory(story, selection);
editingDomain.getCommandStack().execute(command);
}
}
}
}
}
viewer.refresh();
}
});
ColumnViewerToolTipSupport.enableFor(viewer);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
State state = service.getCommand(HighlightUserStoryCommand.COMMAND_ID).getState(HighlightUserStoryCommand.STATE_ID);
state.setValue(getSelectedStories().size() == 1 && isActiveUserStory(getSelectedStories().get(0)));
service.refreshElements(HighlightUserStoryCommand.COMMAND_ID, null);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
updateUserStoryHighlightment();
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
State state = service.getCommand(HighlightUserStoryCommand.COMMAND_ID).getState(HighlightUserStoryCommand.STATE_ID);
state.setValue(getSelectedStories().size() == 1 && isActiveUserStory(getSelectedStories().get(0)));
service.refreshElements(HighlightUserStoryCommand.COMMAND_ID, null);
}
});
getSite().setSelectionProvider(viewer);
selectionListener = new ViewpointMultiSelectionListener(this) {
@Override
protected void eObjectSelected(Session session, List<EObject> selectedEObjects) {
update(session, selectedEObjects);
}
};
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
}
Aggregations