List of usage examples for org.eclipse.jface.dialogs MessageDialog open
public int open()
From source file:Gui.MainWindow_ver2.java
License:Open Source License
public boolean showMessageDialog(String string, String string2) { String message = (string);/*from ww w . ja v a2 s . c om*/ String title = (string2); String[] options = new String[2]; options[0] = "YES"; options[1] = "NO"; MessageDialog messageBox = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, options, 2); int response = messageBox.open(); if (response == 0) { return true; } else { return false; } }
From source file:Gui.MainWindow_ver2.java
License:Open Source License
private void saveBeforExitMessage() { if (!isMulti) { String title = ("Save before exit"); String message = ("The current game was not saved. Would you like to save it?"); String[] options = new String[2]; options[0] = "YES"; options[1] = "NO"; MessageDialog messageBox = new MessageDialog(shell, title, null, message, MessageDialog.WARNING, options, 2);//w ww . jav a 2 s. c o m int response = messageBox.open(); if (response == 0) { saveAction(); } } }
From source file:Gui.NewGameDialog.java
License:Open Source License
private void getNames() { String sel = numberOfPlayersCombo.getText(); // System.out.println(sel); if (!sel.equals("1") && !sel.equals("2") && !sel.equals("3") && !sel.equals("4")) { // if (shell == null) System.out.println("bla"); String title = ("Number of players error"); String message = ("Number of players is not valid"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); return;/*from w ww .ja v a 2s .c o m*/ } int numberOfPlayers = Integer.parseInt(sel); String[] names = new String[4]; names[0] = player1Text.getText(); names[1] = player2Text.getText(); names[2] = player3Text.getText(); names[3] = player4Text.getText(); //check that names are valid(non empty) for (int i = 0; i < numberOfPlayers; i++) { String isValid = isValidName(names[i]); if (isValid != null) { String title = ("Player name error"); String message = ("Player name must be at length 1 at minimum and 15 at most"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); return; } } boolean[] isAuto = new boolean[4]; isAuto[0] = false; isAuto[1] = computerCheck2.getSelection(); isAuto[2] = computerCheck3.getSelection(); isAuto[3] = computerCheck4.getSelection(); playersInfo = new PlayerInfo[numberOfPlayers]; for (int i = 0; i < numberOfPlayers; i++) { playersInfo[i] = new PlayerInfo(names[i], isAuto[i]); } // if (basicButton.getSelection()) {System.out.println("bla");} gameMode = basicButton.getSelection() ? 'b' : 'a'; dialogShell.dispose(); }
From source file:Gui.NewMultiDialog.java
License:Open Source License
public void open() { try {// w ww . j a v a2 s. co m Shell parent = getParent(); dialogShell = new Shell(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL); { //Register as a resource user - SWTResourceManager will //handle the obtaining and disposing of resources SWTResourceManager.registerResourceUser(dialogShell); } dialogShell.setLayout(new FormLayout()); dialogShell.setText("Multiplayer Dialog"); { Existing = new Button(dialogShell, SWT.PUSH | SWT.CENTER); Existing.setText("Login"); FormData ExistingLData = new FormData(); ExistingLData.width = 66; ExistingLData.height = 33; ExistingLData.left = new FormAttachment(0, 1000, 131); ExistingLData.top = new FormAttachment(0, 1000, 120); Existing.setLayoutData(ExistingLData); Existing.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { //System.out.println("Existing.widgetSelected, event="+evt); isClosed = false; if (text1.getText().equals("")) { String title = ("Error"); String message = ("You must specify your name"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); } else if (EmailText.isEnabled() == true) { //new user login if (EmailText.getText().equals("")) { String title = ("Error"); String message = ("If you login as new user you must specify your email"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); } else if (text2.getText().equals("")) { String title = ("Error"); String message = ("You must specify your password"); MessageDialog m = new MessageDialog(dialogShell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 1); m.open(); } else { setClientInfo(true); // System.out.println("login as new"); } } else { setClientInfo(false); // System.out.println("login as user"); } } }); } { cancelConnect = new Button(dialogShell, SWT.PUSH | SWT.CENTER); cancelConnect.setText("Cancel"); FormData cancelConnectLData = new FormData(); cancelConnectLData.width = 43; cancelConnectLData.height = 33; cancelConnectLData.top = new FormAttachment(0, 1000, 120); cancelConnectLData.left = new FormAttachment(0, 1000, 203); cancelConnectLData.right = new FormAttachment(1000, 1000, -41); cancelConnect.setLayoutData(cancelConnectLData); cancelConnect.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { isClosed = true; dialogShell.dispose(); } }); } { newUser = new Button(dialogShell, SWT.PUSH | SWT.CENTER); newUser.setText("New User"); FormData connectLData = new FormData(); connectLData.width = 86; connectLData.height = 33; connectLData.top = new FormAttachment(0, 1000, 120); connectLData.left = new FormAttachment(0, 1000, 38); newUser.setLayoutData(connectLData); newUser.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { isClosed = false; EmailText.setEnabled(true); newUser.setEnabled(false); label3.setEnabled(true); // if (!text1.getText().equals("")) // setClientInfo(true); // else{ // MessageBox m = new MessageBox(dialogShell, SWT.ICON_ERROR); // m.setText("Error"); // m.setMessage("You must specify the name"); // m.open(); // } } }); } { EmailText = new Text(dialogShell, SWT.NONE); FormData EmailTextLData = new FormData(); EmailTextLData.width = 119; EmailTextLData.height = 17; EmailTextLData.left = new FormAttachment(0, 1000, 91); EmailTextLData.top = new FormAttachment(0, 1000, 101); EmailText.setLayoutData(EmailTextLData); EmailText.setEnabled(false); } { text2 = new Text(dialogShell, SWT.NONE); FormData text2LData = new FormData(); text2LData.width = 119; text2LData.height = 17; text2LData.left = new FormAttachment(0, 1000, 91); text2LData.top = new FormAttachment(0, 1000, 72); text2.setLayoutData(text2LData); text2.setEchoChar('*'); } { text1 = new Text(dialogShell, SWT.NONE); FormData text1LData = new FormData(); text1LData.width = 119; text1LData.height = 17; text1LData.left = new FormAttachment(0, 1000, 91); text1LData.top = new FormAttachment(0, 1000, 40); text1.setLayoutData(text1LData); } { label3 = new Label(dialogShell, SWT.NONE); label3.setText("Email:"); FormData label3LData = new FormData(); label3LData.width = 43; label3LData.height = 17; label3LData.left = new FormAttachment(0, 1000, 18); label3LData.top = new FormAttachment(0, 1000, 101); label3.setLayoutData(label3LData); label3.setFont(SWTResourceManager.getFont("Tahoma", 10, 0, false, false)); label3.setEnabled(false); } { label2 = new Label(dialogShell, SWT.NONE); label2.setText("password:"); FormData label2LData = new FormData(); label2LData.width = 61; label2LData.height = 17; label2LData.left = new FormAttachment(0, 1000, 18); label2LData.top = new FormAttachment(0, 1000, 72); label2.setLayoutData(label2LData); label2.setFont(SWTResourceManager.getFont("Tahoma", 10, 0, false, false)); } { label1 = new Label(dialogShell, SWT.NONE); label1.setText("username:"); FormData label1LData = new FormData(); label1LData.width = 61; label1LData.height = 20; label1LData.left = new FormAttachment(0, 1000, 18); label1LData.top = new FormAttachment(0, 1000, 40); label1.setLayoutData(label1LData); label1.setFont(SWTResourceManager.getFont("Tahoma", 10, 0, false, false)); } { helpLabel = new Label(dialogShell, SWT.NONE); helpLabel.setText("Before login please read carefully the\nrelevant notes at the help window"); FormData helpLabelData = new FormData(); helpLabelData.width = 250; helpLabelData.height = 35; helpLabelData.left = new FormAttachment(0, 1000, 5); helpLabelData.top = new FormAttachment(0, 1000, 5); helpLabel.setLayoutData(helpLabelData); helpLabel.setFont(SWTResourceManager.getFont("Tahoma", 9, 0, false, false)); } dialogShell.layout(); dialogShell.pack(); dialogShell.setLocation(getParent().toDisplay(100, 100)); dialogShell.open(); Display display = dialogShell.getDisplay(); while (!dialogShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:hydrograph.ui.graph.execution.tracking.connection.HydrographServerConnection.java
License:Apache License
/** * Opens a message dialog in case if there are issues while making * connection to server.//from ww w. j a v a 2 s .c o m * * @param job the job * @param shell the shell */ public void messageDialogForExecutionTracking(Job job, Shell shell) { String portNo; String host; if (job.isRemoteMode()) { portNo = TrackingDisplayUtils.INSTANCE.getRemotePortFromPreference(); if (StringUtils.isBlank(portNo)) { portNo = PreferenceConstants.DEFAULT_PORT_NO; } if (PlatformUI.getPreferenceStore().getBoolean(PreferenceConstants.USE_REMOTE_CONFIGURATION)) { host = PlatformUI.getPreferenceStore().getString(PreferenceConstants.REMOTE_HOST); } else { host = job.getHost(); } } else { portNo = TrackingDisplayUtils.INSTANCE.getPortFromPreference(); if (StringUtils.isBlank(portNo)) { portNo = PreferenceConstants.DEFAULT_PORT_NO; } host = job.getHost(); } String msg = "Execution tracking can't be displayed as connection refused on host: " + host + " with port no: " + portNo; MessageDialog dialog = new MessageDialog(shell, "Warning", null, msg, SWT.ICON_WARNING, new String[] { "OK" }, 0); dialog.open(); }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.operational.TransformWidget.java
License:Apache License
/** * @param inputLinkSchema//from www . jav a 2 s . c om * @param currentCompSchema */ private boolean compareSchemaFields(List<GridRow> inputLinkSchema, List<GridRow> currentCompSchema) { for (int index = 0; index < currentCompSchema.size() - 1; index++) { for (GridRow gridRow : inputLinkSchema) { if (StringUtils.equals(gridRow.getFieldName(), currentCompSchema.get(index).getFieldName())) { if (!StringUtils.equals(gridRow.getDataTypeValue(), currentCompSchema.get(index).getDataTypeValue())) { MessageDialog dialog = new MessageDialog(new Shell(), "Warning", null, "Output Schema is updated,Do you want to continue with changes?", MessageDialog.CONFIRM, new String[] { "Yes", "No" }, 0); int dialogResult = dialog.open(); if (dialogResult == 0) { return true; } else { return false; } } } } } return true; }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.schema.ELTSchemaGridWidget.java
License:Apache License
private void propagateInternalSchema() { if (schemaGridRowList != null) { if (SchemaSyncUtility.INSTANCE.isAutoSchemaSyncAllow(getComponent().getComponentName())) { if (SchemaSyncUtility.INSTANCE.isAutoSyncRequiredInMappingWidget(getComponent(), schemaGridRowList)) { MessageDialog dialog = new MessageDialog(new Shell(), Constants.SYNC_WARNING, null, Constants.SCHEMA_NOT_SYNC_MESSAGE, MessageDialog.CONFIRM, new String[] { Messages.SYNC_NOW, Messages.MANUAL_SYNC }, 0); if (dialog.open() == 0) { if (isSchemaUpdated) SchemaSyncUtility.INSTANCE.pushSchemaToMapping(getComponent(), schemaGridRowList); else updateSchemaWithPropogatedSchema(); }//from w ww.ja v a2 s .c o m } } } }
From source file:hydrograph.ui.propertywindow.widgets.dialog.hiveInput.HiveFieldDialogHelper.java
License:Apache License
/** * /* w ww . j a v a 2s. co m*/ * Message dialog to be displayed if compare_fields() method returns false. * */ public int Message_Dialog() { MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Rearrange Fields", null, Messages.HIVE_PARTI_SEQ_ERROR, MessageDialog.ERROR, new String[] { "Rearrange Schema", "Rearrange Partition Fields" }, 0); int result = dialog.open(); return result; }
From source file:hydrograph.ui.propertywindow.widgets.utility.SchemaSyncUtility.java
License:Apache License
public void autoSyncSchema(Schema SchemaForInternalPropagation, Component component, List<AbstractWidget> widgets) { if (SchemaSyncUtility.INSTANCE.isAutoSyncRequiredInSchemaTab(SchemaForInternalPropagation.getGridRow(), (Schema) component.getProperties().get(Constants.SCHEMA_PROPERTY_NAME))) { MessageDialog dialog = new MessageDialog(new Shell(), Constants.SYNC_WARNING, null, Constants.SCHEMA_NOT_SYNC_MESSAGE, MessageDialog.CONFIRM, new String[] { Messages.SYNC_NOW, Messages.MANUAL_SYNC }, 0); if (dialog.open() == 0) { getSchemaGridWidget(widgets).updateSchemaWithPropogatedSchema(); }//from w w w. ja v a 2 s . c o m } }
From source file:ilg.gnuarmeclipse.packs.data.Utils.java
License:Open Source License
public static boolean copyFileWithShell(final URL sourceUrl, File destinationFile, MessageConsoleStream out, IProgressMonitor monitor, final Shell shell) throws IOException { while (true) { try {//from w w w . j ava2 s.c om Utils.copyFile(sourceUrl, destinationFile, out, monitor); return true; } catch (final IOException e) { class ErrorMessageDialog implements Runnable { public int retCode = 0; @Override public void run() { String[] buttons = new String[] { "Retry", "Ignore", "Abort" }; MessageDialog dialog = new MessageDialog(shell, "Read error", null, sourceUrl.toString() + "\n" + e.getMessage(), MessageDialog.ERROR, buttons, 0); retCode = dialog.open(); } } ErrorMessageDialog messageDialog = new ErrorMessageDialog(); Display.getDefault().syncExec(messageDialog); if (messageDialog.retCode == 2) { throw e; // Abort } else if (messageDialog.retCode == 1) { return false; // Ignore } // Else try again } } // HandlerUtil.getActiveShell(event) }