use of com.ramussoft.core.attribute.simple.ElementListPropertyPersistent in project ramus by Vitaliy-Yakovchuk.
the class ElementListPreferenciesEditor method apply.
@Override
public void apply(Attribute attribute, Engine engine, AccessRules accessRules) {
ElementListPropertyPersistent p = new ElementListPropertyPersistent();
p.setQualifier1(((Qualifier) box1.getSelectedItem()).getId());
p.setQualifier2(((Qualifier) box2.getSelectedItem()).getId());
p.setConnectionTypes(variantsArea.getText());
engine.setAttribute(null, attribute, p);
}
use of com.ramussoft.core.attribute.simple.ElementListPropertyPersistent in project ramus by Vitaliy-Yakovchuk.
the class HTTPParser method printMatrixProjection.
private void printMatrixProjection() throws IOException {
final String sId = (String) params.get("matrixid");
if (sId == null) {
printMatrixError();
return;
}
final Long id = Long.parseLong(sId);
if (id == null) {
printMatrixError();
return;
}
Engine engine = dataPlugin.getEngine();
Attribute mp = engine.getAttribute(id);
if (mp == null) {
printMatrixError();
return;
}
htmlTitle = RES.getString("matrixProjection") + " " + mp.getName();
printStartD();
boolean rotate = "true".equals(params.get("rotate"));
htmlStream.print("<center><h2 class=\"Ramus\">" + RES.getString("matrixProjection") + ": " + mp.getName() + "</h2></center>");
htmlStream.println("<table width=100%>");
htmlStream.println("<tr>");
htmlStream.println("<td valign=top align=center width=50%>");
ElementListPropertyPersistent pp = (ElementListPropertyPersistent) engine.getAttribute(null, mp);
Qualifier qualifier1 = engine.getQualifier(pp.getQualifier1());
Qualifier qualifier2 = engine.getQualifier(pp.getQualifier2());
if (rotate) {
Qualifier tmp = qualifier1;
qualifier1 = qualifier2;
qualifier2 = tmp;
}
htmlStream.println("<table border=1 width=100%>");
List<Row> rows = (List) dataPlugin.getRowSet(qualifier1.getId()).getAllRows();
printMainTableTitle(qualifier1.getName());
final Row leftRow = loadRowById();
for (int i = 0; i < rows.size(); i++) {
final Row row = (Row) rows.get(i);
final boolean gray = i % 2 == 0;
String sGray = "";
String bs = "";
String be = "";
if (row.equals(leftRow)) {
bs = "<i>";
be = "</i>";
}
if (gray)
sGray = " bgcolor=" + GRAY;
String href = "matrixprojections/index.html?id=" + row.getGlobalId().toString() + "&matrixid=" + sId + (rotate ? "&rotate=true" : "");
htmlStream.print("<tr>");
htmlStream.print("<td" + sGray + ">");
printStartATeg("rows/index.html?id=" + row.getElement().getId());
htmlStream.print("^");
printEndATeg();
printStartATeg(href);
htmlStream.print(bs);
printRowKod(row, false, IDEF0Plugin.isFunction(qualifier1));
htmlStream.print(be);
if (href != null)
printEndATeg();
htmlStream.print("</td>");
htmlStream.print("<td" + sGray + ">");
printStartATeg(href);
htmlStream.print(bs);
printRowName(row, false);
htmlStream.print(be);
if (href != null)
printEndATeg();
htmlStream.print("</td>");
htmlStream.println("</tr>");
}
htmlStream.println("</table>");
htmlStream.println("</td>");
htmlStream.println("<td valign=top align=center width=50%>");
final String row2Name = qualifier2.getName() + " (" + RES.getString("addedElements") + (leftRow == null ? "" : " " + leftRow.getKod() + ". " + leftRow.getName()) + ")";
if (leftRow != null) {
List<ElementListPersistent> left = (List<ElementListPersistent>) engine.getAttribute(leftRow.getElement(), mp);
final Vector v = new Vector();
for (ElementListPersistent p : left) {
if (rotate) {
v.add(dataPlugin.findRowByGlobalId(p.getElement1Id()));
} else {
v.add(dataPlugin.findRowByGlobalId(p.getElement2Id()));
}
}
printElements(row2Name, v.toArray(), null);
} else {
htmlStream.println("<table width=100%>");
htmlStream.println("<caption>");
printSmallTitle(row2Name);
htmlStream.println("</caption>");
htmlStream.println("</table>");
}
htmlStream.println("</td>");
htmlStream.println("</tr>");
htmlStream.println("</table>");
String href = "matrixprojections/index.html?matrixid=" + sId;
if (!rotate)
href += "&rotate=" + "true";
htmlStream.println("<p align=right>");
printStartATeg(href);
htmlStream.println(RES.getString("rotate"));
printEndATeg();
htmlStream.println("</p>");
printEndD();
}
use of com.ramussoft.core.attribute.simple.ElementListPropertyPersistent in project ramus by Vitaliy-Yakovchuk.
the class ElementListAttributeViewer method printAttribute.
@Override
public void printAttribute(PrintStream printStream, DataPlugin dataPlugin, Element element, Attribute attribute, HTTPParser parser, AttributeViewerCallback callback) throws IOException {
Engine engine = dataPlugin.getEngine();
Qualifier qualifier = engine.getQualifier(element.getQualifierId());
List<ElementListPersistent> list = (List<ElementListPersistent>) engine.getAttribute(element, attribute);
ElementListPropertyPersistent pp = (ElementListPropertyPersistent) engine.getAttribute(null, attribute);
boolean left = qualifier.getId() == pp.getQualifier2();
if (list.size() > 0) {
callback.beforePrint(printStream);
printStream.println("<br>");
for (ElementListPersistent p : list) {
long id;
if (left)
id = p.getElement1Id();
else
id = p.getElement2Id();
Element element2 = engine.getElement(id);
if (element2 != null) {
printLinkToElement(element2, parser, printStream);
printStream.println("<br>");
}
}
callback.afterPrint(printStream);
}
}
use of com.ramussoft.core.attribute.simple.ElementListPropertyPersistent 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;
}
use of com.ramussoft.core.attribute.simple.ElementListPropertyPersistent in project ramus by Vitaliy-Yakovchuk.
the class ElementListPlugin method createSyncAttribute.
@Override
public Attribute createSyncAttribute(Engine engine, QualifierImporter importer, Attribute sourceAttribute) {
ElementListPropertyPersistent pp = (ElementListPropertyPersistent) importer.getSourceValue(null, sourceAttribute);
if (pp == null)
return null;
Qualifier left = null;
Qualifier right = null;
for (Qualifier q : importer.getSourceQualifiers()) {
if (q.getId() == pp.getQualifier1())
left = q;
if (q.getId() == pp.getQualifier2())
right = q;
}
if ((left != null) && (right != null)) {
Qualifier qualifier1 = importer.getDestination(left);
Qualifier qualifier2 = importer.getDestination(right);
Attribute result = null;
List<Attribute> attributes = engine.getAttributes();
for (Attribute attr : attributes) {
if (isSameAttribute(sourceAttribute, attr)) {
ElementListPropertyPersistent dpp = (ElementListPropertyPersistent) engine.getAttribute(null, attr);
if ((dpp != null) && (dpp.getQualifier1() == qualifier1.getId()) && (dpp.getQualifier2() == qualifier2.getId())) {
result = attr;
break;
}
}
}
if (result != null)
return result;
result = engine.createAttribute(sourceAttribute.getAttributeType());
result.setName(sourceAttribute.getName());
engine.updateAttribute(result);
ElementListPropertyPersistent dpp = new ElementListPropertyPersistent();
dpp.setQualifier1(qualifier1.getId());
dpp.setQualifier2(qualifier2.getId());
engine.setAttribute(null, result, dpp);
}
return null;
}
Aggregations