From 7ef66e4d6245724d3c4c4c556e70d2c834b85de7 Mon Sep 17 00:00:00 2001 From: Akarshit Wal Date: Mon, 6 Jul 2015 01:41:13 +0530 Subject: [PATCH] Update tab at last, notification added --- .../app/contrib/ContributionListPanel.java | 8 ++++ .../contrib/ContributionManagerDialog.java | 41 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/app/src/processing/app/contrib/ContributionListPanel.java b/app/src/processing/app/contrib/ContributionListPanel.java index da2e61ab5..860bb9bdc 100644 --- a/app/src/processing/app/contrib/ContributionListPanel.java +++ b/app/src/processing/app/contrib/ContributionListPanel.java @@ -266,6 +266,9 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib c.anchor = GridBagConstraints.NORTH; add(status, c);*/ // System.out.println(dtm.getDataVector()); + if(contributionTab.contributionType == null){ + contributionTab.contributionManagerDialog.numberLabel.setText(Integer.toString(panelByContribution.size())); + } dtm.getDataVector().removeAllElements(); dtm.fireTableDataChanged(); for (Contribution entry : contributionsSet) { @@ -518,4 +521,9 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib public boolean getScrollableTracksViewportWidth() { return true; } + + + public int getNoOfRows() { + return panelByContribution.size(); + } } diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index bb0658c7b..86f2216d8 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -22,7 +22,10 @@ package processing.app.contrib; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; +import java.awt.Insets; +import java.awt.LayoutManager; import java.awt.event.*; import java.io.File; import java.io.IOException; @@ -33,6 +36,7 @@ import java.util.*; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.plaf.basic.BasicTabbedPaneUI; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; @@ -74,9 +78,12 @@ public class ContributionManagerDialog { ContributionTab modesContributionTab; ContributionTab updatesContributionTab; + JLabel numberLabel; + ContributionListing contributionListing = ContributionListing.getInstance(); public ContributionManagerDialog() { + numberLabel = new JLabel(); statusPanel = new StatusPanel(450,this); toolsContributionTab = new ContributionTab(ContributionType.TOOL, statusPanel, this); librariesContributionTab = new ContributionTab(ContributionType.LIBRARY, statusPanel, this); @@ -150,6 +157,20 @@ public class ContributionManagerDialog { updatesContributionTab.showFrame(editor); tabbedPane.addTab("Updates", null, updatesContributionTab.panel, "Updates"); tabbedPane.setMnemonicAt(3, KeyEvent.VK_5); + tabbedPane.setUI(new SpacedTabbedPaneUI()); + + + JPanel updateTabPanel = new JPanel(true); + numberLabel.setOpaque(true); + numberLabel.setBackground(Color.BLUE); + JLabel updateTabLabel = new JLabel("Update"); + + GroupLayout tabLayout = new GroupLayout(updateTabPanel); + tabLayout.setAutoCreateGaps(true); + updateTabPanel.setLayout(tabLayout); + tabLayout.setHorizontalGroup(tabLayout.createSequentialGroup().addComponent(numberLabel).addComponent(updateTabLabel)); + tabLayout.setVerticalGroup(tabLayout.createParallelGroup().addComponent(numberLabel).addComponent(updateTabLabel)); + tabbedPane.setTabComponentAt(4, updateTabPanel); tabbedPane.addChangeListener(new ChangeListener() { @@ -222,6 +243,26 @@ public class ContributionManagerDialog { dialog.setLocationRelativeTo(null); } + public class SpacedTabbedPaneUI extends BasicTabbedPaneUI { + + @Override + protected LayoutManager createLayoutManager() { + return new BasicTabbedPaneUI.TabbedPaneLayout() { + @Override + protected void calculateTabRects(int tabPlacement, int tabCount) { + super.calculateTabRects(tabPlacement, tabCount); + for (int i = 0; i < rects.length; i++) { + if (i == 4) { + rects[i].x = tabbedPane.getWidth() - rects[i].width; + } + rects[i].y -= 5; + rects[i].height += 5; + } + } + }; + } + } + private void setLayoutWithError() { GroupLayout layout = new GroupLayout(dialog.getContentPane()); dialog.getContentPane().setLayout(layout);