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); }