FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

more icons and code cleanup · dimr/processing@d66c639 · GitHub

Repository navigation

Commit d66c639

Browse files
committed
more icons and code cleanup
1 parent 4f11330 commit d66c639

3 files changed

Lines changed: 83 additions & 95 deletions

File tree

‎app/src/processing/app/contrib/ContributionManagerDialog.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,11 @@ public class ContributionManagerDialog {
7373
private JLabel updateTabLabel;
7474

7575
static Font font;
76-
// disabling this because the icon sizing is not implemented correctly
77-
//static int iconVer = Toolkit.highResDisplay() ? 2 : 1;
78-
static final int iconVer = 1;
7976

8077

8178
public ContributionManagerDialog() {
8279
font = Toolkit.getSansFont(14, Font.PLAIN);
83-
// GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(myFont);
84-
numberLabel = new JLabel(Toolkit.getLibIcon("manager/notification-" + iconVer + "x.png"), SwingConstants.CENTER);
80+
numberLabel = new JLabel(Toolkit.getLibIconX("manager/notification"), SwingConstants.CENTER);
8581
librariesContributionTab = new ContributionTab(ContributionType.LIBRARY, this);
8682
modesContributionTab = new ContributionTab(ContributionType.MODE, this);
8783
toolsContributionTab = new ContributionTab(ContributionType.TOOL, this);

‎app/src/processing/app/contrib/StatusPanel.java‎

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public void hyperlinkUpdate(HyperlinkEvent e) {
8686
}
8787
}
8888
});
89-
installButton = new JButton("Install",
90-
Toolkit.getLibIcon("manager/install-" + ContributionManagerDialog.iconVer + "x.png"));
89+
installButton =
90+
new JButton("Install", Toolkit.getLibIconX("manager/install"));
9191
installButton.setFont(Toolkit.getSansFont(14, Font.PLAIN));
9292
installButton.setHorizontalAlignment(SwingConstants.LEFT);
9393
// installButton.setContentAreaFilled(false);
@@ -109,44 +109,35 @@ public void actionPerformed(ActionEvent e) {
109109
updateLabel = new JLabel(" ");
110110
updateLabel.setFont(Toolkit.getSansFont(14, Font.PLAIN));
111111
updateLabel.setHorizontalAlignment(SwingConstants.CENTER);
112-
updateButton = new JButton("Update",
113-
Toolkit.getLibIcon("manager/update-" + ContributionManagerDialog.iconVer + "x.png"));
112+
updateButton =
113+
new JButton("Update", Toolkit.getLibIconX("manager/update"));
114114
updateButton.setFont(Toolkit.getSansFont(14, Font.PLAIN));
115115
updateButton.setHorizontalAlignment(SwingConstants.LEFT);
116-
// updateButton.setAlignmentX(SwingConstants.LEFT);
117-
// updateButton.setContentAreaFilled(false);
118-
// updateButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
119116
updateButton.addActionListener(new ActionListener() {
120-
121-
@Override
122117
public void actionPerformed(ActionEvent e) {
123118
updateButton.setEnabled(false);
124-
ContributionPanel currentPanel = contributionTab.contributionListPanel
125-
.getSelectedPanel();
119+
ContributionPanel currentPanel =
120+
contributionTab.contributionListPanel.getSelectedPanel();
126121
currentPanel.update();
127122
StatusPanel.this.update(currentPanel);
128123
}
129124
});
130125

131-
removeButton = new JButton("Remove",
132-
Toolkit.getLibIcon("manager/remove-" + ContributionManagerDialog.iconVer + "x.png"));
126+
removeButton =
127+
new JButton("Remove", Toolkit.getLibIconX("manager/remove"));
133128
removeButton.setFont(Toolkit.getSansFont(14, Font.BOLD));
134129
removeButton.setHorizontalAlignment(SwingConstants.LEFT);
135-
// removeButton.setContentAreaFilled(false);
136-
// removeButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0)));
137130
removeButton.addActionListener(new ActionListener() {
138-
139-
@Override
140131
public void actionPerformed(ActionEvent e) {
141132
removeButton.setEnabled(false);
142-
ContributionPanel currentPanel = contributionTab.contributionListPanel
143-
.getSelectedPanel();
133+
ContributionPanel currentPanel =
134+
contributionTab.contributionListPanel.getSelectedPanel();
144135
currentPanel.remove();
145136
StatusPanel.this.update(currentPanel);
146137
}
147138
});
148139

149-
int labelWidth = width != 0 ? width * 3 / 4 : GroupLayout.PREFERRED_SIZE;
140+
int labelWidth = (width != 0) ? (3 * width / 4) : GroupLayout.PREFERRED_SIZE;
150141
layout = new GroupLayout(this);
151142
this.setLayout(layout);
152143

‎app/src/processing/app/contrib/UpdateContributionTab.java‎

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -95,30 +95,31 @@ public class UpdateContribListingPanel extends ContributionListPanel {
9595

9696
public UpdateContribListingPanel(ContributionTab contributionTab,
9797
ContributionFilter filter) {
98-
super.contributionTab = contributionTab;
99-
super.filter = filter;
98+
this.contributionTab = contributionTab;
99+
this.filter = filter;
100+
100101
setOpaque(true);
101102
setBackground(Color.WHITE);
102103

103-
// statusPlaceholder = new JPanel();
104-
// statusPlaceholder.setVisible(false);
105-
// status = new StatusPanel(null);
104+
model = new DefaultTableModel() {
105+
@Override
106+
public boolean isCellEditable(int row, int column) {
107+
return false;
108+
}
106109

107-
String[] colName = { "", "Name", "Author", "Installed", "Update To" };
108-
model = new MyTableModel(){
109110
@Override
110111
public Class<?> getColumnClass(int columnIndex) {
111-
if (columnIndex == 0) {
112-
return Icon.class;
113-
}
114-
return String.class;
112+
return (columnIndex == 0) ? Icon.class : String.class;
115113
}
116114
};
117-
model.setColumnIdentifiers(colName);
118-
table = new JTable(model){
115+
116+
model.setColumnIdentifiers(new String[] {
117+
"", "Name", "Author", "Installed", "Update To"
118+
});
119+
120+
table = new JTable(model) {
119121
@Override
120-
public Component prepareRenderer(
121-
TableCellRenderer renderer, int row, int column) {
122+
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
122123
Component c = super.prepareRenderer(renderer, row, column);
123124
String title = (String) getValueAt(row, 1);
124125
if (title.equals("<html><i>Library</i></html>") || title.equals("<html><i>Tools</i></html>")
@@ -128,24 +129,21 @@ public Component prepareRenderer(
128129
}
129130
return c;
130131
}
132+
131133
@Override
132134
public void changeSelection(int rowIndex, int columnIndex,
133135
boolean toggle, boolean extend) {
134136
String title = (String) getValueAt(rowIndex, 1);
135-
if(title.equals("<html><i>Library</i></html>") || title.equals("<html><i>Tools</i></html>")
136-
|| title.equals("<html><i>Modes</i></html>") || title.equals("<html><i>Examples</i></html>")){
137+
if (title.equals("<html><i>Library</i></html>") ||
138+
title.equals("<html><i>Tools</i></html>") ||
139+
title.equals("<html><i>Modes</i></html>") ||
140+
title.equals("<html><i>Examples</i></html>")){
137141
return;
138142
}
139143
super.changeSelection(rowIndex, columnIndex, toggle, extend);
140144
}
141-
// @Override
142-
// public boolean isRowSelected(int row) {
143-
// if (row == 0) {
144-
// return false;
145-
// }
146-
// return super.isRowSelected(row);
147-
// }
148145
};
146+
149147
scrollPane = new JScrollPane(table);
150148
table.setFillsViewportHeight(true);
151149
table.setSelectionBackground(new Color(0xe0fffd));
@@ -160,23 +158,35 @@ public void changeSelection(int rowIndex, int columnIndex,
160158
table.setRowSelectionAllowed(true);
161159
table.setAutoCreateColumnsFromModel(true);
162160
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
163-
table.setDefaultRenderer(String.class, new StatusRendere());
161+
162+
table.setDefaultRenderer(String.class, new DefaultTableCellRenderer() {
163+
@Override
164+
public Component getTableCellRendererComponent(JTable table,
165+
Object value,
166+
boolean isSelected,
167+
boolean hasFocus,
168+
int row, int column) {
169+
return super.getTableCellRendererComponent(table, value, isSelected,
170+
false, row, column);
171+
}
172+
});
173+
164174
table.getTableHeader().setDefaultRenderer(new ContribHeaderRenderer() {
165175
@Override
166176
public Component getTableCellRendererComponent(JTable table,
167177
Object value,
168178
boolean isSelected,
169179
boolean hasFocus, int row,
170180
int column) {
171-
super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
172-
row, column);
181+
// TODO this doesn't do anything with the returned value? [fry]
182+
super.getTableCellRendererComponent(table, value, isSelected,
183+
hasFocus, row, column);
173184
JTableHeader tableHeader = table.getTableHeader();
174185
if (tableHeader != null) {
175186
setForeground(tableHeader.getForeground());
176187
}
177188
setIcon(getIcon(table, column));
178189
setBackground(new Color(0xebebeb));
179-
// setBorder(BorderFactory.createMatteBorder(2, 0, 2, 0, Color.BLACK));
180190
return this;
181191
}
182192
});
@@ -224,33 +234,14 @@ public int compare(Contribution o1, Contribution o2) {
224234

225235
}
226236

227-
class StatusRendere extends DefaultTableCellRenderer {
228-
@Override
229-
public Component getTableCellRendererComponent(JTable table,
230-
Object value,
231-
boolean isSelected,
232-
boolean hasFocus, int row,
233-
int column) {
234-
return super.getTableCellRendererComponent(table, value, isSelected, false,
235-
row, column);
236-
}
237-
}
238-
//
239-
// @Override
240-
// public void contributionAdded(Contribution contribution) {
241-
// if(filter.matches(contribution)){
242-
// super.contributionAdded(contribution);
243-
// }
244-
// }
245-
//
246237
@Override
247238
void updatePanelOrdering(Set<Contribution> contributionsSet) {
248-
if(getNoOfRows() == 0){
249-
contributionTab.contributionManagerDialog.numberLabel.setVisible(false);
250-
}else{
251-
contributionTab.contributionManagerDialog.numberLabel.setText(Integer
252-
.toString(panelByContribution.size()));
253-
contributionTab.contributionManagerDialog.numberLabel.setVisible(true);
239+
JLabel label = contributionTab.contributionManagerDialog.numberLabel;
240+
if (getNoOfRows() == 0) {
241+
label.setVisible(false);
242+
} else {
243+
label.setVisible(true);
244+
label.setText(Integer.toString(panelByContribution.size()));
254245
}
255246
model.getDataVector().removeAllElements();
256247
model.fireTableDataChanged();
@@ -261,16 +252,19 @@ void updatePanelOrdering(Set<Contribution> contributionsSet) {
261252
String fontFace = "<font face=\"" + boldFont.getName() + "\">";
262253

263254
for (Contribution entry : contributionsSet) {
264-
if(entry.getType() != temp){
255+
if (entry.getType() != temp) {
265256
temp = entry.getType();
266-
model.addRow(new Object[] { null, "<html><i>" + temp.getTitle() + "</i></html>", null, null, null });
257+
model.addRow(new Object[] {
258+
null,
259+
"<html><i>" + temp.getTitle() + "</i></html>",
260+
null, null, null
261+
});
267262
}
268263
//TODO Make this into a function
269264
StringBuilder name = new StringBuilder("");
270265
String authorList = entry.getAuthorList();
271266
if (authorList != null) {
272267
for (int i = 0; i < authorList.length(); i++) {
273-
274268
if (authorList.charAt(i) == '[' || authorList.charAt(i) == ']') {
275269
continue;
276270
}
@@ -286,37 +280,44 @@ void updatePanelOrdering(Set<Contribution> contributionsSet) {
286280
}
287281
Icon icon = null;
288282
if (entry.isInstalled()) {
289-
icon = Toolkit.getLibIcon("manager/up-to-date-" + ContributionManagerDialog.iconVer + "x.png");
283+
icon = upToDateIcon;
290284
if (contribListing.hasUpdates(entry)) {
291-
icon = Toolkit.getLibIcon("manager/update-available-" + ContributionManagerDialog.iconVer + "x.png");
285+
icon = updateAvailableIcon;
292286
}
293287
if (!entry.isCompatible(Base.getRevision())) {
294-
icon = Toolkit.getLibIcon("manager/incompatible-" + ContributionManagerDialog.iconVer + "x.png");
288+
icon = incompatibleIcon;
295289
}
296290
}
297291
model.addRow(new Object[] {
298-
icon, "<html>" + fontFace + entry.getName() + "</font></html>", name, entry.getPrettyVersion(),
299-
contributionTab.contribListing.getLatestVersion(entry) });
292+
icon,
293+
"<html>" + fontFace + entry.getName() + "</font></html>",
294+
name,
295+
entry.getPrettyVersion(),
296+
contributionTab.contribListing.getLatestVersion(entry)
297+
});
300298
}
301-
((UpdateStatusPanel)statusPanel).update();
299+
((UpdateStatusPanel)statusPanel).update();
302300
}
303-
private class MyTableModel extends DefaultTableModel{
304-
MyTableModel() {
305-
super(0,0);
306-
}
301+
302+
303+
/*
304+
private class MyTableModel extends DefaultTableModel {
305+
307306
@Override
308307
public boolean isCellEditable(int row, int column) {
309308
return false;
310309
}
310+
311311
@Override
312312
public Class<?> getColumnClass(int columnIndex) {
313-
if(columnIndex == 0){
314-
return Icon.class;
315-
}
316-
return super.getColumnClass(columnIndex);
313+
return (columnIndex == 0) ?
314+
Icon.class : super.getColumnClass(columnIndex);
317315
}
318316
}
317+
*/
319318
}
319+
320+
320321
public class UpdateStatusPanel extends StatusPanel {
321322
public UpdateStatusPanel(int width, final ContributionTab contributionTab) {
322323
super();

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL