public virtual string Show(string filename, Point location) { File jarFile = new File(filename); if (!jarFile.Exists()) { JOptionPane.ShowMessageDialog(panel, "Filename " + jarFile + " does not exist", null, JOptionPane.ErrorMessage); return(null); } IList <string> files; try { files = GetFiles(jarFile); } catch (Exception e) { // Something went wrong reading the file. JOptionPane.ShowMessageDialog(panel, "Filename " + jarFile + " had an error:\n" + e, null, JOptionPane.ErrorMessage); return(null); } if (files.Count == 0) { JOptionPane.ShowMessageDialog(panel, "Filename " + jarFile + " does not contain any models", null, JOptionPane.ErrorMessage); return(null); } return(ShowListSelectionDialog(files, location)); }
/// <summary> /// Create a menu from the provided OneWireContainer /// Vector and allow the user to select a device. /// </summary> /// <param name="owd_vect"> vector of devices to choose from /// </param> /// <returns> OneWireContainer device selected </returns> public static OneWireContainer selectDevice(ArrayList owd_vect, string title) { // create a menu ArrayList menu = new ArrayList(owd_vect.Count); string temp_str; OneWireContainer owd; int i; for (i = 0; i < owd_vect.Count; i++) { owd = (OneWireContainer)owd_vect[i]; temp_str = owd.AddressAsString + " - " + owd.Name; if (owd.AlternateNames.length() > 0) { temp_str += "/" + owd.AlternateNames; } menu.Add(temp_str); } string selectedValue = (string)JOptionPane.showInputDialog(null, title, "1-Wire Tag Creator", JOptionPane.INFORMATION_MESSAGE, null, menu.ToArray(), menu.ToArray()[0]); if (!string.ReferenceEquals(selectedValue, null)) { return((OneWireContainer)owd_vect[menu.IndexOf(selectedValue)]); } else { throw new InterruptedException("Quit in device selection"); } }
public String getUserInputOfSixDigits() { String userInput; userInput = JOptionPane.showInputDialog("input a six digit number"); return(userInput); }
public override void Run() { int failures = 0; try { FileOutputStream fos = new FileOutputStream(this.filename); OutputStreamWriter ow = new OutputStreamWriter(fos, "utf-8"); BufferedWriter bw = new BufferedWriter(ow); foreach (IList <IHasWord> sentence in this.sentences) { Tree tree = this._enclosing.parser.ParseTree(sentence); if (tree == null) { ++failures; ParserPanel.log.Info("Failed on sentence " + sentence); } else { bw.Write(tree.ToString()); bw.NewLine(); } this.progress.SetValue(this.progress.GetValue() + 1); if (this.cancelled) { break; } } bw.Flush(); bw.Close(); ow.Close(); fos.Close(); } catch (IOException e) { JOptionPane.ShowMessageDialog(this._enclosing, "Could not save file " + this.filename + "\n" + e, null, JOptionPane.ErrorMessage); Sharpen.Runtime.PrintStackTrace(e); this._enclosing.SetStatus("Error saving parsed document"); } if (failures == 0) { this.button.SetText("Success!"); } else { this.button.SetText("Done. " + failures + " parses failed"); } if (this.cancelled && failures == 0) { this.dialog.SetVisible(false); } else { this.button.AddActionListener(null); } }
/// <summary> /// Opens a dialog and saves the output of the parser on the current /// text. /// </summary> /// <remarks> /// Opens a dialog and saves the output of the parser on the current /// text. If there is no current text, yell at the user and make /// them feel bad instead. /// </remarks> public virtual void SaveOutput() { if (textPane.GetText().Trim().Length == 0) { JOptionPane.ShowMessageDialog(this, "No text to parse ", null, JOptionPane.ErrorMessage); return; } jfc.SetDialogTitle("Save file"); int status = jfc.ShowSaveDialog(this); if (status == JFileChooser.ApproveOption) { SaveOutput(jfc.GetSelectedFile().GetPath()); } }
private void processSpecialKeys() { if (isSpecialKeyPressed(keyCode.VOLMIN)) { Audio.setVolumeDown(); } else if (isSpecialKeyPressed(keyCode.VOLPLUS)) { Audio.setVolumeUp(); } else if (isSpecialKeyPressed(keyCode.HOME)) { Buttons_Renamed &= ~PSP_CTRL_HOME; // Release the HOME button to avoid dialog spamming. int opt = JOptionPane.showOptionDialog(null, "Exit the current application?", "HOME", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, null, null); if (opt == DialogResult.Yes) { Modules.LoadExecForUserModule.triggerExitCallback(); } } }
/// <summary>Loads a serialized parser specified by given path</summary> public virtual void LoadParser(string filename) { if (filename == null) { return; } // check if file exists before we start the worker thread and progress monitor File file = new File(filename); if (file.Exists()) { lpThread = new ParserPanel.LoadParserThread(this, filename); lpThread.Start(); StartProgressMonitor("Loading Parser", ParserLoadTime); } else { JOptionPane.ShowMessageDialog(this, "Could not find file " + filename, null, JOptionPane.ErrorMessage); SetStatus("Error loading parser"); } }
public override void Run() { bool successful; IParserQuery parserQuery = this._enclosing.parser.ParserQuery(); try { successful = parserQuery.Parse(this.sentence); } catch (Exception) { this._enclosing.StopProgressMonitor(); JOptionPane.ShowMessageDialog(this._enclosing, "Could not parse selected sentence\n(sentence probably too long)", null, JOptionPane.ErrorMessage); this._enclosing.SetStatus("Error parsing"); return; } this._enclosing.StopProgressMonitor(); this._enclosing.SetStatus("Done"); if (successful) { // display the best parse Tree tree = parserQuery.GetBestParse(); //tree.pennPrint(); this._enclosing.treePanel.SetTree(tree); this._enclosing.clearButton.SetEnabled(true); } else { JOptionPane.ShowMessageDialog(this._enclosing, "Could not parse selected sentence", null, JOptionPane.ErrorMessage); this._enclosing.SetStatus("Error parsing"); this._enclosing.treePanel.SetTree(null); this._enclosing.clearButton.SetEnabled(false); } if (this._enclosing.scrollWhenDone) { this._enclosing.ScrollForward(); } }
public override void Run() { try { if (this.zipFilename != null) { this._enclosing.parser = LexicalizedParser.LoadModelFromZip(this.zipFilename, this.filename); } else { this._enclosing.parser = ((LexicalizedParser)LexicalizedParser.LoadModel(this.filename)); } } catch (Exception) { JOptionPane.ShowMessageDialog(this._enclosing, "Error loading parser: " + this.filename, null, JOptionPane.ErrorMessage); this._enclosing.SetStatus("Error loading parser"); this._enclosing.parser = null; } catch (OutOfMemoryException) { JOptionPane.ShowMessageDialog(this._enclosing, "Could not load parser. Out of memory.", null, JOptionPane.ErrorMessage); this._enclosing.SetStatus("Error loading parser"); this._enclosing.parser = null; } this._enclosing.StopProgressMonitor(); if (this._enclosing.parser != null) { this._enclosing.SetStatus("Loaded parser."); this._enclosing.parserFileLabel.SetText("Parser: " + this.filename); this._enclosing.parseButton.SetEnabled(true); this._enclosing.parseNextButton.SetEnabled(true); this._enclosing.saveOutputButton.SetEnabled(true); ParserPanel.tlp = this._enclosing.parser.GetOp().Langpack(); this._enclosing.encoding = ParserPanel.tlp.GetEncoding(); } }
//when the user copies to clip board, select the entire table. //then pull the data off of the grid and create a string object //that is the formatted matrix that the UCI file expects. public void actionPerformed(ActionEvent e) { if (e.getActionCommand().compareTo("Copy") == 0) { StringBuffer sbf = new StringBuffer(); // Check to ensure we have selected only a contiguous block of cells int numcols = jTable1.getColumnCount(); //jTable1.getSelectedColumnCount(); int numrows = jTable1.getRowCount(); //jTable1.getSelectedRowCount(); jTable1.selectAll(); int[] rowsselected = jTable1.getSelectedRows(); int[] colsselected = jTable1.getSelectedColumns(); if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] - colsselected[0] && numcols == colsselected.length))) { JOptionPane.showMessageDialog(null, "Invalid Copy Selection", "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); return; } //write the name of the calculator to the string buffer //xyang sbf.append(" *** " + this.calculatorType + " ***\n"); if (this.calculatorType == "TRAPEZOIDAL") { string txt = plotdata.trapPanel.lblChannelDepth.getText(); //xyang sbf.append(" *** " + txt + " "); double outvalue = plotdata.value[0]; sbf.append(outvalue + "***\n"); txt = plotdata.trapPanel.lblTopChannelWidth.getText(); sbf.append(" *** " + txt + " "); outvalue = plotdata.value[1]; sbf.append(outvalue + "***\n"); txt = plotdata.trapPanel.lblSideChannelSlope.getText(); sbf.append(" *** " + txt + " "); outvalue = plotdata.value[2]; sbf.append(outvalue + "***\n"); txt = plotdata.trapPanel.lblChannelLength.getText(); sbf.append(" *** " + txt + " "); outvalue = plotdata.value[3]; sbf.append(outvalue + "***\n"); /*txt = plotdata.trapPanel.lblChannelMannigsValue.getText(); * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[4]; * sbf.append(outvalue + "***\n");*/ /* txt = plotdata.trapPanel.lblChannelAvgSlope.getText(); * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[5]; * sbf.append(outvalue + "***\n");*/ txt = plotdata.trapPanel.lblIncrement.getText(); sbf.append(" *** " + txt + " "); outvalue = plotdata.value[6]; sbf.append(outvalue + "***\n"); } else if (this.calculatorType == "PARABOLIC") { string txt = plotdata.parabolicPanel.lblChannelLength.getText(); //xyang sbf.append(" *** " + txt + " "); double outvalue = plotdata.value[0]; sbf.append(outvalue + "***\n"); txt = plotdata.parabolicPanel.lblChannelWidth.getText(); sbf.append(" *** " + txt + " "); outvalue = plotdata.value[1]; sbf.append(outvalue + "***\n"); txt = plotdata.parabolicPanel.lblChannelDepth.getText(); sbf.append(" *** " + txt + " "); outvalue = plotdata.value[2]; sbf.append(outvalue + "***\n"); /*txt = plotdata.parabolicPanel.lblChannelMannigsValue.getText(); * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[3]; * sbf.append(outvalue + "***\n"); * * txt = plotdata.parabolicPanel.lblChannelAvgSlope.getText(); * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[4]; * sbf.append(outvalue + "***\n");*/ txt = plotdata.parabolicPanel.lblIncrement.getText(); sbf.append(" *** " + txt + " "); outvalue = plotdata.value[5]; sbf.append(outvalue + "***\n"); } else if (this.calculatorType == "CIRCULAR") { string txt = plotdata.circPanel.lblChannelLength.getText(); //xyang sbf.append(" *** " + txt + " "); double outvalue = plotdata.value[0]; sbf.append(outvalue + "***\n"); txt = plotdata.circPanel.lblChannelDiameter.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[1]; sbf.append(outvalue + "***\n"); /*txt = plotdata.circPanel.lblChannelMannigsValue.getText();//xyang * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[2]; * sbf.append(outvalue + "***\n");*/ txt = plotdata.circPanel.lblChannelAvgSlope.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[3]; sbf.append(outvalue + "***\n"); txt = plotdata.circPanel.lblIncrement.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[4]; sbf.append(outvalue + "***\n"); } else if (this.calculatorType == "RECTANGULAR") { string txt = plotdata.recPanel.lblChannelDepth.getText(); //xyang sbf.append(" *** " + txt + " "); double outvalue = plotdata.value[0]; sbf.append(outvalue + "***\n"); txt = plotdata.recPanel.lblChannelWidth.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[1]; sbf.append(outvalue + "***\n"); txt = plotdata.recPanel.lblChannelLength.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[2]; sbf.append(outvalue + "***\n"); /*txt = plotdata.recPanel.lblChannelMannigsValue.getText();//xyang * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[3]; * sbf.append(outvalue + "***\n");*/ /*txt = plotdata.recPanel.lblChannelAvgSlope.getText();//xyang * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[4]; * sbf.append(outvalue + "***\n");*/ txt = plotdata.recPanel.lblIncrement.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[5]; sbf.append(outvalue + "***\n"); } else if (this.calculatorType == "TRIANGULAR") { string txt = plotdata.triPanel.lblChannelDepth.getText(); //xyang sbf.append(" *** " + txt + " "); double outvalue = plotdata.value[0]; sbf.append(outvalue + "***\n"); txt = plotdata.triPanel.lblChannelWidth.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[1]; sbf.append(outvalue + "***\n"); txt = plotdata.triPanel.lblChannelLength.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[2]; sbf.append(outvalue + "***\n"); /*txt = plotdata.triPanel.lblChannelMannigsValue.getText();//xyang * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[3]; * sbf.append(outvalue + "***\n"); * * txt = plotdata.triPanel.lblChannelAvgSlope.getText();//xyang * sbf.append(" *** " + txt + " "); * outvalue = plotdata.value[4]; * sbf.append(outvalue + "***\n");*/ txt = plotdata.triPanel.lblIncrement.getText(); //xyang sbf.append(" *** " + txt + " "); outvalue = plotdata.value[5]; sbf.append(outvalue + "***\n"); } //xyang end sbf.append(" FTABLE 999\n"); //sbf.append(" 999's are placeholders for user provided ID 1-3 digits in length***"); //sbf.append("\n"); sbf.append(" rows cols ***\n"); //the following section requires me to do a calculation to correctly right justify the rows and cols figures. sbf.append(FiveSpaceFormat(numrows.toString()) + FiveSpaceFormat(numcols.toString()) + "\n"); for (int i = 0; i < numcols; i++) { string colName = jTable1.getColumnModel().getColumn(i).getHeaderValue().toString(); colName = colName.substring(0, colName.indexOf("(")); sbf.append(TenSpaceFormat(colName)); } sbf.append(" ***"); sbf.append("\n"); for (int i = 0; i < numrows; i++) { for (int j = 0; j < numcols; j++) { //jTable1.getValueAt(rowsselected[i],colsselected[j]); double newValue = double.valueOf(jTable1.getValueAt(rowsselected[i], colsselected[j]).toString()); if (newValue.equals(double.NaN)) { newValue = 0.000000d; } DecimalFormat df = new DecimalFormat("#.######"); // if (newValue <= 9E-6){ // sbf.append(TenSpaceFormat("0.00000")); // } // else{ sbf.append(TenSpaceFormat(df.format(newValue))); //} //if (j<numcols-1) sbf.append("\t"); } sbf.append("\n"); } sbf.append("\n"); sbf.append("\n"); sbf.append(FiveSpaceFormat(" END FTABLE999")); /*stsel = new StringSelection(sbf.toString()); * system = Toolkit.getDefaultToolkit().getSystemClipboard(); * system.setContents(stsel,stsel);*/ this.jTArea.setText(sbf.toString()); } }
public virtual int sceNpAuthCreateStartRequest(TPointer paramAddr) { SceNpAuthRequestParameter param = new SceNpAuthRequestParameter(); param.read(paramAddr); if (log.InfoEnabled) { Console.WriteLine(string.Format("sceNpAuthCreateStartRequest param: {0}", param)); } serviceId = param.serviceId; if (!useDummyTicket) { string loginId = JOptionPane.showInputDialog("Enter your PSN Sign-In ID (Email Address)"); if (!string.ReferenceEquals(loginId, null)) { string password = JOptionPane.showInputDialog("Enter your PSN Password"); if (!string.ReferenceEquals(password, null)) { StringBuilder @params = new StringBuilder(); addURLParam(@params, "serviceid", serviceId); addURLParam(@params, "loginid", loginId); addURLParam(@params, "password", password); if (param.cookie != 0) { addURLParam(@params, "cookie", param.cookie, param.cookieSize); } if (param.entitlementIdAddr != 0) { addURLParam(@params, "entitlementid", param.entitlementId); addURLParam(@params, "consumedcount", Convert.ToString(param.consumedCount)); } HttpURLConnection connection = null; ticketBytesLength = 0; try { connection = (HttpURLConnection)(new URL("https://auth.np.ac.playstation.net/nav/auth")).openConnection(); connection.setRequestProperty("X-I-5-Version", "2.1"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("X-Platform-Version", "PSP 06.60"); connection.setRequestProperty("Content-Length", Convert.ToString(@params.Length)); connection.setRequestProperty("User-Agent", "Lediatio Lunto Ritna"); connection.RequestMethod = "POST"; connection.DoOutput = true; System.IO.Stream os = connection.OutputStream; os.WriteByte(@params.ToString().GetBytes()); os.Close(); connection.connect(); int responseCode = connection.ResponseCode; //if (log.DebugEnabled) { Console.WriteLine(string.Format("Response code: {0:D}", responseCode)); foreach (KeyValuePair <string, IList <string> > entry in connection.HeaderFields.entrySet()) { Console.WriteLine(string.Format("{0}: {1}", entry.Key, entry.Value)); } } if (responseCode == 200) { System.IO.Stream @in = connection.InputStream; while (true) { int Length = @in.Read(ticketBytes, ticketBytesLength, ticketBytes.Length - ticketBytesLength); if (Length < 0) { break; } ticketBytesLength += Length; } @in.Close(); //if (log.DebugEnabled) { Console.WriteLine(string.Format("Received ticket: {0}", Utilities.getMemoryDump(ticketBytes, 0, ticketBytesLength))); } } } catch (MalformedURLException e) { Console.WriteLine(e); } catch (IOException e) { Console.WriteLine(e); } finally { if (connection != null) { connection.disconnect(); } } } } } if (param.ticketCallback != 0) { int ticketLength = ticketBytesLength > 0 ? ticketBytesLength : 248; npAuthCreateTicketCallback = Modules.ThreadManForUserModule.hleKernelCreateCallback("sceNpAuthCreateStartRequest", param.ticketCallback, param.callbackArgument); if (Modules.ThreadManForUserModule.hleKernelRegisterCallback(THREAD_CALLBACK_USER_DEFINED, npAuthCreateTicketCallback.Uid)) { Modules.ThreadManForUserModule.hleKernelNotifyCallback(THREAD_CALLBACK_USER_DEFINED, npAuthCreateTicketCallback.Uid, ticketLength); } } return(0); }
public static DialogResult Show(string text) { JOptionPane.showMessageDialog(null, text); return(DialogResult.OK); }
/// <summary>Loads a text or html file from a file path or URL.</summary> /// <remarks> /// Loads a text or html file from a file path or URL. Treats anything /// beginning with <tt>http:\\</tt>,<tt>.htm</tt>, or <tt>.html</tt> as an /// html file, and strips all tags from the document /// </remarks> public virtual void LoadFile(string filename) { if (filename == null) { return; } File file = new File(filename); string urlOrFile = filename; // if file can't be found locally, try prepending http:// and looking on web if (!file.Exists() && filename.IndexOf("://") == -1) { urlOrFile = "http://" + filename; } else { // else prepend file:// to handle local html file urls if (filename.IndexOf("://") == -1) { urlOrFile = "file://" + filename; } } // TODO: why do any of this instead of just reading the file? THIS SHOULD BE UPDATED FOR 2017! // Also, is this working correctly still? // load the document IDocument <object, Word, Word> doc; try { if (urlOrFile.StartsWith("http://") || urlOrFile.EndsWith(".htm") || urlOrFile.EndsWith(".html")) { // strip tags from html documents IDocument <object, Word, Word> docPre = new BasicDocument <object>().Init(new URL(urlOrFile)); IDocumentProcessor <Word, Word, object, Word> noTags = new StripTagsProcessor <object, Word>(); doc = noTags.ProcessDocument(docPre); } else { doc = new BasicDocument <object>(Edu.Stanford.Nlp.Parser.UI.ParserPanel.GetTokenizerFactory()).Init(new InputStreamReader(new FileInputStream(filename), encoding)); } } catch (Exception e) { JOptionPane.ShowMessageDialog(this, "Could not load file " + filename + "\n" + e, null, JOptionPane.ErrorMessage); Sharpen.Runtime.PrintStackTrace(e); SetStatus("Error loading document"); return; } // load the document into the text pane StringBuilder docStr = new StringBuilder(); foreach (Word aDoc in doc) { if (docStr.Length > 0) { docStr.Append(' '); } docStr.Append(aDoc.ToString()); } textPane.SetText(docStr.ToString()); dataFileLabel.SetText(urlOrFile); HighlightSentence(0); forwardButton.SetEnabled(endIndex != textPane.GetText().Length - 1); // scroll to top of document textPane.SetCaretPosition(0); SetStatus("Done"); }
//public void setResultsTextArea(JTextArea jta){this.jTArea = jta;} /** * When this method is called, it either copies or pastes information into intermediate locations. * * Originally, this method is activated on the Keystrokes we are listening to * in this implementation. Here it listens for Copy and Paste ActionCommands. * Selections comprising non-adjacent cells result in invalid selection and * then copy action cannot be performed. * Paste is done by aligning the upper left corner of the selection with the * 1st element in the current selection of the JTable. */ public void actionPerformed()//ActionEvent e) { if (e.getActionCommand().compareTo("Copy") == 0) { StringBuffer sbf = new StringBuffer(); // Check to ensure we have selected only a contiguous block of // cells //int numcols=jTable1.getSelectedColumnCount(); int numcols = jTable1.getColumnCount(); // sri- jul 31 2012 // int numrows=jTable1.getSelectedRowCount(); int numrows = jTable1.getRowCount(); // sri- jul 31 2012 jTable1.selectAll(); // sri- jul 31 2012 int[] rowsselected = jTable1.getSelectedRows(); int[] colsselected = jTable1.getSelectedColumns(); if (!((numrows - 1 == rowsselected[rowsselected.length - 1] - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] - colsselected[0] && numcols == colsselected.length))) { JOptionPane.showMessageDialog(null, "Invalid Copy Selection", "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); return; } for (int i = 0; i < numrows; i++) { for (int j = 0; j < numcols; j++) { double newValue = 0d; try{ newValue = double.parseDouble((jTable1.getValueAt(rowsselected[i], colsselected[j]).toString())); if (newValue.equals(double.NaN)) { newValue = 0d; } //sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); sbf.append(newValue); if (j < numcols - 1) { sbf.append("\t"); } } catch (Exception exc) { } } sbf.append("\n"); } //stsel = new StringSelection(sbf.toString()); // system = Toolkit.getDefaultToolkit().getSystemClipboard(); //system.setContents(stsel,stsel); this.jTArea.setText(sbf.toString()); } if (e.getActionCommand().compareTo("Paste") == 0) { pasteDataIntoJTable("\t"); } else if (e.getActionCommand().compareTo("PasteCSV") == 0) { pasteDataIntoJTable(","); } }
/// <summary> /// Method main, that provides the dialog box prompts to create the /// 1-Wire XML tag. /// </summary> /// <param name="args"> command line arguments </param> public static void Main(string[] args) { OneWireContainer tag_owd; DSPortAdapter adapter = null; ArrayList owd_vect = new ArrayList(5); bool get_min = false, get_max = false, get_channel = false, get_init = false, get_scale = false; string file_type, label, tag_type, method_type = null, cluster; string min = null, max = null, channel = null, init = null, scale = null; // connect now message JOptionPane.showMessageDialog(null, "Connect the 1-Wire device to Tag onto the Default 1-Wire port", "1-Wire Tag Creator", JOptionPane.INFORMATION_MESSAGE); try { // get the default adapter adapter = OneWireAccessProvider.DefaultAdapter; // get exclusive use of adapter adapter.beginExclusive(true); // find all parts owd_vect = findAllDevices(adapter); // select a device tag_owd = selectDevice(owd_vect, "Select the 1-Wire Device to Tag"); // enter the label for this devcie label = JOptionPane.showInputDialog(null, "Enter a human readable label for this device: ", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE); if (string.ReferenceEquals(label, null)) { throw new InterruptedException("Aborted"); } // enter the cluster for this devcie cluster = JOptionPane.showInputDialog(null, "Enter a cluster where this device will reside: ", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE); if (string.ReferenceEquals(cluster, null)) { throw new InterruptedException("Aborted"); } // select the type of device string[] tag_types = new string[] { "sensor", "actuator", "branch" }; tag_type = (string)JOptionPane.showInputDialog(null, "Select the Tag Type", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE, null, tag_types, tag_types[0]); if (string.ReferenceEquals(tag_type, null)) { throw new InterruptedException("Aborted"); } // check if branch selected if (string.ReferenceEquals(tag_type, "branch")) { get_init = true; get_channel = true; } // sensor else if (string.ReferenceEquals(tag_type, "sensor")) { string[] sensor_types = new string[] { "Contact", "Humidity", "Event", "Thermal" }; method_type = (string)JOptionPane.showInputDialog(null, "Select the Sensor Type", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE, null, sensor_types, sensor_types[0]); if (string.ReferenceEquals(method_type, null)) { throw new InterruptedException("Aborted"); } // contact if (string.ReferenceEquals(method_type, "Contact")) { get_min = true; get_max = true; } // Event else if (string.ReferenceEquals(method_type, "Event")) { get_channel = true; get_max = true; } } // actuator else { string[] actuator_types = new string[] { "Switch", "D2A" }; method_type = (string)JOptionPane.showInputDialog(null, "Select the Actuator Type", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE, null, actuator_types, actuator_types[0]); if (string.ReferenceEquals(method_type, null)) { throw new InterruptedException("Aborted"); } get_channel = true; get_init = true; get_min = true; get_max = true; } // enter the tags required if (get_min) { min = JOptionPane.showInputDialog(null, "Enter the 'min' value: ", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE); } if (string.ReferenceEquals(min, null)) { get_min = false; } if (get_max) { max = JOptionPane.showInputDialog(null, "Enter the 'max' value: ", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE); } if (string.ReferenceEquals(max, null)) { get_max = false; } if (get_channel) { channel = JOptionPane.showInputDialog(null, "Enter the 'channel' value: ", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE); } if (string.ReferenceEquals(channel, null)) { get_channel = false; } if (get_init) { init = JOptionPane.showInputDialog(null, "Enter the 'init' value: ", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE); } if (string.ReferenceEquals(init, null)) { get_init = false; } if (get_scale) { scale = JOptionPane.showInputDialog(null, "Enter the 'scale' value: ", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE); } if (string.ReferenceEquals(scale, null)) { get_scale = false; } // build the XML file ArrayList xml = new ArrayList(5); xml.Add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); xml.Add("<cluster name=\"" + cluster + "\">"); xml.Add(" <" + tag_type + " addr=\"" + tag_owd.AddressAsString + "\" type=\"" + method_type + "\">"); xml.Add(" <label>" + label + "</label>"); if (get_max) { xml.Add(" <max>" + max + "</max>"); } if (get_min) { xml.Add(" <min>" + min + "</min>"); } if (get_channel) { xml.Add(" <channel>" + channel + "</channel>"); } if (get_init) { xml.Add(" <init>" + init + "</init>"); } if (get_scale) { xml.Add(" <scale>" + scale + "</scale>"); } xml.Add(" </" + tag_type + ">"); xml.Add("</cluster>"); // display the XML file JList list = new JList(xml.ToArray()); if (MessageBox.Show(null, list, "Is this correct?", MessageBoxButtons.YesNo) != DialogResult.Yes) { throw new InterruptedException("Aborted"); } // loop until file written bool file_written = false; do { // Check if doing desktop or 1-Wire file string[] file_types = new string[] { "Desktop File", "1-Wire File" }; file_type = (string)JOptionPane.showInputDialog(null, "Select where to put this XML 1-Wire Tag file", "1-Wire tag Creator", JOptionPane.INFORMATION_MESSAGE, null, file_types, file_types[0]); if (string.ReferenceEquals(file_type, null)) { throw new InterruptedException("Aborted"); } // save to a PC file if (string.ReferenceEquals(file_type, "Desktop File")) { JFileChooser chooser = new JFileChooser(); int returnVal = chooser.showSaveDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { try { PrintWriter writer = new PrintWriter(new System.IO.FileStream(chooser.SelectedFile.CanonicalPath, true)); for (int i = 0; i < xml.Count; i++) { writer.println(xml[i]); } writer.flush(); writer.close(); JOptionPane.showMessageDialog(null, "XML File saved to: " + chooser.SelectedFile.CanonicalPath, "1-Wire Tag Creator", JOptionPane.INFORMATION_MESSAGE); file_written = true; } catch (FileNotFoundException e) { Console.WriteLine(e); JOptionPane.showMessageDialog(null, "ERROR saving XML File: " + chooser.SelectedFile.CanonicalPath, "1-Wire Tag Creator", JOptionPane.WARNING_MESSAGE); } } } // 1-Wire file else { // search parts again in case the target device was just connected owd_vect = findAllDevices(adapter); // select the 1-Wire device to save the file to tag_owd = selectDevice(owd_vect, "Select the 1-Wire Device to place XML Tag"); // attempt to write to the filesystem of this device try { PrintWriter writer = new PrintWriter(new OWFileOutputStream(tag_owd, "TAGX.0")); for (int i = 0; i < xml.Count; i++) { writer.println(xml[i]); } writer.flush(); writer.close(); JOptionPane.showMessageDialog(null, "XML File saved to: " + tag_owd.AddressAsString + "\\TAGX.000", "1-Wire Tag Creator", JOptionPane.INFORMATION_MESSAGE); file_written = true; } catch (OWFileNotFoundException e) { Console.WriteLine(e); JOptionPane.showMessageDialog(null, "ERROR saving XML File: " + tag_owd.AddressAsString + "\\TAGX.000", "1-Wire Tag Creator", JOptionPane.WARNING_MESSAGE); } } // check if file not written if (!file_written) { if (MessageBox.Show(null, "Try to save file again?", "1-Wire Tag Creator", MessageBoxButtons.OKCancel) != DialogResult.OK) { throw new InterruptedException("Aborted"); } } } while (!file_written); } catch (Exception e) { Console.WriteLine(e); } finally { if (adapter != null) { // end exclusive use of adapter adapter.endExclusive(); // free the port used by the adapter Console.WriteLine("Releasing adapter port"); try { adapter.freePort(); } catch (OneWireException e) { Console.WriteLine(e); } } } Environment.Exit(0); }
public virtual string GetURL() { string url = JOptionPane.ShowInputDialog(frame, "URL: ", "Load URL", JOptionPane.QuestionMessage); return(url); }
public virtual void ActionPerformed(ActionEvent e) { string com = e.GetActionCommand(); switch (com) { case "Open File": { File file = this._enclosing.GetFile(true); if (file != null) { this._enclosing.OpenFile(file); } break; } case "Load URL": { string url = this._enclosing.GetURL(); if (url != null) { this._enclosing.OpenURL(url); } break; } case "Exit": { NERGUI.Exit(); break; } case "Clear": { this._enclosing.ClearDocument(); break; } case "Cut": { this._enclosing.CutDocument(); break; } case "Copy": { this._enclosing.CopyDocument(); break; } case "Paste": { this._enclosing.PasteDocument(); break; } case "Load CRF from File": { File file = this._enclosing.GetFile(true); if (file != null) { this._enclosing.LoadClassifier(file); } break; } case "Load CRF from Classpath": { string text = JOptionPane.ShowInputDialog(this._enclosing.frame, "Enter a classpath resource for an NER classifier"); if (text != null) { // User didn't click cancel this._enclosing.LoadClassifier(text); } break; } case "Load Default CRF": { this._enclosing.LoadClassifier((File)null); break; } case "Run NER": { this._enclosing.Extract(); break; } case "Save Untagged File": { this._enclosing.SaveUntaggedContents(this._enclosing.loadedFile); break; } case "Save Untagged File As ...": { this._enclosing.SaveUntaggedContents(this._enclosing.GetFile(false)); break; } case "Save Tagged File As ...": { File f = this._enclosing.GetFile(false); if (f != null) { // i.e., they didn't cancel out of the file dialog NERGUI.SaveFile(f, this._enclosing.taggedContents); } break; } default: { NERGUI.log.Info("Unknown Action: " + e); break; } } }
/// <summary> /// Requests the component representing the default value to have /// focus. /// </summary> abstract public void selectInitialValue(JOptionPane @op);
/// <summary> /// Returns true if the user has supplied instances of Component for /// either the options or message. /// </summary> abstract public bool containsCustomComponents(JOptionPane @op);
public virtual void DisplayError(string title, string message) { JOptionPane.ShowMessageDialog(frame, message, title, JOptionPane.ErrorMessage); }
//private final PersonajesTableModel tablaPersonajesModel; //CONSTRUCTORES public uiAltaSocio() { //Crear nueva instancia de GestorSocios this.gestor = new GestorSocios(); //Invocar a los metodos definidos en GestorSocios this.cuotas = this.gestor.obtenerCuotas(); this.rutinas = this.gestor.obtenerRutinas(); this.fichasMedicas = this.gestor.obtenerFichasMedicas(); //this.jFechaIngreso.getDateEditor().setEnabled(true); //Se asigna el modelo de datos a la tabla de personajes //tablaPersonajesModel = new PersonajesTableModel(this.personajes); Boolean validarDatos() { //Comprobar si los datos obligatorios fueron ingresados //en caso de que falte alguno informar al usuario Boolean validacion = true; //Console.WriteLine(jFechaIngreso.getDate()); if (txtNombre.getText().isEmpty() || txtApellido.getText().isEmpty() || txtDomicilio.getText().isEmpty() || txtTelefono.getText().isEmpty() || txtMail.getDate() == null) { validacion = false; JOptionPane.showMessageDialog(null, "Todos los campos son obligatorios"); } return validacion; } void crearSocio() { // Se obtienen los datos ingresados por el usuario asignandolos a variables locales al metodo String nombre = txtNombre.getText(); String apellido = txtApellido.getText(); String domicilio = txtDuracion.getText(); String mail = txtMail.getText(); int telefono = txtTelefono.getText(); //Se crea el objeto Pelicula. Socio nuevoSocio = new Socio(dni, nombre, apellido, domicilio, telefono, mail); /*nuevoSocio.setGenero((Genero)generoCombo.getSelectedItem()); nuevoSocio.setClasificacion((Clasificacion)clasificacionCombo.getSelectedItem()); nuevoSocio.setPaisDeOrigen((PaisDeOrigen)paisOrigenCombo.getSelectedItem()); nuevoSocio.setPersonajes(personajes);*/ //Se invoca al metodo guardarPelicula(nueva) implementado en GestoPelicula gestor.guardarSocio(nuevoSocio); //Se notificamos al usuario del nuevo registro //JOptionPane.showMessageDialog(null, "La Película " + nueva.getNombre() + " ha sido agregada con éxito"); } BTN crearNewSocio { // Se validan datos obligatorios. En caso de superar la comprobacion if (!validarDatos()) { JOptionPane.showMessageDialog(null, "Todos los campos son obligatorios"); } else // se comprueba que el nombre no corresponda a una pelicula existente. if (gestor.buscarSocioPorNombre(txtNombre.getText()) != null) { JOptionPane.showMessageDialog(null, "Ya existe una Película con ese nombre"); } else { // se crea la instancia de una nueva pelicula this.crearSocio(); txtNombre.setText(""); txtApellido.setText(""); txtDomicilio.setText(""); txtTelefono.setText(""); txtMail.setText(""); //jFechaIngreso.setDate(null); } } void txtNombreFocusLost(java.awt.event.FocusEvent evt) {