Example usage for com.jgoodies.binding.value ValueHolder ValueHolder

List of usage examples for com.jgoodies.binding.value ValueHolder ValueHolder

Introduction

In this page you can find the example usage for com.jgoodies.binding.value ValueHolder ValueHolder.

Prototype

public ValueHolder(long initialValue) 

Source Link

Document

Constructs a ValueHolder with the specified initial long value that is converted to a Long object.

Usage

From source file:ambit2.ui.editors.SelectFieldsPanel.java

License:Open Source License

protected void buildPanel(String help) {
    FormLayout layout = new FormLayout(
            "3dlu,fill:40dlu:grow,fill:120dlu:grow,3dlu,32dlu, 3dlu, fill:40dlu:grow,fill:120dlu:grow,3dlu", //columns
            "3dlu,12dlu,3dlu,top:[pref,36dlu], 24dlu,3dlu,24dlu,3dlu,24dlu,3dlu,24dlu,bottom:[pref,72dlu]:grow,1dlu,pref,pref,pref,pref,pref"); //rows
    setLayout(layout);/*w  w w  . ja  v a2  s .c  o m*/
    CellConstraints cc = new CellConstraints();

    add(createSeparator("Available"), cc.xywh(2, 2, 2, 1));
    add(createSeparator("Selected"), cc.xywh(7, 2, 2, 1));

    tables = new JList[fieldsModel.length];
    for (int i = 0; i < fieldsModel.length; i++) {
        tables[i] = new JList(fieldsModel[i]);

        SelectionInList<Property> selectionInList = new SelectionInList<Property>(fieldsModel[i]);
        Bindings.bind(tables[i], selectionInList);
        JScrollPane p = new JScrollPane(tables[i]);
        p.setBorder(BorderFactory.createEtchedBorder());
        p.setPreferredSize(new Dimension(160, 280));
        int offset = 2 + i * 5;
        add(p, cc.xywh(offset, 4, 2, 9));

        BeanAdapter beanAdapter = new BeanAdapter(selectionInList);

        String[][] config = { { "name", "Name" }, { "label", "Alias" }, { "units", "Units" },
                { "title", "url" }, { "url", "WWW" } };
        for (int j = 0; j < config.length; j++) {
            String[] c = config[j];
            ValueModel model = beanAdapter.getValueModel(c[0]);
            add(BasicComponentFactory.createLabel(new ValueHolder(c[1])), cc.xywh(offset, j + 14, 1, 1));
            JTextField t = BasicComponentFactory.createTextField(model);
            t.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseEntered(MouseEvent e) {
                    super.mouseEntered(e);
                    ((JTextField) e.getSource()).setToolTipText(((JTextField) e.getSource()).getText());
                }
            });
            add(t, cc.xywh(offset + 1, j + 14, 1, 1));
        }
        /*
        ValueModel nameModel = beanAdapter.getValueModel("name");
        ValueModel commentsModel = beanAdapter.getValueModel("label");
        ValueModel titleModel = beanAdapter.getValueModel("title");
        ValueModel urlModel = beanAdapter.getValueModel("url");           
        //p.add(BasicComponentFactory.createTextField(parentModel));         
        add(BasicComponentFactory.createLabel(new ValueHolder("Name")),cc.xywh(offset,14,1,1));
        add(BasicComponentFactory.createTextField(nameModel),cc.xywh(offset+1,14,1,1));
        add(BasicComponentFactory.createLabel(new ValueHolder("Alias")),cc.xywh(offset,15,1,1));
        add(BasicComponentFactory.createTextField(commentsModel),cc.xywh(offset+1,15,1,1));
        add(BasicComponentFactory.createLabel(new ValueHolder("Reference")),cc.xywh(offset,16,1,1));
        add(BasicComponentFactory.createTextField(titleModel),cc.xywh(offset+1,16,1,1));         
        add(BasicComponentFactory.createLabel(new ValueHolder("WWW")),cc.xywh(offset,17,1,1));
        add(BasicComponentFactory.createTextField(urlModel),cc.xywh(offset+1,17,1,1));     
        */
    }

    buttons = new ArrayList<JButton>();
    int i = 0;
    for (MOVE op : MOVE.values()) {
        JButton button = new JButton(op.display());
        button.setPreferredSize(new Dimension(24, 24));
        button.setMaximumSize(new Dimension(24, 24));
        add(button, cc.xywh(5, 5 + (i * 2), 1, 1));
        button.addActionListener(this);
        button.setActionCommand(op.toString());
        i++;
    }

    /*
    JToolBar toolBar[] = new JToolBar[2];
    toolBar[0] = new JToolBar();
    toolBar[0].add(new JButton("Find"));
    toolBar[0].add(new JToolBar.Separator());
    toolBar[0].add(new JButton("Select all"));
    toolBar[0].add(new JButton("Unselect all"));
    toolBar[0].setFloatable(false);
    add(toolBar[0],cc.xywh(2,14,1,1));
            
    toolBar[1] = new JToolBar();
    toolBar[1].add(new JButton("Move Up"));
    toolBar[1].add(new JButton("Move Down"));
    toolBar[1].add(new JToolBar.Separator());
    toolBar[1].add(new JButton("Select all"));
    toolBar[1].add(new JButton("Unselect all"));
    toolBar[1].setFloatable(false);
    add(toolBar[1],cc.xywh(6,14,1,1));
    */
    /*
    helpArea = new JTextPane();
    helpArea.setText(help);
    helpArea.setEditable(false);
    helpArea.setBackground(new Color(255,255,225));
    helpArea.setPreferredSize(new Dimension(288,48));
    add(new JScrollPane(helpArea),cc.xywh(2,16,5,1));
    */

}

From source file:com.salas.bb.core.GlobalController.java

License:Open Source License

/**
 * Adds new channel to the currently selected guide after currently selected channel.
 *
 * @param url           URL to use for addition or separated list of URL's.
 * @param forceQuery    TRUE to open dialog for URL querying.
 *
 * @return new feed (the first from the list in multi-mode) or
 *         NULL if selected guide isn't Standard Guide or URL's weren't specified.
 *///from ww w . java2s  .c  o  m
public DirectFeed createDirectFeed(String url, boolean forceQuery) {
    DirectFeed feed = null;
    IGuide guide = model.getSelectedGuide();

    if (guide == null || guide instanceof StandardGuide) {
        if (url == null || forceQuery) {
            ValueHolder urlHolder = new ValueHolder(url);

            AddDirectFeedDialog dialog = new AddDirectFeedDialog(getMainFrame(), urlHolder);
            dialog.open();

            url = dialog.hasBeenCanceled() ? null : (String) urlHolder.getValue();
        }

        Set<String> urls = parseMultiURL(url);
        DirectFeed[] feeds = createDirectFeeds(urls, (StandardGuide) guide);

        if (feeds.length > 0)
            feed = feeds[0];
    }

    return feed;
}

From source file:com.salas.bb.dialogs.guide.BasicGuideDialog.java

License:Open Source License

/**
 * Creates dialog./*from  ww  w  .  j  a v  a2s.c  o  m*/
 *
 * @param aFrame                    parent frame.
 * @param aTitle                    dialog title.
 * @param aPublishingAvailable      <code>TRUE</code> if publishing is available.
 * @param aPublishingLimit          the number of guides the user can have published.
 * @param aPublishingLimitReached   <code>TRUE</code> if the limit is reached.
 */
public BasicGuideDialog(Frame aFrame, String aTitle, boolean aPublishingAvailable, int aPublishingLimit,
        boolean aPublishingLimitReached) {
    super(aFrame, aTitle);

    publishingAvailable = aPublishingAvailable;
    publishingLimit = aPublishingLimit;
    publishingLimitReached = aPublishingLimitReached;

    presentTitles = Collections.EMPTY_SET;
    model = new GuideIcons.ComboBoxModel();
    renderer = new IconListCellRenderer();
    readingListsModel = new ReadingListsTableModel();

    tblReadingLists = new JTable(readingListsModel);
    tblReadingLists.setDefaultRenderer(String.class, new ReadingListsTableCellRenderer(readingListsModel));
    UifUtilities.setTableColWidth(tblReadingLists, 2, 90);

    btnAddReadingList = new JButton(null, ResourceUtils.getIcon("add.icon"));
    btnAddReadingList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            onAddReadingList();
        }
    });
    btnRemoveList = new JButton(null, ResourceUtils.getIcon("delete.icon"));
    btnRemoveList.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            onRemoveReadingList();
        }
    });

    // Publishing components
    chPublishingEnabled = ComponentsFactory.createCheckBox(Strings.message("guide.dialog.enable.publishing"));
    lbPublishingPublic = new JLabel(Strings.message("guide.dialog.public.visibility"));
    chPublishingPublic = new JCheckBox();
    lbPublishingTitle = ComponentsFactory.createLabel(Strings.message("guide.dialog.reading.list.title"));
    lbPublishingTags = ComponentsFactory.createLabel(Strings.message("guide.dialog.tags"));
    lbPublishingURL = new JLabel(Strings.message("guide.dialog.publicationurl"));
    lnkPublishingURL = new LinkLabel(Strings.message("guide.dialog.not.published.yet"));
    lbLastPublishingDate = new JLabel(Strings.message("guide.dialog.last.update.date"));
    tfLastPublishingDate = new JLabel(Strings.message("guide.dialog.never.updated"));
    tfPublishingTitle = new JTextField();
    lbPublishingTitle.setLabelFor(tfPublishingTitle);
    tfPublishingTags = new JTextField();
    lbPublishingTags.setLabelFor(tfPublishingTags);

    vhPublishingRating = new ValueHolder(1);
    sscPublishingRating = new StarsSelectionComponent(new BoundedRangeAdapter(vhPublishingRating, 0, 1, 5));
    lbPublishingRating = new JLabel(Strings.message("guide.dialog.rating"));

    btnCopyToClipboard = new JButton(Strings.message("guide.dialog.copy"));
    btnCopyToClipboard.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CommonUtils.copyTextToClipboard(lnkPublishingURL.getText());
        }
    });

    onPublishingEnabled();
    chPublishingEnabled.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            onPublishingEnabled();
        }
    });

    chAllowNotifications = ComponentsFactory
            .createCheckBox(Strings.message("guide.dialog.allow.notifications"));
}

From source file:com.salas.bb.discovery.filter.TestDynamicExtensionURLFilter.java

License:Open Source License

/**
 * Tests dynamic changes to the bean parameter holding the list of extensions.
 *///  ww  w.jav  a2 s  . c  om
public void testDynamicChange() {
    URL url = url("test.avi?test=parameter");
    ValueHolder extensions = new ValueHolder(null);
    DynamicExtensionURLFilter f = new DynamicExtensionURLFilter(extensions, "value");

    // We start with empty list of extensions
    assertFalse("No extensions in the filter", f.matches(url));

    // We set some extensions, but it should be still false
    extensions.setValue("mpg");
    assertFalse("Wrong extensions in the filter", f.matches(url));

    // We add right extension
    extensions.setValue("mpg, aVi");
    assertTrue("Right extensions in the filter", f.matches(url));

    // We remove that right extension
    extensions.setValue(" mov ");
    assertFalse("Wrong extensions in the filter", f.matches(url));

    // We clear the filter extensions
    extensions.setValue(null);
    assertFalse("No extensions in the filter", f.matches(url));
}

From source file:com.salas.bb.views.ArticleListPanel.java

License:Open Source License

/**
 * Constructs panel with list of articles for selected channel.
 *///from w w  w . j  ava  2  s .com
public ArticleListPanel() {
    super(Strings.message("panel.articles"));

    setPreferredSize(new Dimension(300, 100));

    RenderingManager.addPropertyChangeListener(RenderingSettingsNames.THEME, this);

    // Register own controller listener
    GlobalController.SINGLETON.addControllerListener(new ControllerListener());
    PropertyChangeListener articleViewChangeHandler = new ArticleViewChangeHandler();
    GlobalModel.SINGLETON.getGlobalRenderingSettings().addPropertyChangeListener("articleViewMode",
            articleViewChangeHandler);

    // Set the sub-toolbar (right justified in the CoolInternalFrame)
    pageModel = new ValueHolder(0);
    pageModel.addValueChangeListener(new PageModelListener());
    ValueModel pageCountModel = new ValueHolder(0);
    subToolBar = createSubtoolbar();
    setHeaderControl(subToolBar);

    // Create the list that will contain the channels. Uses a custom
    // renderer.
    HTMLFeedDisplayConfig htmlConfig = new HTMLFeedDisplayConfig();
    ImageFeedDisplayConfig imageConfig = new ImageFeedDisplayConfig();
    RenderingManager.addPropertyChangeListener(htmlConfig.getRenderingManagerListener());
    RenderingManager.addPropertyChangeListener(imageConfig.getRenderingManagerListener());

    // Get page size user preferences and subscribe to updates
    UserPreferences preferences = GlobalModel.SINGLETON.getUserPreferences();
    PropertyAdapter paPageSize = new PropertyAdapter(preferences, UserPreferences.PROP_PAGE_SIZE, true);
    paPageSize.addPropertyChangeListener(new PageSizeListener());

    feedDisplay = new CompositeFeedDisplay(htmlConfig, imageConfig, pageModel, pageCountModel);
    feedDisplay.setPageSize(preferences.getPageSize());

    // Setup data-adapter
    FeedDisplayAdapter adapter = new FeedDisplayAdapter(feedDisplay);
    GlobalController.SINGLETON.addControllerListener(adapter);

    // Create scroll pane and put list in it
    JScrollPane listSP = new JumplessScrollPane(feedDisplay.getComponent());
    listSP.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listSP.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    listSP.setFocusable(false);
    listSP.setBorder(null);

    // Register viewport to enable correct scrolling
    feedDisplay.setViewport(listSP.getViewport());

    JPanel content = new JPanel(new BorderLayout());
    content.add(new PagingPanel(pageModel, pageCountModel), BorderLayout.NORTH);
    content.add(listSP, BorderLayout.CENTER);

    // Register scroll pane
    setContent(content);

    setFeedTitle(null);
}

From source file:com.salas.bb.views.feeds.FeedDisplayModel.java

License:Open Source License

/**
 * Creates model w/o highlights advisor.
 */
public FeedDisplayModel() {
    this(new ValueHolder(0));
}

From source file:com.salas.bb.views.feeds.html.TestHTMLFeedDisplay.java

License:Open Source License

protected void setUp() throws Exception {
    super.setUp();

    feed = new DirectFeed();

    view = new HTMLFeedDisplay(new SampleHTMLFeedDisplayConfig(), new ValueHolder(0), new ValueHolder(0));
    view.setFeed(feed);//w  ww. jav  a  2  s .  c om

    article1 = createArticle(DELTA_TOMORROW);
    article2 = createArticle(DELTA_30_DAYS_AGO);
    article3 = createArticle(DELTA_30_DAYS_AGO + DAY);
}

From source file:com.salas.bb.whatshot.TestListModelEvents.java

License:Open Source License

/**
 * Configures the environment./*from ww  w . ja v  a 2s  .  co m*/
 *
 * @throws Exception if something goes wrong.
 */
protected void setUp() throws Exception {
    super.setUp();

    listener = new Mock(IResultsListModelListener.class);
    seq = 0;

    ResourceUtils.setBundlePath("Resource");

    // Create 6 articles: 3 for the first feed, 2 for the second and 1 for the third
    article11 = article(mention("1", "1"), "11");
    article12 = article(mention("1", "2"), "12");
    article13 = article(mention("1", "3"), "13");
    article21 = article(mention("2", "1"), "21");
    article22 = article(mention("2", "2"), "22");
    article31 = article(mention("3", "1"), "31");

    // Create 3 feeds
    feed1 = new DirectFeed();
    feed1.appendArticle(article11);
    feed1.appendArticle(article12);
    feed1.appendArticle(article13);
    feed2 = new DirectFeed();
    feed2.appendArticle(article21);
    feed2.appendArticle(article22);
    feed3 = new DirectFeed();
    feed3.appendArticle(article31);

    // Create 2 guides
    guide1 = new StandardGuide();
    guide1.setTitle("1");
    guide1.add(feed1);
    guide1.add(feed2);
    guide2 = new StandardGuide();
    guide2.setTitle("2");
    guide1.add(feed3);

    // Create the guides set
    set = new GuidesSet();
    set.add(guide1);
    set.add(guide2);

    // Create a model with an item
    engine = new Engine(set);
    mdlStarz = new ValueHolder(1);
    mdlOnlyUnread = new ValueHolder(false);
    mdlToday = new ValueHolder(TimeOption.THIS_WEEK);
    model = new ListModel(engine, mdlStarz, mdlOnlyUnread, mdlToday);
    model.addListener((IResultsListModelListener) listener.proxy());
}

From source file:com.starillon.ibtradetools.ui.spreadcalc.SpreadStrategySelector.java

private void initModels() {
    //---- monthList ----
    monthList.setModel(new DefaultComboBoxModel(ContractMonth.MONTH_LIST));
    int currentYear = Calendar.getInstance().get(Calendar.YEAR);
    List<Integer> years = Lists.newArrayList();
    for (int i = 0; i < 10; ++i) {
        years.add(currentYear + i);/* ww  w  . j a v a 2  s.c o  m*/
    }
    yearList.setModel(new DefaultComboBoxModel(years.toArray()));

    ValueModel selectionHolder = new ValueHolder("Select Strategy");
    List<SpreadStrategy> strategies = Lists.newArrayList();
    strategies.add(SpreadStrategy.BEAR_PUT_SPREAD);
    strategies.add(SpreadStrategy.BULL_PUT_SPREAD);
    strategies.add(SpreadStrategy.BEAR_CALL_SPREAD);
    strategies.add(SpreadStrategy.BULL_CALL_SPREAD);

    strategyList.setModel(new ComboBoxAdapter(strategies, selectionHolder));
}

From source file:cz.vity.freerapid.gui.dialogs.DownloadHistoryDialog.java

private void bindCombobox(final JComboBox combobox, String key, final Object defaultValue,
        final String[] values) {
    if (values == null)
        throw new IllegalArgumentException("List of combobox values cannot be null!!");
    final MyPreferencesAdapter adapter = new MyPreferencesAdapter(key, defaultValue);
    final SelectionInList<String> inList = new SelectionInList<String>(values,
            new ValueHolder(values[(Integer) adapter.getValue()]), adapter);
    Bindings.bind(combobox, inList);
}