use of org.eclipse.swt.widgets.TreeColumn 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.swt.widgets.TreeColumn 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.swt.widgets.TreeColumn in project tdq-studio-se by Talend.
the class ColumnAnalysisDetailsPage method packOtherColumns.
/**
* DOC mzhao Comment method "packOtherColumns".
*/
private void packOtherColumns() {
TreeColumn[] columns = treeViewer.getTree().getColumns();
for (TreeColumn column : columns) {
column.pack();
}
treeViewer.getTree().pack();
treeViewer.getTree().getParent().layout();
}
use of org.eclipse.swt.widgets.TreeColumn in project tdq-studio-se by Talend.
the class AnalyzedElementSynDialog method createTableHeader.
private void createTableHeader() {
sTreeViewer.getTree().setHeaderVisible(true);
sTreeViewer.getTree().setLinesVisible(true);
TreeColumn column1 = new TreeColumn(sTreeViewer.getTree(), SWT.CENTER);
column1.setWidth(200);
// $NON-NLS-1$
column1.setText(DefaultMessagesImpl.getString("AnalyzedElementSynDialog.Name"));
TreeColumn column2 = new TreeColumn(sTreeViewer.getTree(), SWT.CENTER);
column2.setWidth(500);
// $NON-NLS-1$
column2.setText(DefaultMessagesImpl.getString("AnalyzedElementSynDialog.Status"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sTreeViewer.getTree());
}
use of org.eclipse.swt.widgets.TreeColumn in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method createTree.
/**
* @param parent
*/
private Tree createTree(Composite parent) {
final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION) {
@Override
protected boolean isValidItem(TreeItem item) {
if (item == null) {
return false;
}
Object itemData = item.getData(INDICATOR_UNIT_KEY);
Object columnItemData = item.getData(MODELELEMENT_INDICATOR_KEY);
if (itemData != null) {
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
if (indicatorUnit != null && !(indicatorUnit.getIndicator() instanceof CompositeIndicator)) {
return true;
}
return false;
} else {
if (columnItemData != null) {
ModelElementIndicator modelElementIndicator = (ModelElementIndicator) columnItemData;
IRepositoryNode modelElementRepositoryNode = modelElementIndicator.getModelElementRepositoryNode();
return modelElementRepositoryNode == null ? false : true;
}
return false;
}
}
@Override
protected String getItemTooltipText(TreeItem item) {
String expCont = isExpressionNull(item);
if (expCont == null) {
// $NON-NLS-1$
return DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.queryNotGen");
}
return expCont;
}
};
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
newTree.setHeaderVisible(true);
// $NON-NLS-1$
createTreeItem(newTree, 300, "AnalysisColumnTreeViewer.analyzedColumns");
createTreeDataminingItem(newTree);
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.pattern");
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.udi");
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
// TDQ-11622 : add a column here, let the width = 1 and text = EMPTY_STRING TODO need to find a better solution!
TreeColumn blankColumn = new TreeColumn(newTree, SWT.CENTER);
blankColumn.setWidth(1);
// ~ TDQ-11622
parent.layout();
AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {
@Override
protected void handleRemove() {
removeSelectedElements(newTree);
}
};
parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
ColumnViewerDND.installDND(newTree);
this.addTreeListener(newTree);
newTree.setData(this);
return newTree;
}
Aggregations