use of org.eclipse.swt.widgets.MessageBox in project tdi-studio-se by Talend.
the class ImportExchangeDialog method okPressed.
@Override
protected void okPressed() {
//$NON-NLS-1$ //$NON-NLS-2$
IPath tempPath = new Path(System.getProperty("user.dir")).append("temp");
File pathFile = tempPath.toFile();
if (downloadproperty.getFileName() == null || downloadproperty.getFileName() == null) {
MessageBox box = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
//$NON-NLS-1$
box.setText(Messages.getString("ImportExchangeDialog.WARNING"));
//$NON-NLS-1$
box.setMessage(Messages.getString("ImportExchangeDialog.NOTSELECTWARNING"));
box.open();
return;
}
tempFile = new File(pathFile, downloadproperty.getFileName());
try {
url = new URL(downloadproperty.getDownloadUrl());
} catch (MalformedURLException e1) {
ExceptionHandler.process(e1);
}
if (!pathFile.exists()) {
pathFile.mkdirs();
}
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell().getShell());
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("ImportExchangeDialog.downloadProgressBar"), IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
try {
new DownloadHelper().download(url, tempFile);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
});
monitor.done();
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
}
selectFile = tempFile.toString();
super.okPressed();
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class AddressBook method closeAddressBook.
private boolean closeAddressBook() {
if (isModified) {
// ask user if they want to save current address book
MessageBox box = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO | SWT.CANCEL);
box.setText(shell.getText());
box.setMessage(resAddressBook.getString("Close_save"));
int choice = box.open();
if (choice == SWT.CANCEL) {
return false;
} else if (choice == SWT.YES) {
if (!save())
return false;
}
}
TableItem[] items = table.getItems();
for (TableItem item : items) {
item.dispose();
}
return true;
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class AddressBook method createHelpMenu.
/**
* Creates all the items located in the Help submenu and
* associate all the menu items with their appropriate
* functions.
*
* @param menuBar Menu
* the <code>Menu</code> that file contain
* the Help submenu.
*/
private void createHelpMenu(Menu menuBar) {
// Help Menu
MenuItem item = new MenuItem(menuBar, SWT.CASCADE);
item.setText(resAddressBook.getString("Help_menu_title"));
Menu menu = new Menu(shell, SWT.DROP_DOWN);
item.setMenu(menu);
// Help -> About Text Editor
MenuItem subItem = new MenuItem(menu, SWT.NONE);
subItem.setText(resAddressBook.getString("About"));
subItem.addSelectionListener(widgetSelectedAdapter(e -> {
MessageBox box = new MessageBox(shell, SWT.NONE);
box.setText(resAddressBook.getString("About_1") + shell.getText());
box.setMessage(shell.getText() + resAddressBook.getString("About_2"));
box.open();
}));
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class BrowserTab method createExampleWidgets.
/**
* Creates the "Example" widgets.
*/
@Override
void createExampleWidgets() {
/* Compute the widget style */
int style = getDefaultStyle();
if (borderButton.getSelection())
style |= SWT.BORDER;
if (webKitButton.getSelection())
style |= SWT.WEBKIT;
/* Create the example widgets */
try {
browser = new Browser(browserGroup, style);
} catch (SWTError e) {
// Probably missing browser
try {
browser = new Browser(browserGroup, style & ~(SWT.WEBKIT));
} catch (SWTError e2) {
// Unsupported platform
errorMessage = e.getMessage();
return;
}
MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
String resourceString = "WebKitNotFound";
dialog.setMessage(ControlExample.getResourceString(resourceString, e.getMessage()));
dialog.open();
}
if (lastUrl != null) {
browser.setUrl(lastUrl);
} else if (lastText != null) {
browser.setText(lastText);
} else {
StringBuilder sb = new StringBuilder(300);
try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html");
BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) {
int read = 0;
while ((read = br.read()) != -1) sb.append((char) read);
} catch (IOException e) {
log(e.getMessage());
}
String text = sb.toString();
browser.setText(text);
}
lastText = lastUrl = null;
}
use of org.eclipse.swt.widgets.MessageBox in project eclipse.platform.swt by eclipse.
the class DialogTab method createControlWidgets.
/**
* Creates the "Control" widget children.
*/
@Override
void createControlWidgets() {
/* Create the combo */
String[] strings = { ControlExample.getResourceString("ColorDialog"), ControlExample.getResourceString("DirectoryDialog"), ControlExample.getResourceString("FileDialog"), ControlExample.getResourceString("FontDialog"), ControlExample.getResourceString("PrintDialog"), ControlExample.getResourceString("MessageBox") };
dialogCombo = new Combo(dialogStyleGroup, SWT.READ_ONLY);
dialogCombo.setItems(strings);
dialogCombo.setText(strings[0]);
dialogCombo.setVisibleItemCount(strings.length);
/* Create the create dialog button */
createButton = new Button(dialogStyleGroup, SWT.NONE);
createButton.setText(ControlExample.getResourceString("Create_Dialog"));
createButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
/* Create a group for the various dialog button style controls */
Group buttonStyleGroup = new Group(controlGroup, SWT.NONE);
buttonStyleGroup.setLayout(new GridLayout());
buttonStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
buttonStyleGroup.setText(ControlExample.getResourceString("Button_Styles"));
/* Create the button style buttons */
okButton = new Button(buttonStyleGroup, SWT.CHECK);
okButton.setText("SWT.OK");
cancelButton = new Button(buttonStyleGroup, SWT.CHECK);
cancelButton.setText("SWT.CANCEL");
yesButton = new Button(buttonStyleGroup, SWT.CHECK);
yesButton.setText("SWT.YES");
noButton = new Button(buttonStyleGroup, SWT.CHECK);
noButton.setText("SWT.NO");
retryButton = new Button(buttonStyleGroup, SWT.CHECK);
retryButton.setText("SWT.RETRY");
abortButton = new Button(buttonStyleGroup, SWT.CHECK);
abortButton.setText("SWT.ABORT");
ignoreButton = new Button(buttonStyleGroup, SWT.CHECK);
ignoreButton.setText("SWT.IGNORE");
/* Create a group for the icon style controls */
Group iconStyleGroup = new Group(controlGroup, SWT.NONE);
iconStyleGroup.setLayout(new GridLayout());
iconStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
iconStyleGroup.setText(ControlExample.getResourceString("Icon_Styles"));
/* Create the icon style buttons */
iconErrorButton = new Button(iconStyleGroup, SWT.RADIO);
iconErrorButton.setText("SWT.ICON_ERROR");
iconInformationButton = new Button(iconStyleGroup, SWT.RADIO);
iconInformationButton.setText("SWT.ICON_INFORMATION");
iconQuestionButton = new Button(iconStyleGroup, SWT.RADIO);
iconQuestionButton.setText("SWT.ICON_QUESTION");
iconWarningButton = new Button(iconStyleGroup, SWT.RADIO);
iconWarningButton.setText("SWT.ICON_WARNING");
iconWorkingButton = new Button(iconStyleGroup, SWT.RADIO);
iconWorkingButton.setText("SWT.ICON_WORKING");
noIconButton = new Button(iconStyleGroup, SWT.RADIO);
noIconButton.setText(ControlExample.getResourceString("No_Icon"));
/* Create a group for the modal style controls */
Group modalStyleGroup = new Group(controlGroup, SWT.NONE);
modalStyleGroup.setLayout(new GridLayout());
modalStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
modalStyleGroup.setText(ControlExample.getResourceString("Modal_Styles"));
/* Create the modal style buttons */
primaryModalButton = new Button(modalStyleGroup, SWT.RADIO);
primaryModalButton.setText("SWT.PRIMARY_MODAL");
applicationModalButton = new Button(modalStyleGroup, SWT.RADIO);
applicationModalButton.setText("SWT.APPLICATION_MODAL");
systemModalButton = new Button(modalStyleGroup, SWT.RADIO);
systemModalButton.setText("SWT.SYSTEM_MODAL");
/* Create a group for the file dialog style controls */
Group fileDialogStyleGroup = new Group(controlGroup, SWT.NONE);
fileDialogStyleGroup.setLayout(new GridLayout());
fileDialogStyleGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
fileDialogStyleGroup.setText(ControlExample.getResourceString("File_Dialog_Styles"));
/* Create the file dialog style buttons */
openButton = new Button(fileDialogStyleGroup, SWT.RADIO);
openButton.setText("SWT.OPEN");
saveButton = new Button(fileDialogStyleGroup, SWT.RADIO);
saveButton.setText("SWT.SAVE");
multiButton = new Button(fileDialogStyleGroup, SWT.CHECK);
multiButton.setText("SWT.MULTI");
/* Create the orientation group */
if (RTL_SUPPORT_ENABLE) {
createOrientationGroup();
}
/* Create a group for other style and setting controls */
Group otherGroup = new Group(controlGroup, SWT.NONE);
otherGroup.setLayout(new GridLayout());
otherGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
otherGroup.setText(ControlExample.getResourceString("Other"));
/* Create the other style and setting controls */
sheetButton = new Button(otherGroup, SWT.CHECK);
sheetButton.setText("SWT.SHEET");
usePreviousResultButton = new Button(otherGroup, SWT.CHECK);
usePreviousResultButton.setText(ControlExample.getResourceString("Use_Previous_Result"));
effectsVisibleButton = new Button(otherGroup, SWT.CHECK);
effectsVisibleButton.setText("FontDialog.setEffectsVisible");
/* Add the listeners */
dialogCombo.addSelectionListener(widgetSelectedAdapter(event -> dialogSelected(event)));
createButton.addSelectionListener(widgetSelectedAdapter(event -> createButtonSelected(event)));
SelectionListener buttonStyleListener = widgetSelectedAdapter(event -> buttonStyleSelected(event));
okButton.addSelectionListener(buttonStyleListener);
cancelButton.addSelectionListener(buttonStyleListener);
yesButton.addSelectionListener(buttonStyleListener);
noButton.addSelectionListener(buttonStyleListener);
retryButton.addSelectionListener(buttonStyleListener);
abortButton.addSelectionListener(buttonStyleListener);
ignoreButton.addSelectionListener(buttonStyleListener);
/* Set default values for style buttons */
okButton.setEnabled(false);
cancelButton.setEnabled(false);
yesButton.setEnabled(false);
noButton.setEnabled(false);
retryButton.setEnabled(false);
abortButton.setEnabled(false);
ignoreButton.setEnabled(false);
iconErrorButton.setEnabled(false);
iconInformationButton.setEnabled(false);
iconQuestionButton.setEnabled(false);
iconWarningButton.setEnabled(false);
iconWorkingButton.setEnabled(false);
noIconButton.setEnabled(false);
saveButton.setEnabled(false);
openButton.setEnabled(false);
openButton.setSelection(true);
multiButton.setEnabled(false);
noIconButton.setSelection(true);
effectsVisibleButton.setEnabled(false);
effectsVisibleButton.setSelection(true);
}
Aggregations