List of usage examples for javax.swing JCheckBox isSelected
public boolean isSelected()
From source file:be.agiv.security.demo.Main.java
private void invokeClaimsAwareService() { GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridBagConstraints = new GridBagConstraints(); JPanel contentPanel = new JPanel(gridBagLayout); final JLabel ipStsLabel = new JLabel("IP-STS:"); gridBagConstraints.gridx = 0;/*from w w w .j a v a 2 s . c o m*/ gridBagConstraints.gridy = 0; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.ipadx = 5; gridBagLayout.setConstraints(ipStsLabel, gridBagConstraints); contentPanel.add(ipStsLabel); final JTextField ipStsTextField = new JTextField( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(ipStsTextField, gridBagConstraints); contentPanel.add(ipStsTextField); JLabel realmLabel = new JLabel("Realm:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(realmLabel, gridBagConstraints); contentPanel.add(realmLabel); JTextField realmTextField = new JTextField(AGIVSecurity.BETA_REALM, 30); gridBagConstraints.gridx++; gridBagLayout.setConstraints(realmTextField, gridBagConstraints); contentPanel.add(realmTextField); final CredentialPanel credentialPanel = new CredentialPanel(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(credentialPanel, gridBagConstraints); contentPanel.add(credentialPanel); final JLabel rStsLabel = new JLabel("R-STS:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = 1; gridBagLayout.setConstraints(rStsLabel, gridBagConstraints); contentPanel.add(rStsLabel); final JTextField rStsTextField = new JTextField( "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(rStsTextField, gridBagConstraints); contentPanel.add(rStsTextField); JLabel serviceRealmLabel = new JLabel("Service realm:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(serviceRealmLabel, gridBagConstraints); contentPanel.add(serviceRealmLabel); JTextField serviceRealmTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_REALM, 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(serviceRealmTextField, gridBagConstraints); contentPanel.add(serviceRealmTextField); JLabel urlLabel = new JLabel("Service URL:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(urlLabel, gridBagConstraints); contentPanel.add(urlLabel); JTextField urlTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_LOCATION, 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(urlTextField, gridBagConstraints); contentPanel.add(urlTextField); final JCheckBox noWsPolicyCheckBox = new JCheckBox("WSDL without WS-Policy"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(noWsPolicyCheckBox, gridBagConstraints); contentPanel.add(noWsPolicyCheckBox); final JCheckBox useWsSecureConversationCheckBox = new JCheckBox("Use WS-SecureConversation"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(useWsSecureConversationCheckBox, gridBagConstraints); contentPanel.add(useWsSecureConversationCheckBox); final JCheckBox usePreviousSecurityCheckBox = new JCheckBox("Use previous AGIV Security"); final JCheckBox cancelPreviousSecureConversationToken = new JCheckBox("Cancel previous conversation token"); usePreviousSecurityCheckBox.setEnabled(null != this.agivSecurity); cancelPreviousSecureConversationToken.setEnabled(false); usePreviousSecurityCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LOG.debug("use previous security: " + usePreviousSecurityCheckBox.isSelected()); boolean newSecurity = !usePreviousSecurityCheckBox.isSelected(); ipStsLabel.setEnabled(newSecurity); ipStsTextField.setEditable(newSecurity); credentialPanel.setEnabled(newSecurity); rStsLabel.setEnabled(newSecurity); rStsTextField.setEnabled(newSecurity); cancelPreviousSecureConversationToken.setEnabled(!newSecurity); } }); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(usePreviousSecurityCheckBox, gridBagConstraints); contentPanel.add(usePreviousSecurityCheckBox); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(cancelPreviousSecureConversationToken, gridBagConstraints); contentPanel.add(cancelPreviousSecureConversationToken); JPanel expiresPanel = new JPanel(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = 2; gridBagLayout.setConstraints(expiresPanel, gridBagConstraints); contentPanel.add(expiresPanel); JLabel expiresLabelLabel = new JLabel("Secure conversation token expires:"); expiresLabelLabel.setEnabled(null != this.agivSecurity); expiresPanel.add(expiresLabelLabel); JLabel expiresLabel = new JLabel(); expiresLabel.setEnabled(null != this.agivSecurity); expiresPanel.add(expiresLabel); if (null != this.agivSecurity) { if (false == this.agivSecurity.getSecureConversationTokens().isEmpty()) { SecurityToken secureConversationToken = this.agivSecurity.getSecureConversationTokens().values() .iterator().next(); expiresLabel.setText(secureConversationToken.getExpires().toString()); } } int dialogResult = JOptionPane.showConfirmDialog(this, contentPanel, "Claims Aware Service", JOptionPane.OK_CANCEL_OPTION); if (dialogResult == JOptionPane.CANCEL_OPTION) { return; } final String location = urlTextField.getText(); final String serviceRealm = serviceRealmTextField.getText(); final String ipStsLocation = ipStsTextField.getText(); final String rStsLocation = rStsTextField.getText(); final String username = credentialPanel.getUsername(); final String password = credentialPanel.getPassword(); final File pkcs12File = credentialPanel.getPKCS12File(); final String realm = realmTextField.getText(); ExecutorService executor = Executors.newFixedThreadPool(1); FutureTask<ArrayOfClaimInfo> futureTask = new FutureTask<ArrayOfClaimInfo>( new Callable<ArrayOfClaimInfo>() { public ArrayOfClaimInfo call() throws Exception { Service service; if (noWsPolicyCheckBox.isSelected()) { service = ClaimsAwareServiceFactory.getInstanceNoWSPolicy(); } else { service = ClaimsAwareServiceFactory.getInstance(); } IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; if (false == usePreviousSecurityCheckBox.isSelected()) { if (null != username) { Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm, username, password); } else { Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm, pkcs12File, password); } Main.this.agivSecurity.addSTSListener(Main.this); if (Main.this.proxyEnable) { agivSecurity.setProxy(Main.this.proxyHost, Main.this.proxyPort, Main.this.proxyType); } } if (cancelPreviousSecureConversationToken.isSelected()) { Main.this.agivSecurity.cancelSecureConversationTokens(); } Main.this.agivSecurity.enable(bindingProvider, location, useWsSecureConversationCheckBox.isSelected(), serviceRealm); ArrayOfClaimInfo result = iservice.getData(0); return result; } }) { @Override protected void done() { try { ArrayOfClaimInfo result = get(); List<ClaimInfo> claims = result.getClaimInfo(); StringBuffer message = new StringBuffer(); for (ClaimInfo claim : claims) { message.append(claim.getName()); message.append(" = "); message.append(claim.getValue()); message.append("\n"); } JOptionPane.showMessageDialog(Main.this, message.toString(), "Claims Aware Service Result", JOptionPane.INFORMATION_MESSAGE); } catch (final Exception e) { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { Main.this.statusBar.setErrorStatus(e.getMessage()); } }); } catch (Exception e1) { } showException(e); } } }; executor.execute(futureTask); }
From source file:homenetapp.HomeNetAppGui.java
private void enableServerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enableServerCheckBoxActionPerformed javax.swing.JCheckBox checkbox = (javax.swing.JCheckBox) evt.getSource(); if (checkbox.isSelected()) { enableUPnPCheckBox.setEnabled(true); serverPortLabel.setEnabled(true); serverPortTextField.setEnabled(true); System.out.println("Selected"); } else {//from w w w .j ava 2 s.c o m enableUPnPCheckBox.setEnabled(false); serverPortLabel.setEnabled(false); serverPortTextField.setEnabled(false); System.out.println("Not Selected"); } }
From source file:HW3.java
private void finalRemoveSubCategory(String catName) { for (HashMap map : mapList) { if (map != null) { Iterator it = map.keySet().iterator(); while (it.hasNext()) { JCheckBox jcheck = (JCheckBox) it.next(); //System.out.println(jcheck); String s = jcheck.getText(); if (map.get(jcheck).equals(catName)) { if (jcheck.isSelected()) { finalAttributeRemove(s); }/*w w w. java 2 s. c o m*/ int index = subCatNames.indexOf(s); if (index != -1) { subCatNames.remove(index); } int id = selectSubCat.indexOf(s); if (id != -1) { selectSubCat.remove(id); } subCategoryPanel.remove(jcheck); } } map = null; } } subCategoryPanel.revalidate(); subCategoryPanel.repaint(); }
From source file:org.nebulaframework.ui.swing.cluster.ClusterMainUI.java
/** * Setup the General Tab Pane//w w w.ja v a 2 s . c o m * * @return JPanel for pane */ private JPanel setupGeneralTab() { JPanel generalTab = new JPanel(); generalTab.setLayout(new BorderLayout()); /* -- Create Main Panels -- */ JPanel centerPanel = new JPanel(); JPanel northPanel = new JPanel(); JPanel southPanel = new JPanel(); generalTab.add(centerPanel, BorderLayout.CENTER); generalTab.add(northPanel, BorderLayout.NORTH); /* -- Create Center Contents -- */ // Statistics Panel JPanel statsPanel = setupStatsPanel(); // Log Panel JPanel logPanel = new JPanel(); logPanel.setLayout(new BorderLayout()); logPanel.setBorder(BorderFactory.createTitledBorder("Log Output")); JTextPane logTextPane = new JTextPane(); logTextPane.setEditable(false); logTextPane.setBackground(Color.BLACK); logTextPane.setForeground(Color.WHITE); logPanel.add(new JScrollPane(logTextPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER); addUIElement("general.log", logTextPane); // Add to component map JPanel logOptionsPanel = new JPanel(); logPanel.add(logOptionsPanel, BorderLayout.SOUTH); logOptionsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); final JCheckBox logScrollCheckbox = new JCheckBox("Auto-Scroll Log"); logScrollCheckbox.setSelected(true); logScrollCheckbox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JTextPaneAppender.setAutoScroll(logScrollCheckbox.isSelected()); } }); logOptionsPanel.add(logScrollCheckbox); // Enable Logging JTextPaneAppender.setTextPane(logTextPane); centerPanel.setLayout(new BorderLayout(10, 10)); centerPanel.add(statsPanel, BorderLayout.NORTH); centerPanel.add(logPanel, BorderLayout.CENTER); /* -- Create Buttons (South) -- */ generalTab.add(southPanel, BorderLayout.SOUTH); final JButton shutdownButton = new JButton("Shutdown"); shutdownButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doShutdownCluster(); } }); southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 10)); southPanel.add(shutdownButton); addUIElement("general.shutdown", shutdownButton); // Add to components map return generalTab; }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void changeMaxFileSize() { final JPanel panel = new JPanel(); boolean keineLimitierung = iliasProperties.getMaxFileSize() == Long.MAX_VALUE; panel.setLayout(new GridLayout(1, 0)); panel.add(new JLabel("Maximale Dateigre in MB")); final JCheckBox cb = new JCheckBox("Keine Limitierung"); cb.setSelected(keineLimitierung);/*from ww w.j a v a2 s . c o m*/ panel.add(cb); final JTextField fieldFileSize = new JTextField( String.valueOf(iliasProperties.getMaxFileSize() / (1024 * 1024))); panel.add(fieldFileSize); fieldFileSize.setVisible(!cb.isSelected()); cb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fieldFileSize.setVisible(!cb.isSelected()); } }); if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Maximale Dateigre ndern", JOptionPane.OK_CANCEL_OPTION)) { if (cb.isSelected()) { iliasProperties.setMaxFileSize(Long.MAX_VALUE); } else { iliasProperties.setMaxFileSize(Long.parseLong(fieldFileSize.getText()) * 1024 * 1024); } saveProperties(iliasProperties); } }
From source file:HW3.java
private void showMainCategory(ResultSet result) throws SQLException { int i = 1;/*from w w w. ja va 2s. c om*/ while (result.next()) { String catName = result.getString(1); JCheckBox check = new JCheckBox(catName, false); mainCategoryPanel.add(check); check.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { HashMap<JCheckBox, String> returnList = new HashMap<JCheckBox, String>(); if (check.isSelected()) { selectMainCat.add(catName); showSubCat(catName, returnList); mapList[mapListCount] = returnList; finalDisplaySubCategory(catName); } else { clearBusinessTable(); selectMainCat.remove(catName); finalRemoveSubCategory(catName); } } }); i = i + 1; } mainCategoryPanel.setLayout(new GridLayout(i, 1)); mainCategoryPanel.repaint(); setFocusable(true); pack(); }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
private void handleFirstStart() { if (!ServiceFunctions.getPropertiesFile().exists()) { JOptionPane.showMessageDialog(mainFrame, "Willkommen bei " + APP_NAME, "Willkommen", JOptionPane.INFORMATION_MESSAGE); JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("<html>Wenn Sie " + APP_NAME + " nutzen mchten, mssen Sie die folgende Punkte akzeptieren." + "<ul>" + "<li>This software is under the GNU GENERAL PUBLIC LICENSE Version 3.<br>" + "View https://github.com/kekru/ILIASDownloader2/blob/master/LICENSE for detailed information." + "</li>" + "<li>Dieses Programm wird Ihr Passwort nicht speichern</li>" + "<li>Dieses Programm wird Ihren Loginnamen und Ihr Passwort nur an den von Ihnen angegebenen Server senden</li>" + "<li>Ihr Passwort wird im Arbeitsspeicher dieses Computers <b>nicht</b> verschlsselt gespeichert.<br>Ein Schadprogramm knnte den Arbeitsspeicher auslesen und so an Ihre Logindaten gelangen.<br>Der Autor von " + APP_NAME + " bernimmt keine Verantwortung fr die Sicherheit Ihrer Logindaten</li>" + "<li>Im nchsten Schritt mssen Sie Ihren Ilias Server eingeben. Bitte achten Sie darauf, dass die Adresse mit 'https://' beginnt.<br>Das bewirkt eine gesicherte Verbindung zwischen " + APP_NAME + " und Ihrem Ilias Server</li>" + "<li>Die Nutzung und die Weitergabe von " + APP_NAME + " ist kostenlos.</li>" + "<li>Beim Programmstart wird auf Updates berprft. Dabei wird lediglich der Programmname an den Updateserver gesendet. Ihre Logindaten oder andere persnliche Daten werden nicht bertragen.<br>Wenn Sie die Updatefunktion ausschalten mchten, starten Sie das Programm mit dem Parameter '" + StartGui.NO_UPDATER + "'</li>" + "</ul>" + "</html>"), BorderLayout.NORTH); JButton licenseButton = new JButton("Open GNU GENERAL PUBLIC LICENSE Version 3"); licenseButton.addActionListener(new ActionListener() { @Override//w ww .j a v a 2 s.co m public void actionPerformed(ActionEvent e) { openWebsiteLicense(); } }); panel.add(licenseButton, BorderLayout.CENTER); JCheckBox checkboxAccept = new JCheckBox( "Ich akzeptiere die hier aufgefhrten Bedingungen/I accept these agreements."); checkboxAccept.setSelected(false); panel.add(checkboxAccept, BorderLayout.SOUTH); if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Bedingungen", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE) && checkboxAccept.isSelected()) { chooseServer(); } else { System.exit(0); } } }
From source file:ffx.ui.ModelingPanel.java
/** * Create a string representing the modeling command to execute. * * @return the modeling command string./*from w w w. j a v a2 s.c om*/ */ private String createCommandInput() { StringBuilder commandLineParams = new StringBuilder(activeCommand + " "); // Now append command line input to a TextArea, one option per line. // This TextArea gets dumped to an input file. commandTextArea.setText(""); int numparams = optionsTabbedPane.getTabCount(); for (int i = 0; i < numparams; i++) { // A few cases require that a newLine not be generated between // options. boolean newLine = true; // The optionString will collect the parameters for this Option, // then append them to the CommandTextArea. StringBuilder optionString = new StringBuilder(); JPanel optionPanel = (JPanel) optionsTabbedPane.getComponentAt(i); int numOptions = optionPanel.getComponentCount(); String title = optionsTabbedPane.getTitleAt(i); if (title.equalsIgnoreCase("Sequence")) { for (int k = 0; k < acidComboBox.getItemCount(); k++) { if (k != 0) { optionString.append("\n"); } String s = (String) acidComboBox.getItemAt(k); s = s.substring(s.indexOf(" "), s.length()).trim(); optionString.append(s); } // Need an extra newline for Nucleic if (activeCommand.equalsIgnoreCase("NUCLEIC")) { optionString.append("\n"); } } else { JPanel valuePanel = (JPanel) optionPanel.getComponent(numOptions - 1); int numValues = valuePanel.getComponentCount(); for (int j = 0; j < numValues; j++) { Component value = valuePanel.getComponent(j); if (value instanceof JCheckBox) { JCheckBox jcbox = (JCheckBox) value; if (jcbox.isSelected()) { optionString.append("-"); optionString.append(jcbox.getName()); optionString.append(" "); optionString.append(jcbox.getText()); } } else if (value instanceof JTextField) { JTextField jtfield = (JTextField) value; optionString.append("-"); optionString.append(jtfield.getName()); optionString.append(" "); optionString.append(jtfield.getText()); } else if (value instanceof JComboBox) { JComboBox jcb = (JComboBox) value; Object object = jcb.getSelectedItem(); if (object instanceof FFXSystem) { FFXSystem system = (FFXSystem) object; File file = system.getFile(); if (file != null) { String absolutePath = file.getAbsolutePath(); if (absolutePath.endsWith("xyz")) { absolutePath = absolutePath + "_1"; } optionString.append(absolutePath); } } } else if (value instanceof JRadioButton) { JRadioButton jrbutton = (JRadioButton) value; if (jrbutton.isSelected()) { if (!jrbutton.getText().equalsIgnoreCase("NONE")) { optionString.append("-"); optionString.append(jrbutton.getName()); optionString.append(" "); optionString.append(jrbutton.getText()); } if (title.equalsIgnoreCase("C-CAP")) { optionString.append("\n"); } } } } // Handle Conditional Options if (optionPanel.getComponentCount() == 3) { valuePanel = (JPanel) optionPanel.getComponent(1); // JLabel conditionalLabel = (JLabel) // valuePanel.getComponent(0); JTextField jtf = (JTextField) valuePanel.getComponent(1); if (jtf.isEnabled()) { String conditionalInput = jtf.getText(); // Post-Process the Input into Atom Pairs String postProcess = jtf.getName(); if (postProcess != null && postProcess.equalsIgnoreCase("ATOMPAIRS")) { String tokens[] = conditionalInput.split(" +"); StringBuilder atomPairs = new StringBuilder(); int atomNumber = 0; for (String token : tokens) { atomPairs.append(token); if (atomNumber++ % 2 == 0) { atomPairs.append(" "); } else { atomPairs.append("\n"); } } conditionalInput = atomPairs.toString(); } // Append a newline to "enter" the option string. // Append "conditional" input. optionString.append("\n").append(conditionalInput); } } } if (optionString.length() > 0) { commandTextArea.append(optionString.toString()); if (newLine) { commandTextArea.append("\n"); } } } String commandInput = commandTextArea.getText(); if (commandInput != null && !commandInput.trim().equalsIgnoreCase("")) { commandLineParams.append(commandInput); } // The final token on the command line is the structure file name, except // for protein and nucleic. if (!activeCommand.equalsIgnoreCase("Protein") && !activeCommand.equalsIgnoreCase("Nucleic")) { File file = activeSystem.getFile(); if (file != null) { String name = file.getName(); commandLineParams.append(name); commandLineParams.append(" "); } else { return null; } } return commandLineParams.toString(); }
From source file:au.com.jwatmuff.eventmanager.gui.main.LoadCompetitionWindow.java
private void loadBackupButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadBackupButtonActionPerformed File databaseStore = new File(Main.getWorkingDirectory(), "comps"); JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileNameExtensionFilter("Event Manager Files", "evm")); JPanel optionsPanel = new JPanel(); optionsPanel.setBorder(/*from www. java 2s .c om*/ new CompoundBorder(new EmptyBorder(0, 10, 0, 10), new TitledBorder("Load backup options"))); JCheckBox preserveIDCheckbox = new JCheckBox("Preserve competition ID"); optionsPanel.add(preserveIDCheckbox); chooser.setAccessory(optionsPanel); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { /* input zip file */ File file = chooser.getSelectedFile(); /* construct output directory */ File dir = new File(databaseStore, file.getName()); int suffix = 0; while (dir.exists()) { suffix++; dir = new File(databaseStore, file.getName() + "_" + suffix); } /* unzip */ try { ZipUtils.unzipFile(dir, file); /* change id */ Properties props = new Properties(); FileReader fr = new FileReader(new File(dir, "info.dat")); props.load(fr); fr.close(); if (!preserveIDCheckbox.isSelected()) { props.setProperty("UUID", UUID.randomUUID().toString()); } props.setProperty("name", props.getProperty("name") + " - " + dateFormat.format(new Date())); FileWriter fw = new FileWriter(new File(dir, "info.dat")); props.store(fw, ""); fw.close(); /* update gui */ checkDatabasesExecutor.schedule(checkDatabasesTask, 0, TimeUnit.MILLISECONDS); } catch (Exception e) { GUIUtils.displayError(null, "Error while opening file: " + e.getMessage()); } } }
From source file:edu.ku.brc.specify.datamodel.busrules.BaseTreeBusRules.java
@SuppressWarnings("unchecked") @Override/*from w w w.j av a 2s .com*/ public void afterFillForm(final Object dataObj) { // This is a little weak and cheesey, but it gets the job done. // Because both the Tree and Definition want/need to share Business Rules. String viewName = formViewObj.getView().getName(); if (StringUtils.contains(viewName, "TreeDef")) { if (formViewObj.getAltView().getMode() != CreationMode.EDIT) { // when we're not in edit mode, we don't need to setup any listeners since the user can't change anything //log.debug("form is not in edit mode: no special listeners will be attached"); return; } if (!StringUtils.contains(viewName, "TreeDefItem")) { return; } final I nodeInForm = (I) formViewObj.getDataObj(); //disable FullName -related fields if TreeDefItem is used by nodes in the tree //NOTE: Can remove the edit restriction. Tree rebuilds now update fullname fields. Need to add tree rebuild after fullname def edits. if (nodeInForm != null && nodeInForm.getTreeDef() != null) { // boolean canNOTEditFullNameFlds = nodeInForm.hasTreeEntries(); // if (canNOTEditFullNameFlds) // { // ValTextField ftCtrl = (ValTextField )formViewObj.getControlByName("textAfter"); // if (ftCtrl != null) // { // ftCtrl.setEnabled(false); // } // ftCtrl = (ValTextField )formViewObj.getControlByName("textBefore"); // if (ftCtrl != null) // { // ftCtrl.setEnabled(false); // } // ftCtrl = (ValTextField )formViewObj.getControlByName("fullNameSeparator"); // if (ftCtrl != null) // { // ftCtrl.setEnabled(false); // } // ValCheckBox ftBox = (ValCheckBox )formViewObj.getControlByName("isInFullName"); // if (ftBox != null) // { // ftBox.setEnabled(false); // } // } if (!viewName.endsWith("TreeDefItem")) { return; } //disabling editing of name and rank for standard levels. List<TreeDefItemStandardEntry> stds = nodeInForm.getTreeDef().getStandardLevels(); TreeDefItemStandardEntry stdLevel = null; for (TreeDefItemStandardEntry std : stds) { //if (std.getTitle().equals(nodeInForm.getName()) && std.getRank() == nodeInForm.getRankId()) if (std.getRank() == nodeInForm.getRankId()) { stdLevel = std; break; } } if (stdLevel != null) { ValTextField nameCtrl = (ValTextField) formViewObj.getControlByName("name"); Component rankCtrl = formViewObj.getControlByName("rankId"); if (nameCtrl != null) { nameCtrl.setEnabled(false); } if (rankCtrl != null) { rankCtrl.setEnabled(false); } if (nodeInForm.getTreeDef().isRequiredLevel(stdLevel.getRank())) { Component enforcedCtrl = formViewObj.getControlByName("isEnforced"); if (enforcedCtrl != null) { enforcedCtrl.setEnabled(false); } } } } return; } final T nodeInForm = (T) formViewObj.getDataObj(); if (formViewObj.getAltView().getMode() != CreationMode.EDIT) { if (nodeInForm != null) { //XXX this MAY be necessary due to a bug with TextFieldFromPickListTable?? // TextFieldFromPickListTable.setValue() does nothing because of a null adapter member. Component comp = formViewObj.getControlByName("definitionItem"); if (comp instanceof JTextField) { ((JTextField) comp).setText(nodeInForm.getDefinitionItem().getName()); } } } else { processedRules = false; GetSetValueIFace parentField = (GetSetValueIFace) formViewObj.getControlByName("parent"); Component comp = formViewObj.getControlByName("definitionItem"); if (comp instanceof ValComboBox) { final ValComboBox rankComboBox = (ValComboBox) comp; if (parentField instanceof ValComboBoxFromQuery) { final ValComboBoxFromQuery parentCBX = (ValComboBoxFromQuery) parentField; if (parentCBX != null && rankComboBox != null && nodeInForm != null) { parentCBX.registerQueryBuilder(new TreeableSearchQueryBuilder(nodeInForm, rankComboBox, TreeableSearchQueryBuilder.PARENT)); } } if (nodeInForm != null && nodeInForm.getDefinitionItem() != null) { // log.debug("node in form already has a set rank: forcing a call to // adjustRankComboBoxModel()"); UIValidator.setIgnoreAllValidation(this, true); adjustRankComboBoxModel(parentField, rankComboBox, nodeInForm); UIValidator.setIgnoreAllValidation(this, false); } // TODO: the form system MUST require the accepted parent widget to be present if // the // isAccepted checkbox is present final JCheckBox acceptedCheckBox = (JCheckBox) formViewObj.getControlByName("isAccepted"); final ValComboBoxFromQuery acceptedParentWidget = (ValComboBoxFromQuery) formViewObj .getControlByName("acceptedParent"); if (canAccessSynonymy(nodeInForm)) { if (acceptedCheckBox != null && acceptedParentWidget != null) { if (acceptedCheckBox.isSelected() && nodeInForm != null && nodeInForm.getDefinition() != null) { // disable if necessary boolean canSynonymize = nodeInForm.getDefinition().getSynonymizedLevel() <= nodeInForm .getRankId() && nodeInForm.getDescendantCount() == 0; acceptedCheckBox.setEnabled(canSynonymize); } acceptedParentWidget .setEnabled(!acceptedCheckBox.isSelected() && acceptedCheckBox.isEnabled()); if (acceptedCheckBox.isSelected()) { acceptedParentWidget.setValue(null, null); } if (nodeInForm != null && acceptedParentWidget != null && rankComboBox != null) { acceptedParentWidget.registerQueryBuilder(new TreeableSearchQueryBuilder(nodeInForm, rankComboBox, TreeableSearchQueryBuilder.ACCEPTED_PARENT)); } } } else { if (acceptedCheckBox != null) { acceptedCheckBox.setEnabled(false); } if (acceptedParentWidget != null) { acceptedParentWidget.setEnabled(false); } } if (parentField instanceof ValComboBoxFromQuery) { parentChanged(formViewObj, (ValComboBoxFromQuery) parentField, rankComboBox, acceptedCheckBox, acceptedParentWidget); } } } }