本文整理汇总了Java中org.eclipse.swt.widgets.MessageBox类的典型用法代码示例。如果您正苦于以下问题:Java MessageBox类的具体用法?Java MessageBox怎么用?Java MessageBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageBox类属于org.eclipse.swt.widgets包,在下文中一共展示了MessageBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runWithObject
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
@Override
public void runWithObject(Object object) throws Exception {
String typeName = getObjectTypeName(object);
if (typeName == null) {
return;
}
String name = getObjectName(object);
if (name == null) {
return;
}
MessageBox messageBox = new MessageBox(getActiveShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Are you sure you want to delete the " + typeName + " '" + name + "'?");
messageBox.setText("Confirm Delete");
int response = messageBox.open();
if (response == SWT.YES) {
try {
delete(object);
}
catch (Exception e) {
throw new Exception("Failed to delete the " + typeName + " '" + name + "'.", e);
}
}
}
示例2: closeTranscription
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
/**
* @return true if the transcription was closed, false if the operation was
* cancelled
*/
protected boolean closeTranscription() {
if (!textEditor.isDisposed()) {
if (textEditor.isChanged()) {
MessageBox diag = new MessageBox(shell,
SWT.APPLICATION_MODAL | SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.CANCEL);
diag.setMessage("You have unsaved changes, would you like to save them?");
int opt = diag.open();
if (opt == SWT.YES)
saveTranscription();
if (opt == SWT.CANCEL)
return false;
}
textEditor.clear();
transcriptionFile = null;
}
return true;
}
示例3: openTranscriptionFile
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
protected void openTranscriptionFile(File f) {
if (!textEditor.isDisposed()) {
try {
closeTranscription();
transcriptionFile = f;
textEditor.loadTranscription(transcriptionFile);
textFilesCache.add(transcriptionFile);
shell.setText(f.getName());
} catch (Exception e) {
textEditor.clear();
textFilesCache.remove(transcriptionFile);
MessageBox diag = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
diag.setMessage("Unable to open file " + f.getPath());
diag.open();
transcriptionFile = null;
}
}
}
示例4: exportTextFile
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
protected void exportTextFile() {
boolean done = false;
while (!done)
if (!textEditor.isDisposed()) {
FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
fd.setFilterNames(new String[] { "Plain text file (*.txt)", "All Files (*.*)" });
fd.setFilterExtensions(new String[] { "*.txt", "*.*" });
String lastPath = Config.getInstance().getString(Config.LAST_EXPORT_TRANSCRIPTION_PATH);
if (lastPath != null && !lastPath.isEmpty())
fd.setFileName(lastPath);
String file = fd.open();
try {
if (file != null) {
Config.getInstance().putValue(Config.LAST_EXPORT_TRANSCRIPTION_PATH, file);
File destFile = new File(file);
boolean overwrite = true;
if (destFile.exists())
overwrite = MessageDialog.openConfirm(shell, "Overwrite current file?",
"Would you like to overwrite " + destFile.getName() + "?");
if (overwrite) {
textEditor.exportText(new File(file));
done = true;
}
} else
done = true;
} catch (Exception e) {
e.printStackTrace();
MessageBox diag = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
diag.setMessage("Unable to export to file " + transcriptionFile.getPath());
diag.open();
}
}
}
示例5: importTextFile
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
protected void importTextFile(File f) {
if (!textEditor.isDisposed()) {
FileDialog fd = new FileDialog(shell, SWT.OPEN);
fd.setText("Import text");
fd.setFilterExtensions(new String[] { "*.txt;*.TXT" });
fd.setFilterNames(new String[] { "Plain text files (*.txt)" });
String selected = fd.open();
if (selected != null) {
try {
textEditor.importText(new File(selected));
} catch (IOException e) {
e.printStackTrace();
MessageBox diag = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
diag.setMessage("Unable to open file " + transcriptionFile.getPath());
diag.open();
}
}
}
}
示例6: removeCordovaDirectory
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
/***
* Dialog yes/no which ask to user if we want
* remove the cordova directory present into "_private" directory
* We also explain, what we do and how to recreate the cordova environment
*/
public void removeCordovaDirectory() {
String mobilePlatformName = mobilePlatform.getName();
if (parentShell != null) {
MessageBox customDialog = new MessageBox(parentShell, SWT.ICON_INFORMATION | SWT.YES | SWT.NO);
customDialog.setText("Remove cordova directory");
customDialog.setMessage("Do you want to remove the Cordova directory located in \"_private\\localbuild\\" +
mobilePlatformName + "\" directory?\n\n" +
"It will also remove this project's Cordova environment!\n\n" +
"To recreate the project's Cordova environment, you just need to run a new local build."
);
if (customDialog.open() == SWT.YES) {
buildLocally.removeCordovaDirectory();
} else {
return;
}
} else {
//TODO
}
}
示例7: reset
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
public void reset() {
JavelinConnector javelinConnector = (JavelinConnector) connector;
Javelin javelin = javelinConnector.javelin;
int emulatorID = (int) javelinConnector.emulatorID;
switch (emulatorID) {
case Session.EmulIDSNA:
case Session.EmulIDAS400:
MessageBox messageBox = new MessageBox(getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION
| SWT.APPLICATION_MODAL);
String message = "This will send a KEY_RESET to the emulator.";
messageBox.setMessage(message);
int ret = messageBox.open();
if (ret == SWT.OK) {
javelin.doAction("KEY_RESET");
Engine.logEmulators
.info("KEY_RESET has been sent to the emulator, because of an user request.");
}
break;
default:
ConvertigoPlugin
.warningMessageBox("The Reset function is only available for IBM emulators (3270 and AS/400).");
break;
}
}
示例8: toolSelected
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
@Override
public void toolSelected() {
Sketch sketch = AvoGlobal.project.getActiveSketch();
if(sketch == null || sketch.isConsumed){
MessageBox m = new MessageBox(AvoGlobal.menuet.getShell(), SWT.ICON_QUESTION | SWT.OK);
m.setMessage( "You must select an unconsumed sketch before\n" +
"any 2Dto3D operations can be performed.\n\n" +
"Please create a new sketch or select one\n" +
"by double-clicking on it in the project's\n" +
"list of elements.");
m.setText("Please select a sketch");
m.open();
}else{
// there is a sketch active!
changeMenuetToolMode(Menuet.MENUET_MODE_BUILD);
// TODO: Building should not be done in the view!!
sketch.buildRegions();
int i = AvoGlobal.project.getActivePart().addNewFeat2D3D(sketch.getUniqueID());
AvoGlobal.project.getActivePart().setActiveSubPart(i);
}
}
示例9: okPressed
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
@Override
protected void okPressed() {
int dbport;
String port = txtDbPort.getText();
if(txtDbPort.getText().isEmpty()) {
dbport = 0;
} else {
try {
dbport = Integer.parseInt(port);
} catch (NumberFormatException ex) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR);
mb.setText(Messages.dbStoreEditorDialog_cannot_save_entry);
mb.setMessage(MessageFormat.format(
Messages.dbStoreEditorDialog_not_valid_port_number,
port));
mb.open();
return;
}
}
dbInfo = new DbInfo(txtName.getText(), txtDbName.getText(),
txtDbUser.getText(), txtDbPass.getText(),
txtDbHost.getText(), dbport);
super.okPressed();
}
示例10: execute
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
IWorkbenchPart part = HandlerUtil.getActiveEditor(event);
if (part instanceof SQLEditor){
SQLEditor sqlEditor = (SQLEditor) part;
if (sqlEditor.getCurrentDb() != null) {
sqlEditor.updateDdl();
} else {
MessageBox mb = new MessageBox(HandlerUtil.getActiveShell(event), SWT.ICON_INFORMATION);
mb.setText(Messages.UpdateDdl_select_source);
mb.setMessage(Messages.UpdateDdl_select_source_msg);
mb.open();
}
}
return null;
}
示例11: populateViewParameterFileBox
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
private void populateViewParameterFileBox(ParameterFile parameterFile) {
//parameterFileTextBox.setText(file.getPath());
try {
Map<String, String> parameterMap = new LinkedHashMap<>();
parameterMap = ParameterFileManager.getInstance().getParameterMap(getParamterFileLocation(parameterFile));
setGridData(parameters, parameterMap);
parameterTableViewer.setData("CURRENT_PARAM_FILE", getParamterFileLocation(parameterFile));
} catch (IOException ioException) {
MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR
| SWT.OK);
messageBox.setText(MessageType.ERROR.messageType());
messageBox.setMessage(ErrorMessages.UNABLE_TO_POPULATE_PARAM_FILE
+ ioException.getMessage());
messageBox.open();
logger.debug("Unable to populate parameter file", ioException);
}
parameterTableViewer.refresh();
}
示例12: loadSchemaFromExternalFile
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
/**
**
* This methods loads schema from external schema file
*
* @param externalSchemaFilePath
* @param schemaType
* @return
*/
public List<GridRow> loadSchemaFromExternalFile(String externalSchemaFilePath,String schemaType) {
IPath filePath=new Path(externalSchemaFilePath);
IPath copyOfFilePath=filePath;
if (!filePath.isAbsolute()) {
filePath = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath).getRawLocation();
}
if(filePath!=null && filePath.toFile().exists()){
GridRowLoader gridRowLoader=new GridRowLoader(schemaType, filePath.toFile());
return gridRowLoader.importGridRowsFromXML();
}else{
MessageBox messageBox=new MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_ERROR);
messageBox.setMessage(Messages.FAILED_TO_IMPORT_SCHEMA_FILE+"\n"+copyOfFilePath.toString());
messageBox.setText(Messages.ERROR);
messageBox.open();
}
return null;
}
示例13: showMessageForGeneratingUniqueJobId
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
/**
* Create a Message Box displays a currentJob UniqueId and a message to
* generate new Unique Id.
* @param container
* @param jobFile
* @param isSubjob
* @return {@link Integer}
*/
private int showMessageForGeneratingUniqueJobId(Container container, IFile jobFile, boolean isSubJob) {
int buttonId = SWT.NO;
if(StringUtils.isBlank(container.getUniqueJobId())){
return SWT.YES;
}
MessageBox messageBox = new MessageBox(Display.getCurrent().getActiveShell(),
SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setText("Question");
String previousUniqueJobId = container.getUniqueJobId();
if (isSubJob) {
messageBox.setMessage(Messages.bind(Messages.GENERATE_NEW_UNIQUE_JOB_ID_FOR_SUB_JOB, jobFile.getName(),
previousUniqueJobId));
} else {
messageBox.setMessage(
Messages.bind(Messages.GENERATE_NEW_UNIQUE_JOB_ID_FOR_JOB, jobFile.getName(), previousUniqueJobId));
}
buttonId = messageBox.open();
return buttonId;
}
示例14: createChartPrintJob
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
/**
* Creates a print job for the chart.
*/
public void createChartPrintJob() {
//FIXME try to replace swing print stuff by swt
PrinterJob job = PrinterJob.getPrinterJob();
PageFormat pf = job.defaultPage();
PageFormat pf2 = job.pageDialog(pf);
if (pf2 != pf) {
job.setPrintable(this, pf2);
if (job.printDialog()) {
try {
job.print();
}
catch (PrinterException e) {
MessageBox messageBox = new MessageBox(
canvas.getShell(), SWT.OK | SWT.ICON_ERROR );
messageBox.setMessage( e.getMessage() );
messageBox.open();
}
}
}
}
示例15: cancelPressed
import org.eclipse.swt.widgets.MessageBox; //导入依赖的package包/类
@Override
protected void cancelPressed() {
if (applyButton.isEnabled()) {
if (!isNoPressed) {
ConfirmCancelMessageBox confirmCancelMessageBox = new ConfirmCancelMessageBox(container);
MessageBox confirmCancleMessagebox = confirmCancelMessageBox.getMessageBox();
if (confirmCancleMessagebox.open() == SWT.OK) {
closeDialog=super.close();
}
} else {
closeDialog=super.close();
}
} else {
closeDialog=super.close();
}
isCancelPressed=true;
}