use of org.eclipse.jface.viewers.CheckStateChangedEvent in project egit by eclipse.
the class GitTraceConfigurationDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(3, false));
platformSwitch = new Button(main, SWT.CHECK);
platformSwitch.setText(UIText.GitTraceConfigurationDialog_PlatformSwitchCheckbox);
GridDataFactory.fillDefaults().span(3, 1).applyTo(platformSwitch);
platformSwitch.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEnablement();
}
});
tv = new CheckboxTreeViewer(main, SWT.BORDER);
tv.setContentProvider(new TraceTableContentProvider(optionsMap));
Tree tree = tv.getTree();
GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(tree);
// enable testing with SWTBot
// $NON-NLS-1$ //$NON-NLS-2$
tree.setData("org.eclipse.swtbot.widget.key", "LocationTree");
TreeColumn c1 = new TreeColumn(tree, SWT.NONE);
c1.setWidth(400);
c1.setText(UIText.GitTraceConfigurationDialog_LocationHeader);
tree.setHeaderVisible(true);
Label fileLabel = new Label(main, SWT.NONE);
fileLabel.setText(UIText.GitTraceConfigurationDialog_TraceFileLocationLabel);
traceFileLocation = new Text(main, SWT.BORDER);
traceFileLocation.setEditable(false);
GridDataFactory.defaultsFor(traceFileLocation).grab(true, false).applyTo(traceFileLocation);
Button openButton = new Button(main, SWT.PUSH);
openButton.setText(UIText.GitTraceConfigurationDialog_OpenInEditorButton);
openButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IFileStore store = EFS.getLocalFileSystem().getStore(new Path(traceFileLocation.getText()));
try {
IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), new FileStoreEditorInput(store), EditorsUI.DEFAULT_TEXT_EDITOR_ID);
} catch (PartInitException ex) {
Activator.handleError(ex.getMessage(), ex, true);
}
}
});
initValues();
platformSwitch.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setDirty(true);
}
});
tv.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
setDirty(true);
}
});
Dialog.applyDialogFont(main);
return main;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project egit by eclipse.
the class CommitViewerComparator method createFileSection.
private Section createFileSection(Composite container) {
Section filesSection = toolkit.createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.CLIENT_INDENT);
GridDataFactory.fillDefaults().grab(true, true).applyTo(filesSection);
Composite filesArea = toolkit.createComposite(filesSection);
filesSection.setClient(filesArea);
toolkit.paintBordersFor(filesArea);
GridLayoutFactory.fillDefaults().extendedMargins(2, 2, 2, 2).applyTo(filesArea);
ToolBar filesToolbar = new ToolBar(filesSection, SWT.FLAT);
filesSection.setTextClient(filesToolbar);
PatternFilter patternFilter = new PatternFilter() {
@Override
protected boolean isLeafMatch(Viewer viewer, Object element) {
if (element instanceof CommitItem) {
CommitItem commitItem = (CommitItem) element;
return wordMatches(commitItem.path);
}
return super.isLeafMatch(viewer, element);
}
};
patternFilter.setIncludeLeadingWildcard(true);
FilteredCheckboxTree resourcesTreeComposite = new FilteredCheckboxTree(filesArea, toolkit, SWT.FULL_SELECTION, patternFilter) {
@Override
protected WorkbenchJob doCreateRefreshJob() {
// workaround for file filter not having an explicit change
// listener
WorkbenchJob filterJob = super.doCreateRefreshJob();
filterJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
updateFileSectionText();
}
});
}
}
});
return filterJob;
}
};
Tree resourcesTree = resourcesTreeComposite.getViewer().getTree();
resourcesTree.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
resourcesTreeComposite.setLayoutData(GridDataFactory.fillDefaults().hint(600, 200).grab(true, true).create());
resourcesTree.addSelectionListener(new CommitItemSelectionListener());
resourcesTree.setHeaderVisible(true);
if (getPreferenceStore().getBoolean(UIPreferences.WARN_BEFORE_COMMITTING) && getPreferenceStore().getBoolean(UIPreferences.BLOCK_COMMIT)) {
ignoreErrors = new Button(resourcesTreeComposite, SWT.CHECK);
ignoreErrors.setText(UIText.CommitDialog_IgnoreErrors);
ignoreErrors.setSelection(false);
ignoreErrors.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Button button = (Button) e.getSource();
boolean enable = button.getSelection();
updateMessage();
updateCommitButtons(enable);
}
});
}
TreeColumn statCol = new TreeColumn(resourcesTree, SWT.LEFT);
statCol.setText(UIText.CommitDialog_Status);
statCol.setWidth(150);
statCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByStatus));
TreeColumn resourceCol = new TreeColumn(resourcesTree, SWT.LEFT);
resourceCol.setText(UIText.CommitDialog_Path);
resourceCol.setWidth(415);
resourceCol.addSelectionListener(new HeaderSelectionListener(CommitItem.Order.ByFile));
filesViewer = resourcesTreeComposite.getCheckboxTreeViewer();
new TreeViewerColumn(filesViewer, statCol).setLabelProvider(createStatusLabelProvider());
new TreeViewerColumn(filesViewer, resourceCol).setLabelProvider(new CommitPathLabelProvider());
ColumnViewerToolTipSupport.enableFor(filesViewer);
filesViewer.setContentProvider(new CommitFileContentProvider());
filesViewer.setUseHashlookup(true);
IDialogSettings settings = org.eclipse.egit.ui.Activator.getDefault().getDialogSettings();
if (settings.get(SHOW_UNTRACKED_PREF) != null) {
// note, no matter how the dialog settings are, if
// the preferences force us to include untracked files
// we must show them
showUntracked = Boolean.valueOf(settings.get(SHOW_UNTRACKED_PREF)).booleanValue() || getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
}
filesViewer.addFilter(new CommitItemFilter());
filesViewer.setInput(items.toArray());
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(createContextMenuListener());
filesViewer.getTree().setMenu(menuManager.createContextMenu(filesViewer.getTree()));
filesViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
updateFileSectionText();
}
});
showUntrackedItem = new ToolItem(filesToolbar, SWT.CHECK);
Image showUntrackedImage = UIIcons.UNTRACKED_FILE.createImage();
UIUtils.hookDisposal(showUntrackedItem, showUntrackedImage);
showUntrackedItem.setImage(showUntrackedImage);
showUntrackedItem.setToolTipText(UIText.CommitDialog_ShowUntrackedFiles);
showUntrackedItem.setSelection(showUntracked);
showUntrackedItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showUntracked = showUntrackedItem.getSelection();
filesViewer.refresh(true);
updateFileSectionText();
updateMessage();
}
});
ToolItem checkAllItem = new ToolItem(filesToolbar, SWT.PUSH);
Image checkImage = UIIcons.CHECK_ALL.createImage();
UIUtils.hookDisposal(checkAllItem, checkImage);
checkAllItem.setImage(checkImage);
checkAllItem.setToolTipText(UIText.CommitDialog_SelectAll);
checkAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
filesViewer.setAllChecked(true);
updateFileSectionText();
updateMessage();
}
});
ToolItem uncheckAllItem = new ToolItem(filesToolbar, SWT.PUSH);
Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
uncheckAllItem.setImage(uncheckImage);
uncheckAllItem.setToolTipText(UIText.CommitDialog_DeselectAll);
uncheckAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
filesViewer.setAllChecked(false);
updateFileSectionText();
updateMessage();
}
});
if (!allowToChangeSelection) {
amendingItem.setSelection(false);
amendingItem.setEnabled(false);
showUntrackedItem.setSelection(false);
showUntrackedItem.setEnabled(false);
checkAllItem.setEnabled(false);
uncheckAllItem.setEnabled(false);
filesViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
if (!event.getChecked())
filesViewer.setAllChecked(true);
updateFileSectionText();
}
});
filesViewer.setAllChecked(true);
} else {
final boolean includeUntracked = getPreferenceStore().getBoolean(UIPreferences.COMMIT_DIALOG_INCLUDE_UNTRACKED);
for (CommitItem item : items) {
if (!preselectAll && !preselectedFiles.contains(item.path))
continue;
if (item.status == Status.ASSUME_UNCHANGED)
continue;
if (!includeUntracked && item.status == Status.UNTRACKED)
continue;
filesViewer.setChecked(item, true);
}
}
statCol.pack();
resourceCol.pack();
return filesSection;
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project egit by eclipse.
the class RepositorySearchDialog method createControl.
@Override
public void createControl(Composite parent) {
setMessage(UIText.RepositorySearchDialog_searchRepositoriesMessage);
Composite main = new Composite(parent, SWT.NONE);
main.setLayout(new GridLayout(1, false));
main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Group searchGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
searchGroup.setText(UIText.RepositorySearchDialog_SearchCriteriaGroup);
searchGroup.setLayout(new GridLayout(4, false));
GridDataFactory.fillDefaults().grab(true, false).minSize(SWT.DEFAULT, SWT.DEFAULT).applyTo(searchGroup);
Label dirLabel = new Label(searchGroup, SWT.NONE);
dirLabel.setText(UIText.RepositorySearchDialog_directory);
dir = new Text(searchGroup, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).hint(300, SWT.DEFAULT).minSize(100, SWT.DEFAULT).applyTo(dir);
dir.setToolTipText(UIText.RepositorySearchDialog_EnterDirectoryToolTip);
String defaultRepoPath = RepositoryUtil.getDefaultRepositoryDir();
String initialPath = prefs.get(PREF_PATH, defaultRepoPath);
dir.setText(initialPath);
Button browse = new Button(searchGroup, SWT.PUSH);
browse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
browse.setText(UIText.RepositorySearchDialog_browse);
browse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(getShell());
dd.setMessage(UIText.RepositorySearchDialog_BrowseDialogMessage);
dd.setFilterPath(dir.getText());
String directory = dd.open();
if (directory != null) {
dir.setText(directory);
prefs.put(PREF_PATH, directory);
try {
prefs.flush();
} catch (BackingStoreException e1) {
// ignore here
}
doSearch();
}
}
});
searchButton = new Button(searchGroup, SWT.PUSH);
searchButton.setText(UIText.RepositorySearchDialog_Search);
searchButton.setToolTipText(UIText.RepositorySearchDialog_SearchTooltip);
searchButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doSearch();
}
});
lookForNestedButton = new Button(searchGroup, SWT.CHECK);
lookForNestedButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
lookForNestedButton.setSelection(prefs.getBoolean(PREF_DEEP_SEARCH, false));
lookForNestedButton.setText(UIText.RepositorySearchDialog_DeepSearch_button);
lookForNestedButton.setToolTipText(UIText.RepositorySearchDialog_SearchRecursiveToolTip);
lookForNestedButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
prefs.putBoolean(PREF_DEEP_SEARCH, lookForNestedButton.getSelection());
try {
prefs.flush();
} catch (BackingStoreException e1) {
// ignore
}
setNeedsSearch();
}
});
skipHiddenButton = new Button(searchGroup, SWT.CHECK);
skipHiddenButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
skipHiddenButton.setSelection(prefs.getBoolean(PREF_SKIP_HIDDEN, true));
skipHiddenButton.setText(UIText.RepositorySearchDialog_SkipHidden);
skipHiddenButton.setToolTipText(UIText.RepositorySearchDialog_SkipHiddenTooltip);
skipHiddenButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
prefs.putBoolean(PREF_SKIP_HIDDEN, skipHiddenButton.getSelection());
try {
prefs.flush();
} catch (BackingStoreException e1) {
// ignore
}
setNeedsSearch();
}
});
Group searchResultGroup = new Group(main, SWT.SHADOW_ETCHED_IN);
searchResultGroup.setText(UIText.RepositorySearchDialog_SearchResultGroup);
searchResultGroup.setLayout(new GridLayout(2, false));
GridDataFactory.fillDefaults().grab(true, true).minSize(SWT.DEFAULT, 0).applyTo(searchResultGroup);
PatternFilter filter = new PatternFilter() {
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
if (getCheckedItems().contains(element)) {
return true;
}
return super.isElementVisible(viewer, element);
}
};
fTree = new FilteredCheckboxTree(searchResultGroup, null, SWT.NONE, filter);
fTreeViewer = fTree.getCheckboxTreeViewer();
fTreeViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
enableOk();
}
});
fTreeViewer.addDoubleClickListener(event -> {
Object element = ((IStructuredSelection) event.getSelection()).getFirstElement();
fTreeViewer.setChecked(element, !fTreeViewer.getChecked(element));
enableOk();
});
// Set a reasonable minimum height here; otherwise the dialog comes up
// with a tree that has only a few rows visible.
GridDataFactory.fillDefaults().grab(true, true).minSize(0, 300).applyTo(fTree);
ToolBar toolbar = new ToolBar(searchResultGroup, SWT.FLAT | SWT.VERTICAL);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(toolbar);
checkAllItem = new ToolItem(toolbar, SWT.PUSH);
checkAllItem.setToolTipText(UIText.RepositorySearchDialog_CheckAllRepositories);
checkAllItem.setEnabled(false);
Image checkImage = UIIcons.CHECK_ALL.createImage();
UIUtils.hookDisposal(checkAllItem, checkImage);
checkAllItem.setImage(checkImage);
checkAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fTreeViewer.setAllChecked(true);
enableOk();
}
});
uncheckAllItem = new ToolItem(toolbar, SWT.PUSH);
uncheckAllItem.setToolTipText(UIText.RepositorySearchDialog_UncheckAllRepositories);
uncheckAllItem.setEnabled(false);
Image uncheckImage = UIIcons.UNCHECK_ALL.createImage();
UIUtils.hookDisposal(uncheckAllItem, uncheckImage);
uncheckAllItem.setImage(uncheckImage);
uncheckAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fTreeViewer.setAllChecked(false);
enableOk();
}
});
// TODO this isn't the most optimal way of handling this... ideally we
// should have some type of delay
// if we could use databinding an observeDelayedValue would totally work
// here
dir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
setNeedsSearch();
}
});
fTreeViewer.setContentProvider(new ContentProvider());
fTreeViewer.setLabelProvider(new RepositoryLabelProvider());
setControl(main);
enableOk();
if (fillSearch)
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (!getControl().isDisposed())
doSearch();
}
});
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project tdq-studio-se by Talend.
the class TablesSelectionDialog method addCheckedListener.
@Override
protected void addCheckedListener() {
// When user checks a checkbox in the tree, check all its children
getTreeViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
TreePath treePath = new TreePath(new Object[] { event.getElement() });
getTreeViewer().setSelection(new TreeSelection(treePath));
if (event.getChecked()) {
Object element = event.getElement();
getTreeViewer().setSubtreeChecked(element, true);
if (element instanceof IRepositoryNode) {
setOutput(element);
handleTablesChecked((IRepositoryNode) element, true);
}
} else {
Object element = event.getElement();
getTreeViewer().setSubtreeChecked(element, false);
if (element instanceof IRepositoryNode) {
setOutput(element);
handleTablesChecked((IRepositoryNode) element, false);
}
}
updateOKStatus();
}
});
getTableViewer().addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
Object element = event.getElement();
if (element instanceof DBTableRepNode || element instanceof DBViewRepNode) {
handleTableChecked((IRepositoryNode) element, event.getChecked());
}
}
});
}
use of org.eclipse.jface.viewers.CheckStateChangedEvent in project statecharts by Yakindu.
the class SGenWizardPage2 method createObjectTree.
private void createObjectTree(Composite container) {
lblNewLabel = new Label(container, SWT.NONE);
lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
lblNewLabel.setText("Choose: " + getSelectedGenerator().getContentType());
resourceTree = new CheckboxTreeViewer(container, SWT.BORDER);
resourceTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
resourceTree.setContentProvider(new WorkspaceTreeContentProvider());
resourceTree.setLabelProvider(new SGenWorkspaceLabelProvider());
TreePropagatingCheckStateListener checkStateListener = new TreePropagatingCheckStateListener(resourceTree) {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
super.checkStateChanged(event);
}
};
resourceTree.addCheckStateListener(checkStateListener);
resourceTree.addDoubleClickListener(new TreeExpandingDoubleClickListener(resourceTree, checkStateListener));
resourceTree.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
resourceTree.setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
// '.' prefixed folder
if (element instanceof IFolder) {
return !((IFolder) element).getName().startsWith(".");
}
return true;
}
} });
}
Aggregations