use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method setActiveObject.
public void setActiveObject(final Object activeObject, boolean silent) {
this.prevActiveObject = this.getActiveObject();
if (activeObject instanceof MovingText)
this.activeMovingTextIndex = refactor.getTexts().indexOf(activeObject);
else
this.activeMovingTextIndex = -1;
if (activeObject instanceof MovingFunction) {
NFunction function = (NFunction) ((MovingFunction) activeObject).getFunction();
if (!silent) {
panel.getFramework().propertyChanged(Commands.ACTIVATE_ELEMENT, function.getElement());
long id = dataPlugin.getBaseFunctionQualifier().getAttributeForName();
for (Attribute attr : dataPlugin.getBaseFunctionQualifier().getAttributes()) if (attr.getId() == id) {
panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, new AttributeEditorView.ElementAttribute(function.getElement(), attr));
}
}
Enumeration e = ((MovingFunction) activeObject).getFunction().children();
while (e.hasMoreElements()) ((Function) e.nextElement()).getSectors();
}
final Object o = this.activeObject;
if ((activeObject == null) && (!silent)) {
panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, null);
}
this.activeObject = activeObject;
if (o != activeObject)
panel.getFrame().refreshActions(panel);
if (activeObject instanceof PaintSector.Pin) {
final PaintSector.Pin pin = (PaintSector.Pin) activeObject;
panel.getFrame().getJCheckBoxMenuItemShowTilda().setSelected(pin.getSector().isShowTilda());
panel.getFrame().getJCheckBoxMenuItemTransparentText().setSelected(pin.getSector().isTransparent());
if (!silent) {
panel.getFramework().propertyChanged(Commands.ACTIVATE_ELEMENT, ((NSector) pin.getSector().getSector()).getElement(), pin);
panel.getFramework().propertyChanged(Commands.ACTIVATE_ATTRIBUTE, new AttributeEditorView.ElementAttribute(((NSector) pin.getSector().getSector()).getElement(), IDEF0Plugin.getStreamAttribute(dataPlugin.getEngine())), pin);
}
}
repaintAsync();
}
use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class MovingArea method checkRemoveLevelFunction.
/**
* Метод перевіряє, чи правильно розташовані сектори, щоб функціональний
* блок міг бути видалений.
*
* @param context Функціональний блок, який має бути видалений.
* @return <code>true</code>, якщо функціональний блок може бути видалений,
* <code>false</code>, якщо функціональний блок не може бути
* видалений.
*/
private boolean checkRemoveLevelFunction(final Function context) {
final Function f = (Function) context.getParentRow();
((NFunction) f).clearSectorsBuffer();
final Vector<Sector> sectors = f.getSectors();
for (int i = 0; i < sectors.size(); i++) {
final Sector sector = sectors.get(i);
if (context.equals(sector.getStart().getFunction())) {
if (sector.getEnd().getBorderType() != sector.getStart().getFunctionType())
return false;
} else if (context.equals(sector.getEnd().getFunction())) {
if (sector.getStart().getBorderType() != sector.getEnd().getFunctionType())
return false;
} else
return false;
}
return true;
}
use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class FunctionOptionsDialog method apptype.
private void apptype() {
Engine e = dataPlugin.getEngine();
if (e instanceof Journaled)
((Journaled) e).startUserTransaction();
function.setFont(getJFontChooser().getSelFont());
function.setBackground(getJColorChooser().getColor());
function.setForeground(getJColorChooser1().getColor());
final JList jList = selectOwner.getJList();
if (jList.getSelectedIndex() == 0)
function.setOwner(null);
else {
function.setOwner((Row) jList.getSelectedValue());
}
function.setType(functionType.getType());
AccessRules rules = dataPlugin.getAccessRules();
Element element = ((NFunction) function).getElement();
for (int index = attributes.size() - 1; index >= 0; index--) {
Attribute attribute = attributes.get(index);
if (rules.canUpdateElement(element.getId(), attribute.getId())) {
Object value = attributeEditors.get(index).getValue();
if (!equals(value, values.get(index)))
e.setAttribute(element, attribute, value);
}
}
if (e instanceof Journaled)
((Journaled) e).commitUserTransaction();
}
use of com.ramussoft.pb.data.negine.NFunction in project ramus by Vitaliy-Yakovchuk.
the class FunctionOptionsDialog method load.
private void load() {
Engine e = dataPlugin.getEngine();
Qualifier qualifier = function.getQualifier();
attributes = new ArrayList<Attribute>(qualifier.getAttributes());
for (int i = attributes.size() - 1; i >= 0; i--) {
Attribute attribute = attributes.get(i);
AttributePlugin plugin = framework.findAttributePlugin(attribute.getAttributeType());
Element element = ((NFunction) function).getElement();
AttributeEditor editor = plugin.getAttributeEditor(e, dataPlugin.getAccessRules(), element, attribute, "function", null);
if (editor == null)
continue;
attributeEditors.add(0, editor);
JComponent component = editor.getComponent();
JPanel panel = new JPanel(new BorderLayout());
panel.add(component, BorderLayout.CENTER);
Action[] actions = editor.getActions();
if (actions.length > 0) {
JToolBar bar = new JToolBar();
for (Action a : actions) {
JButton b = bar.add(a);
b.setFocusable(false);
bar.add(b);
}
panel.add(bar, BorderLayout.NORTH);
}
getJTabbedPane().insertTab(attribute.getName(), null, panel, null, 0);
Object value = e.getAttribute(element, attribute);
editor.setValue(value);
values.add(0, value);
}
getJColorChooser().setColor(function.getBackground());
getJColorChooser1().setColor(function.getForeground());
getJFontChooser().setSelFont(function.getFont());
functionType.setFunction(function);
selectOwner.setFunction(function);
}
Aggregations