From 6fdf1be323657bc0fe5862adfe7a7d488f29ea9f Mon Sep 17 00:00:00 2001 From: Akarshit Wal Date: Fri, 14 Aug 2015 19:39:52 +0530 Subject: [PATCH] CM as in mockup --- .../app/contrib/ContributionListPanel.java | 63 +++++++------- .../contrib/ContributionManagerDialog.java | 86 ++++++++++++++----- .../app/contrib/ContributionPanel.java | 35 ++++---- .../app/contrib/ContributionTab.java | 50 ++++++++--- .../processing/app/contrib/StatusPanel.java | 13 +-- .../app/contrib/UpdateContributionTab.java | 68 +++++++++++---- 6 files changed, 208 insertions(+), 107 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionListPanel.java b/app/src/processing/app/contrib/ContributionListPanel.java index 7f8a2df54..cf47167cd 100644 --- a/app/src/processing/app/contrib/ContributionListPanel.java +++ b/app/src/processing/app/contrib/ContributionListPanel.java @@ -58,6 +58,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib protected ContributionListing contribListing = ContributionListing.getInstance(); protected JTable table; DefaultTableModel dtm; + Font myFont; public ContributionListPanel() { // TODO Auto-generated constructor stub @@ -72,15 +73,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib setLayout(new GridBagLayout()); setOpaque(true); - - if (Base.isLinux()) { - // Because of a bug with GNOME, getColor returns the wrong value for - // List.background. We'll just assume its white. The number of people - // using Linux and an inverted color theme should be small enough. - setBackground(Color.white); - } else { - setBackground(UIManager.getColor("List.background")); - } + setBackground(Color.WHITE); panelByContribution = new TreeMap(contribListing.getComparator()); @@ -96,13 +89,17 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib TableCellRenderer renderer, int row, int column) { Component c = super.prepareRenderer(renderer, row, column); if (isRowSelected(row)) { - c.setBackground(Color.blue); + c.setBackground(new Color(0xe0fffd)); } else { c.setBackground(Color.white); } return c; } }; + + myFont = Toolkit.getSansFont(14, Font.PLAIN); + GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(myFont); + // There is a space before Status String[] colName = { " Status", "Name", "Author" }; dtm.setColumnIdentifiers(colName); @@ -110,9 +107,10 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib table.setFillsViewportHeight(true); // table.setBorder(); table.setDefaultRenderer(Contribution.class, new StatusRendere()); - table.setRowHeight(30); + table.setFont(Toolkit.getSansFont(14, Font.PLAIN)); + table.setRowHeight(28); table.setRowMargin(6); - table.getColumnModel().setColumnMargin(-1); + table.getColumnModel().setColumnMargin(0); table.getColumnModel().getColumn(0).setMaxWidth(60); table.getColumnModel().getColumn(2).setMinWidth(ContributionManagerDialog.AUTHOR_WIDTH); table.getColumnModel().getColumn(2).setMaxWidth(ContributionManagerDialog.AUTHOR_WIDTH); @@ -193,8 +191,11 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib setForeground(tableHeader.getForeground()); } setIcon(getIcon(table, column)); - //TODO: put correct Color here - setBackground(Color.LIGHT_GRAY); + if (column % 2 == 0) { + setBackground(new Color(0xdfdfdf)); + } else { + setBackground(new Color(0xebebeb)); + } setBorder(null); return this; } @@ -257,6 +258,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib if (column == 0) { Icon icon = null; label.setBorder(BorderFactory.createEmptyBorder(2, 17, 0, 0)); + label.setFont(Toolkit.getSansFont(14, Font.PLAIN)); if (contribution.isInstalled()) { icon = Toolkit.getLibIcon("manager/up-to-date.png"); if (contribListing.hasUpdates(contribution)) { @@ -268,7 +270,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib } label.setIcon(icon); if (isSelected) { - label.setBackground(Color.BLUE); + label.setBackground(new Color(0xe0fffd)); } label.setOpaque(true); // return table.getDefaultRenderer(Icon.class).getTableCellRendererComponent(table, icon, isSelected, false, row, column); @@ -277,13 +279,13 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib FontMetrics fontMetrics = table.getFontMetrics(table.getFont()); int colSize = table.getColumnModel().getColumn(1).getWidth(); String sentence = contribution.getSentence(); - int currentWidth = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD)).stringWidth(contribution.getName()); - int ellipsesWidth = fontMetrics.stringWidth(" ..."); - String name = "" + contribution.getName() + ""; + int currentWidth = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD)).stringWidth(contribution.getName() + " | "); + int ellipsesWidth = fontMetrics.stringWidth("..."); + String name = "" + contribution.getName(); if (sentence == null) { - label.setText(name + ""); + label.setText(name + ""); } else { - sentence = " - " + sentence; + sentence = " | " + sentence; currentWidth += ellipsesWidth; int i = 0; for (i = 0; i < sentence.length(); i++) { @@ -294,7 +296,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib } // Adding ellipses only if text doesn't fits into the column if(i != sentence.length()){ - label.setText(name + sentence.substring(0, i) + " ..."); + label.setText(name + sentence.substring(0, i) + "..."); }else { label.setText(name + sentence + ""); } @@ -303,8 +305,9 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib label.setForeground(Color.LIGHT_GRAY); } if (table.isRowSelected(row)) { - label.setBackground(Color.BLUE); + label.setBackground(new Color(0xe0fffd)); } + label.setFont(myFont); label.setOpaque(true); } else { label = new JLabel( @@ -332,10 +335,13 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib label.setHorizontalAlignment(SwingConstants.LEFT); if(!contribution.isCompatible(Base.getRevision())){ label.setForeground(Color.LIGHT_GRAY); + }else{ + label.setForeground(Color.BLACK); } if (table.isRowSelected(row)) { - label.setBackground(Color.BLUE); + label.setBackground(new Color(0xe0fffd)); } + label.setFont(Toolkit.getSansFont(14, Font.BOLD)); label.setOpaque(true); } return label; @@ -378,12 +384,16 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib c.anchor = GridBagConstraints.NORTH; add(status, c);*/ // System.out.println(dtm.getDataVector()); + int row = table.getSelectedRow(); dtm.getDataVector().removeAllElements(); dtm.fireTableDataChanged(); for (Contribution entry : contributionsSet) { ((MyTableModel) table.getModel()).addRow(new Object[] { entry, entry, entry }); } + if (row >= 0) { + table.setRowSelectionInterval(row, row); + } } @@ -404,13 +414,6 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib updateColors(); // XXX this is the place } } - // To make the scroll shift to the first element - // http://stackoverflow.com/questions/19400239/scrolling-to-the-top-jpanel-inside-a-jscrollpane - EventQueue.invokeLater(new Runnable() { - public void run() { - scrollRectToVisible(new Rectangle(0, 0, 1, 1)); - } - }); } }); } diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 514ec271d..c7dd0773e 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -46,8 +46,10 @@ public class ContributionManagerDialog { static final String ANY_CATEGORY = Language.text("contrib.all"); static final int TAB_WIDTH = 100; static final int TAB_HEIGHT = 34; - static final int AUTHOR_WIDTH = 150; + static final int AUTHOR_WIDTH = 240; static final int STATUS_WIDTH = 60; + static final int FILTER_WIDTH = 180; + JFrame dialog; JTabbedPane tabbedPane; String title; @@ -122,10 +124,10 @@ public class ContributionManagerDialog { tabbedPane.setSelectedIndex(index); //done before as downloadAndUpdateContributionListing() requires the current selected tab downloadAndUpdateContributionListing(editor.getBase()); if(index != 4){ - tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setBackground(Color.WHITE); + tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setBackground(new Color(0xe0fffd)); tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setForeground(Color.BLACK); }else{ - updateTabPanel.setBackground(Color.WHITE); + updateTabPanel.setBackground(new Color(0xe0fffd)); updateTabLabel.setForeground(Color.BLACK); } } @@ -175,10 +177,10 @@ public class ContributionManagerDialog { updateTabLabel.setForeground(Color.WHITE); int currentIndex = tabbedPane.getSelectedIndex(); if(currentIndex != 4){ - tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setBackground(Color.WHITE); + tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setBackground(new Color(0xe0fffd)); tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setForeground(Color.BLACK); }else{ - updateTabPanel.setBackground(Color.WHITE); + updateTabPanel.setBackground(new Color(0xe0fffd)); updateTabLabel.setForeground(Color.BLACK); } // // When the tab is changed update status to the current selected panel @@ -254,20 +256,47 @@ public class ContributionManagerDialog { tabLabels = new JLabel[4]; for(int i = 0 ; i < 4; i++){ - tabLabels[i] = new JLabel(tabTitles[i]); + final int temp = i; + tabLabels[i] = new JLabel(tabTitles[i]){ + @Override + protected void paintComponent(Graphics g) { + g.setClip(Toolkit.createRoundRect(0, 0, + getWidth(), getHeight(), + temp == 0 ? 6 : 0, + temp == 3 ? 6 : 0, + 0, 0)); + super.paintComponent(g); + + } + }; tabLabels[i].setForeground(Color.WHITE); tabLabels[i].setBackground(new Color(0x2d4251)); tabLabels[i].setOpaque(true); tabLabels[i].setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); tabLabels[i].setPreferredSize(new Dimension(TAB_WIDTH, TAB_HEIGHT)); tabLabels[i].setHorizontalAlignment(SwingConstants.CENTER); + tabLabels[i].setFont(Toolkit.getSansFont(14, Font.BOLD)); tabbedPane.setTabComponentAt(i, tabLabels[i]); } - updateTabPanel = new JPanel(true); + updateTabPanel = new JPanel(){ + @Override + protected void paintComponent(Graphics g) { + g.setClip(Toolkit.createRoundRect(0, 0, + getWidth(), getHeight(), + 6, + 6, + 0, 0)); + super.paintComponent(g); + + } + };; updateTabLabel = new JLabel("Updates"); + updateTabLabel.setFont(Toolkit.getSansFont(14, Font.BOLD)); numberLabel.setVerticalTextPosition(SwingConstants.CENTER); numberLabel.setHorizontalTextPosition(SwingConstants.CENTER); + numberLabel.setFont(Toolkit.getSansFont(14, Font.BOLD)); + numberLabel.setForeground(Color.WHITE); updateTabPanel.setOpaque(true); updateTabPanel.setBackground(new Color(0x2d4251)); updateTabLabel.setForeground(Color.WHITE); @@ -292,8 +321,16 @@ public class ContributionManagerDialog { GroupLayout tabLayout = new GroupLayout(updateTabPanel); tabLayout.setAutoCreateGaps(true); updateTabPanel.setLayout(tabLayout); - tabLayout.setHorizontalGroup(tabLayout.createSequentialGroup() - .addComponent(updateTabLabel).addComponent(numberLabel)); + tabLayout.setHorizontalGroup(tabLayout + .createSequentialGroup() + + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, + GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) + .addComponent(updateTabLabel) + .addComponent(numberLabel) + + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, + GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); tabLayout.setVerticalGroup(tabLayout .createParallelGroup(GroupLayout.Alignment.CENTER) .addComponent(numberLabel).addComponent(updateTabLabel)); @@ -303,16 +340,18 @@ public class ContributionManagerDialog { public class SpacedTabbedPaneUI extends BasicTabbedPaneUI { + protected Color hazAlfa(int fila) { + int alfa = 0; + if (fila >= 0) { + alfa = 50 + (fila > 7 ? 70 : 10 * fila); + } + return new Color(0, 0, 0, alfa); + } @Override protected void installDefaults() { UIManager.put("TabbedPane.selected", Color.BLACK); UIManager.put("TabbedPane.tabsOverlapBorder" , true); super.installDefaults(); - highlight = Color.RED; - lightHighlight = Color.GRAY; - shadow = Color.GREEN; - darkShadow = Color.BLACK; - focus = Color.YELLOW; tabInsets = new Insets(0, 0, 0, 0); contentBorderInsets = new Insets(0, 0, 0, 0); tabAreaInsets = new Insets(0, 0, 0, 0); @@ -327,6 +366,17 @@ public class ContributionManagerDialog { // protected int getTabLabelShiftY(int tabPlacement, int tabIndex, // boolean isSelected) { // return 3; +// } +// @Override +// protected void paintTab(Graphics g, int tabPlacement, +// Rectangle[] rects, int tabIndex, +// Rectangle iconRect, Rectangle textRect) { +// Graphics2D g2 = (Graphics2D) g; +// g2.fill(Toolkit.createRoundRect(rects[tabIndex].x, rects[tabIndex].y, +// rects[tabIndex].x + rects[tabIndex].width, rects[tabIndex].y + rects[tabIndex].height, +// 6, +// 6, +// 0, 0)); // } @Override protected void paintTabBackground(Graphics g, int tabPlacement, @@ -704,18 +754,10 @@ public class ContributionManagerDialog { if (error) { - if (exception instanceof SocketTimeoutException) { - activeTab.statusPanel.setErrorMessage(Language - .text("contrib.errors.list_download.timeout")); - } else { - activeTab.statusPanel.setErrorMessage(Language - .text("contrib.errors.list_download")); - } exception.printStackTrace(); makeAndShowTab(true,false); } else { makeAndShowTab(false, false); - activeTab.statusPanel.setMessage(Language.text("contrib.status.done")); } } }); diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 0481c0042..a30f7547a 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -459,13 +459,27 @@ class ContributionPanel extends JPanel { } else { description.append("" + contrib.getName() + ""); } - description.append(""); + description.append(" "); + + String version = contrib.getPrettyVersion(); + + // TODO this has no place here, we shouldn't be cleaning up contrib + // information in the f*king GUI. + if (version != null && !version.isEmpty()) { + if (version.toLowerCase().startsWith("build")) // For Python mode + description.append(version.substring(5, version.indexOf(',')).trim()); + else if (version.toLowerCase().startsWith("v")) // For ketai library + description.append(version); + else + description.append(version); + } + description.append("
"); + String authorList = contrib.getAuthorList(); if (authorList != null && !authorList.isEmpty()) { - description.append(" by "); description.append(toHtmlLinks(contrib.getAuthorList())); } - description.append("
"); + description.append("

"); if (contrib.isDeletionFlagged()) { description.append(REMOVE_RESTART_MESSAGE); @@ -484,21 +498,6 @@ class ContributionPanel extends JPanel { description.append(sentence); } - String version = contrib.getPrettyVersion(); - - // TODO this has no place here, we shouldn't be cleaning up contrib - // information in the f*king GUI. - if (version != null && !version.isEmpty()) { - description.append("
"); - if (version.toLowerCase().startsWith("build")) // For Python mode - description.append("v" - + version.substring(5, version.indexOf(',')).trim()); - else if (version.toLowerCase().startsWith("v")) // For ketai library - description.append(version); - else - description.append("v" + version); - } - long lastUpdatedUTC = contrib.getLastUpdated(); if (lastUpdatedUTC != 0) { DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM); diff --git a/app/src/processing/app/contrib/ContributionTab.java b/app/src/processing/app/contrib/ContributionTab.java index 7742f5453..b67af1c2a 100644 --- a/app/src/processing/app/contrib/ContributionTab.java +++ b/app/src/processing/app/contrib/ContributionTab.java @@ -22,7 +22,10 @@ package processing.app.contrib; import java.awt.Color; +import java.awt.ComponentOrientation; import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; import java.awt.event.*; import java.util.*; @@ -48,7 +51,6 @@ public class ContributionTab { ContributionListPanel contributionListPanel; StatusPanel statusPanel; FilterField filterField; - JLabel filterLabel; JButton restartButton; JLabel categoryLabel; JLabel loaderLabel; @@ -138,8 +140,6 @@ public class ContributionTab { loaderLabel = new JLabel(Toolkit.getLibIcon("manager/loader.gif")); loaderLabel.setOpaque(false); loaderLabel.setBackground(Color.WHITE); - filterLabel = new JLabel("Filter"); - filterLabel.setOpaque(false); } /*restartButton = new JButton(Language.text("contrib.restart")); @@ -198,17 +198,18 @@ public class ContributionTab { .createParallelGroup(GroupLayout.Alignment.CENTER) .addGroup(layout .createSequentialGroup() - .addContainerGap() - .addComponent(filterLabel) - .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(filterField) + .addGap(ContributionManagerDialog.STATUS_WIDTH) + .addComponent(filterField, + ContributionManagerDialog.FILTER_WIDTH, + ContributionManagerDialog.FILTER_WIDTH, + ContributionManagerDialog.FILTER_WIDTH) // .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) .addComponent(categoryChooser, - ContributionManagerDialog.AUTHOR_WIDTH, - ContributionManagerDialog.AUTHOR_WIDTH, - ContributionManagerDialog.AUTHOR_WIDTH) + ContributionManagerDialog.AUTHOR_WIDTH - 10, + ContributionManagerDialog.AUTHOR_WIDTH - 10, + ContributionManagerDialog.AUTHOR_WIDTH - 10) .addContainerGap()).addComponent(loaderLabel) .addComponent(contributionListPanel).addComponent(errorPanel) .addComponent(statusPanel)); @@ -217,7 +218,7 @@ public class ContributionTab { .createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) - .addComponent(filterLabel).addComponent(categoryChooser) + .addComponent(categoryChooser) .addComponent(filterField)) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) @@ -228,7 +229,7 @@ public class ContributionTab { GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); layout.linkSize(SwingConstants.VERTICAL, categoryChooser, filterField); layout.setHonorsVisibility(contributionListPanel, false); - + panel.setBackground(Color.WHITE); panel.setBorder(null); } @@ -242,6 +243,7 @@ public class ContributionTab { categoryChooser = new JComboBox(); categoryChooser.setMaximumRowCount(20); + categoryChooser.setFont(Toolkit.getSansFont(14, Font.PLAIN)); updateCategoryChooser(); @@ -274,6 +276,7 @@ public class ContributionTab { errorMessage.setText("Could not connect to the Processing server.
" + "Contributions cannot be installed or updated without an Internet connection.
" + "Please verify your network connection again, then try connecting again."); + errorMessage.setFont(Toolkit.getSansFont(14, Font.PLAIN)); errorMessage.setMaximumSize(new Dimension(550, 50)); errorMessage.setOpaque(false); @@ -293,6 +296,7 @@ public class ContributionTab { } }); tryAgainButton = new JButton("Try Again"); + tryAgainButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); // tryAgainButton.setContentAreaFilled(false); // tryAgainButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0))); tryAgainButton.addActionListener(new ActionListener() { @@ -417,24 +421,44 @@ public class ContributionTab { class FilterField extends JTextField { Icon searchIcon; List filters; + JLabel filterLabel; public FilterField () { super(""); + + filterLabel = new JLabel("Filter"); + filterLabel.setFont(Toolkit.getSansFont(14, Font.PLAIN)); + filterLabel.setOpaque(false); + + setFont(Toolkit.getSansFont(14, Font.PLAIN)); searchIcon = Toolkit.getLibIcon("manager/search.png"); setOpaque(false); - + setBorder(BorderFactory.createMatteBorder(0, 33, 0, 0, searchIcon)); + + GroupLayout fl = new GroupLayout(this); + setLayout(fl); + fl.setHorizontalGroup(fl.createSequentialGroup().addComponent(filterLabel)); + fl.setVerticalGroup(fl.createSequentialGroup() + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, + GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) + .addComponent(filterLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, + GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)); + filters = new ArrayList(); addFocusListener(new FocusListener() { public void focusLost(FocusEvent focusEvent) { if (getText().isEmpty()) { setBorder(BorderFactory.createMatteBorder(0, 33, 0, 0, searchIcon)); + filterLabel.setVisible(true); } } public void focusGained(FocusEvent focusEvent) { setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 0)); + filterLabel.setVisible(false); } }); diff --git a/app/src/processing/app/contrib/StatusPanel.java b/app/src/processing/app/contrib/StatusPanel.java index 479b430bb..70ff4a546 100644 --- a/app/src/processing/app/contrib/StatusPanel.java +++ b/app/src/processing/app/contrib/StatusPanel.java @@ -23,6 +23,7 @@ package processing.app.contrib; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -61,7 +62,7 @@ class StatusPanel extends JPanel { public StatusPanel(int width, final ContributionTab contributionTab) { super(); - setBackground(Color.LIGHT_GRAY); + setBackground(new Color(0xebebeb)); // setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK)); this.contributionTab = contributionTab; @@ -71,6 +72,7 @@ class StatusPanel extends JPanel { label.setEditable(false); label.setOpaque(false); label.setContentType("text/html"); + label.setFont(Toolkit.getSansFont(14, Font.PLAIN)); label.addHyperlinkListener(new HyperlinkListener() { @Override @@ -82,7 +84,8 @@ class StatusPanel extends JPanel { } } }); - installButton = new JButton("Install", Toolkit.getLibIcon("manager/update.png")); + installButton = new JButton("Install", Toolkit.getLibIcon("manager/install.png")); + installButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); installButton.setHorizontalAlignment(SwingConstants.LEFT); // installButton.setContentAreaFilled(false); // installButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0))); @@ -100,7 +103,9 @@ class StatusPanel extends JPanel { progressBarPanel.setLayout(new BorderLayout()); progressBarPanel.setOpaque(false); updateLabel = new JLabel(" "); + updateLabel.setFont(Toolkit.getSansFont(14, Font.PLAIN)); updateButton = new JButton("Update", Toolkit.getLibIcon("manager/update.png")); + updateButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); updateButton.setHorizontalAlignment(SwingConstants.LEFT); // updateButton.setAlignmentX(SwingConstants.LEFT); // updateButton.setContentAreaFilled(false); @@ -117,6 +122,7 @@ class StatusPanel extends JPanel { }); removeButton = new JButton("Remove", Toolkit.getLibIcon("manager/remove.png")); + removeButton.setFont(Toolkit.getSansFont(14, Font.BOLD)); removeButton.setHorizontalAlignment(SwingConstants.LEFT); // removeButton.setContentAreaFilled(false); // removeButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0))); @@ -186,7 +192,6 @@ class StatusPanel extends JPanel { void setMessage(String message) { if (label != null) { - label.setForeground(Color.BLACK); label.setText(message); label.repaint(); } @@ -194,8 +199,6 @@ class StatusPanel extends JPanel { void setErrorMessage(String message) { if (label != null) { - //setForeground(Color.RED); - label.setForeground(new Color(160, 0, 0)); label.setText(message); label.repaint(); } diff --git a/app/src/processing/app/contrib/UpdateContributionTab.java b/app/src/processing/app/contrib/UpdateContributionTab.java index 333e2374a..eab3dea42 100644 --- a/app/src/processing/app/contrib/UpdateContributionTab.java +++ b/app/src/processing/app/contrib/UpdateContributionTab.java @@ -2,6 +2,7 @@ package processing.app.contrib; import java.awt.Color; import java.awt.Component; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Comparator; @@ -20,12 +21,17 @@ import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.LayoutStyle; import javax.swing.ListSelectionModel; +import javax.swing.SwingConstants; import javax.swing.UIManager; +import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import javax.swing.table.JTableHeader; import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; import processing.app.Base; +import processing.app.contrib.ContributionListPanel.MyColumnHeaderRenderer; import processing.app.ui.Editor; import processing.app.ui.Toolkit; @@ -85,22 +91,22 @@ public class UpdateContributionTab extends ContributionTab { super.contributionTab = contributionTab; super.filter = filter; setOpaque(true); - - if (Base.isLinux()) { - // Because of a bug with GNOME, getColor returns the wrong value for - // List.background. We'll just assume its white. The number of people - // using Linux and an inverted color theme should be small enough. - setBackground(Color.white); - } else { - setBackground(UIManager.getColor("List.background")); - } + setBackground(Color.WHITE); // statusPlaceholder = new JPanel(); // statusPlaceholder.setVisible(false); // status = new StatusPanel(null); String[] colName = { "", "Name", "Author", "Installed", "Update To" }; - dtm = new MyTableModel(); + dtm = new MyTableModel(){ + @Override + public Class getColumnClass(int columnIndex) { + if (columnIndex == 0) { + return Icon.class; + } + return String.class; + } + }; dtm.setColumnIdentifiers(colName); table = new JTable(dtm){ @Override @@ -119,8 +125,8 @@ public class UpdateContributionTab extends ContributionTab { public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) { String title = (String) getValueAt(rowIndex, 1); - if(title.equals(title.equals("Library") || title.equals("Tools") - || title.equals("Modes") || title.equals("Examples"))){ + if(title.equals("Library") || title.equals("Tools") + || title.equals("Modes") || title.equals("Examples")){ return; } super.changeSelection(rowIndex, columnIndex, toggle, extend); @@ -135,6 +141,9 @@ public class UpdateContributionTab extends ContributionTab { }; JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); + table.setSelectionBackground(new Color(0xe0fffd)); + table.setSelectionForeground(table.getForeground()); + table.setFont(Toolkit.getSansFont(14, Font.PLAIN)); table.setRowHeight(30); table.setRowMargin(6); table.getColumnModel().setColumnMargin(-1); @@ -144,6 +153,7 @@ public class UpdateContributionTab extends ContributionTab { table.setRowSelectionAllowed(true); table.setAutoCreateColumnsFromModel(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table.setDefaultRenderer(String.class, new StatusRendere()); table.getTableHeader().setDefaultRenderer(new MyColumnHeaderRenderer() { @Override public Component getTableCellRendererComponent(JTable table, @@ -158,11 +168,12 @@ public class UpdateContributionTab extends ContributionTab { setForeground(tableHeader.getForeground()); } setIcon(getIcon(table, column)); - setBackground(Color.LIGHT_GRAY); + setBackground(new Color(0xebebeb)); // setBorder(BorderFactory.createMatteBorder(2, 0, 2, 0, Color.BLACK)); return this; } }); + GroupLayout layout = new GroupLayout(this); layout.setHorizontalGroup(layout.createParallelGroup().addComponent(scrollPane)); @@ -205,6 +216,18 @@ public class UpdateContributionTab extends ContributionTab { }); } + + class StatusRendere extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, int row, + int column) { + return super.getTableCellRendererComponent(table, value, isSelected, false, + row, column); + } + } // // @Override // public void contributionAdded(Contribution contribution) { @@ -246,12 +269,12 @@ public class UpdateContributionTab extends ContributionTab { } Icon icon = null; if (entry.isInstalled()) { - icon = Toolkit.getLibIcon("icons/installedAndUptodate.png"); + icon = Toolkit.getLibIcon("manager/up-to-date.png"); if (contribListing.hasUpdates(entry)) { - icon = Toolkit.getLibIcon("icons/installedNeedsUpdate.png"); + icon = Toolkit.getLibIcon("manager/update-available.png"); } if (!entry.isCompatible(Base.getRevision())) { - icon = Toolkit.getLibIcon("icons/installedIncompatible.png"); + icon = Toolkit.getLibIcon("manager/incompatible.png"); } } dtm @@ -280,7 +303,9 @@ public class UpdateContributionTab extends ContributionTab { public class UpdateStatusPanel extends StatusPanel { public UpdateStatusPanel(int width, final ContributionTab contributionTab) { super(); - updateButton = new JButton("Update All"); + updateButton = new JButton("Update All", Toolkit.getLibIcon("manager/update.png")); + updateButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); + updateButton.setHorizontalAlignment(SwingConstants.LEFT); // updateButton.setContentAreaFilled(false); // updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0))); updateButton.addActionListener(new ActionListener() { @@ -292,7 +317,7 @@ public class UpdateContributionTab extends ContributionTab { } } }); - this.setBackground(Color.LIGHT_GRAY); + this.setBackground(new Color(0xe0fffd)); // this.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK)); layout = new GroupLayout(this); this.setLayout(layout); @@ -309,9 +334,14 @@ public class UpdateContributionTab extends ContributionTab { .addComponent(updateButton)); updateButton.setVisible(true); } + @Override public void update(ContributionPanel panel) { - + if (contributionListPanel.getNoOfRows() > 0) { + updateButton.setEnabled(true); + } else { + updateButton.setEnabled(false); + } } } }