use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class QueryView method getQuery.
public Query getQuery() {
if (selectableTableView == null)
return null;
Query query = new Query(new HashMap<String, String>(0));
List<Row> rows = selectableTableView.getSelectedRows();
ArrayList<Element> elements = new ArrayList<Element>(rows.size());
for (Row row : rows) elements.add(row.getElement());
query.setElements(elements);
return query;
}
use of com.ramussoft.database.common.Row 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;
}
use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class ChartSetsView method deleteDiagram.
public void deleteDiagram() {
List<Row> rows = new ArrayList<Row>();
int[] sels = table.getSelectedRows();
for (int i : sels) {
TreePath path = table.getPathForRow(i);
if (path != null) {
TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
if (node != null) {
Row row = node.getRow();
if (row != null)
rows.add(row);
}
}
}
if (rows.size() > 0) {
if (JOptionPane.showConfirmDialog(component, GlobalResourcesManager.getString("DeleteActiveElementsDialog.Warning"), GlobalResourcesManager.getString("ConfirmMessage.Title"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return;
Engine engine = framework.getEngine();
((Journaled) engine).startUserTransaction();
for (Row row : rows) engine.deleteElement(row.getElementId());
((Journaled) engine).commitUserTransaction();
}
}
use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class ChartSetsView method deleteChartSet.
public void deleteChartSet() {
List<Row> rows = new ArrayList<Row>();
int[] sels = table.getSelectedRows();
for (int i : sels) {
TreePath path = table.getPathForRow(i);
if (path != null) {
TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
if (node != null) {
Row row = node.getRow();
if (row != null)
rows.add(row);
}
}
}
if (rows.size() > 0) {
if (JOptionPane.showConfirmDialog(component, GlobalResourcesManager.getString("DeleteActiveElementsDialog.Warning"), GlobalResourcesManager.getString("ConfirmMessage.Title"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION)
return;
Engine engine = framework.getEngine();
((Journaled) engine).startUserTransaction();
for (Row row : rows) ChartPlugin.deleteChartSet(engine, row.getElement());
((Journaled) engine).commitUserTransaction();
}
}
use of com.ramussoft.database.common.Row in project ramus by Vitaliy-Yakovchuk.
the class OtherElementTableCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int rowIndex, int columnIndex) {
this.table = table;
if (value instanceof String) {
Row r = rowSet.findRow((String) value);
if (r != null)
value = r.getElementId();
else
value = null;
}
if (value instanceof Long) {
value = new RowAttributeWrapper(rowSet.findRow((Long) value), nameAttribute);
}
this.value = value;
if (value != null)
this.value = ((RowAttributeWrapper) value).getRow().getElementId();
Row row = (value != null) ? ((RowAttributeWrapper) value).getRow() : null;
if (row == null) {
codeField.setText("");
valueField.setText("");
} else {
codeField.setText(row.getCode());
valueField.setText(value.toString());
valueField.setCaretPosition(0);
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
codeField.selectAll();
codeField.requestFocus();
}
});
if (table instanceof ElementsTable) {
element = ((ElementsTable) table).getElementForRow(rowIndex);
}
return component;
}
Aggregations