List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:classes.ExceptionUtilities.java
License:Apache License
/** * Generic function which creates an error popup with a generic title and a custom error message passed to * the method.//w w w . ja v a 2s. com */ public void Error(String message) { Display display = Display.getDefault(); Shell shell = new Shell(display); MessageDialog.openError(shell, "ERROR", message); }
From source file:clustere.dialogs.ProteinFunctionDialog.java
License:Open Source License
/** * excel/*from w w w .j av a 2 s. c o m*/ */ public void SaveXls() { FileDialog fd = new FileDialog(dialogShell, SWT.SAVE); fd.setFilterExtensions(new String[] { "*.xls" }); fd.setFilterNames(new String[] { "Excel.xls" }); String filename = fd.open(); if (filename == null || filename.equals("")) return; TableItem[] ti = table1.getItems(); try { WritableWorkbook book = Workbook.createWorkbook(new File(filename)); WritableSheet sheet = book.createSheet("", 0); // jxl.write.Label label=new jxl.write.Label(0,0,"test"); // sheet.addCell(label); // for(int i=0;i<10;i++){ // sheet.addCell(new jxl.write.Label(0,i+1,""+i+"")); // } WritableFont font3 = new WritableFont(WritableFont.createFont(" _GB2312"), 17, WritableFont.NO_BOLD); WritableCellFormat format1 = new WritableCellFormat(font3); // sheet.setRowView(0, 20); sheet.setColumnView(0, 20); sheet.setColumnView(1, 100); jxl.write.Label label1 = new jxl.write.Label(0, 0, "Pritein"); jxl.write.Label label2 = new jxl.write.Label(1, 0, "Functions"); label1.setCellFormat(format1); label2.setCellFormat(format1); sheet.addCell(label1); sheet.addCell(label2); for (int i = 0; i < ti.length; i++) { sheet.addCell(new jxl.write.Label(0, i + 1, ti[i].getText(0))); sheet.addCell(new jxl.write.Label(1, i + 1, ti[i].getText(1))); } // jxl.write.Number number = new jxl.write.Number(1,0,789.123); // sheet.addCell(number); book.write(); book.close(); } catch (Exception e) { MessageDialog.openError(dialogShell, "Error", e.toString()); return; } MessageDialog.openInformation(dialogShell, "Success", "File Saved Successfully"); }
From source file:clustere.dialogs.ProteinFunctionDialog.java
License:Open Source License
/** * /* w ww .j a v a 2 s . com*/ */ public void loadProteins(HashMap<String, Set<String>> result) { FileDialog fd = new FileDialog(dialogShell, SWT.OPEN); fd.setText("Load Proteins"); fd.setFilterExtensions(new String[] { "*.txt", "*" }); fd.setFilterNames(new String[] { "(*.txt)", "()" }); String filename = fd.open(); if (filename == null || filename.equals("")) return; Set<String> proteins = new HashSet<String>(); try { BufferedReader br = new BufferedReader(new FileReader(new File(filename))); Scanner s; String str = br.readLine(); while (str != null) { s = new Scanner(str); while (s.hasNext()) { proteins.add(s.next().toUpperCase()); } str = br.readLine(); } br.close(); } catch (Exception e1) { MessageDialog.openError(dialogShell, "Error", ""); return; } Iterator it = proteins.iterator(); table1.removeAll(); while (it.hasNext()) { String s = (String) it.next(); Set<String> v = null; v = result.get(s); new TableItem(table1, SWT.LEFT).setText(new String[] { s, getString(v) }); } label3.setText("Total Item: " + table1.getItemCount()); MessageDialog.openInformation(dialogShell, "Success", "File read Successfully!"); }
From source file:clustere.dialogs.SaveOptionDialog.java
License:Open Source License
/** * /* w ww .j a va 2 s . co m*/ */ public void saveCluster() { String str = list1.getSelection()[0]; TreeElement treeElement = null; for (int i = 0; i < ViewPart1.list.size(); i++) { TreeElement te = ViewPart1.list.get(i); String testr = te.getName(); int index = testr.indexOf('('); testr = testr.substring(0, index); if (te.hasChildren() && testr.equals(str)) { treeElement = te; break; } } if (treeElement == null) { MessageDialog.openError(dialogShell, "Error", "No result found"); return; } FileDialog fd = new FileDialog(dialogShell, SWT.SAVE); if (button3.getSelection()) { fd.setFilterExtensions(new String[] { "*.ey", "*.txt" }); fd.setFilterNames(new String[] { "*.ey", "*.txt" }); } else if (button4.getSelection()) { fd.setFilterExtensions(new String[] { "*.cx", "*.txt" }); fd.setFilterNames(new String[] { "*.cx", "*.txt" }); } String filename = fd.open(); if (filename == null || filename.equals("")) return; try { BufferedWriter bw = new BufferedWriter(new FileWriter(new File(filename))); bw.write(str + ":Total Clusters:" + treeElement.getChildren().size()); bw.newLine(); bw.write("Node ID\t\tNode Neighbours"); bw.newLine(); for (int i = 0; i < treeElement.getChildren().size(); i++) { TreeElement te = treeElement.getChildren().get(i); Node n = te.getNode(); bw.write("Cluster:" + i + "\t" + n.getScope()); bw.newLine(); for (int j = 0; j < te.getNodes().size(); j++) { Node node = te.getNodes().get(j); bw.write(node.getNodeID()); // bw.write("\t"+getString(node.getNeighbours())); bw.newLine(); } } if (button4.getSelection()) { bw.write("***********************************Original Network*****************************"); bw.newLine(); for (int i = 0; i < GraphInfo.edgelist.size(); i++) { Edge edge = GraphInfo.edgelist.get(i); bw.write(edge.getNode1().getNodeID() + " "); bw.write(edge.getNode2().getNodeID() + " "); bw.write(String.valueOf((int) edge.getWeight())); bw.newLine(); } } // Vector<Node> clusterNode = treeElement.getNodes(); // bw.write("Overlap of clusters****************"); // bw.newLine(); // for(int i=0;i<clusterNode.size();i++){ // Node node = clusterNode.get(i); // bw.write(node.getNodeID()+"\t"+node.getScope()); // for(int j=0;j<node.getNeighbour_NUM();j++){ // Node node2 = node.getNeighbours().get(j); // bw.write("\t"+node2.getNodeID()); // } // bw.newLine(); // } bw.flush(); bw.close(); } catch (Exception e) { MessageDialog.openError(dialogShell, "Error", "File read exception:" + e.toString()); } MessageDialog.openInformation(dialogShell, "Success", "File saved successfully"); }
From source file:cn.com.sky.hyperbola.AddContactDialog.java
License:Open Source License
protected void okPressed() { nickname = nicknameText.getText();/* w ww .j av a 2 s .c o m*/ server = serverText.getText(); userId = userIdText.getText(); if (nickname.equals("")) { MessageDialog.openError(getShell(), "Invalid Nickname", "Nickname field must not be blank."); return; } if (server.equals("")) { MessageDialog.openError(getShell(), "Invalid Server", "Server field must not be blank."); return; } if (userId.equals("")) { MessageDialog.openError(getShell(), "Invalid User id", "User id field must not be blank."); return; } super.okPressed(); }
From source file:cn.dockerfoundry.ide.eclipse.explorer.ui.wizards.DockerConnectionWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridData fileSelectionData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); composite.setLayoutData(fileSelectionData); GridLayout fileSelectionLayout = new GridLayout(); fileSelectionLayout.numColumns = 3;/* ww w.j a v a 2 s. c o m*/ fileSelectionLayout.makeColumnsEqualWidth = false; fileSelectionLayout.marginWidth = 0; fileSelectionLayout.marginHeight = 0; composite.setLayout(fileSelectionLayout); setControl(composite); editor = new StringFieldEditor("connName", "Docker Connection Name: ", composite); //NON-NLS-1 //NON-NLS-2 editor.getTextControl(composite).addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { String connName = DockerConnectionWizardPage.this.editor.getStringValue(); System.out.println("connName:" + connName); } }); // Group group0 = new Group(composite, SWT.NULL); // GridLayout layout = new GridLayout(); // layout.numColumns = 1; // group0.setLayout(layout); connSetting = new Button(composite, SWT.CHECK); connSetting.setSelection(true); connSetting.setText("Use default connection settings"); GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; connSetting.setLayoutData(gridData); group1 = new Group(composite, SWT.NULL); group1.setText("Connection Setting"); gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; group1.setLayoutData(gridData); optionsButton = new Button[2]; optionsButton[0] = new Button(group1, SWT.RADIO); optionsButton[0].setText("Unix Socket"); optionsButton[0].setSelection(true); gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; optionsButton[0].setLayoutData(gridData); unixSocketFileFieldEditor = new FileFieldEditor("Location", " Location: ", group1); //NON-NLS-1 //NON-NLS-2 unixSocketFileFieldEditor.getTextControl(group1).addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { String location = DockerConnectionWizardPage.this.unixSocketFileFieldEditor.getStringValue(); System.out.println("Location:" + location); } }); optionsButton[1] = new Button(group1, SWT.RADIO); optionsButton[1].setText("HTTPS Connection"); gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; optionsButton[1].setLayoutData(gridData); hostEditor = new StringFieldEditor("host", " Host: ", group1); //NON-NLS-1 //NON-NLS-2 hostEditor.getTextControl(group1).addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { String host = DockerConnectionWizardPage.this.hostEditor.getStringValue(); System.out.println("host:" + host); } }); authenticationButton = new Button(group1, SWT.CHECK); authenticationButton.setSelection(true); authenticationButton.setText("Enable authentication"); gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); gridData.horizontalSpan = 3; authenticationButton.setLayoutData(gridData); authenticationFileFieldEditor = new FileFieldEditor("Path", " Path: ", group1); //NON-NLS-1 //NON-NLS-2 authenticationFileFieldEditor.getTextControl(group1).addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { String path = DockerConnectionWizardPage.this.authenticationFileFieldEditor.getStringValue(); System.out.println("Path:" + path); } }); testConnection = new Button(composite, SWT.PUSH); testConnection.setText("Test Connection"); testConnection.setAlignment(SWT.RIGHT); testConnection.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { try { String conn = testConnection(); StringBuilder sb = new StringBuilder( "Successfully connect to Docker with the following info:\n"); sb.append(conn); MessageDialog.openInformation(getShell(), "Docker Connection", sb.toString()); } catch (Exception e) { e.printStackTrace(); StringBuilder sb = new StringBuilder( "Failed to connect to Docker with the following reason:\n"); sb.append(e.getLocalizedMessage()); MessageDialog.openError(getShell(), "Docker Connection", sb.toString()); } } @Override public void keyReleased(KeyEvent arg0) { keyPressed(arg0); } }); composite.moveAbove(null); checkUseUnixSocket(); checkUseDefaultConnSetting(); addListener(); }
From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.CloudUiUtil.java
License:Open Source License
public static void openUrl(String location, int browserChoice) { try {// w w w .jav a2s.c om URL url = null; if (location != null) { url = new URL(location); } if (browserChoice == WebBrowserPreference.EXTERNAL) { try { IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport(); support.getExternalBrowser().openURL(url); } catch (Exception e) { } } else { IWebBrowser browser; int flags; if (WorkbenchBrowserSupport.getInstance().isInternalWebBrowserAvailable()) { flags = IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR; } else { flags = IWorkbenchBrowserSupport.AS_EXTERNAL | IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR; } String generatedId = "org.eclipse.mylyn.web.browser-" + Calendar.getInstance().getTimeInMillis(); //$NON-NLS-1$ browser = WorkbenchBrowserSupport.getInstance().createBrowser(flags, generatedId, null, null); browser.openURL(url); } } catch (PartInitException e) { MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.CloudUiUtil_ERROR_OPEN_BROWSER_FAIL_TITLE, Messages.CloudUiUtil_ERROR_OPEN_BROWSER_BODY); } catch (MalformedURLException e) { if (location == null || location.trim().equals("")) { //$NON-NLS-1$ MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.CloudUiUtil_ERROR_OPEN_BROWSER_FAIL_TITLE, NLS.bind(Messages.CloudUiUtil_ERROR_EMPTY_URL_BODY, location)); } else { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.CloudUiUtil_ERROR_OPEN_BROWSER_FAIL_TITLE, NLS.bind(Messages.CloudUiUtil_ERROR_MALFORM_URL_BODY, location)); } } }
From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.editor.ApplicationDetailsPart.java
License:Open Source License
protected void logError(String message, Shell dialogueShell) { if (editorPage != null && !editorPage.isDisposed()) { if (message != null) { editorPage.setErrorMessage(message); } else {//from w w w . j a v a 2s.co m editorPage.setErrorMessage(null); } } if (dialogueShell != null && message != null) { MessageDialog.openError(dialogueShell, Messages.ApplicationDetailsPart_TEXT_DEBUG, message); } }
From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.TargetURLDialog.java
License:Open Source License
@Override protected void okPressed() { // List<CloudURL> allUrls = CloudUiUtil.getAllUrls(serverTypeId); for (CloudServerURL url : allCloudUrls) { if (url.getName().equals(name)) { MessageDialog.openError(getParentShell(), Messages.TargetURLDialog_ERROR_DUPLICATE_TITLE, NLS.bind(Messages.TargetURLDialog_ERROR_DUPLICATE_BODY, name)); return; }//from w w w .j a v a2 s .com } final boolean[] shouldProceed = new boolean[] { false }; BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { public void run() { url = replaceWildcard(cloudUrl.getUrl(), wildcard, value); try { DockerFoundryPlugin.getCloudFoundryClientFactory().getCloudFoundryOperations(url) .getCloudInfo(); shouldProceed[0] = true; } catch (Exception e) { shouldProceed[0] = MessageDialog.openQuestion(getParentShell(), Messages.TargetURLDialog_ERROR_INVALID_URL_TITLE, NLS.bind(Messages.TargetURLDialog_ERROR_INVALID_URL_BODY, url)); } } }); if (shouldProceed[0]) { super.okPressed(); } }
From source file:cn.dockerfoundry.ide.eclipse.server.ui.internal.UpdatePasswordDialog.java
License:Open Source License
@Override protected void okPressed() { if (!verifyPassword.equals(password)) { MessageDialog.openError(getParentShell(), Messages.UpdatePasswordDialog_ERROR_VERIFY_PW_TITLE, Messages.UpdatePasswordDialog_ERROR_VERIFY_PW_BODY); return;/*from ww w. j ava 2s . co m*/ } super.okPressed(); }