use of org.eclipse.ui.forms.events.ExpansionEvent in project titan.EclipsePlug-ins by eclipse.
the class DebugPreferencePage method createExtendableComposite.
/**
* Creates an expandable composite on the user interface.
*
* @param parent
* the parent composite where this one can be added to.
* @param title
* the title of the new composite.
*
* @return the created composite.
*/
private ExpandableComposite createExtendableComposite(final Composite parent, final String title) {
final ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
ex.setText(title);
ex.setExpanded(false);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
ex.setLayoutData(data);
ex.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
Composite temp = parent;
while (temp != null && !(temp instanceof ScrolledComposite)) {
temp = temp.getParent();
}
if (temp != null) {
Point point = pagecomp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
((ScrolledComposite) temp).setMinSize(point);
((ScrolledComposite) temp).layout(true, true);
}
}
});
return ex;
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project titan.EclipsePlug-ins by eclipse.
the class TestportParametersSectionPage method createTestportParameterTable.
private void createTestportParameterTable(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
Composite client = toolkit.createComposite(section, SWT.WRAP);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
client.setLayout(layout);
toolkit.paintBordersFor(client);
testportParametersTable = toolkit.createTable(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
testportParametersTable.setEnabled(testportParametersHandler != null);
TableColumn column = new TableColumn(testportParametersTable, SWT.LEFT, 0);
column.setText("Parameter name");
column.setWidth(150);
column.setMoveable(false);
column = new TableColumn(testportParametersTable, SWT.LEFT, 0);
column.setText("Testport name");
column.setMoveable(false);
column.setWidth(130);
column = new TableColumn(testportParametersTable, SWT.LEFT, 0);
column.setText("Component name");
column.setMoveable(false);
column.setWidth(130);
testportParametersTable.setHeaderVisible(true);
testportParametersTable.setLinesVisible(true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 100;
gd.heightHint = 200;
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = SWT.FILL;
testportParametersTable.setLayoutData(gd);
Composite buttons = toolkit.createComposite(client);
buttons.setLayout(new GridLayout());
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_VERTICAL));
add = toolkit.createButton(buttons, "Add...", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
add.setLayoutData(gd);
add.setEnabled(testportParametersHandler != null);
add.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (testportParametersHandler == null) {
return;
}
if (testportParametersHandler.getLastSectionRoot() == null) {
createNewTestportParameterSection();
}
TestportParameter newTestportParameter = createNewParameter();
if (newTestportParameter == null) {
return;
}
ConfigTreeNodeUtilities.addChild(testportParametersHandler.getLastSectionRoot(), newTestportParameter.getRoot());
testportParametersHandler.getTestportParameters().add(newTestportParameter);
internalRefresh();
testportParametersTableViewer.setSelection(new StructuredSelection(newTestportParameter));
parameterValueText.setText(newTestportParameter.getValue().getText());
editor.setDirty();
}
});
remove = toolkit.createButton(buttons, "Remove", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
remove.setLayoutData(gd);
remove.setEnabled(testportParametersHandler != null);
remove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (testportParametersTableViewer == null || testportParametersHandler == null) {
return;
}
removeSelectedParameters();
if (testportParametersHandler.getTestportParameters().isEmpty()) {
removeTestportParameterSection();
}
internalRefresh();
editor.setDirty();
}
});
totalTestportParametersLabel = toolkit.createLabel(buttons, "Total: 0");
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
totalTestportParametersLabel.setLayoutData(gd);
section.setText("Testport parameters");
section.setDescription("Specify the list of testport parameters for this configuration.");
section.setClient(client);
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
gd = new GridData(GridData.FILL_BOTH);
section.setLayoutData(gd);
testportParametersTableViewer = new TableViewer(testportParametersTable);
testportParametersTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
StructuredSelection selection = (StructuredSelection) event.getSelection();
if (selection.size() != 1) {
parameterValueText.setEnabled(false);
return;
}
TestportParameter testportParameter = (TestportParameter) selection.getFirstElement();
if (testportParameter != null) {
if (testportParameter.getValue() != null) {
if (testportParameter.getValue().getText().length() == 0) {
String temp = ConfigTreeNodeUtilities.toString(testportParameter.getValue());
ConfigTreeNodeUtilities.setText(testportParameter.getValue(), temp);
}
parameterValueText.setText(testportParameter.getValue().getText());
}
valueChanged = true;
}
parameterValueText.setEnabled(testportParametersHandler != null && testportParameter != null);
}
});
testportParametersTableViewer.setContentProvider(new TestportParameterDataContentProvider());
testportParametersTableViewer.setLabelProvider(new TestportParameterDataLabelProvider());
testportParametersTableViewer.setInput(testportParametersHandler);
testportParametersTableViewer.setColumnProperties(columnNames);
testportParametersTableViewer.setCellEditors(new TextCellEditor[] { new TextCellEditor(testportParametersTable), new TextCellEditor(testportParametersTable), new TextCellEditor(testportParametersTable) });
testportParametersTableViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(final Object element, final String property) {
return true;
}
@Override
public String getValue(final Object element, final String property) {
int columnIndex = Arrays.asList(columnNames).indexOf(property);
TestportParameterDataLabelProvider labelProvider = (TestportParameterDataLabelProvider) testportParametersTableViewer.getLabelProvider();
return labelProvider.getColumnText(element, columnIndex);
}
@Override
public void modify(final Object element, final String property, final Object value) {
int columnIndex = Arrays.asList(columnNames).indexOf(property);
if (element != null && element instanceof TableItem && value instanceof String) {
TestportParameter testportParameter = (TestportParameter) ((TableItem) element).getData();
switch(columnIndex) {
case 0:
// COMPONENT_NAME
ConfigTreeNodeUtilities.setText(testportParameter.getComponentName(), ((String) value).trim());
break;
case 1:
// TESTPORT_NAME
ConfigTreeNodeUtilities.setText(testportParameter.getTestportName(), ((String) value).trim());
break;
case 2:
// PARAMETER_NAME
ConfigTreeNodeUtilities.setText(testportParameter.getParameterName(), ((String) value).trim());
break;
default:
break;
}
testportParametersTableViewer.refresh(testportParameter);
editor.setDirty();
}
}
});
testportParametersTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { TestportParameterTransfer.getInstance() }, new TestportParameterSectionDragSourceListener(this, testportParametersTableViewer));
testportParametersTableViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { TestportParameterTransfer.getInstance() }, new TestportParameterSectionDropTargetListener(testportParametersTableViewer, editor));
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project titan.EclipsePlug-ins by eclipse.
the class DefineSubPage method createDefinitionSection.
void createDefinitionSection(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
Composite client = toolkit.createComposite(section, SWT.WRAP);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
client.setLayout(layout);
toolkit.paintBordersFor(client);
defineElementsTable = toolkit.createTable(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
defineElementsTable.setEnabled(defineSectionHandler != null);
TableColumn column = new TableColumn(defineElementsTable, SWT.LEFT, 0);
column.setText("Definition name");
column.setMoveable(false);
column.setWidth(150);
column = new TableColumn(defineElementsTable, SWT.LEFT, 1);
column.setText("Definition value");
column.setWidth(300);
column.setMoveable(false);
defineElementsTable.setHeaderVisible(true);
defineElementsTable.setLinesVisible(true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 100;
gd.heightHint = 200;
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = SWT.FILL;
defineElementsTable.setLayoutData(gd);
Composite buttons = toolkit.createComposite(client);
buttons.setLayout(new GridLayout());
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_VERTICAL));
add = toolkit.createButton(buttons, "Add...", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
add.setLayoutData(gd);
add.setEnabled(defineSectionHandler != null);
add.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (defineSectionHandler == null) {
return;
}
if (defineSectionHandler.getLastSectionRoot() == null) {
createNewDefineSection();
}
final Definition newItem = createNewDefineItem();
if (newItem == null) {
return;
}
ConfigTreeNodeUtilities.addChild(defineSectionHandler.getLastSectionRoot(), newItem.getRoot());
defineSectionHandler.getDefinitions().add(newItem);
internalRefresh();
defineElementsTable.select(defineSectionHandler.getDefinitions().size() - 1);
defineElementsTable.showSelection();
editor.setDirty();
}
});
remove = toolkit.createButton(buttons, "Remove", SWT.PUSH);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
remove.setLayoutData(gd);
remove.setEnabled(defineSectionHandler != null);
remove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (defineElementsTableViewer == null || defineSectionHandler == null) {
return;
}
removeSelectedDefineItems();
if (defineSectionHandler.getDefinitions().isEmpty()) {
removeDefineSection();
}
internalRefresh();
editor.setDirty();
}
});
totalDefineElementsLabel = toolkit.createLabel(buttons, "Total defined: 0");
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
totalDefineElementsLabel.setLayoutData(gd);
section.setText("Definitions");
section.setDescription("Specify the list of Definitions for this configuration.");
section.setClient(client);
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
gd = new GridData(GridData.FILL_BOTH);
section.setLayoutData(gd);
defineElementsTableViewer = new TableViewer(defineElementsTable);
defineElementsTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
// not needed this time
}
});
defineElementsTableViewer.setContentProvider(new DefineDataContentProvider());
defineElementsTableViewer.setLabelProvider(new DefineDataLabelProvider());
defineElementsTableViewer.setInput(defineSectionHandler);
defineElementsTableViewer.setColumnProperties(COLUMN_NAMES);
defineElementsTableViewer.setCellEditors(new TextCellEditor[] { new TextCellEditor(defineElementsTable), new TextCellEditor(defineElementsTable) });
defineElementsTableViewer.setCellModifier(new ICellModifier() {
@Override
public boolean canModify(final Object element, final String property) {
return true;
}
@Override
public String getValue(final Object element, final String property) {
int columnIndex = Arrays.asList(COLUMN_NAMES).indexOf(property);
DefineDataLabelProvider labelProvider = (DefineDataLabelProvider) defineElementsTableViewer.getLabelProvider();
return labelProvider.getColumnText(element, columnIndex);
}
@Override
public void modify(final Object element, final String property, final Object value) {
int columnIndex = Arrays.asList(COLUMN_NAMES).indexOf(property);
if (element != null && element instanceof TableItem && value instanceof String) {
Definition definition = (Definition) ((TableItem) element).getData();
switch(columnIndex) {
case 0:
ConfigTreeNodeUtilities.setText(definition.getDefinitionName(), ((String) value).trim());
break;
case 1:
ConfigTreeNodeUtilities.setText(definition.getDefinitionValue(), ((String) value).trim());
break;
default:
break;
}
defineElementsTableViewer.refresh(definition);
editor.setDirty();
}
}
});
defineElementsTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { DefineItemTransfer.getInstance() }, new DefineSectionDragSourceListener(this, defineElementsTableViewer));
defineElementsTableViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT, new Transfer[] { DefineItemTransfer.getInstance() }, new DefineSectionDropTargetListener(defineElementsTableViewer, editor));
internalRefresh();
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project titan.EclipsePlug-ins by eclipse.
the class NamingConventionPreferencePage method createExtendableComposite.
/**
* Creates an expandable composite on the user interface.
*
* @param parent
* the parent composite where this one can be added to.
* @param title
* the title of the new composite.
*
* @return the created composite.
*/
private ExpandableComposite createExtendableComposite(final Composite parent, final String title) {
final ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
ex.setText(title);
ex.setExpanded(false);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2;
ex.setLayoutData(data);
ex.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
Composite temp = parent;
while (temp != null && !(temp instanceof ScrolledComposite)) {
temp = temp.getParent();
}
if (temp != null) {
Point point = pagecomp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
((ScrolledComposite) temp).setMinSize(point);
((ScrolledComposite) temp).layout(true, true);
}
}
});
return ex;
}
use of org.eclipse.ui.forms.events.ExpansionEvent in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createResourceDetails.
private void createResourceDetails(IViewerObservableValue selectedResourceTreeItem, Composite parent, DataBindingContext dbc) {
ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
ExpandableComposite expandable = new ExpandableComposite(scrolledComposite, SWT.None);
scrolledComposite.setContent(expandable);
expandable.setText("Resource Details");
expandable.setExpanded(true);
expandable.setLayout(new FillLayout());
Composite detailsContainer = new Composite(expandable, SWT.NONE);
expandable.setClient(detailsContainer);
expandable.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
getControl().update();
((Composite) getControl()).layout(true);
}
});
IObservableValue<IResource> selectedResource = new WritableValue<>();
ValueBindingBuilder.bind(selectedResourceTreeItem).converting(new ObservableTreeItem2ModelConverter()).to(selectedResource).notUpdatingParticipant().in(dbc);
new ResourceDetailViews(selectedResource, detailsContainer, dbc).createControls();
}
Aggregations