Some changes

This commit is contained in:
Akarshit Wal
2015-08-12 21:54:46 +05:30
parent 70bda77497
commit ca9cee8705
5 changed files with 189 additions and 87 deletions
@@ -103,7 +103,8 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
return c;
}
};
String[] colName = { "Status", "Name", "Author" };
// There is a space before Status
String[] colName = { " Status", "Name", "Author" };
dtm.setColumnIdentifiers(colName);
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
@@ -113,6 +114,8 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
table.setRowMargin(6);
table.getColumnModel().setColumnMargin(-1);
table.getColumnModel().getColumn(0).setMaxWidth(60);
table.getColumnModel().getColumn(2).setMinWidth(ContributionManagerDialog.AUTHOR_WIDTH);
table.getColumnModel().getColumn(2).setMaxWidth(ContributionManagerDialog.AUTHOR_WIDTH);
table.setShowGrid(false);
table.setColumnSelectionAllowed(false);
table.setCellSelectionEnabled(false);
@@ -190,10 +193,9 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
setForeground(tableHeader.getForeground());
}
setIcon(getIcon(table, column));
setBackground(Color.WHITE);
setBorder(BorderFactory.createCompoundBorder(BorderFactory
.createMatteBorder(2, 0, 2, 0, Color.BLACK), BorderFactory
.createEmptyBorder(0, (column == 2 ? 17 : 0), 0, 0)));
//TODO: put correct Color here
setBackground(Color.LIGHT_GRAY);
setBorder(null);
return this;
}
@@ -44,7 +44,10 @@ import processing.app.ui.Toolkit;
*/
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 STATUS_WIDTH = 60;
JFrame dialog;
JTabbedPane tabbedPane;
String title;
@@ -63,6 +66,12 @@ public class ContributionManagerDialog {
ContributionListing contributionListing = ContributionListing.getInstance();
private JLabel[] tabLabels;
private JPanel updateTabPanel;
private JLabel updateTabLabel;
public ContributionManagerDialog() {
numberLabel = new JLabel(Toolkit.getLibIcon("manager/notification.png"), SwingConstants.CENTER);
@@ -112,6 +121,13 @@ public class ContributionManagerDialog {
makeFrame(editor);
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()).setForeground(Color.BLACK);
}else{
updateTabPanel.setBackground(Color.WHITE);
updateTabLabel.setForeground(Color.BLACK);
}
}
tabbedPane.setSelectedIndex(index);
dialog.setVisible(true);
@@ -120,7 +136,6 @@ public class ContributionManagerDialog {
public void makeFrame(final Editor editor) {
dialog = new JFrame(title);
String[] tabTitles = { "Tools","Libraries","Modes","Examples","Updates"};
tabbedPane = new JTabbedPane();
makeAndShowTab(false, true);
@@ -142,47 +157,30 @@ public class ContributionManagerDialog {
tabbedPane.addTab("Updates", null, updatesContributionTab.panel, "Updates");
tabbedPane.setMnemonicAt(3, KeyEvent.VK_5);
tabbedPane.setUI(new SpacedTabbedPaneUI());
tabbedPane.setBackground(Color.WHITE);
tabbedPane.setBackground(new Color(0x132638));
tabbedPane.setOpaque(true);
tabbedPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
// tabbedPane.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
JPanel updateTabPanel = new JPanel(true);
JLabel updateTabLabel = new JLabel("Update");
numberLabel.setVerticalTextPosition(SwingConstants.CENTER);
numberLabel.setHorizontalTextPosition(SwingConstants.CENTER);
updateTabPanel.setOpaque(false);
updateTabPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
.createMatteBorder(0, 2, 0, 0, Color.BLACK), BorderFactory
.createEmptyBorder(4, 4, 4, 4)));
tabbedPane.setTabComponentAt(4, updateTabPanel);
JLabel tabLabels[] = new JLabel[4];
for(int i = 0 ; i < tabLabels.length;i++){
tabLabels[i] = new JLabel(tabTitles[i]);
tabLabels[i]
.setBorder(BorderFactory.createCompoundBorder(BorderFactory
.createMatteBorder(0, (i == 0 ? 0 : 2), 0, (i == 3 ? 2 : 0),
Color.BLACK), BorderFactory
.createEmptyBorder(4, 4, 4, 4)));
tabbedPane.setTabComponentAt(i, tabLabels[i]);
}
GroupLayout tabLayout = new GroupLayout(updateTabPanel);
tabLayout.setAutoCreateGaps(true);
updateTabPanel.setLayout(tabLayout);
tabLayout.setHorizontalGroup(tabLayout
.createSequentialGroup()
.addComponent(numberLabel)
.addComponent(updateTabLabel));
tabLayout.setVerticalGroup(tabLayout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(numberLabel)
.addComponent(updateTabLabel));
makeAndSetTabComponents();
tabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
for(int i = 0 ; i < 4; i++){
tabLabels[i].setBackground(new Color(0x2d4251));
tabLabels[i].setForeground(Color.WHITE);
}
updateTabPanel.setBackground(new Color(0x2d4251));
updateTabLabel.setForeground(Color.WHITE);
int currentIndex = tabbedPane.getSelectedIndex();
if(currentIndex != 4){
tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setBackground(Color.WHITE);
tabbedPane.getTabComponentAt(tabbedPane.getSelectedIndex()).setForeground(Color.BLACK);
}else{
updateTabPanel.setBackground(Color.WHITE);
updateTabLabel.setForeground(Color.BLACK);
}
// // When the tab is changed update status to the current selected panel
// ContributionPanel currentPanel = getActiveTab().contributionListPanel
// .getSelectedPanel();
@@ -249,6 +247,57 @@ public class ContributionManagerDialog {
dialog.setLocationRelativeTo(null);
}
private void makeAndSetTabComponents() {
String[] tabTitles = { "Tools","Libraries","Modes","Examples","Updates"};
tabLabels = new JLabel[4];
for(int i = 0 ; i < 4; i++){
tabLabels[i] = new JLabel(tabTitles[i]);
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);
tabbedPane.setTabComponentAt(i, tabLabels[i]);
}
updateTabPanel = new JPanel(true);
updateTabLabel = new JLabel("Updates");
numberLabel.setVerticalTextPosition(SwingConstants.CENTER);
numberLabel.setHorizontalTextPosition(SwingConstants.CENTER);
updateTabPanel.setOpaque(true);
updateTabPanel.setBackground(new Color(0x2d4251));
updateTabLabel.setForeground(Color.WHITE);
updateTabPanel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
updateTabPanel.setPreferredSize(new Dimension(TAB_WIDTH, TAB_HEIGHT));
// updateTabPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
// .createMatteBorder(0, 2, 0, 0, Color.BLACK), BorderFactory
// .createEmptyBorder(4, 4, 4, 4)));
tabbedPane.setTabComponentAt(4, updateTabPanel);
// JLabel tabLabels[] = new JLabel[4];
// for(int i = 0 ; i < tabLabels.length;i++){
// tabLabels[i] = new JLabel(tabTitles[i]);
// tabLabels[i]
// .setBorder(BorderFactory.createCompoundBorder(BorderFactory
// .createMatteBorder(0, (i == 0 ? 0 : 2), 0, (i == 3 ? 2 : 0),
// Color.BLACK), BorderFactory
// .createEmptyBorder(4, 4, 4, 4)));
// tabbedPane.setTabComponentAt(i, tabLabels[i]);
// }
GroupLayout tabLayout = new GroupLayout(updateTabPanel);
tabLayout.setAutoCreateGaps(true);
updateTabPanel.setLayout(tabLayout);
tabLayout.setHorizontalGroup(tabLayout.createSequentialGroup()
.addComponent(updateTabLabel).addComponent(numberLabel));
tabLayout.setVerticalGroup(tabLayout
.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(numberLabel).addComponent(updateTabLabel));
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -256,18 +305,47 @@ public class ContributionManagerDialog {
public class SpacedTabbedPaneUI extends BasicTabbedPaneUI {
@Override
protected void installDefaults() {
UIManager.put("TabbedPane.selected", Color.WHITE);
UIManager.put("TabbedPane.selected", Color.BLACK);
UIManager.put("TabbedPane.tabsOverlapBorder" , true);
super.installDefaults();
highlight = Color.WHITE;
lightHighlight = Color.WHITE;
shadow = Color.WHITE;
darkShadow = Color.WHITE;
focus = Color.LIGHT_GRAY;
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);
selectedTabPadInsets = new Insets(0, 0, 0, 0);
}
// @Override
// protected int getTabLabelShiftX(int tabPlacement, int tabIndex,
// boolean isSelected) {
// return 0;
// }
// @Override
// protected int getTabLabelShiftY(int tabPlacement, int tabIndex,
// boolean isSelected) {
// return 3;
// }
@Override
protected void paintTabBackground(Graphics g, int tabPlacement,
int tabIndex, int x, int y, int w, int h,
boolean isSelected) {
return;
}
@Override
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
int x, int y, int w, int h, boolean isSelected) {
return;
}
@Override
protected void paintFocusIndicator(Graphics g, int tabPlacement,
Rectangle[] rects, int tabIndex,
Rectangle iconRect, Rectangle textRect,
boolean isSelected) {
return;
}
@Override
protected LayoutManager createLayoutManager() {
@@ -281,13 +359,11 @@ public class ContributionManagerDialog {
@Override
protected void calculateTabRects(int tabPlacement, int tabCount) {
super.calculateTabRects(tabPlacement, tabCount);
for (int i = 0; i < rects.length; i++) {
rects[i].y -= 10;
rects[i].height += 15;
if (i == 4) {
rects[i].x = tabbedPane.getWidth() - rects[i].width - 2;
}
}
rects[0].x -= 2;
rects[1].x -= 1;
rects[2].x -= 1;
rects[3].x -= 1;
rects[4].x = tabbedPane.getWidth() - rects[4].width + 1;
}
};
}
@@ -305,7 +381,8 @@ public class ContributionManagerDialog {
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(tabbedPane));
layout.setVerticalGroup(layout.createParallelGroup().addComponent(tabbedPane));
layout.setHonorsVisibility(tabbedPane, true);
dialog.getContentPane().setBackground(Color.WHITE);
//TODO set color here
dialog.getContentPane().setBackground(new Color(0x132638));
dialog.validate();
dialog.repaint();
}
@@ -25,7 +25,6 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.*;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.event.*;
@@ -203,20 +202,24 @@ public class ContributionTab {
.addComponent(filterLabel)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(filterField)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
// .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
.addComponent(categoryChooser,
categoryChooser.getPreferredSize().width + 20,
categoryChooser.getPreferredSize().width + 20,
categoryChooser.getPreferredSize().width + 20)
ContributionManagerDialog.AUTHOR_WIDTH,
ContributionManagerDialog.AUTHOR_WIDTH,
ContributionManagerDialog.AUTHOR_WIDTH)
.addContainerGap()).addComponent(loaderLabel)
.addComponent(contributionListPanel).addComponent(errorPanel)
.addComponent(statusPanel));
layout.setVerticalGroup(layout
.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(filterLabel).addComponent(categoryChooser)
.addComponent(filterField))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
.addComponent(loaderLabel)
.addComponent(contributionListPanel))
@@ -227,7 +230,7 @@ public class ContributionTab {
layout.setHonorsVisibility(contributionListPanel, false);
panel.setBackground(Color.WHITE);
panel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
panel.setBorder(null);
}
@@ -264,7 +267,7 @@ public class ContributionTab {
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
errorPanel.setLayout(layout);
errorPanel.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
// errorPanel.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
errorMessage = new JTextPane();
errorMessage.setEditable(false);
errorMessage.setContentType("text/html");
@@ -290,8 +293,8 @@ public class ContributionTab {
}
});
tryAgainButton = new JButton("Try Again");
tryAgainButton.setContentAreaFilled(false);
tryAgainButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
// tryAgainButton.setContentAreaFilled(false);
// tryAgainButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
tryAgainButton.addActionListener(new ActionListener() {
@Override
+32 -12
View File
@@ -28,6 +28,8 @@ import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
@@ -38,6 +40,7 @@ import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import processing.app.Base;
import processing.app.ui.Toolkit;
class StatusPanel extends JPanel {
@@ -51,15 +54,19 @@ class StatusPanel extends JPanel {
JButton updateButton;
JButton removeButton;
GroupLayout layout;
JLabel iconLabel;
ContributionListing contributionListing = ContributionListing.getInstance();
ContributionTab contributionTab;
public StatusPanel(int width, final ContributionTab contributionTab) {
super();
setBackground(Color.WHITE);
setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
setBackground(Color.LIGHT_GRAY);
// setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
this.contributionTab = contributionTab;
iconLabel = new JLabel();
label = new JTextPane();
label.setEditable(false);
label.setOpaque(false);
@@ -75,9 +82,10 @@ class StatusPanel extends JPanel {
}
}
});
installButton = new JButton("Install");
installButton.setContentAreaFilled(false);
installButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
installButton = new JButton("Install", Toolkit.getLibIcon("manager/update.png"));
installButton.setHorizontalAlignment(SwingConstants.LEFT);
// installButton.setContentAreaFilled(false);
// installButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
installButton.addActionListener(new ActionListener() {
@Override
@@ -92,9 +100,11 @@ class StatusPanel extends JPanel {
progressBarPanel.setLayout(new BorderLayout());
progressBarPanel.setOpaque(false);
updateLabel = new JLabel(" ");
updateButton = new JButton("Update");
updateButton.setContentAreaFilled(false);
updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
updateButton = new JButton("Update", Toolkit.getLibIcon("manager/update.png"));
updateButton.setHorizontalAlignment(SwingConstants.LEFT);
// updateButton.setAlignmentX(SwingConstants.LEFT);
// updateButton.setContentAreaFilled(false);
// updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
updateButton.addActionListener(new ActionListener() {
@Override
@@ -106,9 +116,10 @@ class StatusPanel extends JPanel {
}
});
removeButton = new JButton("Remove");
removeButton.setContentAreaFilled(false);
removeButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
removeButton = new JButton("Remove", Toolkit.getLibIcon("manager/remove.png"));
removeButton.setHorizontalAlignment(SwingConstants.LEFT);
// removeButton.setContentAreaFilled(false);
// removeButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
removeButton.addActionListener(new ActionListener() {
@Override
@@ -129,6 +140,8 @@ class StatusPanel extends JPanel {
layout.setHorizontalGroup(layout
.createSequentialGroup()
.addComponent(iconLabel, 50, 50, 50)
.addGap(0)
.addComponent(label, labelWidth, labelWidth, labelWidth)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
@@ -140,7 +153,8 @@ class StatusPanel extends JPanel {
.addComponent(removeButton)));
layout.setVerticalGroup(layout
.createParallelGroup()
.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(iconLabel)
.addComponent(label)
.addGroup(layout
.createSequentialGroup()
@@ -198,6 +212,12 @@ class StatusPanel extends JPanel {
progressBarPanel.removeAll();
if (panel.getContrib().isSpecial()) {
Icon contribIcon = new ImageIcon(Toolkit.getLibImage("/icons/pde-48.png"));
iconLabel.setIcon(contribIcon);
} else {
iconLabel.setIcon(null);
}
label.setText(panel.description.toString());
updateButton.setEnabled(contributionListing.hasDownloadedLatestList()
@@ -74,7 +74,7 @@ public class UpdateContributionTab extends ContributionTab {
layout.setHonorsVisibility(contributionListPanel, false);
panel.setBackground(Color.WHITE);
panel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
// panel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
}
@@ -108,8 +108,8 @@ public class UpdateContributionTab extends ContributionTab {
TableCellRenderer renderer, int row, int column) {
Component c = super.prepareRenderer(renderer, row, column);
String title = (String) getValueAt(row, 1);
if (title.equals("<html><i>Library</i></html>") || title.equals("Tools")
|| title.equals("Modes") || title.equals("Examples")) {
if (title.equals("<html><i>Library</i></html>") || title.equals("<html><i>Tools</i></html>")
|| title.equals("<html><i>Modes</i></html>") || title.equals("<html><i>Examples</i></html>")) {
((JComponent) c).setBorder(BorderFactory
.createMatteBorder(row == 0 ? 0 : 2, 0, 2, 0, Color.BLACK));
}
@@ -119,7 +119,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("<html><i>Library</i></html>")){
if(title.equals(title.equals("<html><i>Library</i></html>") || title.equals("<html><i>Tools</i></html>")
|| title.equals("<html><i>Modes</i></html>") || title.equals("<html><i>Examples</i></html>"))){
return;
}
super.changeSelection(rowIndex, columnIndex, toggle, extend);
@@ -157,8 +158,8 @@ public class UpdateContributionTab extends ContributionTab {
setForeground(tableHeader.getForeground());
}
setIcon(getIcon(table, column));
setBackground(Color.WHITE);
setBorder(BorderFactory.createMatteBorder(2, 0, 2, 0, Color.BLACK));
setBackground(Color.LIGHT_GRAY);
// setBorder(BorderFactory.createMatteBorder(2, 0, 2, 0, Color.BLACK));
return this;
}
});
@@ -280,10 +281,9 @@ public class UpdateContributionTab extends ContributionTab {
public UpdateStatusPanel(int width, final ContributionTab contributionTab) {
super();
updateButton = new JButton("Update All");
updateButton.setContentAreaFilled(false);
updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
// updateButton.setContentAreaFilled(false);
// updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
updateButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
@@ -292,8 +292,8 @@ public class UpdateContributionTab extends ContributionTab {
}
}
});
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
this.setBackground(Color.LIGHT_GRAY);
// this.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
layout = new GroupLayout(this);
this.setLayout(layout);