use of org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeLabelProvider in project linuxtools by eclipse.
the class CreaterepoTreeTest method initViewer.
/**
* Initialize the treeviewer and tree. Needs access to UI thread when using
* SWTBot tests. Need to wrap tests in Display.getDefault().syncExec().
*/
private void initViewer() {
viewer = new TreeViewer(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
viewer.setContentProvider(new CreaterepoTreeContentProvider());
viewer.setLabelProvider(new CreaterepoTreeLabelProvider());
CreaterepoCategoryModel model = new CreaterepoCategoryModel(project);
viewer.setInput(model);
tree = viewer.getTree();
}
use of org.eclipse.linuxtools.internal.rpm.createrepo.tree.CreaterepoTreeLabelProvider in project linuxtools by eclipse.
the class MetadataPage method createFormContent.
@Override
protected void createFormContent(IManagedForm managedForm) {
// setting up the form page
super.createFormContent(managedForm);
GridLayout layout = new GridLayout();
toolkit = managedForm.getToolkit();
ScrolledForm form = managedForm.getForm();
form.setText(Messages.MetadataPage_formHeaderText);
form.setImage(Activator.getImageDescriptor(HEADER_ICON).createImage());
ToolBarManager toolbarManager = (ToolBarManager) form.getToolBarManager();
toolkit.decorateFormHeading(form.getForm());
// add the menuContribution from MANIFEST.MF to the form
IMenuService menuService = getSite().getService(IMenuService.class);
menuService.populateContributionManager(toolbarManager, MENU_URI);
toolbarManager.update(true);
layout = new GridLayout();
layout.marginWidth = 6;
layout.marginHeight = 12;
form.getBody().setLayout(layout);
// --------------------------------- REVISION SECTION START ----------
// Section and its client area to manage updating revision info
Section revSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
layout = new GridLayout();
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
data.grabExcessHorizontalSpace = true;
revSection.setText(Messages.MetadataPage_sectionTitleRevision);
revSection.setDescription(Messages.MetadataPage_sectionInstructionRevision);
revSection.setLayoutData(data);
// the client area containing the editing fields
Composite sectionClient = toolkit.createComposite(revSection);
layout = new GridLayout(2, false);
layout.marginWidth = 1;
layout.marginHeight = 7;
sectionClient.setLayout(layout);
Text revisionTxt = createTextFieldWithLabel(sectionClient, Messages.MetadataPage_labelRevision);
String prefRevisionTxt = eclipsePreferences.get(CreaterepoPreferenceConstants.PREF_REVISION, ICreaterepoConstants.EMPTY_STRING);
if (!prefRevisionTxt.isEmpty()) {
revisionTxt.setText(prefRevisionTxt);
}
revisionTxt.addSelectionListener(SelectionListener.widgetDefaultSelectedAdapter(e -> {
String revisionText = revisionTxt.getText().trim();
savePreferences(CreaterepoPreferenceConstants.PREF_REVISION, revisionText);
}));
revSection.setClient(sectionClient);
// ---------- REVISION SECTION END
// --------------------------------- TAGS SECTION START ----------
// Section and its client area to manage tags
Section tagSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
layout = new GridLayout();
tagSection.setText(Messages.MetadataPage_sectionTitleTags);
tagSection.setDescription(Messages.MetadataPage_sectionInstructionTags);
tagSection.setLayoutData(expandComposite());
// the client area containing the tags
Composite sectionClientTags = toolkit.createComposite(tagSection);
layout = new GridLayout(2, false);
layout.marginWidth = 1;
layout.marginHeight = 7;
sectionClientTags.setLayout(layout);
tagTxt = createTextFieldWithLabel(sectionClientTags, Messages.MetadataPage_labelTags);
tagTxt.addSelectionListener(new AddTagButtonListener());
tagsTreeViewer = new TreeViewer(sectionClientTags, SWT.BORDER | SWT.SINGLE | SWT.HORIZONTAL | SWT.VERTICAL | SWT.LEFT_TO_RIGHT | SWT.SMOOTH);
tagsTreeViewer.setContentProvider(new CreaterepoTreeContentProvider());
tagsTreeViewer.setLabelProvider(new CreaterepoTreeLabelProvider());
CreaterepoCategoryModel model = new CreaterepoCategoryModel(project);
tagsTreeViewer.setInput(model);
// change the tag text field on change (make editing tag easier)
tagsTreeViewer.addSelectionChangedListener(event -> {
if (tagsTree.getSelectionCount() == 1) {
TreeItem treeItem = tagsTree.getSelection()[0];
if (!(treeItem.getData() instanceof CreaterepoTreeCategory)) {
String tag = (String) treeItem.getData();
tagTxt.setText(tag);
} else {
tagTxt.setText(ICreaterepoConstants.EMPTY_STRING);
}
}
});
// expand or shrink a category
tagsTreeViewer.addDoubleClickListener(event -> {
IStructuredSelection selection = (IStructuredSelection) tagsTreeViewer.getSelection();
if (selection.getFirstElement() instanceof CreaterepoTreeCategory) {
CreaterepoTreeCategory category = (CreaterepoTreeCategory) selection.getFirstElement();
tagsTreeViewer.setExpandedState(category, !tagsTreeViewer.getExpandedState(category));
}
});
tagsTree = tagsTreeViewer.getTree();
tagsTree.setLayoutData(expandComposite());
// everything to do with the buttons
Composite buttonList = toolkit.createComposite(sectionClientTags);
layout = new GridLayout();
data = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
layout.marginWidth = 0;
layout.marginHeight = 0;
buttonList.setLayout(layout);
buttonList.setLayoutData(data);
createPushButton(buttonList, Messages.MetadataPage_buttonAddTag, toolkit).addSelectionListener(new AddTagButtonListener());
createPushButton(buttonList, Messages.MetadataPage_buttonEditTag, toolkit).addSelectionListener(new EditTagButtonListener());
createPushButton(buttonList, Messages.MetadataPage_buttonRemoveTag, toolkit).addSelectionListener(new RemoveTagButtonListener());
tagSection.setClient(sectionClientTags);
// ---------- TAGS SECTION END
refreshTree();
managedForm.refresh();
}
Aggregations