use of org.eclipse.swt.custom.ScrolledComposite in project linuxtools by eclipse.
the class SystemTapScriptGraphOptionsTab method createColumnSelector.
private void createColumnSelector(Composite parent) {
GridLayout layout = new GridLayout();
parent.setLayout(layout);
Composite topLayout = new Composite(parent, SWT.NONE);
topLayout.setLayout(new GridLayout(1, false));
topLayout.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Button generateExpsButton = new Button(topLayout, SWT.PUSH);
generateExpsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
generateExpsButton.setText(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsButton);
generateExpsButton.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsTooltip);
generateExpsButton.addSelectionListener(regexGenerator);
Composite regexButtonLayout = new Composite(parent, SWT.NONE);
regexButtonLayout.setLayout(new GridLayout(3, false));
regexButtonLayout.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Label selectedRegexLabel = new Label(regexButtonLayout, SWT.NONE);
selectedRegexLabel.setText(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
selectedRegexLabel.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_regexTooltip);
regularExpressionCombo = new Combo(regexButtonLayout, SWT.DROP_DOWN);
regularExpressionCombo.setTextLimit(MAX_REGEX_LENGTH);
regularExpressionCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
regularExpressionCombo.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
int selected = regularExpressionCombo.getSelectionIndex();
if (selected == selectedRegex) {
return;
}
// If deselecting an empty regular expression, delete it automatically.
if (regularExpressionCombo.getItem(selectedRegex).isEmpty() && graphsDataList.get(selectedRegex).size() == 0 && outputList.get(selectedRegex).isEmpty()) {
// Otherwise, the deleted blank entry would be replaced by another blank entry.
if (selected == regularExpressionCombo.getItemCount() - 1) {
// To keep the text blank.
regularExpressionCombo.select(selectedRegex);
return;
}
removeRegex(false);
if (selected > selectedRegex) {
selected--;
}
}
// update all appropriate values to make room for a new regular expression.
if (selected == regularExpressionCombo.getItemCount() - 1 && getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) {
// $NON-NLS-1$
outputList.add("");
regexErrorMessages.add(null);
columnNamesList.add(new ArrayList<String>());
cachedNamesList.add(new Stack<String>());
graphsDataList.add(new LinkedList<GraphData>());
// Remove "Add New Regex" from the selected combo item; make it blank.
// $NON-NLS-1$
regularExpressionCombo.setItem(selected, "");
regularExpressionCombo.select(selected);
updateRegexSelection(selected, false);
updateLaunchConfigurationDialog();
// (Don't do this _every_ time something is added.)
if (getNumberOfRegexs() == 2) {
removeRegexButton.setEnabled(true);
}
if (getNumberOfRegexs() < MAX_NUMBER_OF_REGEXS) {
regularExpressionCombo.add(Messages.SystemTapScriptGraphOptionsTab_regexAddNew);
}
} else {
updateRegexSelection(selected, false);
}
}));
regularExpressionCombo.addModifyListener(regexListener);
removeRegexButton = new Button(regexButtonLayout, SWT.PUSH);
removeRegexButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
removeRegexButton.setText(Messages.SystemTapScriptGraphOptionsTab_regexRemove);
removeRegexButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
IWorkbench workbench = PlatformUI.getWorkbench();
MessageDialog dialog = new MessageDialog(workbench.getActiveWorkbenchWindow().getShell(), Messages.SystemTapScriptGraphOptionsTab_removeRegexTitle, null, MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_removeRegexAsk, regularExpressionCombo.getItem(selectedRegex)), MessageDialog.QUESTION, new String[] { "Yes", "No" }, // $NON-NLS-1$ //$NON-NLS-2$
0);
int result = dialog.open();
if (result == 0) {
// Yes
removeRegex(true);
}
}));
GridLayout twoColumns = new GridLayout(2, false);
Composite regexSummaryComposite = new Composite(parent, SWT.NONE);
regexSummaryComposite.setLayout(twoColumns);
regexSummaryComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Label sampleOutputLabel = new Label(regexSummaryComposite, SWT.NONE);
sampleOutputLabel.setText(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
sampleOutputLabel.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_sampleOutputTooltip);
this.sampleOutputText = new Text(regexSummaryComposite, SWT.BORDER);
this.sampleOutputText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
this.sampleOutputText.addModifyListener(sampleOutputListener);
sampleOutputText.setToolTipText(Messages.SystemTapScriptGraphOptionsTab_sampleOutputTooltip);
Composite expressionTableLabels = new Composite(parent, SWT.NONE);
expressionTableLabels.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
expressionTableLabels.setLayout(twoColumns);
Label label = new Label(expressionTableLabels, SWT.NONE);
label.setText(Messages.SystemTapScriptGraphOptionsTab_columnTitle);
label.setAlignment(SWT.LEFT);
Label label2 = new Label(expressionTableLabels, SWT.NONE);
label2.setAlignment(SWT.LEFT);
label2.setText(Messages.SystemTapScriptGraphOptionsTab_extractedValueLabel);
ScrolledComposite regexTextScrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
data.heightHint = 200;
regexTextScrolledComposite.setLayoutData(data);
textFieldsComposite = new Composite(regexTextScrolledComposite, SWT.NONE);
textFieldsComposite.setLayout(new GridLayout(4, false));
regexTextScrolledComposite.setContent(textFieldsComposite);
regexTextScrolledComposite.setExpandHorizontal(true);
// To position the column labels properly, add a dummy column and use its children's sizes for reference.
// This is necessary since expressionTableLabels can't share a layout with textFieldsComposite.
textListenersEnabled = false;
addColumn(null);
data = new GridData(SWT.FILL, SWT.FILL, false, false);
data.horizontalIndent = textFieldsComposite.getChildren()[2].getLocation().x;
data.widthHint = textFieldsComposite.getChildren()[2].getSize().x;
label.setLayoutData(data);
label2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
removeColumn(false);
textListenersEnabled = true;
}
use of org.eclipse.swt.custom.ScrolledComposite in project linuxtools by eclipse.
the class PackageVMPage method createControl.
@Override
public void createControl(Composite parent) {
ScrolledComposite scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrollTop.setExpandVertical(true);
scrollTop.setExpandHorizontal(true);
final Composite container = new Composite(scrollTop, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(3).margins(6, 6).applyTo(container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true, false).applyTo(container);
// Box name
final Label boxNameLabel = new Label(container, SWT.NONE);
boxNameLabel.setText(// $NON-NLS-1$
WizardMessages.getString("ImagePull.name.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxNameLabel);
final Text boxNameText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(2, 1).applyTo(boxNameText);
boxNameText.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("ImagePull.name.tooltip"));
// Name binding
final IObservableValue<String> boxNameObservable = BeanProperties.value(PackageVMPageModel.class, PackageVMPageModel.BOX_NAME).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxNameText), boxNameObservable, new UpdateValueStrategy(), null);
// Box folder
final Label boxFolderLabel = new Label(container, SWT.NONE);
// $NON-NLS-1$
boxFolderLabel.setText(WizardMessages.getString("PackageVMPage.folder.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(boxFolderLabel);
final Text boxFolderText = new Text(container, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(boxFolderText);
boxFolderText.setToolTipText(// $NON-NLS-1$
WizardMessages.getString("PackageVMPage.folder.desc"));
// Folder binding
final IObservableValue<String> boxFolderObservable = BeanProperties.value(PackageVMPageModel.class, PackageVMPageModel.BOX_FOLDER).observe(model);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(boxFolderText), boxFolderObservable, new UpdateValueStrategy(), null);
// search
final Button searchButton = new Button(container, SWT.NONE);
searchButton.setText(// $NON-NLS-1$
WizardMessages.getString("ImagePull.search.label"));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(searchButton);
searchButton.addSelectionListener(onSearchFolder());
dbc.addValidationStatusProvider(new PackageVMValidationStatusProvider(boxNameObservable, boxFolderObservable));
// setup validation support
WizardPageSupport.create(this, dbc);
scrollTop.setContent(container);
Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrollTop.setSize(point);
scrollTop.setMinSize(point);
setControl(container);
}
use of org.eclipse.swt.custom.ScrolledComposite in project linuxtools by eclipse.
the class EnvironmentVariablesPreferencePage method createContents.
/**
* Creates a ScrolledComposite, sets options on oit, opens string field editors for the
* preferences.
*
* @param parent The parent of the ScrolledComposite object.
*
* @return The ScrolledComposite object that is created configured.
*/
@Override
protected Control createContents(Composite parent) {
ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
Composite c = new Composite(sc, SWT.NONE);
sc.setExpandHorizontal(true);
sc.setExpandVertical(true);
sc.setContent(c);
envVariables = new StringFieldEditor[PreferenceConstants.P_ENV.values().length];
int i = 0;
for (PreferenceConstants.P_ENV env : PreferenceConstants.P_ENV.values()) {
envVariables[i] = createStringFieldEditor(env.toPrefKey(), env.toEnvKey(), c);
i++;
}
return sc;
}
use of org.eclipse.swt.custom.ScrolledComposite in project linuxtools by eclipse.
the class NewDockerConnectionPage method createControl.
@Override
public void createControl(final Composite parent) {
final ScrolledComposite scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrollTop.setExpandVertical(true);
scrollTop.setExpandHorizontal(true);
final Composite container = new Composite(scrollTop, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(container);
createConnectionSettingsContainer(container);
// attach the Databinding context status to this wizard page.
WizardPageSupport.create(this, this.dbc);
Clipboard clip = new Clipboard(Display.getCurrent());
String content = (String) clip.getContents(TextTransfer.getInstance(), DND.SELECTION_CLIPBOARD);
// DOCKER_HOST is the minimal property needed
if (content != null && content.contains(DefaultDockerConnectionSettingsFinder.DOCKER_HOST)) {
retrieveConnectionSettings(content);
} else {
content = (String) clip.getContents(TextTransfer.getInstance(), DND.CLIPBOARD);
if (content != null && content.contains(DefaultDockerConnectionSettingsFinder.DOCKER_HOST)) {
retrieveConnectionSettings(content);
} else {
retrieveDefaultConnectionSettings();
}
}
scrollTop.setContent(container);
Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrollTop.setSize(point);
scrollTop.setMinSize(point);
setControl(container);
}
use of org.eclipse.swt.custom.ScrolledComposite in project linuxtools by eclipse.
the class ImageRunResourceVolumesVariablesPage method createControl.
@Override
public void createControl(Composite parent) {
final ScrolledComposite scrollTop = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrollTop.setExpandVertical(true);
scrollTop.setExpandHorizontal(true);
final Composite container = new Composite(scrollTop, SWT.NONE);
GridLayoutFactory.fillDefaults().numColumns(COLUMNS).margins(6, 6).applyTo(container);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(container);
createVolumeSettingsContainer(container);
// createSectionSeparator(container, true);
createEnvironmentVariablesContainer(container);
createLabelVariablesContainer(container);
createSectionSeparator(container, true);
createResourceSettingsContainer(container);
setDefaultValues();
scrollTop.setContent(container);
Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
scrollTop.setSize(point);
scrollTop.setMinSize(point);
// TODO: Workaround https://bugs.eclipse.org/bugs/show_bug.cgi?id=487160
setControl(scrollTop);
}
Aggregations