Example #1
0
  @Override
  public TipiContext createContext() throws IOException {

    String stylePath = myServletContext.getRealPath("Default.stylesheet");
    logger.info("StylePath: " + stylePath);
    try {
      FileInputStream fis = new FileInputStream(stylePath);
      Styles.loadStyleSheet(fis);
      fis.close();
    } catch (IOException e) {
      logger.error("Error: ", e);
    }

    if (Styles.DEFAULT_STYLE_SHEET != null) {
      setStyleSheet(Styles.DEFAULT_STYLE_SHEET);
      Style ss = Styles.DEFAULT_STYLE_SHEET.getStyle(WindowPane.class, "Default");
      logger.info(">>> " + ss);
    }
    logger.info("REAL PATH: " + myServletContext.getRealPath("/"));

    // Title.Sub
    EchoTipiContext newContext = new EchoTipiContext(this, null);
    ServletContextResourceLoader servletContextTipiLoader =
        new ServletContextResourceLoader(myServletContext, "tipi");
    newContext.setTipiResourceLoader(servletContextTipiLoader);
    ServletContextResourceLoader servletContextResourceLoader =
        new ServletContextResourceLoader(myServletContext, "resource");
    newContext.setGenericResourceLoader(servletContextResourceLoader);
    //	context.setResourceBaseDirectory(new File(myServletContext.getRealPath("/") +
    // "resource/tipi/"));

    TipiEchoExtension ed = new TipiEchoExtension();
    ed.initialize(newContext);

    getContextProperty(ContainerContext.CONTEXT_PROPERTY_NAME);
    TipiScreen es = new TipiScreen();
    //		newContext.processRequiredIncludes();
    es.setContext(newContext);
    es.createContainer();
    newContext.setDefaultTopLevel(es);
    try {
      logger.info("Context created: " + newContext.hashCode());
      initServlet(newContext, myServletConfig.getInitParameterNames(), ed);
    } catch (Throwable ex) {
      ex.printStackTrace();
    }
    return newContext;
  }
Example #2
0
  protected void setComponentValue(String name, Object object) {
    if ("propertyname".equals(name)) {
      myPropertyName = object.toString();
      return;
    }
    if ("label_indent".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      Integer ii = (Integer) object;
      me.setLabelIndent(ii.intValue());
      return;
    }
    if ("width".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      Integer ii = (Integer) object;
      me.setValueSize(ii.intValue());
      return;
    }
    if ("showlabel".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      me.setLabelVisible(((Boolean) object).booleanValue());
      return;
    }
    if ("allowDateOverlay".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      me.setAllowDateOverlay(((Boolean) object).booleanValue());
      return;
    }
    if ("selectiontype".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      me.setSelectiontype("" + object);

      return;
    }
    if ("useLabelsForReadOnly".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      boolean val = ((Boolean) object).booleanValue();
      me.setUseLabelForReadOnlyProperties(val);
      return;
    }
    if ("alwaysUseLabel".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      boolean val = ((Boolean) object).booleanValue();
      me.setAlwaysUseLabel(val);
      return;
    }
    if ("selectionmode".equals(name)) {
      EchoPropertyComponent me = (EchoPropertyComponent) getActualComponent();
      boolean val = ((Boolean) object).booleanValue();
      me.setUseCheckBoxes(val);
      return;
    }
    if ("memoRowCount".equals(name)) {
      myPropertyComponent.setMemoRowCount(((Integer) object).intValue());
      return;
    }
    if ("memoColumnCount".equals(name)) {
      myPropertyComponent.setMemoColumnCount(((Integer) object).intValue());
      return;
    }
    if ("checkboxGroupColumnCount".equals(name)) {
      myPropertyComponent.setCheckboxGroupColumnCount(((Integer) object).intValue());
      return;
    }
    if ("visibleRowCount".equals(name)) {
      myPropertyComponent.setMultiRowCount(((Integer) object).intValue());
      return;
    }
    if ("maxImageHeight".equals(name)) {
      myPropertyComponent.setMaxImageHeight(((Integer) object).intValue());
      return;
    }
    if ("maxImageWidth".equals(name)) {
      myPropertyComponent.setMaxImageWidth(((Integer) object).intValue());
      return;
    }
    // if("verticalScrolls".equals(name)) {
    // setVerticalScrolls(((Boolean) object).booleanValue());
    // }
    // if("horizontalScrolls".equals(name)) {
    // setHorizontalScrolls(((Boolean) object).booleanValue());
    // }
    if ("capitalization".equals(name)) {
      myPropertyComponent.setCapitalization((String) object);
      return;
    }

    if ("propertyValue".equals(name)) {
      myPropertyComponent.setPropertyValue(object);
      return;
    }

    if ("border".equals(name)) {
      Component parent = myPropertyComponent.getParent();
      LayoutData ld = parent.getLayoutData();
      parent.remove(myPropertyComponent);
      GroupBox gb = new GroupBox("" + object);
      Style ss = Styles.DEFAULT_STYLE_SHEET.getStyle(gb.getClass(), "Default");
      gb.setStyle(ss);

      gb.add(myPropertyComponent);
      parent.add(gb);
      if (ld != null) {
        gb.setLayoutData(ld);
      }
      myPropertyComponent.setPropertyValue(object);
      setContainer(gb);
      return;
    }

    if ("allowStringLineWrap".equals(name)) {
      myPropertyComponent.setAllowLineWrap(((Boolean) object).booleanValue());
      return;
    }
    if ("visible".equals(name)) {
      myPropertyComponent.setVisible(((Boolean) object).booleanValue());
      return;
    }

    super.setComponentValue(name, object);
  }