List of usage examples for javax.swing JLabel setForeground
@BeanProperty(preferred = true, visualUpdate = true, description = "The foreground color of the component.") public void setForeground(Color fg)
From source file:edu.ku.brc.specify.extras.ViewToSchemaReview.java
/** * /*from www . ja v a 2 s. c om*/ */ public void checkSchemaAndViews() { Hashtable<String, HashSet<String>> viewFieldHash = new Hashtable<String, HashSet<String>>(); SpecifyAppContextMgr sacm = (SpecifyAppContextMgr) AppContextMgr.getInstance(); for (ViewIFace view : sacm.getEntirelyAllViews()) { //System.err.println(view.getName() + " ----------------------"); for (AltViewIFace av : view.getAltViews()) { ViewDefIFace vd = av.getViewDef(); if (vd.getType() == ViewType.form) { DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(vd.getClassName()); if (ti != null) { HashSet<String> tiHash = viewFieldHash.get(ti.getName()); if (tiHash == null) { tiHash = new HashSet<String>(); viewFieldHash.put(ti.getName(), tiHash); } FormViewDef fvd = (FormViewDef) vd; for (FormRowIFace row : fvd.getRows()) { for (FormCellIFace cell : row.getCells()) { if (cell.getType() == FormCellIFace.CellType.panel) { FormCellPanelIFace panelCell = (FormCellPanelIFace) cell; for (String fieldName : panelCell.getFieldNames()) { tiHash.add(fieldName); } } else if (cell.getType() == FormCellIFace.CellType.field || cell.getType() == FormCellIFace.CellType.subview) { String fieldName = cell.getName(); if (!cell.isIgnoreSetGet() && !fieldName.equals("this")) { DBFieldInfo fi = ti.getFieldByName(fieldName); if (fi != null) { //System.err.println("Form Field["+fieldName+"] is in schema."); tiHash.add(fieldName); } else { DBRelationshipInfo ri = ti.getRelationshipByName(fieldName); if (ri == null) { //System.err.println("Form Field["+fieldName+"] not in table."); } else { tiHash.add(fieldName); } } } else if (cell instanceof FormCellFieldIFace) { FormCellFieldIFace fcf = (FormCellFieldIFace) cell; if (fcf.getUiType() == FormCellFieldIFace.FieldType.plugin) { String pluginName = fcf.getProperty("name"); if (StringUtils.isNotEmpty(pluginName)) { checkPluginForNames(fcf, pluginName, tiHash); } } } } } } } } } } for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) { int cnt = 0; HashSet<String> tiHash = viewFieldHash.get(ti.getName()); if (tiHash != null) { tblTitle2Name.put(ti.getTitle(), ti.getName()); //System.err.println(ti.getName() + " ----------------------"); for (DBFieldInfo fi : ti.getFields()) { Boolean isInForm = tiHash.contains(fi.getName()); modelList.add( createRow(ti.getTitle(), fi.getName(), fi.getTitle(), isInForm, fi.isHidden(), cnt++)); } for (DBRelationshipInfo ri : ti.getRelationships()) { Boolean isInForm = tiHash.contains(ri.getName()); modelList.add( createRow(ti.getTitle(), ri.getName(), ri.getTitle(), isInForm, ri.isHidden(), cnt++)); } } } viewModel = new ViewModel(); JTable table = new JTable(viewModel); sorter = new TableRowSorter<TableModel>(viewModel); searchTF = new JAutoCompTextField(20); table.setRowSorter(sorter); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p:g")); SearchBox searchBox = new SearchBox(searchTF, null); filterCBX = UIHelper.createComboBox(new String[] { "None", "Not On Form, Not Hidden", "On Form, Hidden" }); PanelBuilder searchPB = new PanelBuilder(new FormLayout("p,2px,p, f:p:g, p,2px,p", "p")); searchPB.add(UIHelper.createI18NFormLabel("SEARCH"), cc.xy(1, 1)); searchPB.add(searchBox, cc.xy(3, 1)); searchPB.add(UIHelper.createI18NFormLabel("Filter"), cc.xy(5, 1)); searchPB.add(filterCBX, cc.xy(7, 1)); JLabel legend = UIHelper.createLabel( "<HTML><li><font color=\"red\">Red</font> - Not on form and not hidden</li><li><font color=\"magenta\">Magenta</font> - On the form , but is hidden</li><li>Black - Correct</li>"); legend.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); PanelBuilder legPB = new PanelBuilder(new FormLayout("p,f:p:g", "p")); legPB.add(legend, cc.xy(1, 1)); pb.add(searchPB.getPanel(), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(table), cc.xy(1, 3)); pb.add(legPB.getPanel(), cc.xy(1, 5)); pb.setDefaultDialogBorder(); sorter.setRowFilter(null); searchTF.getDocument().addDocumentListener(new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { if (filterCBX.getSelectedIndex() > 0) { blockCBXUpdate = true; filterCBX.setSelectedIndex(-1); blockCBXUpdate = false; } String text = searchTF.getText(); sorter.setRowFilter(text.isEmpty() ? null : RowFilter.regexFilter("^(?i)" + text, 0, 1)); } }); } }); filterCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (!blockCBXUpdate) { RowFilter<TableModel, Integer> filter = null; int inx = filterCBX.getSelectedIndex(); if (inx > 0) { filter = filterCBX.getSelectedIndex() == 1 ? new NotOnFormNotHiddenRowFilter() : new OnFormIsHiddenRowFilter(); } sorter.setRowFilter(filter); } } }); } }); table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false)); table.setDefaultRenderer(Boolean.class, new BiColorBooleanTableCellRenderer()); table.getColumnModel().getColumn(0).setCellRenderer(new TitleCellFadeRenderer()); table.getColumnModel().getColumn(3).setCellRenderer(new BiColorTableCellRenderer(true)); table.getColumnModel().getColumn(2).setCellRenderer(new BiColorTableCellRenderer(false) { @SuppressWarnings("unchecked") @Override public Component getTableCellRendererComponent(JTable tableArg, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel lbl = (JLabel) super.getTableCellRendererComponent(tableArg, value, isSelected, hasFocus, row, column); /*if (sorter.getRowFilter() != null) { System.out.println(" getRowCount:"+sorter.getModel().getRowCount()); Pair<String, Integer> col1Pair = (Pair<String, Integer>)sorter.getModel().getValueAt(row, 0); rowData = modelList.get(col1Pair.second); } else { rowData = modelList.get(row); }*/ //System.out.println(" R2:"+row+" "+rowData[0]+"/"+rowData[1]+" - "+rowData[3]+"|"+rowData[4]); if (value instanceof TableInfo) { TableInfo pair = (TableInfo) value; Object[] rowData = modelList.get(pair.getSecond()); lbl.setText(rowData[0].toString()); } else if (value instanceof Pair<?, ?>) { Pair<String, Integer> pair = (Pair<String, Integer>) value; Object[] rowData = modelList.get(pair.getSecond()); boolean isOnForm = rowData[3] instanceof Boolean ? (Boolean) rowData[3] : ((String) rowData[3]).equals("Yes"); boolean isHidden = rowData[4] instanceof Boolean ? (Boolean) rowData[4] : ((String) rowData[4]).equals("true"); if (!isOnForm && !isHidden) { lbl.setForeground(Color.RED); } else if (isOnForm && isHidden) { lbl.setForeground(Color.MAGENTA); } else { lbl.setForeground(Color.BLACK); } lbl.setText(pair.getFirst()); } else { lbl.setText(value.toString()); } return lbl; } }); //UIHelper.makeTableHeadersCentered(table, false); UIHelper.calcColumnWidths(table, null); //Removing fix all button because fix() method is broken (bug #8087)... /*CustomDialog dlg = new CustomDialog((Frame)UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCELAPPLY, pb.getPanel()) { @Override protected void applyButtonPressed() { fix(this); } }; dlg.setApplyLabel("Fix All");*/ CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCEL, pb.getPanel()); //... end removing fix all button dlg.setVisible(true); if (!dlg.isCancelled()) { updateSchema(); } }
From source file:eu.europa.ec.markt.tlmanager.view.pages.TreeDataPublisher.java
/** * This method handles the state of the <code>JLabel</code>'s that are associated to mandatory fields, as well as * any 'special' component. It is called via two tracks: Once by the implementation of the * <code>BindingListener</code> in <code>BindingManager</code> and once by individual action listeners for each * component. These action listeners are installed at the same time of the installation of the binding (cf. * BindingManager.setupComponent()).//from w ww . j a v a 2s .c o m * * @param component the component * @param failure if the label should express a failure */ protected void changeMandatoryComponents(Component component, boolean failure) { if (mandatoryLabels == null) { return; } for (JLabel label : mandatoryLabels) { if (label == null || component == null || label.getLabelFor() == null) { continue; } if (label.getLabelFor().equals(component)) { boolean empty = false; if (component instanceof JTextField) { JTextField tf = (JTextField) component; if (tf.getText().isEmpty()) { empty = true; } } else if (component instanceof JComboBox) { JComboBox box = (JComboBox) component; if (box.isEditable()) { final String text = ((JTextComponent) box.getEditor().getEditorComponent()).getText(); if (StringUtils.isEmpty(text) || StringUtils.equals(text, Util.DEFAULT_NO_SELECTION_ENTRY)) { empty = true; } } else { if (box.getSelectedItem().equals(Util.DEFAULT_NO_SELECTION_ENTRY)) { empty = true; } } } else if (component instanceof JXDatePicker) { JXDatePicker picker = (JXDatePicker) component; Date date = picker.getDate(); if (date == null) { empty = true; } } else if (component instanceof DateTimePicker) { DateTimePicker picker = (DateTimePicker) component; Date date = picker.getDateTime(); if (date == null) { empty = true; } } else if (component instanceof MultivalueButton) { MultivalueButton button = (MultivalueButton) component; if (button.getMultivaluePanel().getMultivalueModel().isEmpty()) { empty = true; } } else if (component instanceof CertificateProperty) { CertificateProperty certificateProperty = (CertificateProperty) component; empty = certificateProperty.isEmpty(); } if (failure || empty) { label.setForeground(Configuration.MANDATORY_COLOR); } else { label.setForeground(Configuration.NORMAL_COLOR); } break; } } }
From source file:GUI.MainWindow.java
public void addReference(JTree tree, JList list, Reference current) { DefaultMutableTreeNode node = ((DefaultMutableTreeNode) tree.getLastSelectedPathComponent()); if (node == null) { return;/*w w w .j a v a 2 s . co m*/ } Object obj = node.getUserObject(); if (!(obj instanceof Vulnerability)) { return; // here be monsters, most likely in the merge tree } Vulnerability vuln = (Vulnerability) obj; DefaultListModel dlm = (DefaultListModel) list.getModel(); // Build Input Field and display it JTextField description = new JTextField(); JTextField url = new JTextField(); // If current is not null then pre-set the description and risk if (current != null) { description.setText(current.getDescription()); url.setText(current.getUrl()); } JLabel error = new JLabel( "A valid URL needs to be supplied including the protocol i.e. http://www.github.com"); error.setForeground(Color.red); Object[] message = { "Description:", description, "URL:", url }; String url_string = null; Reference newref = null; while (url_string == null) { int option = JOptionPane.showConfirmDialog(null, message, "Add Reference", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { System.out.println("User clicked ok, validating data"); String ref_desc = description.getText(); String ref_url = url.getText(); if (!ref_desc.equals("") || !ref_url.equals("")) { // Both have values // Try to validate URL try { URL u = new URL(url.getText()); u.toURI(); url_string = url.getText(); // Causes loop to end with a valid url } catch (MalformedURLException ex) { url_string = null; //ex.printStackTrace(); } catch (URISyntaxException ex) { url_string = null; //ex.printStackTrace(); } } } else if (option == JOptionPane.CANCEL_OPTION || option == JOptionPane.CLOSED_OPTION) { System.out.println("User clicked cancel/close"); return; // ends the loop without making any chages } if (url_string == null) { // We need to show an error saying that the url failed to parse Object[] message2 = { error, "Description:", description, "URL:", url }; message = message2; } } // If you get here there is a valid reference URL and description Reference ref = new Reference(description.getText(), url.getText()); if (current == null) { // Add it to the vuln vuln.addReference(ref); // Add it to the GUI dlm.addElement(ref); System.out.println("Valid reference added: " + ref); } else { // Modify it in the vuln vuln.modifyReference(current, ref); // Update the GUI dlm.removeElement(current); dlm.addElement(ref); System.out.println("Valid reference modified: " + ref); } }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java
/** * Sets the chat session to associate to this chat panel. * @param chatSession the chat session to associate to this chat panel *//*from ww w . java 2s . c o m*/ public void setChatSession(ChatSession chatSession) { if (this.chatSession != null) { // remove old listener this.chatSession.removeChatTransportChangeListener(this); } this.chatSession = chatSession; this.chatSession.addChatTransportChangeListener(this); if ((this.chatSession != null) && this.chatSession.isContactListSupported()) { topPanel.remove(conversationPanelContainer); TransparentPanel rightPanel = new TransparentPanel(new BorderLayout()); Dimension chatConferencesListsPanelSize = new Dimension(150, 25); Dimension chatContactsListsPanelSize = new Dimension(150, 175); Dimension rightPanelSize = new Dimension(150, 200); rightPanel.setMinimumSize(rightPanelSize); rightPanel.setPreferredSize(rightPanelSize); TransparentPanel contactsPanel = new TransparentPanel(new BorderLayout()); contactsPanel.setMinimumSize(chatContactsListsPanelSize); contactsPanel.setPreferredSize(chatContactsListsPanelSize); conferencePanel.setMinimumSize(chatConferencesListsPanelSize); conferencePanel.setPreferredSize(chatConferencesListsPanelSize); this.chatContactListPanel = new ChatRoomMemberListPanel(this); this.chatContactListPanel.setOpaque(false); topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); topSplitPane.setBorder(null); // remove default borders topSplitPane.setOneTouchExpandable(true); topSplitPane.setOpaque(false); topSplitPane.setResizeWeight(1.0D); Color msgNameBackground = Color.decode(ChatHtmlUtils.MSG_NAME_BACKGROUND); // add border to the divider if (topSplitPane.getUI() instanceof BasicSplitPaneUI) { ((BasicSplitPaneUI) topSplitPane.getUI()).getDivider() .setBorder(BorderFactory.createLineBorder(msgNameBackground)); } ChatTransport chatTransport = chatSession.getCurrentChatTransport(); JPanel localUserLabelPanel = new JPanel(new BorderLayout()); JLabel localUserLabel = new JLabel(chatTransport.getProtocolProvider().getAccountID().getDisplayName()); localUserLabel.setFont(localUserLabel.getFont().deriveFont(Font.BOLD)); localUserLabel.setHorizontalAlignment(SwingConstants.CENTER); localUserLabel.setBorder(BorderFactory.createEmptyBorder(2, 0, 3, 0)); localUserLabel.setForeground(Color.decode(ChatHtmlUtils.MSG_IN_NAME_FOREGROUND)); localUserLabelPanel.add(localUserLabel, BorderLayout.CENTER); localUserLabelPanel.setBackground(msgNameBackground); JButton joinConference = new JButton( GuiActivator.getResources().getI18NString("service.gui.JOIN_VIDEO")); joinConference.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { showChatConferenceDialog(); } }); contactsPanel.add(localUserLabelPanel, BorderLayout.NORTH); contactsPanel.add(chatContactListPanel, BorderLayout.CENTER); conferencePanel.add(joinConference, BorderLayout.CENTER); rightPanel.add(conferencePanel, BorderLayout.NORTH); rightPanel.add(contactsPanel, BorderLayout.CENTER); topSplitPane.setLeftComponent(conversationPanelContainer); topSplitPane.setRightComponent(rightPanel); topPanel.add(topSplitPane); } else { if (topSplitPane != null) { if (chatContactListPanel != null) { topSplitPane.remove(chatContactListPanel); chatContactListPanel = null; } this.messagePane.remove(topSplitPane); topSplitPane = null; } topPanel.add(conversationPanelContainer); } if (chatSession instanceof MetaContactChatSession) { // The subject panel is added here, because it's specific for the // multi user chat and is not contained in the single chat chat panel. if (subjectPanel != null) { this.remove(subjectPanel); subjectPanel = null; this.revalidate(); this.repaint(); } writeMessagePanel.initPluginComponents(); writeMessagePanel.setTransportSelectorBoxVisible(true); //Enables to change the protocol provider by simply pressing the // CTRL-P key combination ActionMap amap = this.getActionMap(); amap.put("ChangeProtocol", new ChangeTransportAction()); InputMap imap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK), "ChangeProtocol"); } else if (chatSession instanceof ConferenceChatSession) { ConferenceChatSession confSession = (ConferenceChatSession) chatSession; writeMessagePanel.setTransportSelectorBoxVisible(false); confSession.addLocalUserRoleListener(this); confSession.addMemberRoleListener(this); ChatRoom room = ((ChatRoomWrapper) chatSession.getDescriptor()).getChatRoom(); room.addMemberPropertyChangeListener(this); setConferencesPanelVisible(room.getCachedConferenceDescriptionSize() > 0); subjectPanel = new ChatRoomSubjectPanel((ConferenceChatSession) chatSession); // The subject panel is added here, because it's specific for the // multi user chat and is not contained in the single chat chat panel. this.add(subjectPanel, BorderLayout.NORTH); this.revalidate(); this.repaint(); } if (chatContactListPanel != null) { // Initialize chat participants' panel. Iterator<ChatContact<?>> chatParticipants = chatSession.getParticipants(); while (chatParticipants.hasNext()) chatContactListPanel.addContact(chatParticipants.next()); } }
From source file:userinterface.properties.GUIGraphHandler.java
public void plotNewFunction() { JDialog dialog;// w ww. j a va2 s . c om JRadioButton radio2d, radio3d, newGraph, existingGraph; JTextField functionField, seriesName; JButton ok, cancel; JComboBox<String> chartOptions; JLabel example; //init all the fields of the dialog dialog = new JDialog(GUIPrism.getGUI()); radio2d = new JRadioButton("2D"); radio3d = new JRadioButton("3D"); newGraph = new JRadioButton("New Graph"); existingGraph = new JRadioButton("Exisiting"); chartOptions = new JComboBox<String>(); functionField = new JTextField(); ok = new JButton("Plot"); cancel = new JButton("Cancel"); seriesName = new JTextField(); example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); example.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { example.setCursor(new Cursor(Cursor.HAND_CURSOR)); example.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); example.setForeground(Color.BLACK); } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (radio2d.isSelected()) { functionField.setText("x/2 + 5"); } else { functionField.setText("x+y+5"); } functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setForeground(Color.BLACK); } } }); //set dialog properties dialog.setSize(400, 350); dialog.setTitle("Plot a new function"); dialog.setModal(true); dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); dialog.setLocationRelativeTo(GUIPrism.getGUI()); //add every component to their dedicated panels JPanel graphTypePanel = new JPanel(new FlowLayout()); graphTypePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type")); graphTypePanel.add(radio2d); graphTypePanel.add(radio3d); JPanel functionFieldPanel = new JPanel(new BorderLayout()); functionFieldPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function")); functionFieldPanel.add(functionField, BorderLayout.CENTER); functionFieldPanel.add(example, BorderLayout.SOUTH); JPanel chartSelectPanel = new JPanel(); chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS)); chartSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to")); JPanel radioPlotPanel = new JPanel(new FlowLayout()); radioPlotPanel.add(newGraph); radioPlotPanel.add(existingGraph); JPanel chartOptionsPanel = new JPanel(new FlowLayout()); chartOptionsPanel.add(chartOptions); chartSelectPanel.add(radioPlotPanel); chartSelectPanel.add(chartOptionsPanel); JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomControlPanel.add(ok); bottomControlPanel.add(cancel); JPanel seriesNamePanel = new JPanel(new BorderLayout()); seriesNamePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); seriesNamePanel.add(seriesName, BorderLayout.CENTER); // add all the panels to the dialog dialog.add(graphTypePanel); dialog.add(functionFieldPanel); dialog.add(chartSelectPanel); dialog.add(seriesNamePanel); dialog.add(bottomControlPanel); // do all the enables and set properties radio2d.setSelected(true); newGraph.setSelected(true); chartOptions.setEnabled(false); functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); seriesName.setText("New function"); ok.setMnemonic('P'); cancel.setMnemonic('C'); example.setToolTipText("click to try out"); ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); cancel.getActionMap().put("cancel", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); boolean found = false; for (int i = 0; i < theTabs.getTabCount(); i++) { if (theTabs.getComponentAt(i) instanceof Graph) { chartOptions.addItem(getGraphName(i)); found = true; } } if (!found) { existingGraph.setEnabled(false); chartOptions.setEnabled(false); } //add all the action listeners radio2d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio2d.isSelected()) { radio3d.setSelected(false); if (chartOptions.getItemCount() > 0) { existingGraph.setEnabled(true); chartOptions.setEnabled(true); } example.setText( "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); } } }); radio3d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio3d.isSelected()) { radio2d.setSelected(false); newGraph.setSelected(true); existingGraph.setEnabled(false); chartOptions.setEnabled(false); example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>"); } } }); newGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGraph.isSelected()) { existingGraph.setSelected(false); chartOptions.setEnabled(false); } } }); existingGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existingGraph.isSelected()) { newGraph.setSelected(false); chartOptions.setEnabled(true); } } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String function = functionField.getText(); Expression expr = null; try { expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function); expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.typeCheck(); expr.semanticCheck(); } catch (PrismLangException e1) { // for copying style JLabel label = new JLabel(); // html content in our case the error we want to show JEditorPane ep = new JEditorPane("text/html", "<html> There was an error parsing the function. To read about what built-in" + " functions are supported <br>and some more information on the functions, visit " + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>." + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } } }); ep.setEditable(false); ep.setBackground(label.getBackground()); // show the error dialog JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE); return; } if (radio2d.isSelected()) { ParametricGraph graph = null; if (newGraph.isSelected()) { graph = new ParametricGraph(""); } else { for (int i = 0; i < theTabs.getComponentCount(); i++) { if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) { graph = (ParametricGraph) theTabs.getComponent(i); } } } dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true); } else if (radio3d.isSelected()) { try { expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.semanticCheck(); expr.typeCheck(); } catch (PrismLangException e1) { e1.printStackTrace(); } if (expr.getAllConstants().size() < 2) { JOptionPane.showMessageDialog(dialog, "There are not enough variables in the function to plot a 3D chart!", "Error", JOptionPane.ERROR_MESSAGE); return; } // its always a new graph ParametricGraph3D graph = new ParametricGraph3D(expr); dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false); } dialog.dispose(); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // we will show info about the function when field is out of focus functionField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!functionField.getText().equals("")) { return; } functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); } @Override public void focusGained(FocusEvent e) { if (!functionField.getText().equals("Add function expression here....")) { return; } functionField.setForeground(Color.BLACK); functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setText(""); } }); // show the dialog dialog.setVisible(true); }
From source file:de.cismet.cids.custom.objecteditors.wunda_blau.WebDavPicturePanel.java
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The * content of this method is always regenerated by the Form Editor. *///from w w w .java 2 s.c o m @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { GridBagConstraints gridBagConstraints; bindingGroup = new BindingGroup(); final RoundedPanel pnlFotos = new RoundedPanel(); final SemiRoundedPanel pnlHeaderFotos = new SemiRoundedPanel(); final JLabel lblHeaderFotos = new JLabel(); final JPanel jPanel2 = new JPanel(); final JPanel jPanel1 = new JPanel(); final JScrollPane jspFotoList = new JScrollPane(); lstFotos = new JList(); final JPanel pnlCtrlButtons = new JPanel(); btnAddImg = new JButton(); btnRemoveImg = new JButton(); final JPanel pnlMap = new JPanel(); final RoundedPanel pnlVorschau = new RoundedPanel(); final SemiRoundedPanel semiRoundedPanel2 = new SemiRoundedPanel(); final JLabel lblVorschau = new JLabel(); final JPanel jPanel3 = new JPanel(); pnlFoto = new JPanel(); lblPicture = new JLabel(); lblBusy = new JXBusyLabel(new Dimension(75, 75)); final JPanel pnlCtrlBtn = new JPanel(); btnPrevImg = new JButton(); btnNextImg = new JButton(); final FormListener formListener = new FormListener(); setName("Form"); // NOI18N setOpaque(false); setLayout(new GridBagLayout()); pnlFotos.setMinimumSize(new Dimension(400, 200)); pnlFotos.setName("pnlFotos"); // NOI18N pnlFotos.setPreferredSize(new Dimension(400, 200)); pnlFotos.setLayout(new GridBagLayout()); pnlHeaderFotos.setBackground(new Color(51, 51, 51)); pnlHeaderFotos.setForeground(new Color(51, 51, 51)); pnlHeaderFotos.setName("pnlHeaderFotos"); // NOI18N pnlHeaderFotos.setLayout(new FlowLayout()); lblHeaderFotos.setForeground(new Color(255, 255, 255)); Mnemonics.setLocalizedText(lblHeaderFotos, NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.lblHeaderFotos.text")); // NOI18N lblHeaderFotos.setName("lblHeaderFotos"); // NOI18N pnlHeaderFotos.add(lblHeaderFotos); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; pnlFotos.add(pnlHeaderFotos, gridBagConstraints); jPanel2.setName("jPanel2"); // NOI18N jPanel2.setOpaque(false); jPanel2.setLayout(new GridBagLayout()); jPanel1.setName("jPanel1"); // NOI18N jPanel1.setOpaque(false); jPanel1.setLayout(new GridBagLayout()); jspFotoList.setMinimumSize(new Dimension(250, 130)); jspFotoList.setName("jspFotoList"); // NOI18N lstFotos.setMinimumSize(new Dimension(250, 130)); lstFotos.setName("lstFotos"); // NOI18N lstFotos.setPreferredSize(new Dimension(250, 130)); final ELProperty eLProperty = ELProperty.create("${cidsBean." + beanCollProp + "}"); final JListBinding jListBinding = SwingBindings.createJListBinding(AutoBinding.UpdateStrategy.READ_WRITE, this, eLProperty, lstFotos); bindingGroup.addBinding(jListBinding); lstFotos.addListSelectionListener(formListener); jspFotoList.setViewportView(lstFotos); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.anchor = GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jPanel1.add(jspFotoList, gridBagConstraints); pnlCtrlButtons.setName("pnlCtrlButtons"); // NOI18N pnlCtrlButtons.setOpaque(false); pnlCtrlButtons.setLayout(new GridBagLayout()); btnAddImg.setIcon(new ImageIcon( getClass().getResource("/de/cismet/cids/custom/objecteditors/wunda_blau/edit_add_mini.png"))); // NOI18N Mnemonics.setLocalizedText(btnAddImg, NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnAddImg.text")); // NOI18N btnAddImg.setBorderPainted(false); btnAddImg.setContentAreaFilled(false); btnAddImg.setName("btnAddImg"); // NOI18N btnAddImg.addActionListener(formListener); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.insets = new Insets(0, 0, 5, 0); pnlCtrlButtons.add(btnAddImg, gridBagConstraints); btnRemoveImg.setIcon(new ImageIcon( getClass().getResource("/de/cismet/cids/custom/objecteditors/wunda_blau/edit_remove_mini.png"))); // NOI18N Mnemonics.setLocalizedText(btnRemoveImg, NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnRemoveImg.text")); // NOI18N btnRemoveImg.setBorderPainted(false); btnRemoveImg.setContentAreaFilled(false); btnRemoveImg.setName("btnRemoveImg"); // NOI18N btnRemoveImg.addActionListener(formListener); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridy = 1; gridBagConstraints.insets = new Insets(5, 0, 0, 0); pnlCtrlButtons.add(btnRemoveImg, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.anchor = GridBagConstraints.NORTH; gridBagConstraints.insets = new Insets(0, 5, 0, 0); jPanel1.add(pnlCtrlButtons, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new Insets(10, 10, 10, 0); jPanel2.add(jPanel1, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new Insets(0, 0, 2, 0); pnlFotos.add(jPanel2, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.anchor = GridBagConstraints.NORTH; gridBagConstraints.insets = new Insets(0, 0, 5, 5); add(pnlFotos, gridBagConstraints); pnlMap.setBorder(BorderFactory.createEtchedBorder()); pnlMap.setMinimumSize(new Dimension(400, 200)); pnlMap.setName("pnlMap"); // NOI18N pnlMap.setPreferredSize(new Dimension(400, 200)); pnlMap.setLayout(new BorderLayout()); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.VERTICAL; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new Insets(5, 0, 0, 5); add(pnlMap, gridBagConstraints); pnlMap.add(map, BorderLayout.CENTER); pnlVorschau.setName("pnlVorschau"); // NOI18N pnlVorschau.setLayout(new GridBagLayout()); semiRoundedPanel2.setBackground(new Color(51, 51, 51)); semiRoundedPanel2.setName("semiRoundedPanel2"); // NOI18N semiRoundedPanel2.setLayout(new FlowLayout()); lblVorschau.setForeground(new Color(255, 255, 255)); Mnemonics.setLocalizedText(lblVorschau, NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.lblVorschau.text")); // NOI18N lblVorschau.setName("lblVorschau"); // NOI18N semiRoundedPanel2.add(lblVorschau); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; pnlVorschau.add(semiRoundedPanel2, gridBagConstraints); jPanel3.setName("jPanel3"); // NOI18N jPanel3.setOpaque(false); jPanel3.setLayout(new GridBagLayout()); pnlFoto.setName("pnlFoto"); // NOI18N pnlFoto.setOpaque(false); pnlFoto.setLayout(new GridBagLayout()); lblPicture.setHorizontalAlignment(SwingConstants.CENTER); Mnemonics.setLocalizedText(lblPicture, NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.lblPicture.text")); // NOI18N lblPicture.setName("lblPicture"); // NOI18N gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; pnlFoto.add(lblPicture, gridBagConstraints); lblBusy.setHorizontalAlignment(SwingConstants.CENTER); lblBusy.setMaximumSize(new Dimension(140, 40)); lblBusy.setMinimumSize(new Dimension(140, 60)); lblBusy.setName("lblBusy"); // NOI18N lblBusy.setPreferredSize(new Dimension(140, 60)); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; pnlFoto.add(lblBusy, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new Insets(10, 10, 0, 10); jPanel3.add(pnlFoto, gridBagConstraints); pnlCtrlBtn.setName("pnlCtrlBtn"); // NOI18N pnlCtrlBtn.setOpaque(false); pnlCtrlBtn.setPreferredSize(new Dimension(100, 50)); pnlCtrlBtn.setLayout(new GridBagLayout()); btnPrevImg.setIcon(new ImageIcon(getClass().getResource("/res/arrow-left.png"))); // NOI18N Mnemonics.setLocalizedText(btnPrevImg, NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnPrevImg.text")); // NOI18N btnPrevImg.setBorderPainted(false); btnPrevImg.setFocusPainted(false); btnPrevImg.setName("btnPrevImg"); // NOI18N btnPrevImg.addActionListener(formListener); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; pnlCtrlBtn.add(btnPrevImg, gridBagConstraints); btnNextImg.setIcon(new ImageIcon(getClass().getResource("/res/arrow-right.png"))); // NOI18N Mnemonics.setLocalizedText(btnNextImg, NbBundle.getMessage(WebDavPicturePanel.class, "WebDavPicturePanel.btnNextImg.text")); // NOI18N btnNextImg.setBorderPainted(false); btnNextImg.setFocusPainted(false); btnNextImg.setName("btnNextImg"); // NOI18N btnNextImg.addActionListener(formListener); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; pnlCtrlBtn.add(btnNextImg, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.insets = new Insets(0, 10, 10, 10); jPanel3.add(pnlCtrlBtn, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; pnlVorschau.add(jPanel3, gridBagConstraints); gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new Insets(0, 5, 0, 0); add(pnlVorschau, gridBagConstraints); bindingGroup.bind(); }
From source file:fs.MainWindow.java
public void GenerateTable(Object[][] data, String title, String subtitle, final String[] titles) { JFrame window = new JFrame(title); window.setLayout(new java.awt.BorderLayout(5, 5)); JLabel label = new JLabel(subtitle); label.setFont(new java.awt.Font("Tahoma", 1, 12)); label.setForeground(new java.awt.Color(0, 0, 255)); label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); label.setOpaque(true);/*from ww w. j av a 2 s . c o m*/ label.setPreferredSize(new java.awt.Dimension(50, 30)); ListModel lm = new AbstractListModel() { String headers[] = titles; @Override public int getSize() { return headers.length; } @Override public Object getElementAt(int index) { return headers[index]; } }; // String[] titles = getClasses(); JList rowHeader = new JList(lm); rowHeader.setFixedCellWidth(50); JTable jTable = new JTable(data, titles); rowHeader.setFixedCellHeight(jTable.getRowHeight()); rowHeader.setCellRenderer(new RowHeaderRenderer(jTable)); JScrollPane scroll = new JScrollPane(jTable); scroll.setRowHeaderView(rowHeader); getContentPane().add(scroll, BorderLayout.CENTER); jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jTable.setAlignmentX(JTable.CENTER_ALIGNMENT); window.add(label, java.awt.BorderLayout.NORTH); window.add(scroll, java.awt.BorderLayout.CENTER); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); window.setBounds((screenSize.width - 800) / 2, (screenSize.height - 270) / 2, 800, 270); window.setVisible(true); }
From source file:gui.GW2EventerGui.java
/** * Creates new form GW2EventerGui//from ww w .j av a 2 s .com */ public GW2EventerGui() { this.guiIcon = new ImageIcon(ClassLoader.getSystemResource("media/icon.png")).getImage(); if (System.getProperty("os.name").startsWith("Windows")) { this.OS = "Windows"; this.isWindows = true; } else { this.OS = "Other"; this.isWindows = false; } if (this.isWindows == true) { this.checkIniDir(); } initComponents(); this.speakQueue = new LinkedList(); this.speakRunnable = new Runnable() { @Override public void run() { String path = System.getProperty("user.home") + "\\.gw2eventer"; File f; String sentence; while (!speakQueue.isEmpty()) { f = new File(path + "\\tts.vbs"); if (!f.exists() && !f.isDirectory()) { sentence = (String) speakQueue.poll(); try { Writer writer = new OutputStreamWriter( new FileOutputStream( System.getProperty("user.home") + "\\.gw2eventer\\tts.vbs"), "ISO-8859-15"); BufferedWriter fout = new BufferedWriter(writer); fout.write("Dim Speak"); fout.newLine(); fout.write("Set Speak=CreateObject(\"sapi.spvoice\")"); fout.newLine(); fout.write("Speak.Speak \"" + sentence + "\""); fout.close(); Runtime rt = Runtime.getRuntime(); try { if (sentence.length() > 0) { Process p = rt.exec(System.getProperty("user.home") + "\\.gw2eventer\\tts.bat"); } } catch (IOException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } try { Thread.sleep(3000); } catch (InterruptedException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } else { try { Thread.sleep(1000); } catch (InterruptedException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } } } }; this.matchIds = new HashMap(); this.matchId = "2-6"; this.matchIdColor = "green"; this.jLabelNewVersion.setVisible(false); this.updateInformed = false; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(screenSize.width / 2 - this.getSize().width / 2, (screenSize.height / 2 - this.getSize().height / 2) - 20); double width = screenSize.getWidth(); double height = screenSize.getHeight(); if ((width == 1280) && (height == 720 || height == 768 || height == 800)) { this.setExtendedState(this.MAXIMIZED_BOTH); //this.setLocation(0, 0); } JSpinner.NumberEditor jsEditor = (JSpinner.NumberEditor) this.jSpinnerRefreshTime.getEditor(); DefaultFormatter formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); /* jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayX.getEditor(); formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); jsEditor = (JSpinner.NumberEditor)this.jSpinnerOverlayY.getEditor(); formatter = (DefaultFormatter) jsEditor.getTextField().getFormatter(); formatter.setAllowsInvalid(false); */ this.workingButton = this.jButtonRefresh; this.refreshSelector = this.jCheckBoxAutoRefresh; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { apiManager.saveSettingstoFile(); System.exit(0); } }); this.pushGui = new PushGui(this, true, "", ""); this.pushGui.setIconImage(guiIcon); this.donateGui = new DonateGui(this, true); this.donateGui.setIconImage(guiIcon); this.infoGui = new InfoGui(this, true); this.infoGui.setIconImage(guiIcon); this.feedbackGui = new FeedbackGui(this, true); this.feedbackGui.setIconImage(guiIcon); this.overlayGui = new OverlayGui(this); this.initOverlayGui(); this.settingsOverlayGui = new SettingsOverlayGui(this); this.initSettingsOverlayGui(); this.wvwOverlayGui = new WvWOverlayGui(this); this.initWvwOverlayGui(); this.language = "en"; this.worldID = "2206"; //Millersund [DE] this.setTranslations(); this.eventLabels = new ArrayList(); this.eventLabelsTimer = new ArrayList(); this.homeWorlds = new HashMap(); this.preventSystemSleep = true; for (int i = 1; i <= EVENT_COUNT; i++) { try { Field f = getClass().getDeclaredField("labelEvent" + i); JLabel l = (JLabel) f.get(this); l.setPreferredSize(new Dimension(70, 28)); //l.setToolTipText(""); //int width2 = l.getX(); //int height2 = l.getY(); //System.out.println("$coords .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";"); this.eventLabels.add(l); final int ii = i; l.addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mousePressed(java.awt.event.MouseEvent evt) { showSoundSelector(ii); } }); f = getClass().getDeclaredField("labelTimer" + i); l = (JLabel) f.get(this); l.setEnabled(true); l.setVisible(false); l.setForeground(Color.green); //int width2 = l.getX(); //int height2 = l.getY(); //System.out.println("$coords2 .= \"{\\\"x\\\": \\\""+ width2 + "\\\", \\\"y\\\": \\\""+ height2 + "\\\"},\\n\";"); this.eventLabelsTimer.add(l); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } int[] disabledEvents = { 6, 8, 11, 12, 17, 18, 19, 20, 21, 22 }; for (int i = 0; i < disabledEvents.length; i++) { Field f; JLabel l; try { f = getClass().getDeclaredField("labelEvent" + disabledEvents[i]); l = (JLabel) f.get(this); l.setEnabled(false); l.setVisible(false); f = getClass().getDeclaredField("labelTimer" + disabledEvents[i]); l = (JLabel) f.get(this); l.setEnabled(false); l.setVisible(false); } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(GW2EventerGui.class.getName()).log(Level.SEVERE, null, ex); } } this.lastPush = new Date(); if (this.apiManager == null) { this.apiManager = new ApiManager(this, this.jSpinnerRefreshTime, this.jCheckBoxAutoRefresh.isSelected(), this.eventLabels, this.language, this.worldID, this.homeWorlds, this.jComboBoxHomeWorld, this.jLabelServer, this.jLabelWorking, this.jCheckBoxPlaySounds.isSelected(), this.workingButton, this.refreshSelector, this.eventLabelsTimer, this.jComboBoxLanguage, this.overlayGui, this.jCheckBoxWvWOverlay); } //this.wvwMatchReader = new WvWMatchReader(this.matchIds, this.jCheckBoxWvW); //this.wvwMatchReader.start(); this.preventSleepMode(); this.runUpdateService(); this.runPushService(); this.runTips(); //this.runTest(); }
From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java
private void updateRowFilter() { @SuppressWarnings("unchecked") TableRowSorter<CurationTableModel> rowSorter = (TableRowSorter<CurationTableModel>) curationTable .getRowSorter();/* w w w. ja va2 s . c o m*/ onlyRowsWithScores = onlyRowsWithScoresCheckbox.isSelected(); boolean onlyUneditedBefore = onlyUncurated; onlyUncurated = onlyUneditedCheckbox.isSelected(); @SuppressWarnings("unused") boolean hideInactiveBefore = hideInactive; hideInactive = hideInactivePlots.isSelected(); JLabel label = curationTablePanel.separator.getLabel(); String msg; if (isAnyFilterActive()) { rowSorter.setRowFilter(plotFilter); label.setForeground(Color.RED); msg = PHRASE_SHOWING + curationTable.getRowCount() + " of " + curationTableModel.getRowCount(); } else { rowSorter.setRowFilter(null); label.setForeground(Color.DARK_GRAY); msg = PHRASE_SHOWING_ALL + +curationTable.getRowCount(); } curationTable.setRowSorter(rowSorter); if (onlyUneditedBefore != onlyUncurated) { curationTableModel.setUsingOnlyUnedited(onlyUncurated); } // Allow filter to be applied before updating SwingUtilities.invokeLater(new Runnable() { @Override public void run() { label.setToolTipText(msg); label.setText(msg); } }); }
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 a v a2 s .c o 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; }