public void disableAll() { for (int i = 0; i < relComponents.length; i++) { relComponents[i].getJComponent().setEnabled(false); if (relComponents[i] instanceof LabelPair) { LabelPair lp = (LabelPair) relComponents[i]; lp.getLabel().setEnabled(false); } } commentPane.setEnabled(false); }
private void enableRelationType() { disableAll(); LABELS[] l = Constants.getLabels(relComponents[LABELS.rel.ordinal()].getAnnValue()); for (int i = 0; i < l.length; i++) { relComponents[l[i].ordinal()].getJComponent().setEnabled(true); if (relComponents[l[i].ordinal()] instanceof LabelPair) { LabelPair lp = (LabelPair) relComponents[l[i].ordinal()]; lp.getLabel().setEnabled(true); } } if (relComponents[LABELS.rel.ordinal()].getAnnValue().equals(RELTYPELABELS.Implicit.toString()) && relComponents[LABELS.conn1.ordinal()].getAnnValue().equals("")) { relComponents[LABELS.sClass1B.ordinal()].getJComponent().setEnabled(false); relComponents[LABELS.conn2.ordinal()].getJComponent().setEnabled(false); relComponents[LABELS.sClass2A.ordinal()].getJComponent().setEnabled(false); relComponents[LABELS.sClass2B.ordinal()].getJComponent().setEnabled(false); } if (relComponents[LABELS.sClass1A.ordinal()].getAnnValue().equals("")) { relComponents[LABELS.sClass1B.ordinal()].getJComponent().setEnabled(false); } if (relComponents[LABELS.rel.ordinal()].getAnnValue().equals(RELTYPELABELS.Implicit.toString()) && relComponents[LABELS.conn2.ordinal()].getAnnValue().equals("")) { relComponents[LABELS.sClass2A.ordinal()].getJComponent().setEnabled(false); relComponents[LABELS.sClass2B.ordinal()].getJComponent().setEnabled(false); } if (relComponents[LABELS.sClass2A.ordinal()].getAnnValue().equals("")) { relComponents[LABELS.sClass2B.ordinal()].getJComponent().setEnabled(false); } /** Remove connective span/site if it violates the relation type */ String relType = relComponents[LABELS.rel.ordinal()].getAnnValue(); String connSpanList = relComponents[LABELS.connSpanList.ordinal()].getAnnValue(); if (SpanList.isSpanList(connSpanList) && (relType.equals(RELTYPELABELS.Implicit.toString()) || relType.equals(RELTYPELABELS.EntRel.toString()) || relType.equals(RELTYPELABELS.NoRel.toString()))) { relComponents[LABELS.connSpanList.ordinal()].setAnnValue(""); } else if (!SpanList.isSpanList(connSpanList) && (relType.equals(RELTYPELABELS.Explicit.toString()) || relType.equals(RELTYPELABELS.AltLex.toString()))) { relComponents[LABELS.connSpanList.ordinal()].setAnnValue(""); } commentPane.setEnabled(true); }
private void addRow(LABELS[] labels) { JPanel p = new JPanel(); p.setAlignmentX(LEFT_ALIGNMENT); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); // p.setBorder(BorderFactory.createTitledBorder("panel"));// for (int i = 0; i < labels.length; i++) { AnnComponent ac = relComponents[labels[i].ordinal()]; if (ac instanceof LabelPair) { LabelPair lp = (LabelPair) ac; p.add(lp.getLabel()); p.add(Box.createHorizontalStrut(2)); } else if (ac instanceof CheckboxComponent) { CheckboxComponent cc = (CheckboxComponent) ac; p.add(cc.getJLabel()); p.add(Box.createHorizontalStrut(2)); } p.add(ac.getContainer()); if (i < labels.length - 1) { p.add(Box.createHorizontalStrut(Constants.spacing)); } } addRow(p, 0); }
void updateTheLabel(DocumentEvent e) { Document doc = (Document) e.getDocument(); String text = null; try { text = doc.getText(0, doc.getLength()); doc = null; } catch (BadLocationException ex) { text = null; } if (text != null) { try { double number = Double.parseDouble(text); if (number > 1) { label.setText(labelPair.getPlural()); } else { label.setText(labelPair.getSingular()); } } catch (NumberFormatException ex) { // Do nothing } finally { text = null; } } }
public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) { GridBagLayout gridbag = (GridBagLayout) getLayout(); labelPair = lp; label = new JLabel(labelPair.getSingular(), JLabel.LEFT); pane.getDocument().addDocumentListener(this); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 20, 0, 00); gridbag.setConstraints(pane, c); add(pane); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 20); gridbag.setConstraints(label, c); add(label); JPanel filler = new JPanel(); filler.setBackground(white); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.8; c.weighty = 0.8; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_END; gridbag.setConstraints(filler, c); add(filler); filler = null; c = null; }