use of org.eclipse.jface.viewers.ViewerSorter in project bndtools by bndtools.
the class ResolutionFailurePanel method copyUnresolvedToClipboard.
// private void switchFailureViewMode() {
// Object input = unresolvedViewer.getInput();
// unresolvedViewer.setInput(null);
// setFailureViewMode();
// unresolvedViewer.setInput(input);
// unresolvedViewer.expandToLevel(2);
// }
private void copyUnresolvedToClipboard() {
StringBuilder builder = new StringBuilder();
Object input = unresolvedViewer.getInput();
if (input == null)
return;
ITreeContentProvider contentProvider = (ITreeContentProvider) unresolvedViewer.getContentProvider();
Object[] roots = contentProvider.getElements(input);
ViewerSorter sorter = unresolvedViewer.getSorter();
if (sorter != null)
Arrays.sort(roots, new SorterComparatorAdapter(unresolvedViewer, sorter));
for (Object root : roots) {
appendLabels(root, contentProvider, builder, 0);
}
/*
* TODO if (result != null) { StringBuilder buffer = new StringBuilder(); List<Reason> unresolved =
* result.getUnresolved(); if (unresolved != null) for (Iterator<Reason> iter = unresolved.iterator();
* iter.hasNext(); ) { Reason reason = iter.next();
* buffer.append(unresolvedLabelProvider.getLabel(reason.getRequirement ()).getString()); buffer.append('\t');
* buffer.append(unresolvedLabelProvider .getLabel(reason.getResource())); if (iter.hasNext())
* buffer.append('\n'); } }
*/
Clipboard clipboard = new Clipboard(composite.getDisplay());
TextTransfer transfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { builder.toString() }, new Transfer[] { transfer });
clipboard.dispose();
}
use of org.eclipse.jface.viewers.ViewerSorter in project bndtools by bndtools.
the class ResolutionFailurePanel method appendLabels.
private void appendLabels(Object unresolvedTreeElem, ITreeContentProvider contentProvider, StringBuilder builder, int indent) {
for (int i = 0; i < indent; i++) builder.append("..");
// builder.append(getClipboardContent(unresolvedTreeElem)).append('\n');
Object[] children = contentProvider.getChildren(unresolvedTreeElem);
if (children == null)
return;
ViewerSorter sorter = unresolvedViewer.getSorter();
if (sorter != null)
Arrays.sort(children, new SorterComparatorAdapter(unresolvedViewer, sorter));
for (Object child : children) {
appendLabels(child, contentProvider, builder, indent + 1);
}
}
use of org.eclipse.jface.viewers.ViewerSorter in project bndtools by bndtools.
the class PackageInfoDialog method createDialogArea.
/**
* Create contents of the dialog.
*
* @param parent
*/
@SuppressWarnings("unused")
@Override
protected Control createDialogArea(Composite parent) {
setMessage(Messages.PackageInfoDialog_Message);
setTitle(Messages.PackageInfoDialog_Title);
Composite container = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 10;
layout.marginWidth = 10;
composite.setLayout(layout);
table = new Table(composite, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION);
table.setHeaderVisible(true);
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);
gd_table.heightHint = 100;
table.setLayoutData(gd_table);
table.setLinesVisible(true);
TableColumn tblclmnPackage = new TableColumn(table, SWT.NONE);
tblclmnPackage.setWidth(267);
tblclmnPackage.setText(Messages.PackageInfoDialog_ExportedPackage);
TableColumn tblclmnVersion = new TableColumn(table, SWT.NONE);
tblclmnVersion.setWidth(77);
tblclmnVersion.setText(Messages.PackageInfoDialog_Version);
Button btnCheckAll = new Button(composite, SWT.NONE);
btnCheckAll.setText(Messages.PackageInfoDialog_btnCheckAll_text);
btnCheckAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
btnCheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selection.clear();
selection.addAll(packages);
viewer.setCheckedElements(selection.toArray());
validate();
}
});
Button btnUncheckAll = new Button(composite, SWT.NONE);
btnUncheckAll.setText(Messages.PackageInfoDialog_btnUncheckAll_text_1);
btnUncheckAll.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
btnUncheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selection.clear();
viewer.setCheckedElements(selection.toArray());
validate();
}
});
final Button btnAlwaysGenerate = new Button(composite, SWT.CHECK);
btnAlwaysGenerate.setText(Messages.PackageInfoDialog_AlwaysGenerate);
viewer = new CheckboxTableViewer(table);
TableViewerColumn tblViewerClmnPackage = new TableViewerColumn(viewer, tblclmnPackage);
tblViewerClmnPackage.setLabelProvider(new PackageNameLabelProvider(table.getDisplay()));
TableViewerColumn tblViewerClmnVersion = new TableViewerColumn(viewer, tblclmnVersion);
tblViewerClmnVersion.setLabelProvider(new PackageVersionLabelProvider());
tblViewerClmnVersion.setEditingSupport(new VersionEditingSupport(viewer));
viewer.setContentProvider(ArrayContentProvider.getInstance());
viewer.setSorter(new ViewerSorter() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
FileVersionTuple f1 = (FileVersionTuple) e1;
FileVersionTuple f2 = (FileVersionTuple) e2;
return f1.compareTo(f2);
}
});
viewer.setInput(packages);
viewer.setCheckedElements(selection.toArray());
new Label(composite, SWT.NONE);
btnAlwaysGenerate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dontAsk = btnAlwaysGenerate.getSelection();
}
});
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
FileVersionTuple pkg = (FileVersionTuple) event.getElement();
if (event.getChecked())
selection.add(pkg);
else
selection.remove(pkg);
validate();
}
});
return container;
}
use of org.eclipse.jface.viewers.ViewerSorter in project bndtools by bndtools.
the class WorkspacePreviewPage method createControl.
@Override
public void createControl(Composite parent) {
setTitle("Preview Changes");
//$NON-NLS-1$
setImageDescriptor(Plugin.imageDescriptorFromPlugin("icons/bndtools-wizban.png"));
imgAdded = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/incoming.gif").createImage(parent.getDisplay());
imgOverwrite = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/conflict.gif").createImage(parent.getDisplay());
imgError = AbstractUIPlugin.imageDescriptorFromPlugin(Plugin.PLUGIN_ID, "icons/error_obj.gif").createImage(parent.getDisplay());
int columns = 4;
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(columns, false);
composite.setLayout(layout);
setControl(composite);
Label lblTitle = new Label(composite, SWT.NONE);
lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, columns, 1));
// Table
tblOutputs = new Table(composite, SWT.BORDER | SWT.CHECK);
tblOutputs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, columns, 1));
vwrOutputs = new CheckboxTableViewer(tblOutputs);
vwrOutputs.setContentProvider(ArrayContentProvider.getInstance());
vwrOutputs.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
StyledString label;
Image icon;
String path = (String) cell.getElement();
String error = resourceErrors.get(path);
if (error != null) {
label = new StyledString(path, ItalicStyler.INSTANCE_ERROR);
icon = imgError;
} else {
label = new StyledString(path);
icon = existingFiles.contains(path) ? imgOverwrite : imgAdded;
}
cell.setText(path);
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(icon);
}
});
vwrOutputs.setSorter(new ViewerSorter(Collator.getInstance()));
// Details display
final Label lblDetails = new Label(composite, SWT.NONE);
lblDetails.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, columns, 1));
lblDetails.setText(MSG_NOTHING_SELECTED);
// Button Panel
Label spacer1 = new Label(composite, SWT.NONE);
spacer1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button btnSelectNonConflict = new Button(composite, SWT.PUSH);
btnSelectNonConflict.setText("Select Non-Conflicting");
btnSelectNonConflict.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
checkedPaths.clear();
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (!existingFiles.contains(path))
checkedPaths.add(path);
}
vwrOutputs.setCheckedElements(checkedPaths.toArray());
}
});
}
});
Button btnSelectAll = new Button(composite, SWT.PUSH);
btnSelectAll.setText("Select All");
btnSelectAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
vwrOutputs.setAllChecked(true);
}
});
Button btnSelectNone = new Button(composite, SWT.PUSH);
btnSelectNone.setText("Select None");
btnSelectNone.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
vwrOutputs.setAllChecked(false);
}
});
// Listeners
vwrOutputs.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) vwrOutputs.getSelection();
if (sel.isEmpty()) {
lblDetails.setText(MSG_NOTHING_SELECTED);
} else {
String path = (String) sel.getFirstElement();
String resourceError = resourceErrors.get(path);
if (resourceError != null) {
lblDetails.setText(resourceError);
} else if (existingFiles.contains(path)) {
lblDetails.setText("This file already exists and will be overwritten");
} else {
lblDetails.setText("This file will be created");
}
}
}
});
vwrOutputs.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(final CheckStateChangedEvent event) {
modifyLock.ifNotModifying(new Runnable() {
@Override
public void run() {
final String updatedPath = (String) event.getElement();
if (event.getChecked()) {
checkedPaths.add(updatedPath);
// Check any directories that are parents of this path
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (path.endsWith("/") && updatedPath.startsWith(path)) {
checkedPaths.add(path);
vwrOutputs.setChecked(path, true);
}
}
}
});
} else {
checkedPaths.remove(updatedPath);
// Uncheck any paths that are descendants of this path
if (updatedPath.endsWith("/")) {
modifyLock.modifyOperation(new Runnable() {
@Override
public void run() {
for (Entry<String, Resource> entry : templateOutputs.entries()) {
String path = entry.getKey();
if (path.startsWith(updatedPath)) {
checkedPaths.remove(path);
vwrOutputs.setChecked(path, false);
}
}
}
});
}
}
}
});
}
});
}
use of org.eclipse.jface.viewers.ViewerSorter in project ACS by ACS-Community.
the class LostSourcesPart method createPartControl.
public void createPartControl(Composite parent) {
listViewer = new ListViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
listViewer.setContentProvider(LostSourcesContainer.getInstance());
listViewer.setSorter(new ViewerSorter());
listViewer.setInput(null);
}
Aggregations