| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,15 +73,11 @@ public class ContributionManagerDialog { | |||
| 73 | 73 | private JLabel updateTabLabel; | |
| 74 | 74 | ||
| 75 | 75 | 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; | ||
| 79 | 76 | ||
| 80 | 77 | ||
| 81 | 78 | public ContributionManagerDialog() { | |
| 82 | 79 | 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); | ||
| 85 | 81 | librariesContributionTab = new ContributionTab(ContributionType.LIBRARY, this); | |
| 86 | 82 | modesContributionTab = new ContributionTab(ContributionType.MODE, this); | |
| 87 | 83 | toolsContributionTab = new ContributionTab(ContributionType.TOOL, this); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,8 +86,8 @@ public void hyperlinkUpdate(HyperlinkEvent e) { | |||
| 86 | 86 | } | |
| 87 | 87 | } | |
| 88 | 88 | }); | |
| 89 | - installButton = new JButton("Install", | ||
| 90 | - Toolkit.getLibIcon("manager/install-" + ContributionManagerDialog.iconVer + "x.png")); | ||
| 89 | + installButton = | ||
| 90 | + new JButton("Install", Toolkit.getLibIconX("manager/install")); | ||
| 91 | 91 | installButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); | |
| 92 | 92 | installButton.setHorizontalAlignment(SwingConstants.LEFT); | |
| 93 | 93 | // installButton.setContentAreaFilled(false); | |
@@ -109,44 +109,35 @@ public void actionPerformed(ActionEvent e) { | |||
| 109 | 109 | updateLabel = new JLabel(" "); | |
| 110 | 110 | updateLabel.setFont(Toolkit.getSansFont(14, Font.PLAIN)); | |
| 111 | 111 | 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")); | ||
| 114 | 114 | updateButton.setFont(Toolkit.getSansFont(14, Font.PLAIN)); | |
| 115 | 115 | 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))); | ||
| 119 | 116 | updateButton.addActionListener(new ActionListener() { | |
| 120 | - | ||
| 121 | - @Override | ||
| 122 | 117 | public void actionPerformed(ActionEvent e) { | |
| 123 | 118 | updateButton.setEnabled(false); | |
| 124 | - ContributionPanel currentPanel = contributionTab.contributionListPanel | ||
| 125 | - .getSelectedPanel(); | ||
| 119 | + ContributionPanel currentPanel = | ||
| 120 | + contributionTab.contributionListPanel.getSelectedPanel(); | ||
| 126 | 121 | currentPanel.update(); | |
| 127 | 122 | StatusPanel.this.update(currentPanel); | |
| 128 | 123 | } | |
| 129 | 124 | }); | |
| 130 | 125 | ||
| 131 | - removeButton = new JButton("Remove", | ||
| 132 | - Toolkit.getLibIcon("manager/remove-" + ContributionManagerDialog.iconVer + "x.png")); | ||
| 126 | + removeButton = | ||
| 127 | + new JButton("Remove", Toolkit.getLibIconX("manager/remove")); | ||
| 133 | 128 | removeButton.setFont(Toolkit.getSansFont(14, Font.BOLD)); | |
| 134 | 129 | removeButton.setHorizontalAlignment(SwingConstants.LEFT); | |
| 135 | - // removeButton.setContentAreaFilled(false); | ||
| 136 | - // removeButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK, 1),BorderFactory.createEmptyBorder(3, 0, 3, 0))); | ||
| 137 | 130 | removeButton.addActionListener(new ActionListener() { | |
| 138 | - | ||
| 139 | - @Override | ||
| 140 | 131 | public void actionPerformed(ActionEvent e) { | |
| 141 | 132 | removeButton.setEnabled(false); | |
| 142 | - ContributionPanel currentPanel = contributionTab.contributionListPanel | ||
| 143 | - .getSelectedPanel(); | ||
| 133 | + ContributionPanel currentPanel = | ||
| 134 | + contributionTab.contributionListPanel.getSelectedPanel(); | ||
| 144 | 135 | currentPanel.remove(); | |
| 145 | 136 | StatusPanel.this.update(currentPanel); | |
| 146 | 137 | } | |
| 147 | 138 | }); | |
| 148 | 139 | ||
| 149 | - int labelWidth = width != 0 ? width * 3 / 4 : GroupLayout.PREFERRED_SIZE; | ||
| 140 | + int labelWidth = (width != 0) ? (3 * width / 4) : GroupLayout.PREFERRED_SIZE; | ||
| 150 | 141 | layout = new GroupLayout(this); | |
| 151 | 142 | this.setLayout(layout); | |
| 152 | 143 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,30 +95,31 @@ public class UpdateContribListingPanel extends ContributionListPanel { | |||
| 95 | 95 | ||
| 96 | 96 | public UpdateContribListingPanel(ContributionTab contributionTab, | |
| 97 | 97 | ContributionFilter filter) { | |
| 98 | - super.contributionTab = contributionTab; | ||
| 99 | - super.filter = filter; | ||
| 98 | + this.contributionTab = contributionTab; | ||
| 99 | + this.filter = filter; | ||
| 100 | + | ||
| 100 | 101 | setOpaque(true); | |
| 101 | 102 | setBackground(Color.WHITE); | |
| 102 | 103 | ||
| 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 | + } | ||
| 106 | 109 | ||
| 107 | - String[] colName = { "", "Name", "Author", "Installed", "Update To" }; | ||
| 108 | - model = new MyTableModel(){ | ||
| 109 | 110 | @Override | |
| 110 | 111 | 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; | ||
| 115 | 113 | } | |
| 116 | 114 | }; | |
| 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) { | ||
| 119 | 121 | @Override | |
| 120 | - public Component prepareRenderer( | ||
| 121 | - TableCellRenderer renderer, int row, int column) { | ||
| 122 | + public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { | ||
| 122 | 123 | Component c = super.prepareRenderer(renderer, row, column); | |
| 123 | 124 | String title = (String) getValueAt(row, 1); | |
| 124 | 125 | if (title.equals("<html><i>Library</i></html>") || title.equals("<html><i>Tools</i></html>") | |
@@ -128,24 +129,21 @@ public Component prepareRenderer( | |||
| 128 | 129 | } | |
| 129 | 130 | return c; | |
| 130 | 131 | } | |
| 132 | + | ||
| 131 | 133 | @Override | |
| 132 | 134 | public void changeSelection(int rowIndex, int columnIndex, | |
| 133 | 135 | boolean toggle, boolean extend) { | |
| 134 | 136 | 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>")){ | ||
| 137 | 141 | return; | |
| 138 | 142 | } | |
| 139 | 143 | super.changeSelection(rowIndex, columnIndex, toggle, extend); | |
| 140 | 144 | } | |
| 141 | - // @Override | ||
| 142 | - // public boolean isRowSelected(int row) { | ||
| 143 | - // if (row == 0) { | ||
| 144 | - // return false; | ||
| 145 | - // } | ||
| 146 | - // return super.isRowSelected(row); | ||
| 147 | - // } | ||
| 148 | 145 | }; | |
| 146 | + | ||
| 149 | 147 | scrollPane = new JScrollPane(table); | |
| 150 | 148 | table.setFillsViewportHeight(true); | |
| 151 | 149 | table.setSelectionBackground(new Color(0xe0fffd)); | |
@@ -160,23 +158,35 @@ public void changeSelection(int rowIndex, int columnIndex, | |||
| 160 | 158 | table.setRowSelectionAllowed(true); | |
| 161 | 159 | table.setAutoCreateColumnsFromModel(true); | |
| 162 | 160 | 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 | + | ||
| 164 | 174 | table.getTableHeader().setDefaultRenderer(new ContribHeaderRenderer() { | |
| 165 | 175 | @Override | |
| 166 | 176 | public Component getTableCellRendererComponent(JTable table, | |
| 167 | 177 | Object value, | |
| 168 | 178 | boolean isSelected, | |
| 169 | 179 | boolean hasFocus, int row, | |
| 170 | 180 | 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); | ||
| 173 | 184 | JTableHeader tableHeader = table.getTableHeader(); | |
| 174 | 185 | if (tableHeader != null) { | |
| 175 | 186 | setForeground(tableHeader.getForeground()); | |
| 176 | 187 | } | |
| 177 | 188 | setIcon(getIcon(table, column)); | |
| 178 | 189 | setBackground(new Color(0xebebeb)); | |
| 179 | - // setBorder(BorderFactory.createMatteBorder(2, 0, 2, 0, Color.BLACK)); | ||
| 180 | 190 | return this; | |
| 181 | 191 | } | |
| 182 | 192 | }); | |
@@ -224,33 +234,14 @@ public int compare(Contribution o1, Contribution o2) { | |||
| 224 | 234 | ||
| 225 | 235 | } | |
| 226 | 236 | ||
| 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 | - // | ||
| 246 | 237 | @Override | |
| 247 | 238 | 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())); | ||
| 254 | 245 | } | |
| 255 | 246 | model.getDataVector().removeAllElements(); | |
| 256 | 247 | model.fireTableDataChanged(); | |
@@ -261,16 +252,19 @@ void updatePanelOrdering(Set<Contribution> contributionsSet) { | |||
| 261 | 252 | String fontFace = "<font face=\"" + boldFont.getName() + "\">"; | |
| 262 | 253 | ||
| 263 | 254 | for (Contribution entry : contributionsSet) { | |
| 264 | - if(entry.getType() != temp){ | ||
| 255 | + if (entry.getType() != temp) { | ||
| 265 | 256 | 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 | + }); | ||
| 267 | 262 | } | |
| 268 | 263 | //TODO Make this into a function | |
| 269 | 264 | StringBuilder name = new StringBuilder(""); | |
| 270 | 265 | String authorList = entry.getAuthorList(); | |
| 271 | 266 | if (authorList != null) { | |
| 272 | 267 | for (int i = 0; i < authorList.length(); i++) { | |
| 273 | - | ||
| 274 | 268 | if (authorList.charAt(i) == '[' || authorList.charAt(i) == ']') { | |
| 275 | 269 | continue; | |
| 276 | 270 | } | |
@@ -286,37 +280,44 @@ void updatePanelOrdering(Set<Contribution> contributionsSet) { | |||
| 286 | 280 | } | |
| 287 | 281 | Icon icon = null; | |
| 288 | 282 | if (entry.isInstalled()) { | |
| 289 | - icon = Toolkit.getLibIcon("manager/up-to-date-" + ContributionManagerDialog.iconVer + "x.png"); | ||
| 283 | + icon = upToDateIcon; | ||
| 290 | 284 | if (contribListing.hasUpdates(entry)) { | |
| 291 | - icon = Toolkit.getLibIcon("manager/update-available-" + ContributionManagerDialog.iconVer + "x.png"); | ||
| 285 | + icon = updateAvailableIcon; | ||
| 292 | 286 | } | |
| 293 | 287 | if (!entry.isCompatible(Base.getRevision())) { | |
| 294 | - icon = Toolkit.getLibIcon("manager/incompatible-" + ContributionManagerDialog.iconVer + "x.png"); | ||
| 288 | + icon = incompatibleIcon; | ||
| 295 | 289 | } | |
| 296 | 290 | } | |
| 297 | 291 | 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 | + }); | ||
| 300 | 298 | } | |
| 301 | - ((UpdateStatusPanel)statusPanel).update(); | ||
| 299 | + ((UpdateStatusPanel)statusPanel).update(); | ||
| 302 | 300 | } | |
| 303 | - private class MyTableModel extends DefaultTableModel{ | ||
| 304 | - MyTableModel() { | ||
| 305 | - super(0,0); | ||
| 306 | - } | ||
| 301 | + | ||
| 302 | + | ||
| 303 | + /* | ||
| 304 | + private class MyTableModel extends DefaultTableModel { | ||
| 305 | + | ||
| 307 | 306 | @Override | |
| 308 | 307 | public boolean isCellEditable(int row, int column) { | |
| 309 | 308 | return false; | |
| 310 | 309 | } | |
| 310 | + | ||
| 311 | 311 | @Override | |
| 312 | 312 | 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); | ||
| 317 | 315 | } | |
| 318 | 316 | } | |
| 317 | + */ | ||
| 319 | 318 | } | |
| 319 | + | ||
| 320 | + | ||
| 320 | 321 | public class UpdateStatusPanel extends StatusPanel { | |
| 321 | 322 | public UpdateStatusPanel(int width, final ContributionTab contributionTab) { | |
| 322 | 323 | super(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments