示例#1
0
  public JPanel getInterfaceVisualizer() {
    JPanel panel = new JPanel();
    final JLabel ipLabel = new JLabel();

    if (isVersion4()) {
      ipLabel.setText("IPv4 address: " + getIPString());
    } else if (isVersion6()) {
      ipLabel.setText("IPv6 address: " + getIPString());
    } else {
      ipLabel.setText("Unknown IP");
    }

    panel.add(ipLabel);

    Observer observer;
    this.addObserver(
        observer =
            new Observer() {
              public void update(Observable obs, Object obj) {
                if (isVersion4()) {
                  ipLabel.setText("IPv4 address: " + getIPString());
                } else if (isVersion6()) {
                  ipLabel.setText("IPv6 address: " + getIPString());
                } else {
                  ipLabel.setText("Unknown IP");
                }
              }
            });

    panel.putClientProperty("intf_obs", observer);

    return panel;
  }
  /** Constructor */
  public MapListCellRenderer() {
    JPanel pFirst = new JPanel();
    pFirst.setOpaque(false);
    pFirst.setLayout(new BorderLayout(5, 0));
    pFirst.add(mapNameLabel, BorderLayout.CENTER);
    pFirst.add(playerCountLabel, BorderLayout.EAST);
    pFirst.setAlignmentX(Component.LEFT_ALIGNMENT);
    rightPanelPart.add(pFirst);
    rightPanelPart.add(mapIdLabel);
    mapIdLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    rightPanelPart.add(descriptionLabel);
    descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    rightPanelPart.setOpaque(false);
    rightPanelPart.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    mapNameLabel.setFont(mapNameLabel.getFont().deriveFont(Font.BOLD));
    mapNameLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    mapNameLabel.setForeground(FOREGROUND);
    mapIdLabel.setForeground(FOREGROUND);
    descriptionLabel.setForeground(FOREGROUND);
    playerCountLabel.setForeground(Color.BLUE);

    contentsPanel.setLayout(new BorderLayout());
    contentsPanel.add(rightPanelPart, BorderLayout.CENTER);
    contentsPanel.add(iconLabel, BorderLayout.WEST);
    contentsPanel.putClientProperty(ELFStyle.KEY, ELFStyle.PANEL_DRAW_BG_CUSTOM);

    iconLabel.setOpaque(false);
    iconLabel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));

    // Update UI
    SwingUtilities.updateComponentTreeUI(contentsPanel);
  }
  private void init() {
    JPanel quickSearchPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));

    final TreeModel treeModel = explorer.getTreeModel();
    final QuickTreeFilterField field =
        new QuickTreeFilterField(treeModel) {
          protected FilterableTreeModel createDisplayTreeModel(TreeModel treeModel) {
            return new FilterableTreeModel(treeModel) {
              @Override
              protected void configureListModelWrapper(ListModelWrapper wrapper, Object node) {

                if (node instanceof DefaultMutableTreeNode) {
                  // ImageFileExplorer.LazyNode inode = (ImageFileExplorer.LazyNode) node;
                  DefaultMutableTreeNode inode = (DefaultMutableTreeNode) node;
                  boolean expanded = explorer.getJTree().isExpanded(new TreePath(inode.getPath()));
                  if (inode.isLeaf() || expanded) {
                    super.configureListModelWrapper(wrapper, node);
                  }
                }
              }
            };
          }
        };

    field.setSearchingDelay(200);
    quickSearchPanel.add(field);

    JPanel treePanel = new JPanel(new BorderLayout(2, 2));

    field.setTree(explorer.getJTree());
    SearchableUtils.installSearchable(field.getTree());

    JTree tree = field.getTree();
    tree.setModel(field.getDisplayTreeModel());
    DataTipManager.get().register(tree);

    treePanel.add(explorer.getComponent());

    mainPanel.add(treePanel);
    mainPanel.add(quickSearchPanel, BorderLayout.BEFORE_FIRST_LINE);

    EventBus.subscribeStrongly(
        DataSourceStatusEvent.class,
        new EventSubscriber<DataSourceStatusEvent>() {
          @Override
          public void onEvent(DataSourceStatusEvent event) {
            explorer.getJTree().repaint();
          }
        });

    mainPanel.putClientProperty(IActionProvider.KEY, this);
  }
示例#4
0
  public void setSelectedIndex(int index) {
    Component c = getComponentAt(index);
    if (c instanceof LoadingPanel) {
      JPanel p = (JPanel) c;
      if (p.getClientProperty("BINDED") == null) {
        new Thread(new BindingRunnable(index, openers.get(index))).start();
        p.putClientProperty("BINDED", true);
      }
    }

    this.oldIndex = getSelectedIndex();
    super.setSelectedIndex(index);
  }
示例#5
0
  public JPanel getInterfaceVisualizer() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    final NumberFormat form = NumberFormat.getNumberInstance();

    final JLabel positionLabel = new JLabel();
    positionLabel.setText(
        "x="
            + form.format(getXCoordinate())
            + " "
            + "y="
            + form.format(getYCoordinate())
            + " "
            + "z="
            + form.format(getZCoordinate()));

    panel.add(positionLabel);

    Observer observer;
    this.addObserver(
        observer =
            new Observer() {
              public void update(Observable obs, Object obj) {
                positionLabel.setText(
                    "x="
                        + form.format(getXCoordinate())
                        + " "
                        + "y="
                        + form.format(getYCoordinate())
                        + " "
                        + "z="
                        + form.format(getZCoordinate()));
              }
            });

    // Saving observer reference for releaseInterfaceVisualizer
    panel.putClientProperty("intf_obs", observer);

    return panel;
  }
示例#6
0
  public JPanel getInterfaceVisualizer() {
    JPanel panel = new JPanel();
    final JLabel idLabel = new JLabel();

    idLabel.setText("Mote ID: " + getMoteID());

    panel.add(idLabel);

    Observer observer;
    this.addObserver(
        observer =
            new Observer() {
              public void update(Observable obs, Object obj) {
                idLabel.setText("Mote ID: " + getMoteID());
              }
            });

    // Saving observer reference for releaseInterfaceVisualizer
    panel.putClientProperty("intf_obs", observer);

    return panel;
  }
  private void initializeLayout() {
    if (!(vsr instanceof JDialog)) {
      UserInfo ui = pst.getApplicationUser();
      String userName = ui.getUsername();
      viewLayout = new MainFormLayout(getTitle(), "system1".equals(userName) ? " " : userName);

      JPanel formPanel = (JPanel) AttributeAccessor.get(vsr, "pnlMain");
      formPanel.putClientProperty("pnlMain", true);

      /*
                  JPanel footerPanel = (JPanel) AttributeAccessor.get(vsr, "footerPanel");
                  Component[]  components=footerPanel.getComponents();
                  for(int i=0;i<components.length;i++){
                      if(components[i] instanceof JLabel){
                          ((JLabel)components[i]).setBackground(new Color(-13395480));
                          ((JLabel)components[i]).setOpaque(true);
                          ((JLabel)components[i]).setForeground(new Color(-1));
                      }
                  }
      */

      viewLayout.contentPanel.add(formPanel, BorderLayout.CENTER);

      AbstractAction aa =
          new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
              if (logger.isDebugEnabled()) logger.debug("Closing view for " + pst);
              pst.closeView();
            }
          };

      if (pst instanceof FindPresenter || pst.isShowCloseButton()) {
        logger.info("Close button added to view");
        //                ((HeaderPanel) viewLayout.headerPanel).createCloseButton(aa);
      }
      addUserInfo();
    }
  }
 public ParentComponentInfo setBindingPath(JPanel jpanel, String... paths) {
   ParentComponentInfo parentComponentInfo = new ParentComponentInfo(paths);
   jpanel.putClientProperty(BindingBuilder.BINDING_PATHS, parentComponentInfo);
   return parentComponentInfo;
 }