List of usage examples for javax.swing JTextArea setWrapStyleWord
@BeanProperty(description = "should wrapping occur at word boundaries") public void setWrapStyleWord(boolean word)
From source file:base.BasePlayer.AddGenome.java
public void actionPerformed(ActionEvent event) { if (event.getSource() == download) { if (!downloading) { downloading = true;/*from w w w .ja v a 2s . co m*/ downloadGenome(genometable.getValueAt(genometable.getSelectedRow(), 0).toString()); downloading = false; } } else if (event.getSource() == getLinks) { URL[] urls = AddGenome.genomeHash .get(genometable.getValueAt(genometable.getSelectedRow(), 0).toString()); JPopupMenu menu = new JPopupMenu(); JTextArea area = new JTextArea(); JScrollPane menuscroll = new JScrollPane(); area.setFont(Main.menuFont); menu.add(menuscroll); menu.setPreferredSize(new Dimension( menu.getFontMetrics(Main.menuFont).stringWidth(urls[0].toString()) + Main.defaultFontSize * 10, (int) menu.getFontMetrics(Main.menuFont).getHeight() * 4)); //area.setMaximumSize(new Dimension(300, 600)); area.setLineWrap(true); area.setWrapStyleWord(true); for (int i = 0; i < urls.length; i++) { area.append(urls[i].toString() + "\n"); } area.setCaretPosition(0); area.revalidate(); menuscroll.getViewport().add(area); menu.pack(); menu.show(this, 0, 0); } else if (event.getSource() == checkEnsembl) { if (ensemblfetch) { menu.show(AddGenome.treescroll, 0, 0); } else { EnsemblFetch fetcher = new EnsemblFetch(); fetcher.execute(); } } else if (event.getSource() == checkUpdates) { URL testfile = null; try { // kattoo onko paivityksia annotaatioon String ref = selectedNode.toString(); if (AddGenome.genomeHash.get(ref) != null) { ArrayList<String> testfiles = new ArrayList<String>(); if (Main.drawCanvas != null) { for (int i = 0; i < Main.genomehash.get(ref).size(); i++) { testfiles.add(Main.genomehash.get(ref).get(i).getName().replace(".bed.gz", "")); } } testfile = AddGenome.genomeHash.get(ref)[1]; String result = Main.checkFile(testfile, testfiles); if (result.length() == 0) { Main.showError("You have newest annotation file.", "Note"); } else { int n = JOptionPane.showConfirmDialog(Main.drawCanvas, "New annotation file found: " + result + "\nDownload it now?", "Note", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { URL fileurl = new URL(testfile.getProtocol() + "://" + testfile.getHost() + testfile.getPath().substring(0, testfile.getPath().lastIndexOf("/") + 1) + result); OutputRunner runner = new OutputRunner(fileurl, ref); runner.downloadAnnotation = true; runner.execute(); } } } else { Main.showError("This genome is not from Ensembl list, could not check for updates.", "Note", AddGenome.genometable); } } catch (Exception e) { Main.showError("Cannot connect to " + testfile.getHost() + ".\nTry again later.", "Error"); e.printStackTrace(); } } else if (event.getSource() == remove) { if (!selectedNode.isLeaf()) { String removeref = selectedNode.toString(); // Boolean same = false; try { if (Main.drawCanvas != null) { if (removeref.equals(Main.refDropdown.getSelectedItem().toString())) { Main.referenceFile.close(); // same = true; if (ChromDraw.exonReader != null) { ChromDraw.exonReader.close(); } } } if (Main.genomehash.containsKey(removeref)) { for (int i = Main.genomehash.get(removeref).size() - 1; i >= 0; i--) { Main.genomehash.get(removeref).remove(i); } Main.genomehash.remove(removeref); } if (Main.drawCanvas != null) { Main.refModel.removeElement(removeref); Main.refDropdown.removeItem(removeref); Main.refDropdown.revalidate(); } for (int i = 0; i < Main.genome.getItemCount(); i++) { if (Main.genome.getItem(i).getName() != null) { if (Main.genome.getItem(i).getName().equals(removeref)) { Main.genome.remove(Main.genome.getItem(i)); break; } } } FileUtils.deleteDirectory(new File(Main.genomeDir.getCanonicalPath() + "/" + removeref)); checkGenomes(); Main.setAnnotationDrop(""); if (Main.genomehash.size() == 0) { Main.refDropdown.setSelectedIndex(0); Main.setChromDrop("-1"); } } catch (Exception e) { e.printStackTrace(); try { Main.showError("Could not delete genome folder.\nYou can do it manually by deleting folder " + Main.genomeDir.getCanonicalPath() + "/" + removeref, "Note"); } catch (IOException e1) { e1.printStackTrace(); } } } else { try { if (Main.drawCanvas != null) { if (ChromDraw.exonReader != null) { ChromDraw.exonReader.close(); } } Main.removeAnnotationFile(selectedNode.getParent().toString(), selectedNode.toString()); FileUtils.deleteDirectory(new File(Main.genomeDir.getCanonicalPath() + "/" + selectedNode.getParent().toString() + "/annotation/" + selectedNode.toString())); // root.remove(selectedNode.getParent().getIndex(selectedNode)); // root.remove // checkGenomes(); } catch (Exception e) { e.printStackTrace(); try { Main.showError("Could not delete genome folder.\nYou can do it manually by deleting folder " + Main.genomeDir.getCanonicalPath() + "/" + selectedNode.getParent().toString() + "/annotation/" + selectedNode.toString(), "Note"); } catch (IOException e1) { e1.printStackTrace(); } } treemodel.removeNodeFromParent(selectedNode); } } else if (event.getSource() == add) { if (genomeFile == null) { if (new File(genomeFileText.getText()).exists()) { genomeFile = new File(genomeFileText.getText()); } else { genomeFileText.setText("Select reference genome fasta-file."); genomeFileText.setForeground(Color.red); return; } } /*if(genomeName.getText().contains("Give name") || genomeName.getText().length() == 0) { genomeName.setText("Give name of the genome"); genomeName.setForeground(Color.red); genomeName.revalidate(); } else if(!annotation && new File(Main.userDir +"/genomes/"+genomeName.getText().trim().replace("\\s+", "_")).exists()) { genomeName.setText("This genome exists already."); genomeName.setForeground(Color.red); genomeName.revalidate(); } else */ if ((genomeFileText.getText().length() == 0 || genomeFileText.getText().startsWith("Select reference"))) { genomeFileText.setText("Select reference genome fasta-file."); genomeFileText.setForeground(Color.red); genomeFileText.revalidate(); } else { OutputRunner runner = new OutputRunner( genomeFile.getName().replace(".fasta", "").replace(".gz", ""), genomeFile, annotationFile); runner.execute(); } } else if (event.getSource() == openRef) { try { JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterFasta fastaFilter = new MyFilterFasta(); chooser.addChoosableFileFilter(fastaFilter); chooser.setDialogTitle("Select reference fasta-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { genomeFile = chooser.getSelectedFile(); Main.downloadDir = genomeFile.getParent(); Main.writeToConfig("DownloadDir=" + genomeFile.getParent()); genomeFileText.setText(genomeFile.getName()); genomeFileText.revalidate(); frame.pack(); } } catch (Exception ex) { ex.printStackTrace(); } } else if (event.getSource() == openAnno) { try { JFileChooser chooser = new JFileChooser(Main.downloadDir); chooser.setMultiSelectionEnabled(false); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); MyFilterGFF gffFilter = new MyFilterGFF(); chooser.addChoosableFileFilter(gffFilter); chooser.setDialogTitle("Select annotation gff3-file"); if (Main.screenSize != null) { chooser.setPreferredSize(new Dimension((int) Main.screenSize.getWidth() / 3, (int) Main.screenSize.getHeight() / 3)); } int returnVal = chooser.showOpenDialog((Component) this.getParent()); if (returnVal == JFileChooser.APPROVE_OPTION) { if (genomeFile == null) { genomeFile = Main.fastahash.get(Main.hoverGenome); } annotationFile = chooser.getSelectedFile(); Main.downloadDir = annotationFile.getParent(); Main.writeToConfig("DownloadDir=" + annotationFile.getParent()); OutputRunner runner = new OutputRunner( genomeFile.getName().replace(".fasta", "").replace(".gz", ""), genomeFile, annotationFile); runner.execute(); } } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:it.imtech.metadata.MetaUtility.java
/** * Metodo adibito alla creazione dinamica ricorsiva dell'interfaccia dei * metadati/* w w w. ja va2s . c om*/ * * @param submetadatas Map contente i metadati e i sottolivelli di metadati * @param vocabularies Map contenente i dati contenuti nel file xml * vocabulary.xml * @param parent Jpanel nel quale devono venir inseriti i metadati * @param level Livello corrente */ public void create_metadata_view(Map<Object, Metadata> submetadatas, JPanel parent, int level, final String panelname) throws Exception { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); int lenght = submetadatas.size(); int labelwidth = 220; int i = 0; JButton addcontribute = null; for (Map.Entry<Object, Metadata> kv : submetadatas.entrySet()) { ArrayList<Component> tabobjects = new ArrayList<Component>(); if (kv.getValue().MID == 17 || kv.getValue().MID == 23 || kv.getValue().MID == 18 || kv.getValue().MID == 137) { continue; } //Crea un jpanel nuovo e fa appen su parent JPanel innerPanel = new JPanel(new MigLayout("fillx, insets 1 1 1 1")); innerPanel.setName("pannello" + level + i); i++; String datatype = kv.getValue().datatype.toString(); if (kv.getValue().MID == 45) { JPanel choice = new JPanel(new MigLayout()); JComboBox combo = addClassificationChoice(choice, kv.getValue().sequence, panelname); JLabel labelc = new JLabel(); labelc.setText(Utility.getBundleString("selectclassif", bundle)); labelc.setPreferredSize(new Dimension(100, 20)); choice.add(labelc); findLastClassification(panelname); if (last_classification != 0 && classificationRemoveButton == null) { logger.info("Removing last clasification"); classificationRemoveButton = new JButton("-"); classificationRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); removeClassificationToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); findLastClassification(panelname); //update last_classification BookImporter.getInstance().setCursor(null); } }); if (Integer.parseInt(kv.getValue().sequence) == last_classification) { choice.add(classificationRemoveButton, "wrap, width :50:"); } } if (classificationAddButton == null) { logger.info("Adding a new classification"); choice.add(combo, "width 100:600:600"); classificationAddButton = new JButton("+"); classificationAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addClassificationToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); choice.add(classificationAddButton, "width :50:"); } else { //choice.add(combo, "wrap,width 100:700:700"); choice.add(combo, "width 100:700:700"); if (Integer.parseInt(kv.getValue().sequence) == last_classification) { choice.add(classificationRemoveButton, "wrap, width :50"); } } parent.add(choice, "wrap,width 100:700:700"); classificationMID = kv.getValue().MID; innerPanel.setName(panelname + "---ImPannelloClassif---" + kv.getValue().sequence); try { addClassification(innerPanel, classificationMID, kv.getValue().sequence, panelname); } catch (Exception ex) { logger.error("Errore nell'aggiunta delle classificazioni"); } parent.add(innerPanel, "wrap, growx"); BookImporter.policy.addIndexedComponent(combo); continue; } if (datatype.equals("Node")) { JLabel label = new JLabel(); label.setText(kv.getValue().description); label.setPreferredSize(new Dimension(100, 20)); int size = 16 - (level * 2); Font myFont = new Font("MS Sans Serif", Font.PLAIN, size); label.setFont(myFont); if (Integer.toString(kv.getValue().MID).equals("11")) { JPanel temppanel = new JPanel(new MigLayout()); //update last_contribute findLastContribute(panelname); if (last_contribute != 0 && removeContribute == null) { logger.info("Removing last contribute"); removeContribute = new JButton("-"); removeContribute.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance() .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); removeContributorToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); if (!kv.getValue().sequence.equals("")) { if (Integer.parseInt(kv.getValue().sequence) == last_contribute) { innerPanel.add(removeContribute, "width :50:"); } } } if (addcontribute == null) { logger.info("Adding a new contribute"); addcontribute = new JButton("+"); addcontribute.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { BookImporter.getInstance() .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); addContributorToMetadata(panelname); BookImporter.getInstance().refreshMetadataTab(false, panelname); BookImporter.getInstance().setCursor(null); } }); temppanel.add(label, " width :200:"); temppanel.add(addcontribute, "width :50:"); innerPanel.add(temppanel, "wrap, growx"); } else { temppanel.add(label, " width :200:"); findLastContribute(panelname); if (!kv.getValue().sequence.equals("")) { if (Integer.parseInt(kv.getValue().sequence) == last_contribute) { temppanel.add(removeContribute, "width :50:"); } } innerPanel.add(temppanel, "wrap, growx"); } } else if (Integer.toString(kv.getValue().MID).equals("115")) { logger.info("Devo gestire una provenience!"); } } else { String title = ""; if (kv.getValue().mandatory.equals("Y") || kv.getValue().MID == 14 || kv.getValue().MID == 15) { title = kv.getValue().description + " *"; } else { title = kv.getValue().description; } innerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title, TitledBorder.LEFT, TitledBorder.TOP)); if (datatype.equals("Vocabulary")) { TreeMap<String, String> entryCombo = new TreeMap<String, String>(); int index = 0; String selected = null; if (!Integer.toString(kv.getValue().MID).equals("8")) entryCombo.put(Utility.getBundleString("comboselect", bundle), Utility.getBundleString("comboselect", bundle)); for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) { String tempmid = Integer.toString(kv.getValue().MID); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { String[] testmid = tempmid.split("---"); tempmid = testmid[0]; } if (vc.getKey().equals(tempmid)) { TreeMap<String, VocEntry> iEntry = vc.getValue(); for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) { entryCombo.put(ivc.getValue().description, ivc.getValue().ID); if (kv.getValue().value != null) { if (kv.getValue().value.equals(ivc.getValue().ID)) { selected = ivc.getValue().ID; } } index++; } } } final ComboMapImpl model = new ComboMapImpl(); model.setVocabularyCombo(true); model.putAll(entryCombo); final JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence); } else { voc.setName("MID_" + Integer.toString(kv.getValue().MID)); } if (Integer.toString(kv.getValue().MID).equals("8") && selected == null) selected = "44"; selected = (selected == null) ? Utility.getBundleString("comboselect", bundle) : selected; for (int k = 0; k < voc.getItemCount(); k++) { Map.Entry<String, String> el = (Map.Entry<String, String>) voc.getItemAt(k); if (el.getValue().equals(selected)) voc.setSelectedIndex(k); } voc.setPreferredSize(new Dimension(150, 30)); innerPanel.add(voc, "wrap, width :400:"); tabobjects.add(voc); } else if (datatype.equals("CharacterString") || datatype.equals("GPS")) { final JTextArea textField = new javax.swing.JTextArea(); if (Integer.toString(kv.getValue().MID_parent).equals("11") || Integer.toString(kv.getValue().MID_parent).equals("13")) { textField.setName( "MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence); } else { textField.setName("MID_" + Integer.toString(kv.getValue().MID)); } textField.setPreferredSize(new Dimension(230, 0)); textField.setText(kv.getValue().value); textField.setLineWrap(true); textField.setWrapStyleWord(true); innerPanel.add(textField, "wrap, width :300:"); textField.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { if (e.getModifiers() > 0) { textField.transferFocusBackward(); } else { textField.transferFocus(); } e.consume(); } } }); tabobjects.add(textField); } else if (datatype.equals("LangString")) { JScrollPane inner_scroll = new javax.swing.JScrollPane(); inner_scroll.setHorizontalScrollBarPolicy( javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); inner_scroll.setVerticalScrollBarPolicy( javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); inner_scroll.setPreferredSize(new Dimension(240, 80)); inner_scroll.setName("langStringScroll"); final JTextArea jTextArea1 = new javax.swing.JTextArea(); jTextArea1.setName("MID_" + Integer.toString(kv.getValue().MID)); jTextArea1.setText(kv.getValue().value); jTextArea1.setSize(new Dimension(350, 70)); jTextArea1.setLineWrap(true); jTextArea1.setWrapStyleWord(true); inner_scroll.setViewportView(jTextArea1); innerPanel.add(inner_scroll, "width :300:"); //Add combo language box JComboBox voc = getComboLangBox(kv.getValue().language); voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "_lang"); voc.setPreferredSize(new Dimension(200, 20)); innerPanel.add(voc, "wrap, width :300:"); jTextArea1.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { if (e.getModifiers() > 0) { jTextArea1.transferFocusBackward(); } else { jTextArea1.transferFocus(); } e.consume(); } } }); tabobjects.add(jTextArea1); tabobjects.add(voc); } else if (datatype.equals("Language")) { final JComboBox voc = getComboLangBox(kv.getValue().value); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :500:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("Boolean")) { int selected = 0; TreeMap bin = new TreeMap<String, String>(); bin.put("yes", Utility.getBundleString("voc1", bundle)); bin.put("no", Utility.getBundleString("voc2", bundle)); if (kv.getValue().value == null) { switch (kv.getValue().MID) { case 35: selected = 0; break; case 36: selected = 1; break; } } else if (kv.getValue().value.equals("yes")) { selected = 1; } else { selected = 0; } final ComboMapImpl model = new ComboMapImpl(); model.putAll(bin); final JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setSelectedIndex(selected); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :300:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("License")) { String selectedIndex = null; int vindex = 0; int defaultIndex = 0; TreeMap<String, String> entryCombo = new TreeMap<String, String>(); for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) { if (vc.getKey().equals(Integer.toString(kv.getValue().MID))) { TreeMap<String, VocEntry> iEntry = vc.getValue(); for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) { entryCombo.put(ivc.getValue().description, ivc.getValue().ID); if (ivc.getValue().ID.equals("1")) defaultIndex = vindex; if (kv.getValue().value != null) { if (ivc.getValue().ID.equals(kv.getValue().value)) { selectedIndex = Integer.toString(vindex); } } vindex++; } } } if (selectedIndex == null) selectedIndex = Integer.toString(defaultIndex); ComboMapImpl model = new ComboMapImpl(); model.putAll(entryCombo); model.setVocabularyCombo(true); JComboBox voc = new javax.swing.JComboBox(model); model.specialRenderCombo(voc); voc.setName("MID_" + Integer.toString(kv.getValue().MID)); voc.setSelectedIndex(Integer.parseInt(selectedIndex)); voc.setPreferredSize(new Dimension(150, 20)); voc.setBounds(5, 5, 150, 20); innerPanel.add(voc, "wrap, width :500:"); //BookImporter.policy.addIndexedComponent(voc); tabobjects.add(voc); } else if (datatype.equals("DateTime")) { //final JXDatePicker datePicker = new JXDatePicker(); JDateChooser datePicker = new JDateChooser(); datePicker.setName("MID_" + Integer.toString(kv.getValue().MID)); JPanel test = new JPanel(new MigLayout()); JLabel lbefore = new JLabel(Utility.getBundleString("beforechristlabel", bundle)); JCheckBox beforechrist = new JCheckBox(); beforechrist.setName("MID_" + Integer.toString(kv.getValue().MID) + "_check"); if (kv.getValue().value != null) { try { if (kv.getValue().value.charAt(0) == '-') { beforechrist.setSelected(true); } Date date1 = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); if (kv.getValue().value.charAt(0) == '-') { date1 = sdf.parse(adjustDate(kv.getValue().value)); } else { date1 = sdf.parse(kv.getValue().value); } datePicker.setDate(date1); } catch (Exception e) { //Console.WriteLine("ERROR import date:" + ex.Message); } } test.add(datePicker, "width :200:"); test.add(lbefore, "gapleft 30"); test.add(beforechrist, "wrap"); innerPanel.add(test, "wrap"); } } //Recursive call create_metadata_view(kv.getValue().submetadatas, innerPanel, level + 1, panelname); if (kv.getValue().editable.equals("Y") || (datatype.equals("Node") && kv.getValue().hidden.equals("0"))) { parent.add(innerPanel, "wrap, growx"); for (Component tabobject : tabobjects) { BookImporter.policy.addIndexedComponent(tabobject); } } } }
From source file:edu.ku.brc.af.ui.forms.ViewFactory.java
protected boolean createItem(final DBTableInfo parentTableInfo, final DBTableChildIFace childInfo, final MultiView parent, final ViewDefIFace viewDef, final FormValidator validator, final ViewBuilderIFace viewBldObj, final AltViewIFace.CreationMode mode, final HashMap<String, JLabel> labelsForHash, final Object currDataObj, final FormCellIFace cell, final boolean isEditOnCreateOnly, final int rowInx, final BuildInfoStruct bi) { bi.compToAdd = null;//from w w w .j av a2 s . co m bi.compToReg = null; bi.doAddToValidator = true; bi.doRegControl = true; DBRelationshipInfo relInfo = childInfo instanceof DBRelationshipInfo ? (DBRelationshipInfo) childInfo : null; if (isEditOnCreateOnly) { EditViewCompSwitcherPanel evcsp = new EditViewCompSwitcherPanel(cell); bi.compToAdd = evcsp; bi.compToReg = evcsp; if (validator != null) { //DataChangeNotifier dcn = validator.createDataChangeNotifer(cell.getIdent(), evcsp, null); DataChangeNotifier dcn = validator.hookupComponent(evcsp, cell.getIdent(), UIValidator.Type.Changed, null, false); evcsp.setDataChangeNotifier(dcn); } } else if (cell.getType() == FormCellIFace.CellType.label) { FormCellLabel cellLabel = (FormCellLabel) cell; String lblStr = cellLabel.getLabel(); if (cellLabel.isRecordObj()) { JComponent riComp = viewBldObj.createRecordIndentifier(lblStr, cellLabel.getIcon()); bi.compToAdd = riComp; } else { String lStr = " "; int align = SwingConstants.RIGHT; boolean useColon = StringUtils.isNotEmpty(cellLabel.getLabelFor()); if (lblStr.equals("##")) { //lStr = " "; bi.isDerivedLabel = true; cellLabel.setDerived(true); } else { String alignProp = cellLabel.getProperty("align"); if (StringUtils.isNotEmpty(alignProp)) { if (alignProp.equals("left")) { align = SwingConstants.LEFT; } else if (alignProp.equals("center")) { align = SwingConstants.CENTER; } else { align = SwingConstants.RIGHT; } } else if (useColon) { align = SwingConstants.RIGHT; } else { align = SwingConstants.LEFT; } if (isNotEmpty(lblStr)) { if (useColon) { lStr = lblStr + ":"; } else { lStr = lblStr; } } else { lStr = " "; } } if (lStr.indexOf(LF) > -1) { lStr = "<html>" + StringUtils.replace(lStr, LF, "<br>") + "</html>"; } JLabel lbl = createLabel(lStr, align); String colorStr = cellLabel.getProperty("fg"); if (StringUtils.isNotEmpty(colorStr)) { lbl.setForeground(UIHelper.parseRGB(colorStr)); } labelsForHash.put(cellLabel.getLabelFor(), lbl); bi.compToAdd = lbl; viewBldObj.addLabel(cellLabel, lbl); } bi.doAddToValidator = false; bi.doRegControl = false; } else if (cell.getType() == FormCellIFace.CellType.field) { FormCellField cellField = (FormCellField) cell; bi.isRequired = bi.isRequired || cellField.isRequired() || (childInfo != null && childInfo.isRequired()); DBFieldInfo fieldInfo = childInfo instanceof DBFieldInfo ? (DBFieldInfo) childInfo : null; if (fieldInfo != null && fieldInfo.isHidden()) { FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_FIELD_HIDDEN", cellField.getIdent(), cellField.getName(), viewDef.getName()); } else { if (fieldInfo != null && fieldInfo.isHidden()) { FormDevHelper.appendLocalizedFormDevError("ViewFactory.FORM_REL_HIDDEN", cellField.getIdent(), cellField.getName(), viewDef.getName()); } } FormCellField.FieldType uiType = cellField.getUiType(); // Check to see if there is a PickList and get it if there is PickListDBAdapterIFace adapter = null; String pickListName = cellField.getPickListName(); if (childInfo != null && StringUtils.isEmpty(pickListName) && fieldInfo != null) { pickListName = fieldInfo.getPickListName(); } if (isNotEmpty(pickListName)) { adapter = PickListDBAdapterFactory.getInstance().create(pickListName, false); if (adapter == null || adapter.getPickList() == null) { FormDevHelper.appendFormDevError("PickList Adapter [" + pickListName + "] cannot be null!"); return false; } } /*if (uiType == FormCellFieldIFace.FieldType.text) { String weblink = cellField.getProperty("weblink"); if (StringUtils.isNotEmpty(weblink)) { String name = cellField.getProperty("name"); if (StringUtils.isNotEmpty(name) && name.equals("WebLink")) { uiType } } }*/ // The Default Display for combox is dsptextfield, except when there is a TableBased PickList // At the time we set the display we don't want to go get the picklist to find out. So we do it // here after we have the picklist and actually set the change into the cellField // because it uses the value to determine whether to convert the value into a text string // before setting it. if (mode == AltViewIFace.CreationMode.VIEW) { if (uiType == FormCellFieldIFace.FieldType.combobox && cellField.getDspUIType() != FormCellFieldIFace.FieldType.textpl) { if (adapter != null)// && adapter.isTabledBased()) { uiType = FormCellFieldIFace.FieldType.textpl; cellField.setDspUIType(uiType); } else { uiType = cellField.getDspUIType(); } } else { uiType = cellField.getDspUIType(); } } else if (uiType == FormCellField.FieldType.querycbx) { if (AppContextMgr.isSecurityOn()) { DBTableInfo tblInfo = childInfo != null ? DBTableIdMgr.getInstance() .getByShortClassName(childInfo.getDataClass().getSimpleName()) : null; if (tblInfo != null) { PermissionSettings perm = tblInfo.getPermissions(); if (perm != null) { //PermissionSettings.dumpPermissions("QCBX: "+tblInfo.getShortClassName(), perm.getOptions()); if (perm.isViewOnly() || !perm.canView()) { uiType = FormCellField.FieldType.textfieldinfo; } } } } } Class<?> fieldClass = childInfo != null ? childInfo.getDataClass() : null; String uiFormatName = cellField.getUIFieldFormatterName(); if (mode == AltViewIFace.CreationMode.EDIT && uiType == FormCellField.FieldType.text && fieldClass != null) { if (fieldClass == String.class && fieldInfo != null) { // check whether there's a formatter defined for this field in the schema if (fieldInfo.getFormatter() != null) { uiFormatName = fieldInfo.getFormatter().getName(); uiType = FormCellField.FieldType.formattedtext; } } else if (fieldClass == Integer.class || fieldClass == Long.class || fieldClass == Short.class || fieldClass == Byte.class || fieldClass == Double.class || fieldClass == Float.class || fieldClass == BigDecimal.class) { //log.debug(cellField.getName()+" is being changed to NUMERIC"); uiType = FormCellField.FieldType.formattedtext; uiFormatName = "Numeric" + fieldClass.getSimpleName(); } } // Create the UI Component boolean isReq = cellField.isRequired() || (fieldInfo != null && fieldInfo.isRequired()) || (relInfo != null && relInfo.isRequired()); cellField.setRequired(isReq); switch (uiType) { case text: bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter); bi.doAddToValidator = validator == null; // might already added to validator break; case formattedtext: { Class<?> tableClass = null; try { tableClass = Class.forName(viewDef.getClassName()); } catch (Exception ex) { } JComponent tfStart = createFormattedTextField(validator, cellField, tableClass, fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName, mode == AltViewIFace.CreationMode.VIEW, isReq, cellField.getPropertyAsBoolean("alledit", false)); bi.compToAdd = tfStart; if (cellField.getPropertyAsBoolean("series", false)) { JComponent tfEnd = createFormattedTextField(validator, cellField, tableClass, fieldInfo != null ? fieldInfo.getLength() : 0, uiFormatName, mode == AltViewIFace.CreationMode.VIEW, isReq, cellField.getPropertyAsBoolean("alledit", false)); // Make sure we register it like a plugin not a regular control SeriesProcCatNumPlugin plugin = new SeriesProcCatNumPlugin((ValFormattedTextFieldIFace) tfStart, (ValFormattedTextFieldIFace) tfEnd); bi.compToAdd = plugin.getUIComponent(); viewBldObj.registerPlugin(cell, plugin); bi.doRegControl = false; } bi.doAddToValidator = validator == null; // might already added to validator break; } case label: JLabel label = createLabel("", SwingConstants.LEFT); bi.compToAdd = label; break; case dsptextfield: if (StringUtils.isEmpty(cellField.getPickListName())) { JTextField text = UIHelper.createTextField(cellField.getTxtCols()); changeTextFieldUIForDisplay(text, cellField.getPropertyAsBoolean("transparent", false)); bi.compToAdd = text; } else { bi.compToAdd = createTextField(validator, cellField, fieldInfo, isReq, adapter); bi.doAddToValidator = validator == null; // might already added to validator } break; case textfieldinfo: bi.compToAdd = createTextFieldWithInfo(cellField, parent); break; case image: bi.compToAdd = createImageDisplay(cellField, mode, validator); bi.doAddToValidator = (validator != null); break; case url: BrowserLauncherBtn blb = new BrowserLauncherBtn(cellField.getProperty("title")); bi.compToAdd = blb; bi.doAddToValidator = false; break; case combobox: bi.compToAdd = createValComboBox(validator, cellField, adapter, isReq); bi.doAddToValidator = validator != null; // might already added to validator break; case checkbox: { String lblStr = cellField.getLabel(); if (lblStr.equals("##")) { bi.isDerivedLabel = true; cellField.setDerived(true); } ValCheckBox checkbox = new ValCheckBox(lblStr, isReq, cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW); if (validator != null) { DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), checkbox, validator.createValidator(checkbox, UIValidator.Type.Changed)); checkbox.addActionListener(dcn); checkbox.addItemListener(dcn); } bi.compToAdd = checkbox; break; } case tristate: { String lblStr = cellField.getLabel(); if (lblStr.equals("##")) { bi.isDerivedLabel = true; cellField.setDerived(true); } ValTristateCheckBox tristateCB = new ValTristateCheckBox(lblStr, isReq, cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW); if (validator != null) { DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), tristateCB, null); tristateCB.addActionListener(dcn); } bi.compToAdd = tristateCB; break; } case spinner: { String minStr = cellField.getProperty("min"); int min = StringUtils.isNotEmpty(minStr) ? Integer.parseInt(minStr) : 0; String maxStr = cellField.getProperty("max"); int max = StringUtils.isNotEmpty(maxStr) ? Integer.parseInt(maxStr) : 0; ValSpinner spinner = new ValSpinner(min, max, isReq, cellField.isReadOnly() || mode == AltViewIFace.CreationMode.VIEW); if (validator != null) { DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getIdent(), spinner, validator.createValidator(spinner, UIValidator.Type.Changed)); spinner.addChangeListener(dcn); } bi.compToAdd = spinner; break; } case password: bi.compToAdd = createPasswordField(validator, cellField, isReq); bi.doAddToValidator = validator == null; // might already added to validator break; case dsptextarea: bi.compToAdd = createDisplayTextArea(cellField); break; case textarea: { JTextArea ta = createTextArea(validator, cellField, isReq, fieldInfo); JScrollPane scrollPane = new JScrollPane(ta); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy( UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); ta.setLineWrap(true); ta.setWrapStyleWord(true); bi.doAddToValidator = validator == null; // might already added to validator bi.compToReg = ta; bi.compToAdd = scrollPane; break; } case textareabrief: { String title = ""; DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(viewDef.getClassName()); if (ti != null) { DBFieldInfo fi = ti.getFieldByName(cellField.getName()); if (fi != null) { title = fi.getTitle(); } } ValTextAreaBrief txBrief = createTextAreaBrief(validator, cellField, isReq, fieldInfo); txBrief.setTitle(title); bi.doAddToValidator = validator == null; // might already added to validator bi.compToReg = txBrief; bi.compToAdd = txBrief.getUIComponent(); break; } case browse: { JTextField textField = createTextField(validator, cellField, null, isReq, null); if (textField instanceof ValTextField) { ValBrowseBtnPanel bbp = new ValBrowseBtnPanel((ValTextField) textField, cellField.getPropertyAsBoolean("dirsonly", false), cellField.getPropertyAsBoolean("forinput", true)); String fileFilter = cellField.getProperty("filefilter"); String fileFilterDesc = cellField.getProperty("filefilterdesc"); String defaultExtension = cellField.getProperty("defaultExtension"); if (fileFilter != null && fileFilterDesc != null) { bbp.setUseNativeFileDlg(false); bbp.setFileFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter)); bbp.setDefaultExtension(defaultExtension); //bbp.setNativeDlgFilter(new FileNameExtensionFilter(fileFilterDesc, fileFilter)); } bi.compToAdd = bbp; } else { BrowseBtnPanel bbp = new BrowseBtnPanel(textField, cellField.getPropertyAsBoolean("dirsonly", false), cellField.getPropertyAsBoolean("forinput", true)); bi.compToAdd = bbp; } break; } case querycbx: { ValComboBoxFromQuery cbx = createQueryComboBox(validator, cellField, isReq, cellField.getPropertyAsBoolean("adjustquery", true)); cbx.setMultiView(parent); cbx.setFrameTitle(cellField.getProperty("title")); bi.compToAdd = cbx; bi.doAddToValidator = validator == null; // might already added to validator break; } case list: { JList list = createList(validator, cellField, isReq); JScrollPane scrollPane = new JScrollPane(list); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy( UIHelper.isMacOS() ? ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS : ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); bi.doAddToValidator = validator == null; bi.compToReg = list; bi.compToAdd = scrollPane; break; } case colorchooser: { ColorChooser colorChooser = new ColorChooser(Color.BLACK); if (validator != null) { DataChangeNotifier dcn = validator.createDataChangeNotifer(cellField.getName(), colorChooser, null); colorChooser.addPropertyChangeListener("setValue", dcn); } //setControlSize(colorChooser); bi.compToAdd = colorChooser; break; } case button: JButton btn = createFormButton(cellField, cellField.getProperty("title")); bi.compToAdd = btn; break; case progress: bi.compToAdd = createProgressBar(0, 100); break; case plugin: UIPluginable uip = createPlugin(parent, validator, cellField, mode == AltViewIFace.CreationMode.VIEW, isReq); if (uip != null) { bi.compToAdd = uip.getUIComponent(); viewBldObj.registerPlugin(cell, uip); } else { bi.compToAdd = new JPanel(); log.error("Couldn't create UIPlugin [" + cellField.getName() + "] ID:" + cellField.getIdent()); } bi.doRegControl = false; break; case textpl: JTextField txt = new TextFieldFromPickListTable(adapter, cellField.getTxtCols()); changeTextFieldUIForDisplay(txt, cellField.getPropertyAsBoolean("transparent", false)); bi.compToAdd = txt; break; default: FormDevHelper.appendFormDevError("Don't recognize uitype=[" + uiType + "]"); } // switch } else if (cell.getType() == FormCellIFace.CellType.separator) { // still have compToAdd = null; FormCellSeparatorIFace fcs = (FormCellSeparatorIFace) cell; String collapsableName = fcs.getCollapseCompName(); String label = fcs.getLabel(); if (StringUtils.isEmpty(label) || label.equals("##")) { String className = fcs.getProperty("forclass"); if (StringUtils.isNotEmpty(className)) { DBTableInfo ti = DBTableIdMgr.getInstance().getByShortClassName(className); if (ti != null) { label = ti.getTitle(); } } } Component sep = viewBldObj.createSeparator(label); if (isNotEmpty(collapsableName)) { CollapsableSeparator collapseSep = new CollapsableSeparator(sep, false, null); if (bi.collapseSepHash == null) { bi.collapseSepHash = new HashMap<CollapsableSeparator, String>(); } bi.collapseSepHash.put(collapseSep, collapsableName); sep = collapseSep; } bi.doRegControl = cell.getName().length() > 0; bi.compToAdd = (JComponent) sep; bi.doRegControl = StringUtils.isNotEmpty(cell.getIdent()); bi.doAddToValidator = false; } else if (cell.getType() == FormCellIFace.CellType.command) { FormCellCommand cellCmd = (FormCellCommand) cell; JButton btn = createFormButton(cell, cellCmd.getLabel()); if (cellCmd.getCommandType().length() > 0) { btn.addActionListener(new CommandActionWrapper( new CommandAction(cellCmd.getCommandType(), cellCmd.getAction(), ""))); } bi.doAddToValidator = false; bi.compToAdd = btn; } else if (cell.getType() == FormCellIFace.CellType.iconview) { FormCellSubView cellSubView = (FormCellSubView) cell; String subViewName = cellSubView.getViewName(); ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName); if (subView != null) { if (parent != null) { int options = MultiView.VIEW_SWITCHER | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT) ? MultiView.IS_NEW_OBJECT : MultiView.NO_OPTIONS); options |= cellSubView.getPropertyAsBoolean("nosep", false) ? MultiView.DONT_USE_EMBEDDED_SEP : 0; options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false) ? MultiView.NO_MORE_BTN_FOR_SEP : 0; MultiView multiView = new MultiView(parent, cellSubView.getName(), subView, parent.getCreateWithMode(), options, null); parent.addChildMV(multiView); multiView.setClassToCreate(getClassToCreate(parent, cell)); log.debug("[" + cell.getType() + "] [" + cell.getName() + "] col: " + bi.colInx + " row: " + rowInx + " colspan: " + cell.getColspan() + " rowspan: " + cell.getRowspan()); viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx, cellSubView.getColspan(), 1); viewBldObj.closeSubView(cellSubView); bi.curMaxRow = rowInx; bi.colInx += cell.getColspan() + 1; } else { log.error("buildFormView - parent is NULL for subview [" + subViewName + "]"); } } else { log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName() + "] ViewName[" + subViewName + "]"); } // still have compToAdd = null; bi.colInx += 2; } else if (cell.getType() == FormCellIFace.CellType.subview) { FormCellSubView cellSubView = (FormCellSubView) cell; String subViewName = cellSubView.getViewName(); ViewIFace subView = AppContextMgr.getInstance().getView(cellSubView.getViewSetName(), subViewName); if (subView != null) { // Check to see this view should be "flatten" meaning we are creating a grid from a form if (!viewBldObj.shouldFlatten()) { if (parent != null) { ViewIFace parentView = parent.getView(); Properties props = cellSubView.getProperties(); boolean isSingle = cellSubView.isSingleValueFromSet(); boolean isACollection = false; try { Class<?> cls = Class.forName(parentView.getClassName()); Field fld = getFieldFromDotNotation(cellSubView, cls); if (fld != null) { isACollection = Collection.class.isAssignableFrom(fld.getType()); } else { log.error("Couldn't find field [" + cellSubView.getName() + "] in class [" + parentView.getClassName() + "]"); } } catch (Exception ex) { log.error("Couldn't find field [" + cellSubView.getName() + "] in class [" + parentView.getClassName() + "]"); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ViewFactory.class, ex); } if (isSingle) { isACollection = true; } boolean useNoScrollbars = UIHelper.getProperty(props, "noscrollbars", false); //Assume RecsetController will always be handled correctly for one-to-one boolean hideResultSetController = relInfo == null ? false : relInfo.getType().equals(DBRelationshipInfo.RelationshipType.ZeroOrOne); /*XXX bug #9497: boolean canEdit = true; boolean addAddBtn = isEditOnCreateOnly && relInfo != null; if (AppContextMgr.isSecurityOn()) { DBTableInfo tblInfo = childInfo != null ? DBTableIdMgr.getInstance().getByShortClassName(childInfo.getDataClass().getSimpleName()) : null; if (tblInfo != null) { PermissionSettings perm = tblInfo.getPermissions(); if (perm != null) { //XXX whoa. What about view perms??? //if (perm.isViewOnly() || !perm.canView()) { if (!perm.canModify()) { canEdit = false; } } } }*/ int options = (isACollection && !isSingle ? MultiView.RESULTSET_CONTROLLER : MultiView.IS_SINGLE_OBJ) | MultiView.VIEW_SWITCHER | (MultiView.isOptionOn(parent.getCreateOptions(), MultiView.IS_NEW_OBJECT) ? MultiView.IS_NEW_OBJECT : MultiView.NO_OPTIONS) | /* XXX bug #9497:(mode == AltViewIFace.CreationMode.EDIT && canEdit ? MultiView.IS_EDITTING : MultiView.NO_OPTIONS) | (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS) //| (addAddBtn ? MultiView.INCLUDE_ADD_BTN : MultiView.NO_OPTIONS) ; */ (mode == AltViewIFace.CreationMode.EDIT ? MultiView.IS_EDITTING : MultiView.NO_OPTIONS) | (useNoScrollbars ? MultiView.NO_SCROLLBARS : MultiView.NO_OPTIONS) | (hideResultSetController ? MultiView.HIDE_RESULTSET_CONTROLLER : MultiView.NO_OPTIONS); //MultiView.printCreateOptions("HERE", options); options |= cellSubView.getPropertyAsBoolean("nosep", false) ? MultiView.DONT_USE_EMBEDDED_SEP : 0; options |= cellSubView.getPropertyAsBoolean("nosepmorebtn", false) ? MultiView.NO_MORE_BTN_FOR_SEP : 0; options |= cellSubView.getPropertyAsBoolean("collapse", false) ? MultiView.COLLAPSE_SEPARATOR : 0; if (!(isACollection && !isSingle)) { options &= ~MultiView.ADD_SEARCH_BTN; } else { options |= cellSubView.getPropertyAsBoolean("addsearch", false) ? MultiView.ADD_SEARCH_BTN : 0; } //MultiView.printCreateOptions("_______________________________", parent.getCreateOptions()); //MultiView.printCreateOptions("_______________________________", options); boolean useBtn = UIHelper.getProperty(props, "btn", false); if (useBtn) { SubViewBtn.DATA_TYPE dataType; if (isSingle) { dataType = SubViewBtn.DATA_TYPE.IS_SINGLESET_ITEM; } else if (isACollection) { dataType = SubViewBtn.DATA_TYPE.IS_SET; } else { dataType = cellSubView.getName().equals("this") ? SubViewBtn.DATA_TYPE.IS_THIS : SubViewBtn.DATA_TYPE.IS_SET; } SubViewBtn subViewBtn = getInstance().createSubViewBtn(parent, cellSubView, subView, dataType, options, props, getClassToCreate(parent, cell), mode); subViewBtn.setHelpContext(props.getProperty("hc", null)); bi.doAddToValidator = false; bi.compToAdd = subViewBtn; String visProp = cell.getProperty("visible"); if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false") && bi.compToAdd != null) { bi.compToAdd.setVisible(false); } try { addControl(validator, viewBldObj, rowInx, cell, bi); } catch (java.lang.IndexOutOfBoundsException ex) { String msg = "Error adding control type: `" + cell.getType() + "` id: `" + cell.getIdent() + "` name: `" + cell.getName() + "` on row: " + rowInx + " column: " + bi.colInx + "\n" + ex.getMessage(); UIRegistry.showError(msg); return false; } bi.doRegControl = false; bi.compToAdd = null; } else { Color bgColor = getBackgroundColor(props, parent.getBackground()); //log.debug(cellSubView.getName()+" "+UIHelper.getProperty(props, "addsearch", false)); if (UIHelper.getProperty(props, "addsearch", false)) { options |= MultiView.ADD_SEARCH_BTN; } if (UIHelper.getProperty(props, "addadd", false)) { options |= MultiView.INCLUDE_ADD_BTN; } //MultiView.printCreateOptions("SUBVIEW", options); MultiView multiView = new MultiView(parent, cellSubView.getName(), subView, parent.getCreateWithMode(), cellSubView.getDefaultAltViewType(), options, bgColor, cellSubView); multiView.setClassToCreate(getClassToCreate(parent, cell)); setBorder(multiView, cellSubView.getProperties()); parent.addChildMV(multiView); //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan()); viewBldObj.addSubView(cellSubView, multiView, bi.colInx, rowInx, cellSubView.getColspan(), 1); viewBldObj.closeSubView(cellSubView); Viewable viewable = multiView.getCurrentView(); if (viewable != null) { if (viewable instanceof TableViewObj) { ((TableViewObj) viewable).setVisibleRowCount(cellSubView.getTableRows()); } if (viewable.getValidator() != null && childInfo != null) { viewable.getValidator().setRequired(childInfo.isRequired()); } } bi.colInx += cell.getColspan() + 1; } bi.curMaxRow = rowInx; //if (hasColor) //{ // setMVBackground(multiView, multiView.getBackground()); //} } else { log.error("buildFormView - parent is NULL for subview [" + subViewName + "]"); bi.colInx += 2; } } else { //log.debug("["+cell.getType()+"] ["+cell.getName()+"] col: "+bi.colInx+" row: "+rowInx+" colspan: "+cell.getColspan()+" rowspan: "+cell.getRowspan()); viewBldObj.addSubView(cellSubView, parent, bi.colInx, rowInx, cellSubView.getColspan(), 1); AltViewIFace altView = subView.getDefaultAltView(); DBTableInfo sbTableInfo = DBTableIdMgr.getInstance().getByClassName(subView.getClassName()); ViewDefIFace altsViewDef = (ViewDefIFace) altView.getViewDef(); if (altsViewDef instanceof FormViewDefIFace) { FormViewDefIFace fvd = (FormViewDefIFace) altsViewDef; processRows(sbTableInfo, parent, viewDef, validator, viewBldObj, altView.getMode(), labelsForHash, currDataObj, fvd.getRows()); } else if (altsViewDef == null) { // This error is bad enough to have it's own dialog String msg = String.format("The Altview '%s' has a null ViewDef!", altView.getName()); FormDevHelper.appendFormDevError(msg); UIRegistry.showError(msg); } viewBldObj.closeSubView(cellSubView); bi.colInx += cell.getColspan() + 1; } } else { log.error("buildFormView - Could find subview's with ViewSet[" + cellSubView.getViewSetName() + "] ViewName[" + subViewName + "]"); } // still have compToAdd = null; } else if (cell.getType() == FormCellIFace.CellType.statusbar) { bi.compToAdd = new JStatusBar(); bi.doRegControl = true; bi.doAddToValidator = false; } else if (cell.getType() == FormCellIFace.CellType.panel) { bi.doRegControl = false; bi.doAddToValidator = false; cell.setIgnoreSetGet(true); FormCellPanel cellPanel = (FormCellPanel) cell; PanelViewable.PanelType panelType = PanelViewable.getType(cellPanel.getPanelType()); if (panelType == PanelViewable.PanelType.Panel) { PanelViewable panelViewable = new PanelViewable(viewBldObj, cellPanel); processRows(parentTableInfo, parent, viewDef, validator, panelViewable, mode, labelsForHash, currDataObj, cellPanel.getRows()); panelViewable.setVisible(cellPanel.getPropertyAsBoolean("visible", true)); setBorder(panelViewable, cellPanel.getProperties()); if (parent != null) { Color bgColor = getBackgroundColor(cellPanel.getProperties(), parent.getBackground()); if (bgColor != null && bgColor != parent.getBackground()) { panelViewable.setOpaque(true); panelViewable.setBackground(bgColor); } } bi.compToAdd = panelViewable; bi.doRegControl = true; bi.compToReg = panelViewable; } else if (panelType == PanelViewable.PanelType.ButtonBar) { bi.compToAdd = PanelViewable.buildButtonBar(processRows(viewBldObj, cellPanel.getRows())); } else { FormDevHelper.appendFormDevError("Panel Type is not implemented."); return false; } } String visProp = cell.getProperty("visible"); if (StringUtils.isNotEmpty(visProp) && visProp.equalsIgnoreCase("false") && bi.compToAdd != null) { bi.compToAdd.setVisible(false); } return true; }
From source file:no.java.swing.SelectableLabel.java
public SelectableLabel(String text, boolean multiline) { Border border = UIManager.getBorder("Label.border"); setBorder(border != null ? border : Borders.EMPTY_BORDER); setLayout(new BorderLayout()); if (multiline) { JTextArea area = new JTextArea(1, 0) { @Override//from ww w. j a v a 2s . c o m public void updateUI() { setUI(new BasicTextAreaUI()); invalidate(); } }; area.setWrapStyleWord(true); area.setLineWrap(true); textComponent = area; } else { textComponent = new JTextField() { @Override public void updateUI() { setUI(new BasicTextFieldUI()); invalidate(); } }; } textComponent.setOpaque(false); textComponent.setBackground(new Color(0, true)); textComponent.setEditable(false); textComponent.setDropTarget(null); textComponent.setBorder(Borders.EMPTY_BORDER); add(textComponent); if (!StringUtils.isBlank(text)) { setText(text); } }
From source file:org.executequery.gui.editor.LobDataItemViewerPanel.java
private JTextArea createTextArea() { JTextArea textArea = new JTextArea(); textArea.setEditable(false);/*from w ww . ja va2 s. c o m*/ textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setFont(new Font("monospaced", Font.PLAIN, 11)); return textArea; }
From source file:org.kepler.gui.ComponentLibraryPreferencesTab.java
/** * Initialize the top panel that contains controls for the table. *//*www.ja v a 2 s . com*/ private void initDoc() { String header = StaticResources.getDisplayString("preferences.description1", "The Component Library is built using KAR files found" + " in the following local directories. Adding or removing local directories will rebuild" + " the component library.") + "\n\n" + StaticResources.getDisplayString("preferences.description2", "By selecting the search box next to remote" + " repositories, components from the remote repositories will be included" + " when searching components.") + "\n\n" + StaticResources.getDisplayString("preferences.description3", "By selecting the save box next to a local repository, KAR files will be saved" + " to that directory by default.") + "\n\n" + StaticResources.getDisplayString("preferences.description4", "By selecting the save box next to a remote repository, you will be asked " + " if you want to upload the KAR to that repository when it is saved."); JTextArea headerTextArea = new JTextArea(header); headerTextArea.setEditable(false); headerTextArea.setLineWrap(true); headerTextArea.setWrapStyleWord(true); headerTextArea.setPreferredSize(new Dimension(300, 400)); headerTextArea.setBackground(TabManager.BGCOLOR); JPanel headerPanel = new JPanel(new BorderLayout()); headerPanel.setBackground(TabManager.BGCOLOR); headerPanel.add(headerTextArea, BorderLayout.CENTER); JScrollPane headerPane = new JScrollPane(headerPanel); headerPane.setPreferredSize(new Dimension(300, 150)); add(headerPane); }
From source file:org.opencms.applet.upload.FileUploadApplet.java
/** * Displays the dialog that shows the list of files that will be overwritten on the server. * <p>//www. j a v a 2s .c om * The user may uncheck the checkboxes in front of the relative paths to avoid overwriting. * <p> * * @param duplications * a list of Strings that are relative paths to the files that will be overwritten on the server * * @return one of */ private int showDuplicationsDialog(List duplications) { int rtv = ModalDialog.ERROR_OPTION; try { JTextArea dialogIntroPanel = new JTextArea(); dialogIntroPanel.setLineWrap(true); dialogIntroPanel.setWrapStyleWord(true); dialogIntroPanel.setText(m_overwriteDialogIntro); dialogIntroPanel.setEditable(false); dialogIntroPanel.setBackground(m_fileSelector.getBackground()); dialogIntroPanel.setFont(m_font); FileSelectionPanel selectionPanel = new FileSelectionPanel(duplications, m_fileSelector.getCurrentDirectory().getAbsolutePath()); JPanel stacker = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.gridheight = 1; gbc.gridwidth = 1; gbc.weightx = 1f; gbc.weighty = 0f; gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(2, 2, 2, 2); stacker.add(dialogIntroPanel, gbc); gbc.weighty = 1f; gbc.gridy = 1; gbc.insets = new Insets(0, 2, 0, 2); stacker.add(selectionPanel, gbc); m_overwriteDialog = new ModalDialog(m_fileSelector, m_overwriteDialogTitle, m_overwriteDialogOk, m_overwriteDialogCancel, stacker); m_overwriteDialog.setSize(new Dimension(560, 280)); //dialog.setResizable(false); m_overwriteDialog.showDialog(); rtv = m_overwriteDialog.getReturnValue(); } catch (Throwable f) { f.printStackTrace(System.err); } return rtv; }
From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java
/** * Initializes a <code>TextPane</code>. * /* w ww . j a v a2 s . c om*/ * @return See above. */ private JTextArea createTextPane() { JTextArea pane = new JTextArea(); pane.setWrapStyleWord(true); pane.setOpaque(false); pane.setBackground(UIUtilities.BACKGROUND_COLOR); return pane; }
From source file:org.paxle.desktop.impl.dialogues.settings.AbstractAttrConfig.java
protected JTextArea createDescription(final String desc) { final JTextArea df = new JTextArea(desc); Utilities.instance.setTextLabelDefaults(df); df.setLineWrap(true);/*from www. ja v a 2 s . c o m*/ df.setWrapStyleWord(true); return df; }
From source file:org.pgptool.gui.ui.tools.UiUtils.java
private static JScrollPane getScrollableMessage(String msg) { JTextArea textArea = new JTextArea(msg); textArea.setLineWrap(true);// w w w . j a v a 2 s .com textArea.setWrapStyleWord(true); textArea.setEditable(false); textArea.setMargin(new Insets(5, 5, 5, 5)); textArea.setFont(new JTextField().getFont()); // dirty fix to use better font JScrollPane scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(700, 150)); scrollPane.getViewport().setView(textArea); return scrollPane; }