Search in sources :

Example 1 with JFontChooser

use of com.ramussoft.pb.frames.components.JFontChooser in project ramus by Vitaliy-Yakovchuk.

the class SectorFontAttributePlugin method getAttributeEditor.

@Override
public AttributeEditor getAttributeEditor(final Engine engine, final AccessRules rules, final Element element, final Attribute attribute, AttributeEditor old) {
    if (old != null)
        old.close();
    return new AbstractAttributeEditor() {

        private PaintSector.Pin pin;

        private JFontChooser component;

        private Font font;

        {
            component = new JFontChooser();
            ResourceLoader.setJComponentsText(component);
        }

        @Override
        public Object setValue(Object value) {
            this.pin = (PaintSector.Pin) value;
            font = pin.getSector().getFont();
            component.setSelFont(font);
            return value;
        }

        @Override
        public Object getValue() {
            return pin;
        }

        @Override
        public JComponent getComponent() {
            return component;
        }

        @Override
        public void apply(Engine engine, Element element, Attribute attribute, Object value) {
            PaintSector sector = pin.getSector();
            sector.setFont(component.getSelFont());
            sector.copyVisual(Sector.VISUAL_COPY_ADDED);
            pin.getSector().getMovingArea().getRefactor().setUndoPoint();
        }

        @Override
        public boolean isSaveAnyway() {
            return !font.equals(component.getSelFont());
        }
    };
}
Also used : AbstractAttributeEditor(com.ramussoft.gui.common.AbstractAttributeEditor) PaintSector(com.ramussoft.pb.idef.elements.PaintSector) Attribute(com.ramussoft.common.Attribute) JFontChooser(com.ramussoft.pb.frames.components.JFontChooser) Element(com.ramussoft.common.Element) Font(java.awt.Font) Engine(com.ramussoft.common.Engine)

Aggregations

Attribute (com.ramussoft.common.Attribute)1 Element (com.ramussoft.common.Element)1 Engine (com.ramussoft.common.Engine)1 AbstractAttributeEditor (com.ramussoft.gui.common.AbstractAttributeEditor)1 JFontChooser (com.ramussoft.pb.frames.components.JFontChooser)1 PaintSector (com.ramussoft.pb.idef.elements.PaintSector)1 Font (java.awt.Font)1