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 138749
Collapse All | Expand All

(-)a/deployment.deviceanywhere/src/org/netbeans/modules/deployment/deviceanywhere/DeviceAnywhereDeploymentPlugin.java (-1 / +2 lines)
Lines 50-55 import java.util.Collections; Link Here
50
import java.util.Collections;
50
import java.util.Collections;
51
import java.util.HashMap;
51
import java.util.HashMap;
52
import java.util.Map;
52
import java.util.Map;
53
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
53
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
54
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
54
import org.openide.util.NbBundle;
55
import org.openide.util.NbBundle;
55
import org.netbeans.spi.mobility.deployment.DeploymentPlugin;
56
import org.netbeans.spi.mobility.deployment.DeploymentPlugin;
Lines 120-126 public class DeviceAnywhereDeploymentPlu Link Here
120
        return new DeviceAnywhereGlobalCustomizerPanel();
121
        return new DeviceAnywhereGlobalCustomizerPanel();
121
    }
122
    }
122
123
123
    public void initValues(ProjectProperties props, String configuration) {
124
    public void initValues(MultiRootProjectProperties props, String configuration) {
124
        this.props = props;
125
        this.props = props;
125
        this.configuration = configuration;
126
        this.configuration = configuration;
126
    }
127
    }
(-)a/j2me.cdc.project.bdj/src/org/netbeans/modules/j2me/cdc/project/bdj/BDJProjectCategoryCustomizer.java (-3 / +2 lines)
Lines 44-51 import java.io.File; Link Here
44
import java.io.File;
44
import java.io.File;
45
import javax.swing.JFileChooser;
45
import javax.swing.JFileChooser;
46
import javax.swing.JPanel;
46
import javax.swing.JPanel;
47
import javax.swing.filechooser.FileFilter;
47
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
48
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
49
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
48
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
50
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
49
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
51
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
50
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
Lines 70-76 public class BDJProjectCategoryCustomize Link Here
70
        initComponents();
69
        initComponents();
71
    }
70
    }
72
71
73
    public void initValues(ProjectProperties props, String configuration) {
72
    public void initValues(MultiRootProjectProperties props, String configuration) {
74
        vps = VisualPropertySupport.getDefault(props);
73
        vps = VisualPropertySupport.getDefault(props);
75
        vps.register(jCheckBox1, configuration, this);
74
        vps.register(jCheckBox1, configuration, this);
76
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
75
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
(-)a/j2me.cdc.project.execui/src/org/netbeans/modules/j2me/cdc/project/execui/MainClassChooser.java (-2 / +20 lines)
Lines 50-62 import org.openide.filesystems.FileObjec Link Here
50
 */
50
 */
51
public abstract class MainClassChooser extends JPanel {
51
public abstract class MainClassChooser extends JPanel {
52
52
53
53
    /**
54
    /**
54
     * Inicialize MainClassChooser to be able to search for main classes
55
     * Initialize MainClassChooser to be able to search for main classes
56
     * @deprecated Use initialize (FileObject[] ...) instead
55
     * @param sourceRoot
57
     * @param sourceRoot
56
     * @param executionModes
58
     * @param executionModes
57
     * @param bootcp
59
     * @param bootcp
58
     */
60
     */
59
    public abstract void inicialize(FileObject sourceRoot, Map<String, String> executionModes, String bootcp);
61
    @Deprecated
62
    public void inicialize(FileObject sourceRoot, Map<String, String> executionModes, String bootcp) {
63
        initialize (new FileObject[] { sourceRoot }, executionModes, bootcp);
64
    }
65
66
    /**
67
     * Initialize MainClassChooser to be able to search for main classes
68
     * @param sourceRoot
69
     * @param executionModes
70
     * @param bootcp
71
     */
72
    public void initialize(FileObject[] sourceRoots, Map<String, String> executionModes, String bootcp) {
73
        //For bw compatibility, need some implementation.  Will not be
74
        //called if an old subclass overrides the formerly abstract 
75
        //inicialize(). -Tim
76
        throw new UnsupportedOperationException("Not implemented");
77
    }
60
    
78
    
61
    /**
79
    /**
62
     * Sets the main class(-es). If more than one main class is selected (applies only for Xlets), then they are divided by ';'
80
     * Sets the main class(-es). If more than one main class is selected (applies only for Xlets), then they are divided by ';'
(-)a/j2me.cdc.project.execuiimpl/src/org/netbeans/modules/j2me/cdc/project/execuiimpl/MainClassChooserImpl.java (-14 / +28 lines)
Lines 102-108 public class MainClassChooserImpl extend Link Here
102
    protected ChangeListener changeListener;
102
    protected ChangeListener changeListener;
103
    private String dialogSubtitle = null;
103
    private String dialogSubtitle = null;
104
    protected List<String> possibleMainClasses;
104
    protected List<String> possibleMainClasses;
105
    private FileObject sourcesRoot;
105
    private FileObject[] sourceRoots;
106
    private String bcp;
106
    private String bcp;
107
    protected boolean onlyMain;
107
    protected boolean onlyMain;
108
    protected String mainClass;
108
    protected String mainClass;
Lines 117-128 public class MainClassChooserImpl extend Link Here
117
    }
117
    }
118
118
119
    @Override
119
    @Override
120
    public void inicialize(FileObject sourceRoot, Map<String, String> executionModes, String bootcp) {
120
    public void initialize(FileObject[] sourceRoots, Map<String, String> executionModes, String bootcp) {
121
        dialogSubtitle = null;
121
        dialogSubtitle = null;
122
        this.sourcesRoot = sourceRoot;
122
        this.sourceRoots = sourceRoots;
123
        this.onlyMain = false;
123
        this.onlyMain = false;
124
        this.executionModes = executionModes;
124
        this.executionModes = executionModes;
125
        initClassesView (sourcesRoot);
125
        initClassesView (sourceRoots);
126
        if (onlyMain)
126
        if (onlyMain)
127
            onlymainLabel.setText(NbBundle.getMessage(MainClassChooserImpl.class, "MSG_OnlyMainAllowed"));
127
            onlymainLabel.setText(NbBundle.getMessage(MainClassChooserImpl.class, "MSG_OnlyMainAllowed"));
128
        bcp=bootcp;
128
        bcp=bootcp;
Lines 130-136 public class MainClassChooserImpl extend Link Here
130
        specialExecFqnApplet = (executionModes != null) ? executionModes.get(CDCPlatform.PROP_EXEC_APPLET)  : null;        
130
        specialExecFqnApplet = (executionModes != null) ? executionModes.get(CDCPlatform.PROP_EXEC_APPLET)  : null;        
131
    }
131
    }
132
    
132
    
133
    private void initClassesView (final FileObject sourcesRoot) {
133
    private void initClassesView (final FileObject[] sourceRoots) {
134
        possibleMainClasses = null;
134
        possibleMainClasses = null;
135
        jMainClassList.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
135
        jMainClassList.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
136
        jMainClassList.setListData (getWarmupList ());
136
        jMainClassList.setListData (getWarmupList ());
Lines 161-167 public class MainClassChooserImpl extend Link Here
161
        
161
        
162
        RequestProcessor.getDefault ().post (new Runnable () {
162
        RequestProcessor.getDefault ().post (new Runnable () {
163
            public void run () {
163
            public void run () {
164
                possibleMainClasses = getMainClasses (new FileObject[] {sourcesRoot}, executionModes,bcp);
164
                possibleMainClasses = getMainClasses (sourceRoots, executionModes,bcp);
165
                if (possibleMainClasses.isEmpty ()) {                    
165
                if (possibleMainClasses.isEmpty ()) {                    
166
                    SwingUtilities.invokeLater( new Runnable () {
166
                    SwingUtilities.invokeLater( new Runnable () {
167
                        public void run () {
167
                        public void run () {
Lines 177-183 public class MainClassChooserImpl extend Link Here
177
                                final List<String> l = new ArrayList<String>(possibleMainClasses);
177
                                final List<String> l = new ArrayList<String>(possibleMainClasses);
178
                                for (Iterator<String> it = l.iterator(); it.hasNext();) {
178
                                for (Iterator<String> it = l.iterator(); it.hasNext();) {
179
                                    String elem = it.next();
179
                                    String elem = it.next();
180
                                    if (!isMainClass(elem, sourcesRoot) || (executionModes != null && executionModes.containsKey(CDCPlatform.PROP_EXEC_MAIN))){
180
                                    if (!isMainClass(elem, sourceRoots) || (executionModes != null && executionModes.containsKey(CDCPlatform.PROP_EXEC_MAIN))){
181
                                        it.remove();
181
                                        it.remove();
182
                                    }   
182
                                    }   
183
                                }
183
                                }
Lines 197-203 public class MainClassChooserImpl extend Link Here
197
                            boolean xlet = false;
197
                            boolean xlet = false;
198
                            if (!possibleMainClasses.isEmpty()){
198
                            if (!possibleMainClasses.isEmpty()){
199
                                for (String elem : possibleMainClasses) {
199
                                for (String elem : possibleMainClasses) {
200
                                    if (isXletClass(elem, sourcesRoot, specialExecFqnXlet)){
200
                                    if (isXletClass(elem, sourceRoots[0], specialExecFqnXlet)){
201
                                        xlet = true;
201
                                        xlet = true;
202
                                        break;
202
                                        break;
203
                                    }
203
                                    }
Lines 260-268 public class MainClassChooserImpl extend Link Here
260
            {
260
            {
261
                public void run()
261
                public void run()
262
                {
262
                {
263
                    isMain[0] = isMainClass(mainClass, sourcesRoot);
263
                    isMain[0] = isMainClass(mainClass, sourceRoots);
264
                    isXlet[0] = isXletClass(mainClass, sourcesRoot, specialExecFqnXlet);
264
                    isXlet[0] = isXletClass(mainClass, sourceRoots[0], specialExecFqnXlet);
265
                    isApplet[0] = isAppletClass(mainClass, sourcesRoot, specialExecFqnApplet);
265
                    isApplet[0] = isAppletClass(mainClass, sourceRoots[0], specialExecFqnApplet);
266
                }
266
                }
267
            });
267
            });
268
            task.waitFinished();
268
            task.waitFinished();
Lines 490-501 public class MainClassChooserImpl extend Link Here
490
    }//GEN-LAST:event_multipleXletsActionPerformed
490
    }//GEN-LAST:event_multipleXletsActionPerformed
491
491
492
    protected String[] updateListView(final boolean onlyXlets) {
492
    protected String[] updateListView(final boolean onlyXlets) {
493
        if (onlyXlets){
493
        if (onlyXlets && sourceRoots.length > 0){
494
            jMainClassList.setSelectionMode (ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
494
            jMainClassList.setSelectionMode (ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
495
            List<String> l = new ArrayList<String>(possibleMainClasses);
495
            List<String> l = new ArrayList<String>(possibleMainClasses);
496
            for (Iterator<String> it = l.iterator(); it.hasNext();) {
496
            for (Iterator<String> it = l.iterator(); it.hasNext();) {
497
                String elem = it.next();
497
                String elem = it.next();
498
                if (!isXletClass(elem, sourcesRoot, specialExecFqnXlet)){
498
                if (!isXletClass(elem, sourceRoots[0], specialExecFqnXlet)){
499
                    it.remove();
499
                    it.remove();
500
                }
500
                }
501
            }
501
            }
Lines 709-714 public class MainClassChooserImpl extend Link Here
709
            ex.printStackTrace();
709
            ex.printStackTrace();
710
        }
710
        }
711
    }
711
    }
712
713
    private FileObject rootOf (FileObject test) {
714
        for (FileObject root : sourceRoots) {
715
            if (FileUtil.isParentOf(root, test)) {
716
                return root;
717
            }
718
        }
719
        throw new AssertionError (test.getPath() + " not a child of source " +
720
                "roots " + Arrays.asList(sourceRoots));
721
    }
712
    
722
    
713
    /** Returns if the given class name exists under the sources root and
723
    /** Returns if the given class name exists under the sources root and
714
     * it's a main class.
724
     * it's a main class.
Lines 717-723 public class MainClassChooserImpl extend Link Here
717
     * @param root roots of sources
727
     * @param root roots of sources
718
     * @return true if the class name exists and it's a main class
728
     * @return true if the class name exists and it's a main class
719
     */
729
     */
720
    public static boolean isMainClass(String className, FileObject root) {
730
    public static boolean isMainClass(String className, FileObject[] roots) {
731
        if (roots.length == 0) {
732
            return false;
733
        }
734
        FileObject root = roots[0];
721
        ClassPath boot = ClassPath.getClassPath (root, ClassPath.BOOT);  //Single compilation unit
735
        ClassPath boot = ClassPath.getClassPath (root, ClassPath.BOOT);  //Single compilation unit
722
        ClassPath rtm2  = ClassPath.getClassPath (root, ClassPath.EXECUTE);  //Single compilation unit'
736
        ClassPath rtm2  = ClassPath.getClassPath (root, ClassPath.EXECUTE);  //Single compilation unit'
723
        ClassPath rtm1 = ClassPath.getClassPath (root, ClassPath.COMPILE);
737
        ClassPath rtm1 = ClassPath.getClassPath (root, ClassPath.COMPILE);
(-)a/j2me.cdc.project.nokiaS80/src/org/netbeans/modules/j2me/cdc/project/nokiaS80/NokiaS80ProjectCategoryCustomizer.java (-2 / +2 lines)
Lines 46-52 import javax.swing.JPanel; Link Here
46
import javax.swing.JPanel;
46
import javax.swing.JPanel;
47
import javax.swing.JTextField;
47
import javax.swing.JTextField;
48
import javax.swing.filechooser.FileFilter;
48
import javax.swing.filechooser.FileFilter;
49
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
49
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
50
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
50
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
51
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
51
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
52
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
52
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
Lines 71-77 public class NokiaS80ProjectCategoryCust Link Here
71
        initComponents();
71
        initComponents();
72
    }
72
    }
73
73
74
    public void initValues(ProjectProperties props, String configuration) {
74
    public void initValues(MultiRootProjectProperties props, String configuration) {
75
        vps = VisualPropertySupport.getDefault(props);
75
        vps = VisualPropertySupport.getDefault(props);
76
        vps.register(jCheckBox1, configuration, this);
76
        vps.register(jCheckBox1, configuration, this);
77
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
77
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
(-)a/j2me.cdc.project.nsicom/src/org/netbeans/modules/j2me/cdc/project/nsicom/NSIcomProjectCategoryCustomizer.java (-2 / +2 lines)
Lines 51-57 import java.beans.PropertyChangeListener Link Here
51
import java.beans.PropertyChangeListener;
51
import java.beans.PropertyChangeListener;
52
import javax.swing.JPanel;
52
import javax.swing.JPanel;
53
import javax.swing.UIManager;
53
import javax.swing.UIManager;
54
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
54
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
55
import org.netbeans.mobility.activesync.ActiveSyncOps;
55
import org.netbeans.mobility.activesync.ActiveSyncOps;
56
import org.netbeans.mobility.activesync.DeviceConnectedListener;
56
import org.netbeans.mobility.activesync.DeviceConnectedListener;
57
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
57
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 360-366 public class NSIcomProjectCategoryCustom Link Here
360
        }        
360
        }        
361
    }
361
    }
362
362
363
    public void initValues(ProjectProperties props, String configuration) {
363
    public void initValues(MultiRootProjectProperties props, String configuration) {
364
        vps = VisualPropertySupport.getDefault(props);
364
        vps = VisualPropertySupport.getDefault(props);
365
        vps.register(jCheckBox1, configuration, this);
365
        vps.register(jCheckBox1, configuration, this);
366
    }
366
    }
(-)a/j2me.cdc.project.ricoh/src/org/netbeans/modules/j2me/cdc/project/ricoh/RicohProjectCategoryCustomizer.java (-4 / +2 lines)
Lines 50-64 import java.beans.PropertyChangeListener Link Here
50
import java.beans.PropertyChangeListener;
50
import java.beans.PropertyChangeListener;
51
import java.io.File;
51
import java.io.File;
52
import javax.swing.JButton;
52
import javax.swing.JButton;
53
import javax.xml.parsers.*;
54
import javax.swing.JFileChooser;
53
import javax.swing.JFileChooser;
55
import javax.swing.JPanel;
54
import javax.swing.JPanel;
56
import javax.swing.JTextField;
55
import javax.swing.JTextField;
57
import javax.swing.filechooser.FileFilter;
56
import javax.swing.filechooser.FileFilter;
58
import javax.swing.event.*;
59
import org.netbeans.api.java.platform.JavaPlatform;
57
import org.netbeans.api.java.platform.JavaPlatform;
60
import org.netbeans.api.java.platform.JavaPlatformManager;
58
import org.netbeans.api.java.platform.JavaPlatformManager;
61
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
59
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
62
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
60
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
63
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
61
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
64
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
62
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
Lines 97-103 public class RicohProjectCategoryCustomi Link Here
97
    }
95
    }
98
96
99
97
100
    public void initValues(ProjectProperties props, String configuration) {
98
    public void initValues(MultiRootProjectProperties props, String configuration) {
101
        vps = VisualPropertySupport.getDefault(props);
99
        vps = VisualPropertySupport.getDefault(props);
102
        vps.register(jCheckBox1, configuration, this);
100
        vps.register(jCheckBox1, configuration, this);
103
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
101
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
(-)a/j2me.cdc.project.savaje/src/org/netbeans/modules/j2me/cdc/project/savaje/SavaJeProjectCategoryCustomizer.java (-2 / +2 lines)
Lines 46-52 import javax.swing.JPanel; Link Here
46
import javax.swing.JPanel;
46
import javax.swing.JPanel;
47
import javax.swing.JTextField;
47
import javax.swing.JTextField;
48
import javax.swing.filechooser.FileFilter;
48
import javax.swing.filechooser.FileFilter;
49
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
49
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
50
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
50
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
51
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
51
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
52
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
52
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
Lines 73-79 public class SavaJeProjectCategoryCustom Link Here
73
        initComponents();
73
        initComponents();
74
    }
74
    }
75
75
76
    public void initValues(ProjectProperties props, String configuration) {
76
    public void initValues(MultiRootProjectProperties props, String configuration) {
77
        vps = VisualPropertySupport.getDefault(props);
77
        vps = VisualPropertySupport.getDefault(props);
78
        vps.register(jCheckBox1, configuration, this);
78
        vps.register(jCheckBox1, configuration, this);
79
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
79
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
(-)a/j2me.cdc.project.semc/src/org/netbeans/modules/j2me/cdc/project/semc/SemcProjectCategoryCustomizer.java (-2 / +2 lines)
Lines 50-56 import javax.swing.filechooser.FileFilte Link Here
50
import javax.swing.filechooser.FileFilter;
50
import javax.swing.filechooser.FileFilter;
51
import org.netbeans.api.java.platform.JavaPlatform;
51
import org.netbeans.api.java.platform.JavaPlatform;
52
import org.netbeans.api.java.platform.JavaPlatformManager;
52
import org.netbeans.api.java.platform.JavaPlatformManager;
53
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
53
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
54
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
54
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
55
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
55
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
56
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
56
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
Lines 90-96 public class SemcProjectCategoryCustomiz Link Here
90
        initComponents();
90
        initComponents();
91
    }
91
    }
92
92
93
    public void initValues(ProjectProperties props, String configuration) {
93
    public void initValues(MultiRootProjectProperties props, String configuration) {
94
        vps = VisualPropertySupport.getDefault(props);
94
        vps = VisualPropertySupport.getDefault(props);
95
        vps.register(jCheckBox1, configuration, this);
95
        vps.register(jCheckBox1, configuration, this);
96
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
96
        projectDir = FileUtil.toFile(props.getProjectDirectory()).getAbsolutePath();
(-)a/j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/CDCPlatformCustomizer.java (-2 / +2 lines)
Lines 51-57 import org.netbeans.api.java.platform.Ja Link Here
51
import org.netbeans.api.java.platform.JavaPlatformManager;
51
import org.netbeans.api.java.platform.JavaPlatformManager;
52
import org.netbeans.api.java.platform.PlatformsCustomizer;
52
import org.netbeans.api.java.platform.PlatformsCustomizer;
53
import org.netbeans.api.java.platform.Specification;
53
import org.netbeans.api.java.platform.Specification;
54
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
54
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
55
import org.netbeans.modules.j2me.cdc.platform.CDCDevice;
55
import org.netbeans.modules.j2me.cdc.platform.CDCDevice;
56
import org.netbeans.modules.j2me.cdc.platform.CDCPlatform;
56
import org.netbeans.modules.j2me.cdc.platform.CDCPlatform;
57
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
57
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
Lines 93-99 public class CDCPlatformCustomizer exten Link Here
93
        initAll();
93
        initAll();
94
    }
94
    }
95
    
95
    
96
    public void initValues(ProjectProperties props, String configuration) {
96
    public void initValues(MultiRootProjectProperties props, String configuration) {
97
        this.props = props;
97
        this.props = props;
98
        this.vps = VisualPropertySupport.getDefault(props);
98
        this.vps = VisualPropertySupport.getDefault(props);
99
        this.configuration = configuration;
99
        this.configuration = configuration;
(-)a/j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/CustomizerCDCGeneral.java (-2 / +2 lines)
Lines 42-48 package org.netbeans.modules.j2me.cdc.pr Link Here
42
package org.netbeans.modules.j2me.cdc.project;
42
package org.netbeans.modules.j2me.cdc.project;
43
43
44
import javax.swing.JPanel;
44
import javax.swing.JPanel;
45
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
45
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
46
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
46
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
47
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
47
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
48
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
48
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
Lines 67-73 public class CustomizerCDCGeneral extend Link Here
67
    public CustomizerCDCGeneral() {
67
    public CustomizerCDCGeneral() {
68
        initComponents();
68
        initComponents();
69
    }
69
    }
70
    public void initValues(ProjectProperties props, String configuration) {
70
    public void initValues(MultiRootProjectProperties props, String configuration) {
71
        vps = VisualPropertySupport.getDefault(props);
71
        vps = VisualPropertySupport.getDefault(props);
72
        vps.register(jCheckBox1, configuration, this);
72
        vps.register(jCheckBox1, configuration, this);
73
    }
73
    }
(-)a/j2me.cdc.project/src/org/netbeans/modules/j2me/cdc/project/CustomizerRun.java (-4 / +4 lines)
Lines 51-57 import javax.swing.JTextField; Link Here
51
import javax.swing.JTextField;
51
import javax.swing.JTextField;
52
import javax.swing.event.ChangeEvent;
52
import javax.swing.event.ChangeEvent;
53
import javax.swing.event.ChangeListener;
53
import javax.swing.event.ChangeListener;
54
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
54
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
55
import org.netbeans.modules.j2me.cdc.project.CDCPropertiesDescriptor;
55
import org.netbeans.modules.j2me.cdc.project.CDCPropertiesDescriptor;
56
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
56
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
57
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
57
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 80-86 public class CustomizerRun extends JPane Link Here
80
    };
80
    };
81
    
81
    
82
    private VisualPropertySupport vps;
82
    private VisualPropertySupport vps;
83
    private ProjectProperties prop;
83
    private MultiRootProjectProperties prop;
84
    
84
    
85
    private MainClassChooser chooser;
85
    private MainClassChooser chooser;
86
    
86
    
Lines 89-95 public class CustomizerRun extends JPane Link Here
89
        jTextHidden=new javax.swing.JTextField();  
89
        jTextHidden=new javax.swing.JTextField();  
90
        chooser = Lookup.getDefault().lookup(org.netbeans.modules.j2me.cdc.project.execui.MainClassChooser.class);
90
        chooser = Lookup.getDefault().lookup(org.netbeans.modules.j2me.cdc.project.execui.MainClassChooser.class);
91
    }
91
    }
92
    public void initValues(ProjectProperties props, String configuration) {
92
    public void initValues(MultiRootProjectProperties props, String configuration) {
93
        vps = VisualPropertySupport.getDefault(props);
93
        vps = VisualPropertySupport.getDefault(props);
94
        vps.register(jCheckBox1, configuration, this);
94
        vps.register(jCheckBox1, configuration, this);
95
        prop=props;        
95
        prop=props;        
Lines 271-277 public class CustomizerRun extends JPane Link Here
271
            if (chooser == null)
271
            if (chooser == null)
272
                return; //do nothing
272
                return; //do nothing
273
            
273
            
274
            chooser.inicialize(prop.getSourceRoot(),
274
            chooser.initialize(prop.getSourceRoots(),
275
                    CDCProjectUtil.getExecutionModes(prop),(String)prop.get("platform.bootclasspath"));
275
                    CDCProjectUtil.getExecutionModes(prop),(String)prop.get("platform.bootclasspath"));
276
            // only chooseMainClassButton can be performed
276
            // only chooseMainClassButton can be performed
277
//            final MainClassChooser panel = new MainClassChooser (prop.getSourceRoot(),
277
//            final MainClassChooser panel = new MainClassChooser (prop.getSourceRoot(),
(-)a/java.api.common/nbproject/project.xml (-2 / +3 lines)
Lines 199-211 Link Here
199
                <friend>org.netbeans.modules.j2ee.earproject</friend>
199
                <friend>org.netbeans.modules.j2ee.earproject</friend>
200
                <friend>org.netbeans.modules.j2ee.ejbjarproject</friend>
200
                <friend>org.netbeans.modules.j2ee.ejbjarproject</friend>
201
                <friend>org.netbeans.modules.java.j2seproject</friend>
201
                <friend>org.netbeans.modules.java.j2seproject</friend>
202
                <friend>org.netbeans.modules.javafx.profiler</friend>
202
                <friend>org.netbeans.modules.javafx.project</friend>
203
                <friend>org.netbeans.modules.javafx.project</friend>
203
                <friend>org.netbeans.modules.javafx.profiler</friend>
204
                <friend>org.netbeans.modules.mobility.project</friend>
204
                <friend>org.netbeans.modules.projectimport</friend>
205
                <friend>org.netbeans.modules.projectimport</friend>
205
                <friend>org.netbeans.modules.projectimport.jbuilder</friend>
206
                <friend>org.netbeans.modules.projectimport.eclipse.core</friend>
206
                <friend>org.netbeans.modules.projectimport.eclipse.core</friend>
207
                <friend>org.netbeans.modules.projectimport.eclipse.j2se</friend>
207
                <friend>org.netbeans.modules.projectimport.eclipse.j2se</friend>
208
                <friend>org.netbeans.modules.projectimport.eclipse.web</friend>
208
                <friend>org.netbeans.modules.projectimport.eclipse.web</friend>
209
                <friend>org.netbeans.modules.projectimport.jbuilder</friend>
209
                <friend>org.netbeans.modules.scala.project</friend>
210
                <friend>org.netbeans.modules.scala.project</friend>
210
                <friend>org.netbeans.modules.web.project</friend>
211
                <friend>org.netbeans.modules.web.project</friend>
211
                <friend>org.netbeans.modules.xtest</friend>
212
                <friend>org.netbeans.modules.xtest</friend>
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties (-1 / +1 lines)
Lines 174-180 CTL_ProjectFolder=Project Folder\: Link Here
174
CTL_ProjectFolder=Project Folder\:
174
CTL_ProjectFolder=Project Folder\:
175
TITLE_InvalidRoot=Add Package Folder
175
TITLE_InvalidRoot=Add Package Folder
176
MSG_InvalidRoot=<html><b>Package Folder Already Used in Project</b></html>\n\
176
MSG_InvalidRoot=<html><b>Package Folder Already Used in Project</b></html>\n\
177
    Following folders you selected are already used in this or another\n\
177
    The following folders you selected are already used in this or another\n\
178
    project. One package folder can only be used in one project in one\n\
178
    project. One package folder can only be used in one project in one\n\
179
    package folder list (source packages or test packages).
179
    package folder list (source packages or test packages).
180
LBL_InvalidRoot=Package folders already in use:
180
LBL_InvalidRoot=Package folders already in use:
(-)a/mobility.deployment.ricoh/src/org/netbeans/modules/mobility/deployment/ricoh/RicohCustomizerPanel.java (-6 / +2 lines)
Lines 43-58 package org.netbeans.modules.mobility.de Link Here
43
package org.netbeans.modules.mobility.deployment.ricoh;
43
package org.netbeans.modules.mobility.deployment.ricoh;
44
44
45
import java.awt.CardLayout;
45
import java.awt.CardLayout;
46
import java.awt.Component;
47
import java.awt.Container;
48
import javax.swing.text.JTextComponent;
49
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
46
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
50
import org.openide.util.*;
47
import org.openide.util.*;
51
import javax.swing.*;
48
import javax.swing.*;
52
import java.awt.event.*;
49
import java.awt.event.*;
53
import java.io.File;
50
import java.io.File;
54
import java.util.Set;
51
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
55
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
56
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
52
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
57
import org.netbeans.spi.project.support.ant.EditableProperties;
53
import org.netbeans.spi.project.support.ant.EditableProperties;
58
import org.netbeans.spi.project.support.ant.PropertyUtils;
54
import org.netbeans.spi.project.support.ant.PropertyUtils;
Lines 354-360 public class RicohCustomizerPanel extend Link Here
354
        this.repaint();   
350
        this.repaint();   
355
    }
351
    }
356
    
352
    
357
    public void initValues(ProjectProperties props, String configuration)
353
    public void initValues(MultiRootProjectProperties props, String configuration)
358
    {
354
    {
359
        actConfig=configuration;
355
        actConfig=configuration;
360
        actProps =props;
356
        actProps =props;
(-)a/mobility.j2meunit/src/org/netbeans/modules/mobility/j2meunit/J2MEUnitProjectLookupProvider.java (-1 / +1 lines)
Lines 67-73 public class J2MEUnitProjectLookupProvid Link Here
67
    {
67
    {
68
        List lookups=new ArrayList();
68
        List lookups=new ArrayList();
69
        lookups.add(new J2MEUnitPlugin(project,helper));
69
        lookups.add(new J2MEUnitPlugin(project,helper));
70
        lookups.add(new UnitTestForSourceQueryImpl(helper));
70
        lookups.add(new UnitTestForSourceQueryImpl(project, helper));
71
        return lookups;
71
        return lookups;
72
    }   
72
    }   
73
}
73
}
(-)a/mobility.j2meunit/src/org/netbeans/modules/mobility/j2meunit/UnitTestForSourceQueryImpl.java (-9 / +20 lines)
Lines 48-56 package org.netbeans.modules.mobility.j2 Link Here
48
package org.netbeans.modules.mobility.j2meunit;
48
package org.netbeans.modules.mobility.j2meunit;
49
49
50
import java.net.URL;
50
import java.net.URL;
51
import java.util.logging.Level;
52
import java.util.logging.Logger;
53
import org.netbeans.modules.mobility.project.J2MEProject;
54
import org.netbeans.modules.mobility.project.J2MESources;
51
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
55
import org.netbeans.spi.java.queries.MultipleRootsUnitTestForSourceQueryImplementation;
52
import org.netbeans.spi.project.support.ant.AntProjectHelper;
56
import org.netbeans.spi.project.support.ant.AntProjectHelper;
53
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileObject;
58
import org.openide.filesystems.FileStateInvalidException;
59
import org.openide.filesystems.FileUtil;
54
60
55
/**
61
/**
56
 *
62
 *
Lines 59-81 public class UnitTestForSourceQueryImpl Link Here
59
public class UnitTestForSourceQueryImpl implements MultipleRootsUnitTestForSourceQueryImplementation {
65
public class UnitTestForSourceQueryImpl implements MultipleRootsUnitTestForSourceQueryImplementation {
60
    
66
    
61
    final private AntProjectHelper myHelper;
67
    final private AntProjectHelper myHelper;
68
    private final J2MEProject project;
62
    
69
    
63
    public UnitTestForSourceQueryImpl(AntProjectHelper aph) {
70
    public UnitTestForSourceQueryImpl(J2MEProject project, AntProjectHelper aph) {
64
        this.myHelper=aph;
71
        this.myHelper=aph;
72
        this.project = project;
65
    }
73
    }
66
    
74
    
67
    public URL[] findUnitTests(@SuppressWarnings("unused")
75
    public URL[] findUnitTests(@SuppressWarnings("unused")
68
	final FileObject source) {
76
	final FileObject source) {
69
        //we have only one source root in J2ME projects, it is same for both sources and tests
77
        //we have only one source root in J2ME projects, it is same for both sources and tests
70
        try {
78
        J2MESources sources = project.getLookup().lookup(J2MESources.class);
71
            final String sourceRootPath=myHelper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
79
        assert sources != null;
72
            if (sourceRootPath == null) return null;
80
        FileObject sourceRoot = sources.rootFor(source);
73
            final FileObject sourceRoot=this.myHelper.resolveFileObject(sourceRootPath);
81
        if (sourceRoot != null) {
74
            if (sourceRoot == null) return null;
82
            String path = FileUtil.getRelativePath(sourceRoot, source);
75
            return new URL[] {sourceRoot.getURL()};
83
            try {
76
        } catch (Exception e) {
84
                return new URL[]{sourceRoot.getURL()};
77
            return null;
85
            } catch (FileStateInvalidException ex) {
86
                Logger.getLogger(getClass().getName()).log(Level.INFO, null, ex);
87
            }
78
        }
88
        }
89
        return null;
79
    }
90
    }
80
    
91
    
81
    public URL[] findSources(final FileObject unitTest) {
92
    public URL[] findSources(final FileObject unitTest) {
(-)a/mobility.project.ant/antsrc/org/netbeans/modules/mobility/project/ant/KdpDebugTask.java (-2 / +14 lines)
Lines 67-72 import org.openide.util.NbBundle; Link Here
67
import org.openide.util.NbBundle;
67
import org.openide.util.NbBundle;
68
import java.beans.PropertyChangeEvent;
68
import java.beans.PropertyChangeEvent;
69
import java.net.URL;
69
import java.net.URL;
70
import java.util.Hashtable;
70
import java.util.Iterator;
71
import java.util.Iterator;
71
import java.util.Set;
72
import java.util.Set;
72
import org.netbeans.api.debugger.DebuggerEngine;
73
import org.netbeans.api.debugger.DebuggerEngine;
Lines 165-172 public class KdpDebugTask extends Task { Link Here
165
            throw new BuildException(NbBundle.getMessage(KdpDebugTask.class, "ERR_ANT_Address_missing"), getLocation()); //NOI18N
166
            throw new BuildException(NbBundle.getMessage(KdpDebugTask.class, "ERR_ANT_Address_missing"), getLocation()); //NOI18N
166
        }
167
        }
167
        
168
        
168
        //locate source root
169
        //locate at least one source root
169
        String src = project.getProperty("src.dir"); //NOI18N
170
        String src = null;
171
        Hashtable props = project.getProperties();
172
        for (Object prop : props.keySet()) {
173
            if (prop instanceof String) {
174
                String p = (String) prop;
175
                if (p.startsWith("src.") && p.endsWith(".dir")) { //NOI18N
176
                    src = project.getProperty(p);
177
                    break;
178
                }
179
            }
180
        }
181
170
        if (src == null)  throw new BuildException(NbBundle.getMessage(KdpDebugTask.class, "ERR_ANT_source_root_missing"), getLocation()); //NOI18N
182
        if (src == null)  throw new BuildException(NbBundle.getMessage(KdpDebugTask.class, "ERR_ANT_source_root_missing"), getLocation()); //NOI18N
171
        File srcFile = new File(project.getBaseDir(), src);
183
        File srcFile = new File(project.getBaseDir(), src);
172
        if (!srcFile.isDirectory()) srcFile = new File(src);
184
        if (!srcFile.isDirectory()) srcFile = new File(src);
(-)a/mobility.project/nbproject/project.xml (+9 lines)
Lines 307-312 made subject to such option by the copyr Link Here
307
                        <specification-version>6.2</specification-version>
307
                        <specification-version>6.2</specification-version>
308
                    </run-dependency>
308
                    </run-dependency>
309
                </dependency>
309
                </dependency>
310
                <dependency>
311
                    <code-name-base>org.netbeans.modules.java.api.common</code-name-base>
312
                    <build-prerequisite/>
313
                    <compile-dependency/>
314
                    <run-dependency>
315
                        <release-version>0</release-version>
316
                        <specification-version>1.3</specification-version>
317
                    </run-dependency>
318
                </dependency>
310
            </module-dependencies>
319
            </module-dependencies>
311
            <test-dependencies>
320
            <test-dependencies>
312
                <test-type>
321
                <test-type>
(-)6b487c15857b (+60 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans.api.mobility.project.ui.customizer;
41
42
import org.openide.filesystems.FileObject;
43
44
/**
45
 * Extends ProjectProperties to support multiple source roots.
46
 *
47
 * @author Tim Boudreau
48
 */
49
public abstract class MultiRootProjectProperties implements ProjectProperties {
50
51
    /**
52
     * Get all source roots in the project.  Replaces
53
     * <code>ProjectProperties.getSourceRoot()</code>.
54
     * @return
55
     */
56
    public FileObject[] getSourceRoots(){
57
        return new FileObject[] { getSourceRoot() };
58
    }
59
60
}
(-)a/mobility.project/src/org/netbeans/api/mobility/project/ui/customizer/ProjectProperties.java (-2 / +7 lines)
Lines 24-30 Link Here
24
 * Contributor(s):
24
 * Contributor(s):
25
 *
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
28
 * Microsystems, Inc. All Rights Reserved.
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
30
 * If you wish your version of this file to be governed by only the CDDL
Lines 46-58 import org.openide.filesystems.FileObjec Link Here
46
import org.openide.filesystems.FileObject;
46
import org.openide.filesystems.FileObject;
47
47
48
/**
48
/**
49
 * All mobile projects now use <code>MultiRootProjectProperties</code> -
50
 * for accessing the source root folders, use that class's
51
 * <code>getSourceRoots()</code>.
49
 *
52
 *
53
 * @see MultiRootProjectProperties
50
 * @author Adam Sotona
54
 * @author Adam Sotona
51
 */
55
 */
52
public interface ProjectProperties extends Map<String, Object> {
56
public interface ProjectProperties extends Map<String, Object> {
53
    
57
    
54
    public FileObject getProjectDirectory();
58
    public FileObject getProjectDirectory();
55
    
59
60
    @Deprecated
56
    public FileObject getSourceRoot();
61
    public FileObject getSourceRoot();
57
    
62
    
58
    public ProjectConfiguration[] getConfigurations();
63
    public ProjectConfiguration[] getConfigurations();
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ApplicationDescriptorHandler.java (-11 / +12 lines)
Lines 83-99 public class ApplicationDescriptorHandle Link Here
83
    public void handleRename(final FileObject file, final String newName) {
83
    public void handleRename(final FileObject file, final String newName) {
84
        if (!isJava(file)) return;
84
        if (!isJava(file)) return;
85
        final Project p = findProject(file);
85
        final Project p = findProject(file);
86
        final String className = calculateClassName(getSrcRoot(p), file);
86
        final String className = calculateClassName(getSrcRoot(p, file), file);
87
        if (className != null) postChangeRequest(p, className, className.substring(0, className.length() - file.getName().length()) + newName);
87
        if (className != null) postChangeRequest(p, className, className.substring(0, className.length() - file.getName().length()) + newName);
88
    }
88
    }
89
    
89
    
90
    public void handleMove(final FileObject file, final FileObject newFolder) {
90
    public void handleMove(final FileObject file, final FileObject newFolder) {
91
        if (!isJava(file)) return;
91
        if (!isJava(file)) return;
92
        final Project p = findProject(file);
92
        final Project p = findProject(file);
93
        final FileObject srcRoot = getSrcRoot(p);
93
        final FileObject srcRoot = getSrcRoot(p, file);
94
        final String className = calculateClassName(getSrcRoot(p), file);
94
        final String className = calculateClassName(srcRoot, file);
95
        if (className == null) return;
95
        if (className == null) return;
96
        String newClassName = newFolder == null ? null : FileUtil.getRelativePath(srcRoot, newFolder);
96
        String newClassName = newFolder == null ? null : 
97
            FileUtil.getRelativePath(srcRoot, newFolder);
98
        
97
        if (newClassName != null) {
99
        if (newClassName != null) {
98
            if (newClassName.length() > 0) newClassName = newClassName.replace('/', '.') + '.';
100
            if (newClassName.length() > 0) newClassName = newClassName.replace('/', '.') + '.';
99
            newClassName += file.getName();
101
            newClassName += file.getName();
Lines 104-110 public class ApplicationDescriptorHandle Link Here
104
    public void handleDelete(final FileObject file) {
106
    public void handleDelete(final FileObject file) {
105
        if (!isJava(file)) return;
107
        if (!isJava(file)) return;
106
        final Project p = findProject(file);
108
        final Project p = findProject(file);
107
        final String className = calculateClassName(getSrcRoot(p), file);
109
        final String className = calculateClassName(getSrcRoot(p, file), file);
108
        if (className != null) postChangeRequest(p, className, null);
110
        if (className != null) postChangeRequest(p, className, null);
109
    }
111
    }
110
    
112
    
Lines 117-128 public class ApplicationDescriptorHandle Link Here
117
        return p instanceof J2MEProject ? p : null;
119
        return p instanceof J2MEProject ? p : null;
118
    }
120
    }
119
    
121
    
120
    private FileObject getSrcRoot(final Project p) {
122
    private FileObject getSrcRoot(final Project p, FileObject file) {
121
        if (p == null) return null;
123
        J2MESources src = p.getLookup().lookup (J2MESources.class);
122
        final AntProjectHelper helper = p.getLookup().lookup(AntProjectHelper.class);
124
        assert src != null : "Null J2MESources from lookup of project at " +
123
        if (helper == null) return null;
125
                p.getProjectDirectory().getPath();
124
        final String srcDir = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
126
        return src.rootFor(file);
125
        return srcDir == null ? null : helper.resolveFileObject(srcDir);
126
    }
127
    }
127
    
128
    
128
    private String calculateClassName(final FileObject root, final FileObject file) {
129
    private String calculateClassName(final FileObject root, final FileObject file) {
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/Bundle.properties (+9 lines)
Lines 83-85 LBL_Cfg_TemplateSuffix=_template Link Here
83
83
84
EmptyConfigurationTemplate=<empty project configuration>
84
EmptyConfigurationTemplate=<empty project configuration>
85
85
86
#Updater
87
TXT_ProjectUpdate=<html><b>Project Needs Upgrading</b></html>\n\
88
    This project was created in an earlier version of NetBeans IDE. If you\n\
89
    edit its properties in NetBeans IDE {0}, the project will be upgraded and\n\
90
    <html><b>will no longer work in earlier versions of the IDE.</b></html>\n\n\
91
    Do you want to upgrade your project to version {0}?
92
TXT_ProjectUpdateTitle=Change Project Properties
93
CTL_UpdateOption=Upgrade Project
94
AD_UpdateOption=N/A
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/CDCMainClassHelper.java (-7 / +15 lines)
Lines 52-58 import org.netbeans.api.java.classpath.C Link Here
52
import org.netbeans.api.java.classpath.ClassPath;
52
import org.netbeans.api.java.classpath.ClassPath;
53
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.Project;
54
import org.netbeans.api.project.ProjectManager;
54
import org.netbeans.api.project.ProjectManager;
55
import org.netbeans.modules.mobility.project.queries.CompiledSourceForBinaryQuery;
56
import org.netbeans.spi.project.support.ant.AntProjectEvent;
55
import org.netbeans.spi.project.support.ant.AntProjectEvent;
57
import org.netbeans.spi.project.support.ant.AntProjectHelper;
56
import org.netbeans.spi.project.support.ant.AntProjectHelper;
58
import org.netbeans.spi.project.support.ant.AntProjectListener;
57
import org.netbeans.spi.project.support.ant.AntProjectListener;
Lines 73-83 public class CDCMainClassHelper implemen Link Here
73
    final private AntProjectHelper helper;
72
    final private AntProjectHelper helper;
74
    private String mainClass;
73
    private String mainClass;
75
    private FileObject lastMain=null;
74
    private FileObject lastMain=null;
75
    private final J2MEProject project;
76
    
76
    
77
    /** Creates a new instance of CDCMainClassHelper */
77
    /** Creates a new instance of CDCMainClassHelper */
78
    public CDCMainClassHelper(AntProjectHelper helper)
78
    public CDCMainClassHelper(J2MEProject project, AntProjectHelper helper)
79
    {
79
    {
80
        this.helper = helper;
80
        this.helper = helper;
81
        this.project = project;
81
        EditableProperties ep=helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);        
82
        EditableProperties ep=helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);        
82
        mainClass=ep.getProperty("main.class");
83
        mainClass=ep.getProperty("main.class");
83
        if (mainClass != null)
84
        if (mainClass != null)
Lines 145-157 public class CDCMainClassHelper implemen Link Here
145
        {
146
        {
146
            public void run()
147
            public void run()
147
            {
148
            {
148
                final FileObject root = helper.getProjectDirectory().getFileObject(helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).getProperty(DefaultPropertiesDescriptor.SRC_DIR));
149
                J2MESources sources = project.getLookup().lookup(J2MESources.class);
149
                if (root != null)
150
                FileObject[] roots = sources == null ? new FileObject[0] :
151
                    sources.getSourceRoots();
152
                if (roots != null && roots.length > 0)
150
                {
153
                {
151
                    final ClassPath path1 = ClassPath.getClassPath (root, ClassPath.SOURCE);        
154
                    //Should be able to get same classpaths from any root
152
                    final ClassPath path2 = ClassPath.getClassPath (root, ClassPath.COMPILE);
155
                    final ClassPath path1 = ClassPath.getClassPath (roots[0], ClassPath.SOURCE);
156
                    final ClassPath path2 = ClassPath.getClassPath (roots[0], ClassPath.COMPILE);
153
                    final ClassPath path  = org.netbeans.spi.java.classpath.support.ClassPathSupport.createProxyClassPath(new ClassPath[] { path1, path2 } );
157
                    final ClassPath path  = org.netbeans.spi.java.classpath.support.ClassPathSupport.createProxyClassPath(new ClassPath[] { path1, path2 } );
154
                    FileObject o=path.findResource(str.replace('.','/')+".java");
158
                    FileObject o = path.findResource(str.replace('.','/')+".java"); //NOI18N
159
                    
160
                    //XXX this looks like a memory leak that will hold the 
161
                    //a reference to the project.  However, not sure if it will
162
                    //break something to use a weak listener instead
155
                    if (lastMain != null)
163
                    if (lastMain != null)
156
                        lastMain.removeFileChangeListener(CDCMainClassHelper.this);
164
                        lastMain.removeFileChangeListener(CDCMainClassHelper.this);
157
                    if (o!=null)
165
                    if (o!=null)
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEActionProvider.java (-7 / +12 lines)
Lines 214-228 public class J2MEActionProvider implemen Link Here
214
                String activeConfiguration = confs.getActiveConfiguration() != confs.getDefaultConfiguration() ? confs.getActiveConfiguration().getDisplayName() : null;
214
                String activeConfiguration = confs.getActiveConfiguration() != confs.getDefaultConfiguration() ? confs.getActiveConfiguration().getDisplayName() : null;
215
                Properties p = new Properties();
215
                Properties p = new Properties();
216
                if ( command.equals( COMMAND_COMPILE_SINGLE ) ) {
216
                if ( command.equals( COMMAND_COMPILE_SINGLE ) ) {
217
                    String sDir = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
217
                    J2MESources sources = project.getLookup().lookup (J2MESources.class);
218
                    if (sDir != null) {
218
                    assert sources != null;
219
                        FileObject srcDir = helper.resolveFileObject(sDir);
219
                    StringBuilder includes = new StringBuilder();
220
                        if (srcDir != null) {
220
                    for (FileObject root : sources.getSourceRoots()) {
221
                            FileObject[] files = findSourcesAndPackages(context, srcDir);
221
                        FileObject[] found = findSourcesAndPackages(context, root);
222
                            if (files != null) {
222
                        if (found != null) {
223
                                p.setProperty("javac.includes", ActionUtils.antIncludesList(files, srcDir)); // NOI18N
223
                            if (includes.length() != 0) {
224
                                includes.append (',');
224
                            }
225
                            }
226
                            includes.append(ActionUtils.antIncludesList(found, root));
225
                        }
227
                        }
228
                    }
229
                    if (includes.length() > 0) {
230
                        p.setProperty ("javac.includes", includes.toString());
226
                    }
231
                    }
227
                } else if (COMMAND_DEBUG.equals(command)) {
232
                } else if (COMMAND_DEBUG.equals(command)) {
228
                    p.put(DefaultPropertiesDescriptor.OBFUSCATION_LEVEL, "0"); //NOI18N
233
                    p.put(DefaultPropertiesDescriptor.OBFUSCATION_LEVEL, "0"); //NOI18N
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEAntLogger.java (-6 / +31 lines)
Lines 42-47 package org.netbeans.modules.mobility.pr Link Here
42
package org.netbeans.modules.mobility.project;
42
package org.netbeans.modules.mobility.project;
43
import java.io.File;
43
import java.io.File;
44
import java.util.HashMap;
44
import java.util.HashMap;
45
import java.util.regex.Matcher;
45
import java.util.regex.Pattern;
46
import java.util.regex.Pattern;
46
import org.apache.tools.ant.module.spi.AntEvent;
47
import org.apache.tools.ant.module.spi.AntEvent;
47
import org.apache.tools.ant.module.spi.AntLogger;
48
import org.apache.tools.ant.module.spi.AntLogger;
Lines 60-65 public final class J2MEAntLogger extends Link Here
60
public final class J2MEAntLogger extends AntLogger {
61
public final class J2MEAntLogger extends AntLogger {
61
    
62
    
62
    private static final String separator = File.separatorChar == '\\' ? "\\\\" : "/"; //NOI18N
63
    private static final String separator = File.separatorChar == '\\' ? "\\\\" : "/"; //NOI18N
64
    //PENDING:  Determine if : is safe
65
    private static final char PATH_SEPARATOR = ':'; //NOI18N
63
    
66
    
64
    private static final Pattern PREPROCESSED = Pattern.compile(
67
    private static final Pattern PREPROCESSED = Pattern.compile(
65
            "^.*" + separator + "build(?:" + separator + "[a-zA-Z_$][a-zA-Z0-9_$]*)?" + separator + "preprocessed" + separator); // NOI18N
68
            "^.*" + separator + "build(?:" + separator + "[a-zA-Z_$][a-zA-Z0-9_$]*)?" + separator + "preprocessed" + separator); // NOI18N
Lines 78-100 public final class J2MEAntLogger extends Link Here
78
        return session.getVerbosity() < AntEvent.LOG_DEBUG;
81
        return session.getVerbosity() < AntEvent.LOG_DEBUG;
79
    }
82
    }
80
    
83
    
84
    @Override
81
    public boolean interestedInScript(File script, AntSession session) {
85
    public boolean interestedInScript(File script, AntSession session) {
82
        FileObject projfile = FileUtil.toFileObject(FileUtil.normalizeFile(script));
86
        FileObject projfile = FileUtil.toFileObject(FileUtil.normalizeFile(script));
83
        if (projfile == null) return false;
87
        if (projfile == null) return false;
84
        Project proj = FileOwnerQuery.getOwner(projfile);
88
        Project proj = FileOwnerQuery.getOwner(projfile);
85
        if (proj == null) return false;
89
        if (proj == null) return false;
90
        J2MESources sources = proj.getLookup().lookup (J2MESources.class);
91
        if (sources == null) return false;
92
        FileObject[] sourceRootFolders = sources.getSourceRoots();
93
94
        if (sourceRootFolders.length == 0) return false;
86
        AntProjectHelper helper = proj.getLookup().lookup(AntProjectHelper.class);
95
        AntProjectHelper helper = proj.getLookup().lookup(AntProjectHelper.class);
87
        if (helper == null) return false;
96
        if (helper == null) return false;
88
        String sourceRoot = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
97
89
        if (sourceRoot == null) return false;
98
        File[] rootsAsFiles = new File[sourceRootFolders.length];
90
        File srcRoot = helper.resolveFile(sourceRoot);
99
        StringBuilder paths = new StringBuilder();
91
        if (srcRoot == null) return false;
100
        for (int i = 0; i < rootsAsFiles.length; i++) {
101
            rootsAsFiles[i] = FileUtil.toFile(sourceRootFolders[i]);
102
            if (rootsAsFiles[i] == null) {
103
                return false;
104
            }
105
            if (paths.length() > 0) {
106
                paths.append (PATH_SEPARATOR);
107
            }
108
            paths.append (rootsAsFiles[i].getAbsolutePath().replaceAll(CHARSTOESCAPE, ESCAPESEQUENCE));
109
            paths.append (separator);
110
        }
111
92
        HashMap<File, String> roots = (HashMap)session.getCustomData(this);
112
        HashMap<File, String> roots = (HashMap)session.getCustomData(this);
93
        if (roots == null) {
113
        if (roots == null) {
94
            roots = new HashMap();
114
            roots = new HashMap();
95
            session.putCustomData(this, roots);
115
            session.putCustomData(this, roots);
96
        }
116
        }
97
        roots.put(script, srcRoot.getAbsolutePath().replaceAll(CHARSTOESCAPE, ESCAPESEQUENCE) + separator);
117
        roots.put(script, paths.toString());
98
        return true;
118
        return true;
99
    }
119
    }
100
    
120
    
Lines 122-128 public final class J2MEAntLogger extends Link Here
122
            srcRoot = (String)cd;
142
            srcRoot = (String)cd;
123
        if (srcRoot == null) return;
143
        if (srcRoot == null) return;
124
        String message = event.getMessage();
144
        String message = event.getMessage();
125
        String newMessage = PREPROCESSED.matcher(message).replaceFirst(srcRoot);
145
146
        Matcher matcher = PREPROCESSED.matcher(message);
147
        String newMessage = message;
148
        for (String path : srcRoot.split(":")) {
149
            newMessage = matcher.replaceFirst(path);
150
        }
126
        if (!message.equals(newMessage)) {
151
        if (!message.equals(newMessage)) {
127
            event.consume();
152
            event.consume();
128
            event.getSession().deliverMessageLogged(event, newMessage, event.getLogLevel());
153
            event.getSession().deliverMessageLogged(event, newMessage, event.getLogLevel());
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEProject.java (-301 / +407 lines)
Lines 38-45 Link Here
38
 * Version 2 license, then the option applies only if the new code is
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
39
 * made subject to such option by the copyright holder.
40
 */
40
 */
41
package org.netbeans.modules.mobility.project;
41
42
42
package org.netbeans.modules.mobility.project;
43
import java.beans.PropertyChangeEvent;
43
import java.beans.PropertyChangeEvent;
44
import java.beans.PropertyChangeListener;
44
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeSupport;
45
import java.beans.PropertyChangeSupport;
Lines 83-89 import org.netbeans.spi.mobility.project Link Here
83
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
83
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
84
import org.netbeans.spi.project.ProjectConfiguration;
84
import org.netbeans.spi.project.ProjectConfiguration;
85
import org.netbeans.api.project.ui.OpenProjects;
85
import org.netbeans.api.project.ui.OpenProjects;
86
import org.netbeans.modules.mobility.project.classpath.J2MEProjectClassPathExtender;
87
import org.netbeans.spi.project.ui.ProjectOpenedHook;
86
import org.netbeans.spi.project.ui.ProjectOpenedHook;
88
import org.openide.DialogDisplayer;
87
import org.openide.DialogDisplayer;
89
import org.openide.NotifyDescriptor;
88
import org.openide.NotifyDescriptor;
Lines 95-113 import org.openide.util.ImageUtilities; Link Here
95
import org.openide.util.ImageUtilities;
94
import org.openide.util.ImageUtilities;
96
import org.openide.util.Lookup;
95
import org.openide.util.Lookup;
97
import org.openide.util.RequestProcessor;
96
import org.openide.util.RequestProcessor;
98
import org.netbeans.modules.mobility.project.ui.J2MECustomizerProvider;
99
import org.netbeans.modules.mobility.project.ui.J2MEPhysicalViewProvider;
97
import org.netbeans.modules.mobility.project.ui.J2MEPhysicalViewProvider;
100
import org.netbeans.modules.mobility.project.queries.CompiledSourceForBinaryQuery;
101
import org.netbeans.modules.mobility.project.queries.JavadocForBinaryQueryImpl;
102
import org.netbeans.spi.project.AuxiliaryConfiguration;
98
import org.netbeans.spi.project.AuxiliaryConfiguration;
103
import org.netbeans.api.project.ProjectInformation;
99
import org.netbeans.api.project.ProjectInformation;
104
import org.netbeans.modules.j2me.cdc.platform.CDCPlatform;
100
import org.netbeans.modules.j2me.cdc.platform.CDCPlatform;
101
import org.netbeans.modules.java.api.common.SourceRoots;
102
import org.netbeans.modules.java.api.common.ant.UpdateHelper;
103
import org.netbeans.modules.java.api.common.queries.QuerySupport;
105
import org.netbeans.modules.mobility.project.classpath.J2MEClassPathProvider;
104
import org.netbeans.modules.mobility.project.classpath.J2MEClassPathProvider;
105
import org.netbeans.modules.mobility.project.classpath.J2MEProjectClassPathExtender;
106
import org.netbeans.modules.mobility.project.deployment.DeploymentPropertiesHandler;
106
import org.netbeans.modules.mobility.project.deployment.DeploymentPropertiesHandler;
107
import org.netbeans.modules.mobility.project.queries.SourceLevelQueryImpl;
107
import org.netbeans.modules.mobility.project.queries.CompiledSourceForBinaryQuery;
108
import org.netbeans.modules.mobility.project.queries.FileBuiltQueryImpl;
108
import org.netbeans.modules.mobility.project.queries.FileBuiltQueryImpl;
109
import org.netbeans.modules.mobility.project.queries.FileEncodingQueryImpl;
109
import org.netbeans.modules.mobility.project.queries.FileEncodingQueryImpl;
110
import org.netbeans.modules.mobility.project.queries.JavadocForBinaryQueryImpl;
111
import org.netbeans.modules.mobility.project.queries.SourceLevelQueryImpl;
110
import org.netbeans.modules.mobility.project.security.KeyStoreRepository;
112
import org.netbeans.modules.mobility.project.security.KeyStoreRepository;
113
import org.netbeans.modules.mobility.project.ui.J2MECustomizerProvider;
111
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
114
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
112
import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
115
import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
113
import org.netbeans.spi.mobility.deployment.DeploymentPlugin;
116
import org.netbeans.spi.mobility.deployment.DeploymentPlugin;
Lines 117-123 import org.netbeans.spi.project.support. Link Here
117
import org.netbeans.spi.project.support.ant.*;
120
import org.netbeans.spi.project.support.ant.*;
118
import org.netbeans.spi.project.ui.RecommendedTemplates;
121
import org.netbeans.spi.project.ui.RecommendedTemplates;
119
import org.netbeans.spi.project.ui.PrivilegedTemplates;
122
import org.netbeans.spi.project.ui.PrivilegedTemplates;
123
import org.netbeans.spi.project.ui.support.UILookupMergerSupport;
124
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
125
import org.netbeans.spi.queries.SharabilityQueryImplementation;
120
import org.openide.ErrorManager;
126
import org.openide.ErrorManager;
127
import org.openide.util.Exceptions;
121
import org.openide.util.LookupEvent;
128
import org.openide.util.LookupEvent;
122
import org.openide.util.LookupListener;
129
import org.openide.util.LookupListener;
123
import org.openide.util.Mutex;
130
import org.openide.util.Mutex;
Lines 134-180 import org.w3c.dom.Node; Link Here
134
 * @author Jesse Glick, Adam Sotona, Tim Boudreau
141
 * @author Jesse Glick, Adam Sotona, Tim Boudreau
135
 */
142
 */
136
public final class J2MEProject implements Project, AntProjectListener {
143
public final class J2MEProject implements Project, AntProjectListener {
144
137
    final Icon J2ME_PROJECT_ICON = new ImageIcon(ImageUtilities.loadImage(
145
    final Icon J2ME_PROJECT_ICON = new ImageIcon(ImageUtilities.loadImage(
138
            "org/netbeans/modules/mobility/project/ui/resources/mobile-project.png" )); // NOI18N
146
            "org/netbeans/modules/mobility/project/ui/resources/mobile-project.png")); // NOI18N
139
    private static final URLStreamHandler COMPOSED_STREAM_HANDLER = new URLStreamHandler() {
147
    private static final URLStreamHandler COMPOSED_STREAM_HANDLER = new URLStreamHandler() {
148
140
        protected URLConnection openConnection(URL u) throws IOException {
149
        protected URLConnection openConnection(URL u) throws IOException {
141
            return new ComposedConnection(u);
150
            return new ComposedConnection(u);
142
        }
151
        }
143
    };
152
    };
144
    
145
    static final String CONFIGS_NAME = "configurations"; // NOI18N
153
    static final String CONFIGS_NAME = "configurations"; // NOI18N
146
    static final String CONFIG_NAME = "configuration"; // NOI18N
154
    static final String CONFIG_NAME = "configuration"; // NOI18N
147
    static final String CONFIGS_NS = "http://www.netbeans.org/ns/project-configurations/1"; // NOI18N
155
    static final String CONFIGS_NS = "http://www.netbeans.org/ns/project-configurations/1"; // NOI18N
148
    static final String CLASSPATH = "classpath"; // NOI18N
156
    static final String CLASSPATH = "classpath"; // NOI18N
149
    
150
    final AuxiliaryConfiguration aux;
157
    final AuxiliaryConfiguration aux;
151
    final AntProjectHelper helper;
158
    final AntProjectHelper helper;
152
    final GeneratedFilesHelper genFilesHelper;
159
    final GeneratedFilesHelper genFilesHelper;
153
    Lookup lookup;
160
    Lookup lookup;
154
    final MIDletsCacheHelper midletsCacheHelper; 
161
    final MIDletsCacheHelper midletsCacheHelper;
155
    final ProjectConfigurationsHelper configHelper;
162
    final ProjectConfigurationsHelper configHelper;
156
    
163
    private final SourceRoots sourceRoots;
164
    private final SourceRoots testSourceRoots;
165
166
    //XXX This pointlessly leaks FileObjects.  Cache paths instead. -Tim
157
    private static final Set<FileObject> roots = new HashSet<FileObject>();
167
    private static final Set<FileObject> roots = new HashSet<FileObject>();
158
    private static final Map<FileObject, Boolean> folders = new WeakHashMap<FileObject, Boolean>();
168
    private static final Map<FileObject, Boolean> folders = new WeakHashMap<FileObject, Boolean>();
159
    private final ReferenceHelper refHelper;
169
    private final ReferenceHelper refHelper;
160
    private final PropertyChangeSupport pcs;
170
    private final PropertyChangeSupport pcs;
161
    
162
    private TextSwitcher textSwitcher;
171
    private TextSwitcher textSwitcher;
163
    
172
    private final UpdateHelper updater;
173
164
    /* Side effect of this methosd is modification of fo - is this correct? */
174
    /* Side effect of this methosd is modification of fo - is this correct? */
165
    public static boolean isJ2MEFile(FileObject fo) {
175
    public static boolean isJ2MEFile(FileObject fo) {
166
        if (fo == null) return false;
176
        if (fo == null) {
177
            return false;
178
        }
167
        final FileObject archiveRoot = FileUtil.getArchiveFile(fo);
179
        final FileObject archiveRoot = FileUtil.getArchiveFile(fo);
168
        if (archiveRoot != null) {
180
        if (archiveRoot != null) {
169
            fo = archiveRoot;
181
            fo = archiveRoot;
170
        }
182
        }
171
        return isJ2MEFolder(fo.getParent());
183
        return isJ2MEFolder(fo.getParent());
172
    }
184
    }
173
        
185
174
    private static boolean isJ2MEFolder(FileObject fo) { 
186
    private static boolean isJ2MEFolder(FileObject fo) {
175
        if (fo == null) return false;
187
        if (fo == null) {
188
            return false;
189
        }
176
        synchronized (roots) {
190
        synchronized (roots) {
177
            if (roots.contains(fo)) return true;
191
            if (roots.contains(fo)) {
192
                return true;
193
            }
178
        }
194
        }
179
        Boolean result;
195
        Boolean result;
180
        synchronized (folders) {
196
        synchronized (folders) {
Lines 184-191 public final class J2MEProject implement Link Here
184
            FileObject xml;
200
            FileObject xml;
185
            if (fo.isFolder() && (xml = fo.getFileObject("nbproject/project.xml")) != null) {
201
            if (fo.isFolder() && (xml = fo.getFileObject("nbproject/project.xml")) != null) {
186
                result = isJ2MEProjectXML(xml);
202
                result = isJ2MEProjectXML(xml);
187
                if (result) synchronized (roots) {
203
                if (result) {
188
                    roots.add(fo);
204
                    synchronized (roots) {
205
                        roots.add(fo);
206
                    }
189
                }
207
                }
190
            } else {
208
            } else {
191
                result = isJ2MEFolder(fo.getParent());
209
                result = isJ2MEFolder(fo.getParent());
Lines 197-211 public final class J2MEProject implement Link Here
197
        return result;
215
        return result;
198
    }
216
    }
199
217
200
    public boolean isConfigBroken (ProjectConfiguration cfg) {
218
    public boolean isConfigBroken(ProjectConfiguration cfg) {
201
        cfg = cfg == null ? configHelper.getActiveConfiguration() : cfg;
219
        cfg = cfg == null ? configHelper.getActiveConfiguration() : cfg;
202
        String[] breakableConfigProperties = getBreakableProperties (cfg);
220
        String[] breakableConfigProperties = getBreakableProperties(cfg);
203
        String[] breakableConfigPlatformProperties = getBreakablePlatformProperties (cfg);
221
        String[] breakableConfigPlatformProperties = getBreakablePlatformProperties(cfg);
204
        boolean result = BrokenReferencesSupport.isBroken( helper, refHelper, 
222
        boolean result = BrokenReferencesSupport.isBroken(helper, refHelper,
205
                breakableConfigProperties, breakableConfigPlatformProperties);
223
                breakableConfigProperties, breakableConfigPlatformProperties);
206
        //also check for unresolved ant properties
224
        //also check for unresolved ant properties
207
        return result || breakableConfigProperties != null &&
225
        return result || breakableConfigProperties != null &&
208
                breakableConfigProperties[1] != null && 
226
                breakableConfigProperties[1] != null &&
209
                breakableConfigProperties[1].contains("${");
227
                breakableConfigProperties[1].contains("${");
210
    }
228
    }
211
229
Lines 239-245 public final class J2MEProject implement Link Here
239
            if (libs == null) {
257
            if (libs == null) {
240
                libs = DefaultPropertiesDescriptor.PLATFORM_ACTIVE;
258
                libs = DefaultPropertiesDescriptor.PLATFORM_ACTIVE;
241
            } else {
259
            } else {
242
                libs = J2MEProjectProperties.CONFIG_PREFIX + 
260
                libs = J2MEProjectProperties.CONFIG_PREFIX +
243
                        cfg.getDisplayName() + "." +
261
                        cfg.getDisplayName() + "." +
244
                        DefaultPropertiesDescriptor.PLATFORM_ACTIVE;
262
                        DefaultPropertiesDescriptor.PLATFORM_ACTIVE;
245
            }
263
            }
Lines 248-272 public final class J2MEProject implement Link Here
248
    }
266
    }
249
267
250
    private String[] getBreakablePlatformProperties(ProjectConfiguration cfg) {
268
    private String[] getBreakablePlatformProperties(ProjectConfiguration cfg) {
251
        String s[]=new String[1];
269
        String s[] = new String[1];
252
        s[0]=usedActive(cfg);
270
        s[0] = usedActive(cfg);
253
        return s;
271
        return s;
254
    }
272
    }
255
273
256
    public String[] getBreakableProperties() {
274
    public String[] getBreakableProperties() {
257
        final ProjectConfiguration pc[] = configHelper.getConfigurations().toArray(
275
        final ProjectConfiguration pc[] = configHelper.getConfigurations().toArray(
258
                new ProjectConfiguration[0]);
276
                new ProjectConfiguration[0]);
259
        String s[] = new String[2*pc.length+1];
277
        String s[] = new String[2 * pc.length + 1];
260
        s[0] = DefaultPropertiesDescriptor.SRC_DIR;
278
        s[0] = DefaultPropertiesDescriptor.SRC_DIR;
261
        for (int i= 0; i<pc.length; i++) {
279
        for (int i = 0; i < pc.length; i++) {
262
            if (configHelper.getDefaultConfiguration().equals(pc[i])) {
280
            if (configHelper.getDefaultConfiguration().equals(pc[i])) {
263
                s[2*i+1] = DefaultPropertiesDescriptor.LIBS_CLASSPATH;
281
                s[2 * i + 1] = DefaultPropertiesDescriptor.LIBS_CLASSPATH;
264
                s[2*i+2] = DefaultPropertiesDescriptor.SIGN_KEYSTORE;
282
                s[2 * i + 2] = DefaultPropertiesDescriptor.SIGN_KEYSTORE;
265
            } else {
283
            } else {
266
                s[2*i+1] = J2MEProjectProperties.CONFIG_PREFIX + 
284
                s[2 * i + 1] = J2MEProjectProperties.CONFIG_PREFIX +
267
                        pc[i].getDisplayName() + "." +
285
                        pc[i].getDisplayName() + "." +
268
                        DefaultPropertiesDescriptor.LIBS_CLASSPATH; //NOI18N
286
                        DefaultPropertiesDescriptor.LIBS_CLASSPATH; //NOI18N
269
                s[2*i+2] = J2MEProjectProperties.CONFIG_PREFIX + 
287
                s[2 * i + 2] = J2MEProjectProperties.CONFIG_PREFIX +
270
                        pc[i].getDisplayName() + "." +
288
                        pc[i].getDisplayName() + "." +
271
                        DefaultPropertiesDescriptor.SIGN_KEYSTORE; //NOI18N
289
                        DefaultPropertiesDescriptor.SIGN_KEYSTORE; //NOI18N
272
            }
290
            }
Lines 278-288 public final class J2MEProject implement Link Here
278
        final ProjectConfiguration pc[] =
296
        final ProjectConfiguration pc[] =
279
                configHelper.getConfigurations().toArray(new ProjectConfiguration[0]);
297
                configHelper.getConfigurations().toArray(new ProjectConfiguration[0]);
280
        String s[] = new String[pc.length];
298
        String s[] = new String[pc.length];
281
        for (int i= 0; i<pc.length; i++) {
299
        for (int i = 0; i < pc.length; i++) {
282
            if (configHelper.getDefaultConfiguration().equals(pc[i])) {
300
            if (configHelper.getDefaultConfiguration().equals(pc[i])) {
283
                s[i] = DefaultPropertiesDescriptor.PLATFORM_ACTIVE;
301
                s[i] = DefaultPropertiesDescriptor.PLATFORM_ACTIVE;
284
            } else {
302
            } else {
285
                s[i] = J2MEProjectProperties.CONFIG_PREFIX + 
303
                s[i] = J2MEProjectProperties.CONFIG_PREFIX +
286
                        pc[i].getDisplayName() + "." +
304
                        pc[i].getDisplayName() + "." +
287
                        DefaultPropertiesDescriptor.PLATFORM_ACTIVE; //NOI18N
305
                        DefaultPropertiesDescriptor.PLATFORM_ACTIVE; //NOI18N
288
            }
306
            }
Lines 317-345 public final class J2MEProject implement Link Here
317
        }
335
        }
318
        return libs;
336
        return libs;
319
    }
337
    }
320
    
338
321
    protected static void addRoots(final AntProjectHelper helper) {
339
    protected static void addRoots(AntProjectHelper helper, final SourceRoots roots) {
322
        final String src = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
340
        for (FileObject root : roots.getRoots()) {
323
        if (src != null) addRoot(helper.resolveFileObject(src));
341
            addRoot(root);
342
        }
324
    }
343
    }
325
    
344
326
    private static void addRoot(final FileObject fo) {
345
    private static void addRoot(final FileObject fo) {
327
        if (fo != null && !isJ2MEFile(fo)) {
346
        if (fo != null && !isJ2MEFile(fo)) {
328
            synchronized (roots) {
347
            synchronized (roots) {
329
                if (roots.add(fo))
348
                if (roots.add(fo)) {
330
                    RequestProcessor.getDefault().post(new Runnable() {
349
                    RequestProcessor.getDefault().post(new Runnable() {
350
331
                        public void run() {
351
                        public void run() {
332
                            final Enumeration en = fo.getChildren(true);
352
                            final Enumeration en = fo.getChildren(true);
333
                            while (en.hasMoreElements()) try {
353
                            while (en.hasMoreElements()) {
334
                                final FileObject f2 = (FileObject)en.nextElement();
354
                                try {
335
                                if (f2.getExt().equals("java")) DataObject.find(f2).setValid(false); //NOI18N
355
                                    final FileObject f2 = (FileObject) en.nextElement();
336
                            } catch (Exception e) {}
356
                                    if (f2.getExt().equals("java")) {
357
                                        DataObject.find(f2).setValid(false); //NOI18N
358
                                    }
359
                                } catch (Exception e) {
360
                                }
361
                            }
337
                        }
362
                        }
338
                    });
363
                    });
364
                }
339
            }
365
            }
340
        }
366
        }
341
    }
367
    }
342
    
368
343
    private static boolean isJ2MEProjectXML(final FileObject fo) {
369
    private static boolean isJ2MEProjectXML(final FileObject fo) {
344
        BufferedReader in = null;
370
        BufferedReader in = null;
345
        try {
371
        try {
Lines 347-417 public final class J2MEProject implement Link Here
347
                in = new BufferedReader(new InputStreamReader(fo.getInputStream()));
373
                in = new BufferedReader(new InputStreamReader(fo.getInputStream()));
348
                String s;
374
                String s;
349
                while ((s = in.readLine()) != null) {
375
                while ((s = in.readLine()) != null) {
350
                    if (s.indexOf("<type>"+J2MEProjectType.TYPE+"</type>") >= 0) return true; //NOI18N
376
                    if (s.indexOf("<type>" + J2MEProjectType.TYPE + "</type>") >= 0) {
377
                        return true; //NOI18N
378
                    }
351
                }
379
                }
352
            } finally {
380
            } finally {
353
                if (in != null) in.close();
381
                if (in != null) {
382
                    in.close();
383
                }
354
            }
384
            }
355
        } catch (IOException ioe) {}
385
        } catch (IOException ioe) {
386
        }
356
        return false;
387
        return false;
357
    }
388
    }
358
    
389
359
    J2MEProject(AntProjectHelper helper) {
390
    J2MEProject(AntProjectHelper helper) {
360
        this.helper = helper;
391
        this.helper = helper;
361
        addRoots(helper);
362
        aux = helper.createAuxiliaryConfiguration();
392
        aux = helper.createAuxiliaryConfiguration();
363
        refHelper = new ReferenceHelper(helper, aux, helper.getStandardPropertyEvaluator());
393
        refHelper = new ReferenceHelper(helper, aux, helper.getStandardPropertyEvaluator());
364
        configHelper = new ProjectConfigurationsHelper(helper, this);
394
        configHelper = new ProjectConfigurationsHelper(helper, this);
365
        genFilesHelper = new GeneratedFilesHelper(helper);
395
        genFilesHelper = new GeneratedFilesHelper(helper);
366
        midletsCacheHelper = new MIDletsCacheHelper(helper, configHelper);
396
        midletsCacheHelper = new MIDletsCacheHelper(helper, configHelper);
367
        helper.addAntProjectListener(new CDCMainClassHelper(helper));
397
        helper.addAntProjectListener(new CDCMainClassHelper(this, helper));
368
        pcs = new PropertyChangeSupport(this);
398
        pcs = new PropertyChangeSupport(this);
399
        helper.addAntProjectListener(this);
400
        //XXX should be possible to make these more lazy
401
        updater = new UpdateHelper(new Updater(this, helper, aux), helper);
402
        this.sourceRoots = SourceRoots.create(
403
                updater,
404
                evaluator(),
405
                refHelper,
406
                J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
407
                "source-roots", false, "src.{0}{1}.dir"); //NOI18N
408
        this.testSourceRoots = SourceRoots.create(
409
                updater,
410
                evaluator(),
411
                refHelper,
412
                J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
413
                "test-roots", false, "src.{0}{1}.dir"); //NOI18N
414
        if (sourceRoots == null) {
415
            throw new NullPointerException ("SourceRoots.create() returned null");
416
        }
417
418
        assert sourceRoots != null;
419
        assert testSourceRoots != null;
369
        this.lookup = this.createLookup(aux);
420
        this.lookup = this.createLookup(aux);
370
        helper.addAntProjectListener(this);
421
        addRoots(helper, sourceRoots);
371
    }
422
    }
372
    
423
424
    public PropertyEvaluator evaluator() {
425
        return helper.getStandardPropertyEvaluator();
426
    }
427
373
    public void hookNewProjectCreated() {
428
    public void hookNewProjectCreated() {
374
        midletsCacheHelper.refresh();
429
        midletsCacheHelper.refresh();
375
    }
430
    }
376
    
431
377
    public FileObject getProjectDirectory() {
432
    public FileObject getProjectDirectory() {
378
        return helper.getProjectDirectory();
433
        return helper.getProjectDirectory();
379
    }
434
    }
380
    
435
381
    public Lookup getLookup() {
436
    public Lookup getLookup() {
382
        return this.lookup;
437
        return this.lookup;
383
    }
438
    }
384
    
439
385
    public ProjectConfigurationsHelper getConfigurationHelper() {
440
    public ProjectConfigurationsHelper getConfigurationHelper() {
386
        return configHelper;
441
        return configHelper;
387
    }
442
    }
388
443
389
    private Lookup createLookup(final AuxiliaryConfiguration aux) {
444
    private Lookup createLookup(final AuxiliaryConfiguration aux) {
390
        final SourcesHelper sourcesHelper = new SourcesHelper(helper, helper.getStandardPropertyEvaluator());
445
        FileEncodingQueryImplementation encodingQuery =
391
        sourcesHelper.addPrincipalSourceRoot("${src.dir}", NbBundle.getMessage(J2MEProject.class, "LBL_J2MEProject_Source_Packages"), null, null); //NOI18N
446
                QuerySupport.createFileEncodingQuery(evaluator(),
392
        sourcesHelper.addTypedSourceRoot("${src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(J2MEProject.class, "LBL_J2MEProject_Source_Packages"), null, null); //NOI18N
447
                J2MEProjectProperties.SOURCE_ENCODING);
393
        final SubprojectProvider spp = refHelper.createSubprojectProvider();
448
        final SubprojectProvider spp = refHelper.createSubprojectProvider();
394
        
449
        //XXX does not handle deployment.copy.target yet
395
        Object stdLookups[]=new Object[] {
450
            //            helper.createSharabilityQuery(evaluator(),
451
            //                    new String[]{"${src.dir}"},
452
            //                    new String[]{"${dist.root.dir}",
453
            //                    "${build.root.dir}",
454
            //                    "${deployment.copy.target}"}), //NOI18N
455
        assert sourceRoots != null;
456
        assert helper != null;
457
        assert evaluator() != null;
458
        assert sourceRoots != null;
459
        assert testSourceRoots != null;
460
        SharabilityQueryImplementation sharability =
461
                QuerySupport.createSharabilityQuery(helper, evaluator(),
462
                sourceRoots, testSourceRoots);
463
464
        Object stdLookups[] = new Object[]{
396
            new Info(),
465
            new Info(),
397
            aux,
466
            aux,
398
            spp,
467
            spp,
399
            configHelper,
468
            configHelper,
469
            updater,
470
            encodingQuery,
400
            helper,
471
            helper,
401
            midletsCacheHelper,
472
            midletsCacheHelper,
402
            refHelper,
473
            refHelper,
403
            new FileBuiltQueryImpl(helper, configHelper),
474
            new J2MEClassPathProvider(helper, getSourceRoots(), getTestSourceRoots()),
404
            new J2MEActionProvider( this, helper ),
475
            sharability,
476
            new J2MESources(helper, evaluator(), sourceRoots, getTestSourceRoots()),
477
            UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()),
478
            QuerySupport.createTemplateAttributesProvider(helper, encodingQuery),
479
            new FileBuiltQueryImpl(this, helper, configHelper),
480
            new J2MEActionProvider(this, helper),
405
            new J2MEPhysicalViewProvider(this, helper, refHelper, configHelper),
481
            new J2MEPhysicalViewProvider(this, helper, refHelper, configHelper),
406
            new J2MECustomizerProvider( this, helper, refHelper, configHelper),
482
            new J2MECustomizerProvider(this, helper, refHelper, configHelper),
407
            new J2MEClassPathProvider(helper),
408
            new CompiledSourceForBinaryQuery(this, helper),
483
            new CompiledSourceForBinaryQuery(this, helper),
409
            new AntArtifactProviderImpl(),
484
            new AntArtifactProviderImpl(),
410
            new ProjectXmlSavedHookImpl(),
485
            new ProjectXmlSavedHookImpl(),
411
            new ProjectOpenedHookImpl(),
486
            new ProjectOpenedHookImpl(),
412
            new JavadocForBinaryQueryImpl(this, helper),
487
            new JavadocForBinaryQueryImpl(this, helper),
413
            helper.createSharabilityQuery(helper.getStandardPropertyEvaluator(), new String[]{"${src.dir}"}, new String[]{"${dist.root.dir}", "${build.root.dir}", "${deployment.copy.target}"}), //NOI18N
414
            sourcesHelper.createSources(),
415
            new RecommendedTemplatesImpl(),
488
            new RecommendedTemplatesImpl(),
416
            new SourceLevelQueryImpl(helper),
489
            new SourceLevelQueryImpl(helper),
417
            new J2MEProjectClassPathExtender(this, helper, refHelper, configHelper),
490
            new J2MEProjectClassPathExtender(this, helper, refHelper, configHelper),
Lines 419-441 public final class J2MEProject implement Link Here
419
            new PreprocessorFileFilterImplementation(configHelper, helper),
492
            new PreprocessorFileFilterImplementation(configHelper, helper),
420
            new FileEncodingQueryImpl(helper)
493
            new FileEncodingQueryImpl(helper)
421
        };
494
        };
422
        ArrayList<Object> list=new ArrayList<Object>();
495
        ArrayList<Object> list = new ArrayList<Object>();
423
        list.addAll(Arrays.asList(stdLookups));
496
        list.addAll(Arrays.asList(stdLookups));
424
        for (ProjectLookupProvider provider : Lookup.getDefault().lookupAll(ProjectLookupProvider.class))
497
        for (ProjectLookupProvider provider : Lookup.getDefault().lookupAll(ProjectLookupProvider.class)) {
425
        {
498
            list.addAll(provider.createLookupElements(this, helper, refHelper, configHelper));
426
            list.addAll(provider.createLookupElements(this,helper,refHelper,configHelper));
427
        }
499
        }
428
        return Lookups.fixed(list.toArray());
500
        return Lookups.fixed(list.toArray());
429
//        return new AnalysisLookup (list.toArray());
430
    }
501
    }
431
    
502
503
    public SourceRoots getSourceRoots() {
504
        return this.sourceRoots;
505
    }
506
507
    public SourceRoots getTestSourceRoots() {
508
        return this.testSourceRoots;
509
    }
510
432
    /** Store configured project name. */
511
    /** Store configured project name. */
433
    public void setName(final String name) {
512
    public void setName(final String name) {
434
        ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
513
        ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() {
514
435
            public Object run() {
515
            public Object run() {
436
                final Element data = helper.getPrimaryConfigurationData(true);
516
                final Element data = helper.getPrimaryConfigurationData(true);
437
                // XXX replace by XMLUtil when that has findElement, findText, etc.
517
                // XXX replace by XMLUtil when that has findElement, findText, etc.
438
                final NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name");
518
                final NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "name");
439
                Element nameEl;
519
                Element nameEl;
440
                if (nl.getLength() == 1) {
520
                if (nl.getLength() == 1) {
441
                    nameEl = (Element) nl.item(0);
521
                    nameEl = (Element) nl.item(0);
Lines 444-451 public final class J2MEProject implement Link Here
444
                        nameEl.removeChild(deadKids.item(0));
524
                        nameEl.removeChild(deadKids.item(0));
445
                    }
525
                    }
446
                } else {
526
                } else {
447
                    nameEl = data.getOwnerDocument().createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name");
527
                    nameEl = data.getOwnerDocument().createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "name");
448
                    data.insertBefore(nameEl, /* OK if null */data.getChildNodes().item(0));
528
                    data.insertBefore(nameEl, /* OK if null */ data.getChildNodes().item(0));
449
                }
529
                }
450
                nameEl.appendChild(data.getOwnerDocument().createTextNode(name));
530
                nameEl.appendChild(data.getOwnerDocument().createTextNode(name));
451
                helper.putPrimaryConfigurationData(data, true);
531
                helper.putPrimaryConfigurationData(data, true);
Lines 453-491 public final class J2MEProject implement Link Here
453
            }
533
            }
454
        });
534
        });
455
    }
535
    }
456
    
536
457
    public void addPropertyChangeListener(final PropertyChangeListener listener) {
537
    public void addPropertyChangeListener(final PropertyChangeListener listener) {
458
        pcs.addPropertyChangeListener(listener);
538
        pcs.addPropertyChangeListener(listener);
459
    }
539
    }
460
    
540
461
    public void removePropertyChangeListener(final PropertyChangeListener listener) {
541
    public void removePropertyChangeListener(final PropertyChangeListener listener) {
462
        pcs.removePropertyChangeListener(listener);
542
        pcs.removePropertyChangeListener(listener);
463
    }
543
    }
464
    
544
465
    public void configurationXmlChanged(final AntProjectEvent ev) {
545
    public void configurationXmlChanged(final AntProjectEvent ev) {
466
        if (ev.getPath().equals(AntProjectHelper.PROJECT_XML_PATH)) {
546
        if (ev.getPath().equals(AntProjectHelper.PROJECT_XML_PATH)) {
467
            // Could be various kinds of changes, but name & displayName might have changed.
547
            // Could be various kinds of changes, but name & displayName might have changed.
468
            final Info info = (Info)getLookup().lookup(ProjectInformation.class);
548
            final Info info = (Info) getLookup().lookup(ProjectInformation.class);
469
            info.firePropertyChange(ProjectInformation.PROP_NAME);
549
            info.firePropertyChange(ProjectInformation.PROP_NAME);
470
            info.firePropertyChange(ProjectInformation.PROP_DISPLAY_NAME);
550
            info.firePropertyChange(ProjectInformation.PROP_DISPLAY_NAME);
471
        }
551
        }
472
    }
552
    }
473
    
553
474
    public void propertiesChanged(@SuppressWarnings("unused")
554
    public void propertiesChanged(@SuppressWarnings("unused")
475
	final AntProjectEvent ev) {
555
            final AntProjectEvent ev) {
476
        // currently ignored
556
        // currently ignored
477
    }
557
    }
478
 
558
479
    
480
    protected void refreshPrivateProperties() throws IOException {
559
    protected void refreshPrivateProperties() throws IOException {
481
        try {
560
        try {
482
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Object>() {
561
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Object>() {
483
                public Object run()  {
562
563
                public Object run() {
484
                    boolean modified = false;
564
                    boolean modified = false;
485
                    EditableProperties proj = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
565
                    EditableProperties proj = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
486
                    EditableProperties priv = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
566
                    EditableProperties priv = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
487
                    priv.setProperty("netbeans.user",  System.getProperty("netbeans.user")); //NOI18N
567
                    priv.setProperty("netbeans.user", System.getProperty("netbeans.user")); //NOI18N
488
                    for (ProjectPropertiesDescriptor p : Lookup.getDefault().lookup(new Lookup.Template<ProjectPropertiesDescriptor>(ProjectPropertiesDescriptor.class)).allInstances() ) {
568
                    for (ProjectPropertiesDescriptor p : Lookup.getDefault().lookup(new Lookup.Template<ProjectPropertiesDescriptor>(ProjectPropertiesDescriptor.class)).allInstances()) {
489
                        for (PropertyDescriptor d : p.getPropertyDescriptors()) {
569
                        for (PropertyDescriptor d : p.getPropertyDescriptors()) {
490
                            if (d.getDefaultValue() != null) {
570
                            if (d.getDefaultValue() != null) {
491
                                EditableProperties ep = d.isShared() ? proj : priv;
571
                                EditableProperties ep = d.isShared() ? proj : priv;
Lines 500-506 public final class J2MEProject implement Link Here
500
                    if (!cfgs.isEmpty()) {
580
                    if (!cfgs.isEmpty()) {
501
                        modified = true;
581
                        modified = true;
502
                        cfgs.addAll(Arrays.asList(proj.getProperty(DefaultPropertiesDescriptor.ALL_CONFIGURATIONS).split(",")));
582
                        cfgs.addAll(Arrays.asList(proj.getProperty(DefaultPropertiesDescriptor.ALL_CONFIGURATIONS).split(",")));
503
                        cfgs.remove(" "); cfgs.remove(""); //NOI18N
583
                        cfgs.remove(" ");
584
                        cfgs.remove(""); //NOI18N
504
                        StringBuffer sb = new StringBuffer(" "); //NOI18N
585
                        StringBuffer sb = new StringBuffer(" "); //NOI18N
505
                        for (String s : cfgs) {
586
                        for (String s : cfgs) {
506
                            sb.append(',').append(s);
587
                            sb.append(',').append(s);
Lines 508-514 public final class J2MEProject implement Link Here
508
                        proj.setProperty(DefaultPropertiesDescriptor.ALL_CONFIGURATIONS, sb.toString());
589
                        proj.setProperty(DefaultPropertiesDescriptor.ALL_CONFIGURATIONS, sb.toString());
509
                    }
590
                    }
510
                    helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, priv);
591
                    helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, priv);
511
                    if (modified) helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, proj);
592
                    if (modified) {
593
                        helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, proj);
594
                    }
512
                    try {
595
                    try {
513
                        refHelper.addExtraBaseDirectory("netbeans.user"); //NOI18N
596
                        refHelper.addExtraBaseDirectory("netbeans.user"); //NOI18N
514
                    } catch (IllegalArgumentException iae) {
597
                    } catch (IllegalArgumentException iae) {
Lines 518-524 public final class J2MEProject implement Link Here
518
                }
601
                }
519
            });
602
            });
520
        } catch (MutexException e) {
603
        } catch (MutexException e) {
521
            throw (IOException)e.getException();
604
            throw (IOException) e.getException();
522
        }
605
        }
523
        // Probably unnecessary, but just in case:
606
        // Probably unnecessary, but just in case:
524
        try {
607
        try {
Lines 527-544 public final class J2MEProject implement Link Here
527
            ErrorManager.getDefault().notify(e);
610
            ErrorManager.getDefault().notify(e);
528
        }
611
        }
529
    }
612
    }
530
    
613
531
    private Set<String> removeConfigurationsFromProjectXml() {
614
    private Set<String> removeConfigurationsFromProjectXml() {
532
        TreeSet<String> cfgs = new TreeSet();
615
        TreeSet<String> cfgs = new TreeSet();
533
        Element configs = aux.getConfigurationFragment(CONFIGS_NAME, CONFIGS_NS, true);
616
        Element configs = aux.getConfigurationFragment(CONFIGS_NAME, CONFIGS_NS, true);
534
        if (configs != null) {
617
        if (configs != null) {
535
            try {
618
            try {
536
                NodeList subEls = configs.getElementsByTagNameNS(CONFIGS_NS, CONFIG_NAME);
619
                NodeList subEls = configs.getElementsByTagNameNS(CONFIGS_NS, CONFIG_NAME);
537
                for (int i=0; i<subEls.getLength(); i++) {
620
                for (int i = 0; i < subEls.getLength(); i++) {
538
                    final NodeList l = subEls.item(i).getChildNodes();
621
                    final NodeList l = subEls.item(i).getChildNodes();
539
                    for (int j = 0; j < l.getLength(); j++) {
622
                    for (int j = 0; j < l.getLength(); j++) {
540
                        if (l.item(j).getNodeType() == Node.TEXT_NODE) {
623
                        if (l.item(j).getNodeType() == Node.TEXT_NODE) {
541
                            cfgs.add(((Text)l.item(j)).getNodeValue());
624
                            cfgs.add(((Text) l.item(j)).getNodeValue());
542
                        }
625
                        }
543
                    }
626
                    }
544
                }
627
                }
Lines 550-565 public final class J2MEProject implement Link Here
550
        }
633
        }
551
        return cfgs;
634
        return cfgs;
552
    }
635
    }
553
    
636
554
    /**
637
    /**
555
     * Return configured project name.
638
     * Return configured project name.
556
     */
639
     */
557
    public String getName() {
640
    public String getName() {
558
        return ProjectManager.mutex().readAccess(new Mutex.Action<String>() {
641
        return ProjectManager.mutex().readAccess(new Mutex.Action<String>() {
642
559
            public String run() {
643
            public String run() {
560
                final Element data = helper.getPrimaryConfigurationData(true);
644
                final Element data = helper.getPrimaryConfigurationData(true);
561
                // XXX replace by XMLUtil when that has findElement, findText, etc.
645
                // XXX replace by XMLUtil when that has findElement, findText, etc.
562
                NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N
646
                NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N
647
                if (nl.getLength() == 0) {
648
                    nl = data.getElementsByTagNameNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name");
649
                }
563
                if (nl.getLength() == 1) {
650
                if (nl.getLength() == 1) {
564
                    nl = nl.item(0).getChildNodes();
651
                    nl = nl.item(0).getChildNodes();
565
                    if (nl.getLength() == 1 && nl.item(0).getNodeType() == Node.TEXT_NODE) {
652
                    if (nl.getLength() == 1 && nl.item(0).getNodeType() == Node.TEXT_NODE) {
Lines 570-657 public final class J2MEProject implement Link Here
570
            }
657
            }
571
        });
658
        });
572
    }
659
    }
573
    
660
574
    // Private innerclasses ----------------------------------------------------
661
    // Private innerclasses ----------------------------------------------------
575
    
576
    private final class ProjectXmlSavedHookImpl extends ProjectXmlSavedHook {
662
    private final class ProjectXmlSavedHookImpl extends ProjectXmlSavedHook {
577
        
663
578
        ProjectXmlSavedHookImpl() {
664
        ProjectXmlSavedHookImpl() {
579
            // Just to avoid creating accessor class
665
            // Just to avoid creating accessor class
580
        }
666
        }
581
        
667
582
        protected void projectXmlSaved() throws IOException {
668
        protected void projectXmlSaved() throws IOException {
583
            refreshBuildScripts(false);
669
            refreshBuildScripts(false);
584
        }
670
        }
585
        
586
    }
671
    }
587
    
672
588
    private final class ProjectOpenedHookImpl extends ProjectOpenedHook implements LookupListener {
673
    private final class ProjectOpenedHookImpl extends ProjectOpenedHook implements LookupListener {
589
        
674
590
        private boolean skipCloseHook = false;
675
        private boolean skipCloseHook = false;
591
        private PropertyChangeListener platformListener;
676
        private PropertyChangeListener platformListener;
592
        private Lookup.Result deployments;
677
        private Lookup.Result deployments;
593
678
594
        //We need those listners to be able to check for changes on paltform bootclasspath
679
        //We need those listners to be able to check for changes on paltform bootclasspath
595
        private final class PlatformInstalledListener implements PropertyChangeListener 
680
        private final class PlatformInstalledListener implements PropertyChangeListener {
596
        {
681
597
            final List<JavaPlatform> knownPlatforms;
682
            final List<JavaPlatform> knownPlatforms;
598
            private final PropertyChangeListener platformChange = new PropertyChangeListener()
683
            private final PropertyChangeListener platformChange = new PropertyChangeListener() {
599
            {
684
600
                public void propertyChange(PropertyChangeEvent evt)
685
                public void propertyChange(PropertyChangeEvent evt) {
601
                {
686
                    if (CLASSPATH.equals(evt.getPropertyName()) && evt.getSource() instanceof CDCPlatform) {
602
                    if (CLASSPATH.equals(evt.getPropertyName()) && evt.getSource() instanceof CDCPlatform)
687
                        CDCPlatform platform = (CDCPlatform) evt.getSource();
603
                    {
688
                        if (platform != null) {
604
                       CDCPlatform platform = (CDCPlatform)evt.getSource(); 
689
                            List<ProjectConfiguration> configs = J2MEProject.this.getMatchingConfigs((String) platform.getProperties().get("platform.ant.name"));
605
                       if (platform != null)
690
                            J2MEProject.this.updateBootClassPathProperty(configs, platform);
606
                       {
691
                        }
607
                           List<ProjectConfiguration> configs = J2MEProject.this.getMatchingConfigs((String)platform.getProperties().get("platform.ant.name"));
608
                           J2MEProject.this.updateBootClassPathProperty(configs, platform);
609
                       }
610
                    }
692
                    }
611
                }
693
                }
612
            };
694
            };
613
695
614
            PlatformInstalledListener(JavaPlatform known[])
696
            PlatformInstalledListener(JavaPlatform known[]) {
615
            {
697
                knownPlatforms = new ArrayList(Arrays.asList(known));
616
                knownPlatforms=new ArrayList(Arrays.asList(known));
617
698
618
                for (JavaPlatform plat : knownPlatforms)
699
                for (JavaPlatform plat : knownPlatforms) {
619
                {
620
                    plat.addPropertyChangeListener(platformChange);
700
                    plat.addPropertyChangeListener(platformChange);
621
                    List<ProjectConfiguration> configs = J2MEProject.this.getMatchingConfigs(plat.getProperties().get("platform.ant.name"));
701
                    List<ProjectConfiguration> configs = J2MEProject.this.getMatchingConfigs(plat.getProperties().get("platform.ant.name"));
622
                    J2MEProject.this.updateBootClassPathProperty(configs, (CDCPlatform)plat);
702
                    J2MEProject.this.updateBootClassPathProperty(configs, (CDCPlatform) plat);
623
                }
703
                }
624
            }
704
            }
625
705
626
            public void propertyChange(PropertyChangeEvent evt)
706
            public void propertyChange(PropertyChangeEvent evt) {
627
            {
707
                if (evt.getPropertyName().equals(JavaPlatformManager.PROP_INSTALLED_PLATFORMS)) {
628
                if (evt.getPropertyName().equals(JavaPlatformManager.PROP_INSTALLED_PLATFORMS))
708
                    JavaPlatform[] known = JavaPlatformManager.getDefault().getPlatforms(null, new Specification(CDCPlatform.PLATFORM_CDC, null));
629
                {
709
                    List<JavaPlatform> list = Arrays.asList(known);
630
                    JavaPlatform[] known=JavaPlatformManager.getDefault().getPlatforms(null, new Specification (CDCPlatform.PLATFORM_CDC,null));
631
                    List<JavaPlatform> list=Arrays.asList(known);
632
                    List<JavaPlatform> added = new ArrayList(Arrays.asList(known));
710
                    List<JavaPlatform> added = new ArrayList(Arrays.asList(known));
633
                    added.removeAll(knownPlatforms);
711
                    added.removeAll(knownPlatforms);
634
                    knownPlatforms.removeAll(list);
712
                    knownPlatforms.removeAll(list);
635
                    for (JavaPlatform platform : knownPlatforms)
713
                    for (JavaPlatform platform : knownPlatforms) {
636
                    {
637
                        platform.removePropertyChangeListener(platformChange);
714
                        platform.removePropertyChangeListener(platformChange);
638
                    }
715
                    }
639
                    for (JavaPlatform platform : added)
716
                    for (JavaPlatform platform : added) {
640
                    {
641
                        platform.addPropertyChangeListener(platformChange);
717
                        platform.addPropertyChangeListener(platformChange);
642
                    }
718
                    }
643
                    knownPlatforms.clear();
719
                    knownPlatforms.clear();
644
                    knownPlatforms.addAll(list);
720
                    knownPlatforms.addAll(list);
645
                }   
721
                }
646
            }
722
            }
647
        };
723
        };
648
    
724
649
        
650
        ProjectOpenedHookImpl() {
725
        ProjectOpenedHookImpl() {
651
            // Just to avoid creating accessor class
726
            // Just to avoid creating accessor class
652
        }
727
        }
653
        
728
654
        protected synchronized void projectOpened() {
729
        protected synchronized void projectOpened() {
730
            UpdateHelper updater = getLookup().lookup(UpdateHelper.class);
731
            assert updater != null;
732
            try {
733
                if (!updater.isCurrent()) {
734
                    updater.requestUpdate();
735
                }
736
            } catch (IOException ex) {
737
                Exceptions.printStackTrace(ex);
738
            }
655
            //inicialize deployment plugins
739
            //inicialize deployment plugins
656
            deployments = Lookup.getDefault().lookup(new Lookup.Template<DeploymentPlugin>(DeploymentPlugin.class));
740
            deployments = Lookup.getDefault().lookup(new Lookup.Template<DeploymentPlugin>(DeploymentPlugin.class));
657
            deployments.addLookupListener(this);
741
            deployments.addLookupListener(this);
Lines 659-691 public final class J2MEProject implement Link Here
659
            //init keystore, safer than warmup
743
            //init keystore, safer than warmup
660
            KeyStoreRepository.getDefault();
744
            KeyStoreRepository.getDefault();
661
            // Check up on build scripts.
745
            // Check up on build scripts.
662
            addRoots(helper);
746
            addRoots(helper, getSourceRoots());
663
            final SourcesHelper sourcesHelper = getLookup().lookup(SourcesHelper.class);
747
            final SourcesHelper sourcesHelper = getLookup().lookup(SourcesHelper.class);
664
            final String srcDir = helper.getStandardPropertyEvaluator().getProperty(DefaultPropertiesDescriptor.SRC_DIR);
748
665
            final FileObject srcRoot = srcDir == null ? null : helper.resolveFileObject(srcDir);
749
            J2MESources sources = getLookup().lookup(J2MESources.class);
666
            final Project other = srcRoot == null ? null : FileOwnerQuery.getOwner(srcRoot);
750
            Set<Project> notified = new HashSet<Project>();
667
            if (other != null && !J2MEProject.this.equals(other)) {
751
            for (FileObject srcRoot : sources.getSourceRoots()) {
668
                if (Arrays.asList(OpenProjects.getDefault().getOpenProjects()).contains(other)) {
752
                Project other = srcRoot == null ? null : FileOwnerQuery.getOwner(srcRoot);
669
                    final ProjectInformation pi = other.getLookup().lookup(ProjectInformation.class);
753
                if (other != null && !J2MEProject.this.equals(other) && !notified.contains(other)) {
670
                    final String name = pi == null ? other.getProjectDirectory().getPath() : pi.getDisplayName();
754
                    if (Arrays.asList(OpenProjects.getDefault().getOpenProjects()).contains(other)) {
671
                    if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(
755
                        notified.add(other);
672
                            new NotifyDescriptor.Confirmation(NbBundle.getMessage(J2MEProject.class, "MSG_ClashingSourceRoots", J2MEProject.this.getName(), name), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.WARNING_MESSAGE)))) { //NOI18N
756
                        final ProjectInformation pi = other.getLookup().lookup(ProjectInformation.class);
673
                        OpenProjects.getDefault().close(new Project[]{other});
757
                        final String name = pi == null ? other.getProjectDirectory().getPath() : pi.getDisplayName();
674
                    } else {
758
                        if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(
675
                        skipCloseHook = true;
759
                                new NotifyDescriptor.Confirmation(NbBundle.getMessage(J2MEProject.class, "MSG_ClashingSourceRoots", J2MEProject.this.getName(), name), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.WARNING_MESSAGE)))) { //NOI18N
676
                        OpenProjects.getDefault().close(new Project[]{J2MEProject.this});
760
                            OpenProjects.getDefault().close(new Project[]{other});
677
                        return;
761
                        } else {
762
                            skipCloseHook = true;
763
                            OpenProjects.getDefault().close(new Project[]{J2MEProject.this});
764
                            return;
765
                        }
678
                    }
766
                    }
679
                }
767
                }
768
                final FileObject sourceRoot = srcRoot;
769
                ProjectManager.mutex().postWriteRequest(new Runnable() {
770
771
                    public void run() {
772
                        try {
773
                            if (sourcesHelper != null) {
774
                                sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
775
                            }
776
                        } catch (IllegalStateException ise) {
777
                        }
778
                        if (sourceRoot != null) {
779
                            FileOwnerQuery.markExternalOwner(sourceRoot, J2MEProject.this, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
780
                        }
781
                    }
782
                });
680
            }
783
            }
681
            ProjectManager.mutex().postWriteRequest(new Runnable() {
682
                public void run() {
683
                    try {
684
                        if (sourcesHelper != null) sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
685
                    } catch (IllegalStateException ise) {}
686
                    if (srcRoot != null) FileOwnerQuery.markExternalOwner(srcRoot, J2MEProject.this, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
687
                }
688
            });
689
            try {
784
            try {
690
                refreshBuildScripts(true);
785
                refreshBuildScripts(true);
691
                refreshPrivateProperties();
786
                refreshPrivateProperties();
Lines 693-718 public final class J2MEProject implement Link Here
693
            } catch (IOException e) {
788
            } catch (IOException e) {
694
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
789
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
695
            }
790
            }
696
            
791
697
            // register project's classpaths to GlobalPathRegistry
792
            // register project's classpaths to GlobalPathRegistry
698
            final J2MEClassPathProvider cpProvider = lookup.lookup(J2MEClassPathProvider.class);
793
            final J2MEClassPathProvider cpProvider = lookup.lookup(J2MEClassPathProvider.class);
699
            assert cpProvider != null;
794
            assert cpProvider != null;
700
            GlobalPathRegistry.getDefault().register(ClassPath.BOOT, new ClassPath[] {cpProvider.getBootClassPath()});
795
            GlobalPathRegistry.getDefault().register(ClassPath.BOOT, new ClassPath[]{cpProvider.getBootClassPath()});
701
            GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[] {cpProvider.getSourcepath()});
796
            GlobalPathRegistry.getDefault().register(ClassPath.SOURCE, new ClassPath[]{cpProvider.getSourcepath()});
702
            GlobalPathRegistry.getDefault().register(ClassPath.COMPILE, new ClassPath[] {cpProvider.getCompileTimeClasspath()});
797
            GlobalPathRegistry.getDefault().register(ClassPath.COMPILE, new ClassPath[]{cpProvider.getCompileTimeClasspath()});
703
            
798
704
            configHelper.addPropertyChangeListener(textSwitcher = new TextSwitcher(J2MEProject.this, helper));
799
            configHelper.addPropertyChangeListener(textSwitcher = new TextSwitcher(J2MEProject.this, helper));
705
800
706
            final J2MEPhysicalViewProvider phvp  = lookup.lookup(J2MEPhysicalViewProvider.class);
801
            final J2MEPhysicalViewProvider phvp = lookup.lookup(J2MEPhysicalViewProvider.class);
707
            if (hasBrokenLinks()) {
802
            if (hasBrokenLinks()) {
708
                BrokenReferencesSupport.showAlert();
803
                BrokenReferencesSupport.showAlert();
709
            }
804
            }
710
            
805
711
            midletsCacheHelper.refresh();
806
            midletsCacheHelper.refresh();
712
        }
807
        }
713
        
808
714
        protected synchronized void projectClosed() {
809
        protected synchronized void projectClosed() {
715
            if (skipCloseHook) return;
810
            if (skipCloseHook) {
811
                return;
812
            }
716
            //do not listen on deployments for this project
813
            //do not listen on deployments for this project
717
            deployments.removeLookupListener(this);
814
            deployments.removeLookupListener(this);
718
815
Lines 722-766 public final class J2MEProject implement Link Here
722
            } catch (IOException e) {
819
            } catch (IOException e) {
723
                ErrorManager.getDefault().notify(e);
820
                ErrorManager.getDefault().notify(e);
724
            }
821
            }
725
            
822
726
            configHelper.removePropertyChangeListener(textSwitcher);
823
            configHelper.removePropertyChangeListener(textSwitcher);
727
824
728
            // unregister project's classpaths to GlobalPathRegistry
825
            // unregister project's classpaths to GlobalPathRegistry
729
            final J2MEClassPathProvider cpProvider = lookup.lookup(J2MEClassPathProvider.class);
826
            final J2MEClassPathProvider cpProvider = lookup.lookup(J2MEClassPathProvider.class);
730
            GlobalPathRegistry.getDefault().unregister(ClassPath.BOOT, new ClassPath[] {cpProvider.getBootClassPath()});
827
            GlobalPathRegistry.getDefault().unregister(ClassPath.BOOT, new ClassPath[]{cpProvider.getBootClassPath()});
731
            GlobalPathRegistry.getDefault().unregister(ClassPath.SOURCE, new ClassPath[] {cpProvider.getSourcepath()});
828
            GlobalPathRegistry.getDefault().unregister(ClassPath.SOURCE, new ClassPath[]{cpProvider.getSourcepath()});
732
            GlobalPathRegistry.getDefault().unregister(ClassPath.COMPILE, new ClassPath[] {cpProvider.getCompileTimeClasspath()});
829
            GlobalPathRegistry.getDefault().unregister(ClassPath.COMPILE, new ClassPath[]{cpProvider.getCompileTimeClasspath()});
733
            
830
734
            JavaPlatformManager.getDefault().removePropertyChangeListener(platformListener);
831
            JavaPlatformManager.getDefault().removePropertyChangeListener(platformListener);
735
        }
832
        }
736
833
737
        
834
        private void refreshBootClasspath() {
738
        private void refreshBootClasspath()
835
739
        {
740
            
741
            JavaPlatform[] installedPlatforms = JavaPlatformManager.getDefault().
836
            JavaPlatform[] installedPlatforms = JavaPlatformManager.getDefault().
742
                    getPlatforms(null, new Specification (CDCPlatform.PLATFORM_CDC,null));   //NOI18N
837
                    getPlatforms(null, new Specification(CDCPlatform.PLATFORM_CDC, null));   //NOI18N
743
            platformListener = new PlatformInstalledListener(installedPlatforms);
838
            platformListener = new PlatformInstalledListener(installedPlatforms);
744
            JavaPlatformManager.getDefault().addPropertyChangeListener(platformListener);
839
            JavaPlatformManager.getDefault().addPropertyChangeListener(platformListener);
745
        }
840
        }
746
        
841
747
        public void resultChanged(final LookupEvent e) {
842
        public void resultChanged(final LookupEvent e) {
748
            final Collection<Lookup.Result> result = ((Lookup.Result) e.getSource()).allInstances();
843
            final Collection<Lookup.Result> result = ((Lookup.Result) e.getSource()).allInstances();
749
            RequestProcessor.getDefault().post(new Runnable() {
844
            RequestProcessor.getDefault().post(new Runnable() {
845
750
                public void run() {
846
                public void run() {
751
                    DeploymentPropertiesHandler.loadDeploymentProperties(result);
847
                    DeploymentPropertiesHandler.loadDeploymentProperties(result);
752
                }
848
                }
753
            }, 200);
849
            }, 200);
754
        }        
850
        }
755
    }
851
    }
756
    
852
757
    private void refreshBuildScripts(final boolean checkForProjectXmlModified) {
853
    private void refreshBuildScripts(final boolean checkForProjectXmlModified) {
758
        RequestProcessor.getDefault().post(new Runnable() {
854
        RequestProcessor.getDefault().post(new Runnable() {
855
759
            public void run() {
856
            public void run() {
760
                final FileObject root = Repository.getDefault().getDefaultFileSystem().findResource("Buildsystem/org.netbeans.modules.kjava.j2meproject"); //NOI18N
857
                final FileObject root = Repository.getDefault().getDefaultFileSystem().findResource("Buildsystem/org.netbeans.modules.kjava.j2meproject"); //NOI18N
761
                final LinkedList<FileObject> files = new LinkedList();
858
                final LinkedList<FileObject> files = new LinkedList();
762
                files.addAll(Arrays.asList(root.getChildren()));
859
                files.addAll(Arrays.asList(root.getChildren()));
763
                ProjectManager.mutex().postWriteRequest(new Runnable() {
860
                ProjectManager.mutex().postWriteRequest(new Runnable() {
861
764
                    public void run() {
862
                    public void run() {
765
                        try {
863
                        try {
766
                            ProjectManager.getDefault().saveProject(J2MEProject.this);
864
                            ProjectManager.getDefault().saveProject(J2MEProject.this);
Lines 768-791 public final class J2MEProject implement Link Here
768
                            ErrorManager.getDefault().notify(ioe);
866
                            ErrorManager.getDefault().notify(ioe);
769
                        }
867
                        }
770
                        URL u = null;
868
                        URL u = null;
771
                        while (!files.isEmpty()) try {
869
                        while (!files.isEmpty()) {
772
                            FileObject fo = files.removeFirst();
870
                            try {
773
                            if (fo.getExt().equals("xml") && isAuthorized(fo)) { //NOI18N
871
                                FileObject fo = files.removeFirst();
774
                                u = fo.isData() ? fo.getURL() : new URL("", null, -1, fo.getPath(), COMPOSED_STREAM_HANDLER); //NOI18N
872
                                if (fo.getExt().equals("xml") && isAuthorized(fo)) { //NOI18N
775
                                genFilesHelper.refreshBuildScript(FileUtil.getRelativePath(root, fo), u, checkForProjectXmlModified);
873
                                    u = fo.isData() ? fo.getURL() : new URL("", null, -1, fo.getPath(), COMPOSED_STREAM_HANDLER); //NOI18N
776
                            } else if (fo.isFolder()) {
874
                                    genFilesHelper.refreshBuildScript(FileUtil.getRelativePath(root, fo), u, checkForProjectXmlModified);
777
                                files.addAll(Arrays.asList(fo.getChildren()));
875
                                } else if (fo.isFolder()) {
778
                            }
876
                                    files.addAll(Arrays.asList(fo.getChildren()));
779
                        } catch (IOException ioe) {
877
                                }
780
                            ErrorManager.getDefault().notify(ioe);
878
                            } catch (IOException ioe) {
781
                            BufferedReader br = null;
879
                                ErrorManager.getDefault().notify(ioe);
782
                            if (u != null) try {
880
                                BufferedReader br = null;
783
                                br = new BufferedReader(new InputStreamReader(u.openStream()));
881
                                if (u != null) {
784
                                String s;
882
                                    try {
785
                                while ((s = br.readLine()) != null) ErrorManager.getDefault().log(ErrorManager.ERROR, s);
883
                                        br = new BufferedReader(new InputStreamReader(u.openStream()));
786
                            } catch (Exception e) {
884
                                        String s;
787
                            } finally {
885
                                        while ((s = br.readLine()) != null) {
788
                                if (br != null) try {br.close();} catch (IOException e) {}
886
                                            ErrorManager.getDefault().log(ErrorManager.ERROR, s);
887
                                        }
888
                                    } catch (Exception e) {
889
                                    } finally {
890
                                        if (br != null) {
891
                                            try {
892
                                                br.close();
893
                                            } catch (IOException e) {
894
                                            }
895
                                        }
896
                                    }
897
                                }
789
                            }
898
                            }
790
                        }
899
                        }
791
                    }
900
                    }
Lines 793-946 public final class J2MEProject implement Link Here
793
            }
902
            }
794
        });
903
        });
795
    }
904
    }
796
    
905
797
    /**
906
    /**
798
     * Exports the main JAR as an official build product for use from other scripts.
907
     * Exports the main JAR as an official build product for use from other scripts.
799
     * The type of the artifact will be {@link AntArtifact#TYPE_JAR}.
908
     * The type of the artifact will be {@link AntArtifact#TYPE_JAR}.
800
     */
909
     */
801
    private final class AntArtifactProviderImpl implements AntArtifactProvider {
910
    private final class AntArtifactProviderImpl implements AntArtifactProvider {
802
        
911
803
        private AntArtifactProviderImpl()
912
        private AntArtifactProviderImpl() {
804
        {
805
            // Just to avoid creating accessor class
913
            // Just to avoid creating accessor class
806
        }
914
        }
807
        
915
808
        public AntArtifact[] getBuildArtifacts() {
916
        public AntArtifact[] getBuildArtifacts() {
809
            final ProjectConfiguration cfgs[] = configHelper.getConfigurations().toArray(new ProjectConfiguration[0]);
917
            final ProjectConfiguration cfgs[] = configHelper.getConfigurations().toArray(new ProjectConfiguration[0]);
810
            AntArtifact art[] = new AntArtifact[cfgs.length];
918
            AntArtifact art[] = new AntArtifact[cfgs.length];
811
            for (int i=0; i<cfgs.length; i++) {
919
            for (int i = 0; i < cfgs.length; i++) {
812
                art[i] = new J2MEAntArtifact(configHelper.getDefaultConfiguration().equals(cfgs[i]) ? null : cfgs[i].getDisplayName());
920
                art[i] = new J2MEAntArtifact(configHelper.getDefaultConfiguration().equals(cfgs[i]) ? null : cfgs[i].getDisplayName());
813
            }
921
            }
814
            return art;
922
            return art;
815
        }
923
        }
816
        
817
    }
924
    }
818
    
925
819
    private class J2MEAntArtifact extends AntArtifact {
926
    private class J2MEAntArtifact extends AntArtifact {
820
        
927
821
        private final String configuration;
928
        private final String configuration;
822
        
929
823
        public J2MEAntArtifact(String configuration) {
930
        public J2MEAntArtifact(String configuration) {
824
            this.configuration = configuration;//NOI18N
931
            this.configuration = configuration;//NOI18N
825
        }
932
        }
826
        
933
827
        public String getCleanTargetName() {
934
        public String getCleanTargetName() {
828
            return "clean"; //NOI18N
935
            return "clean"; //NOI18N
829
        }
936
        }
830
        
937
831
        public File getScriptLocation() {
938
        public File getScriptLocation() {
832
            return helper.resolveFile(GeneratedFilesHelper.BUILD_XML_PATH);
939
            return helper.resolveFile(GeneratedFilesHelper.BUILD_XML_PATH);
833
        }
940
        }
834
        
941
835
        public String getTargetName() {
942
        public String getTargetName() {
836
            return "jar"; //NOI18N
943
            return "jar"; //NOI18N
837
        }
944
        }
838
        
945
839
        public String getType() {
946
        public String getType() {
840
            return JavaProjectConstants.ARTIFACT_TYPE_JAR;
947
            return JavaProjectConstants.ARTIFACT_TYPE_JAR;
841
        }
948
        }
842
        
949
843
        @Override
950
        @Override
844
        public Project getProject() {
951
        public Project getProject() {
845
            return J2MEProject.this;
952
            return J2MEProject.this;
846
        }
953
        }
847
        
954
848
        public String getID() {
955
        public String getID() {
849
            return configuration == null ? super.getID() : super.getID() + "." + configuration;//NOI18N
956
            return configuration == null ? super.getID() : super.getID() + "." + configuration;//NOI18N
850
        }
957
        }
851
        
958
852
        @Override
959
        @Override
853
        public URI[] getArtifactLocations() {
960
        public URI[] getArtifactLocations() {
854
            final PropertyEvaluator eval = helper.getStandardPropertyEvaluator();
855
            String path = "dist/"; //NOI18N
961
            String path = "dist/"; //NOI18N
856
            if (configuration != null) path += configuration + "/"; //NOI18N
962
            if (configuration != null) {
857
            final String locationResolved = eval.evaluate(path + J2MEProjectUtils.evaluateProperty(helper, "dist.jar", configuration)); //NOI18N
963
                path += configuration + "/"; //NOI18N
964
            }
965
            final String locationResolved = evaluator().evaluate(path + J2MEProjectUtils.evaluateProperty(helper, "dist.jar", configuration)); //NOI18N
858
            if (locationResolved == null) {
966
            if (locationResolved == null) {
859
                return new URI[0];
967
                return new URI[0];
860
            }
968
            }
861
            return new URI[] {getScriptLocation().getParentFile().toURI().relativize(helper.resolveFile(locationResolved).toURI())};
969
            return new URI[]{getScriptLocation().getParentFile().toURI().relativize(helper.resolveFile(locationResolved).toURI())};
862
        }
970
        }
863
        
971
864
        @Override
972
        @Override
865
        public Properties getProperties() {
973
        public Properties getProperties() {
866
            final Properties p = new Properties();
974
            final Properties p = new Properties();
867
            p.put(DefaultPropertiesDescriptor.CONFIG_ACTIVE, configuration == null ? "" : configuration);
975
            p.put(DefaultPropertiesDescriptor.CONFIG_ACTIVE, configuration == null ? "" : configuration);
868
            return p;
976
            return p;
869
        }
977
        }
870
        
871
    }
978
    }
979
872
    private final class Info implements ProjectInformation {
980
    private final class Info implements ProjectInformation {
873
        
981
874
        private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
982
        private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
875
        
983
876
        Info() {
984
        Info() {
877
            // Just to avoid creating accessor class
985
            // Just to avoid creating accessor class
878
        }
986
        }
879
        
987
880
        void firePropertyChange(final String prop) {
988
        void firePropertyChange(final String prop) {
881
            pcs.firePropertyChange(prop, null, null);
989
            pcs.firePropertyChange(prop, null, null);
882
        }
990
        }
883
        
991
884
        public String getName() {
992
        public String getName() {
885
            return PropertyUtils.getUsablePropertyName(J2MEProject.this.getName());
993
            return PropertyUtils.getUsablePropertyName(J2MEProject.this.getName());
886
        }
994
        }
887
        
995
888
        public String getDisplayName() {
996
        public String getDisplayName() {
889
            return J2MEProject.this.getName();
997
            return J2MEProject.this.getName();
890
        }
998
        }
891
        
999
892
        public Icon getIcon() {
1000
        public Icon getIcon() {
893
            return J2ME_PROJECT_ICON;
1001
            return J2ME_PROJECT_ICON;
894
        }
1002
        }
895
        
1003
896
        public Project getProject() {
1004
        public Project getProject() {
897
            return J2MEProject.this;
1005
            return J2MEProject.this;
898
        }
1006
        }
899
        
1007
900
        public void addPropertyChangeListener(final PropertyChangeListener listener) {
1008
        public void addPropertyChangeListener(final PropertyChangeListener listener) {
901
            pcs.addPropertyChangeListener(listener);
1009
            pcs.addPropertyChangeListener(listener);
902
        }
1010
        }
903
        
1011
904
        public void removePropertyChangeListener(final PropertyChangeListener listener) {
1012
        public void removePropertyChangeListener(final PropertyChangeListener listener) {
905
            pcs.removePropertyChangeListener(listener);
1013
            pcs.removePropertyChangeListener(listener);
906
        }
1014
        }
907
        
908
    }
1015
    }
909
    
1016
910
    private static final class RecommendedTemplatesImpl implements RecommendedTemplates, PrivilegedTemplates {
1017
    private static final class RecommendedTemplatesImpl implements RecommendedTemplates, PrivilegedTemplates {
911
        
1018
912
        private static final String LOCATION = "RecommendedTemplates/org.netbeans.modules.kjava.j2meproject"; //NOI18N
1019
        private static final String LOCATION = "RecommendedTemplates/org.netbeans.modules.kjava.j2meproject"; //NOI18N
913
        
1020
914
        private RecommendedTemplatesImpl() {
1021
        private RecommendedTemplatesImpl() {
915
        }
1022
        }
916
        
1023
917
        public String[] getRecommendedTypes() {
1024
        public String[] getRecommendedTypes() {
918
            FileObject root = Repository.getDefault().getDefaultFileSystem().findResource(LOCATION);
1025
            FileObject root = Repository.getDefault().getDefaultFileSystem().findResource(LOCATION);
919
            HashSet<String> result = new HashSet();
1026
            HashSet<String> result = new HashSet();
920
            for (FileObject fo : root.getChildren()) {
1027
            for (FileObject fo : root.getChildren()) {
921
                String s = (String) fo.getAttribute("RecommendedTemplates"); //NOI18N
1028
                String s = (String) fo.getAttribute("RecommendedTemplates"); //NOI18N
922
                if (s != null) result.addAll(Arrays.asList(s.split(","))); //NOI18N
1029
                if (s != null) {
1030
                    result.addAll(Arrays.asList(s.split(","))); //NOI18N
1031
                }
923
            }
1032
            }
924
            return result.toArray(new String[result.size()]);
1033
            return result.toArray(new String[result.size()]);
925
        }
1034
        }
926
        
1035
927
        public String[] getPrivilegedTemplates() {
1036
        public String[] getPrivilegedTemplates() {
928
            //priviledged templates are ordered by module layer
1037
            //priviledged templates are ordered by module layer
929
            DataFolder root = DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().findResource(LOCATION));
1038
            DataFolder root = DataFolder.findFolder(Repository.getDefault().getDefaultFileSystem().findResource(LOCATION));
930
            ArrayList<String> result = new ArrayList();
1039
            ArrayList<String> result = new ArrayList();
931
            for (DataObject ch : root.getChildren()) {
1040
            for (DataObject ch : root.getChildren()) {
932
                String s = (String) ch.getPrimaryFile().getAttribute("PriviledgedTemplates"); //NOI18N
1041
                String s = (String) ch.getPrimaryFile().getAttribute("PriviledgedTemplates"); //NOI18N
933
                if (s != null) result.addAll(Arrays.asList(s.split(","))); //NOI18N
1042
                if (s != null) {
1043
                    result.addAll(Arrays.asList(s.split(","))); //NOI18N
1044
                }
934
            }
1045
            }
935
            return result.toArray(new String[result.size()]);
1046
            return result.toArray(new String[result.size()]);
936
        }
1047
        }
937
        
938
    }
1048
    }
939
    
1049
940
    private static final class ComposedConnection extends URLConnection {
1050
    private static final class ComposedConnection extends URLConnection {
941
        
1051
942
        private static WeakHashMap<URL, byte[]> cache = new WeakHashMap();
1052
        private static WeakHashMap<URL, byte[]> cache = new WeakHashMap();
943
        
1053
944
        public ComposedConnection(URL u) {
1054
        public ComposedConnection(URL u) {
945
            super(u);
1055
            super(u);
946
        }
1056
        }
Lines 953-970 public final class J2MEProject implement Link Here
953
                DataObject mainParts[] = root.getChildren();
1063
                DataObject mainParts[] = root.getChildren();
954
                StringBuffer sb = new StringBuffer();
1064
                StringBuffer sb = new StringBuffer();
955
                String lastTarget = ""; //NOI18N
1065
                String lastTarget = ""; //NOI18N
956
                for (int i=0; i<mainParts.length; i++) {
1066
                for (int i = 0; i < mainParts.length; i++) {
957
                    if (mainParts[i] instanceof DataFolder) {
1067
                    if (mainParts[i] instanceof DataFolder) {
958
                        DataObject subParts[] = ((DataFolder)mainParts[i]).getChildren();
1068
                        DataObject subParts[] = ((DataFolder) mainParts[i]).getChildren();
959
                        StringBuffer subTargets = new StringBuffer(lastTarget);
1069
                        StringBuffer subTargets = new StringBuffer(lastTarget);
960
                        for (int j=0; j<subParts.length; j++) {
1070
                        for (int j = 0; j < subParts.length; j++) {
961
                            FileObject fo = subParts[j].getPrimaryFile();
1071
                            FileObject fo = subParts[j].getPrimaryFile();
962
                            if (fo.isData() && isAuthorized(fo)) {
1072
                            if (fo.isData() && isAuthorized(fo)) {
963
                                String s = read(subParts[j].getPrimaryFile(), lastTarget);
1073
                                String s = read(subParts[j].getPrimaryFile(), lastTarget);
964
                                sb.append(s);
1074
                                sb.append(s);
965
                                subTargets.append(',').append(subParts[j].getName());
1075
                                subTargets.append(',').append(subParts[j].getName());
966
                                if (log) ErrorManager.getDefault().log(ErrorManager.WARNING, fo.getURL().toExternalForm() + '\n' + s + '\n');
1076
                                if (log) {
967
                            } 
1077
                                    ErrorManager.getDefault().log(ErrorManager.WARNING, fo.getURL().toExternalForm() + '\n' + s + '\n');
1078
                                }
1079
                            }
968
                        }
1080
                        }
969
                        lastTarget = subTargets.toString();
1081
                        lastTarget = subTargets.toString();
970
                    } else {
1082
                    } else {
Lines 973-979 public final class J2MEProject implement Link Here
973
                            String s = read(fo, lastTarget);
1085
                            String s = read(fo, lastTarget);
974
                            sb.append(s);
1086
                            sb.append(s);
975
                            lastTarget = mainParts[i].getName();
1087
                            lastTarget = mainParts[i].getName();
976
                            if (log) ErrorManager.getDefault().log(ErrorManager.WARNING, fo.getURL().toExternalForm() + '\n' + s + '\n');
1088
                            if (log) {
1089
                                ErrorManager.getDefault().log(ErrorManager.WARNING, fo.getURL().toExternalForm() + '\n' + s + '\n');
1090
                            }
977
                        }
1091
                        }
978
                    }
1092
                    }
979
                }
1093
                }
Lines 981-995 public final class J2MEProject implement Link Here
981
                synchronized (cache) {
1095
                synchronized (cache) {
982
                    cache.put(getURL(), data);
1096
                    cache.put(getURL(), data);
983
                }
1097
                }
984
                if (log) ErrorManager.getDefault().log(ErrorManager.WARNING, getURL().toExternalForm() + '\n' + sb.toString() + '\n');
1098
                if (log) {
1099
                    ErrorManager.getDefault().log(ErrorManager.WARNING, getURL().toExternalForm() + '\n' + sb.toString() + '\n');
1100
                }
985
            }
1101
            }
986
            return new ByteArrayInputStream(data);
1102
            return new ByteArrayInputStream(data);
987
        }
1103
        }
988
        
1104
989
        public void connect() throws IOException {}
1105
        public void connect() throws IOException {
990
    
1106
        }
1107
991
        private String read(FileObject fo, String dependencies) throws IOException {
1108
        private String read(FileObject fo, String dependencies) throws IOException {
992
            int i = (int)fo.getSize();
1109
            int i = (int) fo.getSize();
993
            byte buff[] = new byte[i];
1110
            byte buff[] = new byte[i];
994
            DataInputStream in = new DataInputStream(fo.getInputStream());
1111
            DataInputStream in = new DataInputStream(fo.getInputStream());
995
            try {
1112
            try {
Lines 1000-1008 public final class J2MEProject implement Link Here
1000
            }
1117
            }
1001
            return new String(buff, "UTF-8").replace("__DEPENDS__", dependencies); //NOI18N
1118
            return new String(buff, "UTF-8").replace("__DEPENDS__", dependencies); //NOI18N
1002
        }
1119
        }
1003
        
1004
    }
1120
    }
1005
    
1121
1006
//    private static final Set<File> FRIENDS_JARS = collectFriendJars();
1122
//    private static final Set<File> FRIENDS_JARS = collectFriendJars();
1007
//    
1123
//    
1008
//    private static Set<String> getFriends() {
1124
//    private static Set<String> getFriends() {
Lines 1038-1044 public final class J2MEProject implement Link Here
1038
//        }
1154
//        }
1039
//        return jars;
1155
//        return jars;
1040
//    }
1156
//    }
1041
    
1042
    private static boolean isAuthorized(FileObject fo) {
1157
    private static boolean isAuthorized(FileObject fo) {
1043
//        if (fo.isFolder() || FRIENDS_JARS == null) return true;
1158
//        if (fo.isFolder() || FRIENDS_JARS == null) return true;
1044
//        URL u = null;
1159
//        URL u = null;
Lines 1070-1156 public final class J2MEProject implement Link Here
1070
//        }
1185
//        }
1071
        return true;
1186
        return true;
1072
    }
1187
    }
1073
    
1188
1074
    
1189
    private static String normalizePath(File path, File jdkHome, String propName) {
1075
    private static String normalizePath (File path,  File jdkHome, String propName) {
1076
        String jdkLoc = jdkHome.getAbsolutePath();
1190
        String jdkLoc = jdkHome.getAbsolutePath();
1077
        if (!jdkLoc.endsWith(File.separator)) {
1191
        if (!jdkLoc.endsWith(File.separator)) {
1078
            jdkLoc = jdkLoc + File.separator;
1192
            jdkLoc = jdkLoc + File.separator;
1079
        }
1193
        }
1080
        String loc = path.getAbsolutePath();
1194
        String loc = path.getAbsolutePath();
1081
        if (loc.startsWith(jdkLoc)) {
1195
        if (loc.startsWith(jdkLoc)) {
1082
            return "${"+propName+"}"+File.separator+loc.substring(jdkLoc.length());           //NOI18N
1196
            return "${" + propName + "}" + File.separator + loc.substring(jdkLoc.length());           //NOI18N
1083
        }
1197
        }
1084
        return loc;
1198
        return loc;
1085
    }
1199
    }
1086
    
1200
1087
    private List<ProjectConfiguration> getMatchingConfigs(final String actualPlatformId) {
1201
    private List<ProjectConfiguration> getMatchingConfigs(final String actualPlatformId) {
1088
        List<ProjectConfiguration> configs = new ArrayList<ProjectConfiguration>();
1202
        List<ProjectConfiguration> configs = new ArrayList<ProjectConfiguration>();
1089
        
1203
1090
        for (ProjectConfiguration config : getConfigurationHelper().getConfigurations())
1204
        for (ProjectConfiguration config : getConfigurationHelper().getConfigurations()) {
1091
        {
1205
            boolean useDef = config.equals(getConfigurationHelper().getDefaultConfiguration());
1092
            boolean useDef= config.equals(getConfigurationHelper().getDefaultConfiguration());
1206
            String platformProp = VisualPropertySupport.translatePropertyName(config.getDisplayName(),
1093
            String platformProp=VisualPropertySupport.translatePropertyName(config.getDisplayName(), 
1207
                    DefaultPropertiesDescriptor.PLATFORM_ACTIVE, useDef);
1094
                                                  DefaultPropertiesDescriptor.PLATFORM_ACTIVE, useDef);
1208
            String platformId = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).getProperty(platformProp);
1095
            String platformId=helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH).getProperty(platformProp);
1209
1096
        
1097
            //platformId is null when non default config, which use default values, is queried
1210
            //platformId is null when non default config, which use default values, is queried
1098
            //This one is not important for us as the change will be/have been done using DefaultConfiguration
1211
            //This one is not important for us as the change will be/have been done using DefaultConfiguration
1099
            if (platformId != null && platformId.equals(actualPlatformId))
1212
            if (platformId != null && platformId.equals(actualPlatformId)) {
1100
            {
1101
                configs.add(config);
1213
                configs.add(config);
1102
            }
1214
            }
1103
        }
1215
        }
1104
        return configs;
1216
        return configs;
1105
    }
1217
    }
1106
    
1218
1107
    private void generatePlatformProperties (CDCPlatform platform,ProjectConfiguration config, String activeDevice, String activeProfile, EditableProperties props)  {
1219
    private void generatePlatformProperties(CDCPlatform platform, ProjectConfiguration config, String activeDevice, String activeProfile, EditableProperties props) {
1108
        Collection<FileObject> installFolders = platform.getInstallFolders();
1220
        Collection<FileObject> installFolders = platform.getInstallFolders();
1109
        if (installFolders.size()>0) {            
1221
        if (installFolders.size() > 0) {
1110
            File jdkHome = FileUtil.toFile (installFolders.iterator().next());
1222
            File jdkHome = FileUtil.toFile(installFolders.iterator().next());
1111
            StringBuffer sbootcp = new StringBuffer();
1223
            StringBuffer sbootcp = new StringBuffer();
1112
            ClassPath bootCP = platform.getBootstrapLibrariesForProfile(activeDevice, activeProfile);
1224
            ClassPath bootCP = platform.getBootstrapLibrariesForProfile(activeDevice, activeProfile);
1113
            for (ClassPath.Entry entry : (List<ClassPath.Entry>)bootCP.entries()) {
1225
            for (ClassPath.Entry entry : (List<ClassPath.Entry>) bootCP.entries()) {
1114
                URL url = entry.getURL();
1226
                URL url = entry.getURL();
1115
                if ("jar".equals(url.getProtocol())) {              //NOI18N
1227
                if ("jar".equals(url.getProtocol())) {              //NOI18N
1116
                    url = FileUtil.getArchiveFile(url);
1228
                    url = FileUtil.getArchiveFile(url);
1117
                }
1229
                }
1118
                File root = new File (URI.create(url.toExternalForm()));
1230
                File root = new File(URI.create(url.toExternalForm()));
1119
                if (sbootcp.length()>0) {
1231
                if (sbootcp.length() > 0) {
1120
                    sbootcp.append(File.pathSeparator);
1232
                    sbootcp.append(File.pathSeparator);
1121
                }
1233
                }
1122
                sbootcp.append(normalizePath(root, jdkHome, "platform.home"));
1234
                sbootcp.append(normalizePath(root, jdkHome, "platform.home"));
1123
            }
1235
            }
1124
            boolean useDef= config.equals(getConfigurationHelper().getDefaultConfiguration());
1236
            boolean useDef = config.equals(getConfigurationHelper().getDefaultConfiguration());
1125
            props.setProperty(VisualPropertySupport.translatePropertyName(config.getDisplayName(),
1237
            props.setProperty(VisualPropertySupport.translatePropertyName(config.getDisplayName(),
1126
                    DefaultPropertiesDescriptor.PLATFORM_BOOTCLASSPATH,useDef),sbootcp.toString());   //NOI18N
1238
                    DefaultPropertiesDescriptor.PLATFORM_BOOTCLASSPATH, useDef), sbootcp.toString());   //NOI18N
1127
        }
1239
        }
1128
    }
1240
    }
1129
1241
1130
    private void updateBootClassPathProperty(List<ProjectConfiguration> configs, CDCPlatform platform)
1242
    private void updateBootClassPathProperty(List<ProjectConfiguration> configs, CDCPlatform platform) {
1131
    {
1243
        if (configs != null) {
1132
        if (configs != null)
1244
            try {
1133
        {
1245
                EditableProperties props = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
1134
            try
1246
                for (ProjectConfiguration config : configs) {
1135
            {
1247
                    boolean useDef = config.equals(getConfigurationHelper().getDefaultConfiguration());
1136
                EditableProperties props=helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
1137
                for (ProjectConfiguration config : configs)
1138
                {
1139
                    boolean useDef= config.equals(getConfigurationHelper().getDefaultConfiguration());
1140
                    generatePlatformProperties(
1248
                    generatePlatformProperties(
1141
                            platform,
1249
                            platform,
1142
                            config,
1250
                            config,
1143
                            props.getProperty(VisualPropertySupport.translatePropertyName(config.getDisplayName(),DefaultPropertiesDescriptor.PLATFORM_DEVICE,useDef)),
1251
                            props.getProperty(VisualPropertySupport.translatePropertyName(config.getDisplayName(), DefaultPropertiesDescriptor.PLATFORM_DEVICE, useDef)),
1144
                            props.getProperty(VisualPropertySupport.translatePropertyName(config.getDisplayName(),DefaultPropertiesDescriptor.PLATFORM_PROFILE,useDef)),
1252
                            props.getProperty(VisualPropertySupport.translatePropertyName(config.getDisplayName(), DefaultPropertiesDescriptor.PLATFORM_PROFILE, useDef)),
1145
                            props
1253
                            props);
1146
                            ); 
1147
                }
1254
                }
1148
                helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,props);
1255
                helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, props);
1149
                ProjectManager.getDefault().saveProject(this);
1256
                ProjectManager.getDefault().saveProject(this);
1150
            } catch (IOException ex)
1257
            } catch (IOException ex) {
1151
            {
1152
                ErrorManager.getDefault().notify(ex);
1258
                ErrorManager.getDefault().notify(ex);
1153
            } 
1259
            }
1154
        }
1260
        }
1155
    }
1261
    }
1156
}
1262
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEProjectGenerator.java (-8 / +33 lines)
Lines 40-46 Link Here
40
 */
40
 */
41
41
42
package org.netbeans.modules.mobility.project;
42
package org.netbeans.modules.mobility.project;
43
import java.awt.EventQueue;
44
import org.netbeans.api.java.platform.JavaPlatform;
43
import org.netbeans.api.java.platform.JavaPlatform;
45
import org.netbeans.api.java.platform.JavaPlatformManager;
44
import org.netbeans.api.java.platform.JavaPlatformManager;
46
import org.netbeans.api.java.platform.Profile;
45
import org.netbeans.api.java.platform.Profile;
Lines 82-96 import org.xml.sax.InputSource; Link Here
82
import org.xml.sax.InputSource;
81
import org.xml.sax.InputSource;
83
import org.xml.sax.SAXException;
82
import org.xml.sax.SAXException;
84
import org.xml.sax.SAXParseException;
83
import org.xml.sax.SAXParseException;
85
import java.io.*;
86
import java.text.MessageFormat;
84
import java.text.MessageFormat;
87
import java.util.*;
88
import java.util.zip.ZipEntry;
85
import java.util.zip.ZipEntry;
89
import java.util.zip.ZipInputStream;
86
import java.util.zip.ZipInputStream;
90
import java.util.jar.Manifest;
87
import java.util.jar.Manifest;
91
import java.util.jar.Attributes;
88
import java.util.jar.Attributes;
92
import java.util.regex.Pattern;
89
import java.util.regex.Pattern;
93
import java.beans.PropertyVetoException;
90
import java.beans.PropertyVetoException;
91
import java.io.BufferedReader;
92
import java.io.File;
93
import java.io.FileInputStream;
94
import java.io.FileOutputStream;
95
import java.io.FileReader;
96
import java.io.IOException;
97
import java.io.InputStream;
98
import java.io.InputStreamReader;
99
import java.io.UnsupportedEncodingException;
100
import java.util.ArrayList;
101
import java.util.Arrays;
102
import java.util.Collection;
103
import java.util.Enumeration;
104
import java.util.HashMap;
105
import java.util.HashSet;
106
import java.util.Iterator;
107
import java.util.Map;
108
import java.util.Properties;
109
import java.util.Set;
94
import javax.swing.DefaultComboBoxModel;
110
import javax.swing.DefaultComboBoxModel;
95
import javax.swing.event.ChangeEvent;
111
import javax.swing.event.ChangeEvent;
96
import javax.swing.event.ChangeListener;
112
import javax.swing.event.ChangeListener;
Lines 223-232 public class J2MEProjectGenerator { Link Here
223
        final AntProjectHelper oldHelper = oldProject.getLookup().lookup(AntProjectHelper.class);
239
        final AntProjectHelper oldHelper = oldProject.getLookup().lookup(AntProjectHelper.class);
224
        final Element data = h.getPrimaryConfigurationData(true);
240
        final Element data = h.getPrimaryConfigurationData(true);
225
        final Document doc = data.getOwnerDocument();
241
        final Document doc = data.getOwnerDocument();
226
        final Element nameEl = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
242
        final Element nameEl = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
227
        nameEl.appendChild(doc.createTextNode(name));
243
        nameEl.appendChild(doc.createTextNode(name));
228
        data.appendChild(nameEl);
244
        data.appendChild(nameEl);
229
        final Element minant = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
245
        final Element minant = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
230
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
246
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
231
        data.appendChild(minant);
247
        data.appendChild(minant);
232
        h.putPrimaryConfigurationData(data, true);
248
        h.putPrimaryConfigurationData(data, true);
Lines 347-358 public class J2MEProjectGenerator { Link Here
347
        final AntProjectHelper h = ProjectGenerator.createProject(projectLocation, J2MEProjectType.TYPE);
363
        final AntProjectHelper h = ProjectGenerator.createProject(projectLocation, J2MEProjectType.TYPE);
348
        final Element data = h.getPrimaryConfigurationData(true);
364
        final Element data = h.getPrimaryConfigurationData(true);
349
        final Document doc = data.getOwnerDocument();
365
        final Document doc = data.getOwnerDocument();
350
        final Element nameEl = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
366
        final Element nameEl = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
351
        nameEl.appendChild(doc.createTextNode(name));
367
        nameEl.appendChild(doc.createTextNode(name));
352
        data.appendChild(nameEl);
368
        data.appendChild(nameEl);
353
        final Element minant = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
369
        
370
        final Element srcRoots = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "source-roots");
371
        final Element defaultRoot = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "root");
372
        defaultRoot.setAttribute("id", "src.dir");
373
        srcRoots.appendChild(defaultRoot);
374
        data.appendChild(srcRoots);
375
376
        final Element minant = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
354
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
377
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
355
        data.appendChild(minant);
378
        data.appendChild(minant);
379
356
        h.putPrimaryConfigurationData(data, true);
380
        h.putPrimaryConfigurationData(data, true);
357
        EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
381
        EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
358
        EditableProperties priv = h.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
382
        EditableProperties priv = h.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
Lines 812-817 public class J2MEProjectGenerator { Link Here
812
        return null;
836
        return null;
813
    }
837
    }
814
    
838
    
839
    @SuppressWarnings("empty-statement")
815
    private static FileObject createProjectLocation(File dir) throws IOException {
840
    private static FileObject createProjectLocation(File dir) throws IOException {
816
        dir = dir.getCanonicalFile();
841
        dir = dir.getCanonicalFile();
817
        File rootF = dir;
842
        File rootF = dir;
Lines 1075-1081 public class J2MEProjectGenerator { Link Here
1075
    protected static void fillMissingMIDlets(final Project project, final AntProjectHelper helper) {
1100
    protected static void fillMissingMIDlets(final Project project, final AntProjectHelper helper) {
1076
        final ReferenceHelper refHelper = project.getLookup().lookup(ReferenceHelper.class);
1101
        final ReferenceHelper refHelper = project.getLookup().lookup(ReferenceHelper.class);
1077
        final ProjectConfigurationsHelper confHelper = project.getLookup().lookup(ProjectConfigurationsHelper.class);
1102
        final ProjectConfigurationsHelper confHelper = project.getLookup().lookup(ProjectConfigurationsHelper.class);
1078
        final MIDletScanner scanner = MIDletScanner.getDefault(new J2MEProjectProperties(project, helper, refHelper, confHelper));
1103
        final MIDletScanner scanner = MIDletScanner.getDefault(new J2MEProjectProperties((J2MEProject) project, helper, refHelper, confHelper));
1079
        final DefaultComboBoxModel midlets = new DefaultComboBoxModel();
1104
        final DefaultComboBoxModel midlets = new DefaultComboBoxModel();
1080
        scanner.scan(midlets, null, null,
1105
        scanner.scan(midlets, null, null,
1081
                     new ChangeListener() {
1106
                     new ChangeListener() {
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEProjectOperations.java (-7 / +3 lines)
Lines 43-48 import java.io.File; Link Here
43
import java.io.File;
43
import java.io.File;
44
import java.io.IOException;
44
import java.io.IOException;
45
import java.util.ArrayList;
45
import java.util.ArrayList;
46
import java.util.Arrays;
46
import java.util.List;
47
import java.util.List;
47
import java.util.Properties;
48
import java.util.Properties;
48
import org.apache.tools.ant.module.api.support.ActionUtils;
49
import org.apache.tools.ant.module.api.support.ActionUtils;
Lines 92-104 public class J2MEProjectOperations imple Link Here
92
    }
93
    }
93
    
94
    
94
    public List<FileObject> getDataFiles() {
95
    public List<FileObject> getDataFiles() {
95
        final List<FileObject> files = new ArrayList<FileObject>();
96
        J2MESources sources = project.getLookup().lookup (J2MESources.class);
96
        final String srcRoot = helper.getStandardPropertyEvaluator().getProperty("src.dir");
97
        return Arrays.asList (sources.getSourceRoots());
97
        if (srcRoot != null) {
98
            final FileObject src = helper.resolveFileObject(srcRoot);
99
            if (src != null) files.add(src);
100
        }
101
        return files;
102
    }
98
    }
103
    
99
    
104
    public void notifyDeleting() throws IOException {
100
    public void notifyDeleting() throws IOException {
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEProjectType.java (-2 / +5 lines)
Lines 24-30 Link Here
24
 * Contributor(s):
24
 * Contributor(s):
25
 *
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
28
 * Microsystems, Inc. All Rights Reserved.
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
30
 * If you wish your version of this file to be governed by only the CDDL
Lines 53-59 public final class J2MEProjectType imple Link Here
53
    
53
    
54
    public static final String TYPE = "org.netbeans.modules.kjava.j2meproject";  //NOI18N
54
    public static final String TYPE = "org.netbeans.modules.kjava.j2meproject";  //NOI18N
55
    private static final String PROJECT_CONFIGURATION_NAME = "data";  //NOI18N
55
    private static final String PROJECT_CONFIGURATION_NAME = "data";  //NOI18N
56
    @Deprecated
56
    public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project";  //NOI18N
57
    public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project";  //NOI18N
58
    public static final String MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/multiroot-j2me-project";  //NOI18N
57
    private static final String PRIVATE_CONFIGURATION_NAME = "data";  //NOI18N
59
    private static final String PRIVATE_CONFIGURATION_NAME = "data";  //NOI18N
58
    private static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project-private";  //NOI18N
60
    private static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project-private";  //NOI18N
59
    
61
    
Lines 70-76 public final class J2MEProjectType imple Link Here
70
    }
72
    }
71
    
73
    
72
    public String getPrimaryConfigurationDataElementNamespace(final boolean shared) {
74
    public String getPrimaryConfigurationDataElementNamespace(final boolean shared) {
73
        return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
75
//        return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
76
        return shared ? MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
74
    }
77
    }
75
    
78
    
76
}
79
}
(-)6b487c15857b (+230 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.mobility.project;
42
43
import java.beans.PropertyChangeListener;
44
import java.beans.PropertyChangeEvent;
45
import java.io.File;
46
import javax.swing.event.ChangeEvent;
47
import javax.swing.event.ChangeListener;
48
import org.openide.util.Mutex;
49
import org.netbeans.api.project.Sources;
50
import org.netbeans.api.project.SourceGroup;
51
import org.netbeans.api.project.ProjectManager;
52
import org.netbeans.api.project.FileOwnerQuery;
53
import org.netbeans.api.java.project.JavaProjectConstants;
54
import org.netbeans.modules.java.api.common.SourceRoots;
55
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
56
import org.netbeans.spi.project.support.GenericSources;
57
import org.netbeans.spi.project.support.ant.SourcesHelper;
58
import org.netbeans.spi.project.support.ant.AntProjectHelper;
59
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
60
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileUtil;
62
import org.openide.util.ChangeSupport;
63
import org.openide.util.NbBundle;
64
65
/**
66
 * Copied from J2SEProject with modifications.
67
 */
68
public class J2MESources implements Sources, PropertyChangeListener, ChangeListener {
69
70
    private static final String BUILD_DIR_PROP =
71
            "${" + J2MEProjectProperties.BUILD_DIR + "}";    //NOI18N
72
    private static final String DIST_DIR_PROP =
73
            "${" + J2MEProjectProperties.DIST_DIR + "}";    //NOI18N
74
    private final AntProjectHelper helper;
75
    private final PropertyEvaluator evaluator;
76
    private final SourceRoots sourceRoots;
77
    private final SourceRoots testRoots;
78
    private SourcesHelper sourcesHelper;
79
    private Sources delegate;
80
    /**
81
     * Flag to forbid multiple invocation of {@link SourcesHelper#registerExternalRoots} 
82
     **/
83
    private boolean externalRootsRegistered;
84
    private final ChangeSupport changeSupport = new ChangeSupport(this);
85
86
    J2MESources(AntProjectHelper helper, PropertyEvaluator evaluator,
87
            SourceRoots sourceRoots, SourceRoots testRoots) {
88
        this.helper = helper;
89
        this.evaluator = evaluator;
90
        this.sourceRoots = sourceRoots;
91
        this.testRoots = testRoots;
92
        this.sourceRoots.addPropertyChangeListener(this);
93
        this.testRoots.addPropertyChangeListener(this);
94
        this.evaluator.addPropertyChangeListener(this);
95
        initSources(); // have to register external build roots eagerly
96
    }
97
98
    public FileObject[] getSourceRoots() {
99
        return sourceRoots.getRoots();
100
    }
101
102
    /**
103
     * Returns an array of SourceGroup of given type. It delegates to {@link SourcesHelper}.
104
     * This method firstly acquire the {@link ProjectManager#mutex} in read mode then it enters
105
     * into the synchronized block to ensure that just one instance of the {@link SourcesHelper}
106
     * is created. These instance is cleared also in the synchronized block by the
107
     * {@link J2SESources#fireChange} method.
108
     */
109
    public SourceGroup[] getSourceGroups(final String type) {
110
        return ProjectManager.mutex().readAccess(new Mutex.Action<SourceGroup[]>() {
111
112
            public SourceGroup[] run() {
113
                Sources _delegate;
114
                synchronized (J2MESources.this) {
115
                    if (delegate == null) {
116
                        delegate = initSources();
117
                        delegate.addChangeListener(J2MESources.this);
118
                    }
119
                    _delegate = delegate;
120
                }
121
                SourceGroup[] groups = _delegate.getSourceGroups(type);
122
                if (type.equals(Sources.TYPE_GENERIC)) {
123
                    FileObject libLoc = getSharedLibraryFolderLocation();
124
                    if (libLoc != null) {
125
                        SourceGroup[] grps = new SourceGroup[groups.length + 1];
126
                        System.arraycopy(groups, 0, grps, 0, groups.length);
127
                        grps[grps.length - 1] = GenericSources.group(null, libLoc,
128
                                "sharedlibraries", // NOI18N
129
                                NbBundle.getMessage(J2MESources.class, "LibrarySourceGroup_DisplayName"),
130
                                null, null);
131
                        return grps;
132
                    }
133
                }
134
                return groups;
135
            }
136
        });
137
    }
138
139
    private FileObject getSharedLibraryFolderLocation() {
140
        String libLoc = helper.getLibrariesLocation();
141
        if (libLoc != null) {
142
            String libLocEval = evaluator.evaluate(libLoc);
143
            File file = null;
144
            if (libLocEval != null) {
145
                file = helper.resolveFile(libLocEval);
146
            }
147
            FileObject libLocFO = FileUtil.toFileObject(file);
148
            if (libLocFO != null) {
149
                //#126366 this can happen when people checkout the project but not the libraries description 
150
                //that is located outside the project
151
                FileObject libLocParent = libLocFO.getParent();
152
                return libLocParent;
153
            }
154
        }
155
        return null;
156
    }
157
158
    private Sources initSources() {
159
        this.sourcesHelper = new SourcesHelper(helper, evaluator);   //Safe to pass APH        
160
        register(sourceRoots);
161
        register(testRoots);
162
        this.sourcesHelper.addNonSourceRoot(BUILD_DIR_PROP);
163
        this.sourcesHelper.addNonSourceRoot(DIST_DIR_PROP);
164
        externalRootsRegistered = false;
165
        ProjectManager.mutex().postWriteRequest(new Runnable() {
166
167
            public void run() {
168
                if (!externalRootsRegistered) {
169
                    sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
170
                    externalRootsRegistered = true;
171
                }
172
            }
173
        });
174
        return this.sourcesHelper.createSources();
175
    }
176
177
    private void register(SourceRoots roots) {
178
        String[] propNames = roots.getRootProperties();
179
        String[] rootNames = roots.getRootNames();
180
        for (int i = 0; i < propNames.length; i++) {
181
            String prop = propNames[i];
182
            String displayName = roots.getRootDisplayName(rootNames[i], prop);
183
            String loc = "${" + prop + "}"; // NOI18N
184
            String includes = "${" + J2MEProjectProperties.INCLUDES + "}"; // NOI18N
185
            String excludes = "${" + J2MEProjectProperties.EXCLUDES + "}"; // NOI18N
186
            sourcesHelper.addPrincipalSourceRoot(loc, includes, excludes, displayName, null, null); // NOI18N
187
            sourcesHelper.addTypedSourceRoot(loc, includes, excludes, JavaProjectConstants.SOURCES_TYPE_JAVA, displayName, null, null); // NOI18N
188
        }
189
    }
190
191
    public void addChangeListener(ChangeListener changeListener) {
192
        changeSupport.addChangeListener(changeListener);
193
    }
194
195
    public void removeChangeListener(ChangeListener changeListener) {
196
        changeSupport.removeChangeListener(changeListener);
197
    }
198
199
    private void fireChange() {
200
        synchronized (this) {
201
            if (delegate != null) {
202
                delegate.removeChangeListener(this);
203
                delegate = null;
204
            }
205
        }
206
        changeSupport.fireChange();
207
    }
208
209
    public void propertyChange(PropertyChangeEvent evt) {
210
        String propName = evt.getPropertyName();
211
        if (SourceRoots.PROP_ROOT_PROPERTIES.equals(propName) ||
212
                J2MEProjectProperties.BUILD_DIR.equals(propName) ||
213
                J2MEProjectProperties.DIST_DIR.equals(propName)) {
214
            this.fireChange();
215
        }
216
    }
217
218
    public void stateChanged(ChangeEvent event) {
219
        this.fireChange();
220
    }
221
222
    public FileObject rootFor (FileObject file) {
223
        for (FileObject fo : getSourceRoots()) {
224
            if (FileUtil.isParentOf(fo, file)) {
225
                return fo;
226
            }
227
        }
228
        return null;
229
    }
230
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/TextSwitcher.java (-13 / +13 lines)
Lines 82-88 public class TextSwitcher implements Pro Link Here
82
    protected ProjectConfigurationsHelper pch;
82
    protected ProjectConfigurationsHelper pch;
83
    
83
    
84
    protected static RequestProcessor switchProcessor = new RequestProcessor(TEXT_SWITCH_SUPPORT);
84
    protected static RequestProcessor switchProcessor = new RequestProcessor(TEXT_SWITCH_SUPPORT);
85
    protected static Object lockObserver = new Object();
85
    protected static final Object lockObserver = new Object();
86
    
86
    
87
    /** Creates a new instance of TextSwitcher */
87
    /** Creates a new instance of TextSwitcher */
88
    public TextSwitcher(Project p, AntProjectHelper h) {
88
    public TextSwitcher(Project p, AntProjectHelper h) {
Lines 130-144 public class TextSwitcher implements Pro Link Here
130
                }
130
                }
131
                
131
                
132
                if (processed == null) return;
132
                if (processed == null) return;
133
                final String srcDir = h.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
133
134
                if (srcDir == null) return;
134
                J2MESources sources = p.getLookup().lookup (J2MESources.class);
135
                final FileObject src = h.resolveFileObject(srcDir);
135
                if (sources != null) {
136
                if (src == null || !src.isFolder()) return;
136
                    for (FileObject root : sources.getSourceRoots()) {
137
                final Enumeration ch = DataFolder.findFolder(src).children(true);
137
                        if (root.isFolder()) {
138
                while (ch.hasMoreElements()) {
138
                            for (Enumeration<DataObject> en = DataFolder.findFolder(root).children(true); en.hasMoreElements();) {
139
                    final DataObject dob = (DataObject)ch.nextElement();
139
                                DataObject dob = en.nextElement();
140
                    if (!processed.contains(dob)) {
140
                                if (!processed.contains(dob)) {
141
                        doSwitch(dob,false);
141
                                    doSwitch(dob, false);
142
                                }
143
                            }
144
                        }
142
                    }
145
                    }
143
                }
146
                }
144
            }
147
            }
Lines 165-178 public class TextSwitcher implements Pro Link Here
165
                identifiers.put(pch.getActiveConfiguration().getDisplayName(),null);
168
                identifiers.put(pch.getActiveConfiguration().getDisplayName(),null);
166
                final CommentingPreProcessor cpp =new CommentingPreProcessor(ppSrc, ppDest, identifiers) ;
169
                final CommentingPreProcessor cpp =new CommentingPreProcessor(ppSrc, ppDest, identifiers) ;
167
                
170
                
168
//                final MDRepository rep = JavaModel.getJavaRepository();
169
//                rep.beginTrans(false);
170
                try {
171
                try {
171
                    doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, TextSwitcher.SKIP_DUCUMENT_CHANGES);
172
                    doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, TextSwitcher.SKIP_DUCUMENT_CHANGES);
172
                    NbDocument.runAtomic(doc, cpp);
173
                    NbDocument.runAtomic(doc, cpp);
173
                } finally {
174
                } finally {
174
                    doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, null);
175
                    doc.putProperty(TextSwitcher.SKIP_DUCUMENT_CHANGES, null);
175
//                    rep.endTrans();
176
                }
176
                }
177
                
177
                
178
                return true;
178
                return true;
(-)6b487c15857b (+226 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
package org.netbeans.modules.mobility.project;
42
43
import java.io.IOException;
44
import javax.swing.JButton;
45
import org.netbeans.api.project.ProjectManager;
46
import org.netbeans.modules.java.api.common.ant.UpdateImplementation;
47
import org.netbeans.spi.project.AuxiliaryConfiguration;
48
import org.netbeans.spi.project.support.ant.AntProjectHelper;
49
import org.netbeans.spi.project.support.ant.EditableProperties;
50
import org.openide.DialogDisplayer;
51
import org.openide.NotifyDescriptor;
52
import org.openide.util.Mutex;
53
import org.openide.util.NbBundle;
54
import org.w3c.dom.Comment;
55
import org.w3c.dom.Document;
56
import org.w3c.dom.Element;
57
import org.w3c.dom.NamedNodeMap;
58
import org.w3c.dom.Node;
59
import org.w3c.dom.NodeList;
60
import org.w3c.dom.Text;
61
62
public final class Updater implements UpdateImplementation, Mutex.Action<Boolean> {
63
64
    private final AuxiliaryConfiguration cfg;
65
    private final AntProjectHelper helper;
66
    private final J2MEProject project;
67
    private final boolean TRANSPARENT_UPDATE =
68
            Boolean.getBoolean("j2meproject.transparentUpdate"); // NOI18N
69
    private final String BUILD_NUMBER =
70
            System.getProperty("netbeans.buildnumber"); // NOI18N
71
    private Boolean isCurrent;
72
    private boolean asked = false;
73
74
    Updater(J2MEProject project, AntProjectHelper helper, AuxiliaryConfiguration cfg) {
75
        super();
76
        this.project = project;
77
        this.helper = helper;
78
        this.cfg = cfg;
79
    }
80
81
    public boolean isCurrent() {
82
        return ProjectManager.mutex().readAccess(this).booleanValue();
83
    }
84
85
    public boolean canUpdate() {
86
        if (TRANSPARENT_UPDATE) {
87
            return true;
88
        }
89
        //Ask just once under a single write access
90
        if (asked) {
91
            return false;
92
        } else {
93
            boolean canUpdate = showUpdateDialog();
94
            if (!canUpdate) {
95
                asked = true;
96
                ProjectManager.mutex().postReadRequest(new Runnable() {
97
98
                    public void run() {
99
                        asked = false;
100
                    }
101
                });
102
            }
103
            return canUpdate;
104
        }
105
    }
106
107
    private boolean showUpdateDialog() {
108
        JButton updateOption = new JButton(NbBundle.getMessage(Updater.class,
109
                "CTL_UpdateOption")); //NOI18N
110
        updateOption.getAccessibleContext().setAccessibleDescription(
111
                NbBundle.getMessage(Updater.class, "AD_UpdateOption")); //NOI18N
112
        return DialogDisplayer.getDefault().notify(
113
                new NotifyDescriptor(NbBundle.getMessage(Updater.class,
114
                "TXT_ProjectUpdate", BUILD_NUMBER), //NOI18N
115
                NbBundle.getMessage(Updater.class, "TXT_ProjectUpdateTitle"), //NOI18N
116
                NotifyDescriptor.DEFAULT_OPTION,
117
                NotifyDescriptor.WARNING_MESSAGE,
118
                new Object[]{updateOption, NotifyDescriptor.CANCEL_OPTION},
119
                updateOption)) == updateOption;
120
    }
121
122
    @SuppressWarnings(value = "deprecation") //NOI18N
123
    public void saveUpdate(final EditableProperties props) throws IOException {
124
        System.err.println("Upgrading " + project.getProjectDirectory().getPath());
125
        this.helper.putPrimaryConfigurationData(getUpdatedSharedConfigurationData(), true);
126
        this.cfg.removeConfigurationFragment("data",
127
                J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, true); //NOI18N
128
        ProjectManager.getDefault().saveProject(this.project);
129
        synchronized (this) {
130
            this.isCurrent = Boolean.TRUE;
131
        }
132
    }
133
134
    @SuppressWarnings(value = "deprecation") //NOI18N
135
    public Element getUpdatedSharedConfigurationData() {
136
        Element cachedElement = null;
137
        if (cachedElement == null) {
138
            @SuppressWarnings(value = "deprecation") //NOI18N
139
            Element oldRoot = this.cfg.getConfigurationFragment("data", //NOI18N
140
                    J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, true);
141
            if (oldRoot != null) {
142
                Document doc = oldRoot.getOwnerDocument();
143
                Element newRoot = doc.createElementNS(
144
                        J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
145
                        "data"); //NOI18N
146
                copyDocument(doc, oldRoot, newRoot);
147
                Element sourceRoots = doc.createElementNS(
148
                        J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
149
                        "source-roots"); //NOI18N
150
                Element root = doc.createElementNS(
151
                        J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
152
                        "root"); //NOI18N
153
                root.setAttribute("id", "src.dir"); //NOI18N
154
                sourceRoots.appendChild(root);
155
                newRoot.appendChild(sourceRoots);
156
                cachedElement = newRoot;
157
            } else {
158
                oldRoot = this.cfg.getConfigurationFragment("data", //NOI18N
159
                        J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
160
                        true);
161
                if (oldRoot != null) {
162
                    Document doc = oldRoot.getOwnerDocument();
163
                    Element newRoot = doc.createElementNS(
164
                            J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
165
                            "data"); //NOI18N
166
                    copyDocument(doc, oldRoot, newRoot);
167
                    cachedElement = newRoot;
168
                }
169
            }
170
        }
171
        return cachedElement;
172
    }
173
174
    public static void copyDocument(Document doc, Element from, Element to) {
175
        NodeList nl = from.getChildNodes();
176
        int length = nl.getLength();
177
        for (int i = 0; i < length; i++) {
178
            Node node = nl.item(i);
179
            Node newNode = null;
180
            switch (node.getNodeType()) {
181
                case Node.ELEMENT_NODE:
182
                    Element oldElement = (Element) node;
183
                    newNode = doc.createElementNS(
184
                            J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
185
                            oldElement.getTagName());
186
                    NamedNodeMap m = oldElement.getAttributes();
187
                    Element newElement = (Element) newNode;
188
                    for (int index = 0; index < m.getLength(); index++) {
189
                        Node attr = m.item(index);
190
                        newElement.setAttribute(attr.getNodeName(),
191
                                attr.getNodeValue());
192
                    }
193
                    copyDocument(doc, oldElement, newElement);
194
                    break;
195
                case Node.TEXT_NODE:
196
                    Text oldText = (Text) node;
197
                    newNode = doc.createTextNode(oldText.getData());
198
                    break;
199
                case Node.COMMENT_NODE:
200
                    Comment oldComment = (Comment) node;
201
                    newNode = doc.createComment(oldComment.getData());
202
                    break;
203
            }
204
            if (newNode != null) {
205
                to.appendChild(newNode);
206
            }
207
        }
208
    }
209
210
    public EditableProperties getUpdatedProjectProperties() {
211
        return helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
212
    }
213
214
    @SuppressWarnings("deprecation")
215
    public synchronized Boolean run() {
216
        if (isCurrent == null) {
217
            if (cfg.getConfigurationFragment("data", //NOI18N
218
                    J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, true) != null) {
219
                isCurrent = Boolean.FALSE;
220
            } else {
221
                isCurrent = Boolean.TRUE;
222
            }
223
        }
224
        return isCurrent;
225
    }
226
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/classpath/J2MEClassPathProvider.java (-25 / +143 lines)
Lines 41-58 Link Here
41
41
42
package org.netbeans.modules.mobility.project.classpath;
42
package org.netbeans.modules.mobility.project.classpath;
43
import java.lang.ref.SoftReference;
43
import java.lang.ref.SoftReference;
44
import java.util.HashMap;
45
import java.util.Map;
44
import javax.swing.event.ChangeEvent;
46
import javax.swing.event.ChangeEvent;
45
import javax.swing.event.ChangeListener;
47
import javax.swing.event.ChangeListener;
46
48
47
import org.netbeans.api.java.classpath.ClassPath;
49
import org.netbeans.api.java.classpath.ClassPath;
50
import org.netbeans.api.project.ProjectManager;
51
import org.netbeans.modules.java.api.common.SourceRoots;
52
import org.netbeans.modules.java.api.common.classpath.ClassPathSupportFactory;
53
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
54
import org.netbeans.modules.mobility.project.J2MEProject;
48
import org.netbeans.modules.mobility.project.J2MEProjectUtils;
55
import org.netbeans.modules.mobility.project.J2MEProjectUtils;
56
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
49
import org.netbeans.spi.java.classpath.ClassPathFactory;
57
import org.netbeans.spi.java.classpath.ClassPathFactory;
58
import org.netbeans.spi.java.classpath.ClassPathImplementation;
50
import org.netbeans.spi.java.classpath.ClassPathProvider;
59
import org.netbeans.spi.java.classpath.ClassPathProvider;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
60
import org.netbeans.spi.project.support.ant.AntProjectHelper;
52
import org.netbeans.spi.project.support.ant.PropertyProvider;
61
import org.netbeans.spi.project.support.ant.PropertyProvider;
53
import org.netbeans.spi.project.support.ant.PropertyUtils;
62
import org.netbeans.spi.project.support.ant.PropertyUtils;
54
import org.openide.filesystems.FileObject;
63
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileUtil;
64
import org.openide.filesystems.FileUtil;
65
import org.openide.util.Mutex;
56
import org.openide.util.WeakListeners;
66
import org.openide.util.WeakListeners;
57
67
58
/**
68
/**
Lines 62-74 public class J2MEClassPathProvider imple Link Here
62
public class J2MEClassPathProvider implements ClassPathProvider {
72
public class J2MEClassPathProvider implements ClassPathProvider {
63
    
73
    
64
    private SoftReference<ClassPath> ctcp, rtcp, sp, bcp;    
74
    private SoftReference<ClassPath> ctcp, rtcp, sp, bcp;    
65
    private FileObject srcDir;
66
    
75
    
67
    protected final AntProjectHelper helper;
76
    protected final AntProjectHelper helper;
77
    private final SourceRoots sourceRoots;
78
    private final SourceRoots testSourceRoots;
68
    
79
    
69
    /** Do nothing */
80
    /** Do nothing */
70
    public J2MEClassPathProvider(AntProjectHelper helper) {
81
    public J2MEClassPathProvider(AntProjectHelper helper, SourceRoots sourceRoots, SourceRoots testRoots) {
71
        this.helper = helper;
82
        this.helper = helper;
83
        this.sourceRoots = sourceRoots;
84
        this.testSourceRoots = testRoots;
72
    }
85
    }
73
    
86
    
74
    public ClassPath findClassPath(final FileObject file, final String type) {
87
    public ClassPath findClassPath(final FileObject file, final String type) {
Lines 76-94 public class J2MEClassPathProvider imple Link Here
76
        if (!checkSrcParent(file)) return null;
89
        if (!checkSrcParent(file)) return null;
77
        if (type.equals(ClassPath.COMPILE)) return getCompileTimeClasspath();
90
        if (type.equals(ClassPath.COMPILE)) return getCompileTimeClasspath();
78
        if (type.equals(ClassPath.EXECUTE)) return getRunTimeClasspath();
91
        if (type.equals(ClassPath.EXECUTE)) return getRunTimeClasspath();
79
        if (type.equals(ClassPath.SOURCE)) return getSourcepath();
92
        if (type.equals(ClassPath.SOURCE)) return getSourcepath(0);
80
        // Unrecognized type, ignore.
93
        // Unrecognized type, ignore.
81
        return null;
94
        return null;
82
    }
95
    }
83
    
96
    
84
    public boolean checkSrcParent(final FileObject file) {
97
    public boolean checkSrcParent(final FileObject file) {
85
        if (srcDir == null || !srcDir.isValid()) {
98
        for (FileObject root : sourceRoots.getRoots()) {
86
            final String prop = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
99
            if (root.equals(file) || FileUtil.isParentOf(root, file)) {
87
            if (prop != null) {
100
                return true;
88
                srcDir = helper.resolveFileObject(prop);
89
            }
101
            }
90
        }
102
        }
91
        return (srcDir != null && file != null && (srcDir.equals(file) || FileUtil.isParentOf(srcDir, file)));
103
        return false;
92
    }
104
    }
93
    
105
    
94
    public ClassPath getCompileTimeClasspath() {
106
    public ClassPath getCompileTimeClasspath() {
Lines 107-112 public class J2MEClassPathProvider imple Link Here
107
        }
119
        }
108
        return cp;
120
        return cp;
109
    }
121
    }
122
123
    //COPIED FROM J2SEPROJECT
124
    /**
125
     * Find what a given file represents.
126
     * @param file a file in the project
127
     * @return one of: <dl>
128
     *         <dt>0</dt> <dd>normal source</dd>
129
     *         <dt>1</dt> <dd>test source</dd>
130
     *         <dt>2</dt> <dd>built class (unpacked)</dd>
131
     *         <dt>3</dt> <dd>built test class</dd>
132
     *         <dt>4</dt> <dd>built class (in dist JAR)</dd>
133
     *         <dt>-1</dt> <dd>something else</dd>
134
     *         </dl>
135
     */
136
    private int getType(FileObject file) {
137
        FileObject[] srcPath = getPrimarySrcPath();
138
        for (int i=0; i < srcPath.length; i++) {
139
            FileObject root = srcPath[i];
140
            if (root.equals(file) || FileUtil.isParentOf(root, file)) {
141
                return 0;
142
            }
143
        }
144
        srcPath = getTestSrcDir();
145
        for (int i=0; i< srcPath.length; i++) {
146
            FileObject root = srcPath[i];
147
            if (root.equals(file) || FileUtil.isParentOf(root, file)) {
148
                return 1;
149
            }
150
        }
151
        FileObject dir = getBuildClassesDir();
152
        if (dir != null && (dir.equals(file) || FileUtil.isParentOf(dir, file))) {
153
            return 2;
154
        }
155
        dir = getDistJar(); // not really a dir at all, of course
156
        if (dir != null && dir.equals(FileUtil.getArchiveFile(file))) {
157
            // XXX check whether this is really the root
158
            return 4;
159
        }
160
        dir = getBuildTestClassesDir();
161
        if (dir != null && (dir.equals(file) || FileUtil.isParentOf(dir,file))) {
162
            return 3;
163
        }
164
        return -1;
165
    }
166
167
    private static final String BUILD_CLASSES_DIR = "build.classes.dir"; // NOI18N
168
    private static final String DIST_JAR = DefaultPropertiesDescriptor.DIST_JAR;
169
    private static final String BUILD_TEST_CLASSES_DIR = "build.test.classes.dir"; // NOI18N
170
    private FileObject getBuildClassesDir() {
171
        return getDir(BUILD_CLASSES_DIR);
172
    }
173
174
    private FileObject getDistJar() {
175
        return getDir(DIST_JAR);
176
    }
177
178
    private FileObject getBuildTestClassesDir() {
179
        //XXX probably want test and build dirs the same for ME?
180
        return getDir(BUILD_TEST_CLASSES_DIR);
181
    }
182
183
    private final ClassPath[] cache = new ClassPath[8];
184
    private final Map<String,FileObject> dirCache = new HashMap<String,FileObject>();
185
    private FileObject getDir(final String propname) {
186
        return ProjectManager.mutex().readAccess(new Mutex.Action<FileObject>() {
187
            public FileObject run() {
188
                synchronized (J2MEClassPathProvider.this) {
189
                    FileObject fo = (FileObject) J2MEClassPathProvider.this.dirCache.get (propname);
190
                    if (fo == null ||  !fo.isValid()) {
191
                        String prop = helper.getStandardPropertyEvaluator().getProperty(propname);
192
                        if (prop != null) {
193
                            fo = helper.resolveFileObject(prop);
194
                            J2MEClassPathProvider.this.dirCache.put (propname, fo);
195
                        }
196
                    }
197
                    return fo;
198
                }
199
            }});
200
    }
201
202
    private FileObject[] getPrimarySrcPath() {
203
        return this.sourceRoots.getRoots();
204
    }
205
206
    private FileObject[] getTestSrcDir() {
207
        return this.testSourceRoots.getRoots();
208
    }
209
210
    public ClassPath getSourcepath() {
211
        return getSourcepath(0);
212
    }
213
214
    private ClassPath getSourcepath(int type) {
215
        if (type < 0 || type > 1) {
216
            return null;
217
        }
218
        ClassPath cp = null;//cache[type]; //Cache causes a deadlock - not going to diagnose now
219
        if (cp == null) {
220
            switch (type) {
221
                case 0: {
222
                    ClassPathImplementation impl =
223
                            ClassPathSupportFactory.createSourcePathImplementation(
224
                            sourceRoots, helper,
225
                            helper.getStandardPropertyEvaluator());
226
                    cp = ClassPathFactory.createClassPath(impl);
227
                    break;
228
                }
229
                case 1:
230
                    ClassPathImplementation impl =
231
                            ClassPathSupportFactory.createSourcePathImplementation(
232
                            testSourceRoots, helper,
233
                            helper.getStandardPropertyEvaluator());
234
                    cp = ClassPathFactory.createClassPath(impl);
235
                    break;
236
            }
237
        }
238
        cache[type] = cp;
239
        return cp;
240
    }
241
242
    //END COPY
110
    
243
    
111
    public ClassPath getRunTimeClasspath() {
244
    public ClassPath getRunTimeClasspath() {
112
        ClassPath cp = null;
245
        ClassPath cp = null;
Lines 114-141 public class J2MEClassPathProvider imple Link Here
114
            cp = ClassPathFactory.createClassPath(
247
            cp = ClassPathFactory.createClassPath(
115
                    new ProjectClassPathImplementation(helper) {
248
                    new ProjectClassPathImplementation(helper) {
116
                protected String evaluatePath() {
249
                protected String evaluatePath() {
117
                    String cp = helper.getStandardPropertyEvaluator().getProperty("build.classes.dir"); //NOI18N
250
                    String cp = helper.getStandardPropertyEvaluator().getProperty(
251
                            J2MEProjectProperties.BUILD_CLASSES_DIR);
118
                    if (cp != null) cp = helper.resolvePath(cp);
252
                    if (cp != null) cp = helper.resolvePath(cp);
119
                    return cp;
253
                    return cp;
120
                }
254
                }
121
            });
255
            });
122
            rtcp = new SoftReference<ClassPath>(cp);
256
            rtcp = new SoftReference<ClassPath>(cp);
123
        }
124
        return cp;
125
    }
126
    
127
    public ClassPath getSourcepath() {
128
        ClassPath cp = null;
129
        if (sp == null || (cp = sp.get()) == null) {
130
            cp = ClassPathFactory.createClassPath(
131
                    new ProjectClassPathImplementation(helper) {
132
                protected String evaluatePath() {
133
                    String cp = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
134
                    if (cp != null) cp = helper.resolvePath(cp);
135
                    return cp;
136
                }
137
            });
138
            sp = new SoftReference<ClassPath>(cp);
139
        }
257
        }
140
        return cp;
258
        return cp;
141
    }
259
    }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/queries/CompiledSourceForBinaryQuery.java (-25 / +32 lines)
Lines 43-49 import java.io.File; Link Here
43
import java.io.File;
43
import java.io.File;
44
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
44
import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation;
45
import org.netbeans.spi.project.support.ant.AntProjectHelper;
45
import org.netbeans.spi.project.support.ant.AntProjectHelper;
46
import org.openide.ErrorManager;
47
import org.openide.filesystems.FileObject;
46
import org.openide.filesystems.FileObject;
48
import java.net.URL;
47
import java.net.URL;
49
import java.net.MalformedURLException;
48
import java.net.MalformedURLException;
Lines 51-56 import java.util.Arrays; Link Here
51
import java.util.Arrays;
50
import java.util.Arrays;
52
import java.util.Collections;
51
import java.util.Collections;
53
import java.util.HashSet;
52
import java.util.HashSet;
53
import java.util.List;
54
import java.util.Set;
54
import java.util.Set;
55
import org.netbeans.api.java.queries.SourceForBinaryQuery;
55
import org.netbeans.api.java.queries.SourceForBinaryQuery;
56
import org.netbeans.api.project.ProjectUtils;
56
import org.netbeans.api.project.ProjectUtils;
Lines 65-70 import org.openide.util.WeakListeners; Link Here
65
65
66
import javax.swing.event.ChangeListener;
66
import javax.swing.event.ChangeListener;
67
import javax.swing.event.ChangeEvent;
67
import javax.swing.event.ChangeEvent;
68
import org.netbeans.modules.mobility.project.J2MESources;
69
import org.openide.util.Exceptions;
68
import org.openide.util.RequestProcessor;
70
import org.openide.util.RequestProcessor;
69
71
70
public class CompiledSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
72
public class CompiledSourceForBinaryQuery implements SourceForBinaryQueryImplementation {
Lines 106-147 public class CompiledSourceForBinaryQuer Link Here
106
            }
108
            }
107
            
109
            
108
            private FileObject[] createRoots() {
110
            private FileObject[] createRoots() {
109
                final ArrayList<FileObject> roots = new ArrayList<FileObject>();
111
                final List<FileObject> roots = new ArrayList<FileObject>();
110
                try {
112
                try {
111
                    final URL projectRoot = URLMapper.findURL(helper.getProjectDirectory(), URLMapper.EXTERNAL);
113
                    final URL projectRoot = URLMapper.findURL(helper.getProjectDirectory(), URLMapper.EXTERNAL);
112
                    URL distRoot = helper.resolveFile("dist").toURI().toURL(); //NOI18N
114
                    URL distRoot = helper.resolveFile("dist").toURI().toURL(); //NOI18N
113
                    URL buildRoot = helper.resolveFile("build").toURI().toURL(); //NOI18N
115
                    URL buildRoot = helper.resolveFile("build").toURI().toURL(); //NOI18N
114
                    if (J2MEProjectUtils.isParentOf(distRoot, binaryRoot) || J2MEProjectUtils.isParentOf(buildRoot, binaryRoot)) {
116
                    if (J2MEProjectUtils.isParentOf(distRoot, binaryRoot) || J2MEProjectUtils.isParentOf(buildRoot, binaryRoot)) {
115
                        final String srcPath = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
117
                        J2MESources sources = project.getLookup().lookup(J2MESources.class);
116
                        final FileObject src = srcPath == null ? null : helper.resolveFileObject(srcPath);
117
                        if (src != null) roots.add(src);
118
                        final String cfg = J2MEProjectUtils.detectConfiguration(projectRoot, binaryRoot);
118
                        final String cfg = J2MEProjectUtils.detectConfiguration(projectRoot, binaryRoot);
119
                        String path = J2MEProjectUtils.evaluateProperty(helper, "libs.classpath", cfg); //NOI18N
119
                        if (sources != null) {
120
                        if (path != null) path = helper.resolvePath(path);
120
                            for (FileObject src : sources.getSourceRoots()) {
121
                        if (path != null) {
121
                                roots.add (src);
122
                            final String p[] = PropertyUtils.tokenizePath(path);
122
                                String path = J2MEProjectUtils.evaluateProperty(helper, "libs.classpath", cfg); //NOI18N
123
                            for (int i=0; i<p.length; i++) try {
123
                                if (path != null) path = helper.resolvePath(path);
124
                                final URL url = J2MEProjectUtils.wrapJar(new File(p[i]).toURI().toURL());
124
                                if (path != null) {
125
                                if (url != null && !J2MEProjectUtils.isParentOf(projectRoot, url)) {
125
                                    final String p[] = PropertyUtils.tokenizePath(path);
126
                                    if (threads.contains(Thread.currentThread())) {
126
                                    for (int i=0; i<p.length; i++) {
127
                                        CyclicDependencyWarningPanel.showWarning(ProjectUtils.getInformation(project).getDisplayName());
127
                                        try {
128
                                        return new FileObject[0];
128
                                            final URL url = J2MEProjectUtils.wrapJar(new File(p[i]).toURI().toURL());
129
                                    }
129
                                            if (url != null && !J2MEProjectUtils.isParentOf(projectRoot, url)) {
130
                                    try {
130
                                                if (threads.contains(Thread.currentThread())) {
131
                                        threads.add(Thread.currentThread());
131
                                                    CyclicDependencyWarningPanel.showWarning(ProjectUtils.getInformation(project).getDisplayName());
132
                                        final SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(url);
132
                                                    return new FileObject[0];
133
                                        if (result != null)
133
                                                }
134
                                            roots.addAll(Arrays.asList(result.getRoots()));
134
                                                try {
135
                                    } finally {
135
                                                    threads.add(Thread.currentThread());
136
                                        threads.remove(Thread.currentThread());
136
                                                    final SourceForBinaryQuery.Result result = SourceForBinaryQuery.findSourceRoots(url);
137
                                                    if (result != null)
138
                                                        roots.addAll(Arrays.asList(result.getRoots()));
139
                                                } finally {
140
                                                    threads.remove(Thread.currentThread());
141
                                                }
142
                                            }
143
                                        } catch (MalformedURLException mue) {
144
                                        }
137
                                    }
145
                                    }
138
                                }
146
                                }
139
                            } catch (MalformedURLException mue) {
140
                            }
147
                            }
141
                        }
148
                        }
142
                    }
149
                    }
143
                } catch (MalformedURLException mue) {
150
                } catch (MalformedURLException mue) {
144
                    ErrorManager.getDefault().notify(mue);
151
                    Exceptions.printStackTrace(mue);
145
                }
152
                }
146
                return roots.toArray(new FileObject[roots.size()]);
153
                return roots.toArray(new FileObject[roots.size()]);
147
            }
154
            }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/queries/FileBuiltQueryImpl.java (-16 / +18 lines)
Lines 53-59 import javax.swing.event.ChangeEvent; Link Here
53
import javax.swing.event.ChangeEvent;
53
import javax.swing.event.ChangeEvent;
54
import javax.swing.event.ChangeListener;
54
import javax.swing.event.ChangeListener;
55
import org.netbeans.api.queries.FileBuiltQuery;
55
import org.netbeans.api.queries.FileBuiltQuery;
56
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
56
import org.netbeans.modules.mobility.project.J2MEProject;
57
import org.netbeans.modules.mobility.project.J2MESources;
57
import org.netbeans.spi.project.support.ant.AntProjectHelper;
58
import org.netbeans.spi.project.support.ant.AntProjectHelper;
58
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
59
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
59
import org.openide.filesystems.FileAttributeEvent;
60
import org.openide.filesystems.FileAttributeEvent;
Lines 64-69 import org.openide.filesystems.FileUtil; Link Here
64
import org.openide.filesystems.FileUtil;
65
import org.openide.filesystems.FileUtil;
65
import org.openide.loaders.DataObject;
66
import org.openide.loaders.DataObject;
66
import org.openide.loaders.DataObjectNotFoundException;
67
import org.openide.loaders.DataObjectNotFoundException;
68
import org.openide.util.Exceptions;
67
import org.openide.util.RequestProcessor;
69
import org.openide.util.RequestProcessor;
68
import org.openide.util.Utilities;
70
import org.openide.util.Utilities;
69
import org.openide.util.WeakListeners;
71
import org.openide.util.WeakListeners;
Lines 76-94 public class FileBuiltQueryImpl implemen Link Here
76
    protected final AntProjectHelper helper;
78
    protected final AntProjectHelper helper;
77
    private static final Object NONE = "NONE"; // NOI18N
79
    private static final Object NONE = "NONE"; // NOI18N
78
    private final Map<FileObject,Object> statuses = new WeakHashMap<FileObject,Object>();
80
    private final Map<FileObject,Object> statuses = new WeakHashMap<FileObject,Object>();
79
    private FileObject srcRoot = null;
81
    private final J2MEProject project;
80
    
82
    
81
    public FileBuiltQueryImpl(AntProjectHelper helper, ProjectConfigurationsHelper confs) {
83
    public FileBuiltQueryImpl(J2MEProject project, AntProjectHelper helper, ProjectConfigurationsHelper confs) {
82
        this.helper = helper;
84
        this.helper = helper;
85
        this.project = project;
83
        confs.addPropertyChangeListener(this);
86
        confs.addPropertyChangeListener(this);
84
    }
85
    
86
    protected FileObject getSrcRoot() {
87
        if (srcRoot == null) {
88
            final String dir = helper.getStandardPropertyEvaluator().getProperty(DefaultPropertiesDescriptor.SRC_DIR);
89
            if (dir != null) srcRoot = helper.resolveFileObject(dir);
90
        }
91
        return srcRoot;
92
    }
87
    }
93
    
88
    
94
    public FileBuiltQuery.Status getStatus(final FileObject file) {
89
    public FileBuiltQuery.Status getStatus(final FileObject file) {
Lines 131-140 public class FileBuiltQueryImpl implemen Link Here
131
    }
126
    }
132
    
127
    
133
    private StatusImpl createStatus(final FileObject file) {
128
    private StatusImpl createStatus(final FileObject file) {
134
        final FileObject root = getSrcRoot();
129
        J2MESources sources = project.getLookup().lookup (J2MESources.class);
135
        if (root != null && file != null && FileUtil.isParentOf(root, file) && file.getExt().equals("java")) try { //NOI18N
130
        for (FileObject fo : sources.getSourceRoots()) {
136
            return new StatusImpl(file);
131
            if (FileUtil.isParentOf(fo, file) && file.getExt().equals("java")) { //NOI18N
137
        } catch (DataObjectNotFoundException dnfe) {}
132
                try {
133
                    return new StatusImpl(file);
134
                } catch (DataObjectNotFoundException ex) {
135
                    Exceptions.printStackTrace(ex);
136
                }
137
            }
138
        }
138
        return null;
139
        return null;
139
    }
140
    }
140
    
141
    
Lines 153-160 public class FileBuiltQueryImpl implemen Link Here
153
        }
154
        }
154
        
155
        
155
        private synchronized File getTarget() {
156
        private synchronized File getTarget() {
156
            final FileObject root = getSrcRoot();
157
            J2MESources sources = project.getLookup().lookup(J2MESources.class);
157
            final FileObject srcFile = source.getPrimaryFile();
158
            final FileObject srcFile = source.getPrimaryFile();
159
            final FileObject root = sources.rootFor(srcFile);
158
            if (root == null || srcFile == null) return null;
160
            if (root == null || srcFile == null) return null;
159
            final String path = FileUtil.getRelativePath(root, srcFile);
161
            final String path = FileUtil.getRelativePath(root, srcFile);
160
            final String buildClasses = helper.getStandardPropertyEvaluator().getProperty("build.classes.dir"); //NOI18N
162
            final String buildClasses = helper.getStandardPropertyEvaluator().getProperty("build.classes.dir"); //NOI18N
(-)6b487c15857b (+74 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
5
Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
7
8
The contents of this file are subject to the terms of either the GNU
9
General Public License Version 2 only ("GPL") or the Common
10
Development and Distribution License("CDDL") (collectively, the
11
"License"). You may not use this file except in compliance with the
12
License. You can obtain a copy of the License at
13
http://www.netbeans.org/cddl-gplv2.html
14
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15
specific language governing permissions and limitations under the
16
License.  When distributing the software, include this License Header
17
Notice in each file and include the License file at
18
nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
19
particular file as subject to the "Classpath" exception as provided
20
by Sun in the GPL Version 2 section of the License file that
21
accompanied this code. If applicable, add the following below the
22
License Header, with the fields enclosed by brackets [] replaced by
23
your own identifying information:
24
"Portions Copyrighted [year] [name of copyright owner]"
25
26
Contributor(s):
27
28
The Original Software is NetBeans. The Initial Developer of the Original
29
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30
Microsystems, Inc. All Rights Reserved.
31
32
If you wish your version of this file to be governed by only the CDDL
33
or only the GPL Version 2, indicate your decision by adding
34
"[Contributor] elects to include this software in this distribution
35
under the [CDDL or GPL Version 2] license." If you do not indicate a
36
single choice of license, a recipient has the option to distribute
37
your version of this file under either the CDDL, the GPL Version 2 or
38
to extend the choice of license to its licensees as provided above.
39
However, if you add GPL Version 2 code and therefore, elected the GPL
40
Version 2 license, then the option applies only if the new code is
41
made subject to such option by the copyright holder.
42
--><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
43
            targetNamespace="http://www.netbeans.org/ns/j2me-project"
44
            xmlns="http://www.netbeans.org/ns/muiltiroot-j2me-project"
45
            elementFormDefault="qualified">
46
    <xsd:element name="data">
47
        <xsd:complexType>
48
            <xsd:sequence>
49
                <xsd:element name="name" type="xsd:token"/>
50
                <xsd:element name="minimum-ant-version" minOccurs="0">
51
                    <xsd:simpleType>
52
                        <xsd:restriction base="xsd:NMTOKEN">
53
                            <xsd:enumeration value="1.6"/>
54
                        </xsd:restriction>
55
                    </xsd:simpleType>
56
                </xsd:element>
57
                <xsd:element name="use-manifest" minOccurs="0"/>
58
                <xsd:element name="explicit-platform" minOccurs="0"/>
59
                <xsd:element name="source-roots">
60
                    <xsd:complexType>
61
                        <xsd:sequence>
62
                            <xsd:element name="root" minOccurs="0" maxOccurs="unbounded">
63
                                <xsd:complexType>
64
                                    <xsd:attribute name="id" use="required" type="xsd:token"/>
65
                                    <xsd:attribute name="name" use="optional" type="xsd:token"/>
66
                                </xsd:complexType>
67
                            </xsd:element>
68
                        </xsd:sequence>
69
                    </xsd:complexType>
70
                </xsd:element>
71
            </xsd:sequence>
72
        </xsd:complexType>
73
    </xsd:element>
74
</xsd:schema>
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/J2MECustomizerProvider.java (-1 / +4 lines)
Lines 47-52 import javax.swing.JButton; Link Here
47
47
48
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
49
import org.netbeans.api.project.ProjectUtils;
49
import org.netbeans.api.project.ProjectUtils;
50
import org.netbeans.modules.mobility.project.J2MEProject;
50
import org.netbeans.modules.mobility.project.ui.customizer.J2MECustomizer;
51
import org.netbeans.modules.mobility.project.ui.customizer.J2MECustomizer;
51
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
52
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
52
import org.netbeans.modules.mobility.project.ProjectConfigurationsHelper;
53
import org.netbeans.modules.mobility.project.ProjectConfigurationsHelper;
Lines 108-118 public class J2MECustomizerProvider impl Link Here
108
        options[ OPTION_CANCEL ].setActionCommand( COMMAND_CANCEL );
109
        options[ OPTION_CANCEL ].setActionCommand( COMMAND_CANCEL );
109
        
110
        
110
        // RegisterListener
111
        // RegisterListener
111
        final J2MEProjectProperties j2meProperties = new J2MEProjectProperties( project, antProjectHelper, refHelper, configHelper );
112
        final J2MEProjectProperties j2meProperties = new J2MEProjectProperties((J2MEProject) project, antProjectHelper, refHelper, configHelper );
112
        final ActionListener optionsListener = new OptionListener( this, project, j2meProperties );
113
        final ActionListener optionsListener = new OptionListener( this, project, j2meProperties );
113
        options[ OPTION_OK ].addActionListener( optionsListener );
114
        options[ OPTION_OK ].addActionListener( optionsListener );
114
        options[ OPTION_CANCEL ].addActionListener( optionsListener );
115
        options[ OPTION_CANCEL ].addActionListener( optionsListener );
115
        final J2MECustomizer customizer = addConfig ? new J2MECustomizer( j2meProperties, J2MECustomizer.ADD_CONFIG_DIALOG) : new J2MECustomizer( j2meProperties );
116
        final J2MECustomizer customizer = addConfig ? new J2MECustomizer( j2meProperties, J2MECustomizer.ADD_CONFIG_DIALOG) : new J2MECustomizer( j2meProperties );
117
        
118
        //XXX Add Sources Panel
116
        dialogDescriptor = new DialogDescriptor(
119
        dialogDescriptor = new DialogDescriptor(
117
                customizer, // innerPane
120
                customizer, // innerPane
118
                ProjectUtils.getInformation(project).getDisplayName(),               // displayName
121
                ProjectUtils.getInformation(project).getDisplayName(),               // displayName
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/J2MEProjectRootNode.java (-7 / +39 lines)
Lines 1-3 package org.netbeans.modules.mobility.pr Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
1
package org.netbeans.modules.mobility.project.ui;
39
package org.netbeans.modules.mobility.project.ui;
2
40
3
import java.awt.Image;
41
import java.awt.Image;
Lines 25-31 import org.openide.actions.FindAction; Link Here
25
import org.openide.actions.FindAction;
63
import org.openide.actions.FindAction;
26
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileObject;
27
import org.openide.nodes.AbstractNode;
65
import org.openide.nodes.AbstractNode;
28
import org.openide.nodes.Children;
29
import org.openide.nodes.Node;
66
import org.openide.nodes.Node;
30
import org.openide.util.HelpCtx;
67
import org.openide.util.HelpCtx;
31
import org.openide.util.ImageUtilities;
68
import org.openide.util.ImageUtilities;
Lines 51-57 final class J2MEProjectRootNode extends Link Here
51
    }
88
    }
52
89
53
    private J2MEProjectRootNode(J2MEProject project, ProjectRootNodeChildren childFactory) {
90
    private J2MEProjectRootNode(J2MEProject project, ProjectRootNodeChildren childFactory) {
54
        super(Children.create(childFactory, true), Lookups.singleton(project));
91
        super(childFactory, Lookups.singleton(project));
55
        this.broken = project.hasBrokenLinks();
92
        this.broken = project.hasBrokenLinks();
56
        this.nodeUpdateTask = RequestProcessor.getDefault().create(this);
93
        this.nodeUpdateTask = RequestProcessor.getDefault().create(this);
57
        setName(ProjectUtils.getInformation(project).getDisplayName());
94
        setName(ProjectUtils.getInformation(project).getDisplayName());
Lines 62-72 final class J2MEProjectRootNode extends Link Here
62
        this.ref3 = WeakListeners.propertyChange(this, LibraryManager.getDefault());
99
        this.ref3 = WeakListeners.propertyChange(this, LibraryManager.getDefault());
63
        LibraryManager.getDefault().addPropertyChangeListener(ref3);
100
        LibraryManager.getDefault().addPropertyChangeListener(ref3);
64
        JavaPlatformManager.getDefault().addPropertyChangeListener(ref1);
101
        JavaPlatformManager.getDefault().addPropertyChangeListener(ref1);
65
    }
66
67
    protected boolean testSourceRoot() {
68
        AntProjectHelper helper = getLookup().lookup(J2MEProject.class).getLookup().lookup(AntProjectHelper.class);
69
        return helper.resolveFileObject(helper.getStandardPropertyEvaluator().getProperty("src.dir")) != null;
70
    }
102
    }
71
103
72
    protected void checkBroken() {
104
    protected void checkBroken() {
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/ProjectRootNodeChildren.java (-16 / +31 lines)
Lines 38-66 Link Here
38
 */
38
 */
39
package org.netbeans.modules.mobility.project.ui;
39
package org.netbeans.modules.mobility.project.ui;
40
40
41
import java.util.Arrays;
41
import java.beans.PropertyChangeEvent;
42
import java.util.List;
42
import java.beans.PropertyChangeListener;
43
import java.util.Collections;
43
import org.netbeans.api.java.project.JavaProjectConstants;
44
import org.netbeans.api.java.project.JavaProjectConstants;
44
import org.netbeans.api.project.ProjectUtils;
45
import org.netbeans.api.project.ProjectUtils;
45
import org.netbeans.api.project.SourceGroup;
46
import org.netbeans.api.project.SourceGroup;
46
import org.netbeans.api.project.Sources;
47
import org.netbeans.api.project.Sources;
48
import org.netbeans.modules.java.api.common.SourceRoots;
47
import org.netbeans.modules.mobility.project.J2MEProject;
49
import org.netbeans.modules.mobility.project.J2MEProject;
48
import org.netbeans.modules.mobility.project.ui.ProjectRootNodeChildren.ChildKind;
50
import org.netbeans.modules.mobility.project.ui.ProjectRootNodeChildren.ChildKind;
49
import org.netbeans.spi.java.project.support.ui.PackageView;
51
import org.netbeans.spi.java.project.support.ui.PackageView;
50
import org.netbeans.spi.project.support.ant.AntProjectHelper;
51
import org.openide.nodes.AbstractNode;
52
import org.openide.nodes.ChildFactory;
53
import org.openide.nodes.Children;
52
import org.openide.nodes.Children;
54
import org.openide.nodes.FilterNode;
55
import org.openide.nodes.Node;
53
import org.openide.nodes.Node;
56
import org.openide.util.NbBundle;
54
import org.openide.util.RequestProcessor;
57
import org.openide.util.lookup.Lookups;
58
55
59
/**
56
/**
60
 *
57
 *
61
 * @author Tim Boudreau
58
 * @author Tim Boudreau
62
 */
59
 */
63
public class ProjectRootNodeChildren extends ChildFactory<ChildKind> {
60
public class ProjectRootNodeChildren extends Children.Keys<ChildKind> implements PropertyChangeListener, Runnable {
64
61
65
    private final J2MEProject project;
62
    private final J2MEProject project;
66
63
Lines 74-86 public class ProjectRootNodeChildren ext Link Here
74
        this.project = project;
71
        this.project = project;
75
    }
72
    }
76
73
77
    protected boolean createKeys(List<ChildKind> toPopulate) {
74
    @Override
78
        toPopulate.addAll(Arrays.asList(ChildKind.values()));
75
    protected void addNotify() {
79
        return true;
76
        setKeys (ChildKind.values());
77
        project.getSourceRoots().addPropertyChangeListener(this);
80
    }
78
    }
81
79
82
    @Override
80
    @Override
83
    protected Node[] createNodesForKey(ChildKind key) {
81
    protected void removeNotify() {
82
        setKeys (Collections.EMPTY_SET);
83
        project.getSourceRoots().removePropertyChangeListener(this);
84
    }
85
86
    @Override
87
    protected Node[] createNodes(ChildKind key) {
84
        switch (key) {
88
        switch (key) {
85
            case Configurations:
89
            case Configurations:
86
                return new Node[]{createConfigurationsNode()};
90
                return new Node[]{createConfigurationsNode()};
Lines 108-118 public class ProjectRootNodeChildren ext Link Here
108
            final SourceGroup sg[] = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
112
            final SourceGroup sg[] = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
109
            result = new Node[sg.length];
113
            result = new Node[sg.length];
110
            int ix = 0;
114
            int ix = 0;
111
            //in preparation for multiple source roots
112
            for (SourceGroup group : sg) {
115
            for (SourceGroup group : sg) {
113
                result[ix++] = PackageView.createPackageView(sg[0]);
116
                result[ix++] = PackageView.createPackageView(group);
114
            }
117
            }
115
        }
118
        }
116
        return result.length == 0 ? new Node[] { Node.EMPTY } : result;
119
        return result.length == 0 ? new Node[0] : result;
120
    }
121
122
    public void propertyChange(PropertyChangeEvent evt) {
123
        System.err.println("Got change from source roots: " + evt.getPropertyName());
124
        if (SourceRoots.PROP_ROOTS.equals(evt.getPropertyName())) {
125
            //Get this out of the way of ProjectManager.mutex()
126
            RequestProcessor.getDefault().post(this);
127
        }
128
    }
129
130
    public void run() {
131
        refreshKey(ChildKind.Sources);
117
    }
132
    }
118
}
133
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties (-3 / +68 lines)
Lines 111-116 LBL_Customizer_Category=&Category\: Link Here
111
# Configuration node labels
111
# Configuration node labels
112
Customizer/org.netbeans.modules.kjava.j2meproject/general=General
112
Customizer/org.netbeans.modules.kjava.j2meproject/general=General
113
Customizer/org.netbeans.modules.kjava.j2meproject/general/general=General
113
Customizer/org.netbeans.modules.kjava.j2meproject/general/general=General
114
Customizer/org.netbeans.modules.kjava.j2meproject/Sources=Sources
114
Customizer/org.netbeans.modules.kjava.j2meproject/Platform=Platform
115
Customizer/org.netbeans.modules.kjava.j2meproject/Platform=Platform
115
Customizer/org.netbeans.modules.kjava.j2meproject/Platform/CLDC=CLDC/MIDP
116
Customizer/org.netbeans.modules.kjava.j2meproject/Platform/CLDC=CLDC/MIDP
116
Customizer/org.netbeans.modules.kjava.j2meproject/Abilities=Abilities
117
Customizer/org.netbeans.modules.kjava.j2meproject/Abilities=Abilities
Lines 691-697 LBL_CustPlatform_NoCustomizer=No customi Link Here
691
LBL_CustPlatform_NoCustomizer=No customizer for selected platform type is available.
692
LBL_CustPlatform_NoCustomizer=No customizer for selected platform type is available.
692
LBL_CustMain_AppVersion=&Application Version Number\:
693
LBL_CustMain_AppVersion=&Application Version Number\:
693
LBL_CustMain_AppCounter=Application &Version Counter\:
694
LBL_CustMain_AppCounter=Application &Version Counter\:
694
LBL_CustMain_AutoIncrement=Automated Appl&ication Version Incrementation
695
LBL_CustMain_AutoIncrement=Automatically Increment Appl&ication Version
695
LBL_NewConfigPanel_ConfigurationPrefix=&New Configurations Prefix\: 
696
LBL_NewConfigPanel_ConfigurationPrefix=&New Configurations Prefix\: 
696
LBL_NewConfigPanel_ConfigurationSuffix=&Suffix\:
697
LBL_NewConfigPanel_ConfigurationSuffix=&Suffix\:
697
ACSN_jButtonAddMore=Add more
698
ACSN_jButtonAddMore=Add more
Lines 706-713 ACSD_CustMain_AppVersion=Application Ver Link Here
706
ACSD_CustMain_AppVersion=Application Version Number
707
ACSD_CustMain_AppVersion=Application Version Number
707
ACSN_CustMain_AppCounter=Application Version Counter
708
ACSN_CustMain_AppCounter=Application Version Counter
708
ACSD_CustMain_AppCounter=Application Version Counter
709
ACSD_CustMain_AppCounter=Application Version Counter
709
ACSN_CustMain_AutoIncrement=Automated Application Version Incrementation
710
ACSN_CustMain_AutoIncrement=Automatically Increment Application Version
710
ACSD_CustMain_AutoIncrement=Select for Automated Application Version Incrementation
711
ACSD_CustMain_AutoIncrement=Select to automatically increment application version
711
ACSN_CustomizeGeneral_UsePreprocessor=Use Preprocessor
712
ACSN_CustomizeGeneral_UsePreprocessor=Use Preprocessor
712
ACSD_CustomizeGeneral_UsePreprocessor=Select to use Preprocessor
713
ACSD_CustomizeGeneral_UsePreprocessor=Select to use Preprocessor
713
ACSN_CustGeneral_RequiredProjects=Required Projects
714
ACSN_CustGeneral_RequiredProjects=Required Projects
Lines 737-739 ACSD_UseDefault=Uses Values from "Defaul Link Here
737
ACSD_UseDefault=Uses Values from "DefaultConfiguration"
738
ACSD_UseDefault=Uses Values from "DefaultConfiguration"
738
ACSN_SelectPlatform=Select platform type
739
ACSN_SelectPlatform=Select platform type
739
ACSD_SelectPlatform=Chooses platform type from list
740
ACSD_SelectPlatform=Chooses platform type from list
741
742
743
#CustomizerSources
744
CTL_ProjectFolder=Project Folder
745
TITLE_InvalidRoot=Add Package Folder
746
MSG_InvalidRoot=<html><b>Package Folder Already Used in Project</b></html>\n\
747
    Following folders you selected are already used in this or another\n\
748
    project. One package folder can only be used in one project in one\n\
749
    package folder list (source packages or test packages).
750
LBL_InvalidRoot=Package folders already in use:
751
MNE_InvalidRoot=A
752
MSG_InvalidRoot2=Those folders cannot be added to the project.
753
AD_InvalidRoot=N/A
754
AD_InvalidRootDlg=N/A
755
CTL_J2SESourceRootsUi_Close=Close
756
AD_J2SESourceRootsUi_Close=N/A
757
CTL_ChangePlatform=Change Platform
758
AD_ChangePlatform=N/A
759
TXT_ChangePlatform=<html><b>Incompatible Source Level Value {0}</b></html>\n\
760
    The source level version for this project ({0}) is higher than the\n\
761
    Java Platform version you just selected ({1}). Changing the Java\n\
762
    Platform will update the project''s source level to version {1}.\n\n\
763
    Do you want to change the Java Platform and update the source level\n\
764
    version?
765
TXT_ChangePlatformTitle=Change Java Platform
766
CustomizerSources.includeExcludeButton=
767
CustomizerSources.title.includeExclude=Configure Includes & Excludes
768
MSG_EncodingWarning=Changing project encoding might result in some characters in existing files not being read and written correctly.
769
CTL_ProjectFolder_1=Project Folder
770
CTL_SourceRoots=Source Roots
771
CTL_TestRoots=Test Roots
772
TXT_SourceLevel=Source Level
773
TXT_Encoding=Encoding
774
CTL_AddSourceRoot=Add Source Root
775
CTL_RemoveSourceRoot=Remove Source Root
776
CTL_UpSourceRoot=Up
777
CTL_DownSourceRoot=Down
778
CTL_AddTestRoot=Add Test Source Root
779
CTL_RemoveTestRoot=Remove Test Source Root
780
CTL_UpTestRoot=Up
781
CTL_DownTestRoot=Down
782
CustomizerSources.includeExcludeButton_1=&Includes/Excludes...
783
784
785
#####################################
786
#J2MESourceRootsUI
787
#####################################
788
CTL_PackageFolders=Package Folder
789
CTL_PackageLabels=Label
790
CTL_J2SESourceRootsUi_Close=Close
791
AD_J2SESourceRootsUi_Close=N/A
792
CTL_ProjectFolder=Project Folder
793
TITLE_InvalidRoot=Add Package Folder
794
MSG_InvalidRoot=<html><b>Package Folder Already Used in Project</b></html>\n\
795
    Following folders you selected are already used in this or another\n\
796
    project. One package folder can only be used in one project in one\n\
797
    package folder list (source packages or test packages).
798
LBL_InvalidRoot=Package folders already in use:
799
MNE_InvalidRoot=A
800
MSG_InvalidRoot2=Those folders cannot be added to the project.
801
LBL_SourceFolder_DialogTitle=Add Source Folder
802
LBL_TestFolder_DialogTitle=Add Test Folder
803
TXT_RootOwnedByProject={0} (owned by {1})
804
DEFAULT_PACKAGE=<Default Package>
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerAbilities.form (-1 / +3 lines)
Lines 1-8 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
6
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
6
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
7
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerAbilities.java (-2 / +3 lines)
Lines 65-70 import javax.swing.ListSelectionModel; Link Here
65
import javax.swing.ListSelectionModel;
65
import javax.swing.ListSelectionModel;
66
import javax.swing.event.ListSelectionListener;
66
import javax.swing.event.ListSelectionListener;
67
import javax.swing.table.AbstractTableModel;
67
import javax.swing.table.AbstractTableModel;
68
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
68
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
69
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
69
import org.netbeans.spi.project.ProjectConfiguration;
70
import org.netbeans.spi.project.ProjectConfiguration;
70
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
71
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
Lines 89-95 public class CustomizerAbilities extends Link Here
89
    final protected JTable table;
90
    final protected JTable table;
90
    final protected StorableTableModel tableModel;
91
    final protected StorableTableModel tableModel;
91
    private VisualPropertySupport vps;
92
    private VisualPropertySupport vps;
92
    private ProjectProperties props;
93
    private MultiRootProjectProperties props;
93
    
94
    
94
    /** Creates new form CustomizerConfigs */
95
    /** Creates new form CustomizerConfigs */
95
    public CustomizerAbilities() {
96
    public CustomizerAbilities() {
Lines 204-210 public class CustomizerAbilities extends Link Here
204
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerAbilities.class, "ACSD_CustAbilities"));
205
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerAbilities.class, "ACSD_CustAbilities"));
205
    }
206
    }
206
    
207
    
207
    public void initValues(ProjectProperties props, String configuration) {
208
    public void initValues(MultiRootProjectProperties props, String configuration) {
208
        this.props = props;
209
        this.props = props;
209
        vps = VisualPropertySupport.getDefault(props);
210
        vps = VisualPropertySupport.getDefault(props);
210
        vps.register(cDefault, configuration, this);
211
        vps.register(cDefault, configuration, this);
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerCompile.java (-1 / +2 lines)
Lines 44-49 import java.util.Arrays; Link Here
44
import java.util.Arrays;
44
import java.util.Arrays;
45
import java.util.Comparator;
45
import java.util.Comparator;
46
import javax.swing.JPanel;
46
import javax.swing.JPanel;
47
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
47
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
48
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
48
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
49
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
49
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
50
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 76-82 public class CustomizerCompile extends J Link Here
76
        Arrays.sort(ENCODINGS, new EncodingComparator());
77
        Arrays.sort(ENCODINGS, new EncodingComparator());
77
    }
78
    }
78
    
79
    
79
    public void initValues(ProjectProperties props, String configuration) {
80
    public void initValues(MultiRootProjectProperties props, String configuration) {
80
        vps = VisualPropertySupport.getDefault(props);
81
        vps = VisualPropertySupport.getDefault(props);
81
        vps.register(defaultCheck, configuration, this);
82
        vps.register(defaultCheck, configuration, this);
82
        
83
        
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerDeploy.java (-2 / +3 lines)
Lines 61-66 import javax.swing.JSlider; Link Here
61
import javax.swing.JSlider;
61
import javax.swing.JSlider;
62
import javax.swing.JSpinner;
62
import javax.swing.JSpinner;
63
import javax.swing.text.JTextComponent;
63
import javax.swing.text.JTextComponent;
64
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
64
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
65
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
65
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
66
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
66
import org.netbeans.modules.mobility.project.deployment.MobilityDeploymentManagerPanel;
67
import org.netbeans.modules.mobility.project.deployment.MobilityDeploymentManagerPanel;
Lines 86-92 public class CustomizerDeploy extends JP Link Here
86
    private MobilityDeploymentProperties mdp = new MobilityDeploymentProperties();
87
    private MobilityDeploymentProperties mdp = new MobilityDeploymentProperties();
87
    
88
    
88
    private String config;
89
    private String config;
89
    private ProjectProperties pp;
90
    private MultiRootProjectProperties pp;
90
    private Component cComp = null;
91
    private Component cComp = null;
91
    
92
    
92
    /** Creates new form CustomizerConfigs */
93
    /** Creates new form CustomizerConfigs */
Lines 213-219 public class CustomizerDeploy extends JP Link Here
213
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerRun.class, "ACSD_CustDeploy"));
214
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerRun.class, "ACSD_CustDeploy"));
214
    }
215
    }
215
    
216
    
216
    public void initValues(ProjectProperties props, String configuration) {
217
    public void initValues(MultiRootProjectProperties props, String configuration) {
217
        for ( DeploymentPlugin p : Lookup.getDefault().lookup(new Lookup.Template<DeploymentPlugin>(DeploymentPlugin.class)).allInstances() ){
218
        for ( DeploymentPlugin p : Lookup.getDefault().lookup(new Lookup.Template<DeploymentPlugin>(DeploymentPlugin.class)).allInstances() ){
218
            if (p instanceof CustomizerPanel){
219
            if (p instanceof CustomizerPanel){
219
                ((CustomizerPanel)p).initValues(props, configuration);
220
                ((CustomizerPanel)p).initValues(props, configuration);
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerFiltering.java (-17 / +119 lines)
Lines 50-74 import java.awt.Dimension; Link Here
50
import java.awt.Dimension;
50
import java.awt.Dimension;
51
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionEvent;
52
import java.awt.event.ActionListener;
52
import java.awt.event.ActionListener;
53
import java.beans.PropertyChangeListener;
54
import java.beans.PropertyVetoException;
55
import java.io.IOException;
53
import java.util.ArrayList;
56
import java.util.ArrayList;
57
import java.util.Arrays;
54
import java.util.Map;
58
import java.util.Map;
55
import java.util.regex.Pattern;
59
import java.util.regex.Pattern;
60
import javax.swing.Icon;
61
import javax.swing.ImageIcon;
56
import javax.swing.JPanel;
62
import javax.swing.JPanel;
57
import javax.swing.plaf.basic.BasicBorders;
63
import javax.swing.plaf.basic.BasicBorders;
58
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
64
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
65
import org.netbeans.api.project.SourceGroup;
59
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
66
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
60
import org.netbeans.modules.mobility.project.ui.customizer.regex.CheckedTreeBeanView;
67
import org.netbeans.modules.mobility.project.ui.customizer.regex.CheckedTreeBeanView;
61
import org.netbeans.modules.mobility.project.ui.customizer.regex.FileObjectCookie;
68
import org.netbeans.modules.mobility.project.ui.customizer.regex.FileObjectCookie;
69
import org.netbeans.spi.java.project.support.ui.PackageView;
62
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
70
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
63
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
71
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
64
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
72
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
65
import org.openide.explorer.ExplorerManager;
73
import org.openide.explorer.ExplorerManager;
66
import org.openide.filesystems.FileObject;
74
import org.openide.filesystems.FileObject;
75
import org.openide.filesystems.FileStateInvalidException;
67
import org.openide.filesystems.FileUtil;
76
import org.openide.filesystems.FileUtil;
77
import org.openide.filesystems.LocalFileSystem;
78
import org.openide.filesystems.MultiFileSystem;
68
import org.openide.loaders.DataObject;
79
import org.openide.loaders.DataObject;
69
import org.openide.loaders.DataObjectNotFoundException;
70
import org.openide.nodes.FilterNode;
80
import org.openide.nodes.FilterNode;
71
import org.openide.nodes.Node;
81
import org.openide.nodes.Node;
82
import org.openide.util.Exceptions;
83
import org.openide.util.ImageUtilities;
72
import org.openide.util.NbBundle;
84
import org.openide.util.NbBundle;
73
85
74
/**
86
/**
Lines 91-97 public class CustomizerFiltering extends Link Here
91
    private Pattern filter;
103
    private Pattern filter;
92
    private Map<String,Object> properties;
104
    private Map<String,Object> properties;
93
    private String configuration;
105
    private String configuration;
94
    private FileObject srcRoot;
106
    private FileObject[] srcRoots;
95
    private String excludesTranslatedPropertyName;
107
    private String excludesTranslatedPropertyName;
96
    
108
    
97
    /** Creates new form CustomizerConfigs */
109
    /** Creates new form CustomizerConfigs */
Lines 211-222 public class CustomizerFiltering extends Link Here
211
        treeView.getAccessibleContext().setAccessibleDescription( jLabelTree.getText() );
223
        treeView.getAccessibleContext().setAccessibleDescription( jLabelTree.getText() );
212
    }
224
    }
213
    
225
    
214
    public void initValues(ProjectProperties props, String configuration) {
226
    public void initValues(MultiRootProjectProperties props, String configuration) {
215
        this.vps = VisualPropertySupport.getDefault(props);
227
        this.vps = VisualPropertySupport.getDefault(props);
216
        this.properties = props;
228
        this.properties = props;
217
        this.configuration = configuration;
229
        this.configuration = configuration;
218
        this.srcRoot = props.getSourceRoot();
230
219
        treeView.setSrcRoot(srcRoot);
231
        this.srcRoots = props.getSourceRoots();
232
233
        treeView.setSrcRoots(srcRoots);
220
        vps.register(defaultCheck, configuration, this);
234
        vps.register(defaultCheck, configuration, this);
221
    }
235
    }
222
    
236
    
Lines 255-268 public class CustomizerFiltering extends Link Here
255
            }
269
            }
256
        }
270
        }
257
        this.filter = Pattern.compile(sFilter);
271
        this.filter = Pattern.compile(sFilter);
258
        try {
272
//        Node rootNode = new AbstractNode (Children.create(new RootNodeFactory(), false));
259
            final DataObject dob = DataObject.find(srcRoot);
273
        Node rootNode = new FOBNode(PackageView.createPackageView(new FakeSourceGroup(srcRoots)), null);
260
            manager.setRootContext(new FOBNode(dob.getNodeDelegate().cloneNode(), dob.getPrimaryFile()));
274
        manager.setRootContext(rootNode);
261
        } catch (DataObjectNotFoundException dnfe) {
262
            manager.setRootContext(Node.EMPTY);
263
        }
264
        treeView.registerProperty(properties, excludesTranslatedPropertyName, filter);
275
        treeView.registerProperty(properties, excludesTranslatedPropertyName, filter);
265
    }
276
    }
277
278
    private static final class FakeSourceGroup implements SourceGroup {
279
        private final FileObject[] roots;
280
        private final MultiFileSystem fs;
281
        FakeSourceGroup(FileObject[] roots) {
282
            this.roots = roots;
283
            LocalFileSystem[] perRoot = new LocalFileSystem[roots.length];
284
            for (int i = 0; i < perRoot.length; i++) {
285
                perRoot[i] = new LocalFileSystem();
286
                try {
287
                    perRoot[i].setRootDirectory(FileUtil.toFile(roots[i]));
288
                } catch (PropertyVetoException ex) {
289
                    Exceptions.printStackTrace(ex);
290
                } catch (IOException ex) {
291
                    Exceptions.printStackTrace(ex);
292
                }
293
            }
294
            fs = new MultiFileSystem (perRoot);
295
        }
296
297
        public FileObject getRootFolder() {
298
            return fs.getRoot();
299
        }
300
301
        public String getName() {
302
            return "X";
303
        }
304
305
        public String getDisplayName() {
306
            return getName();
307
        }
308
309
        public Icon getIcon(boolean opened) {
310
            //Not visible, doesn't matter, but renderer will throw an exception
311
            return new ImageIcon(ImageUtilities.loadImage(
312
                    "org/netbeans/modules/mobility/project/ui/resources/config.gif"));
313
        }
314
315
        public boolean contains(FileObject file) throws IllegalArgumentException {
316
            try {
317
                return file.getFileSystem() == fs;
318
            } catch (FileStateInvalidException ex) {
319
                Exceptions.printStackTrace(ex);
320
                return false;
321
            }
322
        }
323
324
        public void addPropertyChangeListener(PropertyChangeListener listener) {
325
            //do nothing
326
        }
327
328
        public void removePropertyChangeListener(PropertyChangeListener listener) {
329
            //do nothing
330
        }
331
332
    }
333
334
//    private final class RootNodeFactory extends ChildFactory<ClassPath.Entry> {
335
//        @Override
336
//        protected Node createNodeForKey(ClassPath.Entry key) {
337
////            try {
338
////                DataObject dob = DataObject.find(key);
339
////                return new FOBNode(dob.getNodeDelegate(), key);
340
////            } catch (DataObjectNotFoundException ex) {
341
////                Exceptions.printStackTrace(ex);
342
////                return null;
343
////            }
344
//        }
345
//
346
//        @Override
347
//        protected boolean createKeys(List<ClassPath.Entry> toPopulate) {
348
//            ClassPath path = ClassPathFactory.createClassPath(new CPI(srcRoots));
349
//
350
//            for (FileObject fo : srcRoots) {
351
//                toPopulate.addAll(path.entries());
352
//            }
353
////            toPopulate.addAll (Arrays.asList (srcRoots));
354
//        }
355
//    }
356
266
    
357
    
267
    // Variables declaration - do not modify//GEN-BEGIN:variables
358
    // Variables declaration - do not modify//GEN-BEGIN:variables
268
    private javax.swing.JCheckBox defaultCheck;
359
    private javax.swing.JCheckBox defaultCheck;
Lines 275-281 public class CustomizerFiltering extends Link Here
275
    // End of variables declaration//GEN-END:variables
366
    // End of variables declaration//GEN-END:variables
276
    
367
    
277
    boolean acceptFileObject(final FileObject fo) {
368
    boolean acceptFileObject(final FileObject fo) {
278
        final String path = FileUtil.getRelativePath(srcRoot, fo);
369
//        FileObject root = null;
370
//        for (FileObject test : srcRoots) {
371
//            if (fo.getPath().startsWith(test.getPath())) {
372
//                root = test;
373
//            }
374
//        }
375
//        assert root != null : fo.getPath() + " not a child of any of the " +
376
//                "following project source roots: " + Arrays.asList(srcRoots);
377
        final String path = fo.getPath();
279
        return path != null && !filter.matcher(path).matches();
378
        return path != null && !filter.matcher(path).matches();
280
    }
379
    }
281
    
380
    
Lines 287-297 public class CustomizerFiltering extends Link Here
287
    private class FOBNode extends FilterNode implements FileObjectCookie {
386
    private class FOBNode extends FilterNode implements FileObjectCookie {
288
        private final FileObject fo;
387
        private final FileObject fo;
289
        public FOBNode(Node n, FileObject fo) {
388
        public FOBNode(Node n, FileObject fo) {
290
            super(n, fo.isData() ? org.openide.nodes.Children.LEAF : new FOBChildren(n));
389
            super(n, fo != null && fo.isData() ? org.openide.nodes.Children.LEAF : new FOBChildren(n));
291
            this.fo = fo;
390
            this.fo = fo;
292
            disableDelegation(DELEGATE_SET_NAME | DELEGATE_GET_NAME | DELEGATE_SET_DISPLAY_NAME | DELEGATE_GET_DISPLAY_NAME);
391
            disableDelegation(DELEGATE_SET_NAME | DELEGATE_GET_NAME | DELEGATE_SET_DISPLAY_NAME | DELEGATE_GET_DISPLAY_NAME);
293
            setName(fo.getNameExt());
392
//            setName(fo == null ? "" : fo.getNameExt());
294
            setDisplayName(fo.getNameExt());
393
            setName (fo == null ? "" : fo.getPath());
394
            setDisplayName(fo == null || "".equals(getName()) ? NbBundle.getMessage(FOBNode.class,
395
                    "DEFAULT_PACKAGE") : fo.getNameExt());
396
            setShortDescription(getName());
295
        }
397
        }
296
        
398
        
297
        public Node.Cookie getCookie(final Class type) {
399
        public Node.Cookie getCookie(final Class type) {
Lines 300-306 public class CustomizerFiltering extends Link Here
300
        }
402
        }
301
        
403
        
302
        public FileObject getFileObject() {
404
        public FileObject getFileObject() {
303
            return fo;
405
            return fo == null ? getLookup().lookup(DataObject.class).getPrimaryFile() : fo;
304
        }
406
        }
305
    }
407
    }
306
    
408
    
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerGeneral.form (-51 lines)
Lines 97-143 Link Here
97
        </Constraint>
97
        </Constraint>
98
      </Constraints>
98
      </Constraints>
99
    </Component>
99
    </Component>
100
    <Component class="javax.swing.JLabel" name="jLabel4">
101
      <Properties>
102
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
103
          <ComponentRef name="jTextFieldSrcRoot"/>
104
        </Property>
105
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
106
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="LBL_CustomizeGeneral_SrcDir" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
107
        </Property>
108
      </Properties>
109
      <AccessibilityProperties>
110
        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
111
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="ACSN_CustomizeGeneral_SrcDir" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
112
        </Property>
113
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
114
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="ACSD_CustomizeGeneral_SrcDir" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
115
        </Property>
116
      </AccessibilityProperties>
117
      <Constraints>
118
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
119
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="11" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="17" weightX="0.0" weightY="0.0"/>
120
        </Constraint>
121
      </Constraints>
122
    </Component>
123
    <Component class="javax.swing.JTextField" name="jTextFieldSrcRoot">
124
      <Properties>
125
        <Property name="editable" type="boolean" value="false"/>
126
      </Properties>
127
      <AccessibilityProperties>
128
        <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
129
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="ACSN_CustGeneral_PrjSources" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
130
        </Property>
131
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
132
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="ACSD_CustGeneral_PrjSources" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
133
        </Property>
134
      </AccessibilityProperties>
135
      <Constraints>
136
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
137
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
138
        </Constraint>
139
      </Constraints>
140
    </Component>
141
    <Component class="javax.swing.JLabel" name="jLabel5">
100
    <Component class="javax.swing.JLabel" name="jLabel5">
142
      <Properties>
101
      <Properties>
143
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
102
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
Lines 224-234 Link Here
224
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
183
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
225
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="LBL_CustMain_AutoIncrement" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
184
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="LBL_CustMain_AutoIncrement" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
226
        </Property>
185
        </Property>
227
        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
228
          <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
229
            <EmptyBorder bottom="0" left="0" right="0" top="0"/>
230
          </Border>
231
        </Property>
232
        <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
186
        <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
233
          <Insets value="[0, 0, 0, 0]"/>
187
          <Insets value="[0, 0, 0, 0]"/>
234
        </Property>
188
        </Property>
Lines 251-261 Link Here
251
      <Properties>
205
      <Properties>
252
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
206
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
253
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="LBL_CustomizeGeneral_UsePreprocessor" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
207
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="LBL_CustomizeGeneral_UsePreprocessor" replaceFormat="NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
254
        </Property>
255
        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
256
          <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
257
            <EmptyBorder bottom="0" left="0" right="0" top="0"/>
258
          </Border>
259
        </Property>
208
        </Property>
260
        <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
209
        <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
261
          <Insets value="[0, 0, 0, 0]"/>
210
          <Insets value="[0, 0, 0, 0]"/>
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerGeneral.java (-29 / +3 lines)
Lines 50-56 import javax.swing.DefaultListModel; Link Here
50
import javax.swing.DefaultListModel;
50
import javax.swing.DefaultListModel;
51
import javax.swing.JPanel;
51
import javax.swing.JPanel;
52
import javax.swing.JSpinner;
52
import javax.swing.JSpinner;
53
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
53
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
54
import org.netbeans.api.project.Project;
54
import org.netbeans.api.project.Project;
55
import org.netbeans.api.project.ProjectUtils;
55
import org.netbeans.api.project.ProjectUtils;
56
import org.netbeans.api.project.ant.AntArtifact;
56
import org.netbeans.api.project.ant.AntArtifact;
Lines 71-77 import org.openide.util.NbBundle; Link Here
71
 */
71
 */
72
public class CustomizerGeneral extends JPanel implements CustomizerPanel, ActionListener {
72
public class CustomizerGeneral extends JPanel implements CustomizerPanel, ActionListener {
73
    
73
    
74
    private ProjectProperties props;
74
    private MultiRootProjectProperties props;
75
    
75
    
76
    /** Creates new form CustomizerCompile */
76
    /** Creates new form CustomizerCompile */
77
    public CustomizerGeneral() {
77
    public CustomizerGeneral() {
Lines 79-91 public class CustomizerGeneral extends J Link Here
79
        initAccessibility();
79
        initAccessibility();
80
    }
80
    }
81
    
81
    
82
    public void initValues(ProjectProperties props, String configuration) {
82
    public void initValues(MultiRootProjectProperties props, String configuration) {
83
        this.props = props;
83
        this.props = props;
84
        final VisualPropertySupport vps = VisualPropertySupport.getDefault(props);
84
        final VisualPropertySupport vps = VisualPropertySupport.getDefault(props);
85
        
85
        
86
        vps.register(jTextFieldDisplayName, J2MEProjectProperties.J2ME_PROJECT_NAME);
86
        vps.register(jTextFieldDisplayName, J2MEProjectProperties.J2ME_PROJECT_NAME);
87
        vps.register(rebuildCheckBox, DefaultPropertiesDescriptor.NO_DEPENDENCIES);
87
        vps.register(rebuildCheckBox, DefaultPropertiesDescriptor.NO_DEPENDENCIES);
88
        vps.register(jTextFieldSrcRoot, DefaultPropertiesDescriptor.SRC_DIR);
89
        vps.register(jTextFieldAppVersion, DefaultPropertiesDescriptor.APP_VERSION_NUMBER);
88
        vps.register(jTextFieldAppVersion, DefaultPropertiesDescriptor.APP_VERSION_NUMBER);
90
        vps.register(jSpinnerCounter, DefaultPropertiesDescriptor.APP_VERSION_COUNTER);
89
        vps.register(jSpinnerCounter, DefaultPropertiesDescriptor.APP_VERSION_COUNTER);
91
        vps.register(jCheckBoxAutoIncrement, DefaultPropertiesDescriptor.APP_VERSION_AUTOINCREMENT);
90
        vps.register(jCheckBoxAutoIncrement, DefaultPropertiesDescriptor.APP_VERSION_AUTOINCREMENT);
Lines 190-197 public class CustomizerGeneral extends J Link Here
190
        jTextFieldDisplayName = new javax.swing.JTextField();
189
        jTextFieldDisplayName = new javax.swing.JTextField();
191
        jLabel3 = new javax.swing.JLabel();
190
        jLabel3 = new javax.swing.JLabel();
192
        jTextFieldProjectFolder = new javax.swing.JTextField();
191
        jTextFieldProjectFolder = new javax.swing.JTextField();
193
        jLabel4 = new javax.swing.JLabel();
194
        jTextFieldSrcRoot = new javax.swing.JTextField();
195
        jLabel5 = new javax.swing.JLabel();
192
        jLabel5 = new javax.swing.JLabel();
196
        jTextFieldAppVersion = new javax.swing.JTextField();
193
        jTextFieldAppVersion = new javax.swing.JTextField();
197
        jLabel6 = new javax.swing.JLabel();
194
        jLabel6 = new javax.swing.JLabel();
Lines 247-271 public class CustomizerGeneral extends J Link Here
247
        jTextFieldProjectFolder.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSN_CustGeneral_PrjFolder")); // NOI18N
244
        jTextFieldProjectFolder.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSN_CustGeneral_PrjFolder")); // NOI18N
248
        jTextFieldProjectFolder.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerGeneral.class, "ACSD_CustGeneral_PrjFolder")); // NOI18N
245
        jTextFieldProjectFolder.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerGeneral.class, "ACSD_CustGeneral_PrjFolder")); // NOI18N
249
246
250
        jLabel4.setLabelFor(jTextFieldSrcRoot);
251
        org.openide.awt.Mnemonics.setLocalizedText(jLabel4, NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_SrcDir")); // NOI18N
252
        gridBagConstraints = new java.awt.GridBagConstraints();
253
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
254
        gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 12);
255
        add(jLabel4, gridBagConstraints);
256
        jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSN_CustomizeGeneral_SrcDir")); // NOI18N
257
        jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSD_CustomizeGeneral_SrcDir")); // NOI18N
258
259
        jTextFieldSrcRoot.setEditable(false);
260
        gridBagConstraints = new java.awt.GridBagConstraints();
261
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
262
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
263
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
264
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 0);
265
        add(jTextFieldSrcRoot, gridBagConstraints);
266
        jTextFieldSrcRoot.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSN_CustGeneral_PrjSources")); // NOI18N
267
        jTextFieldSrcRoot.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerGeneral.class, "ACSD_CustGeneral_PrjSources")); // NOI18N
268
269
        jLabel5.setLabelFor(jTextFieldAppVersion);
247
        jLabel5.setLabelFor(jTextFieldAppVersion);
270
        org.openide.awt.Mnemonics.setLocalizedText(jLabel5, NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustMain_AppVersion")); // NOI18N
248
        org.openide.awt.Mnemonics.setLocalizedText(jLabel5, NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustMain_AppVersion")); // NOI18N
271
        gridBagConstraints = new java.awt.GridBagConstraints();
249
        gridBagConstraints = new java.awt.GridBagConstraints();
Lines 309-315 public class CustomizerGeneral extends J Link Here
309
        jSpinnerCounter.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSD_AppVersionCounter")); // NOI18N
287
        jSpinnerCounter.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSD_AppVersionCounter")); // NOI18N
310
288
311
        org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxAutoIncrement, NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustMain_AutoIncrement")); // NOI18N
289
        org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxAutoIncrement, NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustMain_AutoIncrement")); // NOI18N
312
        jCheckBoxAutoIncrement.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
313
        jCheckBoxAutoIncrement.setMargin(new java.awt.Insets(0, 0, 0, 0));
290
        jCheckBoxAutoIncrement.setMargin(new java.awt.Insets(0, 0, 0, 0));
314
        gridBagConstraints = new java.awt.GridBagConstraints();
291
        gridBagConstraints = new java.awt.GridBagConstraints();
315
        gridBagConstraints.gridx = 0;
292
        gridBagConstraints.gridx = 0;
Lines 323-329 public class CustomizerGeneral extends J Link Here
323
        jCheckBoxAutoIncrement.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSD_CustMain_AutoIncrement")); // NOI18N
300
        jCheckBoxAutoIncrement.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "ACSD_CustMain_AutoIncrement")); // NOI18N
324
301
325
        org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxUsePreprocessor, NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_UsePreprocessor")); // NOI18N
302
        org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxUsePreprocessor, NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_UsePreprocessor")); // NOI18N
326
        jCheckBoxUsePreprocessor.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
327
        jCheckBoxUsePreprocessor.setMargin(new java.awt.Insets(0, 0, 0, 0));
303
        jCheckBoxUsePreprocessor.setMargin(new java.awt.Insets(0, 0, 0, 0));
328
        gridBagConstraints = new java.awt.GridBagConstraints();
304
        gridBagConstraints = new java.awt.GridBagConstraints();
329
        gridBagConstraints.gridx = 0;
305
        gridBagConstraints.gridx = 0;
Lines 386-392 public class CustomizerGeneral extends J Link Here
386
    private javax.swing.JLabel jLabel1;
362
    private javax.swing.JLabel jLabel1;
387
    private javax.swing.JLabel jLabel2;
363
    private javax.swing.JLabel jLabel2;
388
    private javax.swing.JLabel jLabel3;
364
    private javax.swing.JLabel jLabel3;
389
    private javax.swing.JLabel jLabel4;
390
    private javax.swing.JLabel jLabel5;
365
    private javax.swing.JLabel jLabel5;
391
    private javax.swing.JLabel jLabel6;
366
    private javax.swing.JLabel jLabel6;
392
    private javax.swing.JScrollPane jScrollPane1;
367
    private javax.swing.JScrollPane jScrollPane1;
Lines 394-400 public class CustomizerGeneral extends J Link Here
394
    private javax.swing.JTextField jTextFieldAppVersion;
369
    private javax.swing.JTextField jTextFieldAppVersion;
395
    private javax.swing.JTextField jTextFieldDisplayName;
370
    private javax.swing.JTextField jTextFieldDisplayName;
396
    private javax.swing.JTextField jTextFieldProjectFolder;
371
    private javax.swing.JTextField jTextFieldProjectFolder;
397
    private javax.swing.JTextField jTextFieldSrcRoot;
398
    private javax.swing.JList projectList;
372
    private javax.swing.JList projectList;
399
    private javax.swing.JCheckBox rebuildCheckBox;
373
    private javax.swing.JCheckBox rebuildCheckBox;
400
    // End of variables declaration//GEN-END:variables
374
    // End of variables declaration//GEN-END:variables
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerJad.form (-1 / +3 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
5
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
7
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
6
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
7
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
9
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerJad.java (-3 / +2 lines)
Lines 49-55 import java.awt.Dialog; Link Here
49
import java.awt.Dialog;
49
import java.awt.Dialog;
50
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionListener;
51
import java.awt.event.ActionListener;
52
import java.awt.event.ActionListener;
53
import java.awt.event.MouseAdapter;
52
import java.awt.event.MouseAdapter;
54
import java.awt.event.MouseEvent;
53
import java.awt.event.MouseEvent;
55
import java.util.ArrayList;
54
import java.util.ArrayList;
Lines 61-67 import javax.swing.ListSelectionModel; Link Here
61
import javax.swing.ListSelectionModel;
60
import javax.swing.ListSelectionModel;
62
import javax.swing.event.ListSelectionListener;
61
import javax.swing.event.ListSelectionListener;
63
import javax.swing.table.AbstractTableModel;
62
import javax.swing.table.AbstractTableModel;
64
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
63
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
65
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
64
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
66
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
65
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
67
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
66
import org.netbeans.spi.mobility.project.ui.customizer.VisualPropertyGroup;
Lines 300-306 public class CustomizerJad extends JPane Link Here
300
            table.getSelectionModel().setSelectionInterval(max - 1, max - 1);
299
            table.getSelectionModel().setSelectionInterval(max - 1, max - 1);
301
    }//GEN-LAST:event_bRemoveActionPerformed
300
    }//GEN-LAST:event_bRemoveActionPerformed
302
    
301
    
303
    public void initValues(ProjectProperties props, String configuration) {
302
    public void initValues(MultiRootProjectProperties props, String configuration) {
304
        this.configuration = configuration;
303
        this.configuration = configuration;
305
        configurationProfileValue = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.profile", false));
304
        configurationProfileValue = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.profile", false));
306
        defaultProfileValue = (String) props.get("platform.profile"); //NOI18N
305
        defaultProfileValue = (String) props.get("platform.profile"); //NOI18N
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerJar.java (-1 / +2 lines)
Lines 41-46 Link Here
41
41
42
package org.netbeans.modules.mobility.project.ui.customizer;
42
package org.netbeans.modules.mobility.project.ui.customizer;
43
import javax.swing.JPanel;
43
import javax.swing.JPanel;
44
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
44
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
45
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
45
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
46
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
46
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
47
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 67-73 public class CustomizerJar extends JPane Link Here
67
    }
68
    }
68
    
69
    
69
    
70
    
70
    public void initValues(ProjectProperties props, String configuration) {
71
    public void initValues(MultiRootProjectProperties props, String configuration) {
71
        vps = VisualPropertySupport.getDefault(props);
72
        vps = VisualPropertySupport.getDefault(props);
72
        vps.register(defaultCheck, configuration, this);
73
        vps.register(defaultCheck, configuration, this);
73
    }
74
    }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerJavadoc.java (-1 / +2 lines)
Lines 41-46 Link Here
41
41
42
package org.netbeans.modules.mobility.project.ui.customizer;
42
package org.netbeans.modules.mobility.project.ui.customizer;
43
import javax.swing.JPanel;
43
import javax.swing.JPanel;
44
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
44
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
45
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
45
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
46
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
46
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
47
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 78-84 public class CustomizerJavadoc extends J Link Here
78
    }
79
    }
79
    
80
    
80
    
81
    
81
    public void initValues(ProjectProperties props, String configuration) {
82
    public void initValues(MultiRootProjectProperties props, String configuration) {
82
        this.vps = VisualPropertySupport.getDefault(props);
83
        this.vps = VisualPropertySupport.getDefault(props);
83
        vps.register(defaultCheck, configuration, this);
84
        vps.register(defaultCheck, configuration, this);
84
    }
85
    }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerLibraries.java (-3 / +3 lines)
Lines 52-58 import java.util.Set; Link Here
52
import java.util.Set;
52
import java.util.Set;
53
import javax.swing.JPanel;
53
import javax.swing.JPanel;
54
import javax.swing.UIManager;
54
import javax.swing.UIManager;
55
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
55
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
56
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
56
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
57
import org.netbeans.modules.mobility.project.ui.customizer.VisualClassPathItem;
57
import org.netbeans.modules.mobility.project.ui.customizer.VisualClassPathItem;
58
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
58
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
Lines 72-78 public class CustomizerLibraries extends Link Here
72
    private VisualPropertySupport vps;
72
    private VisualPropertySupport vps;
73
    final private VisualClasspathSupport vcs;
73
    final private VisualClasspathSupport vcs;
74
    private String configuration;
74
    private String configuration;
75
    private ProjectProperties props;
75
    private MultiRootProjectProperties props;
76
    
76
    
77
    /** Creates new form CustomizerConfigs */
77
    /** Creates new form CustomizerConfigs */
78
    public CustomizerLibraries() {
78
    public CustomizerLibraries() {
Lines 231-237 public class CustomizerLibraries extends Link Here
231
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerLibraries.class, "ACSD_CustLibs"));
231
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerLibraries.class, "ACSD_CustLibs"));
232
    }
232
    }
233
    
233
    
234
    public void initValues(ProjectProperties props, String configuration) {
234
    public void initValues(MultiRootProjectProperties props, String configuration) {
235
        this.vps = VisualPropertySupport.getDefault(props);
235
        this.vps = VisualPropertySupport.getDefault(props);
236
        this.props = props;
236
        this.props = props;
237
        this.configuration = configuration;
237
        this.configuration = configuration;
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerMIDP.java (-2 / +2 lines)
Lines 61-67 import org.netbeans.api.java.platform.Pl Link Here
61
import org.netbeans.api.java.platform.PlatformsCustomizer;
61
import org.netbeans.api.java.platform.PlatformsCustomizer;
62
import org.netbeans.api.java.platform.Profile;
62
import org.netbeans.api.java.platform.Profile;
63
import org.netbeans.api.java.platform.Specification;
63
import org.netbeans.api.java.platform.Specification;
64
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
64
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
65
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
65
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
66
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
66
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
67
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
67
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
Lines 226-232 final public class CustomizerMIDP extend Link Here
226
    }
226
    }
227
    
227
    
228
    
228
    
229
    public void initValues(ProjectProperties props, String configuration) {
229
    public void initValues(MultiRootProjectProperties props, String configuration) {
230
        this.props = props;
230
        this.props = props;
231
        this.vps = VisualPropertySupport.getDefault(props);
231
        this.vps = VisualPropertySupport.getDefault(props);
232
        this.configuration = configuration;
232
        this.configuration = configuration;
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerMIDlets.java (-1 / +2 lines)
Lines 56-61 import javax.swing.event.*; Link Here
56
import javax.swing.event.*;
56
import javax.swing.event.*;
57
import javax.swing.table.AbstractTableModel;
57
import javax.swing.table.AbstractTableModel;
58
import javax.swing.table.DefaultTableCellRenderer;
58
import javax.swing.table.DefaultTableCellRenderer;
59
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
59
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
60
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
60
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
61
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
61
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
62
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 318-324 public class CustomizerMIDlets extends J Link Here
318
        }
319
        }
319
    }//GEN-LAST:event_addButtonActionPerformed
320
    }//GEN-LAST:event_addButtonActionPerformed
320
    
321
    
321
    public void initValues(ProjectProperties props, String configuration) {
322
    public void initValues(MultiRootProjectProperties props, String configuration) {
322
        this.vps = VisualPropertySupport.getDefault(props);
323
        this.vps = VisualPropertySupport.getDefault(props);
323
        classes = icons = null;
324
        classes = icons = null;
324
        final MIDletScanner scanner = MIDletScanner.getDefault(props);
325
        final MIDletScanner scanner = MIDletScanner.getDefault(props);
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerObfuscate.java (-1 / +2 lines)
Lines 50-55 import javax.swing.*; Link Here
50
import javax.swing.*;
50
import javax.swing.*;
51
import javax.swing.event.ChangeEvent;
51
import javax.swing.event.ChangeEvent;
52
import javax.swing.event.ChangeListener;
52
import javax.swing.event.ChangeListener;
53
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
53
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
54
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
54
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
55
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
55
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
56
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 194-200 public class CustomizerObfuscate extends Link Here
194
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerObfuscate.class, "ACSD_CustomizerObfuscate"));
195
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerObfuscate.class, "ACSD_CustomizerObfuscate"));
195
    }
196
    }
196
    
197
    
197
    public void initValues(ProjectProperties props, String configuration) {
198
    public void initValues(MultiRootProjectProperties props, String configuration) {
198
        this.vps = VisualPropertySupport.getDefault(props);
199
        this.vps = VisualPropertySupport.getDefault(props);
199
        vps.register(defaultCheck, configuration, this);
200
        vps.register(defaultCheck, configuration, this);
200
    }
201
    }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerPermissions.java (-2 / +2 lines)
Lines 60-66 import javax.swing.event.ListSelectionLi Link Here
60
import javax.swing.event.ListSelectionListener;
60
import javax.swing.event.ListSelectionListener;
61
import javax.swing.table.AbstractTableModel;
61
import javax.swing.table.AbstractTableModel;
62
import javax.swing.table.TableColumn;
62
import javax.swing.table.TableColumn;
63
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
63
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
64
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
64
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
65
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
65
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
66
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
66
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
Lines 227-233 public class CustomizerPermissions exten Link Here
227
            table.getSelectionModel().setSelectionInterval(max - 1, max - 1);
227
            table.getSelectionModel().setSelectionInterval(max - 1, max - 1);
228
    }//GEN-LAST:event_bRemoveActionPerformed
228
    }//GEN-LAST:event_bRemoveActionPerformed
229
    
229
    
230
    public void initValues(ProjectProperties props, String configuration) {
230
    public void initValues(MultiRootProjectProperties props, String configuration) {
231
        this.configuration = configuration;
231
        this.configuration = configuration;
232
        configurationProfileValue = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.profile", false)); // NOI18N
232
        configurationProfileValue = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.profile", false)); // NOI18N
233
        defaultProfileValue = (String) props.get("platform.profile"); //NOI18N
233
        defaultProfileValue = (String) props.get("platform.profile"); //NOI18N
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerPlatform.java (-3 / +3 lines)
Lines 52-58 import javax.swing.JList; Link Here
52
import javax.swing.JList;
52
import javax.swing.JList;
53
import javax.swing.JPanel;
53
import javax.swing.JPanel;
54
import javax.swing.ListCellRenderer;
54
import javax.swing.ListCellRenderer;
55
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
55
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
56
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
56
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
57
import org.netbeans.spi.mobility.project.ui.customizer.ComposedCustomizerPanel;
57
import org.netbeans.spi.mobility.project.ui.customizer.ComposedCustomizerPanel;
58
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
58
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 73-79 public class CustomizerPlatform extends Link Here
73
public class CustomizerPlatform extends JPanel implements ComposedCustomizerPanel, VisualPropertyGroup, ActionListener {
73
public class CustomizerPlatform extends JPanel implements ComposedCustomizerPanel, VisualPropertyGroup, ActionListener {
74
    
74
    
75
    private final ArrayList<TypeComboElement> typeElements = new ArrayList();
75
    private final ArrayList<TypeComboElement> typeElements = new ArrayList();
76
    private ProjectProperties props;
76
    private MultiRootProjectProperties props;
77
    private boolean useDefault;
77
    private boolean useDefault;
78
    
78
    
79
    private HelpCtxCallback callback;
79
    private HelpCtxCallback callback;
Lines 163-169 public class CustomizerPlatform extends Link Here
163
        add(jPanel1, gridBagConstraints);
163
        add(jPanel1, gridBagConstraints);
164
    }// </editor-fold>//GEN-END:initComponents
164
    }// </editor-fold>//GEN-END:initComponents
165
165
166
    public void initValues(ProjectProperties props, String configuration) {
166
    public void initValues(MultiRootProjectProperties props, String configuration) {
167
        this.props = props;
167
        this.props = props;
168
        for (int i=0; i<typeElements.size(); i++) {
168
        for (int i=0; i<typeElements.size(); i++) {
169
            JComponent c = typeElements.get(i).getCustomizer();
169
            JComponent c = typeElements.get(i).getCustomizer();
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerPushReg.java (-2 / +2 lines)
Lines 61-67 import javax.swing.table.AbstractTableMo Link Here
61
import javax.swing.table.AbstractTableModel;
61
import javax.swing.table.AbstractTableModel;
62
import javax.swing.table.TableColumn;
62
import javax.swing.table.TableColumn;
63
import javax.swing.table.DefaultTableCellRenderer;
63
import javax.swing.table.DefaultTableCellRenderer;
64
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
64
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
65
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
65
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
66
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
66
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
67
67
Lines 330-336 public class CustomizerPushReg extends J Link Here
330
            table.getSelectionModel().setSelectionInterval(max - 1, max - 1);
330
            table.getSelectionModel().setSelectionInterval(max - 1, max - 1);
331
    }//GEN-LAST:event_bRemoveActionPerformed
331
    }//GEN-LAST:event_bRemoveActionPerformed
332
    
332
    
333
    public void initValues(ProjectProperties props, String configuration) {
333
    public void initValues(MultiRootProjectProperties props, String configuration) {
334
        this.configuration = configuration;
334
        this.configuration = configuration;
335
        configurationProfileValue = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.profile", false)); //NOI18N
335
        configurationProfileValue = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.profile", false)); //NOI18N
336
        defaultProfileValue = (String) props.get("platform.profile"); //NOI18N
336
        defaultProfileValue = (String) props.get("platform.profile"); //NOI18N
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerRun.java (-2 / +2 lines)
Lines 52-58 import org.netbeans.api.java.platform.Ja Link Here
52
import org.netbeans.api.java.platform.JavaPlatform;
52
import org.netbeans.api.java.platform.JavaPlatform;
53
import org.netbeans.api.java.platform.JavaPlatformManager;
53
import org.netbeans.api.java.platform.JavaPlatformManager;
54
import org.netbeans.api.java.platform.Specification;
54
import org.netbeans.api.java.platform.Specification;
55
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
55
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
56
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
56
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
57
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
57
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
58
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
58
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 191-197 public class CustomizerRun extends JPane Link Here
191
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerRun.class, "ACSD_CustRun"));
191
        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerRun.class, "ACSD_CustRun"));
192
    }
192
    }
193
    
193
    
194
    public void initValues(ProjectProperties props, String configuration) {
194
    public void initValues(MultiRootProjectProperties props, String configuration) {
195
        this.vps = VisualPropertySupport.getDefault(props);
195
        this.vps = VisualPropertySupport.getDefault(props);
196
        String activePlatform = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.active", false));//NOI18N
196
        String activePlatform = (String) props.get(VisualPropertySupport.translatePropertyName(configuration, "platform.active", false));//NOI18N
197
        if (activePlatform == null)
197
        if (activePlatform == null)
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/CustomizerSign.java (-2 / +2 lines)
Lines 64-70 import java.awt.event.ItemEvent; Link Here
64
import java.awt.event.ItemEvent;
64
import java.awt.event.ItemEvent;
65
import java.awt.*;
65
import java.awt.*;
66
import java.util.List;
66
import java.util.List;
67
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
67
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
68
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
68
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
69
69
70
/**
70
/**
Lines 299-305 final public class CustomizerSign extend Link Here
299
        loadKeystores();
299
        loadKeystores();
300
    }//GEN-LAST:event_bOpenSecurityManagerActionPerformed
300
    }//GEN-LAST:event_bOpenSecurityManagerActionPerformed
301
    
301
    
302
    public void initValues(ProjectProperties props, String configuration) {
302
    public void initValues(MultiRootProjectProperties props, String configuration) {
303
        this.props = props;
303
        this.props = props;
304
        this.configuration = configuration;
304
        this.configuration = configuration;
305
        vps = VisualPropertySupport.getDefault(props);
305
        vps = VisualPropertySupport.getDefault(props);
(-)6b487c15857b (+409 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
7
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
9
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
10
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
11
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
12
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
13
    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-70,0,0,2,83"/>
14
  </AuxValues>
15
16
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
17
  <SubComponents>
18
    <Component class="javax.swing.JLabel" name="jLabel1">
19
      <Properties>
20
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
21
          <ComponentRef name="projectLocation"/>
22
        </Property>
23
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
24
          <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_ProjectFolder" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
25
        </Property>
26
      </Properties>
27
      <Constraints>
28
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
29
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
30
        </Constraint>
31
      </Constraints>
32
    </Component>
33
    <Component class="javax.swing.JTextField" name="projectLocation">
34
      <Properties>
35
        <Property name="editable" type="boolean" value="false"/>
36
      </Properties>
37
      <AccessibilityProperties>
38
        <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
39
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_projectLocation" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
40
        </Property>
41
      </AccessibilityProperties>
42
      <Constraints>
43
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
44
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
45
        </Constraint>
46
      </Constraints>
47
    </Component>
48
    <Container class="javax.swing.JPanel" name="sourceRootsPanel">
49
      <Constraints>
50
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
51
          <GridBagConstraints gridX="0" gridY="1" gridWidth="0" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.45"/>
52
        </Constraint>
53
      </Constraints>
54
55
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
56
      <SubComponents>
57
        <Component class="javax.swing.JLabel" name="jLabel2">
58
          <Properties>
59
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
60
              <ComponentRef name="sourceRoots"/>
61
            </Property>
62
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
63
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_SourceRoots" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
64
            </Property>
65
          </Properties>
66
          <Constraints>
67
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
68
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
69
            </Constraint>
70
          </Constraints>
71
        </Component>
72
        <Container class="javax.swing.JScrollPane" name="jScrollPane1">
73
          <Properties>
74
            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
75
              <Dimension value="[450, 150]"/>
76
            </Property>
77
          </Properties>
78
          <Constraints>
79
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
80
              <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="18" weightX="1.0" weightY="0.5"/>
81
            </Constraint>
82
          </Constraints>
83
84
          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
85
          <SubComponents>
86
            <Component class="javax.swing.JTable" name="sourceRoots">
87
              <Properties>
88
                <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
89
                  <Table columnCount="2" rowCount="4">
90
                    <Column editable="false" title="Package Folder" type="java.lang.Object"/>
91
                    <Column editable="false" title="Label" type="java.lang.String"/>
92
                  </Table>
93
                </Property>
94
              </Properties>
95
              <AccessibilityProperties>
96
                <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
97
                  <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_sourceRoots" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
98
                </Property>
99
              </AccessibilityProperties>
100
              <AuxValues>
101
                <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ResizableRowHeightTable()"/>
102
              </AuxValues>
103
            </Component>
104
          </SubComponents>
105
        </Container>
106
        <Component class="javax.swing.JButton" name="addSourceRoot">
107
          <Properties>
108
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
109
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_AddSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
110
            </Property>
111
          </Properties>
112
          <AccessibilityProperties>
113
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
114
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_addSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
115
            </Property>
116
          </AccessibilityProperties>
117
          <Constraints>
118
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
119
              <GridBagConstraints gridX="1" gridY="1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
120
            </Constraint>
121
          </Constraints>
122
        </Component>
123
        <Component class="javax.swing.JButton" name="removeSourceRoot">
124
          <Properties>
125
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
126
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_RemoveSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
127
            </Property>
128
          </Properties>
129
          <AccessibilityProperties>
130
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
131
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_removeSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
132
            </Property>
133
          </AccessibilityProperties>
134
          <Constraints>
135
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
136
              <GridBagConstraints gridX="1" gridY="2" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
137
            </Constraint>
138
          </Constraints>
139
        </Component>
140
        <Component class="javax.swing.JButton" name="upSourceRoot">
141
          <Properties>
142
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
143
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_UpSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
144
            </Property>
145
          </Properties>
146
          <AccessibilityProperties>
147
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
148
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_upSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
149
            </Property>
150
          </AccessibilityProperties>
151
          <Constraints>
152
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
153
              <GridBagConstraints gridX="1" gridY="3" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
154
            </Constraint>
155
          </Constraints>
156
        </Component>
157
        <Component class="javax.swing.JButton" name="downSourceRoot">
158
          <Properties>
159
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
160
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_DownSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
161
            </Property>
162
          </Properties>
163
          <AccessibilityProperties>
164
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
165
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_downSourceRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
166
            </Property>
167
          </AccessibilityProperties>
168
          <Constraints>
169
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
170
              <GridBagConstraints gridX="1" gridY="4" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="6" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
171
            </Constraint>
172
          </Constraints>
173
        </Component>
174
      </SubComponents>
175
    </Container>
176
    <Container class="javax.swing.JPanel" name="testRootsPanel">
177
      <Constraints>
178
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179
          <GridBagConstraints gridX="0" gridY="2" gridWidth="0" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.45"/>
180
        </Constraint>
181
      </Constraints>
182
183
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
184
      <SubComponents>
185
        <Component class="javax.swing.JLabel" name="jLabel3">
186
          <Properties>
187
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
188
              <ComponentRef name="testRoots"/>
189
            </Property>
190
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
191
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_TestRoots" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
192
            </Property>
193
          </Properties>
194
          <Constraints>
195
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
196
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="18" weightX="1.0" weightY="0.0"/>
197
            </Constraint>
198
          </Constraints>
199
        </Component>
200
        <Container class="javax.swing.JScrollPane" name="jScrollPane2">
201
          <Properties>
202
            <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
203
              <Dimension value="[450, 150]"/>
204
            </Property>
205
          </Properties>
206
          <Constraints>
207
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
208
              <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="1.0" weightY="0.5"/>
209
            </Constraint>
210
          </Constraints>
211
212
          <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
213
          <SubComponents>
214
            <Component class="javax.swing.JTable" name="testRoots">
215
              <Properties>
216
                <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
217
                  <Table columnCount="2" rowCount="4">
218
                    <Column editable="false" title="Package Folder" type="java.lang.Object"/>
219
                    <Column editable="false" title="Label" type="java.lang.String"/>
220
                  </Table>
221
                </Property>
222
              </Properties>
223
              <AccessibilityProperties>
224
                <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
225
                  <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_testRoots" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
226
                </Property>
227
              </AccessibilityProperties>
228
              <AuxValues>
229
                <AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new ResizableRowHeightTable()"/>
230
              </AuxValues>
231
            </Component>
232
          </SubComponents>
233
        </Container>
234
        <Component class="javax.swing.JButton" name="addTestRoot">
235
          <Properties>
236
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
237
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_AddTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
238
            </Property>
239
          </Properties>
240
          <AccessibilityProperties>
241
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
242
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_addTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
243
            </Property>
244
          </AccessibilityProperties>
245
          <Constraints>
246
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
247
              <GridBagConstraints gridX="1" gridY="1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
248
            </Constraint>
249
          </Constraints>
250
        </Component>
251
        <Component class="javax.swing.JButton" name="removeTestRoot">
252
          <Properties>
253
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
254
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_RemoveTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
255
            </Property>
256
          </Properties>
257
          <AccessibilityProperties>
258
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
259
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_removeTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
260
            </Property>
261
          </AccessibilityProperties>
262
          <Constraints>
263
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
264
              <GridBagConstraints gridX="1" gridY="2" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="12" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
265
            </Constraint>
266
          </Constraints>
267
        </Component>
268
        <Component class="javax.swing.JButton" name="upTestRoot">
269
          <Properties>
270
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
271
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_UpTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
272
            </Property>
273
          </Properties>
274
          <AccessibilityProperties>
275
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
276
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_upTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
277
            </Property>
278
          </AccessibilityProperties>
279
          <Constraints>
280
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
281
              <GridBagConstraints gridX="1" gridY="3" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
282
            </Constraint>
283
          </Constraints>
284
        </Component>
285
        <Component class="javax.swing.JButton" name="downTestRoot">
286
          <Properties>
287
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
288
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="CTL_DownTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
289
            </Property>
290
          </Properties>
291
          <AccessibilityProperties>
292
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
293
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_downTestRoot" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
294
            </Property>
295
          </AccessibilityProperties>
296
          <Constraints>
297
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
298
              <GridBagConstraints gridX="1" gridY="4" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
299
            </Constraint>
300
          </Constraints>
301
        </Component>
302
      </SubComponents>
303
    </Container>
304
    <Container class="javax.swing.JPanel" name="jPanel1">
305
      <Constraints>
306
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
307
          <GridBagConstraints gridX="0" gridY="3" gridWidth="0" gridHeight="0" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
308
        </Constraint>
309
      </Constraints>
310
311
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
312
      <SubComponents>
313
        <Component class="javax.swing.JLabel" name="jLabel4">
314
          <Properties>
315
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
316
              <ComponentRef name="sourceLevel"/>
317
            </Property>
318
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
319
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="TXT_SourceLevel" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
320
            </Property>
321
          </Properties>
322
          <AuxValues>
323
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
324
          </AuxValues>
325
          <Constraints>
326
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
327
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="17" weightX="0.0" weightY="0.0"/>
328
            </Constraint>
329
          </Constraints>
330
        </Component>
331
        <Component class="javax.swing.JComboBox" name="sourceLevel">
332
          <Properties>
333
            <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
334
              <StringArray count="2">
335
                <StringItem index="0" value="1.4"/>
336
                <StringItem index="1" value="1.5"/>
337
              </StringArray>
338
            </Property>
339
            <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
340
              <Connection code="this.sourceLevel.getPreferredSize()" type="code"/>
341
            </Property>
342
          </Properties>
343
          <AccessibilityProperties>
344
            <Property name="AccessibleContext.accessibleName" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
345
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AN_SourceLevel" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
346
            </Property>
347
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
348
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_SourceLevel" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
349
            </Property>
350
          </AccessibilityProperties>
351
          <Constraints>
352
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
353
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="1.0" weightY="0.0"/>
354
            </Constraint>
355
          </Constraints>
356
        </Component>
357
        <Component class="javax.swing.JLabel" name="jLabel5">
358
          <Properties>
359
            <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
360
              <ComponentRef name="encoding"/>
361
            </Property>
362
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
363
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties" key="TXT_Encoding" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
364
            </Property>
365
          </Properties>
366
          <AccessibilityProperties>
367
            <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
368
              <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="AD_CustomizerSources_Encoding" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
369
            </Property>
370
          </AccessibilityProperties>
371
          <AuxValues>
372
            <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
373
          </AuxValues>
374
          <Constraints>
375
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
376
              <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="0" fill="2" ipadX="0" ipadY="0" insetsTop="8" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="17" weightX="0.0" weightY="0.0"/>
377
            </Constraint>
378
          </Constraints>
379
        </Component>
380
        <Component class="javax.swing.JComboBox" name="encoding">
381
          <Properties>
382
            <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
383
              <StringArray count="4">
384
                <StringItem index="0" value="Item 1"/>
385
                <StringItem index="1" value="Item 2"/>
386
                <StringItem index="2" value="Item 3"/>
387
                <StringItem index="3" value="Item 4"/>
388
              </StringArray>
389
            </Property>
390
          </Properties>
391
          <Constraints>
392
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
393
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="0" fill="2" ipadX="0" ipadY="0" insetsTop="8" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
394
            </Constraint>
395
          </Constraints>
396
        </Component>
397
        <Container class="javax.swing.JPanel" name="jPanel2">
398
          <Constraints>
399
            <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
400
              <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
401
            </Constraint>
402
          </Constraints>
403
404
          <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
405
        </Container>
406
      </SubComponents>
407
    </Container>
408
  </SubComponents>
409
</Form>
(-)6b487c15857b (+732 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Deve1loper of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.mobility.project.ui.customizer;
43
44
import java.awt.Component;
45
import java.awt.Font;
46
import java.awt.Graphics;
47
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionListener;
49
import java.awt.event.ComponentAdapter;
50
import java.awt.event.ComponentEvent;
51
import java.io.File;
52
import java.nio.charset.Charset;
53
import java.nio.charset.CharsetDecoder;
54
import java.nio.charset.CharsetEncoder;
55
import java.nio.charset.IllegalCharsetNameException;
56
import java.util.logging.Logger;
57
import javax.swing.DefaultCellEditor;
58
import javax.swing.DefaultComboBoxModel;
59
import javax.swing.JLabel;
60
import javax.swing.JList;
61
import javax.swing.JTable;
62
import javax.swing.JTextField;
63
import javax.swing.ListCellRenderer;
64
import javax.swing.ListSelectionModel;
65
import javax.swing.UIManager;
66
import javax.swing.event.ListDataEvent;
67
import javax.swing.event.ListDataListener;
68
import javax.swing.plaf.UIResource;
69
import javax.swing.table.TableColumn;
70
import javax.swing.table.TableModel;
71
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
72
import org.netbeans.modules.mobility.project.J2MEProject;
73
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
74
import org.openide.DialogDisplayer;
75
import org.openide.NotifyDescriptor;
76
import org.openide.filesystems.FileObject;
77
import org.openide.filesystems.FileUtil;
78
import org.openide.util.HelpCtx;
79
import org.openide.util.NbBundle;
80
81
/**
82
 * Customizer panel "Sources": source roots, level, includes/excludes.
83
 * @author  Tomas Zezula
84
 */
85
public class CustomizerSources extends javax.swing.JPanel implements HelpCtx.Provider, CustomizerPanel {
86
    //Copied from J2SEProject
87
    private String originalEncoding;
88
    private boolean notified;
89
90
    private J2MEProjectProperties uiProperties;
91
92
    public CustomizerSources() {
93
        initComponents();
94
    }
95
96
    public void initValues(MultiRootProjectProperties props, String configuration) {
97
        this.uiProperties = (J2MEProjectProperties) props;
98
        jScrollPane1.getViewport().setBackground( sourceRoots.getBackground() );
99
        jScrollPane2.getViewport().setBackground( testRoots.getBackground() );
100
        
101
        sourceRoots.setModel( uiProperties.SOURCE_ROOTS_MODEL );
102
        testRoots.setModel( uiProperties.TEST_ROOTS_MODEL );
103
        sourceRoots.getTableHeader().setReorderingAllowed(false);
104
        testRoots.getTableHeader().setReorderingAllowed(false);
105
        J2MEProject project = ((J2MEProjectProperties) uiProperties).getProject();
106
        
107
        FileObject projectFolder = project.getProjectDirectory();
108
        File pf = FileUtil.toFile( projectFolder );
109
        this.projectLocation.setText( pf == null ? "" : pf.getPath() ); // NOI18N
110
        
111
        
112
        J2MESourceRootsUi.EditMediator emSR = J2MESourceRootsUi.registerEditMediator(
113
            project,
114
            project.getSourceRoots(),
115
            sourceRoots,
116
            addSourceRoot,
117
            removeSourceRoot, 
118
            upSourceRoot, 
119
            downSourceRoot,
120
            new LabelCellEditor(sourceRoots, testRoots));
121
        
122
        J2MESourceRootsUi.EditMediator emTSR = J2MESourceRootsUi.registerEditMediator(
123
            project,
124
            project.getTestSourceRoots(),
125
            testRoots,
126
            addTestRoot,
127
            removeTestRoot, 
128
            upTestRoot, 
129
            downTestRoot,
130
            new LabelCellEditor(sourceRoots, testRoots));
131
        
132
        emSR.setRelatedEditMediator( emTSR );
133
        emTSR.setRelatedEditMediator( emSR );
134
        this.sourceLevel.setEditable(false);
135
        this.sourceLevel.setModel(uiProperties.JAVAC_SOURCE_MODEL);
136
        this.sourceLevel.setRenderer(uiProperties.JAVAC_SOURCE_RENDERER);
137
        uiProperties.JAVAC_SOURCE_MODEL.addListDataListener(new ListDataListener () {
138
            public void intervalAdded(ListDataEvent e) {
139
                enableSourceLevel ();
140
            }
141
142
            public void intervalRemoved(ListDataEvent e) {
143
                enableSourceLevel ();
144
            }
145
146
            public void contentsChanged(ListDataEvent e) {
147
                enableSourceLevel ();
148
            }                                    
149
        });
150
        enableSourceLevel ();
151
        this.originalEncoding = project.evaluator().getProperty(J2MEProjectProperties.SOURCE_ENCODING);
152
        if (this.originalEncoding == null) {
153
            this.originalEncoding = Charset.defaultCharset().name();
154
        }
155
        
156
        this.encoding.setModel(new EncodingModel(this.originalEncoding));
157
        this.encoding.setRenderer(new EncodingRenderer());
158
        final String lafid = UIManager.getLookAndFeel().getID();
159
        if (!"Aqua".equals(lafid)) { //NOI18N
160
            this.encoding.putClientProperty ("JComboBox.isTableCellEditor", Boolean.TRUE);    //NOI18N
161
            this.encoding.addItemListener(new java.awt.event.ItemListener(){ 
162
                public void itemStateChanged(java.awt.event.ItemEvent e){ 
163
                    javax.swing.JComboBox combo = (javax.swing.JComboBox)e.getSource(); 
164
                    combo.setPopupVisible(false); 
165
                } 
166
            });
167
        }
168
        this.encoding.addActionListener(new ActionListener () {
169
            public void actionPerformed(ActionEvent arg0) {
170
                handleEncodingChange();
171
            }            
172
        });
173
        initTableVisualProperties(sourceRoots);
174
        initTableVisualProperties(testRoots);
175
    }
176
    
177
    private class TableColumnSizeComponentAdapter extends ComponentAdapter {
178
        private JTable table = null;
179
        
180
        public TableColumnSizeComponentAdapter(JTable table){
181
            this.table = table;
182
        }
183
        
184
        public void componentResized(ComponentEvent evt){
185
            double pw = table.getParent().getParent().getSize().getWidth();
186
            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
187
            TableColumn column = table.getColumnModel().getColumn(0);
188
            column.setWidth( ((int)pw/2) - 1 );
189
            column.setPreferredWidth( ((int)pw/2) - 1 );
190
            column = table.getColumnModel().getColumn(1);
191
            column.setWidth( ((int)pw/2) - 1 );
192
            column.setPreferredWidth( ((int)pw/2) - 1 );
193
        }
194
    }
195
    
196
    private void initTableVisualProperties(JTable table) {
197
198
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
199
        table.setIntercellSpacing(new java.awt.Dimension(0, 0));
200
        // set the color of the table's JViewport
201
        table.getParent().setBackground(table.getBackground());
202
        
203
        //we'll get the parents width so we can use that to set the column sizes.
204
        double pw = table.getParent().getParent().getPreferredSize().getWidth();
205
        
206
        //#88174 - Need horizontal scrollbar for library names
207
        //ugly but I didn't find a better way how to do it
208
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
209
        TableColumn column = table.getColumnModel().getColumn(0);
210
        column.setMinWidth(226);
211
        column.setWidth( ((int)pw/2) - 1 );
212
        column.setPreferredWidth( ((int)pw/2) - 1 );
213
        column.setMinWidth(75);
214
        column = table.getColumnModel().getColumn(1);
215
        column.setMinWidth(226);
216
        column.setWidth( ((int)pw/2) - 1 );
217
        column.setPreferredWidth( ((int)pw/2) - 1 );
218
        column.setMinWidth(75);
219
        this.addComponentListener(new TableColumnSizeComponentAdapter(table));
220
    }
221
    
222
    private void handleEncodingChange () {
223
            Charset enc = (Charset) encoding.getSelectedItem();
224
            String encName;
225
            if (enc != null) {
226
                encName = enc.name();
227
            }
228
            else {
229
                encName = originalEncoding;
230
            }
231
            if (!notified && encName!=null && !encName.equals(originalEncoding)) {
232
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
233
                        NbBundle.getMessage(CustomizerSources.class,"MSG_EncodingWarning"), NotifyDescriptor.WARNING_MESSAGE));
234
                notified=true;
235
            }
236
            this.uiProperties.put(J2MEProjectProperties.SOURCE_ENCODING, encName);
237
    }
238
239
    public HelpCtx getHelpCtx() {
240
        return new HelpCtx (CustomizerSources.class);
241
    }
242
    
243
    private void enableSourceLevel () {
244
        this.sourceLevel.setEnabled(sourceLevel.getItemCount()>0);
245
    }
246
    
247
    
248
    private static class EncodingRenderer extends JLabel implements ListCellRenderer, UIResource {
249
        
250
        public EncodingRenderer() {
251
            setOpaque(true);
252
        }
253
        
254
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
255
            assert value instanceof Charset;
256
            setName("ComboBox.listRenderer"); // NOI18N
257
            setText(((Charset) value).displayName());
258
            setIcon(null);
259
            if (isSelected) {
260
                setBackground(list.getSelectionBackground());
261
                setForeground(list.getSelectionForeground());             
262
            } else {
263
                setBackground(list.getBackground());
264
                setForeground(list.getForeground());
265
            }
266
            return this;
267
        }
268
        
269
        @Override
270
        public String getName() {
271
            String name = super.getName();
272
            return name == null ? "ComboBox.renderer" : name; // NOI18N
273
        }
274
        
275
    }
276
    
277
    private static class EncodingModel extends DefaultComboBoxModel {
278
        
279
        public EncodingModel (String originalEncoding) {
280
            Charset defEnc = null;
281
            for (Charset c : Charset.availableCharsets().values()) {
282
                if (c.name().equals(originalEncoding)) {
283
                    defEnc = c;
284
                }
285
                addElement(c);
286
            }
287
            if (defEnc == null) {
288
                //Create artificial Charset to keep the original value
289
                //May happen when the project was set up on the platform
290
                //which supports more encodings
291
                try {
292
                    defEnc = new UnknownCharset (originalEncoding);
293
                    addElement(defEnc);
294
                } catch (IllegalCharsetNameException e) {
295
                    //The source.encoding property is completely broken
296
                    Logger.getLogger(this.getClass().getName()).info("IllegalCharsetName: " + originalEncoding);
297
                }
298
            }
299
            if (defEnc == null) {
300
                defEnc = Charset.defaultCharset();
301
            }
302
            setSelectedItem(defEnc);
303
        }
304
    }
305
    
306
    private static class UnknownCharset extends Charset {
307
        
308
        UnknownCharset (String name) {
309
            super (name, new String[0]);
310
        }
311
    
312
        public boolean contains(Charset c) {
313
            throw new UnsupportedOperationException();
314
        }
315
316
        public CharsetDecoder newDecoder() {
317
            throw new UnsupportedOperationException();
318
        }
319
320
        public CharsetEncoder newEncoder() {
321
            throw new UnsupportedOperationException();
322
        }
323
}
324
    
325
    private static class ResizableRowHeightTable extends JTable {
326
327
        private boolean needResize = true;
328
        
329
        @Override
330
        public void setFont(Font font) {
331
            needResize = true;
332
            super.setFont(font);
333
        }
334
335
        @Override
336
        public void paint(Graphics g) {
337
            if(needResize) {
338
                this.setRowHeight(g.getFontMetrics(this.getFont()).getHeight());
339
                needResize = false;
340
            }
341
            super.paint(g);
342
        }
343
        
344
    }
345
    
346
    private static class LabelCellEditor extends DefaultCellEditor {
347
        
348
        private JTable sourceRoots;
349
        private JTable testRoots;
350
        
351
        public LabelCellEditor(JTable sourceRoots, JTable testRoots) {
352
            super(new JTextField());
353
            this.sourceRoots = sourceRoots;
354
            this.testRoots = testRoots;
355
        }
356
        
357
        @Override
358
        public boolean stopCellEditing() {
359
            JTextField field = (JTextField) getComponent();
360
            String text = field.getText();
361
            boolean validCell = true;
362
            TableModel model = sourceRoots.getModel();
363
            int rowCount = model.getRowCount();
364
            for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
365
                String value = (String) model.getValueAt(rowIndex, 1);
366
                if (text.equals(value)) {
367
                    validCell = false;
368
                }
369
            }
370
            model = testRoots.getModel();
371
            rowCount = model.getRowCount();
372
            for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
373
                String value = (String) model.getValueAt(rowIndex, 1);
374
                if (text.equals(value)) {
375
                    validCell = false;
376
                }
377
            }
378
            
379
            return validCell == false ? validCell : super.stopCellEditing();
380
        }
381
        
382
    }
383
    
384
    /** This method is called from within the constructor to
385
     * initialize the form.
386
     * WARNING: Do NOT modify this code. The content of this method is
387
     * always regenerated by the Form Editor.
388
     */
389
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
390
    private void initComponents() {
391
        java.awt.GridBagConstraints gridBagConstraints;
392
393
        jLabel1 = new javax.swing.JLabel();
394
        projectLocation = new javax.swing.JTextField();
395
        sourceRootsPanel = new javax.swing.JPanel();
396
        jLabel2 = new javax.swing.JLabel();
397
        jScrollPane1 = new javax.swing.JScrollPane();
398
        sourceRoots = new ResizableRowHeightTable();
399
        addSourceRoot = new javax.swing.JButton();
400
        removeSourceRoot = new javax.swing.JButton();
401
        upSourceRoot = new javax.swing.JButton();
402
        downSourceRoot = new javax.swing.JButton();
403
        testRootsPanel = new javax.swing.JPanel();
404
        jLabel3 = new javax.swing.JLabel();
405
        jScrollPane2 = new javax.swing.JScrollPane();
406
        testRoots = new ResizableRowHeightTable();
407
        addTestRoot = new javax.swing.JButton();
408
        removeTestRoot = new javax.swing.JButton();
409
        upTestRoot = new javax.swing.JButton();
410
        downTestRoot = new javax.swing.JButton();
411
        jPanel1 = new javax.swing.JPanel();
412
        jLabel4 = new javax.swing.JLabel();
413
        sourceLevel = new javax.swing.JComboBox();
414
        jLabel5 = new javax.swing.JLabel();
415
        encoding = new javax.swing.JComboBox();
416
        jPanel2 = new javax.swing.JPanel();
417
418
        setLayout(new java.awt.GridBagLayout());
419
420
        jLabel1.setLabelFor(projectLocation);
421
        jLabel1.setText(org.openide.util.NbBundle.getBundle(CustomizerSources.class).getString("CTL_ProjectFolder")); // NOI18N
422
        add(jLabel1, new java.awt.GridBagConstraints());
423
424
        projectLocation.setEditable(false);
425
        gridBagConstraints = new java.awt.GridBagConstraints();
426
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
427
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
428
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
429
        gridBagConstraints.weightx = 1.0;
430
        add(projectLocation, gridBagConstraints);
431
        projectLocation.getAccessibleContext().setAccessibleDescription("null");
432
433
        sourceRootsPanel.setLayout(new java.awt.GridBagLayout());
434
435
        jLabel2.setLabelFor(sourceRoots);
436
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/mobility/project/ui/customizer/Bundle"); // NOI18N
437
        jLabel2.setText(bundle.getString("CTL_SourceRoots")); // NOI18N
438
        gridBagConstraints = new java.awt.GridBagConstraints();
439
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
440
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
441
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
442
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
443
        sourceRootsPanel.add(jLabel2, gridBagConstraints);
444
445
        jScrollPane1.setPreferredSize(new java.awt.Dimension(450, 150));
446
447
        sourceRoots.setModel(new javax.swing.table.DefaultTableModel(
448
            new Object [][] {
449
                {null, null},
450
                {null, null},
451
                {null, null},
452
                {null, null}
453
            },
454
            new String [] {
455
                "Package Folder", "Label"
456
            }
457
        ) {
458
            Class[] types = new Class [] {
459
                java.lang.Object.class, java.lang.String.class
460
            };
461
            boolean[] canEdit = new boolean [] {
462
                false, false
463
            };
464
465
            public Class getColumnClass(int columnIndex) {
466
                return types [columnIndex];
467
            }
468
469
            public boolean isCellEditable(int rowIndex, int columnIndex) {
470
                return canEdit [columnIndex];
471
            }
472
        });
473
        jScrollPane1.setViewportView(sourceRoots);
474
        sourceRoots.getAccessibleContext().setAccessibleDescription("null");
475
476
        gridBagConstraints = new java.awt.GridBagConstraints();
477
        gridBagConstraints.gridx = 0;
478
        gridBagConstraints.gridy = 1;
479
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
480
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
481
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
482
        gridBagConstraints.weightx = 1.0;
483
        gridBagConstraints.weighty = 0.5;
484
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
485
        sourceRootsPanel.add(jScrollPane1, gridBagConstraints);
486
487
        addSourceRoot.setText(bundle.getString("CTL_AddSourceRoot")); // NOI18N
488
        gridBagConstraints = new java.awt.GridBagConstraints();
489
        gridBagConstraints.gridx = 1;
490
        gridBagConstraints.gridy = 1;
491
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
492
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
493
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
494
        sourceRootsPanel.add(addSourceRoot, gridBagConstraints);
495
        addSourceRoot.getAccessibleContext().setAccessibleDescription("null");
496
497
        removeSourceRoot.setText(bundle.getString("CTL_RemoveSourceRoot")); // NOI18N
498
        gridBagConstraints = new java.awt.GridBagConstraints();
499
        gridBagConstraints.gridx = 1;
500
        gridBagConstraints.gridy = 2;
501
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
502
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
503
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
504
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
505
        sourceRootsPanel.add(removeSourceRoot, gridBagConstraints);
506
        removeSourceRoot.getAccessibleContext().setAccessibleDescription("null");
507
508
        upSourceRoot.setText(bundle.getString("CTL_UpSourceRoot")); // NOI18N
509
        gridBagConstraints = new java.awt.GridBagConstraints();
510
        gridBagConstraints.gridx = 1;
511
        gridBagConstraints.gridy = 3;
512
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
513
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
514
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
515
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
516
        sourceRootsPanel.add(upSourceRoot, gridBagConstraints);
517
        upSourceRoot.getAccessibleContext().setAccessibleDescription("null");
518
519
        downSourceRoot.setText(bundle.getString("CTL_DownSourceRoot")); // NOI18N
520
        gridBagConstraints = new java.awt.GridBagConstraints();
521
        gridBagConstraints.gridx = 1;
522
        gridBagConstraints.gridy = 4;
523
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
524
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
525
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
526
        gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
527
        sourceRootsPanel.add(downSourceRoot, gridBagConstraints);
528
        downSourceRoot.getAccessibleContext().setAccessibleDescription("null");
529
530
        gridBagConstraints = new java.awt.GridBagConstraints();
531
        gridBagConstraints.gridx = 0;
532
        gridBagConstraints.gridy = 1;
533
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
534
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
535
        gridBagConstraints.weightx = 1.0;
536
        gridBagConstraints.weighty = 0.45;
537
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
538
        add(sourceRootsPanel, gridBagConstraints);
539
540
        testRootsPanel.setLayout(new java.awt.GridBagLayout());
541
542
        jLabel3.setLabelFor(testRoots);
543
        jLabel3.setText(bundle.getString("CTL_TestRoots")); // NOI18N
544
        gridBagConstraints = new java.awt.GridBagConstraints();
545
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
546
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
547
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
548
        gridBagConstraints.weightx = 1.0;
549
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
550
        testRootsPanel.add(jLabel3, gridBagConstraints);
551
552
        jScrollPane2.setPreferredSize(new java.awt.Dimension(450, 150));
553
554
        testRoots.setModel(new javax.swing.table.DefaultTableModel(
555
            new Object [][] {
556
                {null, null},
557
                {null, null},
558
                {null, null},
559
                {null, null}
560
            },
561
            new String [] {
562
                "Package Folder", "Label"
563
            }
564
        ) {
565
            Class[] types = new Class [] {
566
                java.lang.Object.class, java.lang.String.class
567
            };
568
            boolean[] canEdit = new boolean [] {
569
                false, false
570
            };
571
572
            public Class getColumnClass(int columnIndex) {
573
                return types [columnIndex];
574
            }
575
576
            public boolean isCellEditable(int rowIndex, int columnIndex) {
577
                return canEdit [columnIndex];
578
            }
579
        });
580
        jScrollPane2.setViewportView(testRoots);
581
        testRoots.getAccessibleContext().setAccessibleDescription("null");
582
583
        gridBagConstraints = new java.awt.GridBagConstraints();
584
        gridBagConstraints.gridx = 0;
585
        gridBagConstraints.gridy = 1;
586
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
587
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
588
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
589
        gridBagConstraints.weightx = 1.0;
590
        gridBagConstraints.weighty = 0.5;
591
        testRootsPanel.add(jScrollPane2, gridBagConstraints);
592
593
        addTestRoot.setText(bundle.getString("CTL_AddTestRoot")); // NOI18N
594
        gridBagConstraints = new java.awt.GridBagConstraints();
595
        gridBagConstraints.gridx = 1;
596
        gridBagConstraints.gridy = 1;
597
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
598
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
599
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
600
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 6, 0);
601
        testRootsPanel.add(addTestRoot, gridBagConstraints);
602
        addTestRoot.getAccessibleContext().setAccessibleDescription("null");
603
604
        removeTestRoot.setText(bundle.getString("CTL_RemoveTestRoot")); // NOI18N
605
        gridBagConstraints = new java.awt.GridBagConstraints();
606
        gridBagConstraints.gridx = 1;
607
        gridBagConstraints.gridy = 2;
608
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
609
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
610
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
611
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
612
        testRootsPanel.add(removeTestRoot, gridBagConstraints);
613
        removeTestRoot.getAccessibleContext().setAccessibleDescription("null");
614
615
        upTestRoot.setText(bundle.getString("CTL_UpTestRoot")); // NOI18N
616
        gridBagConstraints = new java.awt.GridBagConstraints();
617
        gridBagConstraints.gridx = 1;
618
        gridBagConstraints.gridy = 3;
619
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
620
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
621
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
622
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 6, 0);
623
        testRootsPanel.add(upTestRoot, gridBagConstraints);
624
        upTestRoot.getAccessibleContext().setAccessibleDescription("null");
625
626
        downTestRoot.setText(bundle.getString("CTL_DownTestRoot")); // NOI18N
627
        gridBagConstraints = new java.awt.GridBagConstraints();
628
        gridBagConstraints.gridx = 1;
629
        gridBagConstraints.gridy = 4;
630
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
631
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
632
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
633
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0);
634
        testRootsPanel.add(downTestRoot, gridBagConstraints);
635
        downTestRoot.getAccessibleContext().setAccessibleDescription("null");
636
637
        gridBagConstraints = new java.awt.GridBagConstraints();
638
        gridBagConstraints.gridx = 0;
639
        gridBagConstraints.gridy = 2;
640
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
641
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
642
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
643
        gridBagConstraints.weightx = 1.0;
644
        gridBagConstraints.weighty = 0.45;
645
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
646
        add(testRootsPanel, gridBagConstraints);
647
648
        jPanel1.setLayout(new java.awt.GridBagLayout());
649
650
        jLabel4.setLabelFor(sourceLevel);
651
        org.openide.awt.Mnemonics.setLocalizedText(jLabel4, bundle.getString("TXT_SourceLevel")); // NOI18N
652
        gridBagConstraints = new java.awt.GridBagConstraints();
653
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
654
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
655
        jPanel1.add(jLabel4, gridBagConstraints);
656
657
        sourceLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1.4", "1.5" }));
658
        sourceLevel.setMinimumSize(this.sourceLevel.getPreferredSize());
659
        gridBagConstraints = new java.awt.GridBagConstraints();
660
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
661
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
662
        gridBagConstraints.weightx = 1.0;
663
        jPanel1.add(sourceLevel, gridBagConstraints);
664
        sourceLevel.getAccessibleContext().setAccessibleName("null");
665
        sourceLevel.getAccessibleContext().setAccessibleDescription("null");
666
667
        jLabel5.setLabelFor(encoding);
668
        org.openide.awt.Mnemonics.setLocalizedText(jLabel5, org.openide.util.NbBundle.getMessage(CustomizerSources.class, "TXT_Encoding")); // NOI18N
669
        gridBagConstraints = new java.awt.GridBagConstraints();
670
        gridBagConstraints.gridx = 0;
671
        gridBagConstraints.gridy = 1;
672
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
673
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
674
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
675
        gridBagConstraints.insets = new java.awt.Insets(8, 0, 0, 12);
676
        jPanel1.add(jLabel5, gridBagConstraints);
677
        jLabel5.getAccessibleContext().setAccessibleDescription("null");
678
679
        encoding.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
680
        gridBagConstraints = new java.awt.GridBagConstraints();
681
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
682
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
683
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
684
        gridBagConstraints.insets = new java.awt.Insets(8, 0, 0, 0);
685
        jPanel1.add(encoding, gridBagConstraints);
686
        gridBagConstraints = new java.awt.GridBagConstraints();
687
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
688
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
689
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
690
        gridBagConstraints.weightx = 1.0;
691
        jPanel1.add(jPanel2, gridBagConstraints);
692
693
        gridBagConstraints = new java.awt.GridBagConstraints();
694
        gridBagConstraints.gridx = 0;
695
        gridBagConstraints.gridy = 3;
696
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
697
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
698
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
699
        gridBagConstraints.weightx = 1.0;
700
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
701
        add(jPanel1, gridBagConstraints);
702
    }// </editor-fold>//GEN-END:initComponents
703
    
704
   
705
    // Variables declaration - do not modify//GEN-BEGIN:variables
706
    private javax.swing.JButton addSourceRoot;
707
    private javax.swing.JButton addTestRoot;
708
    private javax.swing.JButton downSourceRoot;
709
    private javax.swing.JButton downTestRoot;
710
    private javax.swing.JComboBox encoding;
711
    private javax.swing.JLabel jLabel1;
712
    private javax.swing.JLabel jLabel2;
713
    private javax.swing.JLabel jLabel3;
714
    private javax.swing.JLabel jLabel4;
715
    private javax.swing.JLabel jLabel5;
716
    private javax.swing.JPanel jPanel1;
717
    private javax.swing.JPanel jPanel2;
718
    private javax.swing.JScrollPane jScrollPane1;
719
    private javax.swing.JScrollPane jScrollPane2;
720
    private javax.swing.JTextField projectLocation;
721
    private javax.swing.JButton removeSourceRoot;
722
    private javax.swing.JButton removeTestRoot;
723
    private javax.swing.JComboBox sourceLevel;
724
    private javax.swing.JTable sourceRoots;
725
    private javax.swing.JPanel sourceRootsPanel;
726
    private javax.swing.JTable testRoots;
727
    private javax.swing.JPanel testRootsPanel;
728
    private javax.swing.JButton upSourceRoot;
729
    private javax.swing.JButton upTestRoot;
730
    // End of variables declaration//GEN-END:variables
731
    
732
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/J2MEProjectProperties.java (-14 / +163 lines)
Lines 42-48 package org.netbeans.modules.mobility.pr Link Here
42
package org.netbeans.modules.mobility.project.ui.customizer;
42
package org.netbeans.modules.mobility.project.ui.customizer;
43
import java.io.File;
43
import java.io.File;
44
import java.io.IOException;
44
import java.io.IOException;
45
import java.net.MalformedURLException;
46
import java.net.URL;
45
import java.nio.charset.Charset;
47
import java.nio.charset.Charset;
48
import java.nio.charset.UnsupportedCharsetException;
46
import java.util.ArrayList;
49
import java.util.ArrayList;
47
import java.util.Arrays;
50
import java.util.Arrays;
48
import java.util.Collection;
51
import java.util.Collection;
Lines 54-62 import java.util.List; Link Here
54
import java.util.List;
57
import java.util.List;
55
import java.util.Map;
58
import java.util.Map;
56
import java.util.Set;
59
import java.util.Set;
60
import java.util.Vector;
61
import javax.swing.ComboBoxModel;
62
import javax.swing.DefaultComboBoxModel;
63
import javax.swing.ListCellRenderer;
64
import javax.swing.table.DefaultTableModel;
57
import org.netbeans.api.mobility.project.PropertyDescriptor;
65
import org.netbeans.api.mobility.project.PropertyDescriptor;
58
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
66
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
59
import org.netbeans.api.project.Project;
60
import org.netbeans.api.project.ProjectManager;
67
import org.netbeans.api.project.ProjectManager;
61
import org.netbeans.api.project.ProjectUtils;
68
import org.netbeans.api.project.ProjectUtils;
62
import org.netbeans.api.queries.FileEncodingQuery;
69
import org.netbeans.api.queries.FileEncodingQuery;
Lines 67-95 import org.netbeans.spi.mobility.project Link Here
67
import org.netbeans.spi.mobility.project.PropertyParser;
74
import org.netbeans.spi.mobility.project.PropertyParser;
68
import org.netbeans.spi.mobility.project.support.DefaultPropertyParsers;
75
import org.netbeans.spi.mobility.project.support.DefaultPropertyParsers;
69
import org.netbeans.api.queries.CollocationQuery;
76
import org.netbeans.api.queries.CollocationQuery;
77
import org.netbeans.modules.java.api.common.SourceRoots;
78
import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
79
import org.netbeans.modules.mobility.project.J2MEProject;
80
import org.netbeans.modules.mobility.project.J2MEProjectType;
70
import org.netbeans.modules.mobility.project.ProjectConfigurationsHelper;
81
import org.netbeans.modules.mobility.project.ProjectConfigurationsHelper;
82
import org.netbeans.spi.project.AuxiliaryConfiguration;
71
import org.netbeans.spi.project.support.ant.AntProjectHelper;
83
import org.netbeans.spi.project.support.ant.AntProjectHelper;
72
import org.netbeans.spi.project.support.ant.EditableProperties;
84
import org.netbeans.spi.project.support.ant.EditableProperties;
73
import org.netbeans.spi.project.support.ant.PropertyUtils;
85
import org.netbeans.spi.project.support.ant.PropertyUtils;
74
import org.netbeans.spi.project.support.ant.ReferenceHelper;
86
import org.netbeans.spi.project.support.ant.ReferenceHelper;
75
import org.openide.ErrorManager;
76
import org.openide.filesystems.FileObject;
87
import org.openide.filesystems.FileObject;
77
import org.openide.filesystems.FileUtil;
88
import org.openide.filesystems.FileUtil;
89
import org.openide.filesystems.URLMapper;
78
import org.openide.util.Exceptions;
90
import org.openide.util.Exceptions;
79
import org.openide.util.Lookup;
91
import org.openide.util.Lookup;
80
import org.openide.util.MutexException;
92
import org.openide.util.MutexException;
81
import org.openide.util.Mutex;
93
import org.openide.util.Mutex;
82
import org.openide.util.NbBundle;
94
import org.openide.util.NbBundle;
95
import org.w3c.dom.Document;
96
import org.w3c.dom.Element;
97
import org.w3c.dom.NodeList;
83
98
84
/** Helper class. Defines constants for properties. Knows the proper
99
/** Helper class. Defines constants for properties. Knows the proper
85
 *  place where to store the properties.
100
 *  place where to store the properties.
86
 *
101
 *
87
 * @author Petr Hrebejk, Adam Sotona
102
 * @author Petr Hrebejk, Adam Sotona
88
 */
103
 */
89
public class J2MEProjectProperties implements ProjectProperties {
104
public class J2MEProjectProperties extends MultiRootProjectProperties {
90
    
91
    
92
    
93
    // Special properties of the project
105
    // Special properties of the project
94
    public static final String J2ME_PROJECT_NAME = "j2me.project.name"; //NOI18N
106
    public static final String J2ME_PROJECT_NAME = "j2me.project.name"; //NOI18N
95
    
107
    
Lines 99-104 public class J2MEProjectProperties imple Link Here
99
    
111
    
100
    private static final String LIBS="${libs.";
112
    private static final String LIBS="${libs.";
101
113
114
    public static final String SOURCE_ENCODING = "source.encoding"; // NOI18N
115
    public static final String BUILD_DIR = "build.dir"; // NOI18N
116
    public static final String INCLUDES = "includes"; // NOI18N
117
    public static final String EXCLUDES = "excludes"; // NOI18N
118
    public static final String BUILD_CLASSES_DIR = "build.classes.dir";
119
120
    //XXX DIST_DIR probably wrong for ME projects
121
    public static final String DIST_DIR = "dist.dir"; // NOI18N
102
    // Info about the property destination
122
    // Info about the property destination
103
    private final Set<PropertyDescriptor> PROPERTY_DESCRIPTORS = new HashSet<PropertyDescriptor>();
123
    private final Set<PropertyDescriptor> PROPERTY_DESCRIPTORS = new HashSet<PropertyDescriptor>();
104
    
124
    
Lines 132-153 public class J2MEProjectProperties imple Link Here
132
    
152
    
133
    // Private fields ----------------------------------------------------------
153
    // Private fields ----------------------------------------------------------
134
    
154
    
135
    private Project project;                
155
    private J2MEProject project;
136
    
156
    
137
    protected ReferenceHelper refHelper;
157
    protected ReferenceHelper refHelper;
138
    protected AntProjectHelper antProjectHelper;
158
    protected AntProjectHelper antProjectHelper;
139
    protected HashMap<String,PropertyInfo> properties;
159
    protected HashMap<String,PropertyInfo> properties;
140
    protected ProjectConfigurationsHelper configHelper;
160
    protected ProjectConfigurationsHelper configHelper;
141
    protected ProjectConfiguration devConfigs[]; 
161
    protected ProjectConfiguration devConfigs[]; 
162
    public DefaultTableModel SOURCE_ROOTS_MODEL;
163
    public DefaultTableModel TEST_ROOTS_MODEL;
164
    public ComboBoxModel JAVAC_SOURCE_MODEL;
165
    public ListCellRenderer JAVAC_SOURCE_RENDERER;
142
    
166
    
143
    public J2MEProjectProperties( Project project, AntProjectHelper antProjectHelper, ReferenceHelper refHelper, ProjectConfigurationsHelper configHelper) {
167
    public J2MEProjectProperties( J2MEProject project, AntProjectHelper antProjectHelper, ReferenceHelper refHelper, ProjectConfigurationsHelper configHelper) {
144
        this.project = project;
168
        this.project = project;
145
        this.properties = new HashMap<String,PropertyInfo>();
169
        this.properties = new HashMap<String,PropertyInfo>();
146
        this.antProjectHelper = antProjectHelper;
170
        this.antProjectHelper = antProjectHelper;
147
        this.refHelper = refHelper;
171
        this.refHelper = refHelper;
148
        this.configHelper = configHelper;
172
        this.configHelper = configHelper;
173
        SOURCE_ROOTS_MODEL = J2MESourceRootsUi.createModel( project.getSourceRoots() );
174
        TEST_ROOTS_MODEL = J2MESourceRootsUi.createModel( project.getTestSourceRoots() );
175
        JAVAC_SOURCE_MODEL = new DefaultComboBoxModel(); //XXX for testing.  Covered somewhere else already?
176
        JAVAC_SOURCE_RENDERER = PlatformUiSupport.createSourceLevelListCellRenderer ();
149
        initPropertyDescriptors();
177
        initPropertyDescriptors();
150
        read();
178
        read();
179
    }
180
181
    public J2MEProject getProject() {
182
        return project;
151
    }
183
    }
152
    
184
    
153
    public synchronized void setActiveConfiguration(final ProjectConfiguration cfg) {
185
    public synchronized void setActiveConfiguration(final ProjectConfiguration cfg) {
Lines 252-258 public class J2MEProjectProperties imple Link Here
252
    }
284
    }
253
    
285
    
254
    public FileObject getSourceRoot() {
286
    public FileObject getSourceRoot() {
255
        return antProjectHelper.resolveFileObject(antProjectHelper.getStandardPropertyEvaluator().getProperty("src.dir")); //NOI18N
287
        throw new UnsupportedOperationException ("getSourceRoot() deprecated.  " +
288
                "Use getSourceRoots() instead.");
289
    }
290
291
    @Override
292
    public FileObject[] getSourceRoots() {
293
        URL[] urls = project.getSourceRoots().getRootURLs();
294
        FileObject[] result = new FileObject[urls.length];
295
        for (int i=0; i < urls.length; i++) {
296
            result[i] = URLMapper.findFileObject(urls[i]);
297
        }
298
        return result;
256
    }
299
    }
257
    
300
    
258
    /** Reads all the properties of the project and converts them to objects
301
    /** Reads all the properties of the project and converts them to objects
Lines 341-362 public class J2MEProjectProperties imple Link Here
341
                    
384
                    
342
                    //storing global default encoding by dcurrent project (see issue #97855)
385
                    //storing global default encoding by dcurrent project (see issue #97855)
343
                    String enc = sharedProps.getProperty(DefaultPropertiesDescriptor.JAVAC_ENCODING);
386
                    String enc = sharedProps.getProperty(DefaultPropertiesDescriptor.JAVAC_ENCODING);
344
                    if (enc != null) FileEncodingQuery.setDefaultEncoding(Charset.forName(enc));
387
                    if (enc != null) {
388
                        try {
389
                            FileEncodingQuery.setDefaultEncoding(Charset.forName(enc));
390
                        } catch (UnsupportedCharsetException e) {
391
                            //When the encoding is not supported by JVM do not set it as default
392
                        }
393
                    }
394
395
                    Vector srcRoots = SOURCE_ROOTS_MODEL.getDataVector();
396
//                    Element dataElement = getUpdatedConfiguration (srcRoots, antProjectHelper);
397
//                    antProjectHelper.putPrimaryConfigurationData(dataElement, true);
398
                    SourceRoots roots = project.getSourceRoots();
399
                    updateSourceRoots (roots, srcRoots);
345
                    
400
                    
346
                    // save the project under write lock
401
                    // save the project under write lock
347
                    try {
402
                    try {
348
                        ProjectManager.getDefault().saveProject(project);
403
                        ProjectManager.getDefault().saveProject(project);
349
                    } catch (IOException ex) {
404
                    } catch (IOException ex) {
350
                        ErrorManager.getDefault().notify(ex);
405
                        Exceptions.printStackTrace(ex);
351
                    }
406
                    }
352
407
353
                    return null;
408
                    return null;
354
                }
409
                }
355
            });
410
            });
356
        } catch (MutexException e) {
411
        } catch (MutexException e) {
357
            ErrorManager.getDefault().notify(e.getException());
412
            Exceptions.printStackTrace(e);
358
        }
413
        }
359
        
414
    }
415
416
    private final void updateSourceRoots(SourceRoots roots, List srcRoots) {
417
        int max = srcRoots.size();
418
        URL[] urls = new URL[max];
419
        String[] names = new String[max];
420
        try {
421
            for (int i=0; i < max; i++) {
422
                Vector v = (Vector) srcRoots.get(i);
423
                File dir = (File) v.get(0);
424
                String name = (String) v.get(1);
425
                urls[i] = dir.toURI().toURL();
426
                names[i] = name;
427
            }
428
            roots.putRoots(urls, names);
429
        } catch (MalformedURLException mre) {
430
            Exceptions.printStackTrace(mre);
431
        }
432
433
    }
434
435
    private final Element getUpdatedConfiguration (List srcRoots, AntProjectHelper helper) {
436
        assert ProjectManager.mutex().isWriteAccess() : "Saving roots outside" +
437
                " of project manager mutex";
438
        AuxiliaryConfiguration cfg = project.getLookup().lookup(AuxiliaryConfiguration.class);
439
        assert cfg != null;
440
        EditableProperties publicProps =
441
                helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
442
        EditableProperties privateProps =
443
                helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
444
        Element dataElement = cfg.getConfigurationFragment("data", //NOI18N
445
                J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, true);
446
        if (dataElement == null) {
447
            //XXX recreate
448
            throw new IllegalStateException ("Configuration missing <data> section");
449
        }
450
        Document doc = dataElement.getOwnerDocument();
451
        Element srcRootsElement = findSingleChild (dataElement, "source-roots");
452
        dataElement.removeChild(srcRootsElement);
453
        srcRootsElement = doc.createElementNS(
454
                J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
455
                "source-roots"); //NOI18N
456
        boolean pubChanged = false;
457
        boolean privChanged = false;
458
        for (Object o : srcRoots) {
459
            Vector v = (Vector) o;
460
            File dir = (File) v.get(0);
461
            String name = (String) v.get(1);
462
            Element root = doc.createElementNS(
463
                    J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
464
                    "root"); //NOI18N
465
            String id;
466
            if (isStandardSrcDir (dir)) {
467
                id = "src.dir";
468
            } else {
469
                id = "src." + dir.getName() + ".dir";
470
            }
471
            root.setAttribute("id", id); //NOI18N
472
            if (!name.equals(dir.getName())) {
473
                root.setAttribute ("name", name);
474
            }
475
            srcRootsElement.appendChild (root);
476
            if (!dir.exists()) {
477
                if (!dir.mkdirs()) {
478
                    throw new IllegalStateException ("Could not create " + dir);
479
                }
480
            }
481
            FileObject asFileObject = FileUtil.toFileObject (FileUtil.normalizeFile(dir));
482
            FileObject projDir = project.getProjectDirectory();
483
            String relPath = FileUtil.getRelativePath(projDir, asFileObject);
484
            if (relPath == null) { //not under the project
485
                privateProps.put (id, dir.getPath().replace('\\', '/'));
486
            } else {
487
                publicProps.put(id, relPath);
488
            }
489
        }
490
        if (pubChanged) {
491
            helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, publicProps);
492
        }
493
        if (privChanged) {
494
            helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, privateProps);
495
        }
496
        dataElement.appendChild(srcRootsElement);
497
        return dataElement;
498
    }
499
500
    private boolean isStandardSrcDir (File file) {
501
        FileObject asFo = FileUtil.toFileObject (file);
502
        FileObject standardDir = project.getProjectDirectory().getFileObject("src");
503
        return standardDir != null && standardDir.equals(asFo);
504
    }
505
506
    private static Element findSingleChild (Element parent, String name) {
507
        NodeList l = parent.getElementsByTagNameNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, name);
508
        return (Element) ((Element) (l.getLength() == 0 ? null : l.item(0)));
360
    }
509
    }
361
    
510
    
362
    /** Finds out what are new and removed project dependencies and
511
    /** Finds out what are new and removed project dependencies and
(-)6b487c15857b (+608 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.modules.mobility.project.ui.customizer;
43
44
import java.awt.*;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.io.File;
48
import java.net.URI;
49
import java.net.URL;
50
import java.util.Iterator;
51
import java.util.HashSet;
52
import java.util.Set;
53
import java.util.Vector;
54
import java.text.MessageFormat;
55
import java.util.Arrays;
56
import javax.swing.*;
57
import javax.swing.JButton;
58
import javax.swing.event.ListSelectionEvent;
59
import javax.swing.event.ListSelectionListener;
60
import javax.swing.event.CellEditorListener;
61
import javax.swing.event.ChangeEvent;
62
import javax.swing.table.DefaultTableCellRenderer;
63
import javax.swing.table.DefaultTableModel;
64
import org.netbeans.api.java.project.JavaProjectConstants;
65
import org.netbeans.api.project.ProjectUtils;
66
import org.netbeans.api.project.SourceGroup;
67
import org.netbeans.api.project.Sources;
68
import org.netbeans.api.project.FileOwnerQuery;
69
import org.netbeans.api.project.Project;
70
import org.netbeans.api.project.ProjectInformation;
71
import org.netbeans.modules.java.api.common.SourceRoots;
72
import org.netbeans.modules.mobility.project.J2MEProject;
73
import org.openide.DialogDisplayer;
74
import org.openide.DialogDescriptor;
75
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileUtil;
77
import org.openide.util.NbBundle;
78
79
/** Handles adding, removing, reordering of source roots.
80
 *
81
 * @author Tomas Zezula
82
 */
83
public final class J2MESourceRootsUi {
84
85
    //Copied from J2SEProject
86
  
87
    public static DefaultTableModel createModel( SourceRoots roots ) {
88
        
89
        String[] rootLabels = roots.getRootNames();
90
        String[] rootProps = roots.getRootProperties();
91
        URL[] rootURLs = roots.getRootURLs();
92
        Object[][] data = new Object[rootURLs.length] [2];
93
        for (int i=0; i< rootURLs.length; i++) {
94
            data[i][0] = new File (URI.create (rootURLs[i].toExternalForm()));            
95
            data[i][1] = roots.getRootDisplayName(rootLabels[i], rootProps[i]);
96
        }
97
        return new SourceRootsModel(data);
98
                
99
    }
100
    
101
    public static EditMediator registerEditMediator( J2MEProject master,
102
                                             SourceRoots sourceRoots,
103
                                             JTable rootsList,
104
                                             JButton addFolderButton,
105
                                             JButton removeButton,
106
                                             JButton upButton,
107
                                             JButton downButton,
108
                                             CellEditor rootsListEditor) {
109
        
110
        EditMediator em = new EditMediator( master,
111
                                            sourceRoots,
112
                                            rootsList,
113
                                            addFolderButton,
114
                                            removeButton,
115
                                            upButton,
116
                                            downButton);
117
        
118
        // Register the listeners        
119
        // On all buttons
120
        addFolderButton.addActionListener( em ); 
121
        removeButton.addActionListener( em );
122
        upButton.addActionListener( em );
123
        downButton.addActionListener( em );
124
        // On list selection
125
        rootsList.getSelectionModel().addListSelectionListener( em );
126
        DefaultCellEditor editor = (DefaultCellEditor) rootsListEditor;
127
        if (editor == null) {
128
            editor = new DefaultCellEditor(new JTextField());
129
        }
130
        editor.addCellEditorListener (em);
131
        rootsList.setDefaultRenderer( File.class, new FileRenderer (FileUtil.toFile(master.getProjectDirectory())));
132
        rootsList.setDefaultEditor(String.class, editor);
133
        // Set the initial state of the buttons
134
        em.valueChanged( null );
135
        
136
        DefaultTableModel model = (DefaultTableModel)rootsList.getModel();
137
        String[] columnNames = new String[2];
138
        columnNames[0]  = NbBundle.getMessage( J2MESourceRootsUi.class,"CTL_PackageFolders");
139
        columnNames[1]  = NbBundle.getMessage( J2MESourceRootsUi.class,"CTL_PackageLabels");
140
        model.setColumnIdentifiers(columnNames);
141
        rootsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
142
        
143
        return em;
144
    }
145
    
146
    public static EditMediator registerEditMediator( J2MEProject master,
147
                                             SourceRoots sourceRoots,
148
                                             JTable rootsList,
149
                                             JButton addFolderButton,
150
                                             JButton removeButton,
151
                                             JButton upButton,
152
                                             JButton downButton ) {
153
        return registerEditMediator(master, sourceRoots, rootsList, addFolderButton, 
154
                removeButton, upButton, downButton, null);
155
    }
156
    
157
    /**
158
     * Opens the standard dialog for warning an user about illegal source roots.
159
     * @param roots the set of illegal source/test roots
160
     */
161
    public static void showIllegalRootsDialog (Set/*<File>*/ roots) {
162
        JButton closeOption = new JButton (NbBundle.getMessage(J2MESourceRootsUi.class,"CTL_J2SESourceRootsUi_Close"));
163
        closeOption.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(J2MESourceRootsUi.class,"AD_J2SESourceRootsUi_Close"));        
164
        JPanel warning = new WarningDlg (roots);                
165
        String message = NbBundle.getMessage(J2MESourceRootsUi.class,"MSG_InvalidRoot");
166
        JOptionPane optionPane = new JOptionPane (new Object[] {message, warning},
167
            JOptionPane.WARNING_MESSAGE,
168
            0, 
169
            null, 
170
            new Object[0], 
171
            null);
172
        optionPane.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage(J2MESourceRootsUi.class,"AD_InvalidRootDlg"));
173
        DialogDescriptor dd = new DialogDescriptor (optionPane,
174
            NbBundle.getMessage(J2MESourceRootsUi.class,"TITLE_InvalidRoot"),
175
            true,
176
            new Object[] {
177
                closeOption,
178
            },
179
            closeOption,
180
            DialogDescriptor.DEFAULT_ALIGN,
181
            null,
182
            null);                
183
        DialogDisplayer.getDefault().notify(dd);
184
    }
185
        
186
    // Private innerclasses ----------------------------------------------------
187
188
    public static class EditMediator implements ActionListener, ListSelectionListener, CellEditorListener {
189
190
        
191
        final JTable rootsList;
192
        final JButton addFolderButton;
193
        final JButton removeButton;
194
        final JButton upButton;
195
        final JButton downButton;
196
        private final Project project;
197
        private final SourceRoots sourceRoots;
198
        private final Set ownedFolders;
199
        private DefaultTableModel rootsModel;
200
        private EditMediator relatedEditMediator;
201
        private File lastUsedDir;       //Last used current folder in JFileChooser  
202
203
        
204
        public EditMediator( J2MEProject master,
205
                             SourceRoots sourceRoots,
206
                             JTable rootsList,
207
                             JButton addFolderButton,
208
                             JButton removeButton,
209
                             JButton upButton,
210
                             JButton downButton) {
211
212
            if ( !( rootsList.getModel() instanceof DefaultTableModel ) ) {
213
                throw new IllegalArgumentException( "Jtable's model has to be of class DefaultTableModel" ); // NOI18N
214
            }
215
                    
216
            this.rootsList = rootsList;
217
            this.addFolderButton = addFolderButton;
218
            this.removeButton = removeButton;
219
            this.upButton = upButton;
220
            this.downButton = downButton;
221
            this.ownedFolders = new HashSet();
222
223
            this.project = master;
224
            this.sourceRoots = sourceRoots;
225
226
            this.ownedFolders.clear();
227
            this.rootsModel = (DefaultTableModel)rootsList.getModel();
228
            Vector data = rootsModel.getDataVector();
229
            for (Iterator it = data.iterator(); it.hasNext();) {
230
                Vector row = (Vector) it.next ();
231
                File f = (File) row.elementAt(0);
232
                this.ownedFolders.add (f);
233
            }
234
        }
235
        
236
        public void setRelatedEditMediator(EditMediator rem) {
237
            this.relatedEditMediator = rem;
238
        }
239
        
240
        // Implementation of ActionListener ------------------------------------
241
        
242
        /** Handles button events
243
         */        
244
        public void actionPerformed( ActionEvent e ) {
245
            
246
            Object source = e.getSource();
247
            
248
            if ( source == addFolderButton ) { 
249
                
250
                // Let user search for the Jar file
251
                JFileChooser chooser = new JFileChooser();
252
                FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
253
                chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
254
                chooser.setMultiSelectionEnabled( true );
255
                if (this.sourceRoots.isTest()) {
256
                    chooser.setDialogTitle( NbBundle.getMessage( J2MESourceRootsUi.class, "LBL_TestFolder_DialogTitle"  )); // NOI18N
257
                }
258
                else {
259
                    chooser.setDialogTitle( NbBundle.getMessage( J2MESourceRootsUi.class, "LBL_SourceFolder_DialogTitle"  )); // NOI18N
260
                }    
261
                File curDir = this.lastUsedDir;
262
                if (curDir == null) {
263
                    curDir = FileUtil.toFile(this.project.getProjectDirectory());
264
                }
265
                if (curDir != null) {
266
                    chooser.setCurrentDirectory (curDir);
267
                }
268
                int option = chooser.showOpenDialog( SwingUtilities.getWindowAncestor( addFolderButton ) ); // Sow the chooser
269
                
270
                if ( option == JFileChooser.APPROVE_OPTION ) {
271
                    curDir = chooser.getCurrentDirectory();
272
                    if (curDir != null) {
273
                        this.lastUsedDir = curDir;
274
                        if (this.relatedEditMediator != null) {
275
                            this.relatedEditMediator.lastUsedDir = curDir;
276
                        }
277
                    }
278
                    File files[] = chooser.getSelectedFiles();
279
                    addFolders( files );
280
                }
281
                
282
            }
283
            else if ( source == removeButton ) { 
284
                removeElements();
285
            }
286
            else if ( source == upButton ) {
287
                moveUp();
288
            }
289
            else if ( source == downButton ) {
290
                moveDown();
291
            }
292
        }
293
        
294
        // Selection listener implementation  ----------------------------------
295
        
296
        /** Handles changes in the selection
297
         */        
298
        public void valueChanged( ListSelectionEvent e ) {
299
            
300
            int[] si = rootsList.getSelectedRows();
301
            
302
            // addJar allways enabled
303
            
304
            // addLibrary allways enabled
305
            
306
            // addArtifact allways enabled
307
            
308
            // edit enabled only if selection is not empty
309
            boolean edit = si != null && si.length > 0;            
310
311
            // remove enabled only if selection is not empty
312
            boolean remove = si != null && si.length > 0;
313
            // and when the selection does not contain unremovable item
314
315
            // up button enabled if selection is not empty
316
            // and the first selected index is not the first row
317
            boolean up = si != null && si.length > 0 && si[0] != 0;
318
            
319
            // up button enabled if selection is not empty
320
            // and the laset selected index is not the last row
321
            boolean down = si != null && si.length > 0 && si[si.length-1] !=rootsList.getRowCount() - 1;
322
323
            removeButton.setEnabled( remove );
324
            upButton.setEnabled( up );
325
            downButton.setEnabled( down );       
326
                        
327
            //System.out.println("Selection changed " + edit + ", " + remove + ", " +  + ", " + + ", ");
328
            
329
        }
330
331
        public void editingCanceled(ChangeEvent e) {
332
333
        }
334
335
        public void editingStopped(ChangeEvent e) {
336
            // fireActionPerformed(); 
337
        }
338
        
339
        private void addFolders( File files[] ) {
340
            System.err.println("Add folders " + Arrays.asList(files));
341
            int[] si = rootsList.getSelectedRows();
342
            int lastIndex = si == null || si.length == 0 ? -1 : si[si.length - 1];
343
            ListSelectionModel selectionModel = this.rootsList.getSelectionModel();
344
            selectionModel.clearSelection();
345
            Set rootsFromOtherProjects = new HashSet ();
346
            Set rootsFromRelatedSourceRoots = new HashSet();
347
out:        for( int i = 0; i < files.length; i++ ) {
348
                File normalizedFile = FileUtil.normalizeFile(files[i]);
349
                Project p;
350
                if (ownedFolders.contains(normalizedFile)) {
351
                    Vector dataVector = rootsModel.getDataVector();
352
                    for (int j=0; j<dataVector.size();j++) {
353
                        //Sequential search in this minor case is faster than update of positions during each modification
354
                        File f = (File )((Vector)dataVector.elementAt(j)).elementAt(0);
355
                        if (f.equals(normalizedFile)) {
356
                            selectionModel.addSelectionInterval(j,j);
357
                        }
358
                    }
359
                }
360
                else if (this.relatedEditMediator != null && this.relatedEditMediator.ownedFolders.contains(normalizedFile)) {
361
                    rootsFromRelatedSourceRoots.add (normalizedFile);
362
                    continue;
363
                }
364
                if ((p=FileOwnerQuery.getOwner(normalizedFile.toURI()))!=null && !p.getProjectDirectory().equals(project.getProjectDirectory())) {
365
                    final Sources sources = (Sources) p.getLookup().lookup (Sources.class);
366
                    if (sources == null) {
367
                        rootsFromOtherProjects.add (normalizedFile);
368
                        continue;
369
                    }
370
                    final SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
371
                    final SourceGroup[] javaGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
372
                    final SourceGroup[] groups = new SourceGroup [sourceGroups.length + javaGroups.length];
373
                    System.arraycopy(sourceGroups,0,groups,0,sourceGroups.length);
374
                    System.arraycopy(javaGroups,0,groups,sourceGroups.length,javaGroups.length);
375
                    final FileObject projectDirectory = p.getProjectDirectory();
376
                    final FileObject fileObject = FileUtil.toFileObject(normalizedFile);
377
                    if (projectDirectory == null || fileObject == null) {
378
                        rootsFromOtherProjects.add (normalizedFile);
379
                        continue;
380
                    }
381
                    for (int j=0; j<groups.length; j++) {
382
                        final FileObject sgRoot = groups[j].getRootFolder();
383
                        if (fileObject.equals(sgRoot)) {
384
                            rootsFromOtherProjects.add (normalizedFile);
385
                            continue out;
386
                        }
387
                        if (!projectDirectory.equals(sgRoot) && FileUtil.isParentOf(sgRoot, fileObject)) {
388
                            rootsFromOtherProjects.add (normalizedFile);
389
                            continue out;
390
                        }
391
                    }
392
                }
393
                int current = lastIndex + 1 + i;
394
                rootsModel.insertRow( current, new Object[] {normalizedFile, sourceRoots.createInitialDisplayName(normalizedFile)}); //NOI18N
395
                selectionModel.addSelectionInterval(current,current);
396
                this.ownedFolders.add (normalizedFile);
397
            }
398
            if (rootsFromOtherProjects.size() > 0 || rootsFromRelatedSourceRoots.size() > 0) {
399
                rootsFromOtherProjects.addAll(rootsFromRelatedSourceRoots);
400
                showIllegalRootsDialog (rootsFromOtherProjects);
401
            }
402
        }    
403
404
        private void removeElements() {
405
406
            int[] si = rootsList.getSelectedRows();
407
408
            if(  si == null || si.length == 0 ) {
409
                assert false : "Remove button should be disabled"; // NOI18N
410
            }
411
412
            // Remove the items
413
            for( int i = si.length - 1 ; i >= 0 ; i-- ) {
414
                this.ownedFolders.remove(((Vector)rootsModel.getDataVector().elementAt(si[i])).elementAt(0));
415
                rootsModel.removeRow( si[i] );
416
            }
417
418
419
            if ( rootsModel.getRowCount() != 0) {
420
                // Select reasonable item
421
                int selectedIndex = si[si.length - 1] - si.length  + 1; 
422
                if ( selectedIndex > rootsModel.getRowCount() - 1) {
423
                    selectedIndex = rootsModel.getRowCount() - 1;
424
                }
425
                rootsList.setRowSelectionInterval( selectedIndex, selectedIndex );
426
            }
427
428
            // fireActionPerformed();
429
430
        }
431
432
        private void moveUp() {
433
434
            int[] si = rootsList.getSelectedRows();
435
436
            if(  si == null || si.length == 0 ) {
437
                assert false : "MoveUp button should be disabled"; // NOI18N
438
            }
439
440
            // Move the items up
441
            ListSelectionModel selectionModel = this.rootsList.getSelectionModel();
442
            selectionModel.clearSelection();
443
            for( int i = 0; i < si.length; i++ ) {
444
                Vector item = (Vector) rootsModel.getDataVector().elementAt(si[i]);
445
                int newIndex = si[i]-1;
446
                rootsModel.removeRow( si[i] );
447
                rootsModel.insertRow( newIndex, item );
448
                selectionModel.addSelectionInterval(newIndex,newIndex);
449
            }
450
            // fireActionPerformed();
451
        } 
452
453
        private void moveDown() {
454
455
            int[] si = rootsList.getSelectedRows();
456
457
            if(  si == null || si.length == 0 ) {
458
                assert false : "MoveDown button should be disabled"; // NOI18N
459
            }
460
461
            // Move the items up
462
            ListSelectionModel selectionModel = this.rootsList.getSelectionModel();
463
            selectionModel.clearSelection();
464
            for( int i = si.length -1 ; i >= 0 ; i-- ) {
465
                Vector item = (Vector) rootsModel.getDataVector().elementAt(si[i]);
466
                int newIndex = si[i] + 1;
467
                rootsModel.removeRow( si[i] );
468
                rootsModel.insertRow( newIndex, item );
469
                selectionModel.addSelectionInterval(newIndex,newIndex);
470
            }
471
            // fireActionPerformed();
472
        }    
473
        
474
475
    }
476
477
    private static class SourceRootsModel extends DefaultTableModel {
478
479
        public SourceRootsModel (Object[][] data) {
480
            super (data,new Object[]{"location","label"});//NOI18N
481
        }
482
483
        public boolean isCellEditable(int row, int column) {
484
            return column == 1;
485
        }
486
487
        public Class getColumnClass(int columnIndex) {
488
            switch (columnIndex) {
489
                case 0:
490
                    return File.class;
491
                case 1:
492
                    return String.class;
493
                default:
494
                    return super.getColumnClass (columnIndex);
495
            }
496
        }
497
    }
498
    
499
    private static class FileRenderer extends DefaultTableCellRenderer {
500
        
501
        private File projectFolder;
502
        
503
        public FileRenderer (File projectFolder) {
504
            this.projectFolder = projectFolder;
505
        }
506
        
507
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row, int column) {
508
            String displayName;
509
            if (value instanceof File) {
510
                File root = (File) value;
511
                String pfPath = projectFolder.getAbsolutePath() + File.separatorChar;
512
                String srPath = root.getAbsolutePath();            
513
                if (srPath.startsWith(pfPath)) {
514
                    displayName = srPath.substring(pfPath.length());
515
                }
516
                else {
517
                    displayName = srPath;
518
                }
519
            }
520
            else {
521
                displayName = null;
522
            }
523
            Component c = super.getTableCellRendererComponent(table, displayName, isSelected, hasFocus, row, column);
524
            if (c instanceof JComponent) {
525
                ((JComponent) c).setToolTipText (displayName);
526
            }
527
            return c;
528
        }                        
529
        
530
    }
531
532
    private static class WarningDlg extends JPanel {
533
534
        public WarningDlg (Set invalidRoots) {            
535
            this.initGui (invalidRoots);
536
        }
537
538
        private void initGui (Set invalidRoots) {
539
            setLayout( new GridBagLayout ());                        
540
            JLabel label = new JLabel ();
541
            label.setText (NbBundle.getMessage(J2MESourceRootsUi.class,"LBL_InvalidRoot"));
542
            label.setDisplayedMnemonic(NbBundle.getMessage(J2MESourceRootsUi.class,"MNE_InvalidRoot").charAt(0));            
543
            GridBagConstraints c = new GridBagConstraints();
544
            c.gridx = GridBagConstraints.RELATIVE;
545
            c.gridy = GridBagConstraints.RELATIVE;
546
            c.gridwidth = GridBagConstraints.REMAINDER;
547
            c.fill = GridBagConstraints.HORIZONTAL;
548
            c.anchor = GridBagConstraints.NORTHWEST;
549
            c.weightx = 1.0;
550
            c.insets = new Insets (12,0,6,0);
551
            ((GridBagLayout)this.getLayout()).setConstraints(label,c);
552
            this.add (label);            
553
            JList roots = new JList (invalidRoots.toArray());
554
            roots.setCellRenderer (new InvalidRootRenderer(true));
555
            JScrollPane p = new JScrollPane (roots);
556
            c = new GridBagConstraints();
557
            c.gridx = GridBagConstraints.RELATIVE;
558
            c.gridy = GridBagConstraints.RELATIVE;
559
            c.gridwidth = GridBagConstraints.REMAINDER;
560
            c.fill = GridBagConstraints.BOTH;
561
            c.anchor = GridBagConstraints.NORTHWEST;
562
            c.weightx = c.weighty = 1.0;
563
            c.insets = new Insets (0,0,12,0);
564
            ((GridBagLayout)this.getLayout()).setConstraints(p,c);
565
            this.add (p);
566
            label.setLabelFor(roots);
567
            roots.getAccessibleContext().setAccessibleDescription (NbBundle.getMessage(J2MESourceRootsUi.class,"AD_InvalidRoot"));
568
            JLabel label2 = new JLabel ();
569
            label2.setText (NbBundle.getMessage(J2MESourceRootsUi.class,"MSG_InvalidRoot2"));
570
            c = new GridBagConstraints();
571
            c.gridx = GridBagConstraints.RELATIVE;
572
            c.gridy = GridBagConstraints.RELATIVE;
573
            c.gridwidth = GridBagConstraints.REMAINDER;
574
            c.fill = GridBagConstraints.HORIZONTAL;
575
            c.anchor = GridBagConstraints.NORTHWEST;
576
            c.weightx = 1.0;
577
            c.insets = new Insets (0,0,0,0);
578
            ((GridBagLayout)this.getLayout()).setConstraints(label2,c);
579
            this.add (label2);            
580
        }
581
582
        private static class InvalidRootRenderer extends DefaultListCellRenderer {
583
584
            private boolean projectConflict;
585
586
            public InvalidRootRenderer (boolean projectConflict) {
587
                this.projectConflict = projectConflict;
588
            }
589
590
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
591
                File f = (File) value;
592
                String message = f.getAbsolutePath();
593
                if (projectConflict) {
594
                    Project p = FileOwnerQuery.getOwner(f.toURI());
595
                    if (p!=null) {
596
                        ProjectInformation pi = ProjectUtils.getInformation(p);
597
                        String projectName = pi.getDisplayName();
598
                        message = MessageFormat.format (NbBundle.getMessage(J2MESourceRootsUi.class,"TXT_RootOwnedByProject"), new Object[] {
599
                            message,
600
                            projectName});
601
                    }
602
                }
603
                return super.getListCellRendererComponent(list, message, index, isSelected, cellHasFocus);
604
            }
605
        }
606
    }
607
608
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/MIDletScanner.java (-4 / +8 lines)
Lines 54-59 import java.lang.ref.WeakReference; Link Here
54
import java.lang.ref.WeakReference;
54
import java.lang.ref.WeakReference;
55
import java.net.URL;
55
import java.net.URL;
56
import java.util.ArrayList;
56
import java.util.ArrayList;
57
import java.util.Arrays;
57
import java.util.Collection;
58
import java.util.Collection;
58
import java.util.Enumeration;
59
import java.util.Enumeration;
59
import java.util.HashMap;
60
import java.util.HashMap;
Lines 67-72 import org.netbeans.api.java.platform.Ja Link Here
67
import org.netbeans.api.java.platform.JavaPlatform;
68
import org.netbeans.api.java.platform.JavaPlatform;
68
import org.netbeans.api.java.platform.JavaPlatformManager;
69
import org.netbeans.api.java.platform.JavaPlatformManager;
69
import org.netbeans.api.java.platform.Specification;
70
import org.netbeans.api.java.platform.Specification;
71
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
72
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
70
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
73
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
71
import org.netbeans.api.project.ant.AntArtifact;
74
import org.netbeans.api.project.ant.AntArtifact;
72
import org.netbeans.api.project.libraries.Library;
75
import org.netbeans.api.project.libraries.Library;
Lines 86-92 import org.openide.util.RequestProcessor Link Here
86
 */
89
 */
87
public class MIDletScanner implements Runnable {
90
public class MIDletScanner implements Runnable {
88
    
91
    
89
    private final ProjectProperties props;
92
    private final MultiRootProjectProperties props;
90
    private J2MEPlatform activePlatform;
93
    private J2MEPlatform activePlatform;
91
    private final HashMap<FileObject,HashSet<String>> roots2icons = new HashMap<FileObject,HashSet<String>>();
94
    private final HashMap<FileObject,HashSet<String>> roots2icons = new HashMap<FileObject,HashSet<String>>();
92
    private final HashMap<FileObject,HashSet<String>> roots2midlets = new HashMap<FileObject,HashSet<String>>();
95
    private final HashMap<FileObject,HashSet<String>> roots2midlets = new HashMap<FileObject,HashSet<String>>();
Lines 97-103 public class MIDletScanner implements Ru Link Here
97
    private static Reference<MIDletScanner> cache = new WeakReference(null);
100
    private static Reference<MIDletScanner> cache = new WeakReference(null);
98
    
101
    
99
    
102
    
100
    public static MIDletScanner getDefault(ProjectProperties props) {
103
    public static MIDletScanner getDefault(MultiRootProjectProperties props) {
101
        MIDletScanner sc = cache.get();
104
        MIDletScanner sc = cache.get();
102
        if (sc == null || sc.props != props) {
105
        if (sc == null || sc.props != props) {
103
            sc = new MIDletScanner(props);
106
            sc = new MIDletScanner(props);
Lines 106-112 public class MIDletScanner implements Ru Link Here
106
        return sc;
109
        return sc;
107
    }
110
    }
108
    
111
    
109
    private MIDletScanner(ProjectProperties props) {
112
    private MIDletScanner(MultiRootProjectProperties props) {
110
        this.props = props;
113
        this.props = props;
111
    }
114
    }
112
    
115
    
Lines 175-181 public class MIDletScanner implements Ru Link Here
175
    
178
    
176
    private HashSet<FileObject> getRootsFor(final String configuration) {
179
    private HashSet<FileObject> getRootsFor(final String configuration) {
177
        final HashSet<FileObject> roots = new HashSet<FileObject>();
180
        final HashSet<FileObject> roots = new HashSet<FileObject>();
178
        roots.add(props.getSourceRoot());
181
        FileObject[] all = ((MultiRootProjectProperties) props).getSourceRoots();
182
        roots.addAll(Arrays.asList(all));
179
        List<VisualClassPathItem> cpItems = (List<VisualClassPathItem>)props.get(VisualPropertySupport.translatePropertyName(configuration, DefaultPropertiesDescriptor.LIBS_CLASSPATH, true));
183
        List<VisualClassPathItem> cpItems = (List<VisualClassPathItem>)props.get(VisualPropertySupport.translatePropertyName(configuration, DefaultPropertiesDescriptor.LIBS_CLASSPATH, true));
180
        if (cpItems == null) cpItems = (List<VisualClassPathItem>)props.get(DefaultPropertiesDescriptor.LIBS_CLASSPATH);
184
        if (cpItems == null) cpItems = (List<VisualClassPathItem>)props.get(DefaultPropertiesDescriptor.LIBS_CLASSPATH);
181
        if (cpItems == null) return roots;
185
        if (cpItems == null) return roots;
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/regex/CheckedNodeEditor.java (-9 / +14 lines)
Lines 52-58 import java.awt.event.ItemListener; Link Here
52
import java.awt.event.ItemListener;
52
import java.awt.event.ItemListener;
53
import java.awt.event.MouseEvent;
53
import java.awt.event.MouseEvent;
54
import java.util.EventObject;
54
import java.util.EventObject;
55
import org.openide.filesystems.FileObject;
56
55
57
/**
56
/**
58
 * User: suchys
57
 * User: suchys
Lines 144-158 public class CheckedNodeEditor extends A Link Here
144
                    if (editor instanceof CheckedNodeRenderer.RendererComponent){
143
                    if (editor instanceof CheckedNodeRenderer.RendererComponent){
145
                        ((CheckedNodeRenderer.RendererComponent)editor).removeItemListener(itemListener);
144
                        ((CheckedNodeRenderer.RendererComponent)editor).removeItemListener(itemListener);
146
                    }
145
                    }
146
//                    final Node node = Visualizer.findNode(value);
147
//                    final FileObjectCookie doj = (FileObjectCookie) node.getCookie(FileObjectCookie.class);
148
//                    if (doj != null){
149
//                        final FileObject fo = doj.getFileObject();
150
//                        storage.setState(fo, CheckedTreeBeanView.UNSELECTED == storage.getState(fo));
151
//                        final TreePath path = tree.getAnchorSelectionPath();
152
//                        ((DefaultTreeModel)tree.getModel()).reload();
153
//                        tree.setAnchorSelectionPath(path);
154
//                    }
147
                    final Node node = Visualizer.findNode(value);
155
                    final Node node = Visualizer.findNode(value);
148
                    final FileObjectCookie doj = (FileObjectCookie) node.getCookie(FileObjectCookie.class);
156
                    String path = node.getName().replace('.', '/');
149
                    if (doj != null){
157
                    storage.setState(path, CheckedTreeBeanView.UNSELECTED == storage.getState(path));
150
                        final FileObject fo = doj.getFileObject();
158
                    final TreePath treePath = tree.getAnchorSelectionPath();
151
                        storage.setState(fo, CheckedTreeBeanView.UNSELECTED == storage.getState(fo));
159
                    ((DefaultTreeModel)tree.getModel()).reload();
152
                        final TreePath path = tree.getAnchorSelectionPath();
160
                    tree.setAnchorSelectionPath(treePath);
153
                        ((DefaultTreeModel)tree.getModel()).reload();
154
                        tree.setAnchorSelectionPath(path);
155
                    }
156
                }
161
                }
157
            }
162
            }
158
        };
163
        };
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/regex/CheckedTreeBeanView.java (-22 / +87 lines)
Lines 40-45 Link Here
40
 */
40
 */
41
41
42
package org.netbeans.modules.mobility.project.ui.customizer.regex;
42
package org.netbeans.modules.mobility.project.ui.customizer.regex;
43
import org.openide.explorer.ExplorerManager.Provider;
43
import org.openide.explorer.view.BeanTreeView;
44
import org.openide.explorer.view.BeanTreeView;
44
45
45
import java.awt.event.FocusListener;
46
import java.awt.event.FocusListener;
Lines 49-57 import java.util.Map; Link Here
49
import java.util.Map;
50
import java.util.Map;
50
import java.util.StringTokenizer;
51
import java.util.StringTokenizer;
51
import java.util.regex.Pattern;
52
import java.util.regex.Pattern;
53
import javax.swing.SwingUtilities;
52
import javax.swing.UIManager;
54
import javax.swing.UIManager;
55
import org.openide.explorer.ExplorerManager;
53
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileObject;
54
import org.openide.filesystems.FileUtil;
57
import org.openide.nodes.Node;
55
58
56
/**
59
/**
57
 * User: suchys
60
 * User: suchys
Lines 60-66 import org.openide.filesystems.FileUtil; Link Here
60
 */
63
 */
61
public class CheckedTreeBeanView extends BeanTreeView {
64
public class CheckedTreeBeanView extends BeanTreeView {
62
    
65
    
63
    private FileObject root;
66
    private FileObject[] roots;
64
    private Pattern filter;
67
    private Pattern filter;
65
    private Map<String,Object> data;
68
    private Map<String,Object> data;
66
    final private CheckedNodeRenderer renderer;
69
    final private CheckedNodeRenderer renderer;
Lines 98-121 public class CheckedTreeBeanView extends Link Here
98
        tree.setBackground(UIManager.getDefaults().getColor(editable ?  "Tree.background" : "TextField.inactiveBackground")); //NOI18N
101
        tree.setBackground(UIManager.getDefaults().getColor(editable ?  "Tree.background" : "TextField.inactiveBackground")); //NOI18N
99
    }
102
    }
100
    
103
    
101
    public void setSrcRoot(final FileObject root) {
104
    public void setSrcRoots(final FileObject[] roots) {
102
        this.root = root;
105
        this.roots = roots;
106
    }
107
108
    Object getState(String path) {
109
        return data.get(path);
110
    }
111
112
    void setState(String path, boolean selected) {
113
        System.err.println("set state " + path + " to " + selected);
114
        if (path == null) return; // invalid file object
115
        data.put(path, selected ? SELECTED : UNSELECTED); // set the one
116
        if (path.endsWith("/")) {
117
            path = path.substring(0, path.length() - 1);
118
        }
119
        do { // clean the path to parent
120
            int ix = path.lastIndexOf('/');
121
            if (ix > 0) {
122
                path = path.substring(0, ix);
123
            } else {
124
                break;
125
            }
126
            data.remove(path);
127
            System.err.println("path now " + path);
128
        } while (!"".equals(path) && !"/".equals(path));
129
        updateState(path);
130
//        fo = fo.getParent();
131
//        while (fo != null && !"".equals(fo.getPath())) {
132
//            data.remove (fo.getPath());
133
//        }
134
//        while (fo != null && !root.equals(fo)) { // clean the path to parent
135
//            data.remove(FileUtil.getRelativePath(root, fo));
136
//            fo = fo.getParent();
137
//        }
138
//        updateState(root); // renew the path from parent
139
        if (properties != null && propertyName != null) properties.put(propertyName, getExcludesRegex());
103
    }
140
    }
104
    
141
    
105
    private boolean acceptPath(final String path) {
142
    private boolean acceptPath(final String path) {
106
        return path != null && (path.length()==0 || !this.filter.matcher(path).matches());
143
        return path != null && (path.length()==0 || !this.filter.matcher(path).matches());
107
    }
144
    }
145
108
    
146
    
109
    private synchronized Object updateState(final FileObject fo) {
147
    private synchronized Object updateState(final FileObject fo) {
110
        final String path = FileUtil.getRelativePath(root, fo);
148
        final String path = fo.getPath();
149
        return updateState (path);
150
    }
151
152
    private FileObject rootFo () {
153
        Provider provider = (Provider) SwingUtilities.getAncestorOfClass(ExplorerManager.Provider.class, this);
154
        if (provider != null) {
155
            Node n = provider.getExplorerManager().getRootContext();
156
            FileObjectCookie ck = n.getCookie(FileObjectCookie.class);
157
            if (ck != null) {
158
                return ck.getFileObject();
159
            }
160
        }
161
        return null;
162
    }
163
164
    private synchronized Object updateState (String path) {
165
        
111
        if (!acceptPath(path)) return null; // null means invalid
166
        if (!acceptPath(path)) return null; // null means invalid
112
        Object state = data.get(path);
167
        Object state = data.get(path);
113
        final boolean forceState = state == SELECTED || state == UNSELECTED;
168
        final boolean forceState = state == SELECTED || state == UNSELECTED;
169
        FileObject fo = rootFo().getFileObject(path);
170
        System.err.println("Root fo is " + rootFo());
171
        System.err.println("path is " + path);
172
        System.err.println("  child is " + fo);
173
        System.err.println("  is data? " + fo.isData());
174
        if (fo.isData()) {
175
            if (acceptPath(path)) {
176
                data.put (path, state);
177
            }
178
            return state;
179
        }
114
        final Enumeration en = fo.getChildren(forceState);
180
        final Enumeration en = fo.getChildren(forceState);
115
        while (en.hasMoreElements()) {
181
        while (en.hasMoreElements()) {
116
            final FileObject ch = (FileObject)en.nextElement();
182
            final FileObject ch = (FileObject)en.nextElement();
117
            if (forceState) {
183
            if (forceState) {
118
                final String cp = FileUtil.getRelativePath(root, ch);
184
                final String cp = ch.getPath();
119
                if (acceptPath(cp)) data.put(cp, state);
185
                if (acceptPath(cp)) data.put(cp, state);
120
            } else {
186
            } else {
121
                final Object childState = updateState(ch);
187
                final Object childState = updateState(ch);
Lines 131-162 public class CheckedTreeBeanView extends Link Here
131
    }
197
    }
132
    
198
    
133
    public Object getState(final FileObject fo) { // finds first SELECTED or UNSELECTED from root
199
    public Object getState(final FileObject fo) { // finds first SELECTED or UNSELECTED from root
134
        final String path = FileUtil.getRelativePath(root, fo);
200
        String path = fo == null ? "" : fo.getPath();
135
        if (!acceptPath(path)) return null; //invalid
201
        if (!acceptPath(path)) return null; //invalid
136
        return data.get(path);
202
        return data.get(path);
137
    }
203
    }
138
    
204
    
139
    public synchronized void setState(FileObject fo, final boolean selected) {
205
    public synchronized void setState(FileObject fo, final boolean selected) {
140
        final String path = FileUtil.getRelativePath(root, fo);
206
        final String path = fo.getPath();
141
        if (path == null) return; // invalid file object
207
        setState (path, selected);
142
        data.put(path, selected ? SELECTED : UNSELECTED); // set the one
143
        fo = fo.getParent();
144
        while (fo != null && !root.equals(fo)) { // clean the path to parent
145
            data.remove(FileUtil.getRelativePath(root, fo));
146
            fo = fo.getParent();
147
        }
148
        updateState(root); // renew the path from parent
149
        if (properties != null && propertyName != null) properties.put(propertyName, getExcludesRegex());
150
    }
208
    }
151
    
209
    
152
    public String getExcludesRegex() {
210
    public String getExcludesRegex() {
153
        final StringBuffer sb = new StringBuffer();
211
        final StringBuilder sb = new StringBuilder();
154
        addExcludes(root, sb);
212
        for (FileObject root : roots) {
213
            addExcludes(root, sb);
214
        }
155
        return sb.toString();
215
        return sb.toString();
156
    }
216
    }
157
    
217
    
158
    private void addExcludes(final FileObject fo, final StringBuffer sb) {
218
    private void addExcludes(final FileObject fo, final StringBuilder sb) {
159
        final String path = FileUtil.getRelativePath(root, fo);
219
//        FileObject root = rootOf (fo);
220
//        final String path = FileUtil.getRelativePath(root, fo);
221
        String path = fo.getPath();
160
        if (!acceptPath(path)) return;
222
        if (!acceptPath(path)) return;
161
        final Object state = data.get(path);
223
        final Object state = data.get(path);
162
        if ((path.length() > 0 && state == null) || state == SELECTED) return;
224
        if ((path.length() > 0 && state == null) || state == SELECTED) return;
Lines 184-190 public class CheckedTreeBeanView extends Link Here
184
                if (exclude.indexOf('*') < 0) data.put(exclude, UNSELECTED);
246
                if (exclude.indexOf('*') < 0) data.put(exclude, UNSELECTED);
185
            }
247
            }
186
        }
248
        }
187
        updateState(root);
249
//        for (FileObject root : roots) {
250
//            updateState(root);
251
//        }
252
        updateState("");
188
        renderer.setContentStorage(this);
253
        renderer.setContentStorage(this);
189
        editor.setContentStorage(this);
254
        editor.setContentStorage(this);
190
    }
255
    }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/resources/buildscript/compile (-5 / +26 lines)
Lines 5-15 Link Here
5
    <target name="do-compile">
5
    <target name="do-compile">
6
        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
6
        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
7
        <mkdir dir="${{build.classes.dir}}"/>
7
        <mkdir dir="${{build.classes.dir}}"/>
8
        <javac includeantruntime="false" source="${{javac.source}}" target="${{javac.target}}" deprecation="${{javac.deprecation}}" optimize="${{javac.optimize}}" debug="${{javac.debug}}" destdir="${{build.classes.dir}}" srcdir="${{buildsystem.baton}}" bootclasspath="${{platform.bootclasspath}}" encoding="${{javac.encoding}}">
8
        <javac>
9
            <classpath>
9
        <xsl:attribute name="source">${javac.source}</xsl:attribute>
10
                <path path="${{libs.classpath}}"/>
10
        <xsl:attribute name="target">${javac.target}</xsl:attribute>
11
            </classpath>
11
        <xsl:attribute name="deprecation">${javac.deprecation}</xsl:attribute>
12
        <xsl:attribute name="optimize">${javac.optimize}</xsl:attribute>
13
        <xsl:attribute name="destdir">${build.classes.dir}</xsl:attribute>
14
        <xsl:attribute name="debug">${javac.debug}</xsl:attribute>
15
        <xsl:attribute name="bootclasspath">${platform.bootclasspath}</xsl:attribute>
16
        <xsl:attribute name="encoding">${javac.encoding}</xsl:attribute>
17
        <xsl:attribute name="includeantruntime">false</xsl:attribute>
18
19
        <xsl:attribute name="srcdir">
20
            <xsl:for-each select="//multiroot:source-roots/multiroot:root"><xsl:text>${</xsl:text><xsl:value-of select="@id"/><xsl:text>}</xsl:text><xsl:if test="position()!=last()"><xsl:text>:</xsl:text></xsl:if>
21
            </xsl:for-each>
22
        </xsl:attribute>
23
24
        <classpath>
25
            <path path="${{libs.classpath}}"/>
26
        </classpath>
12
        </javac>
27
        </javac>
28
13
        <copy todir="${{build.classes.dir}}">
29
        <copy todir="${{build.classes.dir}}">
14
            <fileset dir="${{buildsystem.baton}}" defaultexcludes="${{filter.use.standard}}" excludes="${{filter.excludes.evaluated}},${{build.classes.excludes}}"/>
30
            <fileset dir="${{buildsystem.baton}}" defaultexcludes="${{filter.use.standard}}" excludes="${{filter.excludes.evaluated}},${{build.classes.excludes}}"/>
15
        </copy>
31
        </copy>
Lines 32-38 Link Here
32
    <target name="do-compile-single">
48
    <target name="do-compile-single">
33
        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
49
        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
34
        <mkdir dir="${{build.classes.dir}}"/>
50
        <mkdir dir="${{build.classes.dir}}"/>
35
        <javac includeantruntime="false" source="${{javac.source}}" target="${{javac.target}}" deprecation="${{javac.deprecation}}" optimize="${{javac.optimize}}" debug="${{javac.debug}}" srcdir="${{buildsystem.baton}}" destdir="${{build.classes.dir}}" bootclasspath="${{platform.bootclasspath}}" includes="${{javac.includes}}" encoding="${{javac.encoding}}">
51
        <javac includeantruntime="false" source="${{javac.source}}" target="${{javac.target}}" deprecation="${{javac.deprecation}}" optimize="${{javac.optimize}}" debug="${{javac.debug}}"
52
         destdir="${{build.classes.dir}}" bootclasspath="${{platform.bootclasspath}}" includes="${{javac.includes}}" encoding="${{javac.encoding}}">
53
        <xsl:attribute name="srcdir">
54
            <xsl:for-each select="//multiroot:source-roots/multiroot:root"><xsl:text>${</xsl:text><xsl:value-of select="@id"/><xsl:text>}</xsl:text><xsl:if test="position()!=last()"><xsl:text>:</xsl:text></xsl:if>
55
            </xsl:for-each>
56
        </xsl:attribute>
36
            <classpath>
57
            <classpath>
37
                <path path="${{libs.classpath}}"/>
58
                <path path="${{libs.classpath}}"/>
38
            </classpath>
59
            </classpath>
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/resources/buildscript/head (+1 lines)
Lines 44-49 made subject to such option by the copyr Link Here
44
                xmlns:project="http://www.netbeans.org/ns/project/1"
44
                xmlns:project="http://www.netbeans.org/ns/project/1"
45
                xmlns:xalan="http://xml.apache.org/xslt"
45
                xmlns:xalan="http://xml.apache.org/xslt"
46
                xmlns:j2meproject="http://www.netbeans.org/ns/j2me-project"
46
                xmlns:j2meproject="http://www.netbeans.org/ns/j2me-project"
47
                xmlns:multiroot="http://www.netbeans.org/ns/multiroot-j2me-project"
47
                xmlns:projdeps="http://www.netbeans.org/ns/ant-project-references/1"
48
                xmlns:projdeps="http://www.netbeans.org/ns/ant-project-references/1"
48
                xmlns:projdeps2="http://www.netbeans.org/ns/ant-project-references/2"
49
                xmlns:projdeps2="http://www.netbeans.org/ns/ant-project-references/2"
49
                xmlns:configs="http://www.netbeans.org/ns/project-configurations/1"
50
                xmlns:configs="http://www.netbeans.org/ns/project-configurations/1"
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/resources/layer.xml (+8 lines)
Lines 365-370 made subject to such option by the copyr Link Here
365
                    <attr name="customizerPanelClass" newvalue="org.netbeans.modules.mobility.project.ui.customizer.CustomizerGeneral"/>
365
                    <attr name="customizerPanelClass" newvalue="org.netbeans.modules.mobility.project.ui.customizer.CustomizerGeneral"/>
366
                </file>
366
                </file>
367
            </folder>
367
            </folder>
368
            <folder name="Sources">
369
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.mobility.project.ui.customizer.Bundle"/>
370
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/mobility/project/ui/resources/midp.gif"/>
371
                <attr name="customizerPanelClass" newvalue="org.netbeans.modules.mobility.project.ui.customizer.CustomizerSources"/>
372
                <attr name="position" intvalue="150"/>
373
            </folder>
374
368
            <folder name="Platform">
375
            <folder name="Platform">
369
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.mobility.project.ui.customizer.Bundle"/>
376
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.mobility.project.ui.customizer.Bundle"/>
370
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/mobility/project/ui/resources/midp.gif"/>
377
                <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/mobility/project/ui/resources/midp.gif"/>
Lines 527-532 made subject to such option by the copyr Link Here
527
    <folder name="ProjectXMLCatalog">
534
    <folder name="ProjectXMLCatalog">
528
        <!-- XXX unlike everyone else, does not use /1 versioning suffix -->
535
        <!-- XXX unlike everyone else, does not use /1 versioning suffix -->
529
        <file name="j2me-project.xsd" url="../../resources/j2me-project.xsd"/>
536
        <file name="j2me-project.xsd" url="../../resources/j2me-project.xsd"/>
537
        <file name="multiroot-j2me-project.xsd" url="../../resources/multiroot-j2me-project.xsd"/>
530
        <file name="j2me-project-private.xsd" url="../../resources/j2me-project-private.xsd"/>
538
        <file name="j2me-project-private.xsd" url="../../resources/j2me-project-private.xsd"/>
531
        <folder name="project-configurations">
539
        <folder name="project-configurations">
532
            <file name="1.xsd" url="../../../../project/support/resources/project-configurations.xsd"/>
540
            <file name="1.xsd" url="../../../../project/support/resources/project-configurations.xsd"/>
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/wizard/Bundle.properties (+10 lines)
Lines 194-196 TXT_MobileLibrary=Mobile Class Library Link Here
194
194
195
#Sample project iterator
195
#Sample project iterator
196
TXT_SampleProject=Sample Java ME Project
196
TXT_SampleProject=Sample Java ME Project
197
LBL_File_PackageRoot=Package Root\:
198
MNM_File_PackageRoot=R
199
MSG_DISAMBIGUATE_MULTI_FOLDERS=The target package exists under multiple \
200
    source root folders.  Choose a source root folder.
201
MSG_DISAMBIGUATE_NO_FOLDERS=The target package does not exist under any \
202
    source root folder.  Choose a source root folder.
203
TTL_DISAMBIGUATE=Ambiguous Target Folder
204
205
#LocalizationTargetDisambiguationPanel
206
TargetDisambiguationDialog.jTextArea1.text=Select a source root
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/wizard/MIDPTargetChooserPanel.java (-7 / +24 lines)
Lines 44-61 import java.io.File; Link Here
44
import java.io.File;
44
import java.io.File;
45
import java.io.IOException;
45
import java.io.IOException;
46
import java.util.ArrayList;
46
import java.util.ArrayList;
47
import java.util.LinkedList;
47
import java.util.List;
48
import java.util.List;
48
import java.util.StringTokenizer;
49
import java.util.StringTokenizer;
49
import javax.swing.event.ChangeEvent;
50
import javax.swing.event.ChangeEvent;
50
import javax.swing.event.ChangeListener;
51
import javax.swing.event.ChangeListener;
51
import org.netbeans.api.java.classpath.ClassPath;
52
import org.netbeans.api.java.classpath.ClassPath;
52
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.Project;
54
import org.netbeans.modules.mobility.project.ui.wizard.TargetDisambiguationDialog;
53
import org.netbeans.spi.project.ui.templates.support.Templates;
55
import org.netbeans.spi.project.ui.templates.support.Templates;
54
import org.openide.WizardDescriptor;
56
import org.openide.WizardDescriptor;
55
import org.openide.ErrorManager;
56
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileUtil;
58
import org.openide.filesystems.FileUtil;
58
import org.openide.loaders.TemplateWizard;
59
import org.openide.loaders.TemplateWizard;
60
import org.openide.util.Exceptions;
59
import org.openide.util.HelpCtx;
61
import org.openide.util.HelpCtx;
60
import org.openide.util.NbBundle;
62
import org.openide.util.NbBundle;
61
import org.openide.util.Utilities;
63
import org.openide.util.Utilities;
Lines 150-167 final class MIDPTargetChooserPanel imple Link Here
150
    public void storeSettings(final Object settings) {
152
    public void storeSettings(final Object settings) {
151
        templateWizard = (TemplateWizard) settings;
153
        templateWizard = (TemplateWizard) settings;
152
        if( isValid() ) {
154
        if( isValid() ) {
153
            
155
            List <FileObject> folders = new LinkedList<FileObject>();
154
            final FileObject rootFolder = gui.getRootFolder();
156
            FileObject folder = null;
155
            final String packageFileName = gui.getPackageFileName();
157
            final String packageFileName = gui.getPackageFileName();
156
            FileObject folder = rootFolder.getFileObject(packageFileName);
158
            FileObject[] roots = gui.getRootFolders();
157
            if (folder == null) {
159
            FileObject createIn = null;
160
            for (FileObject root : roots) {
161
                FileObject test = root.getFileObject (packageFileName);
162
                if (test != null && test.isFolder()) {
163
                    if (folders.isEmpty()) {
164
                        folder = test;
165
                    }
166
                    folders.add (test);
167
                }
168
            }
169
            if (folders.size() > 1 || (folder == null && roots.length > 1)) {
170
                while ((createIn = TargetDisambiguationDialog.disambiguate (roots, folders, folder)) == null){}
171
            }
172
173
            if (folder == null && createIn != null) {
158
                try {
174
                try {
159
                    folder = FileUtil.createFolder(rootFolder, packageFileName);
175
                    folder = FileUtil.createFolder(createIn, packageFileName);
160
                } catch (IOException e) {
176
                } catch (IOException e) {
161
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
177
                    Exceptions.printStackTrace(e);
162
                    return;
178
                    return;
163
                }
179
                }
164
            }
180
            }
181
            
165
            Templates.setTargetFolder(templateWizard, folder);
182
            Templates.setTargetFolder(templateWizard, folder);
166
            Templates.setTargetName(templateWizard, gui.getTargetName());
183
            Templates.setTargetName(templateWizard, gui.getTargetName());
167
            
184
            
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/wizard/MIDPTargetChooserPanelGUI.java (-10 / +20 lines)
Lines 45-50 import java.awt.event.ActionListener; Link Here
45
import java.awt.event.ActionListener;
45
import java.awt.event.ActionListener;
46
import java.io.File;
46
import java.io.File;
47
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.Arrays;
48
import java.util.Enumeration;
49
import java.util.Enumeration;
49
import java.util.List;
50
import java.util.List;
50
import javax.swing.*;
51
import javax.swing.*;
Lines 59-64 import org.netbeans.api.java.project.Jav Link Here
59
import org.netbeans.api.java.project.JavaProjectConstants;
60
import org.netbeans.api.java.project.JavaProjectConstants;
60
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
61
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
61
import org.netbeans.modules.mobility.project.J2MEProjectUtils;
62
import org.netbeans.modules.mobility.project.J2MEProjectUtils;
63
import org.netbeans.modules.mobility.project.J2MESources;
62
import org.openide.filesystems.FileObject;
64
import org.openide.filesystems.FileObject;
63
import org.openide.filesystems.FileUtil;
65
import org.openide.filesystems.FileUtil;
64
import org.netbeans.spi.java.project.support.ui.PackageView;
66
import org.netbeans.spi.java.project.support.ui.PackageView;
Lines 194-202 public class MIDPTargetChooserPanelGUI e Link Here
194
            cIcon.setSelectedItem("");//NOI18N
196
            cIcon.setSelectedItem("");//NOI18N
195
            RequestProcessor.getDefault().post(new Runnable() {
197
            RequestProcessor.getDefault().post(new Runnable() {
196
                public void run() {
198
                public void run() {
197
                    final ArrayList<FileObject> roots = new ArrayList<FileObject>();
199
                    final List<FileObject> roots = new ArrayList<FileObject>();
198
                    roots.add(helper.resolveFileObject(helper.getStandardPropertyEvaluator().getProperty("src.dir"))); //NOI18N
200
                    J2MESources sources = project.getLookup().lookup (J2MESources.class);
199
                    final String libs = J2MEProjectUtils.evaluateProperty(helper, DefaultPropertiesDescriptor.LIBS_CLASSPATH);
201
                    if (sources != null) {
202
                        roots.addAll (Arrays.asList (sources.getSourceRoots()));
203
                    }
204
                    final String libs = J2MEProjectUtils.evaluateProperty(helper,
205
                            DefaultPropertiesDescriptor.LIBS_CLASSPATH);
200
                    if (libs != null) {
206
                    if (libs != null) {
201
                        final String elements[] = PropertyUtils.tokenizePath(helper.resolvePath(libs));
207
                        final String elements[] = PropertyUtils.tokenizePath(helper.resolvePath(libs));
202
                        for (int i=0; i<elements.length; i++) try {
208
                        for (int i=0; i<elements.length; i++) try {
Lines 600-615 public class MIDPTargetChooserPanelGUI e Link Here
600
        return relPath;
606
        return relPath;
601
    }
607
    }
602
    
608
    
603
    public FileObject getRootFolder() {
609
    public FileObject[] getRootFolders() {
604
        return helper.resolveFileObject(helper.getStandardPropertyEvaluator().getProperty("src.dir")); // NOI18N
610
        J2MESources sources = project.getLookup().lookup(J2MESources.class);
611
        return sources == null ? new FileObject[0] : sources.getSourceRoots();
605
    }
612
    }
606
    
613
    
607
    public File getFolder() {
614
    public File getFolder() {
608
        final FileObject root = getRootFolder();
615
        final FileObject[] roots = getRootFolders();
609
        final File rootFile = FileUtil.toFile(root);
616
        if (roots.length > 0) {
610
        if (rootFile == null)
617
            final File rootFile = FileUtil.toFile(roots[0]); //XXX
611
            return null;
618
            if (rootFile != null) {
612
        return new File(rootFile, getPackageFileName());
619
                return new File(rootFile, getPackageFileName());
620
            }
621
        }
622
        return null;
613
    }
623
    }
614
    
624
    
615
    public String getPackageFileName() {
625
    public String getPackageFileName() {
(-)6b487c15857b (+109 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
5
    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
6
    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
7
    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
8
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
11
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
14
  </AuxValues>
15
16
  <Layout>
17
    <DimensionLayout dim="0">
18
      <Group type="103" groupAlignment="0" attributes="0">
19
          <Group type="102" alignment="1" attributes="0">
20
              <EmptySpace max="-2" attributes="0"/>
21
              <Group type="103" groupAlignment="1" attributes="0">
22
                  <Component id="jScrollPane2" alignment="0" pref="336" max="32767" attributes="0"/>
23
                  <Component id="jScrollPane1" alignment="0" pref="336" max="32767" attributes="0"/>
24
              </Group>
25
              <EmptySpace max="-2" attributes="0"/>
26
          </Group>
27
      </Group>
28
    </DimensionLayout>
29
    <DimensionLayout dim="1">
30
      <Group type="103" groupAlignment="0" attributes="0">
31
          <Group type="102" alignment="0" attributes="0">
32
              <EmptySpace min="-2" max="-2" attributes="0"/>
33
              <Component id="jScrollPane1" pref="47" max="32767" attributes="0"/>
34
              <EmptySpace min="-2" max="-2" attributes="0"/>
35
              <Component id="jScrollPane2" pref="137" max="32767" attributes="0"/>
36
              <EmptySpace min="-2" max="-2" attributes="0"/>
37
          </Group>
38
      </Group>
39
    </DimensionLayout>
40
  </Layout>
41
  <SubComponents>
42
    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
43
      <Properties>
44
        <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
45
          <Color blue="ee" green="ee" id="control" palette="3" red="ee" type="palette"/>
46
        </Property>
47
        <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
48
          <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
49
            <EmptyBorder bottom="0" left="0" right="0" top="0"/>
50
          </Border>
51
        </Property>
52
        <Property name="viewportBorder" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
53
          <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
54
            <EmptyBorder bottom="0" left="0" right="0" top="0"/>
55
          </Border>
56
        </Property>
57
      </Properties>
58
      <AuxValues>
59
        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
60
      </AuxValues>
61
62
      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
63
      <SubComponents>
64
        <Component class="javax.swing.JTextArea" name="jTextArea1">
65
          <Properties>
66
            <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
67
              <Color blue="ee" green="ee" id="control" palette="3" red="ee" type="palette"/>
68
            </Property>
69
            <Property name="columns" type="int" value="20"/>
70
            <Property name="lineWrap" type="boolean" value="true"/>
71
            <Property name="rows" type="int" value="5"/>
72
            <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
73
              <ResourceString bundle="org/netbeans/modules/mobility/project/ui/wizard/Bundle.properties" key="TargetDisambiguationDialog.jTextArea1.text" replaceFormat="org.openide.util.NbBundle.getBundle({sourceFileName}.class).getString(&quot;{key}&quot;)"/>
74
            </Property>
75
            <Property name="wrapStyleWord" type="boolean" value="true"/>
76
            <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
77
              <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
78
                <EmptyBorder bottom="0" left="0" right="0" top="0"/>
79
              </Border>
80
            </Property>
81
            <Property name="opaque" type="boolean" value="false"/>
82
          </Properties>
83
        </Component>
84
      </SubComponents>
85
    </Container>
86
    <Container class="javax.swing.JScrollPane" name="jScrollPane2">
87
      <AuxValues>
88
        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
89
      </AuxValues>
90
91
      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
92
      <SubComponents>
93
        <Component class="javax.swing.JList" name="jList1">
94
          <Properties>
95
            <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
96
              <StringArray count="5">
97
                <StringItem index="0" value="Item 1"/>
98
                <StringItem index="1" value="Item 2"/>
99
                <StringItem index="2" value="Item 3"/>
100
                <StringItem index="3" value="Item 4"/>
101
                <StringItem index="4" value="Item 5"/>
102
              </StringArray>
103
            </Property>
104
          </Properties>
105
        </Component>
106
      </SubComponents>
107
    </Container>
108
  </SubComponents>
109
</Form>
(-)6b487c15857b (+214 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2008 Sun Microsystems, Inc.
38
 */
39
package org.netbeans.modules.mobility.project.ui.wizard;
40
41
import java.util.List;
42
import javax.swing.DefaultListModel;
43
import javax.swing.ListSelectionModel;
44
import javax.swing.event.ChangeEvent;
45
import javax.swing.event.ChangeListener;
46
import javax.swing.event.ListSelectionEvent;
47
import javax.swing.event.ListSelectionListener;
48
import org.openide.DialogDescriptor;
49
import org.openide.DialogDisplayer;
50
import org.openide.NotifyDescriptor;
51
import org.openide.filesystems.FileObject;
52
import org.openide.loaders.DataObject;
53
import org.openide.loaders.DataObjectNotFoundException;
54
import org.openide.util.Exceptions;
55
import org.openide.util.NbBundle;
56
57
/**
58
 * Shows a dialog that asks the user which root folder a new file should be
59
 * put in, if either the requested package does not exist in any root,
60
 * or it exists in multiple roots.
61
 *
62
 * @author Tim Boudreau
63
 */
64
public class TargetDisambiguationDialog extends javax.swing.JPanel implements ListSelectionListener {
65
    private ChangeListener listener;
66
67
    private TargetDisambiguationDialog(FileObject[] rootFolders, List<FileObject> candidates, FileObject defaultChoice) {
68
        initComponents();
69
        String msg;
70
        assert candidates.size() == 0 || candidates.size() > 1 : "If only one" +
71
                " folder is found, disambiguation is not needed";
72
        if (candidates.isEmpty()) {
73
            msg = NbBundle.getMessage(TargetDisambiguationDialog.class,
74
                    "MSG_DISAMBIGUATE_NO_FOLDERS"); //NOI18N
75
        } else {
76
            msg = NbBundle.getMessage(TargetDisambiguationDialog.class,
77
                    "MSG_DISAMBIGUATE_MULTI_FOLDERS"); //NOI18N
78
        }
79
        jTextArea1.setText (msg);
80
        DefaultListModel mdl = new DefaultListModel ();
81
        Item sel = null;
82
        for (int i = 0; i < rootFolders.length; i++) {
83
            Item item = new Item (rootFolders[i]);
84
            mdl.addElement(item);
85
            if (defaultChoice != null && defaultChoice.equals(rootFolders[i])) {
86
                sel = item;
87
            }
88
        }
89
        jList1.setModel (mdl);
90
        jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
91
        if (sel != null) {
92
            jList1.setSelectedValue(sel, true);
93
        }
94
    }
95
96
    /** This method is called from within the constructor to
97
     * initialize the form.
98
     * WARNING: Do NOT modify this code. The content of this method is
99
     * always regenerated by the Form Editor.
100
     */
101
    @SuppressWarnings("unchecked")
102
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
103
    private void initComponents() {
104
105
        jScrollPane1 = new javax.swing.JScrollPane();
106
        jTextArea1 = new javax.swing.JTextArea();
107
        jScrollPane2 = new javax.swing.JScrollPane();
108
        jList1 = new javax.swing.JList();
109
110
        jScrollPane1.setBackground(javax.swing.UIManager.getDefaults().getColor("control"));
111
        jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
112
        jScrollPane1.setViewportBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
113
114
        jTextArea1.setBackground(javax.swing.UIManager.getDefaults().getColor("control"));
115
        jTextArea1.setColumns(20);
116
        jTextArea1.setLineWrap(true);
117
        jTextArea1.setRows(5);
118
        jTextArea1.setText(org.openide.util.NbBundle.getBundle(TargetDisambiguationDialog.class).getString("TargetDisambiguationDialog.jTextArea1.text")); // NOI18N
119
        jTextArea1.setWrapStyleWord(true);
120
        jTextArea1.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
121
        jTextArea1.setOpaque(false);
122
        jScrollPane1.setViewportView(jTextArea1);
123
124
        jList1.setModel(new javax.swing.AbstractListModel() {
125
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
126
            public int getSize() { return strings.length; }
127
            public Object getElementAt(int i) { return strings[i]; }
128
        });
129
        jScrollPane2.setViewportView(jList1);
130
131
        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
132
        this.setLayout(layout);
133
        layout.setHorizontalGroup(
134
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
135
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
136
                .addContainerGap()
137
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
138
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE)
139
                    .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE))
140
                .addContainerGap())
141
        );
142
        layout.setVerticalGroup(
143
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
144
            .add(layout.createSequentialGroup()
145
                .addContainerGap()
146
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE)
147
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
148
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
149
                .addContainerGap())
150
        );
151
    }// </editor-fold>//GEN-END:initComponents
152
153
154
    // Variables declaration - do not modify//GEN-BEGIN:variables
155
    private javax.swing.JList jList1;
156
    private javax.swing.JScrollPane jScrollPane1;
157
    private javax.swing.JScrollPane jScrollPane2;
158
    private javax.swing.JTextArea jTextArea1;
159
    // End of variables declaration//GEN-END:variables
160
161
    public void valueChanged(ListSelectionEvent e) {
162
        listener.stateChanged(new ChangeEvent(this));
163
    }
164
165
    void setListener (ChangeListener cl) {
166
        this.listener = cl;
167
    }
168
169
    FileObject getFolder() {
170
        Item item = (Item) jList1.getSelectedValue();
171
        return item == null ? null : item.folder;
172
    }
173
174
    boolean isOk() {
175
        return getFolder() != null;
176
    }
177
178
    private static final class Item {
179
        private final FileObject folder;
180
        private Item (FileObject folder) {
181
            this.folder = folder;
182
        }
183
184
        @Override
185
        public String toString() {
186
            try {
187
                return DataObject.find(folder).getNodeDelegate().getDisplayName();
188
            } catch (DataObjectNotFoundException ex) {
189
                Exceptions.printStackTrace(ex);
190
                return super.toString();
191
            }
192
        }
193
    }
194
195
    public static FileObject disambiguate(FileObject[] rootFolders, List<FileObject> candidates, FileObject defaultChoice) {
196
        final TargetDisambiguationDialog panel = new TargetDisambiguationDialog(rootFolders,
197
                candidates, defaultChoice);
198
199
        final DialogDescriptor dlg = new DialogDescriptor (panel,
200
                NbBundle.getMessage(TargetDisambiguationDialog.class,
201
                "TTL_DISAMBIGUATE"), true, null); //NOI18N
202
        dlg.setValid(defaultChoice != null);
203
        ChangeListener cl = new ChangeListener() {
204
            public void stateChanged(ChangeEvent e) {
205
                dlg.setValid(panel.isOk());
206
            }
207
        };
208
        panel.setListener(cl);
209
        if (DialogDisplayer.getDefault().notify(dlg).equals(NotifyDescriptor.OK_OPTION)) {
210
            return panel.getFolder();
211
        }
212
        return null;
213
    }
214
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/wizard/i18n/Bundle.properties (-2 lines)
Lines 93-97 LBL_DefaultPackage=<default package> Link Here
93
93
94
#System file system
94
#System file system
95
Templates/MIDP/LocalizationSupport.java=Localization Support Class
95
Templates/MIDP/LocalizationSupport.java=Localization Support Class
96
LBL_File_PackageRoot=Package Root\:
97
MNM_File_PackageRoot=R
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/wizard/i18n/LocalizationSupportPanel.java (-10 / +24 lines)
Lines 40-45 Link Here
40
 */
40
 */
41
41
42
package org.netbeans.modules.mobility.project.ui.wizard.i18n;
42
package org.netbeans.modules.mobility.project.ui.wizard.i18n;
43
import org.netbeans.modules.mobility.project.ui.wizard.TargetDisambiguationDialog;
43
import java.awt.Component;
44
import java.awt.Component;
44
import java.io.File;
45
import java.io.File;
45
import java.util.ArrayList;
46
import java.util.ArrayList;
Lines 57-64 import org.openide.util.NbBundle; Link Here
57
import org.openide.util.NbBundle;
58
import org.openide.util.NbBundle;
58
import org.openide.util.Utilities;
59
import org.openide.util.Utilities;
59
import java.util.StringTokenizer;
60
import java.util.StringTokenizer;
60
import org.openide.ErrorManager;
61
import java.io.IOException;
61
import java.io.IOException;
62
import java.util.LinkedList;
63
import org.openide.util.Exceptions;
62
64
63
/**
65
/**
64
 *
66
 *
Lines 135-154 public final class LocalizationSupportPa Link Here
135
        fullResourceName.append(messageFilename);
137
        fullResourceName.append(messageFilename);
136
        return fullResourceName.toString();
138
        return fullResourceName.toString();
137
    }
139
    }
138
    
140
139
    
140
    
141
    public void storeSettings(final Object settings) {
141
    public void storeSettings(final Object settings) {
142
        if( isValid() ) {
142
        if( isValid() ) {
143
            
143
            List <FileObject> folders = new LinkedList<FileObject>();
144
            final FileObject rootFolder = gui.getRootFolder();
144
            FileObject folder = null;
145
            final String packageFileName = gui.getPackageFileName();
145
            final String packageFileName = gui.getPackageFileName();
146
            FileObject folder = rootFolder.getFileObject(packageFileName);
146
            FileObject[] roots = gui.getRootFolders();
147
            if (folder == null) {
147
            FileObject createIn = null;
148
            for (FileObject root : roots) {
149
                FileObject test = root.getFileObject (packageFileName);
150
                if (test != null && test.isFolder()) {
151
                    if (folders.isEmpty()) {
152
                        folder = test;
153
                    }
154
                    folders.add (test);
155
                }
156
            }
157
            if (folders.size() > 1 || (folder == null && roots.length > 1)) {
158
                while ((createIn = TargetDisambiguationDialog.disambiguate (roots, folders, folder)) == null){}
159
            }
160
161
            if (folder == null && createIn != null) {
148
                try {
162
                try {
149
                    folder = FileUtil.createFolder(rootFolder, packageFileName);
163
                    folder = FileUtil.createFolder(createIn, packageFileName);
150
                } catch (IOException e) {
164
                } catch (IOException e) {
151
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
165
                    Exceptions.printStackTrace(e);
152
                    return;
166
                    return;
153
                }
167
                }
154
            }
168
            }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/wizard/i18n/LocalizationSupportPanelGUI.java (-7 / +18 lines)
Lines 67-76 import java.awt.Dimension; Link Here
67
import java.awt.Dimension;
67
import java.awt.Dimension;
68
import java.awt.event.ActionEvent;
68
import java.awt.event.ActionEvent;
69
import java.awt.event.ActionListener;
69
import java.awt.event.ActionListener;
70
import java.util.LinkedList;
70
import org.netbeans.api.project.SourceGroup;
71
import org.netbeans.api.project.SourceGroup;
71
import org.netbeans.api.project.Sources;
72
import org.netbeans.api.project.Sources;
72
import org.netbeans.api.java.project.JavaProjectConstants;
73
import org.netbeans.api.java.project.JavaProjectConstants;
73
import javax.swing.text.Document;
74
import javax.swing.text.Document;
75
import org.netbeans.modules.mobility.project.J2MESources;
74
import org.netbeans.spi.java.project.support.ui.PackageView;
76
import org.netbeans.spi.java.project.support.ui.PackageView;
75
import org.openide.util.NbBundle;
77
import org.openide.util.NbBundle;
76
78
Lines 247-262 public class LocalizationSupportPanelGUI Link Here
247
        return null;
249
        return null;
248
    }
250
    }
249
    
251
    
250
    public FileObject getRootFolder() {
252
    public FileObject[] getRootFolders() {
251
        return helper.resolveFileObject(helper.getStandardPropertyEvaluator().getProperty("src.dir")); // NOI18N
253
        J2MESources sources = project.getLookup().lookup(J2MESources.class);
254
        return sources == null ? new FileObject[0] : sources.getSourceRoots();
252
    }
255
    }
253
    
256
    
254
    public File getFolder() {
257
    public File getFolder() {
255
        final FileObject root = getRootFolder();
258
        J2MESources sources = project.getLookup().lookup(J2MESources.class);
256
        final File rootFile = FileUtil.toFile(root);
259
        FileObject result = null;
257
        if (rootFile == null)
260
        if (sources != null) {
258
            return null;
261
            //Find any source root that contains the package.  We'll ask the
259
        return new File(rootFile, getPackageFileName());
262
            //user to disambiguate if there are multiple ones later.
263
            for (FileObject root : sources.getSourceRoots()) {
264
                result = root.getFileObject(getPackageFileName());
265
                if (result != null) {
266
                    break;
267
                }
268
            }
269
        }
270
        return result == null ? FileUtil.toFile(result) : null;
260
    }
271
    }
261
    
272
    
262
    
273
    
(-)a/mobility.project/src/org/netbeans/spi/mobility/project/ui/customizer/CustomizerPanel.java (-2 / +2 lines)
Lines 41-47 Link Here
41
41
42
package org.netbeans.spi.mobility.project.ui.customizer;
42
package org.netbeans.spi.mobility.project.ui.customizer;
43
43
44
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
44
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
45
45
46
/**
46
/**
47
 *
47
 *
Lines 49-54 import org.netbeans.api.mobility.project Link Here
49
 */
49
 */
50
public interface CustomizerPanel {
50
public interface CustomizerPanel {
51
    
51
    
52
    public void initValues(ProjectProperties props, String configuration);
52
    public void initValues(MultiRootProjectProperties props, String configuration);
53
    
53
    
54
}
54
}
(-)a/mobility.project/test/unit/src/org/netbeans/modules/mobility/project/J2MEActionProviderTest.java (-1 / +1 lines)
Lines 311-317 public class J2MEActionProviderTest exte Link Here
311
            TestUtil.setHelper(hp);
311
            TestUtil.setHelper(hp);
312
            /* try to add another root for better code coverage */
312
            /* try to add another root for better code coverage */
313
            EditableProperties ep=hp.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
313
            EditableProperties ep=hp.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
314
            ep.setProperty("src.dir",System.getProperty("java.io.tmpdir"));
314
            ep.setProperty(DefaultPropertiesDescriptor.SRC_DIR,System.getProperty("java.io.tmpdir"));
315
            hp.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
315
            hp.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
316
            new J2MEProject(hp);
316
            new J2MEProject(hp);
317
        } catch (Exception e) {
317
        } catch (Exception e) {
(-)a/mobility.project/test/unit/src/org/netbeans/modules/mobility/project/queries/CompiledSourceForBinaryQueryTest.java (-1 / +1 lines)
Lines 156-162 public class CompiledSourceForBinaryQuer Link Here
156
        result.addChangeListener(list);
156
        result.addChangeListener(list);
157
        result.removeChangeListener(null);
157
        result.removeChangeListener(null);
158
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
158
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
159
        ep.setProperty("src.dir","../src2");
159
        ep.setProperty(DefaultPropertiesDescriptor.SRC_DIR,"../src2");
160
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
160
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
161
        //result.removeChangeListener(list);
161
        //result.removeChangeListener(list);
162
    }
162
    }
(-)a/mobility.project/test/unit/src/org/netbeans/modules/mobility/project/queries/FileBuiltQueryImplTest.java (-1 / +2 lines)
Lines 63-68 import org.netbeans.junit.NbTestCase; Link Here
63
import org.netbeans.junit.NbTestCase;
63
import org.netbeans.junit.NbTestCase;
64
import org.netbeans.modules.java.platform.JavaPlatformProvider;
64
import org.netbeans.modules.java.platform.JavaPlatformProvider;
65
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
65
import org.netbeans.modules.mobility.cldcplatform.J2MEPlatform;
66
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
66
import org.netbeans.modules.mobility.project.J2MEActionProvider;
67
import org.netbeans.modules.mobility.project.J2MEActionProvider;
67
import org.netbeans.modules.mobility.project.J2MEProject;
68
import org.netbeans.modules.mobility.project.J2MEProject;
68
import org.netbeans.modules.mobility.project.J2MEProjectGenerator;
69
import org.netbeans.modules.mobility.project.J2MEProjectGenerator;
Lines 266-272 public class FileBuiltQueryImplTest exte Link Here
266
        assertNull(ret,ret);
267
        assertNull(ret,ret);
267
        
268
        
268
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
269
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
269
        ep.setProperty("src.dir","src2");
270
        ep.setProperty(DefaultPropertiesDescriptor.SRC_DIR,"src2");
270
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
271
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
271
        
272
        
272
        
273
        

Return to bug 138749