use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method refresh.
/**
* Оновлює відображення даних на активній функції.
*/
public void refresh() {
final Function activeFunction = dataPlugin.getBaseFunction();
setActiveFunction(activeFunction);
panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, activeFunction);
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method createBlocks.
public void createBlocks(String[] names) {
double fromX = 20;
double fromY = 20;
double x = fromX;
double y = fromY;
Attribute attribute = null;
for (String name : names) {
Function function = createFunctionalObject(x, y, Function.TYPE_FUNCTION, activeFunction);
x += 110;
if (x + 110 + 20 > CLIENT_WIDTH) {
x = fromX;
y += 60;
}
if (attribute == null)
attribute = getDataPlugin().getEngine().getAttribute(getDataPlugin().getEngine().getQualifier(((NFunction) function).getQualifierId()).getAttributeForName());
Object object;
if (attribute.getAttributeType().getTypeName().equals("DFDSName")) {
DFDSName dfdsName = new DFDSName();
dfdsName.setShortName(name);
dfdsName.setLongName("");
object = dfdsName;
} else
object = name;
((NFunction) function).setAttribute(attribute, object);
}
}
use of com.ramussoft.pb.Function 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);
}
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method moveFunction.
/**
* Метод змінює батьківський елемент для активного функціонального блоку.
*
* @param newParent Навий батьківський елемент для функціонального блоку.
*/
public void moveFunction(final Function newParent) {
final MovingFunction movingFunction = (MovingFunction) getActiveObject();
final Function f = movingFunction.getFunction();
removeAddedSectors(f);
f.setParentRow(newParent);
setPanels();
panel.getFrame().propertyChange(MChangeListener.RELOAD_FUNCTION_IN_TREE, dataPlugin.getBaseFunction());
repaintAsync();
}
use of com.ramussoft.pb.Function in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method isOkForCross.
public boolean isOkForCross() {
MovingArea ma = getCurrentMovingArea();
if ((ma != this) && (ma != null)) {
Function a = getActiveFunction();
Function b = ma.getActiveFunction();
if ((cross.a == a) && (cross.b == b))
return cross.res;
cross.res = true;
cross.a = a;
cross.b = b;
if (a.equals(b))
cross.res = false;
if (isParent(a, b))
cross.res = false;
if (isParent(b, a))
cross.res = false;
return cross.res;
}
return true;
}
Aggregations