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());
}
}
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;
}
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;
}
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();
}
}
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();
}
}
Aggregations