use of org.eclipse.ui.forms.widgets.Section in project bndtools by bndtools.
the class ResolutionSuccessPanel method createControl.
public void createControl(Composite parent) {
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
composite = toolkit.createComposite(parent);
GridLayout layout = new GridLayout(1, false);
composite.setLayout(layout);
SashForm form = new SashForm(composite, SWT.VERTICAL);
form.setLayout(new GridLayout(1, false));
form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridData gd;
Section sectRequired = toolkit.createSection(form, Section.TITLE_BAR | Section.EXPANDED);
sectRequired.setText("Required Resources");
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 150;
sectRequired.setLayoutData(gd);
Table tblRequired = toolkit.createTable(sectRequired, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
sectRequired.setClient(tblRequired);
requiredViewer = new TableViewer(tblRequired);
requiredViewer.setContentProvider(ArrayContentProvider.getInstance());
requiredViewer.setLabelProvider(new ResourceLabelProvider());
requiredViewer.setSorter(new BundleSorter());
requiredViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
Resource resource = (Resource) sel.getFirstElement();
reasonsContentProvider.setOptional(false);
if (result != null)
reasonsContentProvider.setResolution(result.getResourceWirings());
reasonsViewer.setInput(resource);
reasonsViewer.expandToLevel(2);
}
});
sectOptional = toolkit.createSection(form, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
sectOptional.setText("Optional Resources");
Composite cmpOptional = toolkit.createComposite(sectOptional);
sectOptional.setClient(cmpOptional);
cmpOptional.setLayout(new GridLayout(2, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 150;
sectOptional.setLayoutData(gd);
Table tblOptional = toolkit.createTable(cmpOptional, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
tblOptional.setLayoutData(gd);
optionalViewer = new CheckboxTableViewer(tblOptional);
optionalViewer.setContentProvider(ArrayContentProvider.getInstance());
optionalViewer.setLabelProvider(new ResourceLabelProvider());
optionalViewer.setSorter(new BundleSorter());
optionalViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
doOptionalReasonUpdate((Resource) sel.getFirstElement());
}
});
optionalViewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
Resource resource = (Resource) event.getElement();
if (!addedOptionals.containsKey(resource)) {
if (event.getChecked()) {
checkedOptional.add(resource);
} else {
checkedOptional.remove(resource);
}
}
presenter.updateButtons();
updateResolveOptionalButton();
optionalViewer.setSelection(new ISelection() {
@Override
public boolean isEmpty() {
return true;
}
});
doOptionalReasonUpdate(resource);
}
});
Composite cmpOptionalButtons = toolkit.createComposite(cmpOptional);
cmpOptionalButtons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
GridLayout gl_cmpOptionalButtons = new GridLayout(3, false);
gl_cmpOptionalButtons.marginHeight = 0;
gl_cmpOptionalButtons.marginWidth = 0;
cmpOptionalButtons.setLayout(gl_cmpOptionalButtons);
btnAddResolveOptional = toolkit.createButton(cmpOptionalButtons, "Update and Resolve", SWT.NONE);
btnAddResolveOptional.setEnabled(false);
btnAddResolveOptional.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAddResolve();
}
});
btnAddResolveOptional.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));
Button btnAllOptional = toolkit.createButton(cmpOptionalButtons, "Select All", SWT.NONE);
btnAllOptional.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
optionalViewer.setAllChecked(true);
checkedOptional.clear();
for (Object object : optionalViewer.getCheckedElements()) {
if (!addedOptionals.containsKey(object)) {
checkedOptional.add((Resource) object);
}
}
presenter.updateButtons();
updateResolveOptionalButton();
}
});
btnAllOptional.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Button btnClearOptional = toolkit.createButton(cmpOptionalButtons, "Clear All", SWT.NONE);
btnClearOptional.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
optionalViewer.setAllChecked(false);
checkedOptional.clear();
presenter.updateButtons();
updateResolveOptionalButton();
}
});
btnClearOptional.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Section sectReason = toolkit.createSection(form, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED);
sectReason.setText("Reasons");
Tree tblReasons = new Tree(sectReason, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
sectReason.setClient(tblReasons);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 200;
gd.heightHint = 150;
sectReason.setLayoutData(gd);
reasonsViewer = new TreeViewer(tblReasons);
reasonsViewer.setContentProvider(reasonsContentProvider);
reasonsViewer.setLabelProvider(new ResolutionTreeLabelProvider());
}
use of org.eclipse.ui.forms.widgets.Section in project bndtools by bndtools.
the class JAREntryPart method createContent.
private void createContent(Composite parent, FormToolkit toolkit) {
Section textSection = toolkit.createSection(parent, Section.TITLE_BAR | Section.EXPANDED);
textSection.setText("Entry Content");
Composite textComposite = toolkit.createComposite(textSection);
text = toolkit.createText(textComposite, "", SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
text.setFont(JFaceResources.getTextFont());
textSection.setClient(textComposite);
Section encodingSection = toolkit.createSection(parent, Section.TITLE_BAR | Section.EXPANDED);
encodingSection.setText("Display Options");
Composite encodingPanel = toolkit.createComposite(encodingSection);
encodingSection.setClient(encodingPanel);
toolkit.createLabel(encodingPanel, "Show As:");
final Button btnText = toolkit.createButton(encodingPanel, "Text", SWT.RADIO);
btnText.setSelection(showAsText);
Button btnBinary = toolkit.createButton(encodingPanel, "Binary (hex)", SWT.RADIO);
btnBinary.setSelection(!showAsText);
toolkit.createLabel(encodingPanel, "Text Encoding:");
final Combo encodingCombo = new Combo(encodingPanel, SWT.READ_ONLY);
encodingCombo.setEnabled(showAsText);
// INITIALISE
encodingCombo.setItems(charsets);
encodingCombo.select(selectedCharset);
// LISTENERS
encodingSection.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
getManagedForm().reflow(true);
}
});
SelectionListener radioListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
showAsText = btnText.getSelection();
encodingCombo.setEnabled(showAsText);
loadContent();
}
};
btnText.addSelectionListener(radioListener);
btnBinary.addSelectionListener(radioListener);
encodingCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
selectedCharset = encodingCombo.getSelectionIndex();
loadContent();
}
});
// LAYOUT
GridLayout layout;
GridData gd;
layout = new GridLayout(1, false);
parent.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
textSection.setLayoutData(gd);
layout = new GridLayout(1, false);
textComposite.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
encodingSection.setLayoutData(gd);
encodingSection.setLayout(new FillLayout());
encodingPanel.setLayout(new GridLayout(3, false));
encodingCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
}
use of org.eclipse.ui.forms.widgets.Section in project linuxtools by eclipse.
the class ImportRPMsPage method createFormContent.
@Override
protected void createFormContent(IManagedForm managedForm) {
// setting up the form page
super.createFormContent(managedForm);
GridLayout layout = new GridLayout();
FormToolkit toolkit = managedForm.getToolkit();
ScrolledForm form = managedForm.getForm();
form.setText(Messages.ImportRPMsPage_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(2, true);
layout.marginWidth = 6;
layout.marginHeight = 12;
form.getBody().setLayout(layout);
// Section and its client area to manage importing the RPMs
Section rpmSection = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
layout = new GridLayout();
rpmSection.setText(Messages.ImportRPMsPage_sectionTitle);
rpmSection.setDescription(Messages.ImportRPMsPage_sectionInstruction);
rpmSection.setLayoutData(expandComposite());
// the client area containing the tree + buttons
Composite sectionClient = toolkit.createComposite(rpmSection);
layout = new GridLayout(2, false);
layout.marginWidth = 1;
layout.marginHeight = 7;
sectionClient.setLayout(layout);
TreeViewer viewer = new TreeViewer(sectionClient, SWT.BORDER | SWT.MULTI | SWT.HORIZONTAL | SWT.VERTICAL | SWT.LEFT_TO_RIGHT | SWT.SMOOTH);
viewer.addDropSupport(DND.DROP_COPY, new Transfer[] { FileTransfer.getInstance() }, new ImportRPMDropListener(viewer, project));
tree = viewer.getTree();
tree.setLayoutData(expandComposite());
Composite buttonList = toolkit.createComposite(sectionClient);
layout = new GridLayout();
GridData data = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
layout.marginWidth = 0;
layout.marginHeight = 0;
buttonList.setLayout(layout);
buttonList.setLayoutData(data);
createPushButton(buttonList, Messages.ImportRPMsPage_buttonImportRPMs, toolkit).addSelectionListener(new ImportButtonListener());
createPushButton(buttonList, Messages.ImportRPMsPage_buttonRemoveRPMs, toolkit).addSelectionListener(new RemoveButtonListener());
new Label(buttonList, SWT.NONE).setLayoutData(new GridData(0, 0));
createPushButton(buttonList, Messages.ImportRPMsPage_buttonCreateRepo, toolkit).addSelectionListener(new CreaterepoButtonListener());
refreshTree();
rpmSection.setClient(sectionClient);
managedForm.refresh();
}
use of org.eclipse.ui.forms.widgets.Section 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();
}
use of org.eclipse.ui.forms.widgets.Section in project yamcs-studio by yamcs.
the class StyleEditor method createPartControl.
@Override
public void createPartControl(Composite parent) {
tk = new FormToolkit(parent.getDisplay());
Composite formWrapper = tk.createComposite(parent);
GridLayout gl = new GridLayout();
formWrapper.setLayout(gl);
form = tk.createScrolledForm(formWrapper);
form.setText("Style Editor");
form.setLayoutData(new GridData(GridData.FILL_BOTH));
gl = new GridLayout();
form.getBody().setLayout(gl);
Section section = tk.createSection(form.getBody(), Section.TITLE_BAR);
section.setText("Colors");
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
StyleDefinition def = loadData(parent.getDisplay());
ManagedForm managedForm = new ManagedForm(tk, form);
resourceManager = new LocalResourceManager(JFaceResources.getResources());
new ThemeColorBlock(def, parent.getDisplay(), resourceManager).createContent(managedForm);
ManagedForm fontsMForm = new ManagedForm(tk, form);
section = tk.createSection(form.getBody(), Section.TITLE_BAR);
section.setText("Fonts");
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
new ThemeColorBlock(def, parent.getDisplay(), resourceManager).createContent(fontsMForm);
}
Aggregations