Java Code Examples for org.eclipse.jface.dialogs.MessageDialog.openError()

The following are Jave code examples for showing how to use openError() of the org.eclipse.jface.dialogs.MessageDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: n4js   File: TestResultsView.java   Source Code and License Vote up 6 votes
/**
 * Invoked when user performs {@link #actionRelaunch}.
 */
protected void performRelaunch() {
	if (null != currentRoot) {
		final TestSession session = from(registeredSessions).firstMatch(s -> s.root == currentRoot).orNull();
		if (null != session) {
			final TestConfiguration configurationToReRun = session.configuration;
			registeredSessions.remove(session);
			try {
				final TestConfiguration newConfiguration = testerFrontEnd.createConfiguration(configurationToReRun);
				testerFrontEndUI.runInUI(newConfiguration);
			} catch (Exception e) {
				String message = "Test class not found in the workspace.";
				if (!Strings.isNullOrEmpty(e.getMessage())) {
					message += " Reason: " + e.getMessage();
				}
				MessageDialog.openError(getShell(), "Cannot open editor", message);
			}
		}
	}
}
 
Example 2
Project: Hydrograph   File: ELTGraphicalEditor.java   Source Code and License Vote up 6 votes
private void generateTargetXMLInLocalFileSystem(IFileStore fileStore, Container container) {

		try {
			if(container!=null)
				ConverterUtil.INSTANCE.convertToXML(container, false, null,fileStore);
			else
				ConverterUtil.INSTANCE.convertToXML(this.container, false,null,fileStore);
		} catch (EngineException eexception) {
			logger.warn("Failed to create the engine xml", eexception);
			MessageDialog.openError(Display.getDefault().getActiveShell(), "Failed to create the engine xml", eexception.getMessage());
		}catch (InstantiationException| IllegalAccessException| InvocationTargetException| NoSuchMethodException exception) {
			logger.error("Failed to create the engine xml", exception);
			Status status = new Status(IStatus.ERROR, "hydrograph.ui.graph",
					"Failed to create Engine XML " + exception.getMessage());
			StatusManager.getManager().handle(status, StatusManager.SHOW);
		}
		
	}
 
Example 3
Project: convertigo-eclipse   File: InteractiveSplashHandler.java   Source Code and License Vote up 6 votes
/**
 * 
 */
private void handleButtonOKWidgetSelected() {
	String username = fTextUsername.getText();
	String password = fTextPassword.getText();
	// Aunthentication is successful if a user provides any username and
	// any password
	if ((username.length() > 0) &&
			(password.length() > 0)) {
		fAuthenticated = true;
	} else {
		MessageDialog.openError(
				getSplash(),
				"Authentication Failed",  //NON-NLS-1
				"A username and password must be specified to login.");  //NON-NLS-1
	}
}
 
Example 4
Project: Hydrograph   File: RunConfigDialog.java   Source Code and License Vote up 6 votes
private boolean isUsernamePasswordOrHostEmpty() {
	Notification notification = new Notification();
	if (remoteMode) {
		if (StringUtils.isEmpty(txtEdgeNode.getText())){
			notification.addError(Messages.EMPTY_HOST_FIELD_MESSAGE);
		}
			
		if (StringUtils.isEmpty(txtUserName.getText())){
			notification.addError(Messages.EMPTY_USERNAME_FIELD_MESSAGE);
		}
		if(radioPassword.getSelection() && StringUtils.isEmpty(txtPassword.getText())){
			notification.addError(Messages.EMPTY_PASSWORD_FIELD_MESSAGE);
		}
	}
	
	if(notification.hasErrors()){
		MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.EMPTY_FIELDS_MESSAGE_BOX_TITLE,
				notification.errorMessage());	
		return true;
	}else{
		return false;
	}
}
 
Example 5
Project: Hydrograph   File: ELTGraphicalEditor.java   Source Code and License Vote up 6 votes
@Override
public void setInput(IEditorInput input) {
	if(input instanceof FileStoreEditorInput){
		MessageBox messageBox=new MessageBox(Display.getCurrent().getActiveShell(),SWT.ICON_WARNING);
		messageBox.setText(Messages.WARNING);
		messageBox.setMessage(Messages.JOB_OPENED_FROM_OUTSIDE_WORKSPACE_WARNING);
		messageBox.open();
	}	
	try {
		GenrateContainerData genrateContainerData = new GenrateContainerData();
		genrateContainerData.setEditorInput(input, this);
		if(StringUtils.equals(this.getJobName()+Messages.JOBEXTENSION, input.getName()) || StringUtils.equals(this.getJobName(), Messages.ELT_GRAPHICAL_EDITOR)){
			container = genrateContainerData.getContainerData();
		}else{
			this.setPartName(input.getName());
		}
		super.setInput(input);
	} catch (CoreException | IOException ce) {
		logger.error("Exception while setting input", ce);
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().dispose();
		MessageDialog.openError(new Shell(), "Error", "Exception occured while opening the graph -\n"+ce.getMessage());
	}
}
 
Example 6
Project: Hydrograph   File: ExternalOperationExpressionUtil.java   Source Code and License Vote up 6 votes
/**
 * Imports UI-operation data from external operation file
 * 
 * @param file
 * @param mappingSheetRow
 * @param showErrorMessage
 * @param transformMapping
 * @param componentName
 * @return
 * @throws ExternalTransformException
 */
public MappingSheetRow importOperation(File file, MappingSheetRow mappingSheetRow ,boolean showErrorMessage,
		TransformMapping transformMapping, String componentName) throws ExternalTransformException {
	if (file!=null) {
		try (FileInputStream fileInputStream=new FileInputStream(file)){
			ExternalOperations externalOperation=(ExternalOperations) unmarshal(fileInputStream,ExternalOperations.class);
			mappingSheetRow=convertToUIOperation(mappingSheetRow, externalOperation.getExternalOperations(),transformMapping, componentName);
			if(mappingSheetRow!=null && showErrorMessage){
				MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Information", "Operation imported sucessfully");
			}
		} catch (Exception exception) {
			LOGGER.warn("Error ", exception);
			if(showErrorMessage){
				MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Failed to import operation - Invalid XML");
			}
		}
	}
	return mappingSheetRow;
}
 
Example 7
Project: Hydrograph   File: GridRowLoader.java   Source Code and License Vote up 6 votes
private boolean validateXML(InputStream xml, InputStream xsd){
	try
	{
		SchemaFactory factory = 
				SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
		javax.xml.validation.Schema schema = factory.newSchema(new StreamSource(xsd));
		Validator validator = schema.newValidator();
		
		validator.validate(new StreamSource(xml));
		return true;
	}
	catch( SAXException| IOException ex)
	{
		MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", Messages.IMPORT_XML_FORMAT_ERROR + "-\n" + ex.getMessage());
		logger.error(Messages.IMPORT_XML_FORMAT_ERROR);
		return false;
	}
}
 
Example 8
Project: Hydrograph   File: RunConfigDialog.java   Source Code and License Vote up 6 votes
private void loadBuildProperties() {
	String buildPropFilePath = buildPropFilePath();
	IPath bldPropPath = new Path(buildPropFilePath);
	IFile iFile = ResourcesPlugin.getWorkspace().getRoot().getFile(bldPropPath);
	try {
		InputStream reader = iFile.getContents();
		buildProps.load(reader);

	} catch (CoreException | IOException e) {
		MessageDialog.openError(Display.getDefault().getActiveShell(), "Error",
				"Exception occurred while loading build properties from file -\n" + e.getMessage());
	}

	Enumeration<?> propertyNames = buildProps.propertyNames();
	populateTextBoxes(propertyNames);

}
 
Example 9
Project: n4js   File: ProjectCompareTree.java   Source Code and License Vote up 5 votes
/**
 * Like {@link #setComparison()}, but a custom progress monitor can be provided (may be <code>null</code> if no
 * progress monitor should be used).
 */
public void setComparison(IProgressMonitor monitor) {
	if (monitor != null) {
		monitor.beginTask("Building comparison for API / implementation projects in workspace ...",
				IProgressMonitor.UNKNOWN);
		monitor.worked(1);
	}
	final List<String> errorMessages = new ArrayList<>();
	if (monitor != null) {
		monitor.subTask("Comparing projects in workspace ...");
		monitor.worked(1);
	}
	final ProjectComparison newComparison = projectCompareTreeHelper.createComparison(true, errorMessages);
	if (errorMessages.isEmpty()) {
		// if there is exactly one implementation, then focus on that; otherwise do not focus on an
		// implementation (i.e. show all implementations side-by-side)
		final String newFocusImplId;
		if (newComparison != null && newComparison.getImplCount() == 1)
			newFocusImplId = newComparison.getImplId(0);
		else
			newFocusImplId = null;
		setComparison(newComparison, newFocusImplId, monitor);
	} else {
		setComparison(null, null, null);
		MessageDialog.openError(
				getTree().getShell(),
				"Setup Invalid",
				"The API / implementation setup is invalid:\n" + Joiner.on('\n').join(errorMessages));
	}
	if (monitor != null)
		monitor.done();
}
 
Example 10
Project: ide-plugins   File: JCloudLink.java   Source Code and License Vote up 5 votes
private void runApplications(final String userKey, final boolean keepLogged, final Path jsonPath) {
    ApplicationsSWT applications = new ApplicationsSWT(null, userKey, keepLogged, ProjectUtils.getCloudLinkConfig(cloudLinkFile), allowDisableApply);
    Credentials credentials = applications.getCredentials();
    
    applications.open();
    
    if (credentials.getCredentials() != null) {
        utils.setCloudLinkIdeKey(credentials.getIdeKey());
        Path finalJsonPath = jsonPath;
        if (jsonPath.toFile().isDirectory()) {
            finalJsonPath = Paths.get(jsonPath.toFile().toString(), ProjectUtils.CLOUDLINK_CONFIG_FILE);
        }
        String cloudLinkText = credentials.getCredentials();
        try {
            Files.write(finalJsonPath, cloudLinkText.getBytes(StandardCharsets.UTF_8));
            cloudLinkFile.refreshLocal(IResource.DEPTH_ONE, null);
        } catch (IOException | CoreException ex) {
            MessageDialog.openError(new Shell(), "Error", "Error writing json file: " + ex);
            ex.printStackTrace();
        }
    } 
    if (credentials.getUserKey() == null) {
        utils.removeCloudLinkUserKey();
        return;
    } 

    if (credentials.getCredentials() != null && runnable != null) {
        runnable.run();
    }
}
 
Example 11
Project: eZooKeeper   File: ZooKeeperServerModelFormPage.java   Source Code and License Vote up 5 votes
private void executeCommand(String command) {

        ZooKeeperServer server = getModel().getData();

        String result = null;

        if (command.equals(ZooKeeperServer.COMMAND_DUMP)) {
            result = server.dump();
        }
        else if (command.equals(ZooKeeperServer.COMMAND_GET_TRACE_MASK)) {
            result = server.getTraceMask();
        }
        else if (command.equals(ZooKeeperServer.COMMAND_RUOK)) {
            result = server.ruok();
        }
        else if (command.equals(ZooKeeperServer.COMMAND_STAT)) {
            result = server.stat();
        }
        else {
            MessageDialog.openError(getSite().getShell(), "Bad command", "Command '" + command + "' not supported.");
            return;
        }

        if (result == null) {
            result = "<Command '" + command + "' returned no result>";
        }

        new CommandResultDialog(command, result).open();

    }
 
Example 12
Project: pmTrans   File: Config.java   Source Code and License Vote up 5 votes
@Override
protected void doStore() {
	if (!character.getText().equals("[space]")
			&& character.getText().length() > 1) {
		MessageDialog
				.openError(
						Display.getCurrent().getActiveShell(),
						"Error",
						"The key "
								+ character.getText()
								+ " is not supported as a shortcut. Please use another one.");
		doLoadDefault();
		return;
	}
	String c = character.getText().equals("[space]") ? " " : character
			.getText();

	IPreferenceStore ps = getPreferenceStore();
	updateAccelerators();
	accelerators = accelerators.replace(ps.getString(keyConst), "");
	if (accelerators.contains(c)) {
		MessageDialog
				.openError(
						Display.getCurrent().getActiveShell(),
						"Error",
						"The key "
								+ c
								+ " is already used as a shortcut. Please use another one.");
		doLoad();
		updateAccelerators();
		return;
	}
	ps.setValue(keyConst, c);
}
 
Example 13
Project: Hydrograph   File: RunConfigDialog.java   Source Code and License Vote up 5 votes
private boolean connectAndValidateUserNamePasswordAndHost() {
	Message message = SCPUtility.INSTANCE.validateCredentials(host, username, password);
	if (message.getMessageType() != MessageType.SUCCESS) {
		MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.CREDENTIAL_VALIDATION_MESSAGEBOX_TITLE,
				message.getMessage());
		return false;
	}else{
		return true;
	}
}
 
Example 14
Project: Hydrograph   File: FilterLogicExternalOperationExpressionUtil.java   Source Code and License Vote up 5 votes
public void exportExpression(File file, ExpressionData expressionData ,boolean showErrorMessage	) throws ExternalTransformException {
	if (file!=null) {
		try{
			Object object=convertUIExpressionToJaxb(expressionData);
			ExternalOperationExpressionUtil.INSTANCE.marshal(ExternalExpressions.class, file, object);
		} catch (Exception exception) {
			LOGGER.warn("Error ", exception);
			if(showErrorMessage){
				MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Failed to export expression - \n"+exception.getMessage());
			}
			return;
		}
		MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "Information", "Expression exported sucessfully");
	}
}
 
Example 15
Project: bdf2   File: DbConectionWizardPage.java   Source Code and License Vote up 5 votes
public void widgetSelected(SelectionEvent e) {
	String url = urlText.getText();
	String username = usernameText.getText();
	String password = passwordText.getText();
	String testResult = testConnection(url, username, password);
	if (testResult == null) {
		MessageDialog.openInformation(getShell(), "提示", "测试连接成功!");
	} else {
		MessageDialog.openError(getShell(), "错误", "测试连接失败!\n" + testResult);
	}
}
 
Example 16
Project: Hydrograph   File: SubJobUtility.java   Source Code and License Vote up 5 votes
/**
 * Do save as sub graph.
 * 
 * @param file
 *            the file
 * @param container
 *            the container
 * @return the i file
 */
public IFile doSaveAsSubJob(IFile file, Container container) {

	ByteArrayOutputStream out = new ByteArrayOutputStream();
	try {
		ConverterUtil.INSTANCE.convertToXML(container, false, null, null);
	
		if (file != null) {
			CanvasUtils.INSTANCE.fromObjectToXML(container,out);
			
			file.create(new ByteArrayInputStream(out.toByteArray()), true, null);
			
			getCurrentEditor().genrateTargetXml(file, null, container);
			getCurrentEditor().setDirty(false);
		}
	} catch (Exception e ) {
		MessageDialog.openError(new Shell(), "Error", "Exception occured while saving the graph -\n" + e.getMessage());
	}
	finally {
		try {
			out.close();
		} catch (IOException ioException) {
			logger.warn("Exception occurred while closing stream");
		}
	}
	return file;
}
 
Example 17
Project: eZooKeeper   File: BaseAction.java   Source Code and License Vote up 4 votes
protected final void openErrorMessageDialog(String title, String message) {
    MessageDialog.openError(getActiveShell(), title, message);
}
 
Example 18
Project: bdf2   File: BaseSelectionAction.java   Source Code and License Vote up 4 votes
public void errorMessage(String message) {
	MessageDialog.openError(getWorkbenchPart().getSite().getShell(), getText(), message);
}
 
Example 19
Project: Hydrograph   File: SubJobOpenAction.java   Source Code and License Vote up 4 votes
@Override
public void run() {
	List<Object> selectedObjects = getSelectedObjects();
	SubJobUtility subJobUtility = new SubJobUtility();
	String mainJobFilePath=subJobUtility.getCurrentEditor().getTitleToolTip();
	Container container = null;
	if (selectedObjects != null && !selectedObjects.isEmpty()) {
		for (Object obj : selectedObjects) {
				
			if (obj instanceof ComponentEditPart) {
				if (((ComponentEditPart) obj).getCastedModel().getCategory()
						.equalsIgnoreCase(Constants.SUBJOB_COMPONENT_CATEGORY)) {
					Component subjobComponent = ((ComponentEditPart) obj).getCastedModel();
					String pathProperty = (String) subjobComponent.getProperties().get(
							Constants.PATH_PROPERTY_NAME);
					if (StringUtils.isNotBlank(pathProperty)) {
						try {
							IPath jobFilePath = new Path(pathProperty);
							if (SubJobUtility.isFileExistsOnLocalFileSystem(jobFilePath)) {
								container = openEditor(jobFilePath);
								if (container != null){
									container.setLinkedMainGraphPath(mainJobFilePath);
									container.setSubjobComponentEditPart(obj);

                                     for (Component component : container.getUIComponentList()) {
									subJobUtility.propogateSchemaToSubjob(subjobComponent, component);
									}

									if(subjobComponent.isContinuousSchemaPropogationAllow())
									{
										Component component1=null;
										for(Object object:container.getChildren())
										{
											if(object instanceof Component)
											{
												 component1=(Component)object;
												if(component1 instanceof InputSubjobComponent)
												{
													SubjobUtility.INSTANCE.initializeSchemaMapForInputSubJobComponent
													(component1, subjobComponent);
													break;
												}	
											}
												
										}
										if(component1!=null)
										SubjobUtility.INSTANCE.setFlagForContinuousSchemaPropogation(component1);
										subjobComponent.setContinuousSchemaPropogationAllow(false);
									}	
									
									subjobComponent.getSubJobContainer().put(Constants.SUBJOB_CONTAINER, container);
								}
								((ComponentEditPart) obj).refresh();
							} else
								MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error",
										"Subjob File does not exists");
							
						} catch (CoreException | IllegalArgumentException exception) {
							logger.error("Unable to open subjob" + exception);
							MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error",
									"Unable to open subjob : Invalid file path\n" + exception.getMessage());
						}
					} else
						MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error",
								"Unable to open subjob : Subjob file path is empty");
				}
			}

		}
	}
}
 
Example 20
Project: Tarski   File: CreateUserRequirementDocument.java   Source Code and License Vote up 4 votes
public void MessageDialogError(IWorkbenchWindow window) {
  MessageDialog.openError(window.getShell(), "ModelWriter Project Management",
      "An error is occured");
}