List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:com.google.gwt.eclipse.core.clientbundle.GeneratedCssResource.java
License:Open Source License
private void createType(IPackageFragment pckg, boolean addComments) throws CoreException { IJavaProject javaProject = pckg.getJavaProject(); final IProgressMonitor monitor = new NullProgressMonitor(); // Method name should already have been sanitized and validated, so all we // should have to do to get a type name is just capitalize it String simpleName = StringUtilities.capitalize(getMethodName()); // See if the type name is already used String qualifiedName = JavaModelUtil.concatenateName(pckg.getElementName(), simpleName); IType existingType = JavaModelSearch.findType(javaProject, qualifiedName); if (existingType != null) { if (ClientBundleUtilities.isCssResource(javaProject, existingType)) { // If the existing type is a CssResource, we'll assume that it wraps // this CSS file and use it for our ClientBundle accessor return type // instead of trying to generate another CssResource here. customCssResourceType = existingType; return; } else {//from ww w .j a v a 2s .c o m // If it's not a CssResource, then we'll need to generate a CssResource // ourself, but we can't use the name. So, let's compute a similar name // that is not already in use. simpleName = StringUtilities.computeUniqueName(getExistingTopLevelTypeNames(pckg), simpleName); } } // Parse the CSS and see if there were problems CssParseResult result = parseCss(); final IStatus status = result.getStatus(); // Bail out when errors occur if (status.getSeverity() == IStatus.ERROR) { throw new CoreException(status); } // For warnings, just display them in a dialog (on the UI thread of course) // TODO: would nice if we could aggregate these and show them all at the end if (status.getSeverity() == IStatus.WARNING) { Display.getDefault().syncExec(new Runnable() { public void run() { MessageDialog.openWarning(null, "CSS Parsing", status.getMessage()); } }); } // Extract the CSS class names final Set<String> cssClassNames = ExtractClassNamesVisitor.exec(result.getStylesheet()); TypeCreator gen = new TypeCreator(pckg, simpleName, TypeCreator.ElementType.INTERFACE, new String[] { ClientBundleUtilities.CSS_RESOURCE_TYPE_NAME }, addComments) { @Override protected void createTypeMembers(IType newType, ImportRewrite imports) throws CoreException { // Create an accessor method for each CSS class for (String cssClass : cssClassNames) { newType.createMethod(computeCssClassMethodSource(newType, cssClass), null, true, monitor); } } }; customCssResourceType = gen.createType(); }
From source file:com.googlecode.osde.internal.runtime.CreateJavaProjectAction.java
License:Apache License
public void run(IAction action) { try {//from w ww . j av a2s .c o m ApplicationInformation appInfo = OpenSocialUtil.createApplicationInformation(file); ApplicationService service = Activator.getDefault().getApplicationService(); ApplicationImpl application = service.getApplication(appInfo.getAppId()); Person person = findPersonWithFriends(); if (person != null) { if (application != null) { NewRestfulAccessProjectResourceWizard wizard = new NewRestfulAccessProjectResourceWizard(); wizard.setApplication(application); wizard.setPerson(person); wizard.init(targetPart.getSite().getWorkbenchWindow().getWorkbench(), currentSelection); wizard.setInitializationData(new SimpleConfigurationElementImpl() { @Override public String getAttribute(String name) throws InvalidRegistryObjectException { if (name.equals("finalPerspective") || name.equals("preferredPerspectives")) { return JavaUI.ID_PERSPECTIVE; } else { return null; } } }, null, null); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.open(); } else { MessageDialog.openWarning(shell, "Warning", "This application does not run yet."); } } else { MessageDialog.openError(shell, "Error", "There is no person in Shindig database."); } } catch (CoreException e) { MessageDialog.openError(shell, "Error", "Invalid gadget file. " + e.getMessage()); } catch (ConnectionException e) { MessageDialog.openError(shell, "Error", "Shindig database not started yet."); } catch (ParserException e) { MessageDialog.openError(shell, "Error", "Invalid syntax. " + e.getMessage()); } }
From source file:com.googlecode.osde.internal.runtime.RunAgainAction.java
License:Apache License
public void run(IAction action) { LaunchApplicationInformation information = Activator.getDefault().getLastApplicationInformation(); if (information == null) { MessageDialog.openWarning(shell, "Warning", "Any application is not started yet."); } else {/* www .ja v a 2 s.com*/ Job job = new LaunchApplicationJob("Running application", information, shell); job.schedule(); notifyUserPrefsView(information); } }
From source file:com.googlecode.osde.internal.runtime.ShowKeysAction.java
License:Apache License
public void run(IAction action) { try {/*from w w w .j ava 2 s.c om*/ ApplicationInformation appInfo = OpenSocialUtil.createApplicationInformation(file); ApplicationService service = Activator.getDefault().getApplicationService(); final ApplicationImpl application = service.getApplication(appInfo.getAppId()); if (application != null) { ImageDescriptor imageDescriptor = Activator.getDefault().getImageRegistry() .getDescriptor("icons/icon_key.gif"); MessageDialog dialog = new MessageDialog(shell, "Application information", imageDescriptor.createImage(), "This is keys for accessing from external service.", MessageDialog.INFORMATION, new String[] { "OK" }, 0) { @Override protected Control createCustomArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; composite.setLayout(gridLayout); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); composite.setLayoutData(layoutData); Label label = new Label(composite, SWT.NONE); label.setText("Title:"); label = new Label(composite, SWT.NONE); label.setText(application.getTitle()); label = new Label(composite, SWT.NONE); label.setText("Path:"); label = new Label(composite, SWT.NONE); label.setText(application.getPath()); label = new Label(composite, SWT.NONE); label.setText("Consumer Key:"); Text text = new Text(composite, SWT.BORDER | SWT.MULTI); text.setText(application.getConsumerKey()); text.setEditable(false); text.setSelection(0); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.heightHint = 20; text.setLayoutData(layoutData); label = new Label(composite, SWT.NONE); label.setText("Consumer Secret:"); text = new Text(composite, SWT.BORDER | SWT.MULTI); text.setText(application.getConsumerSecret()); text.setEditable(false); text.setSelection(0); layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.heightHint = 20; text.setLayoutData(layoutData); return parent; } }; dialog.open(); } else { MessageDialog.openWarning(shell, "Warning", "This application does not run yet."); } } catch (CoreException e) { MessageDialog.openError(shell, "Error", "Invalid gadget file. " + e.getMessage()); } catch (ConnectionException e) { MessageDialog.openError(shell, "Error", "Shindig database not started yet."); } catch (ParserException e) { MessageDialog.openError(shell, "Error", "Invalid gadget file. " + e.getMessage()); } }
From source file:com.googlecode.osde.internal.shindig.CreateSampleDataAction.java
License:Apache License
public void run(IAction action) { try {/*ww w . j av a 2 s . c o m*/ final PersonService personService = Activator.getDefault().getPersonService(); boolean confirm = MessageDialog.openConfirm(shell, "Confirm", "Would you like to create sample data in Shindig database?\n" + "(Created people are 'conrad.doe', 'john.doe', 'jane.doe' and 'george.doe')"); if (confirm) { Job job = new Job("Create sample data") { @Override protected IStatus run(IProgressMonitor monitor) { Person[] samplePeople = createSamplePeople(); monitor.beginTask("Create sample data", samplePeople.length + 2); if (isAlreadyExistsPeople(samplePeople, personService)) { shell.getDisplay().syncExec(new Runnable() { public void run() { IWorkbenchWindow window = targetPart.getSite().getWorkbenchWindow(); MessageDialog.openWarning(window.getShell(), "Warning", "Sample people already exists."); } }); monitor.done(); return Status.OK_STATUS; } for (Person p : samplePeople) { personService.storePerson(p); monitor.worked(1); } setRelations(samplePeople, personService); monitor.worked(1); shell.getDisplay().syncExec(new Runnable() { public void run() { try { IWorkbenchWindow window = targetPart.getSite().getWorkbenchWindow(); PersonView personView = (PersonView) window.getActivePage() .showView(PersonView.ID); personView.loadPeople(); } catch (PartInitException e) { // TODO: Handle PartInitException. throw new IllegalStateException(e); } } }); monitor.worked(1); monitor.done(); return Status.OK_STATUS; } }; job.setUser(true); job.schedule(); } } catch (ConnectionException ce) { MessageDialog.openError(shell, "Error", "Shindig database not started yet."); } }
From source file:com.hangum.tadpole.application.start.dialog.login.FindPasswordDialog.java
License:Open Source License
@Override protected void okPressed() { String strEmail = StringUtils.trimToEmpty(textEmail.getText()); String strQuestion = StringUtils.trimToEmpty(comboQuestion.getText()); String strAnswer = StringUtils.trimToEmpty(textAnswer.getText()); if (!checkValidation()) { MessageDialog.openWarning(getShell(), Messages.FindPasswordDialog_1, Messages.FindPasswordDialog_6); textEmail.setFocus();//from w w w .ja v a 2 s.c o m return; } UserDAO validUser; try { validUser = TadpoleSystem_UserQuery.checkSecurityHint(strEmail, strQuestion, strAnswer); } catch (Exception e) { logger.error("Find password exception", e); //$NON-NLS-1$ MessageDialog.openError(getShell(), Messages.LoginDialog_7, e.getMessage()); return; } super.okPressed(); ChangePasswordDialog dialog = new ChangePasswordDialog(getParentShell(), validUser); dialog.open(); }
From source file:com.hangum.tadpole.commons.admin.core.dialogs.UserLoginHistoryDialog.java
License:Open Source License
private void search() { String strEmail = textEmail.getText(); if ("".equals(strEmail)) { //$NON-NLS-1$ listLoginHistory.clear();//from w ww . ja v a 2s . c o m tvHistory.setInput(listLoginHistory); MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().UserLoginHistoryDialog_8); return; } try { Calendar cal = Calendar.getInstance(); cal.set(dateTimeStart.getYear(), dateTimeStart.getMonth(), dateTimeStart.getDay(), 0, 0, 0); long startTime = cal.getTimeInMillis(); cal.set(dateTimeEnd.getYear(), dateTimeEnd.getMonth(), dateTimeEnd.getDay(), 23, 59, 59); long endTime = cal.getTimeInMillis(); listLoginHistory = TadpoleSystem_UserQuery.getLoginHistory(strEmail, startTime, endTime); tvHistory.setInput(listLoginHistory); } catch (Exception e) { logger.error("find login history", e); //$NON-NLS-1$ } }
From source file:com.hangum.tadpole.commons.admin.core.dialogs.users.NewUserDialog.java
License:Open Source License
/** * generate google otp //w ww .j a v a2 s . c o m */ private void generateGoogleOTP() { if (!btnGetOptCode.getSelection()) { getShell().setSize(370, 240); textSecretKey.setText(""); //$NON-NLS-1$ labelQRCodeURL.setText(""); //$NON-NLS-1$ return; } String strEmail = textEMail.getText(); if ("".equals(strEmail)) { //$NON-NLS-1$ getShell().setSize(370, 240); btnGetOptCode.setSelection(false); textEMail.setFocus(); MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_7); return; } else if (!ValidChecker.isValidEmailAddress(strEmail)) { getShell().setSize(370, 240); btnGetOptCode.setSelection(false); textEMail.setFocus(); MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_15); return; } getShell().setSize(380, 370); secretKey = GoogleAuthManager.getInstance().getSecretKey(); textSecretKey.setText(secretKey); String[] strUserDomain = StringUtils.split(strEmail, "@"); //$NON-NLS-1$ String strURL = GoogleAuthManager.getInstance().getURL(strUserDomain[0], strUserDomain[1], secretKey); if (logger.isDebugEnabled()) { logger.debug("user is " + strUserDomain[0] + ", domain is " + strUserDomain[1] + ", secretkey is " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + secretKey); logger.debug("url is " + strURL); //$NON-NLS-1$ } strURL = StringEscapeUtils.escapeHtml(strURL); labelQRCodeURL.setText( String.format("<a href='%s' target='_blank'>Show QRCode(Only support Google Chrome)</a>", strURL)); //$NON-NLS-1$ }
From source file:com.hangum.tadpole.commons.admin.core.dialogs.users.NewUserDialog.java
License:Open Source License
@Override protected void okPressed() { String strEmail = StringUtils.trimToEmpty(textEMail.getText()); String passwd = StringUtils.trimToEmpty(textPasswd.getText()); String rePasswd = StringUtils.trimToEmpty(textRePasswd.getText()); String name = StringUtils.trimToEmpty(textName.getText()); if (!validation(strEmail, passwd, rePasswd, name)) return;// www. j a v a 2 s . c om if (btnGetOptCode.getSelection()) { if ("".equals(textOTPCode.getText())) { //$NON-NLS-1$ MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().NewUserDialog_40); textOTPCode.setFocus(); return; } if (!GoogleAuthManager.getInstance().isValidate(secretKey, NumberUtils.toInt(textOTPCode.getText()))) { MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().NewUserDialog_42); //$NON-NLS-1$ textOTPCode.setFocus(); return; } } try { /** * ? ?? ? ? NO , YES . */ String approvalYn = GetAdminPreference.getNewUserPermit(); String isEmamilConrim = PublicTadpoleDefine.YES_NO.NO.name(); SMTPDTO smtpDto = new SMTPDTO(); try { smtpDto = GetAdminPreference.getSessionSMTPINFO(); } catch (Exception e) { // igonre exception } if (isAdmin || "".equals(smtpDto.getEmail())) { //$NON-NLS-1$ isEmamilConrim = PublicTadpoleDefine.YES_NO.YES.name(); } String strEmailConformKey = Utils.getUniqueDigit(7); userDao = TadpoleSystem_UserQuery.newUser(PublicTadpoleDefine.INPUT_TYPE.NORMAL.toString(), strEmail, strEmailConformKey, isEmamilConrim, passwd, PublicTadpoleDefine.USER_ROLE_TYPE.ADMIN.toString(), name, comboLanguage.getText(), approvalYn, btnGetOptCode.getSelection() ? "YES" : "NO", //$NON-NLS-1$ //$NON-NLS-2$ textSecretKey.getText(), "*"); //$NON-NLS-1$ //$NON-NLS-2$ boolean isSentMail = false; if (!"".equals(smtpDto.getEmail())) { //$NON-NLS-1$ sendEmailAccessKey(name, strEmail, strEmailConformKey); isSentMail = true; } try { AddDefaultSampleDBToUser.addUserDefaultDB(userDao.getSeq(), userDao.getEmail()); } catch (Exception e) { logger.error("Sample db copy error", e); //$NON-NLS-1$ } if (isSentMail) MessageDialog.openInformation(null, Messages.get().Confirm, Messages.get().NewUserDialog_31); else MessageDialog.openInformation(null, Messages.get().Confirm, Messages.get().NewUserDialog_29); //$NON-NLS-1$ } catch (Exception e) { logger.error(Messages.get().NewUserDialog_8, e); MessageDialog.openError(getParentShell(), Messages.get().Confirm, e.getMessage()); return; } super.okPressed(); }
From source file:com.hangum.tadpole.commons.admin.core.dialogs.users.NewUserDialog.java
License:Open Source License
/** * validation//ww w. j av a 2 s .co m * * @param strGroupName * @param strEmail * @param strPass * @param rePasswd * @param name */ private boolean validation(String strEmail, String strPass, String rePasswd, String name) { if ("".equals(strEmail)) { //$NON-NLS-1$ MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_7); textEMail.setFocus(); return false; } else if ("".equals(strPass)) { //$NON-NLS-1$ MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_10); textPasswd.setFocus(); return false; } else if ("".equals(name)) { //$NON-NLS-1$ MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_13); textName.setFocus(); return false; } else if (!ValidChecker.isValidEmailAddress(strEmail)) { MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_15); textEMail.setFocus(); return false; } else if (!ValidChecker.isSimplePasswordChecker(strPass)) { MessageDialog.openWarning(getShell(), Messages.get().Warning, Messages.get().NewUserDialog_25); textPasswd.setFocus(); return false; } else if ("".equals(rePasswd)) { MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_10); textRePasswd.setFocus(); return false; } if (!strPass.equals(rePasswd)) { MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_17); textPasswd.setFocus(); return false; } try { // ??? . if (!TadpoleSystem_UserQuery.isDuplication(strEmail)) { MessageDialog.openWarning(getParentShell(), Messages.get().Warning, Messages.get().NewUserDialog_9); textEMail.setFocus(); return false; } } catch (Exception e) { logger.error("new user", e); MessageDialog.openError(getParentShell(), Messages.get().Error, Messages.get().NewUserDialog_12 + e.getMessage()); return false; } return true; }