diff --git a/cnd.makeproject/test/unit/data/org/netbeans/modules/cnd/makeproject/Project_65_Test/makeproj-with-links/real_dir1/file2.c b/cnd.makeproject/test/unit/data/org/netbeans/modules/cnd/makeproject/Project_65_Test/makeproj-with-links/real_dir1/file2.c old mode 120000 new mode 100644 --- a/cnd.makeproject/test/unit/data/org/netbeans/modules/cnd/makeproject/Project_65_Test/makeproj-with-links/real_dir1/file2.c +++ b/cnd.makeproject/test/unit/data/org/netbeans/modules/cnd/makeproject/Project_65_Test/makeproj-with-links/real_dir1/file2.c @@ -1,1 +1,3 @@ -../real_dir2/file2.c \ No newline at end of file +int foo() { + return 2; +} diff --git a/subversion/src/org/netbeans/modules/subversion/ui/commit/Bundle.properties b/subversion/src/org/netbeans/modules/subversion/ui/commit/Bundle.properties --- a/subversion/src/org/netbeans/modules/subversion/ui/commit/Bundle.properties +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/Bundle.properties @@ -179,4 +179,10 @@ LBL_Advanced=&Advanced: LBL_CommitDialog_FilesToCommit=&Files to Commit: -LBL_ResolvingConflicts=Resolving Conflicts... \ No newline at end of file +LBL_ResolvingConflicts=Resolving Conflicts... + +#popup for commit message +CTL_MenuItem_SelectAll=Select &All (-a) +CTL_MenuItem_Cut=Cu&t (-x) +CTL_MenuItem_Copy=Cop&y (-c) +CTL_MenuItem_Paste=&Paste (-v) \ No newline at end of file diff --git a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitMessageMouseAdapter.java b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitMessageMouseAdapter.java new file mode 100644 --- /dev/null +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitMessageMouseAdapter.java @@ -0,0 +1,103 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.subversion.ui.commit; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.KeyStroke; +import javax.swing.text.JTextComponent; +import org.openide.actions.CopyAction; +import org.openide.actions.CutAction; +import org.openide.actions.PasteAction; +import org.openide.util.actions.CallbackSystemAction; +import org.openide.util.actions.SystemAction; + +/** + * Mouse adapter for the commit message component. + * + * @author Mario Schroeder + */ +public class CommitMessageMouseAdapter extends MouseAdapter { + + private CommitPopupBuilder popupBuilder; + + /** + * Creates a new context popupMenu for a text component. + * @param textComponent + */ + public CommitMessageMouseAdapter() { + + popupBuilder = new CommitPopupBuilder(); + } + + @Override + public void mousePressed(MouseEvent e) { + + if (e.getModifiers() == InputEvent.BUTTON3_MASK) { + show(e.getComponent(), e.getX(), e.getY()); + } + } + + /** + * Shows the popup popupMenu if the invoker is a instance of JTextComponent. + */ + private void show(Component invoker, int x, int y) { + + //to avoid class cast exception in action listener + if (invoker instanceof JTextComponent) { + JTextComponent textComponent = (JTextComponent)invoker; + JPopupMenu popupMenu = popupBuilder.getPopup(textComponent); + popupMenu.setInvoker(invoker); + popupMenu.show(invoker, x, y); + } + } + + + +} diff --git a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java --- a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPanel.java @@ -373,6 +373,7 @@ jScrollPane1.setViewportView(messageTextArea); messageTextArea.getAccessibleContext().setAccessibleName(getMessage("ACSN_CommitForm_Message")); // NOI18N messageTextArea.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_CommitForm_Message")); // NOI18N + messageTextArea.addMouseListener(new CommitMessageMouseAdapter()); Mnemonics.setLocalizedText(filesSectionButton, getMessage("LBL_CommitDialog_FilesToCommit")); // NOI18N Mnemonics.setLocalizedText(filesLabel, getMessage("CTL_CommitForm_FilesToCommit")); // NOI18N diff --git a/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPopupBuilder.java b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPopupBuilder.java new file mode 100644 --- /dev/null +++ b/subversion/src/org/netbeans/modules/subversion/ui/commit/CommitPopupBuilder.java @@ -0,0 +1,155 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.subversion.ui.commit; + +import java.awt.Toolkit; +import java.awt.datatransfer.DataFlavor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.KeyStroke; +import javax.swing.text.JTextComponent; +import org.openide.awt.Mnemonics; +import org.openide.util.NbBundle; + +/** + * Builder for the popup menu. + * + * @author Mario Schroeder + */ +class CommitPopupBuilder { + + private JPopupMenu popupPresenter; + + private JMenuItem cutMenuItem; + + private JMenuItem copyMenuItem; + + private JMenuItem pasteMenuItem; + + private JMenuItem selectAllMenuItem; + + private PopupActionListener actionListener; + + CommitPopupBuilder() { + + build(); + } + + /** + * This method builds the popup menu. + */ + private void build() { + + actionListener = new PopupActionListener(); + + popupPresenter = new JPopupMenu(); + + cutMenuItem = createMenuItem("CTL_MenuItem_Cut"); + copyMenuItem = createMenuItem("CTL_MenuItem_Copy"); + pasteMenuItem = createMenuItem("CTL_MenuItem_Paste"); + selectAllMenuItem = createMenuItem("CTL_MenuItem_SelectAll"); + + popupPresenter.add(cutMenuItem); + popupPresenter.add(copyMenuItem); + popupPresenter.add(pasteMenuItem); + popupPresenter.addSeparator(); + popupPresenter.add(selectAllMenuItem); + + } + + JPopupMenu getPopup(JTextComponent component) { + + boolean textSelected = component.getSelectedText() != null; + cutMenuItem.setEnabled(textSelected); + copyMenuItem.setEnabled(textSelected); + + boolean hasClipboardText = Toolkit.getDefaultToolkit().getSystemClipboard() + .isDataFlavorAvailable(DataFlavor.stringFlavor); + pasteMenuItem.setEnabled(hasClipboardText); + + return popupPresenter; + } + + /** + * Creates a new menu item. + * @param msgKey key for the message within resource bundle. + * @param key key for the accelerator + * @return a new menu item + */ + private JMenuItem createMenuItem(String msgKey) { + + JMenuItem item = new JMenuItem(); + String msg = NbBundle.getMessage(getClass(), msgKey); + Mnemonics.setLocalizedText(item, msg); + item.addActionListener(actionListener); + return item; + } + + /** + * Action listener for menu items. + */ + private class PopupActionListener implements ActionListener { + + @Override + public void actionPerformed(ActionEvent evt) { + Object source = evt.getSource(); + JTextComponent textComponent = (JTextComponent) popupPresenter.getInvoker(); + if (source == cutMenuItem) { + textComponent.cut(); + } + else if (source == copyMenuItem) { + textComponent.copy(); + } + else if (source == pasteMenuItem) { + textComponent.paste(); + } + else if (source == selectAllMenuItem) { + textComponent.selectAll(); + } + } + + } + +}