From 761ec1d496229839f19759e54f6e2551fff7af9f Mon Sep 17 00:00:00 2001 From: JayDusara Date: Sun, 5 Apr 2015 12:07:21 +0530 Subject: [PATCH 1/5] removing conflicts --- .../app/contrib/ContributionPanel.java | 970 +----------------- .../processing/app/syntax/JEditTextArea.java | 253 +---- core/src/processing/core/PGraphics.java | 43 - .../mode/java/pdex/JavaTextAreaPainter.java | 120 +-- 4 files changed, 54 insertions(+), 1332 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 5a2dc7a5c4..a228dcb1de 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -15,951 +15,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -<<<<<<< HEAD - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package processing.app.contrib; - -import java.awt.*; -import java.awt.event.*; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Iterator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.Date; -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; - -import processing.app.Base; -import processing.app.Editor; -import processing.app.Toolkit; -import processing.app.Language; - - -/** - * Panel that expands and gives a brief overview of a library when clicked. - */ -class ContributionPanel extends JPanel { - static public final String REMOVE_RESTART_MESSAGE = - String.format("%s", Language.text("contrib.messages.remove_restart")); - - static public final String INSTALL_RESTART_MESSAGE = - String.format("%s", Language.text("contrib.messages.install_restart")); - - static public final String UPDATE_RESTART_MESSAGE = - String.format("%s", Language.text("contrib.messages.update_restart")); - - static public final String PROGRESS_BAR_CONSTRAINT = "Install/Remove Progress Bar Panel"; - - static public final String BUTTON_CONSTRAINT = "Install/Remvoe Button Panel"; - - static public final String INCOMPATIBILITY_BLUR = "This contribution is not compatible with " - + "the current revision of Processing"; - - private final ContributionListPanel listPanel; - private final ContributionListing contribListing = ContributionListing.getInstance(); - - static private final int BUTTON_WIDTH = 100; - - /** - * Should only be set through setContribution(), - * otherwise UI components will not be updated. - */ - private Contribution contrib; - - private boolean alreadySelected; - private boolean enableHyperlinks; - private HyperlinkListener conditionalHyperlinkOpener; - private JTextPane descriptionBlock; -// private JTextPane notificationBlock; - private JLabel notificationBlock; - private JButton updateButton; - private JProgressBar installProgressBar; - private JButton installRemoveButton; - private JPopupMenu contextMenu; - private JMenuItem openFolder; - private JPanel barButtonCardPane; - -// private HashSet headerPaneSet; - private ActionListener removeActionListener; - private ActionListener installActionListener; - private ActionListener undoActionListener; - - private boolean isUpdateInProgress; - private boolean isInstallInProgress; - private boolean isRemoveInProgress; - - - ContributionPanel(ContributionListPanel contributionListPanel) { - listPanel = contributionListPanel; - barButtonCardPane = new JPanel(); -// headerPaneSet = new HashSet(); - - enableHyperlinks = false; - alreadySelected = false; - conditionalHyperlinkOpener = new HyperlinkListener() { - public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - if (enableHyperlinks) { - if (e.getURL() != null) { - Base.openURL(e.getURL().toString()); - } - } - } - } - }; - - installActionListener = new ActionListener() { - public void actionPerformed(ActionEvent e) { - listPanel.contribManager.status.clear(); - isInstallInProgress = true; - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); - if (contrib instanceof AvailableContribution) { - installContribution((AvailableContribution) contrib); - contribListing.replaceContribution(contrib, contrib); - } - } - }; - - undoActionListener = new ActionListener() { - public void actionPerformed(ActionEvent e) { - listPanel.contribManager.status.clear(); - if (contrib instanceof LocalContribution) { - LocalContribution installed = (LocalContribution) contrib; - installed.setDeletionFlag(false); - contribListing.replaceContribution(contrib, contrib); // ?? - Iterator contribsListIter = contribListing.allContributions.iterator(); - boolean toBeRestarted = false; - while (contribsListIter.hasNext()) { - Contribution contribElement = contribsListIter.next(); - if (contrib.getType().equals(contribElement.getType())) { - if (contribElement.isDeletionFlagged() || contribElement.isUpdateFlagged()) - { - toBeRestarted = !toBeRestarted; - break; - } - } - } - listPanel.contribManager.restartButton.setVisible(toBeRestarted); - } - } - }; - - removeActionListener = new ActionListener() { - public void actionPerformed(ActionEvent arg) { - listPanel.contribManager.status.clear(); - if (contrib.isInstalled() && contrib instanceof LocalContribution) { - isRemoveInProgress = true; - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); - updateButton.setEnabled(false); - installRemoveButton.setEnabled(false); - installProgressBar.setVisible(true); - installProgressBar.setIndeterminate(true); - - ((LocalContribution) contrib).removeContribution(listPanel.contribManager.editor, - new JProgressMonitor(installProgressBar) { - public void finishedAction() { - // Finished uninstalling the library - resetInstallProgressBarState(); - isRemoveInProgress = false; - installRemoveButton.setEnabled(true); - - reorganizePaneComponents(); - setSelected(true); // Needed for smooth working. Dunno why, though... - } - - public void cancel() { - super.cancel(); - resetInstallProgressBarState(); - isRemoveInProgress = false; - installRemoveButton.setEnabled(true); - - reorganizePaneComponents(); - setSelected(true); - - boolean isModeActive = false; - if (contrib.getType() == ContributionType.MODE) { - ModeContribution m = (ModeContribution) contrib; - Iterator iter = listPanel.contribManager.editor.getBase().getEditors().iterator(); - - while (iter.hasNext()) { - Editor e = iter.next(); - if (e.getMode().equals(m.getMode())) { - isModeActive = true; - break; - } - } - } - if(!isModeActive) - listPanel.contribManager.restartButton.setVisible(true); - else - updateButton.setEnabled(true); - } - }, - listPanel.contribManager.status); - } - } - }; - - 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(); - Base.openFolder(folder); - } - } - }); - - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - - addPaneComponents(); -// addProgressBarAndButton(); - - setBackground(listPanel.getBackground()); - setOpaque(true); - setSelected(false); - - setExpandListener(this, new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if (contrib.isCompatible(Base.getRevision())) - listPanel.setSelectedPanel(ContributionPanel.this); - else - listPanel.contribManager.status.setErrorMessage(contrib.getName() - + " is not compatible with this revision of Processing"); - } - }); - } - - - /** - * Create the widgets for the header panel which is visible when the - * library panel is not clicked. - */ - private void addPaneComponents() { - setLayout(new BorderLayout()); - - descriptionBlock = new JTextPane(); - descriptionBlock.setInheritsPopupMenu(true); - Insets margin = descriptionBlock.getMargin(); - margin.bottom = 0; - descriptionBlock.setMargin(margin); - descriptionBlock.setContentType("text/html"); - setTextStyle(descriptionBlock); - descriptionBlock.setOpaque(false); - if (UIManager.getLookAndFeel().getID().equals("Nimbus")) { - descriptionBlock.setBackground(new Color(0, 0, 0, 0)); - } -// stripTextSelectionListeners(descriptionBlock); - - descriptionBlock.setBorder(new EmptyBorder(4, 7, 7, 7)); - descriptionBlock.setHighlighter(null); - add(descriptionBlock, BorderLayout.CENTER); - - JPanel updateBox = new JPanel(); //new BoxLayout(filterPanel, BoxLayout.X_AXIS) - updateBox.setLayout(new BorderLayout()); - - notificationBlock = new JLabel(); - notificationBlock.setInheritsPopupMenu(true); - notificationBlock.setVisible(false); - notificationBlock.setOpaque(false); - // not needed after changing to JLabel -// notificationBlock.setContentType("text/html"); -// notificationBlock.setHighlighter(null); -// setTextStyle(notificationBlock); - notificationBlock.setFont(new Font("Verdana", Font.ITALIC, 10)); -// stripTextSelectionListeners(notificationBlock); - - updateButton = new JButton("Update"); - updateButton.setInheritsPopupMenu(true); - Dimension updateButtonDimensions = updateButton.getPreferredSize(); - updateButtonDimensions.width = BUTTON_WIDTH; - updateButton.setMinimumSize(updateButtonDimensions); - updateButton.setPreferredSize(updateButtonDimensions); - updateButton.setOpaque(false); - updateButton.setVisible(false); - updateButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - listPanel.contribManager.status.clear(); - isUpdateInProgress = true; - if (contrib.getType().requiresRestart()) { - installRemoveButton.setEnabled(false); - installProgressBar.setVisible(true); - installProgressBar.setIndeterminate(true); - - ((LocalContribution) contrib) - .removeContribution(listPanel.contribManager.editor, - new JProgressMonitor(installProgressBar) { - public void finishedAction() { - // Finished uninstalling the library - resetInstallProgressBarState(); - updateButton.setEnabled(false); - AvailableContribution ad = contribListing - .getAvailableContribution(contrib); - String url = ad.link; - installContribution(ad, url); - } - - @Override - public void cancel() { - super.cancel(); - resetInstallProgressBarState(); - listPanel.contribManager.status.setMessage(""); - isUpdateInProgress = false; - installRemoveButton.setEnabled(true); - if (contrib.isDeletionFlagged()) { - ((LocalContribution)contrib).setUpdateFlag(true); - ((LocalContribution)contrib).setDeletionFlag(false); - contribListing.replaceContribution(contrib,contrib); - } - - boolean isModeActive = false; - if (contrib.getType() == ContributionType.MODE) { - ModeContribution m = (ModeContribution) contrib; - Iterator iter = listPanel.contribManager.editor.getBase().getEditors().iterator(); - - while (iter.hasNext()) { - Editor e = iter.next(); - if (e.getMode().equals(m.getMode())) { - isModeActive = true; - break; - } - } - } - if(!isModeActive) - listPanel.contribManager.restartButton.setVisible(true); - else - updateButton.setEnabled(true); - } - - }, listPanel.contribManager.status); - } else { - updateButton.setEnabled(false); - installRemoveButton.setEnabled(false); - AvailableContribution ad = contribListing.getAvailableContribution(contrib); - String url = ad.link; - installContribution(ad, url); - } - } - }); -// add(updateButton, c); -// } - updateBox.add(updateButton, BorderLayout.EAST); - updateBox.add(notificationBlock, BorderLayout.WEST); - updateBox.setBorder(new EmptyBorder(4, 7, 7, 7)); - updateBox.setOpaque(false); - add(updateBox, BorderLayout.SOUTH); - -// } -// -// -// private void addProgressBarAndButton() { - -// Box statusBox = Box.createVerticalBox(); -// GridBagConstraints c = new GridBagConstraints(); -// c.gridx = 4; -// c.gridy = 0; -// c.weighty = 1; -// c.gridheight = 3; -// c.fill = GridBagConstraints.VERTICAL; -// c.anchor = GridBagConstraints.NORTH; - JPanel rightPane = new JPanel(); - rightPane.setInheritsPopupMenu(true); - rightPane.setOpaque(false); - rightPane.setLayout(new BoxLayout(rightPane, BoxLayout.Y_AXIS)); - rightPane.setMinimumSize(new Dimension(ContributionPanel.BUTTON_WIDTH, 1)); -// add(rightPane, c); -// statusBox.add(rightPane); - add(rightPane, BorderLayout.EAST); - - barButtonCardPane.setLayout(new CardLayout()); - barButtonCardPane.setInheritsPopupMenu(true); - barButtonCardPane.setOpaque(false); - barButtonCardPane.setMinimumSize(new Dimension(ContributionPanel.BUTTON_WIDTH, 1)); - - installProgressBar = new JProgressBar(); - installProgressBar.setInheritsPopupMenu(true); - installProgressBar.setStringPainted(true); - resetInstallProgressBarState(); - Dimension d = installProgressBar.getPreferredSize(); - d.width = ContributionPanel.BUTTON_WIDTH; - installProgressBar.setPreferredSize(d); - installProgressBar.setMaximumSize(d); - installProgressBar.setMinimumSize(d); - installProgressBar.setOpaque(false); - installProgressBar.setAlignmentX(CENTER_ALIGNMENT); - - installRemoveButton = new JButton(" "); - installRemoveButton.setInheritsPopupMenu(true); - - Dimension installButtonDimensions = installRemoveButton.getPreferredSize(); - installButtonDimensions.width = ContributionPanel.BUTTON_WIDTH; - installRemoveButton.setPreferredSize(installButtonDimensions); - installRemoveButton.setMaximumSize(installButtonDimensions); - installRemoveButton.setMinimumSize(installButtonDimensions); - installRemoveButton.setOpaque(false); - installRemoveButton.setAlignmentX(CENTER_ALIGNMENT); - - JPanel barPane = new JPanel(); - barPane.setOpaque(false); - barPane.add(installProgressBar); - - JPanel buttonPane = new JPanel(); - buttonPane.setOpaque(false); - buttonPane.add(installRemoveButton); - - barButtonCardPane.add(buttonPane, BUTTON_CONSTRAINT); - barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT); - - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); - - rightPane.add(barButtonCardPane); - - // Set the minimum size of this pane to be the sum of the height of the - // progress bar and install button - d = installProgressBar.getPreferredSize(); - Dimension d2 = installRemoveButton.getPreferredSize(); - d.width = ContributionPanel.BUTTON_WIDTH; - d.height = d2.height;//d.height+d2.height; - rightPane.setMinimumSize(d); - rightPane.setPreferredSize(d); - } - - - private void reorganizePaneComponents() { - BorderLayout layout = (BorderLayout) this.getLayout(); - remove(layout.getLayoutComponent(BorderLayout.SOUTH)); - remove(layout.getLayoutComponent(BorderLayout.EAST)); - - JPanel updateBox = new JPanel(); - updateBox.setLayout(new BorderLayout()); - updateBox.setInheritsPopupMenu(true); - updateBox.add(notificationBlock, BorderLayout.WEST); - updateBox.setBorder(new EmptyBorder(4, 7, 7, 7)); - updateBox.setOpaque(false); - add(updateBox, BorderLayout.SOUTH); - - JPanel rightPane = new JPanel(); - rightPane.setInheritsPopupMenu(true); - rightPane.setOpaque(false); - rightPane.setLayout(new BoxLayout(rightPane, BoxLayout.Y_AXIS)); - rightPane.setMinimumSize(new Dimension(ContributionPanel.BUTTON_WIDTH, 1)); - add(rightPane, BorderLayout.EAST); - - - if (updateButton.isVisible() && !isRemoveInProgress && !contrib.isDeletionFlagged()) { - JPanel updateRemovePanel = new JPanel(); - updateRemovePanel.setLayout(new FlowLayout()); - updateRemovePanel.setOpaque(false); - updateRemovePanel.add(updateButton); - updateRemovePanel.setInheritsPopupMenu(true); - updateRemovePanel.add(installRemoveButton); - updateBox.add(updateRemovePanel, BorderLayout.EAST); - - JPanel barPane = new JPanel(); - barPane.setOpaque(false); - barPane.setInheritsPopupMenu(true); - barPane.add(installProgressBar); - rightPane.add(barPane); - - if (isUpdateInProgress) - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); - - } - else { - updateBox.add(updateButton, BorderLayout.EAST); - barButtonCardPane.removeAll(); - - JPanel barPane = new JPanel(); - barPane.setOpaque(false); - barPane.setInheritsPopupMenu(true); - barPane.add(installProgressBar); - - JPanel buttonPane = new JPanel(); - buttonPane.setOpaque(false); - buttonPane.setInheritsPopupMenu(true); - buttonPane.add(installRemoveButton); - - barButtonCardPane.add(buttonPane, BUTTON_CONSTRAINT); - barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT); - if (isInstallInProgress || isRemoveInProgress || isUpdateInProgress) - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, PROGRESS_BAR_CONSTRAINT); - else - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); - - rightPane.add(barButtonCardPane); - } - - Dimension d = installProgressBar.getPreferredSize(); - Dimension d2 = installRemoveButton.getPreferredSize(); - d.width = ContributionPanel.BUTTON_WIDTH; - d.height = Math.max(d.height,d2.height); - rightPane.setMinimumSize(d); - rightPane.setPreferredSize(d); - } - - - private void setExpandListener(Component component, - MouseAdapter expandPanelMouseListener) { - component.addMouseListener(expandPanelMouseListener); - if (component instanceof Container) { - for (Component child : ((Container) component).getComponents()) { - setExpandListener(child, expandPanelMouseListener); - } - } - } - - - private void blurContributionPanel(Component component) { - component.setFocusable(false); - component.setEnabled(false); - if (component instanceof JComponent) - ((JComponent) component).setToolTipText(INCOMPATIBILITY_BLUR); - if (component instanceof Container) { - for (Component child : ((Container) component).getComponents()) { - blurContributionPanel(child); - } - } - } - - - public void setContribution(Contribution contrib) { - this.contrib = contrib; - - - if (contrib.isSpecial()) { - ImageIcon processingIcon = new ImageIcon(Toolkit.getLibImage("icons/pde-" - + "48" + ".png")); - JLabel iconLabel = new JLabel(processingIcon); - iconLabel.setBorder(new EmptyBorder(4, 7, 7, 7)); - iconLabel.setVerticalAlignment(SwingConstants.TOP); - add(iconLabel, BorderLayout.WEST); - } - -// StringBuilder nameText = new StringBuilder(); -// nameText.append(""); -// if (contrib.getUrl() == null) { -// nameText.append(contrib.getName()); -// } else { -// nameText.append("" + contrib.getName() + ""); -// } -// nameText.append(""); -// String authorList = contrib.getAuthorList(); -// if (authorList != null && !authorList.isEmpty()) { -// nameText.append(" by "); -// nameText.append(toHtmlLinks(contrib.getAuthorList())); -// } -// nameText.append(""); -// headerText.setText(nameText.toString()); -// -// StringBuilder description = new StringBuilder(); -// description.append(""); -// boolean isFlagged = contrib.isDeletionFlagged(); -// if (isFlagged) { -// description.append(ContributionListPanel.DELETION_MESSAGE); -// } else { -// String sentence = contrib.getSentence(); -// if (sentence == null || sentence.isEmpty()) { -// sentence = "Description unavailable."; -// } else { -// sentence = sanitizeHtmlTags(sentence); -// sentence = toHtmlLinks(sentence); -// } -// description.append(sentence); -// } -// description.append(""); -// descriptionText.setText(description.toString()); - - StringBuilder description = new StringBuilder(); - description.append(""); - if (contrib.getUrl() == null) { - description.append(contrib.getName()); - } else { - description.append("" + contrib.getName() + ""); - } - description.append(""); - String authorList = contrib.getAuthorList(); - if (authorList != null && !authorList.isEmpty()) { - description.append(" by "); - description.append(toHtmlLinks(contrib.getAuthorList())); - } - description.append("
"); - - //System.out.println("checking restart flag for " + contrib + " " + contrib.getName() + " and it's " + contrib.isRestartFlagged()); - if (contrib.isDeletionFlagged()) { - description.append(REMOVE_RESTART_MESSAGE); - } else if (contrib.isRestartFlagged()) { - description.append(INSTALL_RESTART_MESSAGE); - } else if (contrib.isUpdateFlagged()) { - description.append(UPDATE_RESTART_MESSAGE); - } else { - - String sentence = contrib.getSentence(); - if (sentence == null || sentence.isEmpty()) { - sentence = String.format("%s", Language.text("contrib.errors.description_unavailable")); - } else { - sentence = sanitizeHtmlTags(sentence); - sentence = toHtmlLinks(sentence); - } - description.append(sentence); - } - - String version = contrib.getPrettyVersion(); - - if (version != null && !version.isEmpty()) { - description.append("
"); - if (version.toLowerCase().startsWith("build")) // For Python mode - description.append("v" - + version.substring(5, version.indexOf(',')).trim()); - else if (version.toLowerCase().startsWith("v")) // For ketai library - description.append(version); - else - description.append("v" + version); - } - - long lastUpdatedUTC = contrib.getLastUpdated(); - if (lastUpdatedUTC != 0) { - DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM); - Date lastUpdatedDate = new Date(lastUpdatedUTC); - if (version != null && !version.isEmpty()) - description.append(", "); - description.append("Last Updated on " + dateFormatter.format(lastUpdatedDate)); - } - - description.append(""); - //descriptionText.setText(description.toString()); - descriptionBlock.setText(description.toString()); -// System.out.println(description); - - if (contribListing.hasUpdates(contrib)) { - StringBuilder versionText = new StringBuilder(); - versionText.append(""); - 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.getLatestVersion(contrib); - if (latestVersion != null) - versionText.append("New version (" + latestVersion + ") available!"); - else - versionText.append("New version available!"); -// if (contrib.getType().requiresRestart()) { -// // If a contribution can't be reinstalled in-place, the user may need -// // to remove the current version, restart Processing, then install. -// versionText.append(" To update, first remove the current version."); -// } - } - versionText.append(""); - notificationBlock.setText(versionText.toString()); - notificationBlock.setVisible(true); - } else { - notificationBlock.setText(""); - notificationBlock.setVisible(false); - } - - updateButton.setEnabled(true); - if (contrib != null) { - updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || isUpdateInProgress); - } - - installRemoveButton.removeActionListener(installActionListener); - installRemoveButton.removeActionListener(removeActionListener); - installRemoveButton.removeActionListener(undoActionListener); - - if (contrib.isDeletionFlagged()) { - installRemoveButton.addActionListener(undoActionListener); - installRemoveButton.setText(Language.text("contrib.undo")); - } else if (contrib.isInstalled()) { - installRemoveButton.addActionListener(removeActionListener); - installRemoveButton.setText(Language.text("contrib.remove")); - installRemoveButton.setVisible(true); - installRemoveButton.setEnabled(!contrib.isUpdateFlagged()); - reorganizePaneComponents(); - } else { - installRemoveButton.addActionListener(installActionListener); - installRemoveButton.setText(Language.text("contrib.install")); - } - - contextMenu.removeAll(); - - if (contrib.isInstalled()) { - contextMenu.add(openFolder); - setComponentPopupMenu(contextMenu); - } else { - setComponentPopupMenu(null); - } - - if (!contrib.isCompatible(Base.getRevision())) { - blurContributionPanel(this); - } - } - - private void installContribution(AvailableContribution info) { - if (info.link == null) { - listPanel.contribManager.status.setErrorMessage(Language.interpolate("contrib.unsupported_operating_system", info.getType())); - } else { - installContribution(info, info.link); - } - } - - - private void installContribution(AvailableContribution ad, String url) { - installRemoveButton.setEnabled(false); - - try { - URL downloadUrl = new URL(url); - installProgressBar.setVisible(true); - - JProgressMonitor downloadProgress = new JProgressMonitor(installProgressBar) { - public void finishedAction() { - // Finished downloading library - } - - public void cancel() { - // Finished installing library - resetInstallProgressBarState(); - installRemoveButton.setEnabled(!contrib.isUpdateFlagged()); - - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); - isInstallInProgress = false; - if(isUpdateInProgress) - isUpdateInProgress = !isUpdateInProgress; - updateButton.setVisible(contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged()); - setSelected(true); - } - }; - - JProgressMonitor installProgress = new JProgressMonitor(installProgressBar) { - public void finishedAction() { - // Finished installing library - resetInstallProgressBarState(); - installRemoveButton.setEnabled(!contrib.isUpdateFlagged()); - - if (isError()) { - listPanel.contribManager.status.setErrorMessage(Language.text("contrib.download_error")); - } - ((CardLayout) barButtonCardPane.getLayout()).show(barButtonCardPane, BUTTON_CONSTRAINT); - isInstallInProgress = false; - if(isUpdateInProgress) - isUpdateInProgress = !isUpdateInProgress; - updateButton.setVisible(contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged()); - setSelected(true); - } - - public void cancel() { - finishedAction(); - } - }; - - ContributionManager.downloadAndInstall(listPanel.contribManager.editor, - downloadUrl, ad, - downloadProgress, installProgress, - listPanel.contribManager.status); - - } catch (MalformedURLException e) { - Base.showWarning(Language.text("contrib.errors.install_failed"), - Language.text("contrib.errors.malformed_url"), e); - // not sure why we'd re-enable the button if it had an error... -// installRemoveButton.setEnabled(true); - } - } - - - // This doesn't actually seem to work? - /* - static void stripTextSelectionListeners(JEditorPane editorPane) { - for (MouseListener listener : editorPane.getMouseListeners()) { - String className = listener.getClass().getName(); - if (className.endsWith("MutableCaretEvent") || - className.endsWith("DragListener") || - className.endsWith("BasicCaret")) { - editorPane.removeMouseListener(listener); - } - } - } - */ - - - protected void resetInstallProgressBarState() { - installProgressBar.setString(Language.text("contrib.progress.starting")); - installProgressBar.setIndeterminate(false); - installProgressBar.setValue(0); - installProgressBar.setVisible(false); - } - - - /** - * Should be called whenever this component is selected (clicked on) - * or unselected, even if it is already selected. - */ - public void setSelected(boolean isSelected) { - // Only enable hyperlinks if this component is already selected. - // Why? Because otherwise if the user happened to click on what is - // now a hyperlink, it will be opened as the mouse is released. - enableHyperlinks = alreadySelected; - - if (contrib != null) { - updateButton.setVisible((contribListing.hasUpdates(contrib) && !contrib.isUpdateFlagged() && !contrib.isDeletionFlagged()) || isUpdateInProgress); - updateButton.setEnabled(!contribListing.hasListDownloadFailed()); - } - installRemoveButton.setVisible(isSelected() || installRemoveButton.getText().equals(Language.text("contrib.remove")) || isUpdateInProgress); - installRemoveButton.setEnabled(installRemoveButton.getText().equals(Language.text("contrib.remove")) ||!contribListing.hasListDownloadFailed()); - reorganizePaneComponents(); - -// for (JTextPane textPane : headerPaneSet) { - { -// JTextPane textPane = headerText; -// JTextPane textPane = textBlock; - JEditorPane editorPane = descriptionBlock; //textPane; - - editorPane.removeHyperlinkListener(ContributionListPanel.nullHyperlinkListener); - editorPane.removeHyperlinkListener(conditionalHyperlinkOpener); - if (isSelected()) { - editorPane.addHyperlinkListener(conditionalHyperlinkOpener); - editorPane.setEditable(false); - } else { - editorPane.addHyperlinkListener(ContributionListPanel.nullHyperlinkListener); - editorPane.setEditable(true); - } - - // Update style of hyperlinks -// setSelectionStyle(textPane, isSelected()); - setSelectionStyle(descriptionBlock, isSelected()); - } - alreadySelected = isSelected(); - } - - - public boolean isSelected() { - return listPanel.getSelectedPanel() == this; - } - - -// public void setForeground(Color fg) { -// super.setForeground(fg); -// System.out.println(contrib.getName()); -// } - -// static int inc; - - public void setForeground(Color fg) { - super.setForeground(fg); - -// PrintWriter writer = PApplet.createWriter(new File("/Users/fry/Desktop/traces/" + PApplet.nf(++inc, 4) + ".txt")); -// new Exception().printStackTrace(writer); -// writer.flush(); -// writer.close(); - -// if (headerPaneSet != null) { -// System.out.println(headerPaneSet.size()); -//// int rgb = fg.getRGB(); -// for (JTextPane pane : headerPaneSet) { -//// setForegroundStyle(pane, rgb); -// setForegroundStyle(pane, contrib.isInstalled()); -// } -// } - if (contrib != null) { - boolean installed = contrib.isInstalled(); -// setForegroundStyle(headerText, installed); -// setForegroundStyle(descriptionText, installed); - setForegroundStyle(descriptionBlock, installed, isSelected()); - } - } - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - - static String sanitizeHtmlTags(String stringIn) { - stringIn = stringIn.replaceAll("<", "<"); - stringIn = stringIn.replaceAll(">", ">"); - return stringIn; - } - - - /** - * This has a [link](http://example.com/) in [it](http://example.org/). - * - * Becomes... - * - * This has a link in it. - */ - static String toHtmlLinks(String stringIn) { - 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())); - - String text = m.group(1); - String url = m.group(2); - - sb.append(""); - sb.append(text); - sb.append(""); - - start = m.end(); - } - sb.append(stringIn.substring(start)); - return sb.toString(); - } - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - - /** - * Sets coloring based on whether installed or not; - * also makes ugly blue HTML links into the specified color (black). - */ - static void setForegroundStyle(JTextPane textPane, boolean installed, boolean selected) { - Document doc = textPane.getDocument(); - if (doc instanceof HTMLDocument) { - HTMLDocument html = (HTMLDocument) doc; - StyleSheet stylesheet = html.getStyleSheet(); - - String c = (installed && !selected) ? "#555555" : "#000000"; // slightly grayed when installed -// String c = "#000000"; // just make them both black - stylesheet.addRule("body { color:" + c + "; }"); - stylesheet.addRule("a { color:" + c + "; }"); - } - } - - - static void setTextStyle(JTextPane textPane) { - Document doc = textPane.getDocument(); - if (doc instanceof HTMLDocument) { - HTMLDocument html = (HTMLDocument) doc; - StyleSheet stylesheet = html.getStyleSheet(); - stylesheet.addRule("body { " + - " margin: 0; padding: 0;" + - " font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" + - " font-size: 100%;" + "font-size: 0.95em; " + - "}"); - } - } - - -======= You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -1053,6 +108,7 @@ class ContributionPanel extends JPanel { enableHyperlinks = false; alreadySelected = false; conditionalHyperlinkOpener = new HyperlinkListener() { + @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (enableHyperlinks) { @@ -1065,6 +121,7 @@ public void hyperlinkUpdate(HyperlinkEvent e) { }; installActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { listPanel.contribManager.status.clear(); isInstallInProgress = true; @@ -1077,6 +134,7 @@ public void actionPerformed(ActionEvent e) { }; undoActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { listPanel.contribManager.status.clear(); if (contrib instanceof LocalContribution) { @@ -1101,6 +159,7 @@ public void actionPerformed(ActionEvent e) { }; removeActionListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent arg) { listPanel.contribManager.status.clear(); if (contrib.isInstalled() && contrib instanceof LocalContribution) { @@ -1112,6 +171,7 @@ public void actionPerformed(ActionEvent arg) { installProgressBar.setIndeterminate(true); JProgressMonitor monitor = new JProgressMonitor(installProgressBar) { + @Override public void finishedAction() { // Finished uninstalling the library resetInstallProgressBarState(); @@ -1122,6 +182,7 @@ public void finishedAction() { setSelected(true); // Needed for smooth working. Dunno why, though... } + @Override public void cancel() { super.cancel(); resetInstallProgressBarState(); @@ -1163,6 +224,7 @@ public void cancel() { contextMenu = new JPopupMenu(); openFolder = new JMenuItem("Open Folder"); openFolder.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (contrib instanceof LocalContribution) { File folder = ((LocalContribution) contrib).getFolder(); @@ -1181,6 +243,7 @@ public void actionPerformed(ActionEvent e) { setSelected(false); setExpandListener(this, new MouseAdapter() { + @Override public void mousePressed(MouseEvent e) { if (contrib.isCompatible(Base.getRevision())) listPanel.setSelectedPanel(ContributionPanel.this); @@ -1241,6 +304,7 @@ private void addPaneComponents() { updateButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { listPanel.contribManager.status.clear(); isUpdateInProgress = true; @@ -1250,6 +314,7 @@ public void actionPerformed(ActionEvent e) { installProgressBar.setIndeterminate(true); JProgressMonitor progress = new JProgressMonitor(installProgressBar) { + @Override public void finishedAction() { // Finished uninstalling the library resetInstallProgressBarState(); @@ -1677,10 +742,12 @@ private void installContribution(AvailableContribution ad, String url) { installProgressBar.setVisible(true); JProgressMonitor downloadProgress = new JProgressMonitor(installProgressBar) { + @Override public void finishedAction() { // Finished downloading library } + @Override public void cancel() { // Finished installing library resetInstallProgressBarState(); @@ -1696,6 +763,7 @@ public void cancel() { }; JProgressMonitor installProgress = new JProgressMonitor(installProgressBar) { + @Override public void finishedAction() { // Finished installing library resetInstallProgressBarState(); @@ -1712,6 +780,7 @@ public void finishedAction() { setSelected(true); } + @Override public void cancel() { finishedAction(); } @@ -1808,6 +877,7 @@ public boolean isSelected() { // static int inc; + @Override public void setForeground(Color fg) { super.setForeground(fg); @@ -1897,22 +967,20 @@ static void setForegroundStyle(JTextPane textPane, boolean installed, boolean se } } - static void setTextStyle(JTextPane textPane) { Document doc = textPane.getDocument(); if (doc instanceof HTMLDocument) { HTMLDocument html = (HTMLDocument) doc; StyleSheet stylesheet = html.getStyleSheet(); - stylesheet.addRule("body { " + - " margin: 0; padding: 0;" + - " font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" + + stylesheet.addRule("body { " + " margin: 0; padding: 0;" + + " font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;" + + " font-size: 100%;" + "font-size: 0.95em; " + "}"); } } ->>>>>>> refs/remotes/upstream/master static void setSelectionStyle(JTextPane textPane, boolean selected) { Document doc = textPane.getDocument(); if (doc instanceof HTMLDocument) { @@ -1925,4 +993,4 @@ static void setSelectionStyle(JTextPane textPane, boolean selected) { } } } -} +} \ No newline at end of file diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index ebc36d77be..ab1a4fbc64 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -92,6 +92,7 @@ public JEditTextArea(TextAreaDefaults defaults, InputHandler inputHandler) { if (!DISABLE_CARET) { caretTimer = new Timer(500, new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (hasFocus()) { blinkCaret(); @@ -140,7 +141,7 @@ public void actionPerformed(ActionEvent e) { // focusedComponent = this; addMouseWheelListener(new MouseWheelListener() { -<<<<<<< HEAD + @Override public void mouseWheelMoved(MouseWheelEvent e) { if (scrollBarsInitialized) { if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { @@ -190,6 +191,7 @@ protected TextAreaPainter createPainter(final TextAreaDefaults defaults) { /** * Inline Input Method Support for Japanese. */ + @Override public InputMethodRequests getInputMethodRequests() { if (Preferences.getBoolean("editor.input_method_support")) { if (inputMethodSupport == null) { @@ -205,6 +207,7 @@ public InputMethodRequests getInputMethodRequests() { * Get current position of the vertical scroll bar. [fry] * @deprecated Use {@link #getVerticalScrollPosition()}. */ + @Deprecated public int getScrollPosition() { return getVerticalScrollPosition(); } @@ -214,6 +217,7 @@ public int getScrollPosition() { * Set position of the vertical scroll bar. [fry] * @deprecated Use {@link #setVerticalScrollPosition(int)}. */ + @Deprecated public void setScrollPosition(int what) { setVerticalScrollPosition(what); } @@ -360,227 +364,6 @@ public final void setElectricScroll(int electricScroll) { * Updates the state of the scroll bars. This should be called * if the number of lines in the document changes, or when the * size of the text are changes. -======= - - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - if (scrollBarsInitialized) { - if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { - int scrollAmount = e.getUnitsToScroll(); -// System.out.println("rot/amt = " + e.getWheelRotation() + " " + amt); -// int max = vertical.getMaximum(); -// System.out.println("UNIT SCROLL of " + amt + " at value " + vertical.getValue() + " and max " + max); -// System.out.println(" get wheel rotation is " + e.getWheelRotation()); -// int ex = e.getModifiersEx(); -// String mods = InputEvent.getModifiersExText(ex); -// if (ex != 0) { -// System.out.println(" 3 2 1 0"); -// System.out.println(" 10987654321098765432109876543210"); -// System.out.println(" " + PApplet.binary(e.getModifiersEx())); -//// if (mods.length() > 0) { -// System.out.println(" mods extext = " + mods + " " + mods.length() + " " + PApplet.hex(mods.charAt(0))); -// } -// System.out.println(" " + e); - - // inertia scrolling on OS X will fire several shift-wheel events - // that are negative values.. this makes the scrolling area jump. - boolean isHorizontal = Base.isMacOS() && e.isShiftDown(); - if (isHorizontal) { - horizontal.setValue(horizontal.getValue() + scrollAmount); - }else{ - vertical.setValue(vertical.getValue() + scrollAmount); - } - } - } - } - }); - } - - - /** - * Override this to provide your own painter for this {@link JEditTextArea}. - * @param defaults - * @return a newly constructed {@link TextAreaPainter}. - */ - protected TextAreaPainter createPainter(final TextAreaDefaults defaults) { - return new TextAreaPainter(this, defaults); - } - - - /** - * Inline Input Method Support for Japanese. - */ - public InputMethodRequests getInputMethodRequests() { - if (Preferences.getBoolean("editor.input_method_support")) { - if (inputMethodSupport == null) { - inputMethodSupport = new InputMethodSupport(this); - } - return inputMethodSupport; - } - return null; - } - - - /** - * Get current position of the vertical scroll bar. [fry] - * @deprecated Use {@link #getVerticalScrollPosition()}. - */ - public int getScrollPosition() { - return getVerticalScrollPosition(); - } - - - /** - * Set position of the vertical scroll bar. [fry] - * @deprecated Use {@link #setVerticalScrollPosition(int)}. - */ - public void setScrollPosition(int what) { - setVerticalScrollPosition(what); - } - - - /** - * Get current position of the vertical scroll bar. - */ - public int getVerticalScrollPosition() { - return vertical.getValue(); - } - - - /** - * Set position of the vertical scroll bar. - */ - public void setVerticalScrollPosition(int what) { - vertical.setValue(what); - } - - - /** - * Get current position of the horizontal scroll bar. - */ - public int getHorizontalScrollPosition() { - return horizontal.getValue(); - } - - - /** - * Set position of the horizontal scroll bar. - */ - public void setHorizontalScrollPosition(int what) { - horizontal.setValue(what); - } - - - /** - * Returns the object responsible for painting this text area. - */ - public final TextAreaPainter getPainter() { - return painter; - } - - - public final Printable getPrintable() { - return painter.getPrintable(); - } - - - /** - * Returns the input handler. - */ - public final InputHandler getInputHandler() { - return inputHandler; - } - - - /** - * Sets the input handler. - * @param inputHandler The new input handler - */ - public void setInputHandler(InputHandler inputHandler) { - this.inputHandler = inputHandler; - } - - - /** - * Returns true if the caret is blinking, false otherwise. - */ - public final boolean isCaretBlinkEnabled() { - return caretBlinks; - } - - - /** - * Toggles caret blinking. - * @param caretBlinks True if the caret should blink, false otherwise - */ - public void setCaretBlinkEnabled(boolean caretBlinks) { - this.caretBlinks = caretBlinks; - if (!caretBlinks) { - blink = false; - } - painter.invalidateSelectedLines(); - } - - - /** - * Returns true if the caret is visible, false otherwise. - */ - public final boolean isCaretVisible() { - return (!caretBlinks || blink) && caretVisible; - } - - - /** - * Sets if the caret should be visible. - * @param caretVisible True if the caret should be visible, false - * otherwise - */ - public void setCaretVisible(boolean caretVisible) { - this.caretVisible = caretVisible; - blink = true; - - painter.invalidateSelectedLines(); - } - - - /** - * Blinks the caret. - */ - public final void blinkCaret() { - if (caretBlinks) { - blink = !blink; - painter.invalidateSelectedLines(); - } else { - blink = true; - } - } - - - /** - * Returns the number of lines from the top and button of the - * text area that are always visible. - */ - public final int getElectricScroll() { - return electricScroll; - } - - - /** - * Sets the number of lines from the top and bottom of the text - * area that are always visible - * @param electricScroll The number of lines always visible from - * the top or bottom - */ - public final void setElectricScroll(int electricScroll) { - this.electricScroll = electricScroll; - } - - - /** - * Updates the state of the scroll bars. This should be called - * if the number of lines in the document changes, or when the - * size of the text area changes. ->>>>>>> refs/remotes/upstream/master */ public void updateScrollBars() { if (vertical != null && visibleLines != 0) { @@ -1973,6 +1756,7 @@ public void copyAsHTML() { Clipboard clipboard = processing.app.Toolkit.getSystemClipboard(); clipboard.setContents(formatted, new ClipboardOwner() { + @Override public void lostOwnership(Clipboard clipboard, Transferable contents) { // i don't care about ownership } @@ -2143,6 +1927,7 @@ public void paste() { * Called by the AWT when this component is removed from it's parent. * This stops clears the currently focused component. */ + @Override public void removeNotify() { super.removeNotify(); // if(focusedComponent == this) @@ -2187,6 +1972,7 @@ public void processKeyEvent(KeyEvent evt) { */ + @Override public void processKeyEvent(KeyEvent event) { // this had to be added in Processing 007X, because the menu key // events weren't making it up to the frame. @@ -2344,6 +2130,7 @@ class ScrollLayout implements LayoutManager { //final int LEFT_EXTRA = 5; + @Override public void addLayoutComponent(String name, Component comp) { if(name.equals(CENTER)) @@ -2356,6 +2143,7 @@ else if(name.equals(LEFT_OF_SCROLLBAR)) leftOfScrollBar.addElement(comp); } + @Override public void removeLayoutComponent(Component comp) { if(center == comp) @@ -2368,6 +2156,7 @@ public void removeLayoutComponent(Component comp) leftOfScrollBar.removeElement(comp); } + @Override public Dimension preferredLayoutSize(Container parent) { Dimension dim = new Dimension(); @@ -2386,6 +2175,7 @@ public Dimension preferredLayoutSize(Container parent) return dim; } + @Override public Dimension minimumLayoutSize(Container parent) { Dimension dim = new Dimension(); @@ -2406,6 +2196,7 @@ public Dimension minimumLayoutSize(Container parent) return dim; } + @Override public void layoutContainer(Container parent) { Dimension size = parent.getSize(); @@ -2472,11 +2263,13 @@ class MutableCaretEvent extends CaretEvent super(JEditTextArea.this); } + @Override public int getDot() { return getCaretPosition(); } + @Override public int getMark() { return getMarkPosition(); @@ -2485,6 +2278,7 @@ public int getMark() class AdjustHandler implements AdjustmentListener { + @Override public void adjustmentValueChanged(final AdjustmentEvent evt) { if(!scrollBarsInitialized) @@ -2494,6 +2288,7 @@ public void adjustmentValueChanged(final AdjustmentEvent evt) // and the result is that scrolling doesn't stop after // the mouse is released SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { if (evt.getAdjustable() == vertical) { @@ -2508,6 +2303,7 @@ public void run() class ComponentHandler extends ComponentAdapter { + @Override public void componentResized(ComponentEvent evt) { recalculateVisibleLines(); @@ -2517,6 +2313,7 @@ public void componentResized(ComponentEvent evt) class DocumentHandler implements DocumentListener { + @Override public void insertUpdate(DocumentEvent evt) { documentChanged(evt); @@ -2541,6 +2338,7 @@ public void insertUpdate(DocumentEvent evt) select(newStart,newEnd); } + @Override public void removeUpdate(DocumentEvent evt) { documentChanged(evt); @@ -2574,6 +2372,7 @@ public void removeUpdate(DocumentEvent evt) select(newStart,newEnd); } + @Override public void changedUpdate(DocumentEvent evt) { } @@ -2582,6 +2381,7 @@ public void changedUpdate(DocumentEvent evt) class DragHandler implements MouseMotionListener { + @Override public void mouseDragged(MouseEvent evt) { if (popup != null && popup.isVisible()) return; @@ -2611,16 +2411,19 @@ public void mouseDragged(MouseEvent evt) { } } + @Override public void mouseMoved(MouseEvent evt) {} } class FocusHandler implements FocusListener { + @Override public void focusGained(FocusEvent evt) { setCaretVisible(true); } + @Override public void focusLost(FocusEvent evt) { setCaretVisible(false); } @@ -2629,6 +2432,7 @@ public void focusLost(FocusEvent evt) { class MouseHandler extends MouseAdapter { + @Override public void mousePressed(MouseEvent event) { // try { // requestFocus(); @@ -2780,24 +2584,29 @@ class CaretUndo extends AbstractUndoableEdit { this.end = end; } + @Override public boolean isSignificant() { return false; } + @Override public String getPresentationName() { return "caret move"; } + @Override public void undo() throws CannotUndoException { super.undo(); select(start,end); } + @Override public void redo() throws CannotRedoException { super.redo(); select(start,end); } + @Override public boolean addEdit(UndoableEdit edit) { if (edit instanceof CaretUndo) { CaretUndo cedit = (CaretUndo)edit; diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index fd336cb5fc..dbe737913b 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -4573,7 +4573,6 @@ protected boolean textSentence(char[] buffer, int start, int stop, if ((buffer[index] == ' ') || (index == stop)) { float wordWidth = textWidthImpl(buffer, wordStart, index); -<<<<<<< HEAD if (runningX + wordWidth > boxWidth) { if (runningX != 0) { // Next word is too big, output the current line and advance @@ -4615,48 +4614,6 @@ protected boolean textSentence(char[] buffer, int start, int stop, } else { // this word will fit, just add it to the line runningX += wordWidth + spaceWidth; wordStart = index + 1; // move on to the next word -======= - if (runningX + wordWidth >= boxWidth) { - if (runningX != 0) { - // Next word is too big, output the current line and advance - index = wordStart; - textSentenceBreak(lineStart, index); - // Eat whitespace before the first word on the next line. - while ((index < stop) && (buffer[index] == ' ')) { - index++; - } - } else { // (runningX == 0) - // If this is the first word on the line, and its width is greater - // than the width of the text box, then break the word where at the - // max width, and send the rest of the word to the next line. - do { - index--; - if (index == wordStart) { - // Not a single char will fit on this line. screw 'em. - //System.out.println("screw you"); - return false; //Float.NaN; - } - wordWidth = textWidthImpl(buffer, wordStart, index); - } while (wordWidth > boxWidth); - - //textLineImpl(buffer, lineStart, index, x, y); - textSentenceBreak(lineStart, index); - } - lineStart = index; - wordStart = index; - runningX = 0; - - } else if (index == stop) { - // last line in the block, time to unload - //textLineImpl(buffer, lineStart, index, x, y); - textSentenceBreak(lineStart, index); -// y += textLeading; - index++; - - } else { // this word will fit, just add it to the line - runningX += wordWidth; - wordStart = index ; // move on to the next word including the space before the word ->>>>>>> refs/remotes/upstream/master index++; } } else { // not a space or the last character diff --git a/java/src/processing/mode/java/pdex/JavaTextAreaPainter.java b/java/src/processing/mode/java/pdex/JavaTextAreaPainter.java index 4d45425706..00f63d2b2c 100644 --- a/java/src/processing/mode/java/pdex/JavaTextAreaPainter.java +++ b/java/src/processing/mode/java/pdex/JavaTextAreaPainter.java @@ -101,7 +101,8 @@ public JavaTextAreaPainter(JavaTextArea textArea, TextAreaDefaults defaults) { super(textArea, defaults); addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent evt) { + @Override + public void mouseClicked(MouseEvent evt) { if (!getEditor().hasJavaTabs()) { // Ctrl + Click disabled for java tabs if (evt.getButton() == MouseEvent.BUTTON1) { if (evt.isControlDown() || evt.isMetaDown()) { @@ -667,7 +668,6 @@ synchronized public void paint(Graphics gfx) { } -<<<<<<< HEAD public void startInterativeMode() { addMouseListener(this); addMouseMotionListener(this); @@ -779,119 +779,6 @@ public String replaceString(String str, int start, int end, String put) { public void updateCursor(int mouseX, int mouseY) { -======= - protected void startInterativeMode() { - addMouseListener(this); - addMouseMotionListener(this); - interactiveMode = true; - setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - repaint(); - } - - - protected void stopInteractiveMode() { - interactiveMode = false; - - if (colorSelector != null) { - // close color selector - colorSelector.hide(); - colorSelector.frame.dispatchEvent(new WindowEvent(colorSelector.frame, WindowEvent.WINDOW_CLOSING)); - } - - setCursor(new Cursor(Cursor.TEXT_CURSOR)); - repaint(); - } - - - // Update the interface - //public void updateInterface(ArrayList handles[], ArrayList colorBoxes[]) { - protected void updateInterface(List> handles, List> colorBoxes) { - this.handles = handles; - this.colorBoxes = colorBoxes; - - initInterfacePositions(); - repaint(); - } - - - /** - * Initialize all the number changing interfaces. - * synchronize this method to prevent the execution of 'paint' in the middle. - * (don't paint while we make changes to the text of the editor) - */ - private synchronized void initInterfacePositions() { - SketchCode[] code = getEditor().getSketch().getCode(); - int prevScroll = textArea.getVerticalScrollPosition(); - String prevText = textArea.getText(); - - for (int tab=0; tab>>>>>> refs/remotes/upstream/master int currentTab = getCurrentCodeIndex(); for (Handle n : handles.get(currentTab)) { if (n.pick(mouseX, mouseY)) { @@ -988,7 +875,8 @@ public void mousePressed(MouseEvent e) { colorSelector = new ColorSelector(box); colorSelector.frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { + @Override + public void windowClosing(WindowEvent e) { colorSelector.frame.setVisible(false); colorSelector = null; } From 50a14e75241fbc4b3a6ee03230acb37c45937534 Mon Sep 17 00:00:00 2001 From: JayDusara Date: Sun, 5 Apr 2015 19:55:44 +0530 Subject: [PATCH 2/5] code cleanup --- app/src/processing/app/Mode.java | 11 +- app/src/processing/app/Sketch.java | 2 +- .../app/contrib/ProgressMonitor.java | 183 ------------------ .../processing/app/syntax/JEditTextArea.java | 46 +---- core/todo.txt | 8 - todo.txt | 164 ---------------- 6 files changed, 14 insertions(+), 400 deletions(-) delete mode 100644 app/src/processing/app/contrib/ProgressMonitor.java diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index 5c2c225009..f36f34d1cc 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -1127,7 +1127,7 @@ public DefaultMutableTreeNode buildSketchbookTree(){ } return sbNode; } - + protected JFrame sketchbookFrame; /* @@ -1168,11 +1168,10 @@ public void showSketchbookFrame() { Toolkit.setIcon(sketchbookFrame); Toolkit.registerWindowCloseKeys(sketchbookFrame.getRootPane(), new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - sketchbookFrame.setVisible(false); - } - }); + public void actionPerformed(ActionEvent e) { + sketchbookFrame.setVisible(false); + } + }); sketchbookFrame.getContentPane().setLayout(new BorderLayout()); DefaultMutableTreeNode root = buildSketchbookTree(); diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index d134eaa2d3..701334f15a 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -799,7 +799,7 @@ public boolean save() throws IOException { protected boolean saveAs() throws IOException { String newParentDir = null; String newName = null; - + final String oldName2 = folder.getName(); // TODO rewrite this to use shared version from PApplet final String PROMPT = Language.text("save"); diff --git a/app/src/processing/app/contrib/ProgressMonitor.java b/app/src/processing/app/contrib/ProgressMonitor.java deleted file mode 100644 index c8b18f591a..0000000000 --- a/app/src/processing/app/contrib/ProgressMonitor.java +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2013 The Processing Foundation - Copyright (c) 2011-12 Ben Fry and Casey Reas - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package processing.app.contrib; - -import javax.swing.JProgressBar; - - -// 4 classes is more abstraction than is necessary for a single progress bar - -///** -// * The ProgressMonitor interface should be implemented by objects that observe -// * progress of a task or activity. -// */ -//public interface ProgressMonitor { -// -// int UNKNOWN = -1; -// -// /** -// * Starts a new task with the given name. -// * -// * @param maxValue -// * the amount of progress that must be made before a task is -// * finished. This may be set to UNKNOWN. -// */ -// public void startTask(String name, int maxValue); -// -// /** -// * Updates the amount of progress for the current task. -// */ -// public void setProgress(int value); -// -// /** -// * Returns the progress made toward the current task, as previously set by a -// * call to setProgress(). -// */ -// public int getProgress(); -// -// /** -// * @return true if a cancellation has been requested, false -// * otherwise -// */ -// public boolean isCanceled(); -// -// /** -// * Requests for the task to be cancelled by setting isCanceled() to true. -// */ -// public void cancel(); -// -// /** -// * @return true if an error occured while completing the task -// */ -// public boolean isError(); -// -// /** -// * @return an exception that caused the error, may be null. -// */ -// public Exception getException(); -// -// /** -// * Indicates that an error occurred while performing the task. Exception may -// * be null. -// */ -// public void error(Exception e); -// -// /** -// * Returns true if this task is complete -// */ -// public boolean isFinished(); -// -// /** -// * This is called when the current task is finished. This should always be -// * called when a task is finished, whether or not an error occurred or the -// * task was cancelled. -// */ -// public void finished(); -//} - - -//abstract class AbstractProgressMonitor implements ProgressMonitor { -abstract class ProgressMonitor { - static final int UNKNOWN = -1; - boolean canceled = false; - boolean error = false; - boolean finished = false; - Exception exception; - int max; - int progress = 0; - - public void startTask(String name, int maxValue) { - } - - public void setProgress(int value) { - progress = value; - } - - public int getProgress() { - return progress; - } - - public boolean isCanceled() { - return canceled; - } - - public void cancel() { - canceled = true; - } - - public boolean isError() { - return error; - } - - public Exception getException() { - return exception; - } - - public void error(Exception e) { - error = true; - exception = e; - } - - public boolean isFinished() { - return finished; - } - - public void finished() { - finished = true; - } -} - - -//class NullProgressMonitor extends AbstractProgressMonitor { -// public void startTask(String name, int maxValue) { } -//} - - -abstract class JProgressMonitor extends ProgressMonitor { - JProgressBar progressBar; - - public JProgressMonitor(JProgressBar progressBar) { - this.progressBar = progressBar; - // doesn't center properly -// progressBar.setFont(new Font("Dialog", Font.PLAIN, 10)); - } - - public void startTask(String name, int maxValue) { - finished = 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(); - finishedAction(); - } - - public abstract void finishedAction(); -} diff --git a/app/src/processing/app/syntax/JEditTextArea.java b/app/src/processing/app/syntax/JEditTextArea.java index ce2629b747..9cf6ecfd2f 100644 --- a/app/src/processing/app/syntax/JEditTextArea.java +++ b/app/src/processing/app/syntax/JEditTextArea.java @@ -140,11 +140,12 @@ public void actionPerformed(ActionEvent e) { // focusedComponent = this; addMouseWheelListener(new MouseWheelListener() { + @Override public void mouseWheelMoved(MouseWheelEvent e) { if (scrollBarsInitialized) { if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { - int amt = e.getUnitsToScroll(); + int scrollAmount = e.getUnitsToScroll(); // System.out.println("rot/amt = " + e.getWheelRotation() + " " + amt); // int max = vertical.getMaximum(); // System.out.println("UNIT SCROLL of " + amt + " at value " + vertical.getValue() + " and max " + max); @@ -162,14 +163,12 @@ public void mouseWheelMoved(MouseWheelEvent e) { // inertia scrolling on OS X will fire several shift-wheel events // that are negative values.. this makes the scrolling area jump. - boolean skip = Base.isMacOS() && e.isShiftDown(); - //if (ex == 0) { - if (!skip) { - vertical.setValue(vertical.getValue() + amt); -// } else { -// System.out.println(" ** skipping"); + boolean isHorizontal = Base.isMacOS() && e.isShiftDown(); + if (isHorizontal) { + horizontal.setValue(horizontal.getValue() + scrollAmount); + }else{ + vertical.setValue(vertical.getValue() + scrollAmount); } -// System.out.println(); } } } @@ -190,7 +189,6 @@ protected TextAreaPainter createPainter(final TextAreaDefaults defaults) { /** * Inline Input Method Support for Japanese. */ - @Override public InputMethodRequests getInputMethodRequests() { if (Preferences.getBoolean("editor.input_method_support")) { if (inputMethodSupport == null) { @@ -206,7 +204,6 @@ public InputMethodRequests getInputMethodRequests() { * Get current position of the vertical scroll bar. [fry] * @deprecated Use {@link #getVerticalScrollPosition()}. */ - @Deprecated public int getScrollPosition() { return getVerticalScrollPosition(); } @@ -216,7 +213,6 @@ public int getScrollPosition() { * Set position of the vertical scroll bar. [fry] * @deprecated Use {@link #setVerticalScrollPosition(int)}. */ - @Deprecated public void setScrollPosition(int what) { setVerticalScrollPosition(what); } @@ -362,7 +358,7 @@ public final void setElectricScroll(int electricScroll) { /** * Updates the state of the scroll bars. This should be called * if the number of lines in the document changes, or when the - * size of the text are changes. + * size of the text area changes. */ public void updateScrollBars() { if (vertical != null && visibleLines != 0) { @@ -1755,7 +1751,6 @@ public void copyAsHTML() { Clipboard clipboard = processing.app.Toolkit.getSystemClipboard(); clipboard.setContents(formatted, new ClipboardOwner() { - @Override public void lostOwnership(Clipboard clipboard, Transferable contents) { // i don't care about ownership } @@ -1926,7 +1921,6 @@ public void paste() { * Called by the AWT when this component is removed from it's parent. * This stops clears the currently focused component. */ - @Override public void removeNotify() { super.removeNotify(); // if(focusedComponent == this) @@ -1971,7 +1965,6 @@ public void processKeyEvent(KeyEvent evt) { */ - @Override public void processKeyEvent(KeyEvent event) { // this had to be added in Processing 007X, because the menu key // events weren't making it up to the frame. @@ -2129,7 +2122,6 @@ class ScrollLayout implements LayoutManager { //final int LEFT_EXTRA = 5; - @Override public void addLayoutComponent(String name, Component comp) { if(name.equals(CENTER)) @@ -2142,7 +2134,6 @@ else if(name.equals(LEFT_OF_SCROLLBAR)) leftOfScrollBar.addElement(comp); } - @Override public void removeLayoutComponent(Component comp) { if(center == comp) @@ -2155,7 +2146,6 @@ public void removeLayoutComponent(Component comp) leftOfScrollBar.removeElement(comp); } - @Override public Dimension preferredLayoutSize(Container parent) { Dimension dim = new Dimension(); @@ -2174,7 +2164,6 @@ public Dimension preferredLayoutSize(Container parent) return dim; } - @Override public Dimension minimumLayoutSize(Container parent) { Dimension dim = new Dimension(); @@ -2195,7 +2184,6 @@ public Dimension minimumLayoutSize(Container parent) return dim; } - @Override public void layoutContainer(Container parent) { Dimension size = parent.getSize(); @@ -2262,13 +2250,11 @@ class MutableCaretEvent extends CaretEvent super(JEditTextArea.this); } - @Override public int getDot() { return getCaretPosition(); } - @Override public int getMark() { return getMarkPosition(); @@ -2277,7 +2263,6 @@ public int getMark() class AdjustHandler implements AdjustmentListener { - @Override public void adjustmentValueChanged(final AdjustmentEvent evt) { if(!scrollBarsInitialized) @@ -2287,7 +2272,6 @@ public void adjustmentValueChanged(final AdjustmentEvent evt) // and the result is that scrolling doesn't stop after // the mouse is released SwingUtilities.invokeLater(new Runnable() { - @Override public void run() { if (evt.getAdjustable() == vertical) { @@ -2302,7 +2286,6 @@ public void run() class ComponentHandler extends ComponentAdapter { - @Override public void componentResized(ComponentEvent evt) { recalculateVisibleLines(); @@ -2312,7 +2295,6 @@ public void componentResized(ComponentEvent evt) class DocumentHandler implements DocumentListener { - @Override public void insertUpdate(DocumentEvent evt) { documentChanged(evt); @@ -2337,7 +2319,6 @@ public void insertUpdate(DocumentEvent evt) select(newStart,newEnd); } - @Override public void removeUpdate(DocumentEvent evt) { documentChanged(evt); @@ -2371,7 +2352,6 @@ public void removeUpdate(DocumentEvent evt) select(newStart,newEnd); } - @Override public void changedUpdate(DocumentEvent evt) { } @@ -2380,7 +2360,6 @@ public void changedUpdate(DocumentEvent evt) class DragHandler implements MouseMotionListener { - @Override public void mouseDragged(MouseEvent evt) { if (popup != null && popup.isVisible()) return; @@ -2410,19 +2389,16 @@ public void mouseDragged(MouseEvent evt) { } } - @Override public void mouseMoved(MouseEvent evt) {} } class FocusHandler implements FocusListener { - @Override public void focusGained(FocusEvent evt) { setCaretVisible(true); } - @Override public void focusLost(FocusEvent evt) { setCaretVisible(false); } @@ -2431,7 +2407,6 @@ public void focusLost(FocusEvent evt) { class MouseHandler extends MouseAdapter { - @Override public void mousePressed(MouseEvent event) { // try { // requestFocus(); @@ -2583,29 +2558,24 @@ class CaretUndo extends AbstractUndoableEdit { this.end = end; } - @Override public boolean isSignificant() { return false; } - @Override public String getPresentationName() { return "caret move"; } - @Override public void undo() throws CannotUndoException { super.undo(); select(start,end); } - @Override public void redo() throws CannotRedoException { super.redo(); select(start,end); } - @Override public boolean addEdit(UndoableEdit edit) { if (edit instanceof CaretUndo) { CaretUndo cedit = (CaretUndo)edit; diff --git a/core/todo.txt b/core/todo.txt index ac38a6fde7..2fa769264e 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -73,16 +73,8 @@ X play with improvements to full screen here showstoppers -<<<<<<< HEAD -<<<<<<< HEAD -======= _ static sketch with size() produces black window _ are we running on the EDT or not? ->>>>>>> refs/remotes/upstream/master -======= -_ static sketch with size() produces black window -_ are we running on the EDT or not? ->>>>>>> upstream/master _ static mode - no setup() / draw() - broken in Java2D _ https://github.com/processing/processing/issues/3130 _ noSmooth() and other settings reset after setup() diff --git a/todo.txt b/todo.txt index 10f14e9fb2..7d6e3af7da 100644 --- a/todo.txt +++ b/todo.txt @@ -24,166 +24,6 @@ X ie textAlign(RIGHT) / text(lineNum, LEFT_GUTTER - 5, y) X https://github.com/processing/processing/issues/3128 X run button w/ debugger shouldn't require "continue" before actually starting X https://github.com/processing/processing/issues/3096 -<<<<<<< HEAD -<<<<<<< HEAD - -integration of pdex/debug -o make the tabs have a default minimum size -o multiple sizes as they get smaller (web browser style) -X merge experimental into the main Java mode -X thereby removing Java 2.0 mode from the next release -X otherwise redoing the design for 2 modes -X changed JLS4 to JLS8 (but make sure it doesn't introduce anything too weird) -X change build scripts, get things running -X rename TextArea and TextAreaPainter to JavaTextArea -X DebugEditor.createTextArea() is copy & pasted from JavaEditor -X this whole setup is really gross at the moment -X finish Ant task to download JRE and JDK from Oracle -X remove public 'ta' object in DebugEditor, also dmode -X hasJavaTabs() cleanup -X how does it relate to compilationCheckEnabled? -X removed, seems to be duplicate/used the same way - -jre download/install -X make sure the file downloads correctly before renaming -X https://github.com/processing/processing/issues/2960 -X update build scripts for Windows and Linux to use JRE downloader Ant Task -X https://github.com/processing/processing/issues/3059 - -update components -X moving to Java 8 because Java 7 will be discontinued -X http://www.oracle.com/technetwork/java/javase/eol-135779.html -X requires Vista SP2 (ok, just say 7), and OS X 10.8.3, Ubuntu 12.04 -X requires 10.10 to build appbundler (for the Xcode SDK) -X requires ECJ update (using 4.4.1) -X http://download.eclipse.org/eclipse/downloads/drops4/R-4.4.1-201409250400/ -X update to launch4j 3.6 -X http://sourceforge.net/projects/launch4j/files/launch4j-3/3.6/ -o update ld and windres: https://github.com/processing/processing/tree/master/java/application/launch4j/bin -o also xstream.jar https://github.com/processing/processing/tree/master/java/application/launch4j/lib - -earlier -X any problems with new code signing crap? -X issues raised around the symlink (just replace with a copy of the binary?) -X fixed the short-term problem, filed an issue for the rest -X https://developer.apple.com/library/prerelease/mac/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG205 -X Move import suggestion to errors console -X https://github.com/processing/processing/issues/2947 -X server.stop produces an error: java.net.SocketException: socket closed -X https://github.com/processing/processing/issues/74 -X https://github.com/processing/processing/pull/2474 -X NPE when calling Client.ip() after the connection has been closed -X https://github.com/processing/processing/issues/2576 -X https://github.com/processing/processing/pull/2922 - -joel -X Add reference for installed tools and libraries to the Help menu -X https://github.com/processing/processing/issues/943 -X https://github.com/processing/processing/pull/2804 -X examples.properties file missing prevents startup -X https://github.com/processing/processing/issues/3037 -X https://github.com/processing/processing/pull/3047 -X several new French translations -X https://github.com/processing/processing/pull/3061 -X contributions.txt now gets deleted and recreated instead of overwritten -X https://github.com/processing/processing/pull/3073 -X https://github.com/processing/processing/issues/2994 -X Contrib Manager does not stop parsing contribs.txt if an error exists -X https://github.com/processing/processing/pull/3132 -X offer to install libraries imported libraries that are not available -X https://github.com/processing/processing/pull/3155 -X https://github.com/processing/processing/issues/2566 -X make fatal errors terminate the pde -X https://github.com/processing/processing/issues/3068 -X https://github.com/processing/processing/pull/3069 -X Java 8 method replace() used, removed -X https://github.com/processing/processing/issues/3168 -X https://github.com/processing/processing/pull/3169 -X Closing a few unclosed BufferedReaders and InputStreams -X https://github.com/processing/processing/pull/2961 - -manindra -X Fix for "Probably a ++ should go here" messages -X https://github.com/processing/processing/issues/2956 -X Missing opening curly bracket error -X https://github.com/processing/processing/issues/3104 -X missing parenthesis error message -X https://github.com/processing/processing/issues/3103 - -pulls -X add mnemonics for menus (alt-f to open 'file') -X http://code.google.com/p/processing/issues/detail?id=12 -X https://github.com/processing/processing/issues/51 -X https://github.com/processing/processing/pull/2382 -X getCaretLocation() bug in syntax.im package -X https://github.com/processing/processing/issues/2934 -X finish up debian package support (see the processing.mess folder) -X http://code.google.com/p/processing/issues/detail?id=75 -X these bits need to be checked to ensure that they work on other distros -X https://github.com/processing/processing/issues/114 -X https://github.com/processing/processing/pull/2972 -X https://github.com/processing/processing/issues/2973 -X https://github.com/processing/processing/pull/2974 -X Replace ColorChooser PApplets with custom Swing components -X https://github.com/processing/processing/pull/2975 -X fix encodings, line endings, and mime types in the repo -X https://github.com/processing/processing/issues/2955 -X https://github.com/processing/processing/pull/2978 -X https://github.com/processing/processing/pull/2977 -X add control for dependencies (i.e. svg needs xml), needed for export -X http://code.google.com/p/processing/issues/detail?id=70 -X https://github.com/processing/processing/issues/109 -X https://github.com/processing/processing/pull/3010 -X lots of Auto Format fixes -X https://github.com/processing/processing/pull/3002 -X https://github.com/processing/processing/issues/2540 -X https://github.com/processing/processing/issues/1041 -X update name of sketch in the "Recent" menu -X https://github.com/processing/processing/issues/2984 -X https://github.com/processing/processing/pull/3046 -X File change detection rewrite -X https://github.com/processing/processing/pull/3048 -X another file change detection rewrite -X https://github.com/processing/processing/pull/3070 -X broken Windows build due to launch4j .jar not updated -X https://github.com/processing/processing/issues/3062 -X https://github.com/processing/processing/pull/3066 -X exported Linux sketches must be run from the sketch folder -X https://github.com/processing/processing/issues/1046 -X https://github.com/processing/processing/pull/3083 -X rectMode() broken for createShape with JAVA2D -X https://github.com/processing/processing/issues/3024 -X https://github.com/processing/processing/pull/3102 -X IllegalArgumentException when clicking between editor windows -X https://github.com/processing/processing/issues/2530 -X https://github.com/processing/processing/pull/3101 -X processing.net.Server only cleans up internal Clients when trying to write -X https://github.com/processing/processing/issues/3089 -X https://github.com/processing/processing/pull/3097 -X issues with cut/copy shortcuts not working -X https://github.com/processing/processing/pull/3138 -X https://github.com/processing/processing/issues/3136 -X https://github.com/processing/processing/issues/3107 -X Display download percentage when fetching contrib info -X https://github.com/processing/processing/pull/3161 -X Recreating Client instance will cause an out-of-memory error -X https://github.com/processing/processing/issues/1400 -X https://github.com/processing/processing/pull/3088 -X Greek translation and new fonts -X https://github.com/processing/processing/pull/3025 -X Show tooltip when hovering over errors -X https://github.com/processing/processing/pull/3119 - - -3.0a7 -_ finish adding 'examples' contribs -_ https://github.com/processing/processing/issues/2953 -_ don't return here, allow contrib types to fail: -_ https://github.com/processing/processing/blob/master/app/src/processing/app/contrib/ContributionListing.java#L509 - -======= -======= ->>>>>>> upstream/master X remove code that's moving the sketch path arg later X https://github.com/processing/processing/commit/0a14835e6f5f4766b022e73a8fe562318636727c @@ -358,10 +198,6 @@ X http://stackoverflow.com/questions/8837719/java-in-full-screen-on-linux-how- X https://github.com/processing/processing/issues/3158 _ add notes to the Wiki about this (also to Linux) _ https://github.com/processing/processing/wiki/Window-Size-and-Full-Screen -<<<<<<< HEAD ->>>>>>> refs/remotes/upstream/master -======= ->>>>>>> upstream/master pdex _ fix hasJavaTabs() function From cd6834fd5dbfa25e5f99c5ca5534221c0033111f Mon Sep 17 00:00:00 2001 From: JayDusara Date: Sun, 5 Apr 2015 20:38:03 +0530 Subject: [PATCH 3/5] Dont rebuild tree if model is not initialized --- app/src/processing/app/Mode.java | 216 ++++++++++++++++--------------- 1 file changed, 109 insertions(+), 107 deletions(-) diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index f36f34d1cc..ff0795e902 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -47,15 +47,15 @@ public abstract class Mode { protected Base base; - + protected DefaultTreeModel model; protected File folder; protected TokenMarker tokenMarker; - protected HashMap keywordToReference = + protected HashMap keywordToReference = new HashMap(); - + protected Settings theme; // protected Formatter formatter; // protected Tool formatter; @@ -78,7 +78,7 @@ public abstract class Mode { protected File examplesFolder; protected File librariesFolder; protected File referenceFolder; - + protected File examplesContribFolder; public ArrayList coreLibraries; @@ -86,16 +86,16 @@ public abstract class Mode { /** Library folder for core. (Used for OpenGL in particular.) */ protected Library coreLibrary; - - /** + + /** * ClassLoader used to retrieve classes for this mode. Useful if you want - * to grab any additional classes that subclass what's in the mode folder. + * to grab any additional classes that subclass what's in the mode folder. */ protected ClassLoader classLoader; static final int BACKGROUND_WIDTH = 1025; static final int BACKGROUND_HEIGHT = 65; - protected Image backgroundImage; + protected Image backgroundImage; // public Mode(Base base, File folder) { // this(base, folder, base.getSketchbookLibrariesFolder()); @@ -111,14 +111,14 @@ public Mode(Base base, File folder) { examplesFolder = new File(folder, "examples"); librariesFolder = new File(folder, "libraries"); referenceFolder = new File(folder, "reference"); - + // Get path to the contributed examples compatible with this mode examplesContribFolder = Base.getSketchbookExamplesFolder(); // rebuildToolbarMenu(); rebuildLibraryList(); // rebuildExamplesMenu(); - + try { for (File file : getKeywordFiles()) { loadKeywords(file); @@ -128,8 +128,8 @@ public Mode(Base base, File folder) { "Could not load keywords file for " + getTitle() + " mode.", e); } } - - + + /** * To add additional keywords, or to grab them from another mode, override * this function. If your mode has no keywords, return a zero length array. @@ -138,22 +138,22 @@ public File[] getKeywordFiles() { return new File[] { new File(folder, "keywords.txt") }; } - + protected void loadKeywords(File keywordFile) throws IOException { - // overridden for Python, where # is an actual keyword + // overridden for Python, where # is an actual keyword loadKeywords(keywordFile, "#"); } - - - protected void loadKeywords(File keywordFile, + + + protected void loadKeywords(File keywordFile, String commentPrefix) throws IOException { BufferedReader reader = PApplet.createReader(keywordFile); String line = null; while ((line = reader.readLine()) != null) { if (!line.trim().startsWith(commentPrefix)) { - // Was difficult to make sure that mode authors were properly doing - // tab-separated values. By definition, there can't be additional - // spaces inside a keyword (or filename), so just splitting on tokens. + // Was difficult to make sure that mode authors were properly doing + // tab-separated values. By definition, there can't be additional + // spaces inside a keyword (or filename), so just splitting on tokens. String[] pieces = PApplet.splitTokens(line); if (pieces.length >= 2) { String keyword = pieces[0]; @@ -165,7 +165,7 @@ protected void loadKeywords(File keywordFile, if (pieces.length == 3) { String htmlFilename = pieces[2]; if (htmlFilename.length() > 0) { - // if the file is for the version with parens, + // if the file is for the version with parens, // add a paren to the keyword if (htmlFilename.endsWith("_")) { keyword += "_"; @@ -178,13 +178,13 @@ protected void loadKeywords(File keywordFile, } reader.close(); } - - + + public void setClassLoader(ClassLoader loader) { this.classLoader = loader; } - - + + public ClassLoader getClassLoader() { return classLoader; } @@ -193,16 +193,16 @@ public ClassLoader getClassLoader() { /** * Setup additional elements that are only required when running with a GUI, * rather than from the command-line. Note that this will not be called when - * the Mode is used from the command line (because Base will be null). + * the Mode is used from the command line (because Base will be null). */ public void setupGUI() { try { - // First load the default theme data for the whole PDE. + // First load the default theme data for the whole PDE. theme = new Settings(Base.getContentFile("lib/theme.txt")); - - // The mode-specific theme.txt file should only contain additions, - // and in extremely rare cases, it might override entries from the - // main theme. Do not override for style changes unless they are + + // The mode-specific theme.txt file should only contain additions, + // and in extremely rare cases, it might override entries from the + // main theme. Do not override for style changes unless they are // objectively necessary for your Mode. File modeTheme = new File(folder, "theme/theme.txt"); if (modeTheme.exists()) { @@ -220,8 +220,8 @@ public void setupGUI() { "Could not load theme.txt, please re-install Processing", e); } } - - + + /* protected void loadBackground() { String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png"; @@ -234,8 +234,8 @@ protected void loadBackground() { backgroundImage = loadImage("theme/mode" + suffix); } } - - + + public void drawBackground(Graphics g, int offset) { if (backgroundImage != null) { if (!Toolkit.highResDisplay()) { @@ -247,7 +247,7 @@ public void drawBackground(Graphics g, int offset) { g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); } - g.drawImage(backgroundImage, 0, -offset, + g.drawImage(backgroundImage, 0, -offset, BACKGROUND_WIDTH, BACKGROUND_HEIGHT, null); } } @@ -292,14 +292,14 @@ public String getIdentifier() { /** - * Get the folder where this mode is stored. + * Get the folder where this mode is stored. * @since 3.0a3 */ public File getFolder() { return folder; } - - + + public File getExamplesFolder() { return examplesFolder; } @@ -420,7 +420,7 @@ public void actionPerformed(ActionEvent e) { } }); toolbarMenu.add(item); - + item = new JMenuItem(Language.text("examples.add_examples")); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -448,11 +448,11 @@ public void actionPerformed(ActionEvent e) { protected int importMenuIndex = -1; - + /** * Rather than re-building the library menu for every open sketch (very slow - * and prone to bugs when updating libs, particularly with the contribs mgr), - * share a single instance across all windows. + * and prone to bugs when updating libs, particularly with the contribs mgr), + * share a single instance across all windows. * @since 3.0a6 * @param sketchMenu the Sketch menu that's currently active */ @@ -462,8 +462,8 @@ public void removeImportMenu(JMenu sketchMenu) { importMenuIndex = Toolkit.getMenuItemIndex(sketchMenu, importMenu); sketchMenu.remove(importMenu); } - - + + /** * Re-insert the Import Library menu. Added function so that other modes * need not have an 'import' menu. @@ -479,8 +479,8 @@ public void insertImportMenu(JMenu sketchMenu) { sketchMenu.insert(getImportMenu(), importMenuIndex); } } - - + + public JMenu getImportMenu() { if (importMenu == null) { rebuildImportMenu(); @@ -528,10 +528,10 @@ public void actionPerformed(ActionEvent e) { for (Library library : coreLibraries) { JMenuItem item = new JMenuItem(library.getName()); item.addActionListener(listener); - + // changed to library-name to facilitate specification of imports from properties file item.setActionCommand(library.getName()); - + importMenu.add(item); } } @@ -547,7 +547,7 @@ public void actionPerformed(ActionEvent e) { for (Library library : contribLibraries) { JMenuItem item = new JMenuItem(library.getName()); item.addActionListener(listener); - + // changed to library-name to facilitate specification if imports from properties file item.setActionCommand(library.getName()); @@ -674,7 +674,7 @@ public DefaultMutableTreeNode buildExamplesTree() { File[] subfolders = getExampleCategoryFolders(); DefaultMutableTreeNode modeExParent = new DefaultMutableTreeNode("Mode Examples"); - + for (File sub : subfolders) { DefaultMutableTreeNode subNode = new DefaultMutableTreeNode(sub.getName()); if (base.addSketches(subNode, sub)) { @@ -682,7 +682,7 @@ public DefaultMutableTreeNode buildExamplesTree() { modeExParent.add(subNode); } } - + // get library examples boolean any = false; for (Library lib : coreLibraries) { @@ -692,7 +692,7 @@ public DefaultMutableTreeNode buildExamplesTree() { modeExParent.add(libNode); } } - + if (modeExParent.getChildCount() > 0) node.add(modeExParent); @@ -722,7 +722,7 @@ public DefaultMutableTreeNode buildExamplesTree() { } catch (IOException e) { e.printStackTrace(); } - + DefaultMutableTreeNode contribExampleNode = buildContributedExamplesTrees(); if (contribExampleNode.getChildCount() > 0) node.add(contribExampleNode); @@ -785,7 +785,7 @@ public void resetExamples() { /** * Function to give a JTree a pretty alternating gray-white colouring for * its rows. - * + * * @param tree */ private void colourizeTreeRows(JTree tree) { @@ -806,7 +806,7 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, if (!tree.isRowSelected(row)) { if (row % 2 == 0) { - // Need to set this, else the gray from the odd + // Need to set this, else the gray from the odd // rows colours this gray as well. c.setBackground(new Color(255, 255, 255)); @@ -816,15 +816,15 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, } else { // Set background for entire component (including the image). - // Using transparency messes things up, probably since the + // Using transparency messes things up, probably since the // transparent colour is not good friends with the images background colour. c.setBackground(new Color(240, 240, 240)); - // Can't use setBackgroundSelectionColor() directly, since then, the + // Can't use setBackgroundSelectionColor() directly, since then, the // image's background isn't affected. - // The setUI() doesn't fix the image's background because the - // transparency likely interferes with its normal background, - // making its background lighter than the rest. + // The setUI() doesn't fix the image's background because the + // transparency likely interferes with its normal background, + // making its background lighter than the rest. // setBackgroundNonSelectionColor(new Color(190, 190, 190)); setBackgroundSelectionColor(new Color(0, 0, 255)); @@ -852,7 +852,7 @@ protected void paintRow(Graphics g, Rectangle clipBounds, Insets insets, if (!tree.isRowSelected(row)) { if (row % 2 == 0) { - // Need to set this, else the gray from the odd rows + // Need to set this, else the gray from the odd rows // affects the even rows too. g2.setColor(new Color(255, 255, 255, 128)); } else { @@ -883,11 +883,11 @@ public void actionPerformed(ActionEvent e) { examplesFrame.setVisible(false); } }); - + JPanel examplesPanel = new JPanel(); examplesPanel.setLayout(new BorderLayout()); examplesPanel.setBackground(Color.WHITE); - + final JPanel openExamplesManagerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); JLabel openExamplesManagerLabel = new JLabel(Language.text("examples.add_examples")); // openExamplesManagerLabel.setAlignmentX(Component.LEFT_ALIGNMENT); @@ -901,18 +901,18 @@ public void actionPerformed(ActionEvent e) { openExamplesManagerPanel.setCursor(new Cursor(Cursor.HAND_CURSOR)); // openExamplesManagerLabel.setForeground(new Color(0, 0, 238)); openExamplesManagerPanel.addMouseListener(new MouseAdapter() { - + @Override public void mouseClicked(MouseEvent e) { base.handleOpenExampleManager(); // openExamplesManagerLabel.setForeground(new Color(85, 26, 139)); } }); - + final JTree tree = new JTree(buildExamplesTree()); - + colourizeTreeRows(tree); - + tree.setOpaque(true); tree.setAlignmentX(Component.LEFT_ALIGNMENT); @@ -982,14 +982,14 @@ public void treeCollapsed(TreeExpansionEvent event) { } else { tree.setToggleClickCount(1); } - + JScrollPane treePane = new JScrollPane(tree); treePane.setPreferredSize(new Dimension(250, 300)); treePane.setBorder(new EmptyBorder(2, 0, 0, 0)); treePane.setOpaque(true); treePane.setBackground(Color.WHITE); treePane.setAlignmentX(Component.LEFT_ALIGNMENT); - + examplesPanel.add(openExamplesManagerPanel,BorderLayout.PAGE_START); examplesPanel.add(treePane, BorderLayout.CENTER); examplesFrame.getContentPane().add(examplesPanel); @@ -1127,7 +1127,7 @@ public DefaultMutableTreeNode buildSketchbookTree(){ } return sbNode; } - + protected JFrame sketchbookFrame; /* @@ -1136,13 +1136,15 @@ public DefaultMutableTreeNode buildSketchbookTree(){ * deleted not by means of processing application window but externally. */ public void rebuildTree() { - DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); - root.removeAllChildren(); - try { - base.addSketches(root, Base.getSketchbookFolder()); - model.reload(root); - } catch (IOException e) { - e.printStackTrace(); + if (model != null) { + DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); + root.removeAllChildren(); + try { + base.addSketches(root, Base.getSketchbookFolder()); + model.reload(root); + } catch (IOException e) { + e.printStackTrace(); + } } } @@ -1151,14 +1153,14 @@ public void rebuildTree() { * Called from updateInernal in Base.java */ public void updateTree(String sketchName, File sketchFolder) { - File f = new File(sketchFolder.getAbsolutePath() + "\\" + sketchName - + ".pde"); - if (model != null) { - DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); - SketchReference reference = new SketchReference(sketchName, f); - DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(reference); - root.add(newNode); - model.reload(root); + File f = new File(sketchFolder.getAbsolutePath() + "\\" + sketchName + + ".pde"); + if (model != null) { + DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot(); + SketchReference reference = new SketchReference(sketchName, f); + DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(reference); + root.add(newNode); + model.reload(root); } } @@ -1258,7 +1260,7 @@ public void run() { }); } - + /** * Get an ImageIcon object from the Mode folder. * Or when prefixed with /lib, load it from the main /lib folder. @@ -1276,21 +1278,21 @@ public ImageIcon loadIcon(String filename) { // EditorConsole.systemErr.println("found: " + file.getAbsolutePath()); return new ImageIcon(file.getAbsolutePath()); } - - + + /** * Get an image object from the mode folder. * Or when prefixed with /lib, load it from the main /lib folder. */ public Image loadImage(String filename) { - ImageIcon icon = loadIcon(filename); + ImageIcon icon = loadIcon(filename); if (icon != null) { return icon.getImage(); } return null; } - - + + // public EditorButton loadButton(String name) { // return new EditorButton(this, name); // } @@ -1317,7 +1319,7 @@ public String lookupReference(String keyword) { public TokenMarker getTokenMarker() { return tokenMarker; } - + protected TokenMarker createTokenMarker() { return new PdeKeywords(); } @@ -1339,10 +1341,10 @@ protected TokenMarker createTokenMarker() { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // Get attributes/values from the theme.txt file. To discourage burying this - // kind of information in code where it doesn't belong (and is difficult to - // track down), these don't have a "default" option as a second parameter. + // kind of information in code where it doesn't belong (and is difficult to + // track down), these don't have a "default" option as a second parameter. + - /** @since 3.0a6 */ public String getString(String attribute) { return theme.get(attribute); @@ -1388,8 +1390,8 @@ public SyntaxStyle getStyle(String attribute) { // return new SyntaxStyle(color, italic, bold); return new SyntaxStyle(color, bold); } - - + + public Image getGradient(String attribute, int wide, int high) { int top = getColor(attribute + ".gradient.top").getRGB(); int bot = getColor(attribute + ".gradient.bottom").getRGB(); @@ -1400,8 +1402,8 @@ public Image getGradient(String attribute, int wide, int high) { // float r2 = (bot >> 16) & 0xff; // float g2 = (bot >> 8) & 0xff; // float b2 = bot & 0xff; - - BufferedImage outgoing = + + BufferedImage outgoing = new BufferedImage(wide, high, BufferedImage.TYPE_INT_RGB); int[] row = new int[wide]; WritableRaster wr = outgoing.getRaster(); @@ -1467,7 +1469,7 @@ public boolean canEdit(final File f) { } return validExtension(f.getName().substring(dot + 1)); } - + /** * Check this extension (no dots, please) against the list of valid * extensions. @@ -1491,7 +1493,7 @@ public boolean validExtension(String what) { * Returns the appropriate file extension to use for auxilliary source files in a sketch. * For example, in a Java-mode sketch, auxilliary files should be name "Foo.java"; in * Python mode, they should be named "foo.py". - * + * *

Modes that do not override this function will get the default behavior of returning the * default extension. */ @@ -1515,22 +1517,22 @@ public String getModuleExtension() { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /** - * Checks coreLibraries and contribLibraries for a library with the specified name + * Checks coreLibraries and contribLibraries for a library with the specified name * @param libName the name of the library to find * @return the Library or null if not found */ public Library findLibraryByName(String libName) { - + for (Library lib : this.coreLibraries) { if (libName.equals(lib.getName())) return lib; } - + for (Library lib : this.contribLibraries) { if (libName.equals(lib.getName())) return lib; } - + return null; } @@ -1559,7 +1561,7 @@ public void prepareExportFolder(File targetFolder) { // public void handleNewReplace() { // base.handleNewReplace(); // } - + @Override public String toString() { return getTitle(); From 1a6ea9024358a81c2893031e79a8ac826cf1d18f Mon Sep 17 00:00:00 2001 From: JayDusara Date: Fri, 10 Apr 2015 10:25:52 +0530 Subject: [PATCH 4/5] merging changes from original repo --- app/src/processing/app/Base.java | 16 +- app/src/processing/app/ColorChooser.java | 5 +- app/src/processing/app/Platform.java | 49 ++--- app/src/processing/app/Preferences.java | 67 +++++-- core/README.md | 3 + core/src/processing/core/PApplet.java | 17 +- core/src/processing/core/PSurfaceAWT.java | 210 +++++++--------------- core/todo.txt | 9 + 8 files changed, 178 insertions(+), 198 deletions(-) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index da2d05f2bb..19e32e6a95 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1275,14 +1275,14 @@ protected boolean addSketches(DefaultMutableTreeNode node, File folder) throws I return false; // let's not go there } - String[] list = folder.list(); + String[] fileList = folder.list(); // If a bad folder or unreadable or whatever, this will come back null - if (list == null) { + if (fileList == null) { return false; } // Alphabetize the list, since it's not always alpha order - Arrays.sort(list, String.CASE_INSENSITIVE_ORDER); + Arrays.sort(fileList, String.CASE_INSENSITIVE_ORDER); // ActionListener listener = new ActionListener() { // public void actionPerformed(ActionEvent e) { @@ -1301,8 +1301,8 @@ protected boolean addSketches(DefaultMutableTreeNode node, File folder) throws I //menu.addActionListener(listener); boolean found = false; - - for (String name : list) { + for (String name : fileList) { + //Skip hidden files if (name.charAt(0) == '.') { continue; } @@ -1317,18 +1317,14 @@ protected boolean addSketches(DefaultMutableTreeNode node, File folder) throws I if (subfolder.isDirectory()) { File entry = checkSketchFolder(subfolder, name); if (entry != null) { -// DefaultMutableTreeNode item = new DefaultMutableTreeNode(name); DefaultMutableTreeNode item = new DefaultMutableTreeNode(new SketchReference(name, entry)); -// item.addActionListener(listener); -// item.setActionCommand(entry.getAbsolutePath()); -// menu.add(item); + node.add(item); found = true; } else { // not a sketch folder, but maybe a subfolder containing sketches -// JMenu submenu = new JMenu(name); DefaultMutableTreeNode subnode = new DefaultMutableTreeNode(name); // needs to be separate var otherwise would set ifound to false boolean anything = addSketches(subnode, subfolder); diff --git a/app/src/processing/app/ColorChooser.java b/app/src/processing/app/ColorChooser.java index 01ed1ea47f..c70f3d756f 100644 --- a/app/src/processing/app/ColorChooser.java +++ b/app/src/processing/app/ColorChooser.java @@ -146,7 +146,6 @@ public void actionPerformed(ActionEvent actionEvent) { public void show() { window.setVisible(true); - window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); } @@ -490,6 +489,8 @@ public class ColorRange extends JComponent { private int lastX, lastY; public ColorRange() { + setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { @@ -570,6 +571,8 @@ public class ColorSlider extends JComponent { static final int HIGH = 256; public ColorSlider() { + setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { diff --git a/app/src/processing/app/Platform.java b/app/src/processing/app/Platform.java index 4144d39053..208c08b9bd 100644 --- a/app/src/processing/app/Platform.java +++ b/app/src/processing/app/Platform.java @@ -53,16 +53,20 @@ public class Platform { Base base; + public void init(Base base) { + this.base = base; + } + + /** * Set the default L & F. While I enjoy the bounty of the sixteen possible * exception types that this UIManager method might throw, I feel that in * just this one particular case, I'm being spoiled by those engineers - * at Sun, those Masters of the Abstractionverse. It leaves me feeling sad - * and overweight. So instead, I'll pretend that I'm not offered eleven dozen - * ways to report to the user exactly what went wrong, and I'll bundle them - * all into a single catch-all "Exception". Because in the end, all I really - * care about is whether things worked or not. And even then, I don't care. - * + * at Sun, those Masters of the Abstractionverse. So instead, I'll pretend + * that I'm not offered eleven dozen ways to report to the user exactly what + * went wrong, and I'll bundle them all into a single catch-all "Exception". + * Because in the end, all I really care about is whether things worked or + * not. And even then, I don't care. * @throws Exception Just like I said. */ public void setLookAndFeel() throws Exception { @@ -74,17 +78,20 @@ public void setLookAndFeel() throws Exception { } } - public void saveLanguage(String languageCode) {} - public void init(Base base) { - this.base = base; - } + /** + * Handle any platform-specific languages saving. This is necessary on OS X + * because of how bundles are handled, but perhaps your platform would like + * to Think Different too? + * @param languageCode 2-digit lowercase ISO language code + */ + public void saveLanguage(String languageCode) { } - /** - * This function should throw an exception or return a value. - * Do not return null. - */ + /** + * This function should throw an exception or return a value. + * Do not return null. + */ public File getSettingsFolder() throws Exception { // otherwise make a .processing directory int the user's home dir File home = new File(System.getProperty("user.home")); @@ -149,26 +156,26 @@ public void openFolder(File file) throws Exception { } */ } - + /** - * Attempts to move to the Trash on OS X, or the Recycle Bin on Windows. - * Also tries to find a suitable Trash location on Linux. - * If not possible, just deletes the file or folder instead. + * Attempts to move to the Trash on OS X, or the Recycle Bin on Windows. + * Also tries to find a suitable Trash location on Linux. + * If not possible, just deletes the file or folder instead. * @param file the folder or file to be removed/deleted * @return true if the folder was successfully removed - * @throws IOException + * @throws IOException */ final public boolean deleteFile(File file) throws IOException { FileUtils fu = FileUtils.getInstance(); if (fu.hasTrash()) { fu.moveToTrash(new File[] { file }); return true; - + } else if (file.isDirectory()) { Base.removeDir(file); return true; - + } else { return file.delete(); } diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 993ee43cfe..f24c67251d 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -50,7 +50,7 @@ public class Preferences { static final String PREFS_FILE = "preferences.txt"; //$NON-NLS-1$ static HashMap defaults; - static HashMap table = new HashMap(); + static HashMap table = new HashMap(); static File preferencesFile; static final String PROMPT_YES = Language.text("prompt.yes"); @@ -66,9 +66,6 @@ public class Preferences { static public int BUTTON_WIDTH = Integer.parseInt(Language.text("preferences.button.width")); -// /** height of the EditorHeader, EditorToolbar, and EditorStatus */ -// static final int GRID_SIZE = 32; - // Indents and spacing standards. These probably need to be modified // per platform as well, because Mac OS X is so huge, Windows is smaller, // and Linux is all over the map. Consider these deprecated. @@ -90,6 +87,8 @@ static public void init() { "You'll need to reinstall Processing.", e); } + /* provisionally removed in 3.0a6, see changes in load() + // check for platform-specific properties in the defaults String platformExt = "." + PConstants.platformNames[PApplet.platform]; //$NON-NLS-1$ int platformExtLength = platformExt.length(); @@ -109,9 +108,10 @@ static public void init() { String value = get(key); set(actualKey, value); } + */ - // clone the hash table - //defaults = (HashMap) table.clone(); + // Clone the defaults, then override any them with the user's preferences. + // This ensures that any new/added preference will be present. defaults = new HashMap(table); // other things that have to be set explicitly for the defaults @@ -145,8 +145,8 @@ static public void init() { // http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html String proxyHost = get("proxy.host"); String proxyPort = get("proxy.port"); - if (proxyHost != null && proxyHost.trim().length() != 0 && - proxyPort != null && proxyPort.trim().length() != 0) { + if (proxyHost != null && proxyHost.length() != 0 && + proxyPort != null && proxyPort.length() != 0) { System.setProperty("http.proxyHost", proxyHost); System.setProperty("http.proxyPort", proxyPort); } @@ -158,10 +158,19 @@ static protected String getPreferencesPath() { } - // ................................................................. + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + /** + * Load a set of key/value pairs from a UTF-8 encoded file into 'table'. + * For 3.0a6, this removes any platform-specific extensions from keys, so + * that we don't have platform-specific entries in a user's preferences.txt + * file, which would require all prefs to be changed twice, or risk being + * overwritten by the unchanged platform-specific version on reload. + */ static public void load(InputStream input) throws IOException { + HashMap platformSpecific = new HashMap<>(); + String[] lines = PApplet.loadStrings(input); // Reads as UTF-8 for (String line : lines) { if ((line.length() == 0) || @@ -172,13 +181,46 @@ static public void load(InputStream input) throws IOException { if (equals != -1) { String key = line.substring(0, equals).trim(); String value = line.substring(equals + 1).trim(); - table.put(key, value); + if (!isPlatformSpecific(key, value, platformSpecific)) { + table.put(key, value); + } + } + } + // Now override the keys with any platform-specific defaults we've found. + for (String key : platformSpecific.keySet()) { + table.put(key, platformSpecific.get(key)); + } + } + + + /** + * @param key original key (may include platform extension) + * @param value + * @param specific where to put the key/value pairs for *this* platform + * @return true if a platform-specific key + */ + static protected boolean isPlatformSpecific(String key, String value, + Map specific) { + for (String platform : PConstants.platformNames) { + String ext = "." + platform; + if (key.endsWith(ext)) { + String thisPlatform = PConstants.platformNames[PApplet.platform]; + if (platform.equals(thisPlatform)) { + key = key.substring(0, key.lastIndexOf(ext)); + // store this for later overrides + specific.put(key, value); + } else { + // ignore platform-specific defaults for other platforms, + // but return 'true' because it needn't be added to the big list + } + return true; } } + return false; } - // ................................................................. + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . static protected void save() { @@ -191,6 +233,7 @@ static protected void save() { PrintWriter writer = PApplet.createWriter(preferencesFile); String[] keyList = table.keySet().toArray(new String[table.size()]); + // Sorting is really helpful for debugging, diffing, and finding keys keyList = PApplet.sort(keyList); for (String key : keyList) { writer.println(key + "=" + table.get(key)); //$NON-NLS-1$ @@ -201,7 +244,7 @@ static protected void save() { } - // ................................................................. + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . // all the information from preferences.txt diff --git a/core/README.md b/core/README.md index e8b853b57f..d6d49dc11a 100644 --- a/core/README.md +++ b/core/README.md @@ -26,6 +26,9 @@ We're removing `Applet` as the base class for `PApplet` and redoing the entire r #### Retina/HiDPI/2x drawing and displays * Documentation changes [here](https://github.com/processing/processing-docs/issues/170) +#### The Event Dispatch Thread +The current source starts putting AWT (and Swing, if any) calls on the [EDT](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html), per Oracle's statements in Java's documentation. Actual rendering in the default renderer happens off the EDT, but the EDT is used to blit the image to the screen (or resize windows, etc). Looking for more consistent cross-platform results by doing this. + ## The Mess The rest of this document are my notes while I'm making changes. diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 2a15b77525..f23dadc184 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -204,7 +204,7 @@ public class PApplet implements PConstants { static final boolean DEBUG = false; // static final boolean DEBUG = true; - /** Default width and height for applet when not specified */ + /** Default width and height for sketch when not specified */ static public final int DEFAULT_WIDTH = 100; static public final int DEFAULT_HEIGHT = 100; @@ -9341,8 +9341,8 @@ static public void main(final String mainClass) { * the 'args' array when not null. * @param mainClass name of the class to load (with package if any) * @param args command line arguments to pass to the sketch's 'args' array. - * Note that this is *not* the same as the args passed to PApplet - * such as --display and others. + * Note that this is *not* the same as the args passed to (and + * understood by) PApplet such as --display. */ static public void main(final String mainClass, final String[] sketchArgs) { String[] args = new String[] { mainClass }; @@ -9353,7 +9353,6 @@ static public void main(final String mainClass, final String[] sketchArgs) { } - /* static public void runSketch(final String[] args, final PApplet constructedApplet) { EventQueue.invokeLater(new Runnable() { @@ -9362,11 +9361,15 @@ public void run() { } }); } - */ - static public void runSketch(final String[] args, - final PApplet constructedApplet) { + /** + * Moving this to the EDT for 3.0a6 because the main() messes with AWT + * components (or even Swing components, presumably). Hoping to get more + * consistent behavior across platforms and implementations. + */ + static protected void runSketchEDT(final String[] args, + final PApplet constructedApplet) { // Supposed to help with flicker, but no effect on OS X. // TODO IIRC this helped on Windows, but need to double check. System.setProperty("sun.awt.noerasebackground", "true"); diff --git a/core/src/processing/core/PSurfaceAWT.java b/core/src/processing/core/PSurfaceAWT.java index 4a3b7c5504..c788310300 100644 --- a/core/src/processing/core/PSurfaceAWT.java +++ b/core/src/processing/core/PSurfaceAWT.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2014 The Processing Foundation + Copyright (c) 2014-15 The Processing Foundation This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -104,8 +104,10 @@ public void componentResized(ComponentEvent e) { /** - * Handle grabbing the focus from the parent applet. Other renderers can - * override this if handling needs to be different. + * Handle grabbing the focus on startup. Other renderers can override this + * if handling needs to be different. For the AWT, the request is invoked + * later on the EDT. Other implementations may not require that, so the + * invokeLater() happens in here rather than requiring the caller to wrap it. */ public void requestFocus() { // for 2.0a6, moving this request to the EDT @@ -198,72 +200,11 @@ public void addNotify() { } - /* - protected synchronized void render_example() { - System.out.println("render(), bounds are " + getBounds()); - if (getBufferStrategy() == null) { // whole block [121222] - System.out.println("creating a strategy"); - createBufferStrategy(2); - } - BufferStrategy strategy = getBufferStrategy(); - if (strategy == null) { - return; - } - // Render single frame - do { - // The following loop ensures that the contents of the drawing buffer - // are consistent in case the underlying surface was recreated - do { - Graphics draw = strategy.getDrawGraphics(); - //Insets i = getInsets(); - //int w = (int)(((double)(getWidth() - i.left - i.right))/2+0.5); - //int h = (int)(((double)(getHeight() - i.top - i.bottom))/2+0.5); - Insets i = new Insets(0, 0, 0, 0); - int w = getWidth() / 2; - int h = getHeight() / 2; - - if (false) { - draw.setColor(Color.YELLOW); - draw.fillRect(i.left, i.top + h, w, getHeight() - h); - draw.fillRect(i.left + w, i.top, getWidth() - w, h); - draw.setColor(Color.BLACK); - draw.fillRect(i.left, i.top, w, h); - draw.fillRect(i.left + w, i.top + h, getWidth() - w, getHeight() - h); - } else { - draw.setColor(Color.WHITE); - draw.fillRect(i.left, i.top, getWidth(), getHeight()); - - draw.setColor(Color.BLACK); - draw.setFont(new Font("SansSerif", Font.PLAIN, 50)); - draw.drawString("this is some text", 50, 100); - -// draw.setColor(Color.BLACK); -// int mx = Math.max(getWidth(), getHeight()); -// for (int x = -getWidth(); x < getWidth(); x += 5) { -// draw.drawLine(x, 0, x + mx, mx); -// } - } - - draw.dispose(); - - // Repeat the rendering if the drawing buffer contents - // were restored - System.out.println("restored " + strategy.contentsRestored()); - } while (strategy.contentsRestored()); - - // Display the buffer - System.out.println("showing"); - strategy.show(); - - // Repeat the rendering if the drawing buffer was lost - System.out.println("lost " + strategy.contentsLost()); - System.out.println(); - } while (strategy.contentsLost()); - } - */ - - protected synchronized void render() { + if (!EventQueue.isDispatchThread()) { + //throw new IllegalStateException("render() called outside the EDT"); + System.err.println("render() called outside the EDT"); + } // if (canvas == null) { // removeListeners(this); // canvas = new Canvas(); @@ -283,6 +224,13 @@ protected synchronized void render() { return; } + if (graphics.image == null) { + if (PApplet.DEBUG) { + new Exception("image is null, returning").printStackTrace(System.out); + } + return; + } + // System.out.println("render(), canvas bounds are " + canvas.getBounds()); if (canvas.getBufferStrategy() == null) { // whole block [121222] // System.out.println("creating a strategy"); @@ -321,83 +269,15 @@ protected synchronized void render() { } - /* - @Override - public void update(Graphics screen) { - paint(screen); - } - - - @Override - public void paint(Graphics screen) { -// int r = (int) random(10000); -// System.out.println("into paint " + r); - //super.paint(screen); - - // ignore the very first call to paint, since it's coming - // from the o.s., and the applet will soon update itself anyway. - if (frameCount == 0) { -// println("Skipping frame"); - // paint() may be called more than once before things - // are finally painted to the screen and the thread gets going - return; - } - // without ignoring the first call, the first several frames - // are confused because paint() gets called in the midst of - // the initial nextFrame() call, so there are multiple - // updates fighting with one another. - - // make sure the screen is visible and usable - // (also prevents over-drawing when using PGraphicsOpenGL) - -// if (useActive) { -// return; -// } - -// if (insideDraw) { -// new Exception().printStackTrace(System.out); -// } - if (!insideDraw && (g != null) && (g.image != null)) { - if (useStrategy) { - render(); - } else { -// System.out.println("drawing to screen"); - //screen.drawImage(g.image, 0, 0, null); // not retina friendly - screen.drawImage(g.image, 0, 0, width, height, null); - } - } else { - debug(insideDraw + " " + g + " " + ((g != null) ? g.image : "-")); - } - } -*/ - - public void blit() { -// System.out.println("blit"); - ((SmoothCanvas) canvas).render(); // ?? -// canvas.repaint(); - /* - if (canvas.getGraphicsConfiguration() != null) { - GraphicsDevice device = canvas.getGraphicsConfiguration().getDevice(); - if (device != displayDevice) { - System.out.println("display device changed from " + displayDevice + " to " + device); - } - } - - if (useActive) { - if (useStrategy) { - render(); - } else { - Graphics screen = canvas.getGraphics(); - if (screen != null) { - screen.drawImage(g.image, 0, 0, sketch.width, sketch.height, null); - } + // Other folks taht call render() (i.e. paint()) are already on the EDT. + // We need to be using the EDT since we're messing with the Canvas + // object and BufferStrategy and friends. + EventQueue.invokeLater(new Runnable() { + public void run() { + ((SmoothCanvas) canvas).render(); } - } else { - canvas.repaint(); - } -// getToolkit().sync(); // force repaint now (proper method) - */ + }); } @@ -674,6 +554,8 @@ public void windowClosing(WindowEvent e) { private void setCanvasSize() { +// System.out.format("setting canvas size %d %d%n", sketchWidth, sketchHeight); +// new Exception().printStackTrace(System.out); int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH); int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT); @@ -833,7 +715,16 @@ public void resumeThread() { // needs to resize the frame, which will resize the canvas, and so on... public void setSize(int wide, int high) { // System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high); -// new Exception().printStackTrace(System.out); + if (PApplet.DEBUG) { + new Exception(String.format("setSize(%d, %d)", wide, high)).printStackTrace(System.out); + } + + if (wide == sketchWidth && high == sketchHeight) { + if (PApplet.DEBUG) { + new Exception("w/h unchanged " + wide + " " + high).printStackTrace(System.out); + } + return; // unchanged, don't rebuild everything + } sketchWidth = wide; sketchHeight = high; @@ -1421,13 +1312,25 @@ public void run() { // not good to make this synchronized, locks things up // animation thread yields to other running threads. final int NO_DELAYS_PER_YIELD = 15; + /* // If size un-initialized, might be a Canvas. Call setSize() here since // we now have a parent object that this Canvas can use as a peer. if (graphics.image == null) { // System.out.format("it's null, sketchW/H already set to %d %d%n", sketchWidth, sketchHeight); - setSize(sketchWidth, sketchHeight); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + setSize(sketchWidth, sketchHeight); + } + }); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } catch (InvocationTargetException ite) { + ite.printStackTrace(); + } // System.out.format(" but now, sketchW/H changed to %d %d%n", sketchWidth, sketchHeight); } + */ // un-pause the sketch and get rolling sketch.start(); @@ -1443,13 +1346,26 @@ public void run() { // not good to make this synchronized, locks things up // } // render a single frame -// if (g != null) { +// try { +// EventQueue.invokeAndWait(new Runnable() { +// public void run() { sketch.handleDraw(); -// } +// EventQueue.invokeLater(new Runnable() { +// public void run() { if (sketch.frameCount == 1) { requestFocus(); } +// } +// }); + +// } +// }); +// } catch (InterruptedException ie) { +// ie.printStackTrace(); +// } catch (InvocationTargetException ite) { +// ite.getTargetException().printStackTrace(); +// } // wait for update & paint to happen before drawing next frame // this is necessary since the drawing is sometimes in a diff --git a/core/todo.txt b/core/todo.txt index 2fa769264e..376e3443f4 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -72,6 +72,12 @@ X added --span option X play with improvements to full screen here +_ split 'present' and 'full screen'? +_ --full-screen causes considerable flicker at this point +_ or split them when sketchWidth/Height are implemented? +_ check on performance of the new EDT setup + + showstoppers _ static sketch with size() produces black window _ are we running on the EDT or not? @@ -82,6 +88,9 @@ _ https://github.com/processing/processing/issues/3113 _ static mode - no setup() / draw() - broken in OpenGL _ https://github.com/processing/processing/issues/3163 +_ sketch window is not placed at correct location on restart +_ https://github.com/processing/processing/issues/3125 + applet/sketch _ performance issues on OS X (might be threading due to Applet) From dce7b5db2dec1eb659a8c360bd4c75996dae7643 Mon Sep 17 00:00:00 2001 From: JayDusara Date: Fri, 10 Apr 2015 11:20:02 +0530 Subject: [PATCH 5/5] merging phase Signed-off-by: JayDusara --- app/src/processing/app/Mode.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/processing/app/Mode.java b/app/src/processing/app/Mode.java index c53dfde792..3d264f5b9e 100644 --- a/app/src/processing/app/Mode.java +++ b/app/src/processing/app/Mode.java @@ -1100,7 +1100,10 @@ public void actionPerformed(ActionEvent e) { } }); - final JTree tree = new JTree(buildSketchbookTree()); + sketchbookFrame.getContentPane().setLayout(new BorderLayout()); + DefaultMutableTreeNode root = buildSketchbookTree(); + model = new DefaultTreeModel(root); + final JTree tree = new JTree(model); tree.getSelectionModel() .setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setShowsRootHandles(true); @@ -1140,6 +1143,10 @@ public void keyTyped(KeyEvent e) { base.handleOpen(sketch.getPath()); } } + + if (e.getKeyChar() == KeyEvent.VK_SPACE) { + rebuildTree(); + } } }); @@ -1152,7 +1159,9 @@ public void keyTyped(KeyEvent e) { JScrollPane treePane = new JScrollPane(tree); treePane.setPreferredSize(new Dimension(250, 450)); treePane.setBorder(new EmptyBorder(0, 0, 0, 0)); - sketchbookFrame.getContentPane().add(treePane); + JLabel refreshLabel = new JLabel("Press SPACE to refresh"); + sketchbookFrame.getContentPane().add(refreshLabel, BorderLayout.SOUTH); + sketchbookFrame.getContentPane().add(treePane, BorderLayout.CENTER); sketchbookFrame.pack(); }