use of com.ramussoft.gui.qualifier.table.Rows 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.Rows in project ramus by Vitaliy-Yakovchuk.
the class ChartSetView method createComponent.
@Override
public JComponent createComponent() {
final JLabel label = new JLabel(ChartResourceManager.getString("Message.MoveChartToChartSet"));
desktop = new JDesktopPane();
desktop.setTransferHandler(new TransferHandler("") {
/**
*/
private static final long serialVersionUID = 4967256166603971141L;
@Override
public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
for (DataFlavor flavor : transferFlavors) {
if (flavor.equals(RowTreeTable.rowsListFlavor)) {
return true;
}
}
return false;
}
@Override
public boolean importData(JComponent comp, Transferable t) {
try {
Rows rows = (Rows) t.getTransferData(RowTreeTable.rowsListFlavor);
if (rows.size() > 0) {
((Journaled) engine).startUserTransaction();
for (Row row : rows) {
Point position = comp.getMousePosition();
if (position == null)
position = new Point(10, 10);
ChartPlugin.addChartLink(engine, element, row.getElement(), position.getX(), position.getY(), 340, 300);
}
}
((Journaled) engine).commitUserTransaction();
return rows.size() > 0;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
});
label.setBackground(desktop.getBackground());
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
List<ChartBounds> bounds = ChartPlugin.getChartBounds(engine, element);
for (ChartBounds cb : bounds) {
final JInternalFrame frame = new JInternalFrame(cb.getChart().getName(), true, true, true, true);
final ChartView chartView = new ChartView(framework, cb.getChart()) {
protected void titleChanged(String newTitle) {
frame.setTitle(newTitle);
reload();
}
};
final ChartBounds b = cb;
frame.setSize((int) cb.getWidth(), (int) cb.getHeight());
frame.setLocation((int) cb.getX(), (int) cb.getY());
frame.setContentPane(chartView.createComponent());
desktop.add(frame);
frame.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ChartHolder holder = new ChartHolder(chartView, frame, b.getLink());
holders.add(holder);
}
});
}
return desktop;
}
use of com.ramussoft.gui.qualifier.table.Rows in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method setActiveFunction.
/**
* Задає значення активного на блоку (того який являється базовим для
* решти).
*
* @param activeFunction Значення активної функції.
*/
public void setActiveFunction(final Function activeFunction) {
synchronized (backgroundPaintlock) {
bImage = null;
}
String size = activeFunction.getPageSize();
initSize(size);
if (panel != null) {
cancelAdding();
panel.setMovingAreaSize(zoom);
}
if (activeFunction.getType() >= Function.TYPE_EXTERNAL_REFERENCE)
return;
textPaintCache.clear();
if (activeFunction.getDecompositionType() == DIAGRAM_TYPE_DFDS) {
DropTarget dropTarget = new DropTarget();
this.setDropTarget(dropTarget);
try {
dropTarget.addDropTargetListener(new DropTargetAdapter() {
@Override
public void drop(DropTargetDropEvent event) {
if (event.getTransferable().isDataFlavorSupported(RowTreeTable.rowsListFlavor)) {
try {
event.acceptDrop(event.getSourceActions());
Rows rows = (Rows) event.getTransferable().getTransferData(RowTreeTable.rowsListFlavor);
FloatPoint point = toPoint(event.getLocation().x, event.getLocation().y);
Function owner = null;
for (MovingPanel panel : panels) if (panel instanceof DFDSFunction && panel.contain(point)) {
owner = ((DFDSFunction) panel).getFunction();
}
startUserTransaction();
Function function = createFunctionalObject(getDoubleOrdinate(event.getLocation().getX()), getDoubleOrdinate(event.getLocation().getY()), Function.TYPE_DFDS_ROLE, activeFunction);
RectangleVisualOptions ops = IDEF0Plugin.getDefaultRectangleVisualOptions(dataPlugin.getEngine(), rows.get(0).getElement());
if (ops != null) {
FRectangle rect = function.getBounds();
rect.setHeight(ops.bounds.getHeight());
rect.setWidth(ops.bounds.getWidth());
function.setBounds(rect);
function.setFont(ops.font);
function.setBackground(ops.background);
function.setForeground(ops.foreground);
}
Stream stream = (Stream) dataPlugin.createRow(dataPlugin.getBaseStream(), true);
Row[] rows2 = new Row[rows.size()];
for (int i = 0; i < rows2.length; i++) rows2[i] = dataPlugin.findRowByGlobalId(rows.get(i).getElementId());
stream.setRows(rows2);
function.setLink(stream.getElement().getId());
if (owner != null) {
function.setOwner(owner);
DFDSFunction function2 = findDFDSFunction(owner);
List<Function> roles = getRoles(function2);
if (!roles.contains(function))
roles.add(function);
if (function2 != null)
function2.justifyRoles(roles);
}
commitUserTransaction();
panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, activeFunction);
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else
event.rejectDrop();
}
});
} catch (TooManyListenersException e) {
e.printStackTrace();
}
} else
this.setDropTarget(null);
if (rec)
return;
rec = true;
if (panel != null) {
boolean locked;
if (activeFunction.equals(lockedFunction))
locked = true;
else
locked = activeFunction.lock();
refactor.loadFromFunction(activeFunction, false);
if (!activeFunction.equals(lockedFunction)) {
if (lockedFunction != null)
lockedFunction.unlock();
if (locked)
lockedFunction = activeFunction;
else
lockedFunction = null;
}
panel.setMovingActiveFunction(activeFunction);
if (getState() == END_POINT_ADDING)
setState(START_POINT_ADDING);
if ((getState() == END_POINT_CHANGING) || (getState() == START_POINT_CHANGING) || (getState() == FUNCTION_ADDING_STATE) || (getState() == TEXT_ADDING_STATE))
cancelAdding();
} else
refactor.loadFromFunction(activeFunction, false);
boolean updateListeneres = this.activeFunction != activeFunction;
this.activeFunction = activeFunction;
if (panel != null) {
panel.getFrame().propertyChange(MChangeListener.REFRESH_FUNCTION_IN_TREE, activeFunction);
}
setPanels();
if (panel != null) {
setActiveObject(null);
final java.awt.Point mp = getMousePosition();
if (mp != null)
moveMoveListener.mouseMoved(new MouseEvent(this, 0, 0, 0, mp.x, mp.y, 0, false));
}
functionIndex = dataPlugin.indexOfFunction(activeFunction);
if (functionIndex < 0)
functionIndex = 0;
rec = false;
if (updateListeneres) {
ActiveFunctionEvent event = new ActiveFunctionEvent(activeFunction);
for (ActiveFunctionListener l : getActiveFunctionListeners()) l.activeFunctionChanged(event);
}
if (panel != null) {
panel.getFrame().refreshActions(panel);
}
}
Aggregations