private boolean add() { // Validation: if (StringUtil.isEmpty(jtf_fileName.getText())) { JOptionPane.showMessageDialog( this, "Name must be present!", "Validation: name empty!", JOptionPane.ERROR_MESSAGE); jtf_fileName.requestFocus(); return false; } // Read values: final String fileName = jtf_fileName.getText(); final ContentType ct = jp_contentType.getContentType(); final File file = new File(jtf_file.getText()); final ReqEntityFilePart part = new ReqEntityFilePartBean(fileName, ct, file); // Trigger all listeners: for (AddMultipartPartListener l : listeners) { l.addPart(part); } // Clear: clear(); // Focus: jb_file.requestFocus(); return true; }
private void selectFile() { File f = rest_ui.getOpenFile(FileChooserType.OPEN_REQUEST_BODY); if (f == null) { // Pressed cancel? return; } if (!f.canRead()) { JOptionPane.showMessageDialog( rest_ui.getFrame(), "File not readable: " + f.getAbsolutePath(), "IO Error", JOptionPane.ERROR_MESSAGE); return; } // Content type charset correction: ContentTypeSelectorOnFile.select(jp_contentType, f, this); // Set name: if (StringUtil.isEmpty(jtf_fileName.getText())) { jtf_fileName.setText(f.getName()); } // Set file: jtf_file.setText(f.getAbsolutePath()); }
@Override public void clear() { jp_contentType.clear(); jtf_fileName.setText(""); jtf_file.setText(""); }