/**
  * Evaluates the title expression in the null context and returns the result.
  *
  * @return Returns an empty string or the title expression.
  */
 private String getTitle() {
   IModelObject element = xidget.getConfig();
   IExpression titleExpr =
       Xlate.childGet(element, "title", Xlate.get(element, "title", (IExpression) null));
   if (titleExpr != null) return titleExpr.evaluateString();
   return "";
 }
  /* (non-Javadoc)
   * @see org.xidget.feature.IWidgetCreationFeature#createWidget()
   */
  public void createWidgets() {
    jPanel = new Canvas(xidget, new AnchorLayoutManager(xidget));
    jPanel.addMouseListener(mouseListener);
    jPanel.addMouseMotionListener(mouseListener);

    // create titled border if necessary (but not for tab entries)
    IXidget parent = xidget.getParent();
    if (parent != null && hasTitle()) {
      if (!parent.getConfig().isType("tabs")) jPanel.setBorder(new TitledBorder(getTitle()));
    }

    component = jPanel;

    // create scrollpane if requested
    if (Xlate.get(xidget.getConfig(), "scroll", false)) {
      component = new JScrollPane(jPanel);
    }

    // add panel to parent container
    IXidget xidgetParent = xidget.getParent();
    if (xidgetParent != null) {
      IWidgetContainerFeature containerFeature =
          xidget.getParent().getFeature(IWidgetContainerFeature.class);
      if (containerFeature != null) {
        int index = xidgetParent.getChildren().indexOf(xidget);
        containerFeature.addWidget(index, xidget);
      }
    }
  }
Пример #3
0
 public void notifyValue(
     IExpression expression,
     IContext[] contexts,
     IModelObject object,
     Object newValue,
     Object oldValue) {
   if (object == node) {
     ISliderWidgetFeature feature = xidget.getFeature(ISliderWidgetFeature.class);
     feature.setPrecision(Xlate.get(object, 1));
   }
 }
Пример #4
0
 public void notifyRemove(IExpression expression, IContext context, List<IModelObject> nodes) {
   node = expression.queryFirst(context);
   ISliderWidgetFeature feature = xidget.getFeature(ISliderWidgetFeature.class);
   feature.setPrecision(Xlate.get(node, 1));
 }
Пример #5
0
 public void notifyAdd(IExpression expression, IContext context, List<IModelObject> nodes) {
   node = nodes.get(0);
   ISliderWidgetFeature feature = xidget.getFeature(ISliderWidgetFeature.class);
   feature.setPrecision(Xlate.get(node, 1));
 }
 /**
  * Returns true if the widget has a title.
  *
  * @return Returns true if the widget has a title.
  */
 private boolean hasTitle() {
   IModelObject element = xidget.getConfig();
   IExpression titleExpr =
       Xlate.childGet(element, "title", Xlate.get(element, "title", (IExpression) null));
   return titleExpr != null;
 }