use of com.ramussoft.gui.common.AttributeEditor in project ramus by Vitaliy-Yakovchuk.
the class IDEF0Object method createEditFrame.
@Override
protected void createEditFrame() {
final GUIFramework framework = movingArea.getPanel().getFramework();
final Engine engine = framework.getEngine();
long id = getFunction().getLink();
Element element2 = null;
if (id >= 0)
element2 = engine.getElement(id);
if (element2 == null)
element2 = getFunction().getElement();
final Element element = element2;
Qualifier qualifier = engine.getQualifier(element.getQualifierId());
Attribute name = null;
if (qualifier.getAttributeForName() >= 0)
name = engine.getAttribute(qualifier.getAttributeForName());
if (name == null) {
JOptionPane.showMessageDialog(framework.getMainFrame(), ResourceLoader.getString("NameAttributeNotSet"));
return;
}
final Attribute nameAttribute = name;
AttributePlugin plugin = framework.findAttributePlugin(name);
final AttributeEditor editor = plugin.getAttributeEditor(engine, framework.getAccessRules(), element, name, "activity_name", null);
setTextComponent(new JScrollPane(editor.getLastComponent()));
final Object value = engine.getAttribute(element, name);
editor.setValue(value);
final Rectangle r = movingArea.getIBounds(getBounds());
final JTextArea textArea = (JTextArea) editor.getLastComponent();
processTextArea(textArea);
// textArea.setBackground(getFunction().getBackground());
// textArea.setForeground(getFunction().getForeground());
// textArea.setFont(movingArea.getFont(getFont()));
// textArea.setCaretColor(getFunction().getForeground());
final JPopupMenu menu = textArea.getComponentPopupMenu();
textArea.setComponentPopupMenu(null);
movingArea.getPanel().setActionDisable(true);
textArea.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER && e.isControlDown()) {
stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
} else if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
cancelEdit(editor, textArea, menu);
}
});
textArea.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
stopEdit(element, engine, nameAttribute, editor, value, textArea, menu);
}
@Override
public void focusGained(FocusEvent e) {
}
});
movingArea.add(getTextComponent());
movingArea.setbImage(null);
getTextComponent().setBounds(r);
movingArea.revalidate();
movingArea.repaint();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
textArea.requestFocus();
}
});
}
use of com.ramussoft.gui.common.AttributeEditor 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);
}
use of com.ramussoft.gui.common.AttributeEditor in project ramus by Vitaliy-Yakovchuk.
the class FunctionOptionsDialog method showModal.
public void showModal(final Row row) {
function = (Function) row;
load();
Options.loadOptions("function_options_dialog", this);
int index = Options.getInteger("DEFAULT_FUNCTION_DIALOG_TAB", 0);
if (index < getJTabbedPane().getTabCount()) {
getJTabbedPane().setSelectedIndex(index);
Component component = getJTabbedPane().getSelectedComponent();
requestFocusForTextComponent(component);
}
setVisible(true);
Options.saveOptions("function_options_dialog", this);
Options.setInteger("DEFAULT_FUNCTION_DIALOG_TAB", getJTabbedPane().getSelectedIndex());
while (getJTabbedPane().getTabCount() > staticTabCount) {
getJTabbedPane().removeTabAt(0);
}
for (AttributeEditor editor : attributeEditors) editor.close();
attributeEditors.clear();
attributes.clear();
values.clear();
}
Aggregations