List of usage examples for javax.swing JOptionPane showInputDialog
@SuppressWarnings("deprecation") public static Object showInputDialog(Component parentComponent, Object message, String title, int messageType, Icon icon, Object[] selectionValues, Object initialSelectionValue) throws HeadlessException
From source file:lu.fisch.unimozer.Diagram.java
public void runFast() { //System.out.println("TZ: runFast"); try {// w ww . j a v a 2s. com // compile all //doCompilationOnly(null); //frame.setCompilationErrors(new Vector<CompilationError>()); //Console.disconnectAll(); //Console.disconnectErr(); if (compile()) { Vector<String> mains = getMains(); String runnable = null; if (mains.size() == 0) { JOptionPane.showMessageDialog(frame, "Sorry, but your project does not contain any runnable public class ...", "Error", JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR); } else { if (mains.size() == 1) { runnable = mains.get(0); } else { String[] classNames = new String[mains.size()]; for (int c = 0; c < mains.size(); c++) classNames[c] = mains.get(c); runnable = (String) JOptionPane.showInputDialog(frame, "Unimozer detected more than one runnable class.\n" + "Please select which one you want to run.", "Run", JOptionPane.QUESTION_MESSAGE, Unimozer.IMG_QUESTION, classNames, ""); } // we know now what to run MyClass runnClass = classes.get(runnable); // set full signature String fullSign = "void main(String[] args)"; if (runnClass.hasMain2()) fullSign = "void main(String args[])"; // get signature String sign = runnClass.getSignatureByFullSignature(fullSign); String complete = runnClass.getCompleteSignatureBySignature(sign); if ((runnClass.hasMain2()) && (sign.equals("void main(String)"))) { sign = "void main(String[])"; } //System.out.println("Calling method (full): "+fullSign); //System.out.println("Calling method : "+sign); // find method System.out.println("TZ: compile"); Class c = Runtime5.getInstance().load(runnClass.getFullName()); Method m[] = c.getMethods(); for (int i = 0; i < m.length; i++) { String full = ""; full += m[i].getReturnType().getSimpleName(); full += " "; full += m[i].getName(); full += "("; Class<?>[] tvm = m[i].getParameterTypes(); LinkedHashMap<String, String> genericInputs = new LinkedHashMap<String, String>(); for (int t = 0; t < tvm.length; t++) { String sn = tvm[t].toString(); genericInputs.put("param" + t, sn); sn = sn.substring(sn.lastIndexOf('.') + 1, sn.length()); if (sn.startsWith("class")) sn = sn.substring(5).trim(); // array is shown as ";" ??? if (sn.endsWith(";")) { sn = sn.substring(0, sn.length() - 1) + "[]"; } full += sn + ", "; } if (tvm.length > 0) full = full.substring(0, full.length() - 2); full += ")"; //if((full.equals(sign) || full.equals(fullSign))) // System.out.println("Found: "+full); if ((full.equals(sign) || full.equals(fullSign))) { try { String method = runnClass.getFullName() + "." + m[i].getName() + "(null)"; // Invoke method in a new thread final String myMeth = method; //System.out.println("Running now: "+myMeth); Runnable r = new Runnable() { public void run() { Console.cls(); try { Console.disconnectAll(); System.out.println("Running now: " + myMeth); System.out.println(Runtime5.getInstance().toString()); Console.connectAll(); Object retobj = Runtime5.getInstance().executeMethod(myMeth); if (retobj != null) JOptionPane.showMessageDialog(frame, retobj.toString(), "Result", JOptionPane.INFORMATION_MESSAGE, Unimozer.IMG_INFO); } catch (EvalError ex) { JOptionPane.showMessageDialog(frame, ex.toString(), "Execution error", JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR); MyError.display(ex); } } }; Thread t = new Thread(r); t.start(); //System.out.println(method); //Object retobj = Runtime5.getInstance().executeMethod(method); //if(retobj!=null) JOptionPane.showMessageDialog(frame, retobj.toString(), "Result", JOptionPane.INFORMATION_MESSAGE,Unimozer.IMG_INFO); } catch (Throwable ex) { JOptionPane.showMessageDialog(frame, ex.toString(), "Execution error", JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR); MyError.display(ex); } } } } } } catch (ClassNotFoundException ex) { JOptionPane.showMessageDialog(frame, "There was an error while running your project ...", "Error :: ClassNotFoundException", JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR); } }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Insert standard prefixes in the assertions text area. * //from w ww. ja v a 2 s.c o m * The user must choose the format (syntax) to use. */ private void insertPrefixes() { String whichFormat; int formatIndex; String[] formatsToChoose; List<String> formatsAvail; StringBuffer prefixesToAdd; JTextArea areaToUpdate; formatsAvail = new ArrayList<String>(); for (int format = 0; format < FORMATS.length; ++format) { if (STANDARD_PREFIXES[format].length > 0) { formatsAvail.add(FORMATS[format]); } } // SPARQL is a special case - not an RDF serialization formatsAvail.add("SPARQL (tab)"); formatsToChoose = new String[formatsAvail.size()]; for (int format = 0; format < formatsAvail.size(); ++format) { formatsToChoose[format] = formatsAvail.get(format); } whichFormat = (String) JOptionPane.showInputDialog(this, "Choose the format for the prefixes", "Choose Format", JOptionPane.QUESTION_MESSAGE, null, formatsToChoose, null); LOGGER.debug("Chosen format for prefixes: " + whichFormat); if (whichFormat != null) { formatIndex = getIndexValue(FORMATS, whichFormat); // SPARQL - special case - not an RDF serialization format if (formatIndex == UNKNOWN) { formatIndex = STANDARD_PREFIXES.length - 1; areaToUpdate = sparqlInput; } else { areaToUpdate = assertionsInput; } LOGGER.debug("Chosen format index for prefixes: " + formatIndex); if (formatIndex >= 0) { String currentData; currentData = areaToUpdate.getText(); prefixesToAdd = new StringBuffer(); for (int prefix = 0; prefix < STANDARD_PREFIXES[formatIndex].length; ++prefix) { prefixesToAdd.append(STANDARD_PREFIXES[formatIndex][prefix]); prefixesToAdd.append('\n'); } areaToUpdate.setText(prefixesToAdd.toString() + currentData); } } }
From source file:lu.fisch.unimozer.Diagram.java
public void jar() { try {/*from w ww .j av a 2 s .co m*/ // compile all if (compile()) if (save()) { // adjust the dirname String dir = getDirectoryName(); if (!dir.endsWith(System.getProperty("file.separator"))) { dir += System.getProperty("file.separator"); } // adjust the filename String name = getDirectoryName(); if (name.endsWith(System.getProperty("file.separator"))) { name = name.substring(0, name.length() - 1); } name = name.substring(name.lastIndexOf(System.getProperty("file.separator")) + 1); /*String[] classNames = new String[classes.size()+1]; Set<String> set = classes.keySet(); Iterator<String> itr = set.iterator(); classNames[0]=null; int c = 1; while (itr.hasNext()) { classNames[c]=itr.next(); c++; }/**/ Vector<String> mains = getMains(); String[] classNames = new String[mains.size()]; for (int c = 0; c < mains.size(); c++) classNames[c] = mains.get(c); // default class to launch String mc = ""; { if (classNames.length == 0) { mc = ""; JOptionPane.showMessageDialog(printOptions, "Unimozer was unable to detect a startable class\n" + "inside your project. The JAR-archive will be created\n" + "but it won't be executable!", "Mainclass", JOptionPane.INFORMATION_MESSAGE, Unimozer.IMG_INFO); } else if (classNames.length == 1) mc = classNames[0]; else mc = (String) JOptionPane.showInputDialog(frame, "Unimozer detected more than one runnable class.\n" + "Please select which one you want to be launched\n" + "automatically with the JAR-archive.", "Autostart", JOptionPane.QUESTION_MESSAGE, Unimozer.IMG_QUESTION, classNames, ""); } // target JVM String target = null; if (Runtime5.getInstance().usesSunJDK() && mc != null) { String[] targets = new String[] { "1.1", "1.2", "1.3", "1.5", "1.6" }; if (System.getProperty("java.version").startsWith("1.7")) targets = new String[] { "1.1", "1.2", "1.3", "1.5", "1.6", "1.7" }; if (System.getProperty("java.version").startsWith("1.8")) targets = new String[] { "1.1", "1.2", "1.3", "1.5", "1.6", "1.7", "1.8" }; target = (String) JOptionPane.showInputDialog(frame, "Please enter version of the JVM you want to target.", "Target JVM", JOptionPane.QUESTION_MESSAGE, Unimozer.IMG_QUESTION, targets, "1.6"); } // make the class-files and all // related stuff if (((Runtime5.getInstance().usesSunJDK() && target != null) || (!Runtime5.getInstance().usesSunJDK())) && (mc != null)) if (makeInteractive(false, target, false) == true) { StringList manifest = new StringList(); manifest.add("Manifest-Version: 1.0"); manifest.add("Created-By: " + Unimozer.E_VERSION + " " + Unimozer.E_VERSION); manifest.add("Name: " + name); if (mc != null) { manifest.add("Main-Class: " + mc); } // compose the filename File fDir = new File(dir + "dist" + System.getProperty("file.separator")); fDir.mkdir(); name = dir + "dist" + System.getProperty("file.separator") + name + ".jar"; String baseName = dir; String libFolderName = dir + "lib"; String distLibFolderName = dir + "dist" + System.getProperty("file.separator") + "lib"; File outFile = new File(name); FileOutputStream bo = new FileOutputStream(name); JarOutputStream jo = new JarOutputStream(bo); String dirname = getDirectoryName(); if (!dirname.endsWith(System.getProperty("file.separator"))) { dirname += System.getProperty("file.separator"); } // add the files to the array addToJar(jo, "", new File(dirname + "bin" + System.getProperty("file.separator"))); // add the files to the array addToJar(jo, "", new File(dirname + "src" + System.getProperty("file.separator")), new String[] { "java" }); /* // define a filter for files that do not start with a dot FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return !name.startsWith("."); } }; // get the bin directory File binDir = new File(dirname+"bin"+System.getProperty("file.separator")); // get all files File[] files = binDir.listFiles(filter); for(int f=0;f<files.length;f++) { FileInputStream bi = new FileInputStream(files[f]); String entry = files[f].getAbsolutePath(); entry = entry.substring(binDir.getAbsolutePath().length()+1); JarEntry je = new JarEntry(entry); jo.putNextEntry(je); byte[] buf = new byte[1024]; int anz; while ((anz = bi.read(buf)) != -1) { jo.write(buf, 0, anz); } bi.close(); } */ // ask to include another direectory // directory filter /* FilenameFilter dirFilter = new FilenameFilter() { public boolean accept(File dir, String name) { File isDir = new File(dir+System.getProperty("file.separator")+name); return isDir.isDirectory() && !name.equals("bin") && !name.equals("src") && !name.equals("dist") && !name.equals("nbproject") && !name.equals("doc"); } }; // get directories File projectDir = new File(dirname); String[] subDirs = projectDir.list(dirFilter); if(subDirs.length>0) { String subdir = (String) JOptionPane.showInputDialog( frame, "Do you want to include any other resources directory?\n"+ "Click ?Cancel? to not include any resources directory!", "JAR Packager", JOptionPane.QUESTION_MESSAGE, Unimozer.IMG_QUESTION, subDirs, null); if(subdir!=null) { addToJar(jo,subdir+"/",new File(dirname+subdir+System.getProperty("file.separator"))); } } */ /* Set<String> set = classes.keySet(); Iterator<String> itr = set.iterator(); int i = 0; while (itr.hasNext()) { String classname = itr.next(); String act = classname + ".class"; FileInputStream bi = new FileInputStream(dirname+"bin"+System.getProperty("file.separator")+act); JarEntry je = new JarEntry(act); jo.putNextEntry(je); byte[] buf = new byte[1024]; int anz; while ((anz = bi.read(buf)) != -1) { jo.write(buf, 0, anz); } bi.close(); } */ // copy libs File lib = new File(libFolderName); File distLib = new File(distLibFolderName); StringList libs = null; if (lib.exists()) { libs = CopyDirectory.copyFolder(lib, distLib); } String cp = new String(); if (libs != null) { for (int i = 0; i < libs.count(); i++) { String myLib = libs.get(i); myLib = myLib.substring(baseName.length()); if (i != 0) cp = cp + " "; cp = cp + myLib; } //manifest.add("Class-Path: "+cp); } // Let's search for the path of the swing-layout JAR file String cpsw = ""; if (getCompleteSourceCode().contains("org.jdesktop.layout")) { if (Main.classpath != null) { // copy the file String src = Main.classpath; File f1 = new File(src); String dest = distLibFolderName + System.getProperty("file.separator") + f1.getName(); // create folder if not exists File f2 = new File(distLibFolderName); if (!f2.exists()) f2.mkdir(); // copy the file InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } in.close(); out.close(); // add the manifest entry cpsw = "lib" + System.getProperty("file.separator") + f1.getName(); } } manifest.add("Class-Path: " + cp + " " + cpsw); // adding the manifest file manifest.add(""); JarEntry je = new JarEntry("META-INF/MANIFEST.MF"); jo.putNextEntry(je); String mf = manifest.getText(); jo.write(mf.getBytes(), 0, mf.getBytes().length); jo.close(); bo.close(); cleanAll(); JOptionPane.showMessageDialog(frame, "The JAR-archive has been generated ...", "Success", JOptionPane.INFORMATION_MESSAGE, Unimozer.IMG_INFO); } } } /*catch (ClassNotFoundException ex) { JOptionPane.showMessageDialog(frame, "There was an error while creating the JAR-archive ...", "Error :: ClassNotFoundException", JOptionPane.ERROR_MESSAGE,Unimozer.IMG_ERROR); }*/ catch (IOException ex) { JOptionPane.showMessageDialog(frame, "There was an error while creating the JAR-archive ...", "Error :: IOException", JOptionPane.ERROR_MESSAGE, Unimozer.IMG_ERROR); } }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void changeServicePriority() { final QPlanService plan = (QPlanService) listUserService.getSelectedValue(); if (plan == null) { return; }/*from w w w .j a va 2 s .c om*/ // ? , ? ? ? ? . listUserService.requestFocus(); listUserService.requestFocusInWindow(); final String name = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.select_priority.message"), getLocaleMessage("admin.select_priority.title"), JOptionPane.QUESTION_MESSAGE, null, Uses.get_COEFF_WORD().values().toArray(), Uses.get_COEFF_WORD().values().toArray()[plan.getCoefficient()]); //? , if (name != null) { for (int i = 0; i < Uses.get_COEFF_WORD().size(); i++) { if (name.equals(Uses.get_COEFF_WORD().get(i))) { plan.setCoefficient(i); } } } }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void standAdvance() { final QService service = (QService) treeServices.getLastSelectedPathComponent(); if (service != null && service.isLeaf()) { String inputData = null; if (service.getInput_required()) { inputData = (String) JOptionPane.showInputDialog(this, service.getInput_caption(), "***", 3, null, null, ""); if (inputData == null) { return; }/* w w w . ja v a2s .c o m*/ } String comments = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.comments"), "***", 3, null, null, ""); if (inputData == null) { inputData = ""; } final QAdvanceCustomer res; try { res = FAdvanceCalendar.showCalendar(this, true, new ServerNetProperty(), service, false, 0, -1, inputData, comments); } catch (Exception ex) { throw new ClientException(getLocaleMessage("admin.send_cmd_adv.err") + " " + ex); } if (res == null) { return; } // new Thread(() -> { FWelcome.printTicketAdvance(res, ((QService) treeServices.getModel().getRoot()).getTextToLocale(QService.Field.NAME)); }).start(); JOptionPane.showMessageDialog(this, getLocaleMessage("admin.client_adv_dialog.msg_1") + " \"" + service.getName() + "\". " + getLocaleMessage("admin.client_adv_dialog.msg_2") + " \"" + res.getId() + "\".", getLocaleMessage("admin.client_adv_dialog.title"), JOptionPane.INFORMATION_MESSAGE); } }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addRespItem() { // ? ? , String respName = getLocaleMessage("admin.add_resp_dialog.info"); boolean flag = true; while (flag) { respName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_resp_dialog.message"), getLocaleMessage("admin.add_resp_dialog.title"), 3, null, null, respName); if (respName == null) { return; }//from www. jav a 2s . co m if ("".equals(respName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_resp_dialog.err1.message"), getLocaleMessage("admin.add_resp_dialog.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (respName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_resp_dialog.err2.message"), getLocaleMessage("admin.add_resp_dialog.err2.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (respName.length() > 100) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_resp_dialog.err3.message"), getLocaleMessage("admin.add_resp_dialog.err3.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } QLog.l().logger().debug("? \"" + respName + "\""); final QRespItem item = new QRespItem(); item.setName(respName); item.setHTMLText( "<html><b><p align=center><span style='font-size:20.0pt;color:green'>" + respName + "</span></b>"); QResponseList.getInstance().addElement(item); listResponse.setSelectedValue(item, true); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addSchedule() { // ? ? , String scheduleName = getLocaleMessage("admin.add_work_plan_dialog.info"); boolean flag = true; while (flag) { scheduleName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_work_plan_dialog.message"), getLocaleMessage("admin.add_work_plan_dialog.title"), 3, null, null, scheduleName); if (scheduleName == null) { return; }//from w w w.ja va 2s . c o m if ("".equals(scheduleName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_work_plan_dialog.err1.message"), getLocaleMessage("admin.add_work_plan_dialog.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (scheduleName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_work_plan_dialog.err2.message"), getLocaleMessage("admin.add_work_plan_dialog.err2.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (scheduleName.length() > 150) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_work_plan_dialog.err3.message"), getLocaleMessage("admin.add_work_plan_dialog.err3.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } QLog.l().logger().debug("? \"" + scheduleName + "\""); final QSchedule item = new QSchedule(); item.setName(scheduleName); item.setType(0); QScheduleList.getInstance().addElement(item); listSchedule.setSelectedValue(item, true); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addResult() { String resultText = ""; boolean flag = true; while (flag) { resultText = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_result_dialog.message"), getLocaleMessage("admin.add_result_dialog.title"), 3, null, null, resultText); if (resultText == null) { return; }// w ww .j a va 2 s . c o m if ("".equals(resultText)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_result_dialog.err1.message"), getLocaleMessage("admin.add_result_dialog.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (resultText.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_result_dialog.err2.message"), getLocaleMessage("admin.add_result_dialog.err2.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (resultText.length() > 150) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_result_dialog.err3.message"), getLocaleMessage("admin.add_result_dialog.err3.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } QLog.l().logger().debug("? \"" + resultText + "\""); final QResult item = new QResult(); item.setName(resultText); QResultList.getInstance().addElement(item); listResults.setSelectedValue(item, true); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void addCalendar() { // ? ? ? , String calendarName = getLocaleMessage("admin.add_calendar_dialog.info"); boolean flag = true; while (flag) { calendarName = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.add_calendar_dialog.message"), getLocaleMessage("admin.add_calendar_dialog.title"), 3, null, null, calendarName); if (calendarName == null) { return; }/*from ww w . j av a 2 s. c o m*/ if ("".equals(calendarName)) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_calendar_dialog.err1.message"), getLocaleMessage("admin.add_calendar_dialog.err1.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (calendarName.indexOf('\"') != -1) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_calendar_dialog.err2.message"), getLocaleMessage("admin.add_calendar_dialog.err2.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else if (calendarName.length() > 150) { JOptionPane.showConfirmDialog(this, getLocaleMessage("admin.add_calendar_dialog.err3.message"), getLocaleMessage("admin.add_calendar_dialog.err3.title"), JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE); } else { flag = false; } } QLog.l().logger().debug("? \"" + calendarName + "\""); final QCalendar item = new QCalendar(); item.setName(calendarName); QCalendarList.getInstance().addElement(item); listCalendar.setSelectedValue(item, true); }
From source file:ru.apertum.qsystem.client.forms.FAdmin.java
@Action public void changePriority() { final String num = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.action.change_priority.num.message"), getLocaleMessage("admin.action.change_priority.num.title"), 3, null, null, ""); if (num != null) { final String name = (String) JOptionPane.showInputDialog(this, getLocaleMessage("admin.action.change_priority.get.message"), getLocaleMessage("admin.action.change_priority.get.title"), JOptionPane.QUESTION_MESSAGE, null, Uses.get_PRIORITYS_WORD().values().toArray(), Uses.get_PRIORITYS_WORD().values().toArray()[1]); //? , if (name != null) { for (int i = 0; i < Uses.get_PRIORITYS_WORD().size(); i++) { if (name.equals(Uses.get_PRIORITYS_WORD().get(i))) { JOptionPane.showMessageDialog(this, NetCommander.setCustomerPriority(new ServerNetProperty(), i, num), getLocaleMessage("admin.action.change_priority.title"), JOptionPane.INFORMATION_MESSAGE); }//from w w w . j av a 2s .c o m } } } }