Search in sources :

Example 1 with HasRuntimeReadOnly

use of com.servoy.j2db.ui.runtime.HasRuntimeReadOnly in project servoy-client by Servoy.

the class PropertyCopy method copyElementProps.

public static void copyElementProps(IComponent org, IComponent copy) {
    if (org == null || copy == null)
        return;
    // if (org instanceof IDelegate && copy instanceof IDelegate)
    // {
    // org = (JComponent)((IDelegate)org).getDelegate();
    // copy = (JComponent) ((IDelegate)copy).getDelegate();
    // }
    copy.setLocation(org.getLocation());
    copy.setSize(org.getSize());
    copy.setBackground(org.getBackground());
    copy.setForeground(org.getForeground());
    copy.setToolTipText(org.getToolTipText());
    copy.setComponentVisible(org.isVisible());
    copy.setComponentEnabled(org.isEnabled());
    copy.setOpaque(org.isOpaque());
    copy.setFont(org.getFont());
    if (org instanceof ILabel && copy instanceof ILabel) {
        ((ILabel) copy).setMediaIcon(((ILabel) org).getMediaIcon());
        ((ILabel) copy).setText(((ILabel) org).getText());
    }
    if (org instanceof IFieldComponent && copy instanceof IFieldComponent) {
        ((IFieldComponent) copy).setEditable(((IFieldComponent) org).isEditable());
    }
    if (org instanceof IScriptableProvider && copy instanceof IScriptableProvider) {
        IScriptable source = ((IScriptableProvider) org).getScriptObject();
        IScriptable destination = ((IScriptableProvider) copy).getScriptObject();
        if (source instanceof IFormatScriptComponent && destination instanceof IFormatScriptComponent) {
            ((IFormatScriptComponent) destination).setComponentFormat(((IFormatScriptComponent) source).getComponentFormat());
        }
        if (source instanceof HasRuntimeReadOnly && destination instanceof HasRuntimeReadOnly) {
            ((HasRuntimeReadOnly) destination).setReadOnly(((HasRuntimeReadOnly) source).isReadOnly());
        }
        if (source instanceof HasRuntimeVisible && destination instanceof HasRuntimeVisible) {
            ((HasRuntimeVisible) destination).setVisible(((HasRuntimeVisible) source).isVisible());
        }
        if (source instanceof HasRuntimeImage && destination instanceof HasRuntimeImage) {
            String imageURL = ((HasRuntimeImage) source).getImageURL();
            if (imageURL != null) {
                // only copy if explicitly set with a url
                ((HasRuntimeImage) destination).setImageURL(imageURL);
            }
            String rolloverImageURL = ((HasRuntimeImage) source).getRolloverImageURL();
            if (rolloverImageURL != null) {
                // only copy if explicitly set with a url
                ((HasRuntimeImage) destination).setRolloverImageURL(rolloverImageURL);
            }
        }
        if (source instanceof IRuntimeTabPaneAlike && destination instanceof IRuntimeTabPaneAlike) {
            // keep active tab when printing
            ((IRuntimeTabPaneAlike) destination).setTabIndex(((IRuntimeTabPaneAlike) source).getTabIndex());
        }
    }
    if (org instanceof IProviderStylePropertyChanges && copy instanceof IProviderStylePropertyChanges) {
        ((IProviderStylePropertyChanges) copy).getStylePropertyChanges().setChanges(((IProviderStylePropertyChanges) org).getStylePropertyChanges().getChanges());
    }
}
Also used : HasRuntimeReadOnly(com.servoy.j2db.ui.runtime.HasRuntimeReadOnly) HasRuntimeImage(com.servoy.j2db.ui.runtime.HasRuntimeImage) HasRuntimeVisible(com.servoy.j2db.ui.runtime.HasRuntimeVisible) IRuntimeTabPaneAlike(com.servoy.j2db.ui.runtime.IRuntimeTabPaneAlike) IFormatScriptComponent(com.servoy.j2db.ui.scripting.IFormatScriptComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IScriptable(com.servoy.j2db.scripting.IScriptable)

Example 2 with HasRuntimeReadOnly

use of com.servoy.j2db.ui.runtime.HasRuntimeReadOnly in project servoy-client by Servoy.

the class TableView method editCellAt.

/*
	 * (non-Javadoc)
	 *
	 * @see com.servoy.j2db.gui.FixedJTable#editCellAt(int, int, java.util.EventObject)
	 */
@Override
public boolean editCellAt(int row, int column, EventObject e) {
    boolean b = super.editCellAt(row, column, e);
    Component comp = getEditorComponent();
    if (comp instanceof ISupportEventExecutor) {
        // focus lost event comes after editor is removed from hierarchy
        IEventExecutor executor = ((ISupportEventExecutor) comp).getEventExecutor();
        if (executor instanceof BaseEventExecutor) {
            ((BaseEventExecutor) executor).setFormName(fc.getName());
        }
    }
    if (b && !isEditable() && comp instanceof IScriptableProvider && ((IScriptableProvider) comp).getScriptObject() instanceof HasRuntimeReadOnly && !((HasRuntimeReadOnly) ((IScriptableProvider) comp).getScriptObject()).isReadOnly()) {
        // the component is editable again, we have to set it back
        ((HasRuntimeReadOnly) ((IScriptableProvider) comp).getScriptObject()).setReadOnly(true);
    }
    return b;
}
Also used : HasRuntimeReadOnly(com.servoy.j2db.ui.runtime.HasRuntimeReadOnly) IEventExecutor(com.servoy.j2db.ui.IEventExecutor) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) GraphicalComponent(com.servoy.j2db.persistence.GraphicalComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) ISupportEventExecutor(com.servoy.j2db.ui.ISupportEventExecutor) BaseEventExecutor(com.servoy.j2db.ui.BaseEventExecutor) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider)

Example 3 with HasRuntimeReadOnly

use of com.servoy.j2db.ui.runtime.HasRuntimeReadOnly in project servoy-client by Servoy.

the class ListView method getReadOnlyAwareComponents.

private List<HasRuntimeReadOnly> getReadOnlyAwareComponents() {
    List<HasRuntimeReadOnly> readOnlyAwareComponents = new ArrayList<HasRuntimeReadOnly>();
    ListCellRenderer cellRenderer = getCellRenderer();
    if (cellRenderer instanceof DataRenderer) {
        DataRenderer dr = (DataRenderer) cellRenderer;
        for (int i = 0; i < dr.getComponentCount(); i++) {
            Component c = dr.getComponent(i);
            if (c instanceof IScriptableProvider && ((IScriptableProvider) c).getScriptObject() instanceof HasRuntimeReadOnly) {
                readOnlyAwareComponents.add((HasRuntimeReadOnly) ((IScriptableProvider) c).getScriptObject());
            }
        }
    }
    IEditListEditor editorComponent = getCellEditor();
    if (editorComponent instanceof FormBodyEditor) {
        FormBodyEditor formBodyEditor = (FormBodyEditor) editorComponent;
        DataRenderer dataRenderer = formBodyEditor.getDataRenderer();
        for (int i = 0; i < dataRenderer.getComponentCount(); i++) {
            Component c = dataRenderer.getComponent(i);
            if (c instanceof IScriptableProvider && ((IScriptableProvider) c).getScriptObject() instanceof HasRuntimeReadOnly) {
                readOnlyAwareComponents.add((HasRuntimeReadOnly) ((IScriptableProvider) c).getScriptObject());
            }
        }
    }
    return readOnlyAwareComponents;
}
Also used : HasRuntimeReadOnly(com.servoy.j2db.ui.runtime.HasRuntimeReadOnly) IEditListEditor(com.servoy.j2db.util.editlist.IEditListEditor) DataRenderer(com.servoy.j2db.smart.dataui.DataRenderer) FormBodyEditor(com.servoy.j2db.smart.dataui.FormBodyEditor) ArrayList(java.util.ArrayList) ListCellRenderer(javax.swing.ListCellRenderer) Component(java.awt.Component) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) Point(java.awt.Point)

Example 4 with HasRuntimeReadOnly

use of com.servoy.j2db.ui.runtime.HasRuntimeReadOnly in project servoy-client by Servoy.

the class ListView method setEditableWithStateTracking.

/*
	 * (non-Javadoc)
	 *
	 * @see com.servoy.j2db.smart.ISupportEditStateTracking#setEditableWithStateTracking(boolean)
	 */
@Override
public void setEditableWithStateTracking(boolean b) {
    if (editable != b) {
        super.setEditable(b);
        this.editable = b;
        if (editable == false) {
            Iterator<HasRuntimeReadOnly> readOnlyAwareComponentsIte = getReadOnlyAwareComponents().iterator();
            HasRuntimeReadOnly el;
            while (readOnlyAwareComponentsIte.hasNext()) {
                el = readOnlyAwareComponentsIte.next();
                if (el.isReadOnly() == false) {
                    el.setReadOnly(true);
                    if (componentsWithEditableStateChanged.contains(el) == false)
                        componentsWithEditableStateChanged.add(el);
                }
            }
        } else {
            if (componentsWithEditableStateChanged.size() != 0) {
                for (HasRuntimeReadOnly component : componentsWithEditableStateChanged) {
                    component.setReadOnly(false);
                }
            }
            componentsWithEditableStateChanged.clear();
        }
        invalidate();
        repaint();
    }
}
Also used : HasRuntimeReadOnly(com.servoy.j2db.ui.runtime.HasRuntimeReadOnly)

Example 5 with HasRuntimeReadOnly

use of com.servoy.j2db.ui.runtime.HasRuntimeReadOnly in project servoy-client by Servoy.

the class TableView method setEditableWithStateTracking.

public void setEditableWithStateTracking(boolean b) {
    if (editable != b) {
        super.setEditable(b);
        this.editable = b;
        if (editable == false) {
            Iterator<HasRuntimeReadOnly> readOnlyAwareComponentsIte = getReadOnlyAwareComponents().iterator();
            HasRuntimeReadOnly el;
            while (readOnlyAwareComponentsIte.hasNext()) {
                el = readOnlyAwareComponentsIte.next();
                if (el.isReadOnly() == false) {
                    el.setReadOnly(true);
                    if (componentsWithEditableStateChanged.contains(el) == false)
                        componentsWithEditableStateChanged.add(el);
                }
            }
        } else {
            if (componentsWithEditableStateChanged.size() != 0) {
                for (HasRuntimeReadOnly component : componentsWithEditableStateChanged) {
                    component.setReadOnly(false);
                }
            }
            componentsWithEditableStateChanged.clear();
        }
        repaint();
    }
}
Also used : HasRuntimeReadOnly(com.servoy.j2db.ui.runtime.HasRuntimeReadOnly)

Aggregations

HasRuntimeReadOnly (com.servoy.j2db.ui.runtime.HasRuntimeReadOnly)5 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)3 Component (java.awt.Component)2 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)1 IScriptable (com.servoy.j2db.scripting.IScriptable)1 DataRenderer (com.servoy.j2db.smart.dataui.DataRenderer)1 FormBodyEditor (com.servoy.j2db.smart.dataui.FormBodyEditor)1 BaseEventExecutor (com.servoy.j2db.ui.BaseEventExecutor)1 IComponent (com.servoy.j2db.ui.IComponent)1 IEventExecutor (com.servoy.j2db.ui.IEventExecutor)1 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)1 ISupportEventExecutor (com.servoy.j2db.ui.ISupportEventExecutor)1 HasRuntimeImage (com.servoy.j2db.ui.runtime.HasRuntimeImage)1 HasRuntimeVisible (com.servoy.j2db.ui.runtime.HasRuntimeVisible)1 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)1 IRuntimeTabPaneAlike (com.servoy.j2db.ui.runtime.IRuntimeTabPaneAlike)1 IFormatScriptComponent (com.servoy.j2db.ui.scripting.IFormatScriptComponent)1 IEditListEditor (com.servoy.j2db.util.editlist.IEditListEditor)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1