diff --git a/app/.settings/org.eclipse.jdt.core.prefs b/app/.settings/org.eclipse.jdt.core.prefs index e35336027..da7176c57 100644 --- a/app/.settings/org.eclipse.jdt.core.prefs +++ b/app/.settings/org.eclipse.jdt.core.prefs @@ -33,7 +33,7 @@ org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index ed93035df..b1b2992c3 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -275,9 +275,11 @@ public class Base { } - /** Instantiates and adds new contributed modes to the contribModes list. + /** + * Instantiates and adds new contributed modes to the contribModes list. * Checks for duplicates so the same mode isn't instantiates twice. Does not - * remove modes because modes can't be removed once they are instantiated */ + * remove modes because modes can't be removed once they are instantiated. + */ void rebuildContribModes() { if (contribModes == null) contribModes = new ArrayList(); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 6ecce1b1f..65c82726c 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -132,7 +132,7 @@ public abstract class Editor extends JFrame implements RunnerListener { // don't close the window when clicked, the app will take care // of that via the handleQuitInternal() methods // http://dev.processing.org/bugs/show_bug.cgi?id=440 - setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // When bringing a window to front, let the Base know addWindowListener(new WindowAdapter() { diff --git a/app/src/processing/app/Library.java b/app/src/processing/app/Library.java index 834ca236a..dd4b9e09d 100644 --- a/app/src/processing/app/Library.java +++ b/app/src/processing/app/Library.java @@ -37,13 +37,13 @@ public class Library extends InstalledContribution { * this might be the windows64 subfolder with the library. */ String nativeLibraryPath; - + static public final String propertiesFileName = "library.properties"; - /** - * Filter to pull out just files and none of the platform-specific + /** + * Filter to pull out just files and none of the platform-specific * directories, and to skip export.txt. As of 2.0a2, other directories are - * included, because we need things like the 'plugins' subfolder w/ video. + * included, because we need things like the 'plugins' subfolder w/ video. */ static FilenameFilter standardFilter = new FilenameFilter() { public boolean accept(File dir, String name) { @@ -82,8 +82,8 @@ public class Library extends InstalledContribution { public Library(File folder) { this(folder, null); } - - + + public Library(File folder, String groupName) { super(folder, Library.propertiesFileName); this.group = groupName; @@ -91,10 +91,10 @@ public class Library extends InstalledContribution { libraryFolder = new File(folder, "library"); examplesFolder = new File(folder, "examples"); referenceFile = new File(folder, "reference/index.html"); - + File exportSettings = new File(libraryFolder, "export.txt"); HashMap exportTable = Base.readSettings(exportSettings); - + exportList = new HashMap(); // get the list of files just in the library root @@ -192,7 +192,7 @@ public class Library extends InstalledContribution { // get the path for all .jar files in this code folder packageList = Base.packageListFromClassPath(getClassPath()); - + } @@ -268,8 +268,8 @@ public class Library extends InstalledContribution { public String getGroup() { return group; } - - + + public String getPath() { return folder.getAbsolutePath(); } @@ -350,7 +350,7 @@ public class Library extends InstalledContribution { * that doesn't specify bit depth. */ public String[] getApplicationExportList(int platform, int bits) { - String platformName = PApplet.platformNames[platform]; + String platformName = PConstants.platformNames[platform]; if (bits == 32) { String[] pieces = exportList.get(platformName + "32"); if (pieces != null) return pieces; @@ -360,8 +360,8 @@ public class Library extends InstalledContribution { } return exportList.get(platformName); } - - + + public File[] getAndroidExports() { return wrapFiles(androidExportList); } @@ -375,14 +375,14 @@ public class Library extends InstalledContribution { public boolean hasMultipleArch(int platform) { return multipleArch[platform]; } - - + + public boolean supportsArch(int platform, int bits) { // If this is a universal library, or has no natives, then we're good. if (multipleArch[platform] == false) { return true; } - return getApplicationExportList(platform, bits) != null; + return getApplicationExportList(platform, bits) != null; } @@ -415,13 +415,13 @@ public class Library extends InstalledContribution { return (new File(dir, name).isDirectory()); } }; - + public static ArrayList discover(File folder) { ArrayList libraries = new ArrayList(); discover(folder, libraries); return libraries; } - + static public void discover(File folder, ArrayList libraries) { String[] list = folder.list(junkFolderFilter); @@ -465,20 +465,20 @@ public class Library extends InstalledContribution { static protected void list(File folder, ArrayList libraries) { ArrayList librariesFolders = new ArrayList(); discover(folder, librariesFolders); - + for (File baseFolder : librariesFolders) { libraries.add(new Library(baseFolder)); } - + String[] list = folder.list(junkFolderFilter); if (list != null) { for (String subfolderName : list) { File subfolder = new File(folder, subfolderName); - + if (!libraries.contains(subfolder)) { ArrayList discoveredLibFolders = new ArrayList(); discover(subfolder, discoveredLibFolders); - + for (File discoveredFolder : discoveredLibFolders) { libraries.add(new Library(discoveredFolder, subfolderName)); } @@ -486,7 +486,7 @@ public class Library extends InstalledContribution { } } } - + public Type getType() { return Type.LIBRARY; } diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 9420d6a9d..578ab1c76 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -37,9 +37,9 @@ import processing.app.Library; import processing.app.contrib.ContributionListing.Filter; public class ContributionManagerDialog { - + static final String ANY_CATEGORY = "All"; - + JFrame dialog; String title; Filter permaFilter; @@ -48,53 +48,53 @@ public class ContributionManagerDialog { ContributionListPanel contributionListPanel; StatusPanel statusBar; FilterField filterField; - + // the calling editor, so updates can be applied Editor editor; String category; ContributionListing contribListing; - - + + public ContributionManagerDialog(String title, ContributionListing.Filter filter) { - + this.title = title; this.permaFilter = filter; - + contribListing = ContributionListing.getInstance(); - + contributionListPanel = new ContributionListPanel(this, filter); contribListing.addContributionListener(contributionListPanel); } - - + + public boolean hasUpdates() { return contribListing.hasUpdates(); } - - + + public void showFrame(Editor editor) { this.editor = editor; - + if (dialog == null) { dialog = new JFrame(title); - + Base.setIcon(dialog); - + createComponents(); - + registerDisposeListeners(); - + dialog.pack(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setLocation((screen.width - dialog.getWidth()) / 2, (screen.height - dialog.getHeight()) / 2); - + contributionListPanel.grabFocus(); } - + dialog.setVisible(true); - + if (!contribListing.hasDownloadedLatestList()) { contribListing.getAdvertisedContributions(new AbstractProgressMonitor() { public void startTask(String name, int maxValue) { @@ -106,7 +106,7 @@ public class ContributionManagerDialog { updateContributionListing(); updateCategoryChooser(); if (isError()) { - statusBar.setErrorMessage("An error occured when downloading " + + statusBar.setErrorMessage("An error occured when downloading " + "the list of available contributions."); } else { statusBar.updateUI(); @@ -114,10 +114,10 @@ public class ContributionManagerDialog { } }); } - + updateContributionListing(); } - + /** * Close the window after an OK or Cancel. */ @@ -125,30 +125,30 @@ public class ContributionManagerDialog { dialog.dispose(); editor = null; } - + /** Creates and arranges the Swing components in the dialog. */ private void createComponents() { dialog.setResizable(true); - + Container pane = dialog.getContentPane(); pane.setLayout(new GridBagLayout()); - + { // Shows "Filter by Category" and the combo box for selecting a category GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; - + JPanel categorySelector = new JPanel(); categorySelector.setLayout(new BoxLayout(categorySelector, BoxLayout.X_AXIS)); pane.add(categorySelector, c); - + categorySelector.add(Box.createHorizontalStrut(6)); JLabel categoryLabel = new JLabel("Filter by Category:"); categorySelector.add(categoryLabel); - + categorySelector.add(Box.createHorizontalStrut(5)); - + categoryChooser = new JComboBox(); categoryChooser.setMaximumRowCount(20); updateCategoryChooser(); @@ -165,7 +165,7 @@ public class ContributionManagerDialog { } }); } - + { // The scroll area containing the contribution listing and the status bar. GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; @@ -174,43 +174,43 @@ public class ContributionManagerDialog { c.gridwidth = 2; c.weighty = 1; c.weightx = 1; - + scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(300, 300)); scrollPane.setViewportView(contributionListPanel); scrollPane.getViewport().setOpaque(true); scrollPane.getViewport().setBackground(contributionListPanel.getBackground()); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); - scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + statusBar = new StatusPanel(); statusBar.setBorder(BorderFactory.createEtchedBorder()); - + final JLayeredPane layeredPane = new JLayeredPane(); layeredPane.add(scrollPane, JLayeredPane.DEFAULT_LAYER); layeredPane.add(statusBar, JLayeredPane.PALETTE_LAYER); - + layeredPane.addComponentListener(new ComponentAdapter() { - + void resizeLayers() { scrollPane.setSize(layeredPane.getSize()); scrollPane.updateUI(); } - + public void componentShown(ComponentEvent e) { resizeLayers(); } - + public void componentResized(ComponentEvent arg0) { resizeLayers(); } }); - + final JViewport viewport = scrollPane.getViewport(); viewport.addComponentListener(new ComponentAdapter() { void resizeLayers() { statusBar.setLocation(0, viewport.getHeight() - 18); - + Dimension d = viewport.getSize(); d.height = 20; d.width += 3; @@ -223,10 +223,10 @@ public class ContributionManagerDialog { resizeLayers(); } }); - + pane.add(layeredPane, c); } - + { // The filter text area GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; @@ -238,14 +238,14 @@ public class ContributionManagerDialog { pane.add(filterField, c); } - + dialog.setMinimumSize(new Dimension(450, 400)); } private void updateCategoryChooser() { if (categoryChooser == null) return; - + ArrayList categories; categoryChooser.removeAllItems(); categories = new ArrayList(contribListing.getCategories(permaFilter)); @@ -268,9 +268,9 @@ public class ContributionManagerDialog { } }; Base.registerWindowCloseKeys(dialog.getRootPane(), disposer); - + // handle window closing commands for ctrl/cmd-W or hitting ESC. - + dialog.getContentPane().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { //System.out.println(e); @@ -308,15 +308,15 @@ public class ContributionManagerDialog { } } } - + ArrayList contributions = new ArrayList(); contributions.addAll(editor.contribTools); contributions.addAll(libraries); contributions.addAll(compilations); - + contribListing.updateInstalledList(contributions); } - + public void setFilterText(String filter) { if (filter == null || filter.isEmpty()) { filterField.setText(""); @@ -326,72 +326,72 @@ public class ContributionManagerDialog { filterField.isShowingHint = false; } filterField.applyFilter(); - + } - + class FilterField extends JTextField { - + final static String filterHint = "Filter your search..."; boolean isShowingHint; - + List filters; - + public FilterField () { super(filterHint); - + isShowingHint = true; - + filters = new ArrayList(); - + updateStyle(); - + addFocusListener(new FocusListener() { - + public void focusLost(FocusEvent focusEvent) { if (filterField.getText().isEmpty()) { isShowingHint = true; } - + updateStyle(); } - + public void focusGained(FocusEvent focusEvent) { if (isShowingHint) { isShowingHint = false; filterField.setText(""); } - + updateStyle(); } }); - + getDocument().addDocumentListener(new DocumentListener() { - + public void removeUpdate(DocumentEvent e) { applyFilter(); } - + public void insertUpdate(DocumentEvent e) { applyFilter(); } - + public void changedUpdate(DocumentEvent e) { applyFilter(); } }); } - + public void applyFilter() { String filter = filterField.getFilterText(); filter = filter.toLowerCase(); - + // Replace anything but 0-9, a-z, or : with a space filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " "); filters = Arrays.asList(filter.split(" ")); filterLibraries(category, filters); } - + public String getFilterText() { return isShowingHint ? "" : getText(); } @@ -399,7 +399,7 @@ public class ContributionManagerDialog { public void updateStyle() { if (isShowingHint) { setText(filterHint); - + // setForeground(UIManager.getColor("TextField.light")); // too light setForeground(Color.gray); setFont(getFont().deriveFont(Font.ITALIC)); @@ -413,27 +413,27 @@ public class ContributionManagerDialog { public boolean hasAlreadyBeenOpened() { return dialog != null; } - + class StatusPanel extends JPanel implements ErrorWidget { - + String errorMessage; - + StatusPanel() { addMouseListener(new MouseAdapter() { - + public void mousePressed(MouseEvent e) { clearErrorMessage(); } }); } - + @Override protected void paintComponent(Graphics g) { super.paintComponent(g); - + g.setFont(new Font("SansSerif", Font.PLAIN, 10)); int baseline = (getSize().height + g.getFontMetrics().getAscent()) / 2; - + if (contribListing.isDownloadingListing()) { g.setColor(Color.black); g.drawString("Downloading software listing...", 2, baseline); @@ -446,11 +446,11 @@ public class ContributionManagerDialog { setVisible(false); } } - + public void setErrorMessage(String message) { errorMessage = message; setVisible(true); - + JPanel placeholder = ContributionManagerDialog.this.contributionListPanel.statusPlaceholder; Dimension d = getPreferredSize(); if (Base.isWindows()) { @@ -458,42 +458,42 @@ public class ContributionManagerDialog { placeholder.setPreferredSize(d); } placeholder.setVisible(true); - + // Rectangle rect = scrollPane.getViewport().getViewRect(); // rect.x += d.height; // scrollPane.getViewport().scrollRectToVisible(rect); } - + void clearErrorMessage() { errorMessage = null; repaint(); - + ContributionManagerDialog.this.contributionListPanel.statusPlaceholder .setVisible(false); } } - + } abstract class JProgressMonitor extends AbstractProgressMonitor { JProgressBar progressBar; - + public JProgressMonitor(JProgressBar progressBar) { this.progressBar = progressBar; } - + public void startTask(String name, int maxValue) { isFinished = false; progressBar.setString(name); progressBar.setIndeterminate(maxValue == UNKNOWN); progressBar.setMaximum(maxValue); } - + public void setProgress(int value) { super.setProgress(value); progressBar.setValue(value); } - + @Override public void finished() { super.finished(); @@ -501,5 +501,5 @@ abstract class JProgressMonitor extends AbstractProgressMonitor { } public abstract void finishedAction(); - + } \ No newline at end of file diff --git a/app/src/processing/app/contrib/InstalledContribution.java b/app/src/processing/app/contrib/InstalledContribution.java index 20a9d4d53..f4566f367 100644 --- a/app/src/processing/app/contrib/InstalledContribution.java +++ b/app/src/processing/app/contrib/InstalledContribution.java @@ -23,7 +23,10 @@ package processing.app.contrib; import java.io.File; +import java.io.IOException; import java.util.*; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; import processing.app.*; @@ -39,15 +42,15 @@ public abstract class InstalledContribution implements Contribution { protected int version; // 102 protected int latestVersion; // 103 protected String prettyVersion; // "1.0.2" - + protected File folder; protected HashMap properties; - + public InstalledContribution(File folder, String propertiesFileName) { - + this.folder = folder; - + File propertiesFile = new File(folder, propertiesFileName); properties = Base.readSettings(propertiesFile); @@ -71,53 +74,83 @@ public abstract class InstalledContribution implements Contribution { } prettyVersion = properties.get("prettyVersion"); } - + public File getFolder() { return folder; } - + public boolean isInstalled() { return folder != null; } - + public String getCategory() { return category; } - + public String getName() { return name; } - + public String getId() { return id; } - + public String getAuthorList() { return authorList; } - + public String getUrl() { return url; } - + public String getSentence() { return sentence; } - + public String getParagraph() { return paragraph; } - + public int getVersion() { return version; } - + public int getLatestVersion() { return latestVersion; } - + public String getPrettyVersion() { return prettyVersion; } - + + static protected String findClassInZipFile(String base, File file) { + // Class file to search for + String classFileName = "/" + base + ".class"; + + try { + ZipFile zipFile = new ZipFile(file); + Enumeration entries = zipFile.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + + if (!entry.isDirectory()) { + String name = entry.getName(); + //System.out.println("entry: " + name); + + if (name.endsWith(classFileName)) { + //int slash = name.lastIndexOf('/'); + //String packageName = (slash == -1) ? "" : name.substring(0, slash); + // Remove .class and convert slashes to periods. + zipFile.close(); + return name.substring(0, name.length() - 6).replace('/', '.'); + } + } + } + zipFile.close(); + } catch (IOException e) { + //System.err.println("Ignoring " + filename + " (" + e.getMessage() + ")"); + e.printStackTrace(); + } + return null; + } } diff --git a/app/src/processing/app/contrib/ModeContribution.java b/app/src/processing/app/contrib/ModeContribution.java index c98ef07cf..00c585b49 100644 --- a/app/src/processing/app/contrib/ModeContribution.java +++ b/app/src/processing/app/contrib/ModeContribution.java @@ -35,22 +35,19 @@ import processing.app.Base; import processing.app.Mode; public class ModeContribution extends InstalledContribution { + static final String propertiesFileName = "mode.properties"; private URLClassLoader loader; - private String className; - Base base; - Mode mode; - static String propertiesFileName = "mode.properties"; - static public Mode getCoreMode(Base base, String classname, File folder) { + static public Mode getCoreMode(Base base, String className, File folder) { try { - Class c = Class.forName(classname); - Constructor cc; - cc = c.getConstructor(Base.class, File.class); + Class c = Thread.currentThread().getContextClassLoader().loadClass(className); +// Class c = Class.forName(classname); + Constructor cc = c.getConstructor(Base.class, File.class); return (Mode) cc.newInstance(base, folder); } catch (Exception e) { e.printStackTrace(); @@ -58,17 +55,15 @@ public class ModeContribution extends InstalledContribution { return null; } + static public ModeContribution getContributedMode(Base base, File folder) { ModeContribution mode = new ModeContribution(base, folder); - if (mode.isValid()) - return mode; - - return null; + return mode.isValid() ? mode : null; } + private ModeContribution(Base base, File folder) { super(folder, ModeContribution.propertiesFileName); - this.base = base; File modeDirectory = new File(folder, "mode"); @@ -81,30 +76,30 @@ public class ModeContribution extends InstalledContribution { } }); - if (archives == null || archives.length == 0) - return; - - try { - URL[] urlList = new URL[archives.length]; - for (int j = 0; j < urlList.length; j++) { + if (archives != null && archives.length > 0) { + try { + URL[] urlList = new URL[archives.length]; + for (int j = 0; j < urlList.length; j++) { urlList[j] = archives[j].toURI().toURL(); - } - loader = new URLClassLoader(urlList); + } + loader = new URLClassLoader(urlList); - for (int j = 0; j < archives.length; j++) { - className = ToolContribution.findClassInZipFile( folder.getName(), - archives[j] ); - if (className != null) break; + for (int j = 0; j < archives.length; j++) { + className = findClassInZipFile(folder.getName(), archives[j]); + if (className != null) break; + } + } catch (MalformedURLException e) { + // Maybe log this } - } catch (MalformedURLException e) { - // Maybe log this } } + private boolean isValid() { return className != null; } + /** * Creates an instance of the Mode object. Warning: this makes it impossible * (on Windows) to move the files in the mode's classpath without restarting @@ -124,43 +119,50 @@ public class ModeContribution extends InstalledContribution { return false; } + public Mode getMode() { return mode; } + public Type getType() { return Type.MODE; } - public boolean equals(Object o) { - if (o == null || o instanceof ModeContribution) - return false; + public boolean equals(Object o) { + if (o == null || o instanceof ModeContribution) { + return false; + } ModeContribution other = (ModeContribution) o; return loader.equals(other.loader) && className.equals(other.className); } + static public ArrayList list(Base base, File folder) { ArrayList modes = new ArrayList(); ArrayList modeFolders = discover(folder); for (File potentialModeFolder : modeFolders) { + System.out.println("getting mode from " + potentialModeFolder); ModeContribution contrib = getContributedMode(base, potentialModeFolder); if (contrib != null) { + System.out.println("adding mode " + contrib); modes.add(contrib); } } return modes; } + static protected ArrayList discover(File folder) { ArrayList modeFolders = new ArrayList(); discover(folder, modeFolders); return modeFolders; } - static protected void discover(File folder, ArrayList modeFolders) { + static protected void discover(File folder, ArrayList modeFolders) { File[] folders = folder.listFiles(new FileFilter() { public boolean accept(File potentialModeFolder) { if (!potentialModeFolder.isDirectory()) return false; @@ -168,13 +170,10 @@ public class ModeContribution extends InstalledContribution { } }); - if (folders == null || folders.length == 0) { - return; - } - - for (File potentialModeFolder : folders) { - modeFolders.add(potentialModeFolder); + if (folders != null && folders.length > 0) { + for (File potentialModeFolder : folders) { + modeFolders.add(potentialModeFolder); + } } } - } diff --git a/app/src/processing/app/contrib/ToolContribution.java b/app/src/processing/app/contrib/ToolContribution.java index 62e63868c..907413831 100644 --- a/app/src/processing/app/contrib/ToolContribution.java +++ b/app/src/processing/app/contrib/ToolContribution.java @@ -25,7 +25,6 @@ package processing.app.contrib; import java.io.*; import java.net.*; import java.util.*; -import java.util.zip.*; import processing.app.Editor; import processing.app.tools.Tool; @@ -38,7 +37,7 @@ public class ToolContribution extends InstalledContribution implements Tool { URLClassLoader loader; Tool tool; - + static String propertiesFileName = "tool.properties"; static public ToolContribution getTool(File folder) { @@ -104,6 +103,7 @@ public class ToolContribution extends InstalledContribution implements Tool { */ } + /** * @return true if a Tool class of the expected name was found in this tool's * classpath @@ -112,6 +112,7 @@ public class ToolContribution extends InstalledContribution implements Tool { return className != null; } + /** * Loads the tool, making it impossible (on Windows) to move the files in the * classpath without restarting the PDE. @@ -121,36 +122,6 @@ public class ToolContribution extends InstalledContribution implements Tool { tool = (Tool) toolClass.newInstance(); } - static protected String findClassInZipFile(String base, File file) { - // Class file to search for - String classFileName = "/" + base + ".class"; - - try { - ZipFile zipFile = new ZipFile(file); - Enumeration entries = zipFile.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = (ZipEntry) entries.nextElement(); - - if (!entry.isDirectory()) { - String name = entry.getName(); - //System.out.println("entry: " + name); - - if (name.endsWith(classFileName)) { - //int slash = name.lastIndexOf('/'); - //String packageName = (slash == -1) ? "" : name.substring(0, slash); - // Remove .class and convert slashes to periods. - zipFile.close(); - return name.substring(0, name.length() - 6).replace('/', '.'); - } - } - } - zipFile.close(); - } catch (IOException e) { - //System.err.println("Ignoring " + filename + " (" + e.getMessage() + ")"); - e.printStackTrace(); - } - return null; - } /** * Searches and returns a list of tools found in the immediate children of the @@ -180,14 +151,15 @@ public class ToolContribution extends InstalledContribution implements Tool { return tools; } + static protected ArrayList discover(File folder) { ArrayList tools = new ArrayList(); discover(folder, tools); return tools; } - - static protected void discover(File folder, ArrayList toolFolders) { + + static protected void discover(File folder, ArrayList toolFolders) { File[] folders = folder.listFiles(new FileFilter() { public boolean accept(File folder) { if (folder.isDirectory()) { @@ -212,7 +184,7 @@ public class ToolContribution extends InstalledContribution implements Tool { if (folders != null) { for (int i = 0; i < folders.length; i++) { Tool tool = ToolContribution.getTool(folders[i]); - + if (tool != null) toolFolders.add(folders[i]); } diff --git a/app/src/processing/app/syntax/DefaultInputHandler.java b/app/src/processing/app/syntax/DefaultInputHandler.java index 7fdbe9076..93cf7d3de 100644 --- a/app/src/processing/app/syntax/DefaultInputHandler.java +++ b/app/src/processing/app/syntax/DefaultInputHandler.java @@ -162,7 +162,7 @@ public class DefaultInputHandler extends InputHandler // don't get command-s or other menu key equivs on mac // unless it's something that's specifically bound (cmd-left or right) //if ((modifiers & KeyEvent.META_MASK) != 0) return; - if ((modifiers & KeyEvent.META_MASK) != 0) { + if ((modifiers & InputEvent.META_MASK) != 0) { KeyStroke keyStroke = KeyStroke.getKeyStroke(keyCode, modifiers); if (currentBindings.get(keyStroke) == null) { return; @@ -177,7 +177,7 @@ public class DefaultInputHandler extends InputHandler KeyEvent.VK_META); */ - if((modifiers & ~KeyEvent.SHIFT_MASK) != 0 + if((modifiers & ~InputEvent.SHIFT_MASK) != 0 || evt.isActionKey() || keyCode == KeyEvent.VK_BACK_SPACE || keyCode == KeyEvent.VK_DELETE @@ -242,11 +242,11 @@ public class DefaultInputHandler extends InputHandler // this is the apple/cmd key on macosx.. so menu commands // were being passed through as legit keys.. added this line // in an attempt to prevent. - if ((modifiers & KeyEvent.META_MASK) != 0) return; + if ((modifiers & InputEvent.META_MASK) != 0) return; // Prevent CTRL-/ from going through as a typed '/' character // http://code.google.com/p/processing/issues/detail?id=596 - if ((modifiers & KeyEvent.CTRL_MASK) != 0 && c == '/') return; + if ((modifiers & InputEvent.CTRL_MASK) != 0 && c == '/') return; if (c != KeyEvent.CHAR_UNDEFINED) // && // (modifiers & KeyEvent.ALT_MASK) == 0) diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index e21c539e5..7b4d10cc5 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -106,8 +106,8 @@ public class JEditTextArea extends JComponent // Initialize the GUI setLayout(new ScrollLayout()); add(CENTER, painter); - add(RIGHT, vertical = new JScrollBar(JScrollBar.VERTICAL)); - add(BOTTOM, horizontal = new JScrollBar(JScrollBar.HORIZONTAL)); + add(RIGHT, vertical = new JScrollBar(Adjustable.VERTICAL)); + add(BOTTOM, horizontal = new JScrollBar(Adjustable.HORIZONTAL)); // Add some event listeners vertical.addAdjustmentListener(new AdjustHandler()); diff --git a/app/src/processing/app/syntax/im/CompositionTextManager.java b/app/src/processing/app/syntax/im/CompositionTextManager.java index ba9ee155f..7192e9537 100644 --- a/app/src/processing/app/syntax/im/CompositionTextManager.java +++ b/app/src/processing/app/syntax/im/CompositionTextManager.java @@ -10,6 +10,7 @@ import java.awt.font.TextAttribute; import java.awt.font.TextLayout; import java.text.AttributedCharacterIterator; import java.text.AttributedString; +import java.text.CharacterIterator; import javax.swing.text.BadLocationException; @@ -17,15 +18,15 @@ import processing.app.syntax.JEditTextArea; import processing.app.syntax.TextAreaPainter; /** - * This class Manage texts from input method + * This class Manage texts from input method * by begin-process-end steps. - * - * First, if a user start inputing via input method, + * + * First, if a user start inputing via input method, * beginCompositionText is called from InputMethodSupport. * Second, the user continues from input method, processCompositionText is called * and reflect user inputs to text area. * Finally the user try to commit text, endCompositionText is called. - * + * * @author Takashi Maekawa (takachin@generative.info) */ @@ -36,7 +37,7 @@ public class CompositionTextManager { private boolean isInputProcess; private int initialCaretPosition; public static final int COMPOSING_UNDERBAR_HEIGHT = 5; - + /** * Create text manager class with a textarea. * @param textArea texarea component for PDE. @@ -70,9 +71,9 @@ public class CompositionTextManager { /** * Called when a user begins input from input method. * This method initializes text manager. - * + * * @param text Text from InputMethodEvent. - * @param commited_count Numbers of committed characters in text. + * @param commited_count Numbers of committed characters in text. */ public void beginCompositionText(AttributedCharacterIterator text, int committed_count) { isInputProcess = true; @@ -84,9 +85,9 @@ public class CompositionTextManager { /** * Called when a user processing input characters and * select candidates from input method. - * + * * @param text Text from InputMethodEvent. - * @param commited_count Numbers of committed characters in text. + * @param commited_count Numbers of committed characters in text. */ public void processCompositionText(AttributedCharacterIterator text, int committed_count) { int layoutCaretPosition = initialCaretPosition + committed_count; @@ -95,7 +96,7 @@ public class CompositionTextManager { int textLength = text.getEndIndex() - text.getBeginIndex() - committed_count; StringBuffer unCommitedStringBuf = new StringBuffer(textLength); char c; - for (c = text.setIndex(committed_count); c != AttributedCharacterIterator.DONE + for (c = text.setIndex(committed_count); c != CharacterIterator.DONE && textLength > 0; c = text.next(), --textLength) { unCommitedStringBuf.append(c); } @@ -120,16 +121,16 @@ public class CompositionTextManager { } /** - * Called when a user fixed text from input method or delete all + * Called when a user fixed text from input method or delete all * composition text. This method resets CompositionTextPainter. - * + * * @param text Text from InputMethodEvent. - * @param commited_count Numbers of committed characters in text. + * @param commited_count Numbers of committed characters in text. */ public void endCompositionText(AttributedCharacterIterator text, int committed_count) { /* * If there are no committed characters, remove it all from textarea. - * This case will happen if a user delete all composing characters by backspace or delete key. + * This case will happen if a user delete all composing characters by backspace or delete key. * If it does, these previous characters are needed to be deleted. */ if(committed_count == 0){ diff --git a/app/src/processing/mode/android/Permissions.java b/app/src/processing/mode/android/Permissions.java index 50dde6fff..11b6128e0 100644 --- a/app/src/processing/mode/android/Permissions.java +++ b/app/src/processing/mode/android/Permissions.java @@ -36,7 +36,7 @@ import processing.app.Sketch; public class Permissions extends JFrame { - static final String GUIDE_URL = + static final String GUIDE_URL = "http://developer.android.com/guide/topics/security/security.html#permissions"; static final int BORDER_HORIZ = 5; @@ -50,14 +50,14 @@ public class Permissions extends JFrame { // Editor editor; Sketch sketch; - + public Permissions(Sketch sketch) { //public Permissions(Editor editor) { super("Android Permissions Selector"); this.sketch = sketch; // this.editor = editor; -// XMLElement xml = +// XMLElement xml = permissionList = new CheckBoxList(); // permissionList.addMouseListener(new MouseAdapter() { @@ -74,7 +74,7 @@ public class Permissions extends JFrame { // } // }); -// ListSelectionModel lsm = permissionList.getSelectionModel(); +// ListSelectionModel lsm = permissionList.getSelectionModel(); // lsm.addListSelectionListener(new ListSelectionListener() { // public void valueChanged(ListSelectionEvent e) { //// ListSelectionModel lsm = (ListSelectionModel) e.getSource(); @@ -105,7 +105,7 @@ public class Permissions extends JFrame { // int h = permissionList.getFixedCellHeight(); // permissionList.setFixedCellHeight(h + 8); permissionList.setFixedCellHeight(20); - permissionList.setBorder(new EmptyBorder(BORDER_VERT, BORDER_HORIZ, + permissionList.setBorder(new EmptyBorder(BORDER_VERT, BORDER_HORIZ, BORDER_VERT, BORDER_HORIZ)); DefaultListModel model = new DefaultListModel(); @@ -114,8 +114,8 @@ public class Permissions extends JFrame { model.addElement(new JCheckBox(item)); } - permissionScroller = - new JScrollPane(permissionList, + permissionScroller = + new JScrollPane(permissionList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // permissionList.setVisibleRowCount(20); @@ -126,7 +126,7 @@ public class Permissions extends JFrame { public void keyTyped(KeyEvent e) { if (e.getKeyChar() == ' ') { int index = permissionList.getSelectedIndex(); - JCheckBox checkbox = + JCheckBox checkbox = (JCheckBox) permissionList.getModel().getElementAt(index); checkbox.setSelected(!checkbox.isSelected()); permissionList.repaint(); @@ -148,14 +148,14 @@ public class Permissions extends JFrame { "" + "Android applications must specifically ask for permission\n" + "to do things like connect to the internet, write a file,\n" + - "or make phone calls. When installing your application,\n" + + "or make phone calls. When installing your application,\n" + "users will be asked whether they want to allow such access.\n" + "More about permissions can be found " + "here."; // "" + // "Android applications must specifically ask for permission\n" + // "to do things like connect to the internet, write a file,\n" + -// "or make phone calls. When installing your application,\n" + +// "or make phone calls. When installing your application,\n" + // "users will be asked whether they want to allow such access.\n" + // "More about permissions can be found " + // "here."; @@ -184,7 +184,7 @@ public class Permissions extends JFrame { textarea.setAlignmentX(LEFT_ALIGNMENT); // textarea.setBorder(new EmptyBorder(13, 8, 13, 8)); - + // textarea.setBackground(null); // textarea.setBackground(Color.RED); // textarea.setEditable(false); @@ -200,7 +200,7 @@ public class Permissions extends JFrame { pain.add(permissionScroller); // pain.add(permissionList); pain.add(Box.createVerticalStrut(8)); - + // descriptionLabel = new JTextArea(4, 10); descriptionLabel = new JLabel(); // descriptionLabel = new JLabel() { @@ -215,7 +215,7 @@ public class Permissions extends JFrame { // } // }; descriptionLabel.setPreferredSize(new Dimension(400, 50)); - descriptionLabel.setVerticalAlignment(JLabel.TOP); + descriptionLabel.setVerticalAlignment(SwingConstants.TOP); descriptionLabel.setAlignmentX(LEFT_ALIGNMENT); pain.add(descriptionLabel); pain.add(Box.createVerticalStrut(8)); @@ -237,7 +237,7 @@ public class Permissions extends JFrame { // Box buttons = Box.createHorizontalBox(); buttons.setAlignmentX(LEFT_ALIGNMENT); JButton okButton = new JButton("OK"); - Dimension dim = new Dimension(Preferences.BUTTON_WIDTH, + Dimension dim = new Dimension(Preferences.BUTTON_WIDTH, okButton.getPreferredSize().height); okButton.setPreferredSize(dim); okButton.addActionListener(new ActionListener() { @@ -248,7 +248,7 @@ public class Permissions extends JFrame { } }); okButton.setEnabled(true); - + JButton cancelButton = new JButton("Cancel"); cancelButton.setPreferredSize(dim); cancelButton.addActionListener(new ActionListener() { @@ -323,8 +323,8 @@ public class Permissions extends JFrame { } return sel.toArray(new String[0]); } - - + + protected void saveSelections() { String[] sel = getSelections(); Manifest mf = new Manifest(sketch); @@ -338,7 +338,7 @@ public class Permissions extends JFrame { // public void init(Editor editor) { -// this.editor = editor; +// this.editor = editor; // } @@ -346,17 +346,17 @@ public class Permissions extends JFrame { // // parse the manifest file here and figure out what permissions are set // Manifest mf = new Manifest(editor); // setSelections(mf.getPermissions()); -// +// // // show the window and get to work // setVisible(true); // } - - + + /** * Created by inserting the HTML doc into OpenOffice, then copy and pasting - * the table into a plain text document, then adding the quotes via search + * the table into a plain text document, then adding the quotes via search * and replace. If there's a way to auto-create from aapt, that'd be better, - * but I haven't found anything yet. + * but I haven't found anything yet. */ static final String[] listing = { "ACCESS_CHECKIN_PROPERTIES", "Allows read/write access to the \"properties\" table in the checkin database, to change values that get uploaded.", @@ -474,8 +474,8 @@ public class Permissions extends JFrame { "WRITE_SMS", "Allows an application to write SMS messages.", "WRITE_SYNC_SETTINGS", "Allows applications to write the sync settings" }; - - static String[] title; + + static String[] title; static String[] description; static int count; static { @@ -490,9 +490,9 @@ public class Permissions extends JFrame { } -// Code for this CheckBoxList class found on the net, though I've lost the -// link. If you run across the original version, please let me know so that -// the original author can be credited properly. It was from a snippet +// Code for this CheckBoxList class found on the net, though I've lost the +// link. If you run across the original version, please let me know so that +// the original author can be credited properly. It was from a snippet // collection, but it seems to have been picked up so many places with others // placing their copyright on it, that I haven't been able to determine the // original author. [fry 20100216] @@ -507,7 +507,7 @@ class CheckBoxList extends JList { checkboxWidth = new JCheckBox().getPreferredSize().width; // add the amount for the inset checkboxWidth += Permissions.BORDER_HORIZ; - + addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (isEnabled()) { @@ -529,11 +529,11 @@ class CheckBoxList extends JList { }); setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } - - + + protected class CellRenderer implements ListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { JCheckBox checkbox = (JCheckBox) value; // checkbox.setBorder(new EmptyBorder(13, 5, 3, 5)); // trying again diff --git a/app/src/processing/mode/java/Compiler.java b/app/src/processing/mode/java/Compiler.java index d1ecc9cd1..1f492d7bf 100644 --- a/app/src/processing/mode/java/Compiler.java +++ b/app/src/processing/mode/java/Compiler.java @@ -698,7 +698,7 @@ public class Compiler { System.err.println("This code needs to be updated " + "for this version of Processing, " + "please read the Changes page on the Wiki."); - JavaEditor.showChanges(); + Editor.showChanges(); } diff --git a/app/src/processing/mode/java/PdeKeyListener.java b/app/src/processing/mode/java/PdeKeyListener.java index ab967bfad..4e092191f 100644 --- a/app/src/processing/mode/java/PdeKeyListener.java +++ b/app/src/processing/mode/java/PdeKeyListener.java @@ -122,7 +122,7 @@ public class PdeKeyListener { } } - if ((event.getModifiers() & KeyEvent.META_MASK) != 0) { + if ((event.getModifiers() & InputEvent.META_MASK) != 0) { //event.consume(); // does nothing return false; } @@ -136,7 +136,7 @@ public class PdeKeyListener { // } if ((code == KeyEvent.VK_UP) && - ((event.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { + ((event.getModifiers() & InputEvent.CTRL_MASK) != 0)) { // back up to the last empty line char contents[] = textarea.getText().toCharArray(); //int origIndex = textarea.getCaretPosition() - 1; @@ -163,7 +163,7 @@ public class PdeKeyListener { // if the first char, index will be -2 if (index < 0) index = 0; - if ((event.getModifiers() & KeyEvent.SHIFT_MASK) != 0) { + if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { textarea.setSelectionStart(caretIndex); textarea.setSelectionEnd(index); } else { @@ -173,7 +173,7 @@ public class PdeKeyListener { return true; } else if ((code == KeyEvent.VK_DOWN) && - ((event.getModifiers() & KeyEvent.CTRL_MASK) != 0)) { + ((event.getModifiers() & InputEvent.CTRL_MASK) != 0)) { char contents[] = textarea.getText().toCharArray(); int caretIndex = textarea.getCaretPosition(); @@ -199,7 +199,7 @@ public class PdeKeyListener { //textarea.setSelectionStart(index); //textarea.setSelectionEnd(index); - if ((event.getModifiers() & KeyEvent.SHIFT_MASK) != 0) { + if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { textarea.setSelectionStart(caretIndex); textarea.setSelectionEnd(index); } else { @@ -213,7 +213,7 @@ public class PdeKeyListener { switch (c) { case 9: // TAB - if ((event.getModifiers() & KeyEvent.SHIFT_MASK) != 0) { + if ((event.getModifiers() & InputEvent.SHIFT_MASK) != 0) { // if shift is down, the user always expects an outdent // http://code.google.com/p/processing/issues/detail?id=458 editor.handleOutdent(); @@ -417,7 +417,7 @@ public class PdeKeyListener { public boolean keyTyped(KeyEvent event) { char c = event.getKeyChar(); - if ((event.getModifiers() & KeyEvent.CTRL_MASK) != 0) { + if ((event.getModifiers() & InputEvent.CTRL_MASK) != 0) { // on linux, ctrl-comma (prefs) being passed through to the editor if (c == KeyEvent.VK_COMMA) { event.consume(); diff --git a/app/src/processing/mode/java/preproc/PdePreprocessor.java b/app/src/processing/mode/java/preproc/PdePreprocessor.java index 73566c338..0a6b5e6ee 100644 --- a/app/src/processing/mode/java/preproc/PdePreprocessor.java +++ b/app/src/processing/mode/java/preproc/PdePreprocessor.java @@ -622,7 +622,7 @@ public class PdePreprocessor { //((CommonAST)parserAST).setVerboseStringConversion( // true, parser.getTokenNames()); // (made to use the static version because of jikes 1.22 warning) - CommonAST.setVerboseStringConversion(true, parser.getTokenNames()); + BaseAST.setVerboseStringConversion(true, parser.getTokenNames()); final String className; if (mode == Mode.JAVA) { @@ -675,29 +675,29 @@ public class PdePreprocessor { // hide and which to copy to the hidden text // filter = new TokenStreamCopyingHiddenTokenFilter(lexer); - filter.hide(PdeRecognizer.SL_COMMENT); - filter.hide(PdeRecognizer.ML_COMMENT); - filter.hide(PdeRecognizer.WS); - filter.copy(PdeRecognizer.SEMI); - filter.copy(PdeRecognizer.LPAREN); - filter.copy(PdeRecognizer.RPAREN); - filter.copy(PdeRecognizer.LCURLY); - filter.copy(PdeRecognizer.RCURLY); - filter.copy(PdeRecognizer.COMMA); - filter.copy(PdeRecognizer.RBRACK); - filter.copy(PdeRecognizer.LBRACK); - filter.copy(PdeRecognizer.COLON); - filter.copy(PdeRecognizer.TRIPLE_DOT); + filter.hide(PdePartialTokenTypes.SL_COMMENT); + filter.hide(PdePartialTokenTypes.ML_COMMENT); + filter.hide(PdePartialTokenTypes.WS); + filter.copy(PdePartialTokenTypes.SEMI); + filter.copy(PdePartialTokenTypes.LPAREN); + filter.copy(PdePartialTokenTypes.RPAREN); + filter.copy(PdePartialTokenTypes.LCURLY); + filter.copy(PdePartialTokenTypes.RCURLY); + filter.copy(PdePartialTokenTypes.COMMA); + filter.copy(PdePartialTokenTypes.RBRACK); + filter.copy(PdePartialTokenTypes.LBRACK); + filter.copy(PdePartialTokenTypes.COLON); + filter.copy(PdePartialTokenTypes.TRIPLE_DOT); // Because the meanings of < and > are overloaded to support // type arguments and type parameters, we have to treat them // as copyable to hidden text (or else the following syntax, // such as (); and what not gets lost under certain circumstances) // -- jdf - filter.copy(PdeRecognizer.LT); - filter.copy(PdeRecognizer.GT); - filter.copy(PdeRecognizer.SR); - filter.copy(PdeRecognizer.BSR); + filter.copy(PdePartialTokenTypes.LT); + filter.copy(PdePartialTokenTypes.GT); + filter.copy(PdePartialTokenTypes.SR); + filter.copy(PdePartialTokenTypes.BSR); // create a parser and set what sort of AST should be generated // diff --git a/core/src/processing/core/PFont.java b/core/src/processing/core/PFont.java index da55b23b6..27281a64f 100644 --- a/core/src/processing/core/PFont.java +++ b/core/src/processing/core/PFont.java @@ -157,7 +157,7 @@ public class PFont implements PConstants { /** for subclasses that need to store metadata about the font */ - protected HashMap cacheMap; +// protected HashMap cacheMap; public PFont() { } // for subclasses diff --git a/core/todo.txt b/core/todo.txt index 78014e10a..7e79e95b3 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,5 +1,12 @@ 0211 core +_ new keyEvent methods not firing +_ http://code.google.com/p/processing/issues/detail?id=1225 + +_ remove subsetting stuff from PFont + +_ add deprecated versions of getFont, getImage, etc. + _ double check that new key and mouse events are being addressed correctly diff --git a/todo.txt b/todo.txt index 5d801c7e9..b4e08e9cd 100644 --- a/todo.txt +++ b/todo.txt @@ -2,6 +2,8 @@ X make file selectable from the OS X menubar X http://code.google.com/p/processing/issues/detail?id=1215 +_ "Processing is damaged and should be put in the trash" for 2.0b2 +_ http://code.google.com/p/processing/issues/detail?id=1226 _ running at size(7000, 4000) followed by size(100, 100) _ http://code.google.com/p/processing/issues/detail?id=1213