use of com.servoy.j2db.ui.runtime.IRuntimeTabPaneAlike 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());
}
}
Aggregations