use of com.ramussoft.gui.qualifier.table.RowTreeTableComponent 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.RowTreeTableComponent in project ramus by Vitaliy-Yakovchuk.
the class ModelsPanel method init.
private void init() {
tree = new RowTreeTableComponent(engine, IDEF0Plugin.getModelTree(engine), framework.getAccessRules(), new ModelRowCreator(), new Attribute[] { StandardAttributesPlugin.getAttributeNameAttribute(engine) }, framework) {
@Override
protected RowTreeTableModel createRowTreeTableModel(final Engine engine, Qualifier qualifier, AccessRules accessRules, RootCreater rootCreater, Attribute[] attributes, GUIFramework framework) {
RowTreeTableModel rowTreeTableModel = new RowTreeTableModel(engine, qualifier, attributes, accessRules, rootCreater, framework) {
@Override
protected RowNode newRowNode(Row row) {
Long id = (Long) row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine));
if (id != null) {
Qualifier qualifier = engine.getQualifier(id);
if (qualifier != null) {
ModelsNode node = newModelsNode(row, qualifier);
node.getTreeTableModel().setTable(tree.getTable());
node.getTreeTableModel().setModelSupport(tree.getModel().getModelSupport());
return node;
}
}
return super.newRowNode(row);
}
@Override
public boolean isCellEditable(Object node, int column) {
if (super.isCellEditable(node, column)) {
if (node instanceof ModelsNode)
return true;
}
return false;
}
};
return rowTreeTableModel;
}
@Override
protected RowTreeTable createTable(AccessRules accessRules, GUIFramework framework, AttributePlugin[] plugins) {
return new RowTreeTable(accessRules, model.getRowSet(), plugins, framework, model) {
long treeModelsId = IDEF0Plugin.getModelTree(engine).getId();
@Override
public Transferable createTransferable() {
final int[] is = getSelectedRows();
final ArrayList<Integer> al = new ArrayList<Integer>();
long id = IDEF0Plugin.getModelTree(engine).getId();
Rows rows = new Rows();
for (final int i : is) {
al.add(i);
TreeTableNode node = (TreeTableNode) getPathForRow(i).getLastPathComponent();
if ((node != null) && (node.getRow() != null)) {
Row row = node.getRow();
rows.add(row);
if (row.getElement().getQualifierId() != id)
return null;
}
}
exporting = true;
return new ArrayTransferable(al, rows);
}
@Override
public boolean importData(Transferable t, boolean on, int aIndex) {
int index = aIndex;
long id = IDEF0Plugin.getModelTree(engine).getId();
if (index >= getRowCount())
index--;
if (index < 0)
return false;
TreeTableNode node = (TreeTableNode) getPathForRow(index).getLastPathComponent();
if (node.getRow() != null)
if (node.getRow().getElement().getQualifierId() != id)
return false;
return super.importData(t, on, aIndex);
}
@Override
protected Icon getDefaultIcon(Row row) {
if (row.getElement().getQualifierId() != treeModelsId) {
if (row.getChildCount() == 0)
return note;
else
return function;
}
if (row.getAttribute(StandardAttributesPlugin.getAttributeQualifierId(engine)) == null)
return null;
return ModelsPanel.this.model;
}
};
}
};
fixTable((TreeTableNode) tree.getModel().getRoot());
tree.getTable().addMouseListener(new MouseAdapter() {
private int[] lastSelectedRows;
private long lastClickTime;
@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 < QualifierView.EDIT_NAME_CLICK_DELAY) && (Arrays.equals(lastSelectedRows, tree.getTable().getSelectedRows()))) {
if (!tree.getTable().isEditing()) {
editTableField();
}
} else {
lastClickTime = System.currentTimeMillis();
lastSelectedRows = tree.getTable().getSelectedRows();
}
}
}
}
});
tree.getTable().setEditIfNullEvent(false);
tree.getTable().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "EditCell");
tree.getTable().getActionMap().put("EditCell", new AbstractAction() {
/**
*/
private static final long serialVersionUID = 3229634866196074563L;
@Override
public void actionPerformed(ActionEvent e) {
if ((tree.getTable().getSelectedRow() >= 0) && (tree.getTable().getSelectedColumn() >= 0))
editTableField();
}
});
JScrollPane pane = new JScrollPane();
pane.setViewportView(tree);
this.add(pane, BorderLayout.CENTER);
}
use of com.ramussoft.gui.qualifier.table.RowTreeTableComponent 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.RowTreeTableComponent 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.RowTreeTableComponent 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