use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.
the class TableChartAttributePlugin method getAttributePreferenciesEditor.
@Override
public AttributePreferenciesEditor getAttributePreferenciesEditor() {
return new AttributePreferenciesEditor() {
private RowTreeTableComponent component;
@Override
public JComponent createComponent(Attribute attribute, Engine engine, AccessRules accessRules) {
component = new RowTreeTableComponent(engine, ChartPlugin.getCharts(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
component.setSelectType(SelectType.RADIO);
return component;
}
@Override
public boolean canApply() {
return component.getModel().getSelectedRows().size() > 0;
}
@Override
public void apply(Attribute attribute, Engine engine, AccessRules accessRules) {
Row row = component.getModel().getSelectedRows().get(0);
TableChartPersistent tcp = new TableChartPersistent();
tcp.setOtherElementId(row.getElementId());
engine.setAttribute(null, attribute, tcp);
}
};
}
use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.
the class ChartsView method createComponent.
@Override
public JComponent createComponent() {
Engine engine = framework.getEngine();
AccessRules accessRules = framework.getAccessRules();
component = new RowTreeTableComponent(engine, ChartPlugin.getCharts(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
component.getTable().addSelectionListener(new SelectionListener() {
@Override
public void changeSelection(SelectionEvent event) {
TreeTableNode selectedNode = component.getTable().getSelectedNode();
if (selectedNode == null)
chartPrefernecesAction.setEnabled(false);
else {
Row row = selectedNode.getRow();
chartPrefernecesAction.setEnabled(row != null);
}
openChartAction.setEnabled(chartPrefernecesAction.isEnabled());
deleteChartAction.setEnabled(chartPrefernecesAction.isEnabled());
}
});
table = component.getTable();
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
openDiagram();
} else {
if ((e.getClickCount() == 1) && (System.currentTimeMillis() - lastClickTime < EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, table.getSelectedRows()))) {
if (!table.isEditing()) {
editTableField();
}
} else {
lastClickTime = System.currentTimeMillis();
lastSelectedRows = table.getSelectedRows();
}
}
}
}
});
table.setEditIfNullEvent(false);
table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
table.getActionMap().put("EditCell", new AbstractAction() {
/**
*/
private static final long serialVersionUID = 3229634866196074563L;
@Override
public void actionPerformed(ActionEvent e) {
if ((table.getSelectedRow() >= 0) && (table.getSelectedColumn() >= 0))
editTableField();
}
});
table.setExportRows(true);
return component;
}
use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.
the class AttributePullView method createComponent.
@Override
public JComponent createComponent() {
component = new RowTreeTableComponent(engine, attributeQualifier, rules, new RowRootCreater(), new Attribute[] { attributeName, attributeTypeName }, framework);
table = component.getTable();
component.getModel().setEditable(1, false);
((AbstractTableModel) table.getModel()).fireTableStructureChanged();
Attribute type = (Attribute) engine.getPluginProperty("Core", StandardAttributesPlugin.ATTRIBUTE_TYPE_NAME);
final Hashtable<String, String> names = new Hashtable<String, String>();
for (AttributeType type2 : engine.getAttributeTypes()) {
AttributePlugin plugin = framework.findAttributePlugin(type2);
try {
String key = "AttributeType." + type2.toString();
names.put(key, plugin.getString(key));
} catch (Exception e) {
e.printStackTrace();
}
}
String key = "AttributeType.Core.ElementList";
names.put(key, GlobalResourcesManager.getString(key));
component.getModel().setAttributeLocalizer(new RowTreeTableModel.Localizer() {
@Override
public Object getValue(Object key) {
if (key == null)
return "Anknown attribute type";
return names.get("AttributeType." + key.toString());
}
}, type);
table.getTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
refreshActions();
}
});
rowSet = component.getRowSet();
table.setEditIfNullEvent(false);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
setupAttribute();
}
}
}
});
refreshActions();
table.setComponentPopupMenu(createJPopupMenu());
return component;
}
use of com.ramussoft.gui.qualifier.table.RowRootCreater in project ramus by Vitaliy-Yakovchuk.
the class ChartSetsView method createComponent.
@Override
public JComponent createComponent() {
Engine engine = framework.getEngine();
AccessRules accessRules = framework.getAccessRules();
component = new RowTreeTableComponent(engine, ChartPlugin.getChartSets(engine), accessRules, new RowRootCreater(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework);
table = component.getTable();
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
if ((e.getClickCount() % 2 == 0) && (e.getClickCount() > 0)) {
openChartSet();
} else {
if ((e.getClickCount() == 1) && (System.currentTimeMillis() - lastClickTime < EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, table.getSelectedRows()))) {
if (!table.isEditing()) {
editTableField();
}
} else {
lastClickTime = System.currentTimeMillis();
lastSelectedRows = table.getSelectedRows();
}
}
}
}
});
table.addSelectionListener(new SelectionListener() {
@Override
public void changeSelection(SelectionEvent event) {
TreeTableNode selectedNode = component.getTable().getSelectedNode();
if (selectedNode == null)
openChartSetAction.setEnabled(false);
else {
Row row = selectedNode.getRow();
openChartSetAction.setEnabled(row != null);
}
deleteChartSetAction.setEnabled(openChartSetAction.isEnabled());
}
});
table.setEditIfNullEvent(false);
table.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
table.getActionMap().put("EditCell", new AbstractAction() {
/**
*/
private static final long serialVersionUID = 3229634866196074563L;
@Override
public void actionPerformed(ActionEvent e) {
if ((table.getSelectedRow() >= 0) && (table.getSelectedColumn() >= 0))
editTableField();
}
});
return component;
}
Aggregations