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.

View | Details | Raw Unified | Return to bug 162718
Collapse All | Expand All

(-)a/projectapi/src/org/netbeans/api/project/ProjectManager.java (+8 lines)
Lines 64-69 Link Here
64
import org.openide.filesystems.FileChangeListener;
64
import org.openide.filesystems.FileChangeListener;
65
import org.openide.filesystems.FileEvent;
65
import org.openide.filesystems.FileEvent;
66
import org.openide.filesystems.FileObject;
66
import org.openide.filesystems.FileObject;
67
import org.openide.filesystems.FileRenameEvent;
67
import org.openide.filesystems.FileUtil;
68
import org.openide.filesystems.FileUtil;
68
import org.openide.util.Lookup;
69
import org.openide.util.Lookup;
69
import org.openide.util.LookupEvent;
70
import org.openide.util.LookupEvent;
Lines 717-722 Link Here
717
                dir2Proj.remove(fe.getFile());
718
                dir2Proj.remove(fe.getFile());
718
            }
719
            }
719
        }
720
        }
721
722
        @Override
723
        public void fileRenamed(FileRenameEvent fe) {
724
            synchronized (dir2Proj) {
725
                dir2Proj.remove(fe.getFile());
726
            }
727
        }
720
        
728
        
721
    }
729
    }
722
730
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/Bundle.properties (-1 / +1 lines)
Lines 156-160 Link Here
156
156
157
TITLE_BrowseProjectLocation=Browse Project Location
157
TITLE_BrowseProjectLocation=Browse Project Location
158
LBL_BrowseProjectLocation_OK_Button=OK
158
LBL_BrowseProjectLocation_OK_Button=OK
159
VCSWarningMessage=WARNING: This operation will not copy over hidden files.  If this project is under version control, this operation can delete the metadata required by the version control system you are using.
159
VCSWarningMessage=WARNING: This operation will not copy hidden files. If this project is under version control, the copy may not be versioned.
160
LBL_Pre_Delete_Question=Are you sure you want to delete it?
160
LBL_Pre_Delete_Question=Are you sure you want to delete it?
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectOperationsImplementation.java (-99 / +23 lines)
Lines 80-91 Link Here
80
import org.openide.LifecycleManager;
80
import org.openide.LifecycleManager;
81
import org.openide.NotifyDescriptor;
81
import org.openide.NotifyDescriptor;
82
import org.openide.awt.Mnemonics;
82
import org.openide.awt.Mnemonics;
83
import org.openide.filesystems.FileLock;
83
import org.openide.filesystems.FileObject;
84
import org.openide.filesystems.FileObject;
84
import org.openide.filesystems.FileSystem;
85
import org.openide.filesystems.FileSystem;
85
import org.openide.filesystems.FileUtil;
86
import org.openide.filesystems.FileUtil;
86
import org.openide.loaders.DataFolder;
87
import org.openide.loaders.DataObject;
88
import org.openide.loaders.DataObjectNotFoundException;
89
import org.openide.util.ContextAwareAction;
87
import org.openide.util.ContextAwareAction;
90
import org.openide.util.Mutex;
88
import org.openide.util.Mutex;
91
import org.openide.util.NbBundle;
89
import org.openide.util.NbBundle;
Lines 334-350 Link Here
334
                    newTargetFO = createFolder(newTarget.getParentFile(), newTarget.getName());
332
                    newTargetFO = createFolder(newTarget.getParentFile(), newTarget.getName());
335
                }
333
                }
336
                final FileObject newTgtFO = newTargetFO;
334
                final FileObject newTgtFO = newTargetFO;
337
                project.getProjectDirectory().getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
335
                doMoveProject(handle, project, nueFolderName, nueProjectName, newTgtFO, "ERR_Cannot_Move");
338
                    public void run() throws IOException {
339
                        try {
340
                            doMoveProject(handle, project, nueFolderName, nueProjectName, newTgtFO, "ERR_Cannot_Move");
341
                        } catch (IOException x) {
342
                            throw x;
343
                        } catch (Exception x) {
344
                            throw new IOException(x);
345
                        }
346
                    }
347
                });
348
            }
336
            }
349
        });
337
        });
350
    }
338
    }
Lines 365-390 Link Here
365
                final String nueName = panel.getNewName();
353
                final String nueName = panel.getNewName();
366
                
354
                
367
                if (panel.getRenameProjectFolder()) {
355
                if (panel.getRenameProjectFolder()) {
368
                    project.getProjectDirectory().getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
356
                    doMoveProject(handle, project, nueName, nueName, project.getProjectDirectory().getParent(), "ERR_Cannot_Rename");
369
                        public void run() throws IOException {
370
                            try {
371
                                doMoveProject(handle, project, nueName, nueName, project.getProjectDirectory().getParent(), "ERR_Cannot_Rename");
372
                            } catch (IOException x) {
373
                                throw x;
374
                            } catch (Exception x) {
375
                                throw new IOException(x);
376
                            }
377
                        }
378
                    });
379
                } else {
357
                } else {
380
                    project.getProjectDirectory().getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
358
                    project.getProjectDirectory().getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
381
                        public void run() throws IOException {
359
                        public void run() throws IOException {
382
                            try {
360
                            try {
383
                                doRenameProject(handle, project, nueName);
361
                                doRenameProject(handle, project, nueName);
384
                        } catch (IOException x) {
362
                            } catch (IOException x) {
385
                            throw x;
363
                                throw x;
386
                        } catch (Exception x) {
364
                            } catch (Exception x) {
387
                            throw new IOException(x);
365
                                throw new IOException(x);
388
                            }
366
                            }
389
                        }
367
                        }
390
                    });
368
                    });
Lines 462-508 Link Here
462
            handle.progress((int) (currentWorkDone = totalWork * NOTIFY_WORK));
440
            handle.progress((int) (currentWorkDone = totalWork * NOTIFY_WORK));
463
            
441
            
464
            FileObject projectDirectory = project.getProjectDirectory();
442
            FileObject projectDirectory = project.getProjectDirectory();
465
            List<FileObject> toMoveList = new ArrayList<FileObject>();
443
            
466
            for (FileObject child : projectDirectory.getChildren()) {
444
            double workPerFileAndOperation = totalWork * (1.0 - 2 * NOTIFY_WORK - FIND_PROJECT_WORK);
467
                if (child.isValid()) {
445
468
                    toMoveList.add(child);
446
            FileLock lock = projectDirectory.lock();
469
                }
447
            try {
448
                target = projectDirectory.move(lock, newTarget, nueFolderName, null);
449
            } finally {
450
                lock.releaseLock();
470
            }
451
            }
471
            
452
            // TBD if #109580 matters here: do we need to delete nbproject/private? probably not
472
            double workPerFileAndOperation = (totalWork * (1.0 - 2 * NOTIFY_WORK - FIND_PROJECT_WORK) / toMoveList.size()) / 2;
453
            int lastWorkDone = (int) currentWorkDone;
473
            
474
            target = newTarget.createFolder(nueFolderName);
475
454
476
            for (FileObject toCopy : toMoveList) {
455
            currentWorkDone += workPerFileAndOperation;
477
                doCopy(project, toCopy, target);
456
478
                
457
            if (lastWorkDone < (int) currentWorkDone) {
479
                int lastWorkDone = (int) currentWorkDone;
458
                handle.progress((int) currentWorkDone);
480
                
481
                currentWorkDone += workPerFileAndOperation;
482
                
483
                if (lastWorkDone < (int) currentWorkDone) {
484
                    handle.progress((int) currentWorkDone);
485
                }
486
            }
459
            }
487
            
460
            
488
            originalOK = false;
461
            originalOK = false;
489
            
462
            
490
            for (FileObject toCopy : toMoveList) {
491
                doDelete(project, toCopy);
492
                
493
                int lastWorkDone = (int) currentWorkDone;
494
                
495
                currentWorkDone += workPerFileAndOperation;
496
                
497
                if (lastWorkDone < (int) currentWorkDone) {
498
                    handle.progress((int) currentWorkDone);
499
                }
500
            }
501
            
502
            if (projectDirectory.getChildren().length == 0) {
503
                projectDirectory.delete();
504
            }
505
            
506
            //#64264: the non-project cache can be filled with incorrect data (gathered during the project copy phase), clear it:
463
            //#64264: the non-project cache can be filled with incorrect data (gathered during the project copy phase), clear it:
507
            ProjectManager.getDefault().clearNonProjectCache();
464
            ProjectManager.getDefault().clearNonProjectCache();
508
            Project nue = ProjectManager.getDefault().findProject(target);
465
            Project nue = ProjectManager.getDefault().findProject(target);
Lines 510-516 Link Here
510
            handle.progress((int) (currentWorkDone += totalWork * FIND_PROJECT_WORK));
467
            handle.progress((int) (currentWorkDone += totalWork * FIND_PROJECT_WORK));
511
            
468
            
512
            assert nue != null;
469
            assert nue != null;
513
            
470
            assert nue != project : "got same Project for " + projectDirectory + " and " + target;
471
514
            ProjectOperations.notifyMoved(project, nue, FileUtil.toFile(project.getProjectDirectory()), nueProjectName);
472
            ProjectOperations.notifyMoved(project, nue, FileUtil.toFile(project.getProjectDirectory()), nueProjectName);
515
            
473
            
516
            handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK));
474
            handle.progress((int) (currentWorkDone += totalWork * NOTIFY_WORK));
Lines 577-616 Link Here
577
        }
535
        }
578
    }
536
    }
579
    
537
    
580
    private static boolean doDelete(Project original, FileObject toDelete) throws IOException {
581
        if (!original.getProjectDirectory().equals(FileOwnerQuery.getOwner(toDelete).getProjectDirectory())) {
582
            return false;
583
        }
584
        
585
        if (toDelete.isFolder()) {
586
            boolean delete = true;
587
588
            for (FileObject kid : toDelete.getChildren()) {
589
                delete &= doDelete(original, kid);
590
            }
591
            
592
            if (delete) {
593
                //#83958
594
                DataFolder.findFolder(toDelete).delete();
595
            }
596
            
597
            return delete;
598
        } else {
599
            assert toDelete.isData();
600
            try {
601
                //#83958
602
                DataObject dobj = DataObject.find(toDelete);
603
                dobj.delete();
604
            } catch (DataObjectNotFoundException ex) {
605
                //In case of MultiDataObjects the file may be laready deleted
606
                if (toDelete.isValid()) {                    
607
                    toDelete.delete();
608
                }
609
            }
610
            return true;
611
        }
612
    }
613
    
614
    private static JComponent wrapPanel(JComponent component) {
538
    private static JComponent wrapPanel(JComponent component) {
615
        component.setBorder(new EmptyBorder(12, 12, 12, 12));
539
        component.setBorder(new EmptyBorder(12, 12, 12, 12));
616
        
540
        
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectRenamePanel.form (-21 lines)
Lines 139-165 Link Here
139
        </Constraint>
139
        </Constraint>
140
      </Constraints>
140
      </Constraints>
141
    </Component>
141
    </Component>
142
    <Component class="javax.swing.JTextArea" name="jTextArea1">
143
      <Properties>
144
        <Property name="columns" type="int" value="20"/>
145
        <Property name="editable" type="boolean" value="false"/>
146
        <Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
147
          <Connection code="UIManager.getColor(&quot;nb.errorForeground&quot;)" type="code"/>
148
        </Property>
149
        <Property name="lineWrap" type="boolean" value="true"/>
150
        <Property name="rows" type="int" value="5"/>
151
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
152
          <ResourceString bundle="org/netbeans/modules/project/uiapi/Bundle.properties" key="VCSWarningMessage" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
153
        </Property>
154
        <Property name="wrapStyleWord" type="boolean" value="true"/>
155
        <Property name="opaque" type="boolean" value="false"/>
156
      </Properties>
157
      <Constraints>
158
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
159
          <GridBagConstraints gridX="0" gridY="5" gridWidth="2" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="8" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
160
        </Constraint>
161
      </Constraints>
162
    </Component>
163
    <Container class="javax.swing.JPanel" name="progress">
142
    <Container class="javax.swing.JPanel" name="progress">
164
      <Constraints>
143
      <Constraints>
165
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
144
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/DefaultProjectRenamePanel.java (-19 lines)
Lines 110-116 Link Here
110
        alsoRenameFolder = new javax.swing.JCheckBox();
110
        alsoRenameFolder = new javax.swing.JCheckBox();
111
        jLabel3 = new javax.swing.JLabel();
111
        jLabel3 = new javax.swing.JLabel();
112
        errorMessage = new javax.swing.JLabel();
112
        errorMessage = new javax.swing.JLabel();
113
        jTextArea1 = new javax.swing.JTextArea();
114
        progress = new javax.swing.JPanel();
113
        progress = new javax.swing.JPanel();
115
        jPanel4 = new javax.swing.JPanel();
114
        jPanel4 = new javax.swing.JPanel();
116
        progressImpl = new javax.swing.JPanel();
115
        progressImpl = new javax.swing.JPanel();
Lines 192-214 Link Here
192
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
191
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
193
        add(errorMessage, gridBagConstraints);
192
        add(errorMessage, gridBagConstraints);
194
193
195
        jTextArea1.setColumns(20);
196
        jTextArea1.setEditable(false);
197
        jTextArea1.setForeground(UIManager.getColor("nb.errorForeground"));
198
        jTextArea1.setLineWrap(true);
199
        jTextArea1.setRows(5);
200
        jTextArea1.setText(org.openide.util.NbBundle.getMessage(DefaultProjectRenamePanel.class, "VCSWarningMessage")); // NOI18N
201
        jTextArea1.setWrapStyleWord(true);
202
        jTextArea1.setOpaque(false);
203
        gridBagConstraints = new java.awt.GridBagConstraints();
204
        gridBagConstraints.gridx = 0;
205
        gridBagConstraints.gridy = 5;
206
        gridBagConstraints.gridwidth = 2;
207
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
208
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
209
        gridBagConstraints.insets = new java.awt.Insets(8, 0, 0, 0);
210
        add(jTextArea1, gridBagConstraints);
211
212
        progress.setLayout(new java.awt.CardLayout());
194
        progress.setLayout(new java.awt.CardLayout());
213
        progress.add(jPanel4, "not-progress");
195
        progress.add(jPanel4, "not-progress");
214
196
Lines 260-266 Link Here
260
    private javax.swing.JLabel jLabel5;
242
    private javax.swing.JLabel jLabel5;
261
    private javax.swing.JPanel jPanel3;
243
    private javax.swing.JPanel jPanel3;
262
    private javax.swing.JPanel jPanel4;
244
    private javax.swing.JPanel jPanel4;
263
    private javax.swing.JTextArea jTextArea1;
264
    private javax.swing.JPanel progress;
245
    private javax.swing.JPanel progress;
265
    private javax.swing.JPanel progressImpl;
246
    private javax.swing.JPanel progressImpl;
266
    private javax.swing.JTextField projectFolder;
247
    private javax.swing.JTextField projectFolder;
(-)a/projectuiapi/src/org/netbeans/modules/project/uiapi/ProjectCopyPanel.java (+1 lines)
Lines 87-92 Link Here
87
        if (isMove) {
87
        if (isMove) {
88
            nameLabel.setVisible(false);
88
            nameLabel.setVisible(false);
89
            projectName.setVisible(false);
89
            projectName.setVisible(false);
90
            warningTextArea.setVisible(false);
90
        }
91
        }
91
        
92
        
92
        if (Boolean.getBoolean("org.netbeans.modules.project.uiapi.DefaultProjectOperations.showProgress")) {
93
        if (Boolean.getBoolean("org.netbeans.modules.project.uiapi.DefaultProjectOperations.showProgress")) {

Return to bug 162718