use of com.servoy.j2db.IFormUIInternal in project servoy-client by Servoy.
the class WebTabFormLookup method notifyVisible.
public boolean notifyVisible(boolean b, List invokeLaterRunnables) {
if (isReady()) {
IFormUIInternal ui = webForm;
FormController child = ui.getController();
return child.notifyVisible(b, invokeLaterRunnables);
}
return true;
}
use of com.servoy.j2db.IFormUIInternal in project servoy-client by Servoy.
the class TemplateGenerator method getFormHTMLAndCSS.
public static Pair<String, String> getFormHTMLAndCSS(Solution solution, Form form, IServiceProvider sp, String formInstanceName) throws RepositoryException, RemoteException {
if (form == null)
return null;
final IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
boolean enableAnchoring = sp != null ? Utils.getAsBoolean(sp.getRuntimeProperties().get("enableAnchors")) : Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.webclient.enableAnchors", Boolean.TRUE.toString()));
String overriddenStyleName = null;
Pair<String, ArrayList<Pair<String, String>>> retval = formCache.getFormAndCssPair(form, formInstanceName, overriddenStyleName, repository);
Form f = form;
FlattenedSolution fsToClose = null;
try {
if (retval == null) {
if (f.getExtendsID() > 0) {
FlattenedSolution fs = sp == null ? null : sp.getFlattenedSolution();
if (fs == null) {
try {
IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
fsToClose = fs = new FlattenedSolution(solution.getSolutionMetaData(), new AbstractActiveSolutionHandler(as) {
@Override
public IRepository getRepository() {
return repository;
}
});
} catch (RepositoryException e) {
Debug.error("Couldn't create flattened form for the template generator", e);
}
}
f = fs.getFlattenedForm(f);
if (f == null) {
Debug.log("TemplateGenerator couldn't get a FlattenedForm for " + form + ", solution closed?");
f = form;
}
}
StringBuffer html = new StringBuffer();
TextualCSS css = new TextualCSS();
IFormLayoutProvider layoutProvider = FormLayoutProviderFactory.getFormLayoutProvider(sp, solution, f, formInstanceName);
int viewType = layoutProvider.getViewType();
layoutProvider.renderOpenFormHTML(html, css);
int startY = 0;
Iterator<Part> parts = f.getParts();
while (parts.hasNext()) {
Part part = parts.next();
int endY = part.getHeight();
if (Part.rendersOnlyInPrint(part.getPartType())) {
startY = part.getHeight();
// is never shown (=printing only)
continue;
}
Color bgColor = ComponentFactory.getPartBackground(sp, part, f);
if (part.getPartType() == Part.BODY && (viewType == FormController.TABLE_VIEW || viewType == FormController.LOCKED_TABLE_VIEW || viewType == IForm.LIST_VIEW || viewType == FormController.LOCKED_LIST_VIEW)) {
layoutProvider.renderOpenTableViewHTML(html, css, part);
// tableview == bodypart
createCellBasedView(f, f, html, css, layoutProvider.needsHeaders(), startY, endY, bgColor, sp, viewType, enableAnchoring, startY, endY);
layoutProvider.renderCloseTableViewHTML(html);
} else {
layoutProvider.renderOpenPartHTML(html, css, part);
placePartElements(f, startY, endY, html, css, bgColor, enableAnchoring, sp);
layoutProvider.renderClosePartHTML(html, part);
}
startY = part.getHeight();
}
layoutProvider.renderCloseFormHTML(html);
retval = new Pair<String, ArrayList<Pair<String, String>>>(html.toString(), css.getAsSelectorValuePairs());
formCache.putFormAndCssPair(form, formInstanceName, overriddenStyleName, repository, retval);
}
Map<String, String> formIDToMarkupIDMap = null;
if (sp instanceof IApplication) {
Map runtimeProps = sp.getRuntimeProperties();
Map<WebForm, Map<String, String>> clientFormsIDToMarkupIDMap = (Map<WebForm, Map<String, String>>) runtimeProps.get("WebFormIDToMarkupIDCache");
if (clientFormsIDToMarkupIDMap == null) {
clientFormsIDToMarkupIDMap = new WeakHashMap<WebForm, Map<String, String>>();
runtimeProps.put("WebFormIDToMarkupIDCache", clientFormsIDToMarkupIDMap);
}
IForm wfc = ((IApplication) sp).getFormManager().getForm(formInstanceName);
if (wfc instanceof FormController) {
IFormUIInternal wf = ((FormController) wfc).getFormUI();
if (wf instanceof WebForm) {
if (!((WebForm) wf).isUIRecreated())
formIDToMarkupIDMap = clientFormsIDToMarkupIDMap.get(wf);
if (formIDToMarkupIDMap == null) {
ArrayList<Pair<String, String>> formCSS = retval.getRight();
ArrayList<String> selectors = new ArrayList<String>(formCSS.size());
for (Pair<String, String> formCSSEntry : formCSS) selectors.add(formCSSEntry.getLeft());
formIDToMarkupIDMap = getWebFormIDToMarkupIDMap((WebForm) wf, selectors);
clientFormsIDToMarkupIDMap.put((WebForm) wf, formIDToMarkupIDMap);
}
}
}
}
String webFormCSS = getWebFormCSS(retval.getRight(), formIDToMarkupIDMap);
// string the formcss/solutionname/ out of the url.
webFormCSS = StripHTMLTagsConverter.convertMediaReferences(webFormCSS, solution.getName(), new ResourceReference("media"), "", false).toString();
return new Pair<String, String>(retval.getLeft(), webFormCSS);
} finally {
if (fsToClose != null) {
fsToClose.close(null);
}
}
}
use of com.servoy.j2db.IFormUIInternal in project servoy-client by Servoy.
the class SwingFormManager method showPreview.
@Override
public void showPreview(final FormController afp, final IFoundSetInternal foundset, int zoomFactor, final PrinterJob printJob) {
removePreview();
final FormController fc = currentContainer.getController();
if (fc != null) {
List invokeLaterRunnables = new ArrayList();
boolean ok = fc.notifyVisible(false, invokeLaterRunnables);
Utils.invokeLater(getApplication(), invokeLaterRunnables);
if (!ok) {
// cannot hide...so skip preview
return;
}
}
showFormInMainPanel(afp.getName(), currentContainer, null, true, null);
getApplication().getModeManager().setMode(IModeManager.PREVIEW_MODE);
boolean isNewUser = checkAndUpdateFormUser(afp, currentContainer);
if (isNewUser) {
IFormUIInternal ui = afp.getFormUI();
currentContainer.add(ui, afp.getName());
}
try {
final PrintPreview printPreview = new PrintPreview((ISmartClientApplication) getApplication(), afp, foundset, zoomFactor, printJob);
Runnable r = new Runnable() {
public void run() {
printPreviews.put(currentContainer, new PrintPreviewHolder(printPreview, fc));
// $NON-NLS-1$
currentContainer.add(printPreview, "@preview");
// $NON-NLS-1$
currentContainer.show("@preview");
// handle navigator propertly
List invokeLaterRunnables = new ArrayList();
afp.showNavigator(invokeLaterRunnables);
Utils.invokeLater(getApplication(), invokeLaterRunnables);
printPreview.showPages();
}
};
getApplication().invokeLater(r);
} catch (Exception ex) {
// $NON-NLS-1$
getApplication().reportError(Messages.getString("servoy.formManager.error.PrintPreview"), ex);
}
}
use of com.servoy.j2db.IFormUIInternal in project servoy-client by Servoy.
the class FormLookupPanel method createFormPanel.
private FormController createFormPanel() {
FormManager fm = (FormManager) application.getFormManager();
FormController fp = fm.getFormController(formName, this);
if (fp != null) {
IFormUIInternal ui = fp.getFormUI();
if (ui instanceof Component) {
add((Component) ui, BorderLayout.CENTER);
// just to be sure the cardlayout of main panel does return them as not visible
ui.setComponentVisible(true);
// delegate readOnly, really set it once from the form manager state
fp.setReadOnly(fm.isFormReadOnly(formName));
Container con = getParent();
if (con != null && (con instanceof ITabPaneAlike) && !con.isEnabled()) {
// reaply the isEnabled state of the tabpanel to its child tabs (tabs are added after enabled state is set); only if the tabpanel is disabled
this.setEnabled(con.isEnabled());
}
while (con != null) {
if (con instanceof IFormUIInternal) {
fp.getUndoManager().setFormUndoManager(((IFormUIInternal) con).getUndoManager());
break;
}
con = con.getParent();
}
// invalidate later so that everything is first visible (like the datamodel of a tableview)
application.invokeLater(new Runnable() {
public void run() {
validate();
}
});
}
}
return fp;
}
use of com.servoy.j2db.IFormUIInternal in project servoy-client by Servoy.
the class FormLookupPanel method notifyVisible.
/**
* This method must be called on the event thread
*/
public boolean notifyVisible(boolean visible, List invokeLaterRunnables) {
Component[] childs = getComponents();
if (childs.length == 1) {
IFormUIInternal ui = (IFormUIInternal) childs[0];
FormController child = ui.getController();
return child.notifyVisible(visible, invokeLaterRunnables);
}
return true;
}
Aggregations