From d1f0fa648175b2eef175bce3f4b31e0f75da097d Mon Sep 17 00:00:00 2001 From: Akarshit Wal Date: Sun, 16 Aug 2015 12:39:14 +0530 Subject: [PATCH] Temp frix for column width changing --- .../processing/app/contrib/Contribution.java | 21 +++++++++++++++- .../app/contrib/ContributionListPanel.java | 25 +++++++++++-------- .../app/contrib/ContributionListing.java | 13 +--------- .../app/contrib/ContributionPanel.java | 15 +++-------- .../app/contrib/ContributionTab.java | 4 +-- .../processing/app/contrib/StatusPanel.java | 11 +++++--- 6 files changed, 47 insertions(+), 42 deletions(-) diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java index ddd2cf537..f251d95f0 100644 --- a/app/src/processing/app/contrib/Contribution.java +++ b/app/src/processing/app/contrib/Contribution.java @@ -158,7 +158,7 @@ abstract public class Contribution { } - // "1.0.2" + // "1.0.2" or a long string like "Build 0124 12:12:12 random" public String getPrettyVersion() { return prettyVersion; } @@ -321,4 +321,23 @@ abstract public class Contribution { 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; + } } diff --git a/app/src/processing/app/contrib/ContributionListPanel.java b/app/src/processing/app/contrib/ContributionListPanel.java index 4bacd04fc..22c7c78d7 100644 --- a/app/src/processing/app/contrib/ContributionListPanel.java +++ b/app/src/processing/app/contrib/ContributionListPanel.java @@ -32,6 +32,8 @@ import javax.swing.border.Border; 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; @@ -42,7 +44,7 @@ import processing.app.ui.Toolkit; // 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 panelByContribution; @@ -68,6 +70,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib super(); this.contributionTab = contributionTab; this.filter = filter; + // contribListing = ContributionListing.getInstance(); @@ -408,7 +411,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib newPanel.setContribution(contribution); add(newPanel); updatePanelOrdering(panelByContribution.keySet()); - updateColors(); // XXX this is the place +// updateColors(); // XXX this is the place } } } @@ -428,7 +431,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib } } updatePanelOrdering(panelByContribution.keySet()); - updateColors(); +// updateColors(); updateUI(); } }); @@ -501,7 +504,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib } contributionPanel.setSelected(true); - updateColors(); +// updateColors(); requestFocusInWindow(); } } @@ -512,9 +515,9 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib } - /** + /* *//** * Updates the colors of all library panels that are visible. - */ + *//* protected void updateColors() { int count = 0; synchronized (panelByContribution) { @@ -562,9 +565,9 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib } - /** + *//** * 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; @@ -581,9 +584,9 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib } - /** + *//** * 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; @@ -630,7 +633,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib public boolean getScrollableTracksViewportWidth() { return true; } - +*/ public int getNoOfRows() { return panelByContribution.size(); diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index f47c68d83..043da8361 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -519,18 +519,7 @@ public class ContributionListing { 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(); } diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index c6730b2c6..d4346d934 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -111,8 +111,8 @@ class ContributionPanel extends JPanel { private ActionListener undoActionListener; boolean isUpdateInProgress; - private boolean isInstallInProgress; - private boolean isRemoveInProgress; + boolean isInstallInProgress; + boolean isRemoveInProgress; StringBuilder description; @@ -465,16 +465,7 @@ class ContributionPanel extends JPanel { 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("
"); String authorList = contrib.getAuthorList(); diff --git a/app/src/processing/app/contrib/ContributionTab.java b/app/src/processing/app/contrib/ContributionTab.java index d4623b02b..92d674ba2 100644 --- a/app/src/processing/app/contrib/ContributionTab.java +++ b/app/src/processing/app/contrib/ContributionTab.java @@ -253,7 +253,7 @@ public class ContributionTab { category = null; } filterLibraries(category, filterField.filters); - contributionListPanel.updateColors(); +// contributionListPanel.updateColors(); } }); @@ -485,7 +485,7 @@ public class ContributionTab { filters = Arrays.asList(filter.split(" ")); filterLibraries(category, filters); - contributionListPanel.updateColors(); +// contributionListPanel.updateColors(); } } diff --git a/app/src/processing/app/contrib/StatusPanel.java b/app/src/processing/app/contrib/StatusPanel.java index 083e8b3bd..22df2bfef 100644 --- a/app/src/processing/app/contrib/StatusPanel.java +++ b/app/src/processing/app/contrib/StatusPanel.java @@ -174,7 +174,7 @@ class StatusPanel extends JPanel { updateButton, removeButton); progressBarPanel.setVisible(false); - updateLabel.setVisible(false); + updateLabel.setVisible(true); installButton.setEnabled(false); updateButton.setEnabled(false); @@ -229,7 +229,7 @@ class StatusPanel extends JPanel { String latestVersion = contributionListing.getLatestVersion(panel .getContrib()); - String currentVersion = panel.getContrib().getPrettyVersion(); + String currentVersion = panel.getContrib().getPrettyVersionShort(); if (latestVersion != null) { latestVersion = "Update to " + latestVersion; @@ -238,7 +238,7 @@ class StatusPanel extends JPanel { } if (currentVersion != null) { - currentVersion = "Version " + currentVersion; + currentVersion = "v" + currentVersion; } else { currentVersion = ""; } @@ -261,7 +261,10 @@ class StatusPanel extends JPanel { 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();