use of org.eclipse.jface.viewers.StructuredSelection in project bndtools by bndtools.
the class LocalRepositorySelectionPage method createControl.
public void createControl(Composite parent) {
setTitle("Select Local Repository");
setMessage("Bundle will be imported into the selected repository.");
Table table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
final TableViewer viewer = new TableViewer(table);
viewer.setContentProvider(new RepositoryTreeContentProvider());
viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return (element instanceof RepositoryPlugin) && ((RepositoryPlugin) element).canWrite();
}
} });
try {
Workspace workspace = Central.getWorkspace();
viewer.setInput(workspace);
if (selectedRepository != null)
viewer.setSelection(new StructuredSelection(selectedRepository));
validate(workspace);
} catch (Exception e) {
logger.logError("Error querying local repositories", e);
setErrorMessage("Error querying local repositories, see log for details.");
}
// LISTENERS
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
}
});
viewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent evt) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
IWizardPage nextPage = getNextPage();
if (nextPage != null)
getContainer().showPage(nextPage);
}
});
setControl(table);
}
use of org.eclipse.jface.viewers.StructuredSelection in project bndtools by bndtools.
the class WorkspaceReleaseAction method selectionChanged.
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
projects = Collections.emptySet();
if (selection != null && (selection instanceof StructuredSelection)) {
StructuredSelection ss = (StructuredSelection) selection;
projects = new HashSet<IProject>();
for (Iterator<?> itr = ss.iterator(); itr.hasNext(); ) {
Object selected = itr.next();
if (selected instanceof IProject) {
projects.add((IProject) selected);
} else if (selected instanceof IWorkingSet) {
IWorkingSet workingSet = (IWorkingSet) selected;
for (IAdaptable adaptable : workingSet.getElements()) {
IProject project = (IProject) adaptable.getAdapter(IProject.class);
if (project != null && !projects.contains(project)) {
projects.add(project);
}
}
} else if (selected instanceof IFile) {
IFile bndFile = (IFile) selected;
if (bndFile.getName().endsWith(Constants.DEFAULT_BND_EXTENSION)) {
if (!projects.contains(bndFile.getProject()))
projects.add(bndFile.getProject());
}
}
}
}
}
use of org.eclipse.jface.viewers.StructuredSelection in project bndtools by bndtools.
the class ReleaseAction method getLocations.
static IFile[] getLocations(ISelection selection) {
if (selection != null && (selection instanceof StructuredSelection)) {
StructuredSelection ss = (StructuredSelection) selection;
IFile[] result = new IFile[ss.size()];
int n = 0;
for (@SuppressWarnings("unchecked") Iterator<IFile> i = ss.iterator(); i.hasNext(); ) {
result[n++] = i.next();
}
return result;
}
return null;
}
use of org.eclipse.jface.viewers.StructuredSelection in project eclipse.platform.text by eclipse.
the class AnnotationsConfigurationBlock method applyData.
/**
* Applies the given data.
*
* @param data the annotation type to select in the list or <code>null</code>
* @see org.eclipse.ui.internal.editors.text.IPreferenceConfigurationBlock#applyData(java.lang.Object)
* @since 3.4
*/
@Override
public void applyData(Object data) {
if (!(data instanceof String))
return;
for (int i = 0; i < fListModel.length; i++) {
final ListItem element = fListModel[i];
if (data.equals(element.label)) {
final Control control = fAnnotationTypeViewer.getControl();
control.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
control.setFocus();
fAnnotationTypeViewer.setSelection(new StructuredSelection(element), true);
}
});
return;
}
}
}
use of org.eclipse.jface.viewers.StructuredSelection in project eclipse.platform.text by eclipse.
the class LinkedModeConfigurationBlock method updateDecorationViewer.
private void updateDecorationViewer(ListItem item, boolean changed) {
// decoration selection: if the checkbox is enabled, there is
// only one case where the combo is not enabled: if both the highlight and textStyle keys are null
final boolean enabled = fShowInTextCheckBox.getSelection() && !(item.highlightKey == null && item.textStyleKey == null);
fDecorationViewer.getControl().setEnabled(enabled);
if (changed) {
String[] selection = null;
ArrayList<String[]> list = new ArrayList<>();
list.addAll(item.validStyles);
if (getPreferenceStore().getBoolean(item.highlightKey))
selection = HIGHLIGHT;
// set selection
if (selection == null) {
String val = getPreferenceStore().getString(item.textStyleKey);
for (Iterator<String[]> iter = list.iterator(); iter.hasNext(); ) {
String[] elem = iter.next();
if (elem[1].equals(val)) {
selection = elem;
break;
}
}
}
fDecorationViewer.setInput(list.toArray(new Object[list.size()]));
if (selection == null)
selection = list.get(0);
fDecorationViewer.setSelection(new StructuredSelection((Object) selection), true);
}
}
Aggregations