use of com.servoy.j2db.FormManager in project servoy-client by Servoy.
the class WebDataListBox method fireOnRender.
public void fireOnRender(boolean force) {
if (scriptable != null) {
boolean isFocused = false;
IMainContainer currentContainer = ((FormManager) application.getFormManager()).getCurrentContainer();
if (currentContainer instanceof MainPage) {
isFocused = this.equals(((MainPage) currentContainer).getFocusedComponent());
}
if (force)
scriptable.getRenderEventExecutor().setRenderStateChanged();
scriptable.getRenderEventExecutor().fireOnRender(isFocused);
}
}
use of com.servoy.j2db.FormManager in project servoy-client by Servoy.
the class WebTabFormLookup method getWebForm.
private WebForm getWebForm(boolean removeFromParent) {
if (webForm != null && webForm.isDestroyed()) {
webForm = null;
}
if (webForm == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getFormController(formName, this);
if (fc == null) {
fc = fm.leaseFormPanel(formName);
}
if (fc != null) {
// delegate readOnly, really set it once from the form manager state
fc.setReadOnly(fm.isFormReadOnly(formName));
webForm = (WebForm) fc.getFormUI();
if (removeFromParent && webForm.getParent() != null && webForm.getParent() != parent) {
webForm.remove();
}
}
}
return webForm;
}
use of com.servoy.j2db.FormManager in project servoy-client by Servoy.
the class ComponentFactory method createBean.
protected static IComponent createBean(IApplication application, Form form, Bean bean, FlattenedSolution flattenedSolution) {
IComponent c = null;
try {
Object obj = getBeanInstanceFromXML(application, bean.getBeanClassName(), bean.getBeanXML());
if (flattenedSolution != null && obj != null) {
obj = flattenedSolution.setBeanDesignInstance(bean, obj);
}
if (obj instanceof Component) {
((Component) obj).setName(bean.getName());
} else if (obj instanceof IComponent) {
((IComponent) obj).setName(bean.getName());
}
if (obj instanceof IServoyAwareBean) {
((IServoyAwareBean) obj).initialize((IClientPluginAccess) application.getPluginAccess());
}
if (obj instanceof IServoyBeanFactory) {
testReturnTypesForBean(application, obj);
obj = ((IServoyBeanFactory) obj).getBeanInstance(application.getApplicationType(), (IClientPluginAccess) application.getPluginAccess(), new Object[] { ComponentFactory.getWebID(form, bean), form.getName(), form.getStyleName() });
}
testReturnTypesForBean(application, obj);
if (obj instanceof Applet) {
((FormManager) application.getFormManager()).initializeApplet((Applet) obj, bean.getSize());
}
if (obj == null) {
c = application.getItemFactory().createLabel(ComponentFactory.getWebID(form, bean), "bean missing " + bean.getBeanClassName());
} else if (!(obj instanceof java.awt.Component) && !(obj instanceof IComponent)) {
c = application.getItemFactory().createInvisibleBean(ComponentFactory.getWebID(form, bean), obj);
} else if (!(obj instanceof IComponent)) {
c = application.getItemFactory().createBeanHolder(ComponentFactory.getWebID(form, bean), (Component) obj, bean.getAnchors());
} else {
c = (IComponent) obj;
}
// beans do not store the transparent property, keep the value from component
boolean isOpaque = c.isOpaque();
applyBasicComponentProperties(application, c, bean, null);
c.setOpaque(isOpaque);
} catch (// sometimes setting size or location throws exception or even error...create label instead
Throwable e) {
Debug.error(e);
c = application.getItemFactory().createLabel(bean.getName(), "error acessing bean" + bean.getBeanClassName());
java.awt.Dimension dim = bean.getSize();
if (dim != null)
c.setSize(bean.getSize());
}
return c;
}
use of com.servoy.j2db.FormManager in project servoy-client by Servoy.
the class DataProviderEditor method fillDataProviderList.
protected void fillDataProviderList() {
try {
ITable table = null;
if (definedTable == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getCurrentMainShowingFormController();
if (fc != null) {
Form form = fc.getForm();
table = application.getFlattenedSolution().getTable(form.getDataSource());
}
} else {
if (!showRelatedOptionsOnly)
table = definedTable;
}
DefaultListModel model = (DefaultListModel) list.getModel();
model.removeAllElements();
if (showNoneOption)
model.addElement("-none-");
if (!showColumnsOnly)
model.addElement("*columns");
Object o = relationsComboBox.getSelectedItem();
if (o != null) {
if (o instanceof String) {
// table = form.getTable();
} else {
table = application.getFlattenedSolution().getTable(((Relation) o).getForeignDataSource());
}
if (table != null) {
Iterator<Column> it = table.getColumnsSortedByName();
while (it.hasNext()) {
IColumn c = it.next();
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
if (hideMediaColumns) {
// use dataprovider type as defined by column converter
ComponentFormat componentFormat = ComponentFormat.getComponentFormat(null, c, application);
if (componentFormat.dpType == IColumnTypes.MEDIA) {
continue;
}
}
model.addElement(c);
}
}
}
FlattenedSolution s = application.getFlattenedSolution();
if (table != null && !showColumnsOnly) {
Iterator it = s.getScriptCalculations(table, true);
if (it.hasNext()) {
model.addElement("*calculations");
}
while (it.hasNext()) {
ScriptCalculation sc = (ScriptCalculation) it.next();
for (int i = 0; i < model.size(); i++) {
Object obj = model.elementAt(i);
if (obj instanceof IDataProvider) {
IDataProvider dp = (IDataProvider) obj;
if (dp.getDataProviderID().equals(sc.getDataProviderID())) {
// remove the column from the list if use by
model.remove(i);
// stored calc
break;
}
}
}
model.addElement(sc);
}
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
Iterator it3 = s.getAggregateVariables(table, true);
if (it3.hasNext()) {
model.addElement("*aggregates");
}
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (table != null && showColumnsOnly && showSortableOnly) {
Iterator it3 = s.getAggregateVariables(table, true);
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (showGlobalsOption && showColumnsOnly) {
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
use of com.servoy.j2db.FormManager in project servoy-client by Servoy.
the class DataProviderEditor method fillRelationsComboBox.
protected void fillRelationsComboBox(Relation[] relations) throws Exception {
boolean relationsAdded = false;
String item = null;
ITable table = null;
if (definedTable == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getCurrentMainShowingFormController();
if (fc != null) {
Form form = fc.getForm();
table = application.getFlattenedSolution().getTable(form.getDataSource());
}
} else {
table = definedTable;
// definedTable = null;//clear!
}
if (relationsComboBox.getItemCount() > 0)
relationsComboBox.removeAllItems();
Iterator it = application.getFlattenedSolution().getRelations(table, true, true);
while (it.hasNext()) {
Relation rel = (Relation) it.next();
if (!showSortableOnly || (showSortableOnly && rel.isUsableInSort())) {
relationsComboBox.addItem(rel);
relationsAdded = true;
}
}
if (!showRelatedOptionsOnly) {
// $NON-NLS-1$
String tname = "";
if (table != null)
tname = table.getName();
item = "DataProviders for " + tname;
if (relationsComboBox.getModel().getSize() > 0) {
relationsComboBox.insertItemAt(item, 0);
} else {
relationsComboBox.addItem(item);
}
}
if (relations == null) {
if (item == null) {
if (relationsComboBox.getModel().getSize() != 0)
relationsComboBox.setSelectedIndex(0);
} else {
relationsComboBox.setSelectedItem(item);
}
} else {
relationsComboBox.setSelectedItem(relations[0]);
}
relationsComboBox.setEnabled(relationsAdded && !showRelatedOptionsOnly);
}
Aggregations