Search in sources :

Example 6 with Style

use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.

the class ClientPluginAccessProvider method getStyleSheet.

/*
	 * (non-Javadoc)
	 *
	 * @see com.servoy.j2db.plugins.IClientPluginAccess#getStyleSheet(java.lang.String)
	 */
public IStyleSheet getStyleSheet(String name) {
    FlattenedSolution flattenedSolution = application.getFlattenedSolution();
    if (flattenedSolution == null) {
        // when called before flattened solution is set.
        return null;
    }
    String style_name = ComponentFactory.getOverriddenStyleName(application, name);
    Style s = flattenedSolution.getStyle(style_name);
    return ComponentFactory.getCSSStyle(application, s);
}
Also used : FlattenedSolution(com.servoy.j2db.FlattenedSolution) Style(com.servoy.j2db.persistence.Style)

Example 7 with Style

use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.

the class JSSolutionModel method newForm.

protected JSForm newForm(String name, String dataSource, String styleName, boolean show_in_menu, int width, int height, boolean isResponsive) {
    FlattenedSolution fs = application.getFlattenedSolution();
    try {
        Style style = null;
        if (styleName != null) {
            style = fs.getStyle(styleName);
        }
        Form form = createNewForm(style, IdentDocumentValidator.checkName(name), dataSource, show_in_menu, new Dimension(width, height));
        if (!isResponsive) {
            form.createNewPart(Part.BODY, height);
        } else {
            form.setResponsiveLayout(true);
        }
        if (fs.getSolution().getSolutionType() == SolutionMetaData.MOBILE) {
            // mobile solution, make the form mobile
            form.putCustomMobileProperty(IMobileProperties.MOBILE_FORM.propertyName, Boolean.TRUE);
            // set internal style name
            form.setStyleName("_servoy_mobile");
        }
        application.getFormManager().addForm(form, false);
        return instantiateForm(form, true);
    } catch (RepositoryException e) {
        throw new RuntimeException(e);
    }
}
Also used : Form(com.servoy.j2db.persistence.Form) ISMForm(com.servoy.j2db.solutionmodel.ISMForm) IBaseSMForm(com.servoy.base.solutionmodel.IBaseSMForm) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Style(com.servoy.j2db.persistence.Style) RepositoryException(com.servoy.j2db.persistence.RepositoryException) Dimension(java.awt.Dimension)

Example 8 with Style

use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.

the class JSSolutionModel method newStyle.

/**
 * Creates a new style with the given css content string under the given name.
 *
 * NOTE: Will throw an exception if a style with that name already exists.
 *
 * @sample
 * var form = solutionModel.newForm('myForm','db:/my_server/my_table',null,true,1000,800);
 * if (form.transparent == false)
 * {
 * 	var style = solutionModel.newStyle('myStyle','form { background-color: yellow; }');
 * 	style.text = style.text + 'field { background-color: blue; }';
 * 	form.styleName = 'myStyle';
 * }
 * var field = form.newField('columnTextDataProvider',JSField.TEXT_FIELD,100,100,100,50);
 * forms['myForm'].controller.show();
 *
 * @param name the name of the new style
 *
 * @param content the css content of the new style
 *
 * @return a JSStyle object
 */
@JSFunction
public JSStyle newStyle(String name, String content) {
    Style style = application.getFlattenedSolution().createStyle(name, null);
    if (style == null) {
        return null;
    }
    JSStyle jsStyle = new JSStyle(application, style, true);
    jsStyle.setText(content);
    return jsStyle;
}
Also used : Style(com.servoy.j2db.persistence.Style) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 9 with Style

use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.

the class J2DBClient method closeSolution.

@Override
public boolean closeSolution(boolean force, Object[] args) {
    if (getSolution() == null || isClosing)
        return true;
    // $NON-NLS-1$
    blockGUI(Messages.getString("servoy.client.status.closingsolution"));
    try {
        if (!super.closeSolution(force, args))
            return false;
        if (frame != null)
            frame.setTitle(getDisplayApplicationName());
        // delete all dialogs
        Iterator<Window> it = dialogs.values().iterator();
        while (it.hasNext()) {
            Window element = it.next();
            element.dispose();
        }
        dialogs = new HashMap<String, Window>();
        Collection<Style> userStyles = getFlattenedSolution().flushUserStyles();
        if (userStyles != null) {
            for (Style style : userStyles) {
                ComponentFactory.flushStyle(this, style);
            }
        }
        // $NON-NLS-1$
        setStatusText("", null);
        ComponentFactory.flushCachedItems(this);
        invokeLater(new // make some stuff later null so its not created again
        Runnable() {

            public void run() {
                editLabel.setIcon(empty);
                insertModeLabel.setIcon(empty);
                transactionLabel.setIcon(empty);
                lockLabel.setIcon(empty);
                dataChangeLabel.setIcon(empty);
                invokeLater(new Runnable() {

                    public void run() {
                        if (getSolution() == null && getClientInfo() != null) {
                            // select new solution, run later because logout may trigger a login dialog as well
                            handleClientUserUidChanged(null, getClientInfo().getUserUid());
                        }
                    }
                });
            }
        });
        // SmartClient needs to flush the Perist cache because reloading them does create a new instance of the solution
        PersistIndexCache.flush();
        return true;
    } catch (Exception ex) {
        Debug.error(ex);
        return false;
    } finally {
        releaseGUI();
    }
}
Also used : Window(java.awt.Window) Style(com.servoy.j2db.persistence.Style) IOException(java.io.IOException) ApplicationException(com.servoy.j2db.ApplicationException) RemoteException(java.rmi.RemoteException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) ServoyException(com.servoy.j2db.util.ServoyException) LoginException(javax.security.auth.login.LoginException) MalformedURLException(java.net.MalformedURLException)

Example 10 with Style

use of com.servoy.j2db.persistence.Style in project servoy-client by Servoy.

the class JSSolutionModel method removeStyle.

/**
 * Removes the specified style.
 *
 * @sample
 * var s = solutionModel.newStyle("smStyle1",'form { background-color: yellow; }');
 * var status = solutionModel.removeStyle("smStyle1");
 * if (status == false) application.output("Could not remove style.");
 * else application.output("Style removed.");
 *
 * @param name the name of the style to be removed
 *
 * @return true if the removal was successful, false otherwise
 */
@JSFunction
public boolean removeStyle(String name) {
    FlattenedSolution fs = application.getFlattenedSolution();
    Style style = fs.getStyle(name);
    if (style != null) {
        fs.removeStyle(name);
        return true;
    }
    return false;
}
Also used : FlattenedSolution(com.servoy.j2db.FlattenedSolution) Style(com.servoy.j2db.persistence.Style) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Aggregations

Style (com.servoy.j2db.persistence.Style)17 RepositoryException (com.servoy.j2db.persistence.RepositoryException)6 Form (com.servoy.j2db.persistence.Form)4 RemoteException (java.rmi.RemoteException)4 HashMap (java.util.HashMap)4 FlattenedSolution (com.servoy.j2db.FlattenedSolution)3 Solution (com.servoy.j2db.persistence.Solution)3 IStyleSheet (com.servoy.j2db.util.IStyleSheet)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 FlattenedForm (com.servoy.j2db.persistence.FlattenedForm)2 ServoyException (com.servoy.j2db.util.ServoyException)2 HashSet (java.util.HashSet)2 IBaseSMForm (com.servoy.base.solutionmodel.IBaseSMForm)1 ApplicationException (com.servoy.j2db.ApplicationException)1 IForm (com.servoy.j2db.IForm)1 IFormController (com.servoy.j2db.IFormController)1 FoundSetManager (com.servoy.j2db.dataprocessing.FoundSetManager)1 DebugSwingFormMananger (com.servoy.j2db.debug.DebugJ2DBClient.DebugSwingFormMananger)1 BaseComponent (com.servoy.j2db.persistence.BaseComponent)1 Field (com.servoy.j2db.persistence.Field)1