Example usage for com.jgoodies.forms.layout CellConstraints xy

List of usage examples for com.jgoodies.forms.layout CellConstraints xy

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints xy.

Prototype

public CellConstraints xy(int col, int row) 

Source Link

Document

Sets column and row origins; sets width and height to 1; uses the default alignments.

Examples:

 cc.xy(1, 1); cc.xy(1, 3); 

Usage

From source file:com.qspin.qtaste.ui.testcampaign.TestCampaignMainPanel.java

License:Open Source License

public void genUI() {
    TestCampaignTreeModel model = new TestCampaignTreeModel("Test Campaign");
    treeTable = new JTreeTable(model);

    FormLayout layout = new FormLayout("6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px:grow",
            "6px, fill:pref, 6px");
    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    int colIndex = 2;

    JLabel label = new JLabel("Campaign:");
    saveMetaCampaignButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/save_32"));
    saveMetaCampaignButton.setToolTipText("Save campaign");
    saveMetaCampaignButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (selectedCampaign == null) {
                logger.warn("No Campaign created");
                return;
            }/*ww w .j  a v  a  2  s .co  m*/
            treeTable.save(selectedCampaign.getFileName(), selectedCampaign.getCampaignName());
        }
    });
    addNewMetaCampaignButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/add"));
    addNewMetaCampaignButton.setToolTipText("Define a new campaign");
    addNewMetaCampaignButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            String newCampaign = JOptionPane.showInputDialog(null, "New campaign creation:", "Campaign name:",
                    JOptionPane.QUESTION_MESSAGE);
            if (newCampaign != null && newCampaign.length() > 0) {
                int index = addTestCampaign(newCampaign);
                metaCampaignComboBox.setSelectedIndex(index);
                MetaCampaignFile currentSelectedCampaign = (MetaCampaignFile) metaCampaignComboBox
                        .getSelectedItem();
                selectedCampaign = currentSelectedCampaign;
                if (selectedCampaign != null) {
                    treeTable.save(selectedCampaign.getFileName(), selectedCampaign.getCampaignName());
                }
                metaCampaignComboBox.validate();
                metaCampaignComboBox.repaint();
            }
        }
    });

    // get last selected campaign
    GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
    String lastSelectedCampaign = guiConfiguration.getString(LAST_SELECTED_CAMPAIGN_PROPERTY);

    // add campaigns found in the list
    MetaCampaignFile[] campaigns = populateCampaignList();
    builder.add(label, cc.xy(colIndex, 2));
    colIndex += 2;
    builder.add(metaCampaignComboBox, cc.xy(colIndex, 2));
    colIndex += 2;

    // add test campaign mouse listener, for the Rename and Remove actions
    TestcampaignMouseListener testcampaignMouseListener = new TestcampaignMouseListener();
    java.awt.Component[] mTestcampaignListComponents = metaCampaignComboBox.getComponents();
    for (int i = 0; i < mTestcampaignListComponents.length; i++) {
        mTestcampaignListComponents[i].addMouseListener(testcampaignMouseListener);
    }

    metaCampaignComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            MetaCampaignFile currentSelectedCampaign = (MetaCampaignFile) metaCampaignComboBox
                    .getSelectedItem();
            if (currentSelectedCampaign != selectedCampaign) {
                selectedCampaign = currentSelectedCampaign;
                if (selectedCampaign != null) {
                    treeTable.removeAll();
                    if (new File(selectedCampaign.getFileName()).exists()) {
                        treeTable.load(selectedCampaign.getFileName());
                    }

                    GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
                    guiConfiguration.setProperty(LAST_SELECTED_CAMPAIGN_PROPERTY,
                            selectedCampaign.getCampaignName());
                    try {
                        guiConfiguration.save();
                    } catch (ConfigurationException ex) {
                        logger.error("Error while saving GUI configuration: " + ex.getMessage(), ex);
                    }
                } else {
                    treeTable.removeAll();
                }
            }
        }
    });

    boolean setLastSelectedCampaign = false;
    if (lastSelectedCampaign != null) {
        // select last selected campaign
        for (int i = 0; i < campaigns.length; i++) {
            if (campaigns[i].getCampaignName().equals(lastSelectedCampaign)) {
                metaCampaignComboBox.setSelectedIndex(i);
                setLastSelectedCampaign = true;
                break;
            }
        }
    }
    if (!setLastSelectedCampaign && metaCampaignComboBox.getItemCount() > 0) {
        metaCampaignComboBox.setSelectedIndex(0);
    }

    runMetaCampaignButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/running_32"));
    runMetaCampaignButton.setToolTipText("Run campaign");
    runMetaCampaignButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                if (selectedCampaign == null) {
                    logger.warn("No Campaign created");
                    return;
                }

                // first save the current campaign if needed
                if (treeTable.hasChanged()) {
                    treeTable.save(selectedCampaign.getFileName(), selectedCampaign.getCampaignName());
                }

                // set SUT version
                TestBedConfiguration.setSUTVersion(parent.getSUTVersion());

                testExecutionHandler = new CampaignExecutionThread(selectedCampaign.getFileName());
                Thread t = new Thread(testExecutionHandler);
                t.start();
                // set the window to test result
                // TO DO
            } catch (Exception ex) {
                //
                logger.error(ex.getMessage(), ex);
            }
        }
    });

    builder.add(addNewMetaCampaignButton, cc.xy(colIndex, 2));
    colIndex += 2;
    builder.add(saveMetaCampaignButton, cc.xy(colIndex, 2));
    colIndex += 2;
    builder.add(runMetaCampaignButton, cc.xy(colIndex, 2));
    colIndex += 2;

    JScrollPane sp = new JScrollPane(treeTable);
    this.add(builder.getPanel(), BorderLayout.NORTH);
    this.add(sp);
}

From source file:com.qspin.qtaste.ui.TestCaseInteractivePanel.java

License:Open Source License

public void init() {
    try {//  w ww  .  j av  a2  s  . c  o  m
        initIcons();
        JPanel topPanel = new JPanel(new BorderLayout());

        mStartInteractiveTestButton = new JButton();
        mStartInteractiveTestButton.setText("Start Interactive mode");

        StartButtonAction startButtonListener = new StartButtonAction();
        mStartInteractiveTestButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/running_32"));
        mStartInteractiveTestButton.addActionListener(startButtonListener);

        mStopInteractiveTestButton = new JButton();
        mStopInteractiveTestButton.setText("Stop Interactive mode");
        mStopInteractiveTestButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/stop"));
        StopInterractiveButtonAction stopButtonListener = new StopInterractiveButtonAction();
        mStopInteractiveTestButton.setEnabled(false);
        mStopInteractiveTestButton.addActionListener(stopButtonListener);

        FormLayout layout = new FormLayout("6px, pref, 6px, pref, 6px, pref, 6px:grow", "6px, fill:pref, 6px");
        PanelBuilder builder = new PanelBuilder(layout);
        CellConstraints cc = new CellConstraints();
        builder.add(mStartInteractiveTestButton, cc.xy(2, 2));
        builder.add(mStopInteractiveTestButton, cc.xy(4, 2));
        builder.add(new CommonShortcutsPanel(), cc.xy(6, 2));
        JPanel northP = builder.getPanel();
        topPanel.add(northP, BorderLayout.PAGE_START);

        mInteractiveText = new JTextField();
        mExecuteButton = new JButton();
        mExecuteButton.setText("Execute");
        mExecuteButton.setEnabled(false);
        ExecuteButtonAction executeButtonListener = new ExecuteButtonAction();
        mExecuteButton.addActionListener(executeButtonListener);
        mInteractiveText.addActionListener(executeButtonListener);

        mInteractiveText.setEnabled(false);

        topPanel.add(mInteractiveText, BorderLayout.CENTER);
        topPanel.add(mExecuteButton, BorderLayout.EAST);
        add(topPanel, BorderLayout.NORTH);

        log4jPane = new Log4jPanel();

        JSplitPane bottomSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        bottomSplitPane.setResizeWeight(0.5);
        bottomSplitPane.setDividerSize(4);

        bottomSplitPane.setBottomComponent(log4jPane);

        mLogPanel.init();
        testDataView = new TestDataEditor(true);

        JSplitPane topSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        topSplitPane.setResizeWeight(0.8);
        topSplitPane.setDividerSize(4);
        topSplitPane.setTopComponent(mLogPanel);

        topSplitPane.setBottomComponent(testDataView);
        bottomSplitPane.setTopComponent(topSplitPane);
        this.add(bottomSplitPane);

        this.apiTree.addTreeSelectionListener(new TCTreeListener());

        // initialize testData
        m_testData = new TestDataInteractive("QTaste_interactive", 1, null, null);
        m_testData.setGUIMonitoring(true, this);
        String defaultInstance = null;
        try {
            TestBedConfiguration testbedConfig = TestBedConfiguration.getInstance();
            if (testbedConfig != null) {
                defaultInstance = testbedConfig.getDefaultInstanceId();
            }
        } catch (Exception e) {
        }
        m_testData.setValue("INSTANCE_ID", defaultInstance);
        testDataView.setTestData(m_testData);

        TestBedConfiguration
                .registerConfigurationChangeHandler(new TestBedConfiguration.ConfigurationChangeHandler() {

                    public void onConfigurationChange() {
                        String defaultInstance = null;
                        try {
                            TestBedConfiguration testbedConfig = TestBedConfiguration.getInstance();
                            if (testbedConfig != null) {
                                defaultInstance = testbedConfig.getDefaultInstanceId();
                            }
                        } catch (Exception e) {
                        }
                        try {
                            m_testData.setValue("INSTANCE_ID", defaultInstance);
                            testDataView.setTestData(m_testData);
                        } catch (QTasteDataException ex) {
                        }
                    }
                });
    } catch (QTasteDataException ex) {
    }
}

From source file:com.qspin.qtaste.ui.TestCasePane.java

License:Open Source License

protected void genUI() {
    executeButton.setMnemonic(KeyEvent.VK_R);
    saveButton.setMnemonic(KeyEvent.VK_C);
    startExecutionButton.setMnemonic(KeyEvent.VK_N);
    tcDocsPane.setEditable(false);//from www. j a  v  a  2s  . com
    tcDocsPane.setContentType("text/html");

    if (tcLogsPane != null) {
        TextAreaAppender.addTextArea(tcLogsPane);
    }
    tcDocsPane.setEditorKit(new HTMLEditorKit());
    tcDocsPane.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
        }
    });

    ExecuteButtonAction buttonListener = new ExecuteButtonAction();
    executeButton.addActionListener(buttonListener);
    executeButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/running_32"));
    executeButton.setToolTipText("Run Test(s)");

    startExecutionButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/start"));
    startExecutionButton.setToolTipText("Continue test case execution (F8)");
    startExecutionButton.setVisible(false);
    startExecutionButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            continueDebug();
        }
    });

    stepOverExecutionButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/stepover"));
    stepOverExecutionButton.setToolTipText("Step over the script execution (F6)");
    stepOverExecutionButton.setVisible(false);
    stepOverExecutionButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            continueStep();
        }
    });

    stepIntoExecutionButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/stepinto"));
    stepIntoExecutionButton.setToolTipText("Step into the script execution (F5)");
    stepIntoExecutionButton.setVisible(false);
    stepIntoExecutionButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            continueStepInto();
        }
    });

    stopExecutionButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/stop"));
    stopExecutionButton.setToolTipText("Stop execution");
    stopExecutionButton.setVisible(false);
    stopExecutionButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            stopExecution();
        }
    });

    debugButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/debug"));
    debugButton.setToolTipText("Debug Test(s)");
    debugButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            {
                runTestSuite(true, 1, false);
            }
        }
    });
    saveButton.setIcon(ResourceManager.getInstance().getImageIcon("icons/save_32"));
    saveButton.setToolTipText("Save and check script(s) syntax");
    saveButton.setName("save button");
    saveButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (checkScriptsSyntax()) // display dialog when syntax is correct
            {
                JOptionPane.showMessageDialog(null, "Syntax checked successfully");
            }
        }
    });

    resultsButton.addActionListener(new ActionListener() {

        // Show the browser displayed the last test report
        public void actionPerformed(ActionEvent e) {
            boolean showTestSuiteReport = resultsPane.getCurrentRunName().equals("Run1");
            String resDir = TestEngineConfiguration.getInstance().getString("reporting.generated_report_path");
            String baseDir = System.getProperty("user.dir");
            String filename = baseDir + File.separator + resDir + File.separator
                    + (showTestSuiteReport ? "index.html" : "campaign.html");
            File resultsFile = new File(filename);
            try {
                if (Desktop.isDesktopSupported()) {
                    Desktop.getDesktop().open(resultsFile);
                } else {
                    logger.error("Feature not supported by this platform");
                }
            } catch (IOException ex) {
                logger.error("Could not open " + filename);
            }
        }
    });

    resultsButton.setToolTipText("View the HTML Test Run Summary Results");
    resultsButton.setName("test run results button");

    FormLayout layout = new FormLayout(
            "6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px, pref, 6px:grow",
            "6px, fill:pref, 6px");
    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    int rowIndex = 2;
    int colIndex = 2;
    builder.add(executeButton, cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(saveButton, cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(debugButton, cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(resultsButton, cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(new CommonShortcutsPanel(), cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(startExecutionButton, cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(stepOverExecutionButton, cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(stepIntoExecutionButton, cc.xy(colIndex, rowIndex));
    colIndex += 2;
    builder.add(stopExecutionButton, cc.xy(colIndex, rowIndex));

    JPanel northP = builder.getPanel();
    add(northP, BorderLayout.NORTH);
    tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    editorTabbedPane = new JTabbedPane(JTabbedPane.TOP);
    editorTabbedPane.addMouseListener(new TabMouseListener());
    editorTabbedPane.setFocusable(false);
    sourcePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

    getTcSourcePane().add(editorTabbedPane);
    sourcePanel.setTopComponent(getTcSourcePane());
    sourcePanel.setFocusable(false);

    sourcePanel.setDividerSize(4);

    debugPanel = new DebugVariablePanel();
    debugPanel.setPreferredSize(new Dimension(100, 150));
    sourcePanel.setResizeWeight(0.9);
    sourcePanel.setBottomComponent(debugPanel);
    ////////////////////////
    debugPanel.setVisible(false);
    //sourcePanel.add(debugPanel, BorderLayout.SOUTH);
    tabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            // transfer focus to editor if necessary
            if (tabbedPane.getSelectedIndex() == SOURCE_INDEX) {
                Component tab = editorTabbedPane.getSelectedComponent();
                if (tab != null && tab instanceof JScrollPane) {
                    JScrollPane scrollPane = (JScrollPane) tab;
                    tab = scrollPane.getViewport().getView();
                    if (tab != null) {
                        tab.requestFocusInWindow();
                    }
                }
            } else {
                Component tab = tabbedPane.getSelectedComponent();
                if (tab != null && tab instanceof JScrollPane) {
                    JScrollPane scrollPane = (JScrollPane) tab;
                    tab = scrollPane.getViewport().getView();
                    if (tab != null) {
                        tab.requestFocusInWindow();
                    }
                }
            }
            if (!isDocTabSelected()) {
                return;
            }
            // generate doc if necessary
            NonWrappingTextPane tsPane = getTcSourceTextPane();
            if (tsPane != null) {
                File tsFile = new File(tsPane.getFileName());
                PythonTestScript pScript = new PythonTestScript(tsFile, getTestSuiteDirectory());
                if (pScript.isDocSynchronized()) {
                    return;
                }
                // re-generate the doc
                parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                pScript.generateDoc();
                HTMLDocumentLoader loader = new HTMLDocumentLoader();
                HTMLDocument doc;
                try {
                    File tcDoc = pScript.getTestcaseDoc();
                    if (tcDoc != null) {
                        doc = loader.loadDocument(tcDoc.toURI().toURL());
                        setTestCaseInfo(doc);
                    } else {
                        setTestCaseInfo(null);
                    }
                } catch (MalformedURLException e1) {
                    logger.error(e1);
                    setTestCaseInfo(null);
                } catch (IOException e1) {
                    logger.error(e1);
                    setTestCaseInfo(null);
                }
                parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        }
    });

    tabbedPane.add(DOC, new JScrollPane(tcDocsPane));
    tabbedPane.add(SOURCE, sourcePanel);

    tabbedPane.add(RESULTS, resultsPane);
    if (tcLogsPane != null) {
        tabbedPane.add(LOGS, tcLogsPane);
    }

    add(tabbedPane, BorderLayout.CENTER);
}

From source file:com.salas.bb.dialogs.InvalidDiscoveryDialog.java

License:Open Source License

private Component buildMainPanel() {
    FormLayout layout = new FormLayout("7dlu, pref, 2dlu, min:grow", "min:grow, " + "pref, 2dlu, pref, 7dlu, "
            + "pref, 2dlu, " + "pref, 2dlu, " + "pref, 2dlu, " + "pref, 2dlu, " + "pref, " + "min:grow");
    JPanel panel = new JPanel(layout);
    CellConstraints cc = new CellConstraints();

    panel.add(new JLabel(Strings.message("invalid.discovery.wording")), cc.xyw(1, 2, 4));
    panel.add(lbLink, cc.xyw(2, 4, 3));/*  w w w  .j  a  va  2  s  . c om*/

    panel.add(new JLabel(Strings.message("invalid.discovery.query")), cc.xyw(1, 6, 4));

    panel.add(rbNewDiscovery, cc.xy(2, 8));
    panel.add(tfNewDiscoveryUrl, cc.xy(4, 8));

    panel.add(rbSuggest, cc.xy(2, 10));
    panel.add(tfSuggestedUrl, cc.xy(4, 10));

    panel.add(rbLeave, cc.xy(2, 12));

    panel.add(rbRemove, cc.xy(2, 14));

    return panel;
}

From source file:com.salas.bb.dialogs.StarzPanel.java

License:Open Source License

/**
 * Creates a FormLayout and adds the UI components using a PanelBuilder.
 *//*from  w  w w  . ja  va  2s  . c  o m*/
private void build() {
    FormLayout layout = new FormLayout("p, right:p, p:grow, right:p:grow",
            "p, min:grow, p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p: min:grow");

    PanelBuilder builder = new PanelBuilder(layout, this);
    CellConstraints cc = new CellConstraints();

    builder.add(whatIsBox, cc.xyw(1, 1, 4));

    builder.add(lessImportant, cc.xy(3, 3));
    builder.add(moreImportant, cc.xy(4, 3));

    builder.add(activity, cc.xy(2, 5));
    builder.add(activitySlider, cc.xyw(3, 5, 2));

    builder.add(popularitySlider, cc.xyw(3, 7, 2));
    builder.add(popularity, cc.xy(2, 7));

    builder.add(clickthroughs, cc.xy(2, 9));
    builder.add(clickthroughsSlider, cc.xyw(3, 9, 2));

    builder.add(feedViews, cc.xy(2, 11));
    builder.add(feedViewsSlider, cc.xyw(3, 11, 2));
}

From source file:com.salas.bb.installation.InstallationProgressDialog.java

License:Open Source License

/**
 * Builds content.//from   w w w  .  j ava 2 s .  c o  m
 */
protected JComponent buildContent() {
    FormLayout layout = new FormLayout("15dlu, 150dlu:grow, 15dlu", "100dlu:grow, 2dlu, pref");

    PanelBuilder builder = new PanelBuilder(layout);
    CellConstraints cc = new CellConstraints();

    builder.add(buildStepsPanel(), cc.xy(2, 1));
    builder.add(buildButtonBar(), cc.xyw(1, 3, 3));

    return builder.getPanel();
}

From source file:com.salas.bb.search.ResultGroupPanel.java

License:Open Source License

/**
 * Creates group item.//w  w w  .  ja va2s  .  c o  m
 *
 * @param name      name.
 * @param tooltip   tooltip.
 * @param color1    first background color.
 * @param color2    second background color.
 */
public ResultGroupPanel(String name, String tooltip, Color color1, Color color2) {
    backgroundColor1 = color1;
    backgroundColor2 = color2;

    moreItem = new MoreItem();
    lbCount = new JLabel("0");

    setLayout(new FormLayout("5px, 10px, 5px, 50px:grow, 5px, 30px, 5px", "2px, p, 2px"));
    CellConstraints cc = new CellConstraints();

    GroupCollapseIcon icon = new GroupCollapseIcon();
    icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    add(icon, cc.xy(2, 2));

    Font fnt = new Font("Lucida Grande", Font.BOLD, 12);
    lbTitle = new JLabel(name);
    lbTitle.setFont(fnt);
    lbTitle.setForeground(Color.WHITE);
    lbCount.setFont(fnt);
    lbCount.setForeground(Color.WHITE);
    lbCount.setAlignmentX(0.5f);
    add(lbTitle, cc.xy(4, 2));
    add(lbCount, cc.xy(6, 2));

    setBackground(backgroundColor1);
    if (tooltip != null)
        setToolTipText(tooltip);
}

From source file:com.salas.bb.search.ResultItemPanel.java

License:Open Source License

/**
 * Creates item.//ww  w  .ja  v a2s .  c o  m
 *
 * @param aItem item.
 */
public ResultItemPanel(ResultItem aItem) {
    item = aItem;

    Font font = getFont().deriveFont(10f);

    setBorder(new ResultItemBorder(Color.decode("#f7f7f7")));
    setLayout(new FormLayout("20px, 16px, 5px, 50px:grow, 8px, p, 8px, p, 8px, p, 5px", "2px, p, 2px"));
    CellConstraints cc = new CellConstraints();

    JLabel lbIcon = new JLabel(item.getType().getIcon());
    add(lbIcon, cc.xy(2, 2));

    lbTitle = new JLabel(item.toString());
    lbTitle.setFont(font);
    add(lbTitle, cc.xy(4, 2));

    lbDate = new JLabel(dateToString(item.getDate()));
    lbDate.setFont(font);
    add(lbDate, cc.xy(6, 2));

    if (aItem.getObject() instanceof IArticle) {
        IArticle article = (IArticle) aItem.getObject();

        lbPin = new ArticlePinControl(article);
        add(lbPin, cc.xy(10, 2));

        lbUnread = new ArticleReadControl(article);
        add(lbUnread, cc.xy(8, 2));

        // Setup the tooltip and delegate the mouse events to the parent (this panel)
        IFeed feed = article.getFeed();
        lbTitle.setToolTipText(feed == null ? null : feed.getTitle());
        DelegatingMouseListener ml = new DelegatingMouseListener(lbTitle, false, 2);
        lbTitle.addMouseListener(ml);
    }

    setSelected(false);

    visibility = false;
    collapsed = false;
}

From source file:com.salas.bb.utils.uif.ColorListCellRenderer.java

License:Open Source License

/**
 * Creates a renderer component./*  w ww .  ja v a 2 s.c  o m*/
 *
 * @param noColorText text to show when no color is given.
 */
public ColorListCellRenderer(String noColorText) {
    this.noColorText = noColorText;
    CellConstraints cc = new CellConstraints();
    CellConstraints cc2 = new CellConstraints();

    colorSample = new JPanel(new FormLayout("1dlu, center:p:grow, 1dlu", "0dlu, p:grow, 0dlu"));
    label = new JLabel();
    colorSample.add(label, cc.xy(2, 2));

    if (SystemUtils.IS_OS_MAC) {
        setLayout(new FormLayout("0, 10dlu:grow, 2dlu", "2dlu:grow, pref, 1dlu:grow"));
    } else {
        setLayout(new FormLayout("0, pref:grow, 0", "0, pref:grow, 1dlu"));
    }

    add(colorSample, cc2.xy(2, 2, "f, f"));
}

From source file:com.salas.bb.utils.uif.CoolInternalFrame.java

License:Open Source License

/**
 * Creates the appropriately laied out Header for the CoolInternalFrame.
 *
 * @return the header./*from   w  ww  . j a v  a 2s .c  o  m*/
 */
private JPanel buildHeader() {
    FormLayout layout = new FormLayout("11px, pref, min:grow, 2px, pref, 11px", "6px, pref, 1px, pref, 8px");
    headerPanel = new GradientPanel(layout);

    CellConstraints cc = new CellConstraints();
    headerPanel.add(titleLabel, cc.xy(2, 2));
    headerPanel.add(subtitleLabel, cc.xyw(2, 4, 3));
    if (headerCtrlComp != null)
        headerPanel.add(headerCtrlComp, cc.xywh(5, 2, 1, 3, "r, c"));

    headerPanel.setOpaque(SystemUtils.IS_OS_MAC);
    return headerPanel;
}