use of org.eclipse.jface.dialogs.MessageDialog 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.jface.dialogs.MessageDialog in project linuxtools by eclipse.
the class NewDockerConnectionPage method onTestConnectionButtonSelection.
/**
* Verifies that the given connection settings work by trying to connect to
* the target Docker daemon
*
* @return
*/
private SelectionListener onTestConnectionButtonSelection() {
return new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent event) {
try {
getWizard().getContainer().run(true, false, monitor -> {
monitor.beginTask(WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.pingTask"), IProgressMonitor.UNKNOWN);
try {
final DockerConnection dockerConnection = getDockerConnection();
dockerConnection.open(false);
dockerConnection.ping();
dockerConnection.close();
// ping succeeded
displaySuccessDialog();
} catch (DockerException e) {
// in Eclipse.org AERI
if (e.getCause() != null) {
displayErrorDialog(e.getCause());
} else {
displayErrorDialog(e);
}
}
});
} catch (InvocationTargetException | InterruptedException o_O) {
Activator.log(o_O);
}
}
private void displaySuccessDialog() {
displayDialog(WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.success"), WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.pingSuccess"), SWT.ICON_INFORMATION, new String[] { WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.ok") });
}
private void displayErrorDialog(final Throwable cause) {
displayDialog(WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.failure"), WizardMessages.getFormattedString(// $NON-NLS-1$
"DockerConnectionPage.pingFailure", cause.getMessage()), SWT.ICON_ERROR, new String[] { WizardMessages.getString(// $NON-NLS-1$
"DockerConnectionPage.ok") });
}
private void displayDialog(final String dialogTitle, final String dialogMessage, final int icon, final String[] buttonLabels) {
Display.getDefault().syncExec(() -> new MessageDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null, dialogMessage, icon, buttonLabels, 0).open());
}
};
}
use of org.eclipse.jface.dialogs.MessageDialog in project linuxtools by eclipse.
the class STDataViewersExportToCSVDialog method okPressed.
@Override
protected void okPressed() {
File f = new File(outputFile.getText());
if (f.exists()) {
MessageDialog dialog = new MessageDialog(this.getShell(), "Warning: file already exists", null, "File \"" + f.getAbsolutePath() + "\" already exists.\n" + "Overwrite it anyway?", MessageDialog.WARNING, new String[] { "OK", "Cancel" }, 1);
if (dialog.open() > 0) {
return;
}
}
if (isDirty()) {
saveExporterSettings();
}
super.okPressed();
}
use of org.eclipse.jface.dialogs.MessageDialog in project knime-core by knime.
the class WorkflowEditor method promptToSaveOnClose.
/**
* Brings up the Save-Dialog and sets the m_isClosing flag.
* {@inheritDoc}
*/
@Override
public int promptToSaveOnClose() {
/*
* Ideally we would just set the m_isClosing flag and return
* ISaveablePart2.DEFAULT which will bring up a separate dialog. This
* does not work as we have to set the m_isClosing only if the user
* presses YES (no means to figure out what button was pressed when
* eclipse opens the dialog).
*/
if (m_parentEditor != null) {
// ignore closing metanode editors.
return ISaveablePart2.NO;
}
String message = NLS.bind(WorkbenchMessages.EditorManager_saveChangesQuestion, getTitle());
// Show a dialog.
Shell sh = Display.getDefault().getActiveShell();
String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL };
MessageDialog d = new MessageDialog(sh, WorkbenchMessages.Save_Resource, null, message, MessageDialog.QUESTION, buttons, 0);
switch(// returns index in buttons[] array
d.open()) {
case // YES
0:
m_isClosing = true;
return ISaveablePart2.YES;
case // NO
1:
return ISaveablePart2.NO;
default:
// CANCEL button or window 'x'
return ISaveablePart2.CANCEL;
}
}
Aggregations