List of usage examples for javax.swing JTextArea setEditable
@BeanProperty(description = "specifies if the text can be edited") public void setEditable(boolean b)
TextComponent
should be editable. From source file:net.sf.jabref.exporter.SaveDatabaseAction.java
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException { SaveSession session;/*from w ww. j av a2 s. c om*/ frame.block(); try { SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs) .withEncoding(encoding); BibDatabaseWriter databaseWriter = new BibDatabaseWriter(); if (selectedOnly) { session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(), prefs, panel.getSelectedEntries()); } else { session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs); } panel.registerUndoableChanges(session); } catch (UnsupportedCharsetException ex2) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + Localization .lang("Character encoding '%0' is not supported.", encoding.displayName()), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex == SaveException.FILE_LOCKED) { throw ex; } if (ex.specificEntry()) { // Error occured during processing of // be. Highlight it: int row = panel.mainTable.findEntry(ex.getEntry()); int topShow = Math.max(0, row - 3); panel.mainTable.setRowSelectionInterval(row, row); panel.mainTable.scrollTo(topShow); panel.showEntry(ex.getEntry()); } else { LOGGER.error("Problem saving file", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ".\n" + ex.getMessage(), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { frame.unblock(); } boolean commit = true; if (!session.getWriter().couldEncodeAll()) { FormBuilder builder = FormBuilder.create() .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1); builder.add(ta).xy(3, 1); builder.add(Localization.lang("What do you want to do?")).xy(1, 3); String tryDiff = Localization.lang("Try different encoding"); int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, encoding); if (choice == null) { commit = false; } else { Charset newEncoding = Charset.forName((String) choice); return saveDatabase(file, selectedOnly, newEncoding); } } else if (answer == JOptionPane.CANCEL_OPTION) { commit = false; } } try { if (commit) { session.commit(file); panel.setEncoding(encoding); // Make sure to remember which encoding we used. } else { session.cancel(); } } catch (SaveException e) { int ans = JOptionPane.showConfirmDialog(null, Localization.lang("Save failed during backup creation") + ". " + Localization.lang("Save without backup?"), Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.YES_OPTION) { session.setUseBackup(false); session.commit(file); panel.setEncoding(encoding); } else { commit = false; } } return commit; }
From source file:net.sf.jabref.gui.exporter.SaveDatabaseAction.java
private boolean saveDatabase(File file, boolean selectedOnly, Charset encoding) throws SaveException { SaveSession session;//from w ww .j a v a 2s . c o m frame.block(); try { SavePreferences prefs = SavePreferences.loadForSaveFromPreferences(Globals.prefs) .withEncoding(encoding); BibtexDatabaseWriter databaseWriter = new BibtexDatabaseWriter(FileSaveSession::new); if (selectedOnly) { session = databaseWriter.savePartOfDatabase(panel.getBibDatabaseContext(), panel.getSelectedEntries(), prefs); } else { session = databaseWriter.saveDatabase(panel.getBibDatabaseContext(), prefs); } panel.registerUndoableChanges(session); } catch (UnsupportedCharsetException ex2) { JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + Localization .lang("Character encoding '%0' is not supported.", encoding.displayName()), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } catch (SaveException ex) { if (ex == SaveException.FILE_LOCKED) { throw ex; } if (ex.specificEntry()) { // Error occured during processing of // be. Highlight it: int row = panel.getMainTable().findEntry(ex.getEntry()); int topShow = Math.max(0, row - 3); panel.getMainTable().setRowSelectionInterval(row, row); panel.getMainTable().scrollTo(topShow); panel.showEntry(ex.getEntry()); } else { LOGGER.error("Problem saving file", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + ".\n" + ex.getMessage(), Localization.lang("Save database"), JOptionPane.ERROR_MESSAGE); throw new SaveException("rt"); } finally { frame.unblock(); } boolean commit = true; if (!session.getWriter().couldEncodeAll()) { FormBuilder builder = FormBuilder.create() .layout(new FormLayout("left:pref, 4dlu, fill:pref", "pref, 4dlu, pref")); JTextArea ta = new JTextArea(session.getWriter().getProblemCharacters()); ta.setEditable(false); builder.add(Localization.lang("The chosen encoding '%0' could not encode the following characters:", session.getEncoding().displayName())).xy(1, 1); builder.add(ta).xy(3, 1); builder.add(Localization.lang("What do you want to do?")).xy(1, 3); String tryDiff = Localization.lang("Try different encoding"); int answer = JOptionPane.showOptionDialog(frame, builder.getPanel(), Localization.lang("Save database"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, new String[] { Localization.lang("Save"), tryDiff, Localization.lang("Cancel") }, tryDiff); if (answer == JOptionPane.NO_OPTION) { // The user wants to use another encoding. Object choice = JOptionPane.showInputDialog(frame, Localization.lang("Select encoding"), Localization.lang("Save database"), JOptionPane.QUESTION_MESSAGE, null, Encodings.ENCODINGS_DISPLAYNAMES, encoding); if (choice == null) { commit = false; } else { Charset newEncoding = Charset.forName((String) choice); return saveDatabase(file, selectedOnly, newEncoding); } } else if (answer == JOptionPane.CANCEL_OPTION) { commit = false; } } try { if (commit) { session.commit(file.toPath()); panel.getBibDatabaseContext().getMetaData().setEncoding(encoding); // Make sure to remember which encoding we used. } else { session.cancel(); } } catch (SaveException e) { int ans = JOptionPane.showConfirmDialog(null, Localization.lang("Save failed during backup creation") + ". " + Localization.lang("Save without backup?"), Localization.lang("Unable to create backup"), JOptionPane.YES_NO_OPTION); if (ans == JOptionPane.YES_OPTION) { session.setUseBackup(false); session.commit(file.toPath()); panel.getBibDatabaseContext().getMetaData().setEncoding(encoding); } else { commit = false; } } return commit; }
From source file:com.enderville.enderinstaller.ui.Installer.java
private void buildInstallingPane() { getNextButton().setEnabled(false);//w w w .j a v a 2 s. c om getCancelButton().setEnabled(false); getMainPane().removeAll(); getMainPane().setLayout(new MigLayout(new LC().fill())); final JTextArea text = new JTextArea(); text.setEditable(false); getMainPane().add(new JScrollPane(text), new CC().grow().spanY().wrap()); getMainPane().validate(); getMainPane().repaint(); SwingWorker<Object, String> worker = new SwingWorker<Object, String>() { @Override protected Object doInBackground() throws Exception { try { List<String> mods = new ArrayList<String>(); CheckBoxTreeSelectionModel select = getModTree().getCheckBoxTreeSelectionModel(); TreePath[] paths = select.getSelectionPaths(); if (paths != null && paths.length > 0) { for (TreePath path : paths) { DefaultMutableTreeNode node = ((DefaultMutableTreeNode) path.getLastPathComponent()); String mod = (String) node.getUserObject(); if (mod == null) { for (int i = 0; i < node.getChildCount(); i++) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i); mods.add((String) child.getUserObject()); } } else { mods.add(mod); } } } InstallScript.guiInstall(mods, text, getProgressBar()); } catch (Exception e) { LOGGER.error("Error while trying to install mods", e); JOptionPane.showMessageDialog(Installer.this, "Unexpected error while installing mods:\n" + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); setVisible(false); dispose(); } return null; } @Override public void done() { getNextButton().removeActionListener(Installer.this); getNextButton().setText("Done"); getNextButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); } }); getNextButton().setEnabled(true); } }; worker.execute(); }
From source file:net.sf.jabref.gui.openoffice.StyleSelectDialog.java
private void displayStyle(OOBibStyle style) { // Make a dialog box to display the contents: final JDialog dd = new JDialog(diag, style.getName(), true); JTextArea ta = new JTextArea(style.getLocalCopy()); ta.setEditable(false); JScrollPane sp = new JScrollPane(ta); sp.setPreferredSize(new Dimension(700, 500)); dd.getContentPane().add(sp, BorderLayout.CENTER); JButton okButton = new JButton(Localization.lang("OK")); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue();//from w w w .j av a2 s.c om bb.addButton(okButton); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); dd.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); okButton.addActionListener(actionEvent -> dd.dispose()); dd.pack(); dd.setLocationRelativeTo(diag); dd.setVisible(true); }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * Render the message, delegates to typed methods. *///from w ww . j a v a2s. co m @Override public JComponent render(JScrollPane parent, final Message m) { try { if (getPanelMap().containsKey(m)) { return (JComponent) getPanelMap().get(m); } JComponent rval = null; if (m instanceof TextMessage) { rval = handleTextMessage((TextMessage) m); } else if (m instanceof javax.jms.ObjectMessage) { rval = handleObjectMessage((ObjectMessage) m); } else if (m instanceof javax.jms.MapMessage) { rval = handleMapMessage((MapMessage) m); } else if (m instanceof BytesMessage) { rval = handleBytesMessage(parent, (BytesMessage) m); } else if (m instanceof StreamMessage) { rval = handleStreamMessage((StreamMessage) m); } else { JTextArea textPane = new JTextArea(); textPane.setEditable(false); textPane.setText("Message has no Payload"); rval = textPane; } getPanelMap().put(m, rval); return rval; } catch (Throwable ex) { final JTextArea textPane = new JTextArea(); textPane.setEditable(false); final StringWriter string = new StringWriter(); final PrintWriter writer = new PrintWriter(string); ex.printStackTrace(writer); writer.flush(); textPane.setText("Unable to display message:\n" + string.toString()); log.error(ex.getMessage(), ex); return textPane; } }
From source file:net.pms.encoders.AviSynthMEncoder.java
@Override public JComponent config() { FormLayout layout = new FormLayout("left:pref, 0:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 12dlu, p, 3dlu, 0:grow"); PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.EMPTY);/*w w w . j ava 2s . com*/ builder.opaque(false); CellConstraints cc = new CellConstraints(); JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(2, 1, 1)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); multithreading = new JCheckBox(Messages.getString("MEncoderVideo.35"), configuration.getAvisynthMultiThreading()); multithreading.setContentAreaFilled(false); multithreading.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthMultiThreading((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(multithreading), cc.xy(2, 3)); interframe = new JCheckBox(Messages.getString("AviSynthMEncoder.13"), configuration.getAvisynthInterFrame()); interframe.setContentAreaFilled(false); interframe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configuration.setAvisynthInterFrame(interframe.isSelected()); if (configuration.getAvisynthInterFrame()) { JOptionPane.showMessageDialog( SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()), Messages.getString("AviSynthMEncoder.16"), Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE); } } }); builder.add(GuiUtil.getPreferredSizeComponent(interframe), cc.xy(2, 5)); interframegpu = new JCheckBox(Messages.getString("AviSynthMEncoder.15"), configuration.getAvisynthInterFrameGPU()); interframegpu.setContentAreaFilled(false); interframegpu.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthInterFrameGPU((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(interframegpu), cc.xy(2, 7)); convertfps = new JCheckBox(Messages.getString("AviSynthMEncoder.3"), configuration.getAvisynthConvertFps()); convertfps.setContentAreaFilled(false); convertfps.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthConvertFps((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(convertfps), cc.xy(2, 9)); String aviSynthScriptInstructions = Messages.getString("AviSynthMEncoder.4") + Messages.getString("AviSynthMEncoder.5") + Messages.getString("AviSynthMEncoder.6") + Messages.getString("AviSynthMEncoder.7") + Messages.getString("AviSynthMEncoder.8"); JTextArea aviSynthScriptInstructionsContainer = new JTextArea(aviSynthScriptInstructions); aviSynthScriptInstructionsContainer.setEditable(false); aviSynthScriptInstructionsContainer.setBorder(BorderFactory.createEtchedBorder()); aviSynthScriptInstructionsContainer.setBackground(new Color(255, 255, 192)); aviSynthScriptInstructionsContainer.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(130, 135, 144)), BorderFactory.createEmptyBorder(3, 5, 3, 5))); builder.add(aviSynthScriptInstructionsContainer, cc.xy(2, 11)); String clip = configuration.getAvisynthScript(); if (clip == null) { clip = ""; } StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(clip, PMS.AVS_SEPARATOR); int i = 0; while (st.hasMoreTokens()) { if (i > 0) { sb.append("\n"); } sb.append(st.nextToken()); i++; } textArea = new JTextArea(sb.toString()); textArea.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(textArea.getText(), "\n"); int i = 0; while (st.hasMoreTokens()) { if (i > 0) { sb.append(PMS.AVS_SEPARATOR); } sb.append(st.nextToken()); i++; } configuration.setAvisynthScript(sb.toString()); } }); JScrollPane pane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pane.setPreferredSize(new Dimension(500, 350)); builder.add(pane, cc.xy(2, 13)); configuration.addConfigurationListener(new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { if (event.getPropertyName() == null) { return; } if ((!event.isBeforeUpdate()) && event.getPropertyName().equals(PmsConfiguration.KEY_GPU_ACCELERATION)) { interframegpu.setEnabled(configuration.isGPUAcceleration()); } } }); return builder.getPanel(); }
From source file:hermes.renderers.DefaultMessageRenderer.java
/** * List out all the properties in the stream message. * //from w ww. j av a 2s. c o m * @param streamMessage * @return * @throws JMSException */ protected JComponent handleStreamMessage(StreamMessage streamMessage) throws JMSException { JTextArea textPane = new JTextArea(); StringBuffer buffer = new StringBuffer(); textPane.setEditable(false); streamMessage.reset(); try { for (;;) { buffer.append(streamMessage.readObject().toString()).append("\n"); } } catch (MessageEOFException ex) { // NOP } return textPane; }
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
/** * Builds a new JTextArea with the appropriate values set. *//*from ww w . j a v a2s .c o m*/ private JTextArea newTextArea(String msg) { JTextArea text = new JTextArea(); text.setLineWrap(true); text.setWrapStyleWord(true); text.setEditable(false); text.setFont(UIManager.getFont("Table.font")); JLabel label = new JLabel(); text.setForeground(label.getForeground()); text.setBackground(label.getBackground()); text.setText(msg); return text; }
From source file:edu.ku.brc.specify.config.FixDBAfterLogin.java
/** * //from w ww.j a va 2s . c om */ public static void fixUserPermissions(final boolean doSilently) { final String FIXED_USER_PERMS = "FIXED_USER_PERMS"; boolean isAlreadyFixed = AppPreferences.getRemote().getBoolean(FIXED_USER_PERMS, false); if (isAlreadyFixed) { return; } String whereStr = " WHERE p.GroupSubClass = 'edu.ku.brc.af.auth.specify.principal.UserPrincipal' "; String whereStr2 = "AND p.userGroupScopeID IS NULL"; String postSQL = " FROM specifyuser su " + "INNER JOIN specifyuser_spprincipal ss ON su.SpecifyUserID = ss.SpecifyUserID " + "INNER JOIN spprincipal p ON ss.SpPrincipalID = p.SpPrincipalID " + "LEFT JOIN spprincipal_sppermission pp ON p.SpPrincipalID = pp.SpPrincipalID " + "LEFT OUTER JOIN sppermission pm ON pp.SpPermissionID = pm.SpPermissionID " + whereStr; String sql = "SELECT COUNT(*)" + postSQL + whereStr2; log.debug(sql); if (BasicSQLUtils.getCountAsInt(sql) < 1) { sql = "SELECT COUNT(*)" + postSQL; log.debug(sql); if (BasicSQLUtils.getCountAsInt(sql) > 0) { return; } } final String updatePermSQL = "DELETE FROM %s WHERE SpPermissionID = %d"; final String updatePrinSQL = "DELETE FROM %s WHERE SpPrincipalID = %d"; sql = "SELECT p.SpPrincipalID, pp.SpPermissionID" + postSQL; log.debug(sql); HashSet<Integer> prinIds = new HashSet<Integer>(); for (Object[] row : query(sql)) { Integer prinId = (Integer) row[0]; if (prinId != null) { prinIds.add(prinId); } Integer permId = (Integer) row[1]; if (permId != null) { update(String.format(updatePermSQL, "spprincipal_sppermission", permId)); update(String.format(updatePermSQL, "sppermission", permId)); log.debug("Removing PermId: " + permId); } } StringBuilder sb1 = new StringBuilder(); for (Integer prinId : prinIds) { update(String.format(updatePrinSQL, "specifyuser_spprincipal", prinId)); update(String.format(updatePrinSQL, "spprincipal", prinId)); log.debug("Removing PrinId: " + prinId); if (sb1.length() > 0) sb1.append(","); sb1.append(prinId.toString()); } log.debug("(" + sb1.toString() + ")"); // Create all the necessary UperPrincipal records // Start by figuring out what group there are and then create one UserPrincipal record // for each one TreeSet<String> nameSet = new TreeSet<String>(); sql = "SELECT su.Name, su.SpecifyUserID, p.userGroupScopeID, p.SpPrincipalID FROM specifyuser su " + "INNER JOIN specifyuser_spprincipal sp ON su.SpecifyUserID = sp.SpecifyUserID " + "INNER JOIN spprincipal p ON sp.SpPrincipalID = p.SpPrincipalID " + "WHERE p.GroupSubClass = 'edu.ku.brc.af.auth.specify.principal.GroupPrincipal'"; String fields = "TimestampCreated, TimestampModified, Version, GroupSubClass, groupType, Name, Priority, Remarks, userGroupScopeID, CreatedByAgentID, ModifiedByAgentID"; String insertSQL = "INSERT INTO spprincipal (" + fields + ") VALUES(?,?,?,?,?,?,?,?,?,?,?)"; String insertSQL2 = "INSERT INTO specifyuser_spprincipal (SpecifyUserID, SpPrincipalID) VALUES(?,?)"; String searchSql = "SELECT " + fields + " FROM spprincipal WHERE SpPrincipalID = ?"; sb1 = new StringBuilder(); PreparedStatement selStmt = null; PreparedStatement pStmt = null; PreparedStatement pStmt2 = null; try { Connection conn = DBConnection.getInstance().getConnection(); pStmt = conn.prepareStatement(insertSQL, Statement.RETURN_GENERATED_KEYS); pStmt2 = conn.prepareStatement(insertSQL2); selStmt = conn.prepareStatement(searchSql); String adtSQL = "SELECT DISTINCT ca.AgentID FROM specifyuser AS su INNER Join agent AS ca ON su.CreatedByAgentID = ca.AgentID"; Integer createdById = BasicSQLUtils.getCount(conn, adtSQL); if (createdById == null) { createdById = BasicSQLUtils.getCount(conn, "SELECT AgentID FROM agent ORDER BY AgentID ASC LIMIT 0,1"); if (createdById == null) { UIRegistry.showError("The permissions could not be fixed because there were no agents."); AppPreferences.shutdownAllPrefs(); DBConnection.shutdownFinalConnection(true, true); return; } } for (Object[] row : query(sql)) { String usrName = (String) row[0]; Integer userId = (Integer) row[1]; Integer collId = (Integer) row[2]; Integer prinId = (Integer) row[3]; nameSet.add(usrName); log.debug("usrName: " + usrName + " prinId: " + prinId); if (sb1.length() > 0) sb1.append(","); sb1.append(prinId.toString()); selStmt.setInt(1, prinId); ResultSet rs = selStmt.executeQuery(); if (rs.next()) { log.debug(String.format("%s - adding UserPrincipal for Collection %d / %d", usrName, rs.getInt(9), collId)); Integer createdByAgentID = (Integer) rs.getObject(10); Integer modifiedByAgentID = (Integer) rs.getObject(11); pStmt.setTimestamp(1, rs.getTimestamp(1)); pStmt.setTimestamp(2, rs.getTimestamp(2)); pStmt.setInt(3, 1); // Version pStmt.setString(4, "edu.ku.brc.af.auth.specify.principal.UserPrincipal"); // GroupSubClass pStmt.setString(5, null); // groupType pStmt.setString(6, rs.getString(6)); // Name pStmt.setInt(7, 80); // Priority pStmt.setString(8, rs.getString(8)); // Remarks pStmt.setInt(9, rs.getInt(9)); // userGroupScopeID pStmt.setInt(10, createdByAgentID != null ? createdByAgentID : createdById); pStmt.setInt(11, modifiedByAgentID != null ? modifiedByAgentID : createdById); // Create UserPrincipal pStmt.executeUpdate(); int newPrinId = BasicSQLUtils.getInsertedId(pStmt); // Join the new Principal to the SpecifyUser record pStmt2.setInt(1, userId); pStmt2.setInt(2, newPrinId); pStmt2.executeUpdate(); } else { // error } rs.close(); } log.debug("(" + sb1.toString() + ")"); AppPreferences.getRemote().putBoolean(FIXED_USER_PERMS, true); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (pStmt != null) pStmt.close(); if (pStmt2 != null) pStmt2.close(); if (selStmt != null) selStmt.close(); } catch (Exception ex) { } } final StringBuilder sb = new StringBuilder(); for (String nm : nameSet) { if (sb.length() > 0) sb.append('\n'); sb.append(nm); } if (!doSilently) { JTextArea ta = UIHelper.createTextArea(15, 30); ta.setText(sb.toString()); ta.setEditable(false); JEditorPane htmlPane = new JEditorPane("text/html", //$NON-NLS-1$ UIRegistry.getResourceString("FDBAL_PERMFIXEDDESC")); htmlPane.setEditable(false); htmlPane.setOpaque(false); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p:g,8px,f:p:g")); pb.add(htmlPane, cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(ta), cc.xy(1, 3)); pb.setDefaultDialogBorder(); CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getMostRecentWindow(), UIRegistry.getResourceString("FDBAL_PERMFIXED"), true, CustomDialog.OK_BTN, pb.getPanel()); dlg.setOkLabel(UIRegistry.getResourceString("CLOSE")); UIHelper.centerAndShow(dlg); } }
From source file:coreferenceresolver.gui.MarkupGUI.java
private JScrollPane newReviewPanel(Review review, int reviewId) throws BadLocationException { //Model/*from w w w . j a v a 2s . c om*/ ReviewElement reviewElement = new ReviewElement(); ScrollablePanel reviewPanel = new ScrollablePanel(); reviewPanel.setLayout(new BoxLayout(reviewPanel, BoxLayout.PAGE_AXIS)); JTextField title = new JTextField("NEW REVIEW " + reviewId); title.setBackground(Color.pink); reviewPanel.add(title); JTextArea reviewContentTxtArea = new JTextArea(); reviewContentTxtArea.setLineWrap(true); reviewContentTxtArea.setWrapStyleWord(true); reviewContentTxtArea.setEditable(false); reviewContentTxtArea.setText(review.getRawContent()); int chainId = 0; for (CorefChain cc : review.getCorefChains()) { for (int npId : cc.getChain()) { NounPhrase np = review.getNounPhrases().get(npId); Object highlighTag = reviewContentTxtArea.getHighlighter().addHighlight(np.getOffsetBegin(), np.getOffsetEnd() + 1, highlightPainters.get(chainId)); this.markupReviews.get(reviewId).getNounPhrases().get(npId).highlighterTag = highlighTag; } ++chainId; } reviewPanel.add(reviewContentTxtArea); ScrollablePanel markupsPanel = new ScrollablePanel(); markupsPanel.setLayout(new BoxLayout(markupsPanel, BoxLayout.PAGE_AXIS)); for (int i = 0; i < review.getNounPhrases().size(); ++i) { JScrollPane newMarkupPanel = newMarkupPanel(review.getNounPhrases().get(i), reviewElement); markupsPanel.add(newMarkupPanel); } JScrollPane scrollMarkupsPanel = new JScrollPane(markupsPanel); //Add Dimension for scrolling Dimension curScreenDimen = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); scrollMarkupsPanel.setPreferredSize(new Dimension((int) curScreenDimen.getWidth() - 50, 400)); reviewPanel.add(scrollMarkupsPanel); //MODEL reviewElement.reviewTextArea = reviewContentTxtArea; reviewElements.add(reviewElement); reviewPanel.add(new JSeparator(SwingConstants.HORIZONTAL)); reviewPanel.add(Box.createVerticalStrut(20)); JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel); return scrollReviewPanel; }