Package org.beryl.gui

Examples of org.beryl.gui.Widget


    }
  }

  private RadioButton findButton(Object object) throws GUIException {
    for (int i=0, count = getChildCount(); i<count; i++) {
      Widget widget = (Widget) getChild(i);
      if (widget instanceof RadioButton) {
        RadioButton button = (RadioButton) widget;
        if (button.getValue() == object || button.getValue().equals(object)) {
          return button;
        }
View Full Code Here


      if (((String) value).length() > 0)
        button.setMnemonic(((String) value).charAt(0));
      else
        button.setMnemonic('\0');
    } else if (name.equals("default")) {
      Widget widget = getParentWidgetByClass(Frame.class);
      if (widget == null) {
        widget = getParentWidgetByClass(Dialog.class);
      }
      if (widget == null) {
        throw new GUIException("Could not find root window");
      }
      if (((Boolean) value).booleanValue()) {
        widget.setProperty("default", this);
      } else {
        if (widget.getProperty("default") == this)
          widget.setProperty("default", null);
      }
    } else {
      super.setProperty(name, value);
    }
  }
View Full Code Here

          int sortedRow = sorter.getSortedRowForRow(row);
          try {
            TableRow tableRow = tableDataModel.getTableRow(sortedRow);
            String key = (String) columnKeys.get(column);
            if (tableRow.hasCustomRenderer(key)) {
              Widget renderer =
                tableRow.getRenderer(
                  Table.this,
                  getValueAt(row, column),
                  isCellSelected(row, column),
                  hasFocus(),
                  tableRow,
                  key);

              if (renderer != null) {
                return new CustomCellRenderer(renderer);
              }
            }
          } catch (GUIException e) {
            /* There should be no exception here */
            throw new RuntimeException(e);
          }

          if (tableDataModel != null) {
            Object object = tableDataModel.getValue(sortedRow, (String) columnKeys.get(column));
            if (object != null) {
              return getDefaultRenderer(object.getClass());
            }
          }
        }

        /* Fall back to the JTable internal processing */
        return super.getCellRenderer(row, column);
      }

      public TableCellEditor getCellEditor(int row, int column) {
        if (message == null) {
          int sortedRow = sorter.getSortedRowForRow(row);

          try {
            TableRow tableRow = tableDataModel.getTableRow(sortedRow);
            String key = (String) columnKeys.get(column);

            Widget editor =
              tableRow.getEditor(
                Table.this,
                getValueAt(row, column),
                tableDataModel.getTableRow(sortedRow),
                key);
View Full Code Here

    if (name.endsWith(".title") || name.endsWith(".icon") || name.endsWith(".tooltip")) {
      String widgetName = name.substring(0, name.indexOf('.'));
     
      paneInfo.put(name, value);
      if (isConstructed) {
        Widget widget = getChildWidgetByName(widgetName);
        if (widget != null) {
          int index = pane.indexOfComponent(widget.getWidget());
          if (index == -1)
            throw new GUIException("That widget is not a child of the tabbed pane");
          pane.removeTabAt(index);

          String title = (String) paneInfo.get(widgetName + ".title");
          if (title == null)
            title = "(unnamed)";
          pane.insertTab(
            title,
            (Icon) paneInfo.get(widgetName + ".icon"),
            widget.getWidget(),
            (String) paneInfo.get(widgetName + ".tooltip"), index);
        } else {
          throw new GUIException("A tab with that name was not found");
        }
      }
View Full Code Here

    layout.setRowWeight(widgets.size() * 2, 1);
    layout.setColumnWeight(3, 1);
    panel.setLayout(layout);
 
    for (int i = 0; i < widgets.size(); i++) {
      Widget widget = (Widget) widgets.get(i);
      if (widget instanceof LabeledWidget) {
        LabeledWidget lw = (LabeledWidget) widget;
        if (lw.getDataWidget().getWidget().getPreferredSize().height > DEFAULT_HEIGHT) {
          panel.add(lw.getLabel().getWidget(), constraints.rc(i * 2 + 1, 1, "rlt"));
        } else {
          panel.add(lw.getLabel().getWidget(), constraints.rc(i * 2 + 1, 1));
        }
        panel.add(lw.getDataWidget().getWidget(), constraints.rc(i * 2 + 1, 3));
      } else if (widget instanceof Separator) {
        panel.add(widget.getWidget(), constraints.rcwh(i * 2 + 1, 1, 3, 1));
      } else {
        panel.add(widget.getWidget(), constraints.rc(i * 2 + 1, 3, "rtb"));
      }
    }
    if (buttons.size() > 0) {
      JPanel buttonLayout = new JPanel();
      buttonLayout.setLayout(new BoxLayout(buttonLayout, BoxLayout.X_AXIS));
View Full Code Here

  public int getIndex(TreeNode node) {
    return super.getChildIndex((Widget) node);
  }

  public TreeNode getParent() {
    Widget parent = getParentWidget();
    try {
      return (TreeNode) parent;
    } catch (ClassCastException e) {
      return null;
    }
View Full Code Here

          (Dialog) WidgetFactory
            .getInstance()
            .constructWidget(getClass(), "AddInternationalizationDialog", new GUIEventListener() {
          public void eventOccured(GUIEvent event) {
            try {
              Widget source = event.getSource();
              if (event.getName().equals("ok")) {
                String key = (String) source.getDataModel().getValue("key");
                String value = (String) source.getDataModel().getValue("value");

                boolean isNew = (properties.getProperty(key) == null);
                properties.setProperty(key, value);
                if (isNew)
                  propertyModel.addRow(new PropertyTableRow(key));
                modified = true;
              }
              ((Dialog) source.getParentWidgetByClass(Dialog.class)).dispose();
            } catch (Exception e) {
              new MessageDialog(e);
            }
          }
        }, new MapDataModel());
View Full Code Here

      new MessageDialog(e);
    }
  }

  private void loadCustomComponent(String layoutName, String name, Validator validator) throws GUIException {
    Widget widget = WidgetFactory.getInstance().constructWidget(getClass(), name, this, dataModel, group);
    if (validator != null) {
      ((LabeledWidget) widget).getDataWidget().addValidator(validator);
    }

    ArrayList components = (ArrayList) customComponents.get(layoutName);
View Full Code Here

      }
    }

    try {
      for (int i = 0; i < activeComponents.size(); i++) {
        Widget widget = (Widget) activeComponents.get(i);

        widget.recursiveValidate();
      }
      okButton.setEnabled(true);
    } catch (ValidationException ex) {
      okButton.setEnabled(false);
    }
View Full Code Here

  private TableEditor borderEditor = null;

  public BorderAdapter() {
    borderEditor = new ButtonEditor("edit", this) {
      public Widget getEditor(Table table, Object value, TableRow row, String key) throws GUIException {
        Widget widget = super.getEditor(table, value, row, key);
        MapDataModel dataModel = widget.getDataModel();
        dataModel.setValue("row", row);
        dataModel.setValue("frame", table.getParentWidgetByClass(Frame.class));
        return widget;
      }
    };
View Full Code Here

TOP

Related Classes of org.beryl.gui.Widget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.