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 247391 - NbBundle hint destroys existing bundles
Summary: NbBundle hint destroys existing bundles
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-23 07:54 UTC by arittner
Modified: 2015-03-26 14:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
ValidatorPanel before invoking the hint (2.12 KB, application/octet-stream)
2014-09-23 07:56 UTC, arittner
Details
Bundle before invoking the hint (1.85 KB, application/octet-stream)
2014-09-23 07:57 UTC, arittner
Details
Bundle after invoking the hint (1.81 KB, application/octet-stream)
2014-09-23 07:58 UTC, arittner
Details
messages.log (35.26 KB, application/octet-stream)
2014-09-23 08:04 UTC, arittner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description arittner 2014-09-23 07:54:16 UTC
The hint to change a NbBundle.getMessage call to Bundle.static destroys existing Bundles.

I've a package with two JPanels the older panel defines many UI elements with old styled bundles (Bundle.properties and Bundle_de.properties).

The second JPanel uses only a NbBundle.getMessage call. I've added key/value pairs to both bundles. All files are saved. I've no code errors. The warning badge on the top right is green.

NetBeans offers a hint to change NbBundle.get Message to a static Bundle-call. Invoking this hint destroys my Bundle.properties and in my Panel nothing is changed.

Before (and after - in my first tests) I call the hint the code in my new JPanel looks like this:

  /**
   * Creates new form ValidatorPanel
   */
  public ValidatorPanel() {
    initComponents();
    em = new ExplorerManager();
    lookup = ExplorerUtils.createLookup(em, getActionMap());
    outlineManager = OutlineManager
            .createRO(
                    VIEW_DATA,
                    ValidatorPanel.class,
                    "1.1",
                    NbBundle.getMessage(ValidatorPanel.class, "ValidatorPanel.ValidateHeader"))
            .rootVisible(false);

    view = outlineManager.getOutlineView();

    add(view, BorderLayout.CENTER);

  }

The Bundle.properties and Bundle_de.properties (before invoking, only a part):

Bundle.properties:

# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

ImportTool.jPN_Validation.border.title=Validation
ImportTool.jRB_Folders.text=...against special Folders
ImportTool.jRB_DupAll.text=...against all imported addresses
ImportTool.jCB_CheckDuplicates.text=Check for duplicates
...

ValidatorPanel.ValidateHeader=Validations

(behind the last entry: new line)

Bundle_de.properties

# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

ImportTool.displayName=Import Werkzeug

ImportTool.jPN_Validation.border.title=Überprüfung
ImportTool.jRB_Folders.text=...gegen spezielle Verzeichnisse
ImportTool.jRB_DupAll.text=...gegen alle Adressen
...

ValidatorPanel.ValidateHeader=Überprüfungsplugins


After invoking the hint, my Bundle.properties:

# To change this license header, choose License Headers in Project Properties.

 To change this template file, choose Tools | Templates

 and open the template in the editor.



portTool.jPN_Validation.border.title=Validation

mportTool.jRB_Folders.text=...against special Folders

mportTool.jRB_DupAll.text=...against all imported addresses

mportTool.jCB_CheckDuplicates.text=Check for duplicates

mportTool.jPN_ImportSettings.border.title=Import settings
...

The ValidatorPanel.ValidateHeader is succefully removed ;)

The Bundle_de.propertie is not changed. 

Funny, now, with my last test to reproduce the problem, my ValidatorPanel.java is changed:

  /**
   * Creates new form ValidatorPanel
   */
  @NbBundle.Messages("ValidatorPanel.ValidateHeader=Validations")
  public ValidatorPanel() {
    initComponents();
    em = new ExplorerManager();
    lookup = ExplorerUtils.createLookup(em, getActionMap());
    outlineManager = OutlineManager
            .createRO(VIEW_DATA,
                    ValidatorPanel.class,
                    "1.1",
                    ValidatorPanel_ValidateHeader())
            .rootVisible(false);

    view = outlineManager.getOutlineView();

    add(view, BorderLayout.CENTER);

  }


I've some exceptions in my IDE log (IMHO related):

javax.swing.text.BadLocationException: Wrong (offset+length)=1722 > getLength()=1720
	at org.netbeans.editor.BaseDocument.handleRemove(BaseDocument.java:957)
	at org.netbeans.editor.BaseDocument$FilterBypassImpl.remove(BaseDocument.java:2493)
	at javax.swing.text.DocumentFilter.remove(DocumentFilter.java:79)
	at org.openide.text.CloneableEditorSupport$DocFilter.remove(CloneableEditorSupport.java:2386)
	at org.netbeans.editor.BaseDocument.remove(BaseDocument.java:937)
	at org.netbeans.api.java.source.ModificationResult.processDocumentLocked(ModificationResult.java:444)
	at org.netbeans.api.java.source.ModificationResult.access$100(ModificationResult.java:97)
	at org.netbeans.api.java.source.ModificationResult$3.run(ModificationResult.java:401)
	at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:356)
	at org.openide.text.NbDocument.runAtomicAsUser(NbDocument.java:462)
	at org.netbeans.api.java.source.ModificationResult.processDocument(ModificationResult.java:415)
Caused: java.io.IOException
	at org.netbeans.api.java.source.ModificationResult.processDocument(ModificationResult.java:421)
	at org.netbeans.api.java.source.ModificationResult.commit2(ModificationResult.java:363)
	at org.netbeans.api.java.source.ModificationResult.access$000(ModificationResult.java:97)
	at org.netbeans.api.java.source.ModificationResult$2.run(ModificationResult.java:265)
	at org.netbeans.editor.GuardedDocument.runAtomic(GuardedDocument.java:323)
	at org.openide.text.NbDocument.runAtomic(NbDocument.java:436)
[catch] at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:262)
	at org.netbeans.api.java.source.ModificationResult.commit(ModificationResult.java:215)
	at org.netbeans.modules.java.hints.spiimpl.JavaFixImpl$1.run(JavaFixImpl.java:106)
	at org.netbeans.modules.java.hints.spiimpl.JavaFixImpl$1.run(JavaFixImpl.java:97)
	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:654)
	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:644)
	at org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:498)
	at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:598)
	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:155)
	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:139)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:206)
	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:203)
	at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:176)
	at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:360)
	at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:74)
	at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:203)
	at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:106)
	at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:448)
Caused: java.io.IOException
	at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:460)
	at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:419)
	at org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:665)
	at org.netbeans.modules.java.hints.spiimpl.JavaFixImpl.implement(JavaFixImpl.java:97)
[catch] at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:837)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1423)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)

br, josh
Comment 1 arittner 2014-09-23 07:56:36 UTC
Created attachment 149446 [details]
ValidatorPanel before invoking the hint
Comment 2 arittner 2014-09-23 07:57:54 UTC
Created attachment 149447 [details]
Bundle before invoking the hint
Comment 3 arittner 2014-09-23 07:58:53 UTC
Created attachment 149448 [details]
Bundle after invoking the hint
Comment 4 arittner 2014-09-23 07:59:24 UTC
Project properties:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
Comment 5 arittner 2014-09-23 08:04:08 UTC
Created attachment 149449 [details]
messages.log
Comment 6 Svata Dedic 2015-03-26 14:23:57 UTC
I was not able to reproduce the defect using neither dev or 8.0.1 version, sorry. If you encounter the deffect again, please try:
1/ revert the files, close them and reopen and try again (= memory state cleaned up)
2/ ZIP the relevant files (all Bundle_ variants + source) and attach to the defect.

Thanks.