use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.
the class TestportParametersSectionPage method createDetailsPart.
private void createDetailsPart(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 = 1;
client.setLayout(layout);
parameterValueText = toolkit.createText(client, "", SWT.MULTI | SWT.BORDER);
parameterValueText.setLayoutData(new GridData(GridData.FILL_BOTH));
parameterValueText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
StructuredSelection selection = (StructuredSelection) testportParametersTableViewer.getSelection();
Iterator<?> iterator = selection.iterator();
if (!iterator.hasNext()) {
return;
}
TestportParameter testportParameter = (TestportParameter) iterator.next();
ConfigTreeNodeUtilities.setText(testportParameter.getValue(), parameterValueText.getText());
if (valueChanged) {
valueChanged = false;
return;
}
editor.setDirty();
}
});
parameterValueText.setEnabled(testportParametersHandler != null);
section.setText("Testport parameter details");
section.setDescription("Specify the concrete value for the actually selected testport parameter.");
section.setClient(client);
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
GridData gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessVerticalSpace = true;
section.setLayoutData(gd);
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.
the class ModuleParameterSectionPage method createDetailsPart.
private void createDetailsPart(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 = 1;
client.setLayout(layout);
parameterValueText = toolkit.createText(client, "", SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
parameterValueText.setLayoutData(new GridData(GridData.FILL_BOTH));
parameterValueText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
StructuredSelection selection = (StructuredSelection) moduleParametersTableViewer.getSelection();
Iterator<?> iterator = selection.iterator();
if (!iterator.hasNext()) {
return;
}
ModuleParameter moduleParameter = (ModuleParameter) iterator.next();
ConfigTreeNodeUtilities.setText(moduleParameter.getValue(), parameterValueText.getText());
if (valueChanged) {
valueChanged = false;
return;
}
editor.setDirty();
}
});
parameterValueText.setEnabled(moduleParametersHandler != null);
section.setText("Module parameter value");
section.setDescription("Specify the concrete value for the actually selected module parameter.");
section.setClient(client);
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
GridData gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessVerticalSpace = true;
section.setLayoutData(gd);
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.
the class ExecuteSubPage method createExecuteSection.
void createExecuteSection(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));
section.setText("Elements to be executed");
section.setDescription("Specify the list of testcases and control parts to be executed for this configuration.\n" + "Use drag&drop to change the order of elements.");
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
GridData gd = new GridData(GridData.FILL_BOTH);
section.setLayoutData(gd);
Composite client = toolkit.createComposite(section, SWT.WRAP);
section.setClient(client);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
client.setLayout(layout);
gd = new GridData(GridData.FILL_BOTH);
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.verticalAlignment = SWT.FILL;
client.setLayoutData(gd);
toolkit.paintBordersFor(client);
executeElementsTable = toolkit.createTable(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
executeElementsTable.setEnabled(executeSectionHandler != null);
TableColumn column = new TableColumn(executeElementsTable, SWT.LEFT, 0);
column.setText("Module name");
column.setWidth(200);
column.setMoveable(false);
column = new TableColumn(executeElementsTable, SWT.LEFT, 1);
column.setText("Testcase name");
column.setMoveable(false);
column.setWidth(200);
executeElementsTable.setHeaderVisible(true);
executeElementsTable.setLinesVisible(true);
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;
executeElementsTable.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(executeSectionHandler != null);
add.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (executeSectionHandler == null) {
return;
}
if (executeSectionHandler.getLastSectionRoot() == null) {
createNewExecuteSection();
}
ExecuteItem newItem = createNewExecuteItem();
if (newItem == null) {
return;
}
ConfigTreeNodeUtilities.addChild(executeSectionHandler.getLastSectionRoot(), newItem.getRoot());
executeSectionHandler.getExecuteitems().add(newItem);
internalRefresh();
executeElementsTable.select(executeSectionHandler.getExecuteitems().size() - 1);
executeElementsTable.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(executeSectionHandler != null);
remove.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(final SelectionEvent e) {
// Do nothing
}
@Override
public void widgetSelected(final SelectionEvent e) {
if (executeElementsTableViewer == null || executeSectionHandler == null) {
return;
}
removeSelectedExecuteItems();
if (executeSectionHandler.getExecuteitems().isEmpty()) {
removeExecuteSection();
}
internalRefresh();
editor.setDirty();
}
});
totalExecuteElementsLabel = toolkit.createLabel(buttons, "Total: 0");
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
totalExecuteElementsLabel.setLayoutData(gd);
executeElementsTableViewer = new TableViewer(executeElementsTable);
executeElementsTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
// not needed this time
}
});
executeElementsTableViewer.setContentProvider(new ExecuteDataContentProvider());
executeElementsTableViewer.setLabelProvider(new ExecuteDataLabelProvider());
executeElementsTableViewer.setInput(executeSectionHandler);
executeElementsTableViewer.setColumnProperties(COLUMN_NAMES);
executeElementsTableViewer.setCellEditors(new TextCellEditor[] { new TextCellEditor(executeElementsTable), new TextCellEditor(executeElementsTable) });
executeElementsTableViewer.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);
ExecuteDataLabelProvider labelProvider = (ExecuteDataLabelProvider) executeElementsTableViewer.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) {
ExecuteItem executeItem = (ExecuteItem) ((TableItem) element).getData();
switch(columnIndex) {
case 0:
ConfigTreeNodeUtilities.setText(executeItem.getModuleName(), ((String) value).trim());
break;
case 1:
ConfigTreeNodeUtilities.setText(executeItem.getTestcaseName(), ((String) value).trim());
break;
default:
break;
}
executeElementsTableViewer.refresh(executeItem);
editor.setDirty();
}
}
});
executeElementsTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { ExecuteItemTransfer.getInstance() }, new ExecuteSectionDragSourceListener(this, executeElementsTableViewer));
executeElementsTableViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT, new Transfer[] { ExecuteItemTransfer.getInstance() }, new ExecuteSectionDropTargetListener(executeElementsTableViewer, editor));
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.
the class ExternalCommandsSubPage method createExternalcommandsSection.
void createExternalcommandsSection(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));
section.setText("External commands");
section.setDescription("Specify the external commands to be called at execution time for this configuration.");
section.setExpanded(true);
section.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(final ExpansionEvent e) {
form.reflow(false);
}
});
GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
section.setLayoutData(gd);
Composite client = toolkit.createComposite(section, SWT.WRAP);
section.setClient(client);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
client.setLayout(layout);
toolkit.paintBordersFor(client);
valueChanged = true;
toolkit.createLabel(client, "Begin control part:");
beginControlPartText = toolkit.createText(client, "", SWT.SINGLE);
beginControlPartText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
beginControlPartText.setEnabled(executeCommandSectionHandler != null);
beginControlPartText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
if (valueChanged || executeCommandSectionHandler == null) {
return;
}
editor.setDirty();
String temp = beginControlPartText.getText();
if (temp == null || temp.length() == 0) {
// remove the node
if (executeCommandSectionHandler.getBeginControlPartRoot() != null) {
ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getBeginControlPartRoot());
}
executeCommandSectionHandler.setBeginControlPart(null);
executeCommandSectionHandler.setBeginControlPartRoot(null);
removeExternalCommandsSection();
} else if (executeCommandSectionHandler.getBeginControlPart() == null) {
// create the node
createExternalCommandsSection();
ParseTree beginControlPartRoot = new ParserRuleContext();
executeCommandSectionHandler.setBeginControlPartRoot(beginControlPartRoot);
ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), beginControlPartRoot);
ConfigTreeNodeUtilities.addChild(beginControlPartRoot, new AddedParseTree("\nbeginControlPart := "));
ParseTree beginControlPart = new AddedParseTree(temp.trim());
executeCommandSectionHandler.setBeginControlPart(beginControlPart);
ConfigTreeNodeUtilities.addChild(beginControlPartRoot, beginControlPart);
} else {
// simple modification
ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getBeginControlPart(), temp.trim());
}
}
});
if (executeCommandSectionHandler != null && executeCommandSectionHandler.getBeginControlPart() != null) {
beginControlPartText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getBeginControlPart()));
}
Button browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
browse.addSelectionListener(new ExternalCommandBrowser(beginControlPartText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
toolkit.createLabel(client, "Begin testcase:");
beginTestCaseText = toolkit.createText(client, "", SWT.SINGLE);
beginTestCaseText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
beginTestCaseText.setEnabled(executeCommandSectionHandler != null);
beginTestCaseText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
if (valueChanged || executeCommandSectionHandler == null) {
return;
}
editor.setDirty();
String temp = beginTestCaseText.getText();
if (temp == null || temp.length() == 0) {
// remove the node
if (executeCommandSectionHandler.getBeginTestcaseRoot() != null) {
ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getBeginTestcaseRoot());
}
executeCommandSectionHandler.setBeginTestcase(null);
executeCommandSectionHandler.setBeginTestcaseRoot(null);
removeExternalCommandsSection();
} else if (executeCommandSectionHandler.getBeginTestcase() == null) {
// create the node
createExternalCommandsSection();
ParseTree beginTestcaseRoot = new ParserRuleContext();
executeCommandSectionHandler.setBeginTestcaseRoot(beginTestcaseRoot);
ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), beginTestcaseRoot);
ConfigTreeNodeUtilities.addChild(beginTestcaseRoot, new AddedParseTree("\nbeginTestcase := "));
ParseTree beginTestcase = new AddedParseTree(temp.trim());
executeCommandSectionHandler.setBeginTestcase(beginTestcase);
ConfigTreeNodeUtilities.addChild(beginTestcaseRoot, beginTestcase);
} else {
// simple modification
ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getBeginTestcase(), temp.trim());
}
}
});
if (executeCommandSectionHandler != null && executeCommandSectionHandler.getBeginTestcase() != null) {
beginTestCaseText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getBeginTestcase()));
}
browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
browse.addSelectionListener(new ExternalCommandBrowser(beginTestCaseText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
toolkit.createLabel(client, "End control part:");
endControlPartText = toolkit.createText(client, "", SWT.SINGLE);
endControlPartText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
endControlPartText.setEnabled(executeCommandSectionHandler != null);
endControlPartText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
if (valueChanged || executeCommandSectionHandler == null) {
return;
}
editor.setDirty();
String temp = endControlPartText.getText();
if (temp == null || temp.length() == 0) {
// remove the node
if (executeCommandSectionHandler.getEndControlPartRoot() != null) {
ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getEndControlPartRoot());
}
executeCommandSectionHandler.setEndControlPart(null);
executeCommandSectionHandler.setEndControlPartRoot(null);
removeExternalCommandsSection();
} else if (executeCommandSectionHandler.getEndControlPart() == null) {
// create the node
createExternalCommandsSection();
ParseTree endControlPartRoot = new ParserRuleContext();
executeCommandSectionHandler.setEndControlPartRoot(endControlPartRoot);
ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), endControlPartRoot);
ConfigTreeNodeUtilities.addChild(endControlPartRoot, new AddedParseTree("\nendControlPart := "));
ParseTree endControlPart = new AddedParseTree(temp.trim());
executeCommandSectionHandler.setEndControlPart(endControlPart);
ConfigTreeNodeUtilities.addChild(endControlPartRoot, endControlPart);
} else {
// simple modification
ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getEndControlPart(), temp.trim());
}
}
});
if (executeCommandSectionHandler != null && executeCommandSectionHandler.getEndControlPart() != null) {
endControlPartText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getEndControlPart()));
}
browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
browse.addSelectionListener(new ExternalCommandBrowser(endControlPartText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
toolkit.createLabel(client, "End testcase:");
endTestCaseText = toolkit.createText(client, "", SWT.SINGLE);
endTestCaseText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
endTestCaseText.setEnabled(executeCommandSectionHandler != null);
endTestCaseText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
if (valueChanged || executeCommandSectionHandler == null) {
return;
}
editor.setDirty();
String temp = endTestCaseText.getText();
if (temp == null || temp.length() == 0) {
// remove the node
if (executeCommandSectionHandler.getEndTestcaseRoot() != null) {
ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getEndTestcaseRoot());
}
executeCommandSectionHandler.setEndTestcase(null);
executeCommandSectionHandler.setEndTestcaseRoot(null);
removeExternalCommandsSection();
} else if (executeCommandSectionHandler.getEndTestcase() == null) {
// create the node
createExternalCommandsSection();
ParseTree endTestcaseRoot = new ParserRuleContext();
executeCommandSectionHandler.setEndTestcaseRoot(endTestcaseRoot);
ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), endTestcaseRoot);
ConfigTreeNodeUtilities.addChild(endTestcaseRoot, new AddedParseTree("\nendTestcase := "));
ParseTree endTestcase = new AddedParseTree(temp.trim());
executeCommandSectionHandler.setEndTestcase(endTestcase);
ConfigTreeNodeUtilities.addChild(endTestcaseRoot, endTestcase);
} else {
// simple modification
ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getEndTestcase(), temp.trim());
}
}
});
if (executeCommandSectionHandler != null && executeCommandSectionHandler.getEndTestcase() != null) {
endTestCaseText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getEndTestcase()));
}
browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
browse.addSelectionListener(new ExternalCommandBrowser(endTestCaseText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
valueChanged = false;
}
use of org.eclipse.ui.forms.events.ExpansionAdapter in project titan.EclipsePlug-ins by eclipse.
the class BaseNamingConventionPropertyPage 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;
}
Aggregations