Skip to content

Commit

Permalink
Revert "Revert "Temp frix for column width changing""
Browse files Browse the repository at this point in the history
This reverts commit 99f8fc1.
  • Loading branch information
Akarshit committed Aug 16, 2015
1 parent 99f8fc1 commit d4da4b8
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 42 deletions.
21 changes: 20 additions & 1 deletion app/src/processing/app/contrib/Contribution.java
Expand Up @@ -158,7 +158,7 @@ public int getVersion() {
}


// "1.0.2"
// "1.0.2" or a long string like "Build 0124 12:12:12 random"
public String getPrettyVersion() {
return prettyVersion;
}
Expand Down Expand Up @@ -321,4 +321,23 @@ static private String translateCategory(String cat) {
String cleaned = cat.replaceAll("[\\W]+", "_").toLowerCase();
return Language.text("contrib.category." + cleaned);
}

String getPrettyVersionShort() {

String latestVersion = this.getPrettyVersion();
if (latestVersion != null && !latestVersion.isEmpty()) {
if (latestVersion.endsWith("alpla")) {
return latestVersion.replaceAll("alpla", "a");
} else if (latestVersion.toLowerCase().startsWith("build")) { // For Python mode
return (latestVersion.substring(5, latestVersion.indexOf(',')).trim());
} else if (latestVersion.toLowerCase().startsWith("v")) { // For ketai library
return latestVersion.substring(1, latestVersion.length());
} else if (latestVersion.indexOf(' ') != -1) {
return latestVersion.substring(0, latestVersion.indexOf(' '));
} else {
return latestVersion;
}
} else
return null;
}
}
25 changes: 14 additions & 11 deletions app/src/processing/app/contrib/ContributionListPanel.java
Expand Up @@ -32,6 +32,8 @@
import javax.swing.event.*;
import javax.swing.table.*;

import com.sun.xml.internal.bind.v2.runtime.reflect.Lister.Pack;

import processing.app.Base;
import processing.app.Platform;
import processing.app.ui.Toolkit;
Expand All @@ -42,7 +44,7 @@
// necessary in the first place, however; seems like odd behavior.
// It also allows the description text in the panels to wrap properly.

public class ContributionListPanel extends JPanel implements Scrollable, ContributionChangeListener {
public class ContributionListPanel extends JPanel implements ContributionChangeListener {

ContributionTab contributionTab;
TreeMap<Contribution, ContributionPanel> panelByContribution;
Expand All @@ -68,6 +70,7 @@ public ContributionListPanel(final ContributionTab contributionTab,
super();
this.contributionTab = contributionTab;
this.filter = filter;


// contribListing = ContributionListing.getInstance();

Expand Down Expand Up @@ -408,7 +411,7 @@ public void run() {
newPanel.setContribution(contribution);
add(newPanel);
updatePanelOrdering(panelByContribution.keySet());
updateColors(); // XXX this is the place
// updateColors(); // XXX this is the place
}
}
}
Expand All @@ -428,7 +431,7 @@ public void run() {
}
}
updatePanelOrdering(panelByContribution.keySet());
updateColors();
// updateColors();
updateUI();
}
});
Expand Down Expand Up @@ -501,7 +504,7 @@ protected void setSelectedPanel(ContributionPanel contributionPanel) {
}
contributionPanel.setSelected(true);

updateColors();
// updateColors();
requestFocusInWindow();
}
}
Expand All @@ -512,9 +515,9 @@ protected ContributionPanel getSelectedPanel() {
}


/**
/* *//**
* Updates the colors of all library panels that are visible.
*/
*//*
protected void updateColors() {
int count = 0;
synchronized (panelByContribution) {
Expand Down Expand Up @@ -562,9 +565,9 @@ public Dimension getPreferredScrollableViewportSize() {
}
/**
*//**
* Amount to scroll to reveal a new page of items
*/
*//*
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
if (orientation == SwingConstants.VERTICAL) {
int blockAmount = visibleRect.height;
Expand All @@ -581,9 +584,9 @@ public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, i
}
/**
*//**
* Amount to scroll to reveal the rest of something we are on or a new item
*/
*//*
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
if (orientation == SwingConstants.VERTICAL) {
int lastHeight = 0, height = 0;
Expand Down Expand Up @@ -630,7 +633,7 @@ public boolean getScrollableTracksViewportHeight() {
public boolean getScrollableTracksViewportWidth() {
return true;
}

*/

public int getNoOfRows() {
return panelByContribution.size();
Expand Down
13 changes: 1 addition & 12 deletions app/src/processing/app/contrib/ContributionListing.java
Expand Up @@ -519,18 +519,7 @@ String getLatestVersion(Contribution contribution) {
if(newestContrib == null){
return null;
}
String latestVersion = newestContrib.getPrettyVersion();
if (latestVersion != null && !latestVersion.isEmpty()) {
if (latestVersion.toLowerCase().startsWith("build")) // For Python mode
return ("v" + latestVersion.substring(5, latestVersion.indexOf(','))
.trim());
else if (latestVersion.toLowerCase().startsWith("v")) // For ketai library
return latestVersion;
else
return ("v" + latestVersion);
}
else
return null;
return newestContrib.getPrettyVersionShort();
}


Expand Down
15 changes: 3 additions & 12 deletions app/src/processing/app/contrib/ContributionPanel.java
Expand Up @@ -111,8 +111,8 @@ public Contribution getContrib() {
private ActionListener undoActionListener;

boolean isUpdateInProgress;
private boolean isInstallInProgress;
private boolean isRemoveInProgress;
boolean isInstallInProgress;
boolean isRemoveInProgress;

StringBuilder description;

Expand Down Expand Up @@ -465,16 +465,7 @@ public void setContribution(Contribution contrib) {

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(contrib.getPrettyVersionShort());
description.append(" <br/>");

String authorList = contrib.getAuthorList();
Expand Down
4 changes: 2 additions & 2 deletions app/src/processing/app/contrib/ContributionTab.java
Expand Up @@ -253,7 +253,7 @@ public void itemStateChanged(ItemEvent e) {
category = null;
}
filterLibraries(category, filterField.filters);
contributionListPanel.updateColors();
// contributionListPanel.updateColors();
}
});

Expand Down Expand Up @@ -485,7 +485,7 @@ public void applyFilter() {
filters = Arrays.asList(filter.split(" "));
filterLibraries(category, filters);

contributionListPanel.updateColors();
// contributionListPanel.updateColors();
}

}
Expand Down
11 changes: 7 additions & 4 deletions app/src/processing/app/contrib/StatusPanel.java
Expand Up @@ -174,7 +174,7 @@ public void actionPerformed(ActionEvent e) {
updateButton, removeButton);

progressBarPanel.setVisible(false);
updateLabel.setVisible(false);
updateLabel.setVisible(true);

installButton.setEnabled(false);
updateButton.setEnabled(false);
Expand Down Expand Up @@ -229,7 +229,7 @@ public void update(ContributionPanel panel) {

String latestVersion = contributionListing.getLatestVersion(panel
.getContrib());
String currentVersion = panel.getContrib().getPrettyVersion();
String currentVersion = panel.getContrib().getPrettyVersionShort();

if (latestVersion != null) {
latestVersion = "Update to " + latestVersion;
Expand All @@ -238,7 +238,7 @@ public void update(ContributionPanel panel) {
}

if (currentVersion != null) {
currentVersion = "Version " + currentVersion;
currentVersion = "v" + currentVersion;
} else {
currentVersion = "";
}
Expand All @@ -261,7 +261,10 @@ public void update(ContributionPanel panel) {

removeButton.setEnabled(panel.getContrib().isInstalled());
progressBarPanel.add(panel.installProgressBar);
if (panel.installProgressBar.isEnabled()) {
updateLabel.setVisible(true);
progressBarPanel.setVisible(false);
if (panel.isUpdateInProgress || panel.isInstallInProgress || panel.isRemoveInProgress) {
System.out.println("wrong");
progressBarPanel.setVisible(true);
updateLabel.setVisible(false);
progressBarPanel.repaint();
Expand Down

0 comments on commit d4da4b8

Please sign in to comment.