mirror of
https://github.com/processing/processing4.git
synced 2026-02-15 03:15:40 +01:00
cleaning up dead code and warnings
This commit is contained in:
@@ -28,8 +28,6 @@ import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
@@ -65,6 +63,7 @@ import processing.app.contrib.Contribution;
|
||||
import processing.app.contrib.ContributionManager;
|
||||
import processing.app.contrib.ContributionType;
|
||||
import processing.app.contrib.ExamplesContribution;
|
||||
|
||||
import processing.core.PApplet;
|
||||
import processing.data.StringDict;
|
||||
|
||||
@@ -85,11 +84,7 @@ public class ExamplesFrame extends JFrame {
|
||||
examplesContribFolder = Base.getSketchbookExamplesFolder();
|
||||
|
||||
Toolkit.setIcon(this);
|
||||
Toolkit.registerWindowCloseKeys(getRootPane(), new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setVisible(false);
|
||||
}
|
||||
});
|
||||
Toolkit.registerWindowCloseKeys(getRootPane(), e -> setVisible(false));
|
||||
|
||||
JPanel examplesPanel = new JPanel();
|
||||
examplesPanel.setLayout(new BorderLayout());
|
||||
@@ -104,12 +99,7 @@ public class ExamplesFrame extends JFrame {
|
||||
openExamplesManagerPanel.setBorder(BorderFactory.createCompoundBorder(lineBorder, paddingBorder));
|
||||
openExamplesManagerPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
openExamplesManagerPanel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
addExamplesButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ContributionManager.openExamples();
|
||||
}
|
||||
});
|
||||
addExamplesButton.addActionListener(e -> ContributionManager.openExamples());
|
||||
|
||||
final JTree tree = new JTree(buildTree());
|
||||
|
||||
@@ -124,7 +114,7 @@ public class ExamplesFrame extends JFrame {
|
||||
tree.setRootVisible(false);
|
||||
|
||||
// After 2.0a7, no longer expanding each of the categories at Casey's
|
||||
// request. He felt that the window was too complicated too quickly.
|
||||
// request. He felt that the window was too complicated, too quickly.
|
||||
// for (int row = tree.getRowCount()-1; row >= 0; --row) {
|
||||
// tree.expandRow(row);
|
||||
// }
|
||||
@@ -176,13 +166,9 @@ public class ExamplesFrame extends JFrame {
|
||||
});
|
||||
|
||||
tree.setBorder(new EmptyBorder(0, 5, 5, 5));
|
||||
if (Platform.isMacOS()) {
|
||||
tree.setToggleClickCount(2);
|
||||
} else {
|
||||
tree.setToggleClickCount(1);
|
||||
}
|
||||
tree.setToggleClickCount(Platform.isMacOS() ? 2 : 1);
|
||||
|
||||
// Special cell renderer that takes the UI zoom into account
|
||||
// Special cell renderer that takes the Toolkit zoom setting into account
|
||||
tree.setCellRenderer(new ZoomTreeCellRenderer());
|
||||
|
||||
JScrollPane treePane = new JScrollPane(tree);
|
||||
@@ -204,7 +190,7 @@ public class ExamplesFrame extends JFrame {
|
||||
public void setVisible() {
|
||||
// Space for the editor plus a li'l gap
|
||||
int roughWidth = getWidth() + 20;
|
||||
Point p = null;
|
||||
Point p;
|
||||
// If no window open, or the editor is at the edge of the screen
|
||||
Editor editor = base.getActiveEditor();
|
||||
if (editor == null ||
|
||||
@@ -220,13 +206,13 @@ public class ExamplesFrame extends JFrame {
|
||||
|
||||
|
||||
protected void updateExpanded(JTree tree) {
|
||||
Enumeration en = tree.getExpandedDescendants(new TreePath(tree.getModel().getRoot()));
|
||||
Enumeration<TreePath> en =
|
||||
tree.getExpandedDescendants(new TreePath(tree.getModel().getRoot()));
|
||||
//en.nextElement(); // skip the root "Examples" node
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
while (en.hasMoreElements()) {
|
||||
//System.out.println(en.nextElement());
|
||||
TreePath tp = (TreePath) en.nextElement();
|
||||
TreePath tp = en.nextElement();
|
||||
Object[] path = tp.getPath();
|
||||
for (Object o : path) {
|
||||
DefaultMutableTreeNode p = (DefaultMutableTreeNode) o;
|
||||
@@ -358,10 +344,10 @@ public class ExamplesFrame extends JFrame {
|
||||
new DefaultMutableTreeNode(Language.text("examples.contributed"));
|
||||
|
||||
try {
|
||||
File[] subfolders =
|
||||
File[] folders =
|
||||
ContributionType.EXAMPLES.listCandidates(examplesContribFolder);
|
||||
if (subfolders != null) {
|
||||
for (File sub : subfolders) {
|
||||
if (folders != null) {
|
||||
for (File sub : folders) {
|
||||
StringDict props =
|
||||
Contribution.loadProperties(sub, ContributionType.EXAMPLES);
|
||||
if (props != null) {
|
||||
@@ -371,8 +357,8 @@ public class ExamplesFrame extends JFrame {
|
||||
if (base.addSketches(subNode, sub, true)) {
|
||||
contribExamplesNode.add(subNode);
|
||||
|
||||
// TODO there has to be a simpler way of handling this along
|
||||
// with addSketches() as well [fry 150811]
|
||||
// TODO there has to be a simpler way of handling this
|
||||
// along with addSketches() as well [fry 150811]
|
||||
int exampleNodeNumber = -1;
|
||||
// The contrib may have other items besides the examples folder
|
||||
for (int i = 0; i < subNode.getChildCount(); i++) {
|
||||
@@ -388,12 +374,6 @@ public class ExamplesFrame extends JFrame {
|
||||
subNode.add((DefaultMutableTreeNode) exampleNode.getChildAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
// if (subNode.getChildCount() != 1) {
|
||||
// System.err.println("more children than expected when one is enough");
|
||||
// }
|
||||
// TreeNode exampleNode = subNode.getChildAt(0);
|
||||
// subNode.add((DefaultMutableTreeNode) exampleNode.getChildAt(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user