use of bndtools.model.repo.RepositoryTreeContentProvider 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 bndtools.model.repo.RepositoryTreeContentProvider in project bndtools by bndtools.
the class MapValuesContentProvider method createAvailableBundlesPanel.
Control createAvailableBundlesPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
new Label(panel, SWT.NONE).setText("Available Bundles:");
selectionSearchTxt = new Text(panel, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
selectionSearchTxt.setMessage("filter bundle name");
final Tree availableTree = new Tree(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
availableViewer = new TreeViewer(availableTree);
availableViewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
availableViewer.setContentProvider(new RepositoryTreeContentProvider());
availableViewer.setAutoExpandLevel(2);
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
// Load data
try {
refreshBundleList();
} catch (Exception e) {
setErrorMessage("Error querying repositories: " + e.getMessage());
logger.logError("Error querying repository configuration.", e);
}
// Listeners
selectionSearchTxt.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_DOWN)
availableTree.setFocus();
}
});
selectionSearchTxt.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
}
});
availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
// Enable add button when a bundle or bundle version is selected on
// the left
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) availableViewer.getSelection();
for (Iterator<?> iter = sel.iterator(); iter.hasNext(); ) {
Object element = iter.next();
if (element instanceof RepositoryBundle || element instanceof RepositoryBundleVersion || element instanceof ProjectBundle) {
addButton.setEnabled(true);
return;
}
}
addButton.setEnabled(false);
}
});
availableViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
doAdd();
}
});
GridLayout layout;
GridData gd;
layout = new GridLayout(1, false);
panel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
selectionSearchTxt.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 300;
gd.widthHint = 250;
availableTree.setLayoutData(gd);
return panel;
}
Aggregations