mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
more with the warnings
This commit is contained in:
@@ -296,16 +296,19 @@ public class ContributionManager {
|
||||
*/
|
||||
static private void handleUpdateFailedMarkers(final AvailableContribution c) {
|
||||
File typeFolder = c.getType().getSketchbookFolder();
|
||||
|
||||
File[] folderList = typeFolder.listFiles();
|
||||
if (folderList != null) {
|
||||
for (File contribDir : folderList) {
|
||||
if (contribDir.isDirectory()) {
|
||||
File propsFile = new File(contribDir, c.getType() + ".properties");
|
||||
if (propsFile.exists()) {
|
||||
StringDict props = Util.readSettings(propsFile);
|
||||
if (c.getName().equals(props.get("name"))) {
|
||||
return;
|
||||
if (typeFolder != null) {
|
||||
File[] folderList = typeFolder.listFiles();
|
||||
if (folderList != null) {
|
||||
for (File contribDir : folderList) {
|
||||
if (contribDir.isDirectory()) {
|
||||
File propsFile = new File(contribDir, c.getType() + ".properties");
|
||||
if (propsFile.exists()) {
|
||||
StringDict props = Util.readSettings(propsFile);
|
||||
if (props != null) {
|
||||
if (c.getName().equals(props.get("name"))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -383,13 +386,10 @@ public class ContributionManager {
|
||||
|
||||
if (contribution != null) {
|
||||
try {
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listing.replaceContribution(contrib, contribution);
|
||||
base.refreshContribs(contribution.getType());
|
||||
base.setUpdatesAvailable(listing.countUpdates(base));
|
||||
}
|
||||
EventQueue.invokeAndWait(() -> {
|
||||
listing.replaceContribution(contrib, contribution);
|
||||
base.refreshContribs(contribution.getType());
|
||||
base.setUpdatesAvailable(listing.countUpdates(base));
|
||||
});
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
@@ -513,7 +513,7 @@ public class ContributionManager {
|
||||
updateFlagged(base, Base.getSketchbookModesFolder());
|
||||
updateFlagged(base, Base.getSketchbookToolsFolder());
|
||||
|
||||
SwingWorker s = new SwingWorker<Void, Void>() {
|
||||
SwingWorker<Void, Void> s = new SwingWorker<>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
@@ -539,8 +539,6 @@ public class ContributionManager {
|
||||
* Deletes the icky tmp folders that were left over from installs and updates
|
||||
* in the previous run of Processing. Needed to be called only on the tools
|
||||
* and modes sketchbook folders.
|
||||
*
|
||||
* @param root
|
||||
*/
|
||||
static private void deleteTemp(File root) {
|
||||
String pattern = root.getName().substring(0, 4) + "\\d*" + "tmp";
|
||||
@@ -558,13 +556,10 @@ public class ContributionManager {
|
||||
/**
|
||||
* Deletes all the modes/tools/libs that are flagged for removal.
|
||||
*/
|
||||
static private void deleteFlagged(File root) throws Exception {
|
||||
File[] markedForDeletion = root.listFiles(new FileFilter() {
|
||||
public boolean accept(File folder) {
|
||||
return (folder.isDirectory() &&
|
||||
LocalContribution.isDeletionFlagged(folder));
|
||||
}
|
||||
});
|
||||
static private void deleteFlagged(File root) {
|
||||
File[] markedForDeletion = root.listFiles(folder ->
|
||||
(folder.isDirectory() && LocalContribution.isDeletionFlagged(folder))
|
||||
);
|
||||
if (markedForDeletion != null) {
|
||||
for (File folder : markedForDeletion) {
|
||||
Util.removeDir(folder);
|
||||
@@ -615,9 +610,9 @@ public class ContributionManager {
|
||||
List<AvailableContribution> updateContribsList = new LinkedList<>();
|
||||
|
||||
// TODO This is bad code... This root.getName() stuff to get the folder
|
||||
// type, plus "libraries.properties" (not the correct file name).
|
||||
// Not sure the function here so I'm not fixing it at the moment,
|
||||
// but this whole function could use some cleaning. [fry 180105]
|
||||
// type, plus "libraries.properties" (not the correct file name).
|
||||
// Not sure the function here so I'm not fixing it at the moment,
|
||||
// but this whole function could use some cleaning. [fry 180105]
|
||||
|
||||
String type = root.getName().substring(root.getName().lastIndexOf('/') + 1);
|
||||
String propFileName = null;
|
||||
@@ -739,6 +734,7 @@ public class ContributionManager {
|
||||
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
|
||||
|
||||
|
||||
/*
|
||||
static int getTypeIndex(ContributionType contributionType) {
|
||||
int index;
|
||||
if (contributionType == ContributionType.LIBRARY) {
|
||||
@@ -754,4 +750,5 @@ public class ContributionManager {
|
||||
}
|
||||
return index;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.text.DateFormat;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
@@ -90,16 +89,15 @@ class DetailPanel extends JPanel {
|
||||
|
||||
private boolean alreadySelected;
|
||||
private boolean enableHyperlinks;
|
||||
//private HyperlinkListener conditionalHyperlinkOpener;
|
||||
private JTextPane descriptionPane;
|
||||
private JLabel notificationLabel;
|
||||
private JButton updateButton;
|
||||
JProgressBar installProgressBar;
|
||||
private JButton installRemoveButton;
|
||||
private JPopupMenu contextMenu;
|
||||
private JMenuItem openFolder;
|
||||
final private JPopupMenu contextMenu;
|
||||
final private JMenuItem openFolder;
|
||||
|
||||
private JPanel barButtonCardPane;
|
||||
final private JPanel barButtonCardPane;
|
||||
private CardLayout barButtonCardLayout;
|
||||
|
||||
static private final String installText = Language.text("contrib.install");
|
||||
@@ -123,12 +121,10 @@ class DetailPanel extends JPanel {
|
||||
|
||||
contextMenu = new JPopupMenu();
|
||||
openFolder = new JMenuItem("Open Folder");
|
||||
openFolder.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (contrib instanceof LocalContribution) {
|
||||
File folder = ((LocalContribution) contrib).getFolder();
|
||||
Platform.openFolder(folder);
|
||||
}
|
||||
openFolder.addActionListener(e -> {
|
||||
if (contrib instanceof LocalContribution) {
|
||||
File folder = ((LocalContribution) contrib).getFolder();
|
||||
Platform.openFolder(folder);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -175,15 +171,13 @@ class DetailPanel extends JPanel {
|
||||
|
||||
descriptionPane.setBorder(new EmptyBorder(4, 7, 7, 7));
|
||||
descriptionPane.setHighlighter(null);
|
||||
descriptionPane.addHyperlinkListener(new HyperlinkListener() {
|
||||
public void hyperlinkUpdate(HyperlinkEvent e) {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
// for 3.2.3, added the isSelected() prompt here, rather than
|
||||
// adding/removing the listener repeatedly
|
||||
if (isSelected()) {
|
||||
if (enableHyperlinks && e.getURL() != null) {
|
||||
Platform.openURL(e.getURL().toString());
|
||||
}
|
||||
descriptionPane.addHyperlinkListener(e -> {
|
||||
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
|
||||
// for 3.2.3, added the isSelected() prompt here, rather than
|
||||
// adding/removing the listener repeatedly
|
||||
if (isSelected()) {
|
||||
if (enableHyperlinks && e.getURL() != null) {
|
||||
Platform.openURL(e.getURL().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,11 +204,7 @@ class DetailPanel extends JPanel {
|
||||
updateButton.setOpaque(false);
|
||||
updateButton.setVisible(false);
|
||||
|
||||
updateButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
updateButton.addActionListener(e -> update());
|
||||
}
|
||||
|
||||
updateBox.add(updateButton, BorderLayout.EAST);
|
||||
@@ -253,16 +243,14 @@ class DetailPanel extends JPanel {
|
||||
|
||||
installRemoveButton = new JButton(" ");
|
||||
installRemoveButton.setInheritsPopupMenu(true);
|
||||
installRemoveButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String mode = installRemoveButton.getText();
|
||||
if (mode.equals(installText)) {
|
||||
install();
|
||||
} else if (mode.equals(removeText)) {
|
||||
remove();
|
||||
} else if (mode.equals(undoText)) {
|
||||
undo();
|
||||
}
|
||||
installRemoveButton.addActionListener(e -> {
|
||||
String mode = installRemoveButton.getText();
|
||||
if (mode.equals(installText)) {
|
||||
install();
|
||||
} else if (mode.equals(removeText)) {
|
||||
remove();
|
||||
} else if (mode.equals(undoText)) {
|
||||
undo();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -410,11 +398,16 @@ class DetailPanel extends JPanel {
|
||||
String fontFace = "<font face=\"" + boldFont.getName() + "\">";
|
||||
|
||||
StringBuilder desc = new StringBuilder();
|
||||
desc.append("<html><body>" + fontFace);
|
||||
desc.append("<html><body>");
|
||||
desc.append(fontFace);
|
||||
if (contrib.getUrl() == null) {
|
||||
desc.append(contrib.getName());
|
||||
} else {
|
||||
desc.append("<a href=\"" + contrib.getUrl() + "\">" + contrib.getName() + "</a>");
|
||||
desc.append("<a href=\"");
|
||||
desc.append(contrib.getUrl());
|
||||
desc.append("\">");
|
||||
desc.append(contrib.getName());
|
||||
desc.append("</a>");
|
||||
}
|
||||
desc.append("</font> ");
|
||||
|
||||
@@ -454,7 +447,8 @@ class DetailPanel extends JPanel {
|
||||
if (prettyVersion != null) {
|
||||
desc.append(", ");
|
||||
}
|
||||
desc.append("Last Updated on " + dateFormatter.format(lastUpdatedDate));
|
||||
desc.append("Last Updated on ");
|
||||
desc.append(dateFormatter.format(lastUpdatedDate));
|
||||
}
|
||||
|
||||
desc.append("</body></html>");
|
||||
@@ -464,10 +458,11 @@ class DetailPanel extends JPanel {
|
||||
if (contribListing.hasUpdates(contrib) && contrib.isCompatible(Base.getRevision())) {
|
||||
StringBuilder versionText = new StringBuilder();
|
||||
versionText.append("<html><body><i>");
|
||||
//noinspection StatementWithEmptyBody
|
||||
if (contrib.isUpdateFlagged() || contrib.isDeletionFlagged()) {
|
||||
// Already marked for deletion, see requiresRestart() notes below.
|
||||
// versionText.append("To finish an update, reinstall this contribution after restarting.");
|
||||
;
|
||||
|
||||
} else {
|
||||
String latestVersion = contribListing.getLatestPrettyVersion(contrib);
|
||||
if (latestVersion != null) {
|
||||
@@ -485,9 +480,7 @@ class DetailPanel extends JPanel {
|
||||
}
|
||||
|
||||
updateButton.setEnabled(true);
|
||||
if (contrib != null) {
|
||||
updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || updateInProgress);
|
||||
}
|
||||
updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || updateInProgress);
|
||||
|
||||
if (contrib.isDeletionFlagged()) {
|
||||
installRemoveButton.setText(undoText);
|
||||
@@ -667,14 +660,14 @@ class DetailPanel extends JPanel {
|
||||
* href="http://example.org/">it</a>.
|
||||
*/
|
||||
static String toHtmlLinks(String stringIn) {
|
||||
Pattern p = Pattern.compile("\\[(.*?)\\]\\((.*?)\\)");
|
||||
Pattern p = Pattern.compile("\\[(.*?)]\\((.*?)\\)");
|
||||
Matcher m = p.matcher(stringIn);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
int start = 0;
|
||||
while (m.find(start)) {
|
||||
sb.append(stringIn.substring(start, m.start()));
|
||||
sb.append(stringIn, start, m.start());
|
||||
|
||||
String text = m.group(1);
|
||||
String url = m.group(2);
|
||||
|
||||
@@ -29,7 +29,6 @@ import java.util.Map.Entry;
|
||||
import javax.swing.*;
|
||||
import javax.swing.RowSorter.SortKey;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import processing.app.Base;
|
||||
@@ -139,20 +138,19 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
table.setAutoCreateRowSorter(false);
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
|
||||
public void valueChanged(ListSelectionEvent event) {
|
||||
//TODO this executes 2 times when clicked and 1 time when traversed using arrow keys
|
||||
//Ideally this should always be true but while clearing the table something fishy is going on
|
||||
if (table.getSelectedRow() != -1) {
|
||||
setSelectedPanel(panelByContribution.get(table.getValueAt(table
|
||||
.getSelectedRow(), 0)));
|
||||
// Preventing the focus to move out of filterField after typing every character
|
||||
if (!contributionTab.filterHasFocus()) {
|
||||
table.requestFocusInWindow();
|
||||
}
|
||||
}
|
||||
table.getSelectionModel().addListSelectionListener(event -> {
|
||||
// TODO this executes 2 times when clicked and 1 time when traversed
|
||||
// using arrow keys. Ideally this should always be true but while
|
||||
// clearing the table something fishy is going on. [Akarshit 150704]
|
||||
if (table.getSelectedRow() != -1) {
|
||||
setSelectedPanel(panelByContribution.get(table.getValueAt(table
|
||||
.getSelectedRow(), 0)));
|
||||
// Preventing the focus to move out of filterField after typing every character
|
||||
if (!contributionTab.filterHasFocus()) {
|
||||
table.requestFocusInWindow();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
sorter = new TableRowSorter<>(model);
|
||||
table.setRowSorter(sorter);
|
||||
@@ -187,7 +185,8 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
return pos;
|
||||
}
|
||||
|
||||
class ContribHeaderRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
static class ContribHeaderRenderer extends DefaultTableCellRenderer {
|
||||
|
||||
public ContribHeaderRenderer() {
|
||||
setHorizontalTextPosition(LEFT);
|
||||
@@ -363,16 +362,16 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
if (sentence == null) {
|
||||
text.append("</font>");
|
||||
} else {
|
||||
int i = 0;
|
||||
for (i = 0; i < sentence.length(); i++) {
|
||||
currentWidth += fontMetrics.charWidth(sentence.charAt(i));
|
||||
int index;
|
||||
for (index = 0; index < sentence.length(); index++) {
|
||||
currentWidth += fontMetrics.charWidth(sentence.charAt(index));
|
||||
if (currentWidth >= colSize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
text.append(" | </font>").append(sentence, 0, i);
|
||||
text.append(" | </font>").append(sentence, 0, index);
|
||||
// Adding ellipses only if text doesn't fits into the column
|
||||
if(i != sentence.length()) {
|
||||
if (index != sentence.length()) {
|
||||
text.append("...");
|
||||
}
|
||||
}
|
||||
@@ -424,7 +423,7 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
}
|
||||
}
|
||||
|
||||
protected class ContributionTableModel extends AbstractTableModel {
|
||||
static class ContributionTableModel extends AbstractTableModel {
|
||||
|
||||
ContributionColumn[] columns = { ContributionColumn.STATUS, ContributionColumn.NAME, ContributionColumn.AUTHOR };
|
||||
boolean sectionsEnabled;
|
||||
@@ -468,9 +467,11 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
return ContributionListing.getInstance().allContributions.stream().skip(rowIndex).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/*
|
||||
public void setColumns(ContributionColumn[] columns) {
|
||||
this.columns = columns;
|
||||
}
|
||||
*/
|
||||
|
||||
public void enableSections(boolean enable) {
|
||||
this.sectionsEnabled = enable;
|
||||
|
||||
Reference in New Issue
Block a user