This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 123976 - Impossible to add a Library file due to Exception
Summary: Impossible to add a Library file due to Exception
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P2 blocker (vote)
Assignee: Thomas Preisler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-13 19:42 UTC by Alexander Pepin
Modified: 2008-01-15 00:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pepin 2007-12-13 19:42:06 UTC
Steps to reproduce:
- create a new project (e.g. Welcome)
- clean and build it
- call Project Properties->Linker->Libraries
- click on ellipsis button in Libraries property field
- in Libraries window press "Add File Library..." button
- switch "Files of Type" to "All Files" and select welcome.o from build/Debug/Cygwin-Windows directory
Result: Exception window appears
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.AbstractStringBuilder.charAt(AbstractStringBuilder.java:174)
	at java.lang.StringBuilder.charAt(StringBuilder.java:55)
	at org.netbeans.modules.cnd.api.utils.IpeUtils.getRelativePath(IpeUtils.java:165)
	at org.netbeans.modules.cnd.api.utils.IpeUtils.toRelativePath(IpeUtils.java:213)
	at
org.netbeans.modules.cnd.makeproject.configurations.ui.LibrariesPanel$AddLibraryFileButtonAction.actionPerformed(LibrariesPanel.java:341)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
	at java.awt.Component.processMouseEvent(Component.java:6038)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
	at java.awt.Component.processEvent(Component.java:5803)
	at java.awt.Container.processEvent(Container.java:2058)
	at java.awt.Component.dispatchEventImpl(Component.java:4410)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
	at java.awt.Container.dispatchEventImpl(Container.java:2102)
	at java.awt.Window.dispatchEventImpl(Window.java:2429)
	at java.awt.Component.dispatchEvent(Component.java:4240)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:177)
	at java.awt.Dialog$1.run(Dialog.java:1039)
	at java.awt.Dialog$3.run(Dialog.java:1091)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Dialog.show(Dialog.java:1089)
	at org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:834)
	at org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:868)
	at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:856)
	at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:104)
	at org.openide.util.Mutex.doEventAccess(Mutex.java:1223)
	at org.openide.util.Mutex.readAccess(Mutex.java:242)
	at org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:841)
	at java.awt.Component.show(Component.java:1419)
	at java.awt.Component.setVisible(Component.java:1372)
	at java.awt.Window.setVisible(Window.java:801)
	at java.awt.Dialog.setVisible(Dialog.java:979)
	at org.openide.explorer.propertysheet.CustomEditorAction.actionPerformed(CustomEditorAction.java:318)
	at org.openide.explorer.propertysheet.SheetTable.processMouseEvent(SheetTable.java:710)
	at java.awt.Component.processEvent(Component.java:5803)
	at java.awt.Container.processEvent(Container.java:2058)
	at java.awt.Component.dispatchEventImpl(Component.java:4410)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3983)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
	at java.awt.Container.dispatchEventImpl(Container.java:2102)
	at java.awt.Window.dispatchEventImpl(Window.java:2429)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:177)
	at java.awt.Dialog$1.run(Dialog.java:1039)
	at java.awt.Dialog$3.run(Dialog.java:1091)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Dialog.show(Dialog.java:1089)
	at org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:834)
	at org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:868)
	at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:856)
	at org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:104)
	at org.openide.util.Mutex$1AWTWorker.run(Mutex.java:1238)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

The bug is also reproducible in NB 6.0
Comment 1 Thomas Preisler 2008-01-15 00:01:53 UTC
Fixed.
Comment 2 Thomas Preisler 2008-01-15 00:19:54 UTC
File [changed]: AddExistingItemAction.java
Url:
http://cnd.netbeans.org/source/browse/cnd/makeproject/src/org/netbeans/modules/cnd/makeproject/api/actions/AddExistingItemAction.java?r1=1.7&r2=1.8
Delta lines:  +7 -4
-------------------
--- AddExistingItemAction.java	1 Dec 2007 18:23:01 -0000	1.7
+++ AddExistingItemAction.java	15 Jan 2008 00:18:08 -0000	1.8
@@ -42,6 +42,7 @@
 package org.netbeans.modules.cnd.makeproject.api.actions;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.ResourceBundle;
 import org.netbeans.api.project.Project;
 import org.netbeans.api.project.ProjectUtils;
@@ -125,7 +126,7 @@
 	    return;
 
 	File[] files = fileChooser.getSelectedFiles();
-	Item[] items = new Item[files.length];
+        ArrayList<Item> items = new ArrayList<Item>();
 	for (int i = 0; i < files.length; i++) {
 	    String itemPath;
 	    if (PathPanel.getMode() == PathPanel.REL_OR_ABS)
@@ -139,15 +140,17 @@
 	    if (((MakeConfigurationDescriptor)projectDescriptor).findProjectItemByPath(itemPath) != null) {
 		String errormsg = getString("AlreadyInProjectError", itemPath); // NOI18N
 		DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(errormsg, NotifyDescriptor.ERROR_MESSAGE));
-                return;
+                //return;
 	    }
 	    else {
-		folder.addItemAction(items[i] = new Item(itemPath));
+                Item item = new Item(itemPath);
+		folder.addItemAction(item);
+                items.add(item);
 		if (IpeUtils.isPathAbsolute(itemPath))
 		    notifySources = true;
 	    }
 	}
-	MakeLogicalViewProvider.setVisible(project, items);
+	MakeLogicalViewProvider.setVisible(project, items.toArray(new Item[items.size()]));
 
 	if (notifySources)
 	    ((MakeSources)ProjectUtils.getSources(project)).descriptorChanged();
Comment 3 Thomas Preisler 2008-01-15 00:23:08 UTC
File [changed]: LibrariesPanel.java
Url:
http://cnd.netbeans.org/source/browse/cnd/makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/ui/LibrariesPanel.java?r1=1.15&r2=1.16
Delta lines:  +1 -2
-------------------
--- LibrariesPanel.java	27 Sep 2007 23:35:50 -0000	1.15
+++ LibrariesPanel.java	14 Jan 2008 23:54:09 -0000	1.16
@@ -332,8 +332,6 @@
 	    if (ret == JFileChooser.CANCEL_OPTION)
 		return;
 	    String path = fileChooser.getSelectedFile().getPath();
-	    path = FilePathAdaptor.mapToRemote(path);
-	    path = FilePathAdaptor.normalize(path);
 	    // FIXUP: why are baseDir UNIX path when remote?
 	    if (PathPanel.getMode() == PathPanel.REL_OR_ABS)
 		path = IpeUtils.toAbsoluteOrRelativePath(baseDir, path);
@@ -341,6 +339,7 @@
 		path = IpeUtils.toRelativePath(baseDir, path);
 	    else
 		path = path;
+	    path = FilePathAdaptor.mapToRemote(path);
 	    path = FilePathAdaptor.normalize(path);
 	    myListEditorPanel.addObjectAction(new LibraryItem.LibFileItem(path));
 	}