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 123716 - project system should issue warning if saving an older project version
Summary: project system should issue warning if saving an older project version
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Thomas Preisler
URL:
Keywords:
: 114036 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-12-10 06:18 UTC by Thomas Preisler
Modified: 2008-01-23 05:54 UTC (History)
1 user (show)

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 Thomas Preisler 2007-12-10 06:18:43 UTC
The problem is the project system *silently* upgrades the project version to current version when the project is modified and it may come as a surprise to the 
user that the project cannot no longer be opened in older IDEs. And the user will find out after he has modified the project and there is no going back.
Comment 1 Thomas Preisler 2007-12-10 20:48:05 UTC
From Douglas:

I agree that at a minimum the IDE should issue a warning and allow the
user to abort/quit without overwriting the old versioned meta data.
I can understand your skepticism about the value of saving meta
data in old formats.  Do you think it would be worthwhile to move
the old versioned meta data aside prior to writing out the new
meta data?

What I mean by that, is when meta data is about to be written out with
a new version number, first move the meta data with the old version
number aside and issue a message indicating where it has been placed.
This would give the user the ability to recover and use an older version
of the IDE by restoring this meta data, without creating a lot of
overhead for the IDE project to maintain old meta data versions.

Is it feasible to move/save the old meta data?
Comment 2 Thomas Preisler 2007-12-21 18:30:10 UTC
*** Issue 114036 has been marked as a duplicate of this issue. ***
Comment 3 Thomas Preisler 2008-01-23 05:45:24 UTC
Now issuing a warning stating:

Saving your changes will upgrade the project to the current project version.\n\n\
Would you like to continue?\n\n\
If you choose Yes, the project will be upgraded to the current version and the project can no longer be opened with the earlier version of the IDE. \
If you choose No, your changes will be lost.

if about to save project in newer format. 
Comment 4 Thomas Preisler 2008-01-23 05:54:50 UTC
File [changed]: MakeCustomizerProvider.java
Url: http://cnd.netbeans.org/source/browse/cnd/makeproject/src/org/netbeans/modules/cnd/makeproject/api/MakeCustomizerProvider.java?
r1=1.14&r2=1.15
Delta lines:  +23 -0
--------------------
--- MakeCustomizerProvider.java	27 Sep 2007 23:48:27 -0000	1.14
+++ MakeCustomizerProvider.java	23 Jan 2008 05:50:56 -0000	1.15
@@ -46,6 +46,7 @@
 import java.awt.event.ActionListener;
 import java.text.MessageFormat;
 import java.util.Map;
+import java.util.ResourceBundle;
 import java.util.Vector;
 import java.util.WeakHashMap;
 import javax.swing.JButton;
@@ -58,10 +59,12 @@
 import org.netbeans.modules.cnd.makeproject.api.configurations.Folder;
 import org.netbeans.modules.cnd.makeproject.api.configurations.Item;
 import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor;
+import org.netbeans.modules.cnd.makeproject.configurations.CommonConfigurationXMLCodec;
 import org.netbeans.modules.cnd.makeproject.ui.customizer.MakeCustomizer;
 import org.netbeans.spi.project.ui.CustomizerProvider;
 import org.openide.DialogDescriptor;
 import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
 import org.openide.util.NbBundle;
 import org.openide.util.RequestProcessor;
 
@@ -214,6 +217,16 @@
             String command = e.getActionCommand();
             
             if (command.equals(COMMAND_OK) || command.equals(COMMAND_APPLY)) {
+                int previousVersion = projectDescriptor.getVersion();
+                int currentVersion = CommonConfigurationXMLCodec.CURRENT_VERSION;
+                if (previousVersion < currentVersion) {                                           
+                    String txt = getString("UPGRADE_TXT");
+                    NotifyDescriptor d = new NotifyDescriptor.Confirmation(txt, getString("UPGRADE_DIALOG_TITLE"), NotifyDescriptor.YES_NO_OPTION); // 
NOI18N
+                    if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.YES_OPTION) {
+                        return;
+                    }
+                }
+                
 		//projectDescriptor.copyFromProjectDescriptor(clonedProjectdescriptor);
 		projectDescriptor.assign(clonedProjectdescriptor);
 		projectDescriptor.setModified();
@@ -233,5 +246,15 @@
 		makeCustomizer.refresh();
 	    }
         }        
+    }
+    
+    
+    /** Look up i18n strings here */
+    private static ResourceBundle bundle;
+    private static String getString(String s) {
+        if (bundle == null) {
+            bundle = NbBundle.getBundle(MakeCustomizerProvider.class);
+        }
+        return bundle.getString(s);
     }
 }

File [changed]: Bundle.properties
Url: http://cnd.netbeans.org/source/browse/cnd/makeproject/src/org/netbeans/modules/cnd/makeproject/api/Bundle.properties?r1=1.11&r2=1.12
Delta lines:  +7 -0
-------------------
--- Bundle.properties	1 Oct 2007 08:55:08 -0000	1.11
+++ Bundle.properties	23 Jan 2008 05:50:56 -0000	1.12
@@ -105,3 +105,10 @@
 
 #DefaultprojectActionHandler
 SELECT_EXECUTABLE=Select Executable
+
+#Upgrade Dialog
+UPGRADE_TXT=Saving your changes will upgrade the project to the current project version.\n\n\
+Would you like to continue?\n\n\
+If you choose Yes, the project will be upgraded to the current version and the project can no longer be opened with the earlier version of the IDE. \
+If you choose No, your changes will be lost.
+UPGRADE_DIALOG_TITLE=Upgrade Project

Directory: /cnd/makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/
====================================================================================

File [changed]: CommonConfigurationXMLCodec.java
Url: 
http://cnd.netbeans.org/source/browse/cnd/makeproject/src/org/netbeans/modules/cnd/makeproject/configurations/CommonConfigurationXMLCodec.j
ava?r1=1.16&r2=1.17
Delta lines:  +2 -2
-------------------
--- CommonConfigurationXMLCodec.java	10 Oct 2007 21:49:54 -0000	1.16
+++ CommonConfigurationXMLCodec.java	23 Jan 2008 05:50:56 -0000	1.17
@@ -95,11 +95,11 @@
  * V29:
  *   added FORTRANCOMPILERTOOL_ELEMENT
  */
-abstract class CommonConfigurationXMLCodec
+public abstract class CommonConfigurationXMLCodec
     extends XMLDecoder
     implements XMLEncoder {
 
-    protected final static int CURRENT_VERSION = 39;
+    public final static int CURRENT_VERSION = 39;
 
     // Generic
     protected final static String PROJECT_DESCRIPTOR_ELEMENT = "projectDescriptor"; // NOI18N