use of com.ramussoft.gui.qualifier.table.SelectType in project ramus by Vitaliy-Yakovchuk.
the class ElistTabView method createComponent.
@Override
public JComponent createComponent() {
final Engine engine = framework.getEngine();
AccessRules rules = framework.getAccessRules();
ElementListPropertyPersistent p = (ElementListPropertyPersistent) engine.getAttribute(null, elementList);
boolean addListener = q1 == null;
q1 = engine.getQualifier(p.getQualifier1());
q2 = engine.getQualifier(p.getQualifier2());
readOnly = !((rules.canUpdateAttribute(q1.getId(), elementList.getId())) && (rules.canUpdateAttribute(q2.getId(), elementList.getId())));
if (addListener) {
engine.addElementAttributeListener(q1, leftAttributeListener);
engine.addElementAttributeListener(q2, rightAttributeListener);
}
left = new ElistPanel(framework, engine, rules, q1, elementList) {
@Override
public String getPropertiesPrefix() {
return "left" + elementList.getId();
}
@Override
public void changeSelection(SelectionEvent event) {
ElistTabView.this.changeSelection(this, event);
}
@Override
public JComponent createComponent() {
unique = null;
if (getComponent() != null) {
left.clearSelection();
left.setSelectType(SelectType.RADIO);
right.clearSelection();
right.setSelectType(SelectType.RADIO);
}
JComponent component2 = super.createComponent();
getComponent().getPane().getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
comp.repaint();
}
});
getComponent().getTable().getModel().addTableModelListener(modelListener);
getComponent().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@SuppressWarnings("unchecked")
@Override
public void valueChanged(ListSelectionEvent e) {
TreeTableNode node = left.getComponent().getTable().getSelectedNode();
if ((node != null) && (node.getRow() != null)) {
leftElement = node.getRow().getElement();
leftValue = (List<ElementListPersistent>) engine.getAttribute(leftElement, elementList);
if (unique == null)
rightValue = null;
} else
leftValue = null;
comp.repaint();
}
});
return component2;
}
@Override
public void setSelectType(SelectType selectType) {
if ((!readOnly) || (selectType.equals(SelectType.NONE)))
super.setSelectType(selectType);
}
};
right = new ElistPanel(framework, engine, rules, q2, elementList) {
@Override
public String getPropertiesPrefix() {
return "right" + elementList.getId();
}
@Override
public void changeSelection(SelectionEvent event) {
ElistTabView.this.changeSelection(this, event);
}
@Override
public JComponent createComponent() {
unique = null;
if (getComponent() != null) {
left.clearSelection();
left.setSelectType(SelectType.RADIO);
right.clearSelection();
right.setSelectType(SelectType.RADIO);
}
JComponent component2 = super.createComponent();
getComponent().getPane().getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
comp.repaint();
}
});
getComponent().getTable().getModel().addTableModelListener(modelListener);
getComponent().getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@SuppressWarnings("unchecked")
@Override
public void valueChanged(ListSelectionEvent e) {
TreeTableNode node = right.getComponent().getTable().getSelectedNode();
if ((node != null) && (node.getRow() != null)) {
rightElement = node.getRow().getElement();
rightValue = (List<ElementListPersistent>) engine.getAttribute(rightElement, elementList);
if (unique == null)
leftValue = null;
} else
rightValue = null;
comp.repaint();
}
});
return component2;
}
@Override
public void setSelectType(SelectType selectType) {
if ((!readOnly) || (selectType.equals(SelectType.NONE)))
super.setSelectType(selectType);
}
};
JSplitPane pane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
pane1.setRightComponent(rightContainer);
comp.setBackground(Color.white);
pane1.setLeftComponent(comp);
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
pane.setLeftComponent(leftContainer);
Properties properties = engine.getProperties(getProperiesName());
revert = Options.getBoolean("REVERT", false, properties);
revertAction.putValue(Action.SELECTED_KEY, revert);
addPanels();
JPanel panel = new JPanel(new BorderLayout());
panel.add(pane1, BorderLayout.CENTER);
pane.setRightComponent(panel);
component = new JPanel(new BorderLayout());
component.add(pane, BorderLayout.CENTER);
Options.loadOptions(component, properties);
if (readOnly) {
left.setSelectType(SelectType.NONE);
right.setSelectType(SelectType.NONE);
}
return component;
}
Aggregations