當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageBox類代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:baloise,項目名稱:eZooKeeper,代碼行數:26,代碼來源:BaseDeleteAction.java

示例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;
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:22,代碼來源:PmTrans.java

示例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;
		}
	}
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:19,代碼來源:PmTrans.java

示例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();
			}
		}
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:34,代碼來源:PmTrans.java

示例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();
			}
		}
	}
}
 
開發者ID:juanerasmoe,項目名稱:pmTrans,代碼行數:20,代碼來源:PmTrans.java

示例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
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:27,代碼來源:BuildLocallyAction.java

示例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;
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:27,代碼來源:JavelinConnectorComposite.java

示例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);
		
	}
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:26,代碼來源:ToolPartBuildView.java

示例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();
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:26,代碼來源:DbStoreEditorDialog.java

示例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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:19,代碼來源:UpdateDdl.java

示例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();
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:24,代碼來源:MultiParameterFileDialog.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:27,代碼來源:ConverterUiHelper.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:28,代碼來源:UiConverterUtil.java

示例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();
            }
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:ChartComposite.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:21,代碼來源:ELTOperationClassDialog.java


注:本文中的org.eclipse.swt.widgets.MessageBox類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。