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 138228
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 119-125 public class DeviceAnywhereDeploymentPlu Link Here
119
        return new DeviceAnywhereGlobalCustomizerPanel();
120
        return new DeviceAnywhereGlobalCustomizerPanel();
120
    }
121
    }
121
122
122
    public void initValues(ProjectProperties props, String configuration) {
123
    public void initValues(MultiRootProjectProperties props, String configuration) {
123
        this.props = props;
124
        this.props = props;
124
        this.configuration = configuration;
125
        this.configuration = configuration;
125
    }
126
    }
(-)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 100-106 public class MainClassChooserImpl extend Link Here
100
    protected ChangeListener changeListener;
100
    protected ChangeListener changeListener;
101
    private String dialogSubtitle = null;
101
    private String dialogSubtitle = null;
102
    protected List<String> possibleMainClasses;
102
    protected List<String> possibleMainClasses;
103
    private FileObject sourcesRoot;
103
    private FileObject[] sourceRoots;
104
    private String bcp;
104
    private String bcp;
105
    protected boolean onlyMain;
105
    protected boolean onlyMain;
106
    protected String mainClass;
106
    protected String mainClass;
Lines 115-126 public class MainClassChooserImpl extend Link Here
115
    }
115
    }
116
116
117
    @Override
117
    @Override
118
    public void inicialize(FileObject sourceRoot, Map<String, String> executionModes, String bootcp) {
118
    public void initialize(FileObject[] sourceRoots, Map<String, String> executionModes, String bootcp) {
119
        dialogSubtitle = null;
119
        dialogSubtitle = null;
120
        this.sourcesRoot = sourceRoot;
120
        this.sourceRoots = sourceRoots;
121
        this.onlyMain = false;
121
        this.onlyMain = false;
122
        this.executionModes = executionModes;
122
        this.executionModes = executionModes;
123
        initClassesView (sourcesRoot);
123
        initClassesView (sourceRoots);
124
        if (onlyMain)
124
        if (onlyMain)
125
            onlymainLabel.setText(NbBundle.getMessage(MainClassChooserImpl.class, "MSG_OnlyMainAllowed"));
125
            onlymainLabel.setText(NbBundle.getMessage(MainClassChooserImpl.class, "MSG_OnlyMainAllowed"));
126
        bcp=bootcp;
126
        bcp=bootcp;
Lines 128-134 public class MainClassChooserImpl extend Link Here
128
        specialExecFqnApplet = (executionModes != null) ? executionModes.get(CDCPlatform.PROP_EXEC_APPLET)  : null;        
128
        specialExecFqnApplet = (executionModes != null) ? executionModes.get(CDCPlatform.PROP_EXEC_APPLET)  : null;        
129
    }
129
    }
130
    
130
    
131
    private void initClassesView (final FileObject sourcesRoot) {
131
    private void initClassesView (final FileObject[] sourceRoots) {
132
        possibleMainClasses = null;
132
        possibleMainClasses = null;
133
        jMainClassList.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
133
        jMainClassList.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
134
        jMainClassList.setListData (getWarmupList ());
134
        jMainClassList.setListData (getWarmupList ());
Lines 159-165 public class MainClassChooserImpl extend Link Here
159
        
159
        
160
        RequestProcessor.getDefault ().post (new Runnable () {
160
        RequestProcessor.getDefault ().post (new Runnable () {
161
            public void run () {
161
            public void run () {
162
                possibleMainClasses = getMainClasses (new FileObject[] {sourcesRoot}, executionModes,bcp);
162
                possibleMainClasses = getMainClasses (sourceRoots, executionModes,bcp);
163
                if (possibleMainClasses.isEmpty ()) {                    
163
                if (possibleMainClasses.isEmpty ()) {                    
164
                    SwingUtilities.invokeLater( new Runnable () {
164
                    SwingUtilities.invokeLater( new Runnable () {
165
                        public void run () {
165
                        public void run () {
Lines 175-181 public class MainClassChooserImpl extend Link Here
175
                                final List<String> l = new ArrayList<String>(possibleMainClasses);
175
                                final List<String> l = new ArrayList<String>(possibleMainClasses);
176
                                for (Iterator<String> it = l.iterator(); it.hasNext();) {
176
                                for (Iterator<String> it = l.iterator(); it.hasNext();) {
177
                                    String elem = it.next();
177
                                    String elem = it.next();
178
                                    if (!isMainClass(elem, sourcesRoot) || (executionModes != null && executionModes.containsKey(CDCPlatform.PROP_EXEC_MAIN))){
178
                                    if (!isMainClass(elem, sourceRoots) || (executionModes != null && executionModes.containsKey(CDCPlatform.PROP_EXEC_MAIN))){
179
                                        it.remove();
179
                                        it.remove();
180
                                    }   
180
                                    }   
181
                                }
181
                                }
Lines 195-201 public class MainClassChooserImpl extend Link Here
195
                            boolean xlet = false;
195
                            boolean xlet = false;
196
                            if (!possibleMainClasses.isEmpty()){
196
                            if (!possibleMainClasses.isEmpty()){
197
                                for (String elem : possibleMainClasses) {
197
                                for (String elem : possibleMainClasses) {
198
                                    if (isXletClass(elem, sourcesRoot, specialExecFqnXlet)){
198
                                    if (isXletClass(elem, sourceRoots[0], specialExecFqnXlet)){
199
                                        xlet = true;
199
                                        xlet = true;
200
                                        break;
200
                                        break;
201
                                    }
201
                                    }
Lines 258-266 public class MainClassChooserImpl extend Link Here
258
            {
258
            {
259
                public void run()
259
                public void run()
260
                {
260
                {
261
                    isMain[0] = isMainClass(mainClass, sourcesRoot);
261
                    isMain[0] = isMainClass(mainClass, sourceRoots);
262
                    isXlet[0] = isXletClass(mainClass, sourcesRoot, specialExecFqnXlet);
262
                    isXlet[0] = isXletClass(mainClass, sourceRoots[0], specialExecFqnXlet);
263
                    isApplet[0] = isAppletClass(mainClass, sourcesRoot, specialExecFqnApplet);
263
                    isApplet[0] = isAppletClass(mainClass, sourceRoots[0], specialExecFqnApplet);
264
                }
264
                }
265
            });
265
            });
266
            task.waitFinished();
266
            task.waitFinished();
Lines 488-499 public class MainClassChooserImpl extend Link Here
488
    }//GEN-LAST:event_multipleXletsActionPerformed
488
    }//GEN-LAST:event_multipleXletsActionPerformed
489
489
490
    protected String[] updateListView(final boolean onlyXlets) {
490
    protected String[] updateListView(final boolean onlyXlets) {
491
        if (onlyXlets){
491
        if (onlyXlets && sourceRoots.length > 0){
492
            jMainClassList.setSelectionMode (ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
492
            jMainClassList.setSelectionMode (ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
493
            List<String> l = new ArrayList<String>(possibleMainClasses);
493
            List<String> l = new ArrayList<String>(possibleMainClasses);
494
            for (Iterator<String> it = l.iterator(); it.hasNext();) {
494
            for (Iterator<String> it = l.iterator(); it.hasNext();) {
495
                String elem = it.next();
495
                String elem = it.next();
496
                if (!isXletClass(elem, sourcesRoot, specialExecFqnXlet)){
496
                if (!isXletClass(elem, sourceRoots[0], specialExecFqnXlet)){
497
                    it.remove();
497
                    it.remove();
498
                }
498
                }
499
            }
499
            }
Lines 708-713 public class MainClassChooserImpl extend Link Here
708
            ex.printStackTrace();
708
            ex.printStackTrace();
709
        }
709
        }
710
    }
710
    }
711
712
    private FileObject rootOf (FileObject test) {
713
        for (FileObject root : sourceRoots) {
714
            if (FileUtil.isParentOf(root, test)) {
715
                return root;
716
            }
717
        }
718
        throw new AssertionError (test.getPath() + " not a child of source " +
719
                "roots " + Arrays.asList(sourceRoots));
720
    }
711
    
721
    
712
    /** Returns if the given class name exists under the sources root and
722
    /** Returns if the given class name exists under the sources root and
713
     * it's a main class.
723
     * it's a main class.
Lines 716-722 public class MainClassChooserImpl extend Link Here
716
     * @param root roots of sources
726
     * @param root roots of sources
717
     * @return true if the class name exists and it's a main class
727
     * @return true if the class name exists and it's a main class
718
     */
728
     */
719
    public static boolean isMainClass(String className, FileObject root) {
729
    public static boolean isMainClass(String className, FileObject[] roots) {
730
        if (roots.length == 0) {
731
            return false;
732
        }
733
        FileObject root = roots[0];
720
        ClassPath boot = ClassPath.getClassPath (root, ClassPath.BOOT);  //Single compilation unit
734
        ClassPath boot = ClassPath.getClassPath (root, ClassPath.BOOT);  //Single compilation unit
721
        ClassPath rtm2  = ClassPath.getClassPath (root, ClassPath.EXECUTE);  //Single compilation unit'
735
        ClassPath rtm2  = ClassPath.getClassPath (root, ClassPath.EXECUTE);  //Single compilation unit'
722
        ClassPath rtm1 = ClassPath.getClassPath (root, ClassPath.COMPILE);
736
        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 / +4 lines)
Lines 166-183 Link Here
166
                <friend>org.netbeans.modules.j2ee.earproject</friend>
166
                <friend>org.netbeans.modules.j2ee.earproject</friend>
167
                <friend>org.netbeans.modules.j2ee.ejbjarproject</friend>
167
                <friend>org.netbeans.modules.j2ee.ejbjarproject</friend>
168
                <friend>org.netbeans.modules.java.j2seproject</friend>
168
                <friend>org.netbeans.modules.java.j2seproject</friend>
169
                <friend>org.netbeans.modules.javafx.profiler</friend>
169
                <friend>org.netbeans.modules.javafx.project</friend>
170
                <friend>org.netbeans.modules.javafx.project</friend>
170
                <friend>org.netbeans.modules.javafx.profiler</friend>
171
                <friend>org.netbeans.modules.mobility.project</friend>
171
                <friend>org.netbeans.modules.projectimport</friend>
172
                <friend>org.netbeans.modules.projectimport</friend>
172
                <friend>org.netbeans.modules.projectimport.jbuilder</friend>
173
                <friend>org.netbeans.modules.projectimport.eclipse.core</friend>
173
                <friend>org.netbeans.modules.projectimport.eclipse.core</friend>
174
                <friend>org.netbeans.modules.projectimport.eclipse.j2se</friend>
174
                <friend>org.netbeans.modules.projectimport.eclipse.j2se</friend>
175
                <friend>org.netbeans.modules.projectimport.eclipse.web</friend>
175
                <friend>org.netbeans.modules.projectimport.eclipse.web</friend>
176
                <friend>org.netbeans.modules.projectimport.jbuilder</friend>
176
                <friend>org.netbeans.modules.scala.project</friend>
177
                <friend>org.netbeans.modules.scala.project</friend>
177
                <friend>org.netbeans.modules.web.project</friend>
178
                <friend>org.netbeans.modules.web.project</friend>
178
                <friend>org.netbeans.modules.xtest</friend>
179
                <friend>org.netbeans.modules.xtest</friend>
179
                <package>org.netbeans.modules.java.api.common</package>
180
                <package>org.netbeans.modules.java.api.common</package>
180
                <package>org.netbeans.modules.java.api.common.ant</package>
181
                <package>org.netbeans.modules.java.api.common.ant</package>
182
                <package>org.netbeans.modules.java.api.common.classpath</package>
181
                <package>org.netbeans.modules.java.api.common.queries</package>
183
                <package>org.netbeans.modules.java.api.common.queries</package>
182
                <package>org.netbeans.modules.java.api.common.ui</package>
184
                <package>org.netbeans.modules.java.api.common.ui</package>
183
                <package>org.netbeans.modules.java.api.common.util</package>
185
                <package>org.netbeans.modules.java.api.common.util</package>
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties (-1 / +1 lines)
Lines 183-189 CTL_ProjectFolder=Project Folder\: Link Here
183
CTL_ProjectFolder=Project Folder\:
183
CTL_ProjectFolder=Project Folder\:
184
TITLE_InvalidRoot=Add Package Folder
184
TITLE_InvalidRoot=Add Package Folder
185
MSG_InvalidRoot=<html><b>Package Folder Already Used in Project</b></html>\n\
185
MSG_InvalidRoot=<html><b>Package Folder Already Used in Project</b></html>\n\
186
    Following folders you selected are already used in this or another\n\
186
    The following folders you selected are already used in this or another\n\
187
    project. One package folder can only be used in one project in one\n\
187
    project. One package folder can only be used in one project in one\n\
188
    package folder list (source packages or test packages).
188
    package folder list (source packages or test packages).
189
LBL_InvalidRoot=Package folders already in use:
189
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 66-72 public class J2MEUnitProjectLookupProvid Link Here
66
    {
66
    {
67
        List lookups=new ArrayList();
67
        List lookups=new ArrayList();
68
        lookups.add(new J2MEUnitPlugin(project,helper));
68
        lookups.add(new J2MEUnitPlugin(project,helper));
69
        lookups.add(new UnitTestForSourceQueryImpl(helper));
69
        lookups.add(new UnitTestForSourceQueryImpl(project, helper));
70
        return lookups;
70
        return lookups;
71
    }   
71
    }   
72
}
72
}
(-)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>
(-)ea8899550edd (+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 82-84 LBL_Cfg_TemplateSuffix=_template Link Here
82
82
83
EmptyConfigurationTemplate=<empty project configuration>
83
EmptyConfigurationTemplate=<empty project configuration>
84
84
85
#Updater
86
TXT_ProjectUpdate=<html><b>Project Needs Upgrading</b></html>\n\
87
    This project was created in an earlier version of NetBeans IDE. If you\n\
88
    edit its properties in NetBeans IDE {0}, the project will be upgraded and\n\
89
    <html><b>will no longer work in earlier versions of the IDE.</b></html>\n\n\
90
    Do you want to upgrade your project to version {0}?
91
TXT_ProjectUpdateTitle=Change Project Properties
92
CTL_UpdateOption=Upgrade Project
93
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 (-9 / +12 lines)
Lines 48-54 import java.util.*; Link Here
48
import java.util.*;
48
import java.util.*;
49
import org.apache.tools.ant.module.api.support.ActionUtils;
49
import org.apache.tools.ant.module.api.support.ActionUtils;
50
import org.netbeans.api.project.ProjectManager;
50
import org.netbeans.api.project.ProjectManager;
51
import org.netbeans.api.project.ProjectManager;
52
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
51
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
53
import org.netbeans.spi.project.ActionProvider;
52
import org.netbeans.spi.project.ActionProvider;
54
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
53
import org.netbeans.spi.project.ui.support.DefaultProjectOperations;
Lines 61-67 import org.openide.DialogDisplayer; Link Here
61
import org.openide.DialogDisplayer;
60
import org.openide.DialogDisplayer;
62
import org.openide.NotifyDescriptor;
61
import org.openide.NotifyDescriptor;
63
import org.openide.filesystems.*;
62
import org.openide.filesystems.*;
64
import org.openide.util.HelpCtx;
65
import org.openide.util.HelpCtx;
63
import org.openide.util.HelpCtx;
66
import org.openide.util.Lookup;
64
import org.openide.util.Lookup;
67
import org.openide.util.Mutex;
65
import org.openide.util.Mutex;
Lines 215-229 public class J2MEActionProvider implemen Link Here
215
                String activeConfiguration = confs.getActiveConfiguration() != confs.getDefaultConfiguration() ? confs.getActiveConfiguration().getDisplayName() : null;
213
                String activeConfiguration = confs.getActiveConfiguration() != confs.getDefaultConfiguration() ? confs.getActiveConfiguration().getDisplayName() : null;
216
                Properties p = new Properties();
214
                Properties p = new Properties();
217
                if ( command.equals( COMMAND_COMPILE_SINGLE ) ) {
215
                if ( command.equals( COMMAND_COMPILE_SINGLE ) ) {
218
                    String sDir = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
216
                    J2MESources sources = project.getLookup().lookup (J2MESources.class);
219
                    if (sDir != null) {
217
                    assert sources != null;
220
                        FileObject srcDir = helper.resolveFileObject(sDir);
218
                    StringBuilder includes = new StringBuilder();
221
                        if (srcDir != null) {
219
                    for (FileObject root : sources.getSourceRoots()) {
222
                            FileObject[] files = findSourcesAndPackages(context, srcDir);
220
                        FileObject[] found = findSourcesAndPackages(context, root);
223
                            if (files != null) {
221
                        if (found != null) {
224
                                p.setProperty("javac.includes", ActionUtils.antIncludesList(files, srcDir)); // NOI18N
222
                            if (includes.length() != 0) {
223
                                includes.append (',');
225
                            }
224
                            }
225
                            includes.append(ActionUtils.antIncludesList(found, root));
226
                        }
226
                        }
227
                    }
228
                    if (includes.length() > 0) {
229
                        p.setProperty ("javac.includes", includes.toString());
227
                    }
230
                    }
228
                } else if (COMMAND_DEBUG.equals(command)) {
231
                } else if (COMMAND_DEBUG.equals(command)) {
229
                    p.put(DefaultPropertiesDescriptor.OBFUSCATION_LEVEL, "0"); //NOI18N
232
                    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 59-64 public final class J2MEAntLogger extends Link Here
59
public final class J2MEAntLogger extends AntLogger {
60
public final class J2MEAntLogger extends AntLogger {
60
    
61
    
61
    private static final String separator = File.separatorChar == '\\' ? "\\\\" : "/"; //NOI18N
62
    private static final String separator = File.separatorChar == '\\' ? "\\\\" : "/"; //NOI18N
63
    //PENDING:  Determine if : is safe
64
    private static final char PATH_SEPARATOR = ':'; //NOI18N
62
    
65
    
63
    private static final Pattern PREPROCESSED = Pattern.compile(
66
    private static final Pattern PREPROCESSED = Pattern.compile(
64
            "^.*" + separator + "build(?:" + separator + "[a-zA-Z_$][a-zA-Z0-9_$]*)?" + separator + "preprocessed" + separator); // NOI18N
67
            "^.*" + separator + "build(?:" + separator + "[a-zA-Z_$][a-zA-Z0-9_$]*)?" + separator + "preprocessed" + separator); // NOI18N
Lines 77-99 public final class J2MEAntLogger extends Link Here
77
        return session.getVerbosity() < AntEvent.LOG_DEBUG;
80
        return session.getVerbosity() < AntEvent.LOG_DEBUG;
78
    }
81
    }
79
    
82
    
83
    @Override
80
    public boolean interestedInScript(File script, AntSession session) {
84
    public boolean interestedInScript(File script, AntSession session) {
81
        FileObject projfile = FileUtil.toFileObject(FileUtil.normalizeFile(script));
85
        FileObject projfile = FileUtil.toFileObject(FileUtil.normalizeFile(script));
82
        if (projfile == null) return false;
86
        if (projfile == null) return false;
83
        Project proj = FileOwnerQuery.getOwner(projfile);
87
        Project proj = FileOwnerQuery.getOwner(projfile);
84
        if (proj == null) return false;
88
        if (proj == null) return false;
89
        J2MESources sources = proj.getLookup().lookup (J2MESources.class);
90
        if (sources == null) return false;
91
        FileObject[] sourceRootFolders = sources.getSourceRoots();
92
93
        if (sourceRootFolders.length == 0) return false;
85
        AntProjectHelper helper = proj.getLookup().lookup(AntProjectHelper.class);
94
        AntProjectHelper helper = proj.getLookup().lookup(AntProjectHelper.class);
86
        if (helper == null) return false;
95
        if (helper == null) return false;
87
        String sourceRoot = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
96
88
        if (sourceRoot == null) return false;
97
        File[] rootsAsFiles = new File[sourceRootFolders.length];
89
        File srcRoot = helper.resolveFile(sourceRoot);
98
        StringBuilder paths = new StringBuilder();
90
        if (srcRoot == null) return false;
99
        for (int i = 0; i < rootsAsFiles.length; i++) {
100
            rootsAsFiles[i] = FileUtil.toFile(sourceRootFolders[i]);
101
            if (rootsAsFiles[i] == null) {
102
                return false;
103
            }
104
            if (paths.length() > 0) {
105
                paths.append (PATH_SEPARATOR);
106
            }
107
            paths.append (rootsAsFiles[i].getAbsolutePath().replaceAll(CHARSTOESCAPE, ESCAPESEQUENCE));
108
            paths.append (separator);
109
        }
110
91
        HashMap<File, String> roots = (HashMap)session.getCustomData(this);
111
        HashMap<File, String> roots = (HashMap)session.getCustomData(this);
92
        if (roots == null) {
112
        if (roots == null) {
93
            roots = new HashMap();
113
            roots = new HashMap();
94
            session.putCustomData(this, roots);
114
            session.putCustomData(this, roots);
95
        }
115
        }
96
        roots.put(script, srcRoot.getAbsolutePath().replaceAll(CHARSTOESCAPE, ESCAPESEQUENCE) + separator);
116
        roots.put(script, paths.toString());
97
        return true;
117
        return true;
98
    }
118
    }
99
    
119
    
Lines 121-127 public final class J2MEAntLogger extends Link Here
121
            srcRoot = (String)cd;
141
            srcRoot = (String)cd;
122
        if (srcRoot == null) return;
142
        if (srcRoot == null) return;
123
        String message = event.getMessage();
143
        String message = event.getMessage();
124
        String newMessage = PREPROCESSED.matcher(message).replaceFirst(srcRoot);
144
145
        Matcher matcher = PREPROCESSED.matcher(message);
146
        String newMessage = message;
147
        for (String path : srcRoot.split(":")) {
148
            newMessage = matcher.replaceFirst(path);
149
        }
125
        if (!message.equals(newMessage)) {
150
        if (!message.equals(newMessage)) {
126
            event.consume();
151
            event.consume();
127
            event.getSession().deliverMessageLogged(event, newMessage, event.getLogLevel());
152
            event.getSession().deliverMessageLogged(event, newMessage, event.getLogLevel());
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEProject.java (-55 / +113 lines)
Lines 57-66 import java.util.ArrayList; Link Here
57
import java.util.ArrayList;
57
import java.util.ArrayList;
58
import java.util.Arrays;
58
import java.util.Arrays;
59
import java.util.Collection;
59
import java.util.Collection;
60
import java.util.Collections;
61
import java.util.Enumeration;
60
import java.util.Enumeration;
62
import java.util.HashSet;
61
import java.util.HashSet;
63
import java.util.Iterator;
64
import java.util.LinkedList;
62
import java.util.LinkedList;
65
import java.util.List;
63
import java.util.List;
66
import java.util.Map;
64
import java.util.Map;
Lines 81-90 import org.netbeans.api.project.ProjectM Link Here
81
import org.netbeans.api.project.ProjectManager;
79
import org.netbeans.api.project.ProjectManager;
82
import org.netbeans.api.project.ant.AntArtifact;
80
import org.netbeans.api.project.ant.AntArtifact;
83
import org.netbeans.api.java.project.JavaProjectConstants;
81
import org.netbeans.api.java.project.JavaProjectConstants;
84
import org.netbeans.modules.j2me.cdc.platform.spi.CDCPlatformConfigurator;
85
import org.netbeans.modules.j2me.cdc.platform.spi.CDCPlatformUtil;
86
import org.netbeans.spi.mobility.project.ProjectPropertiesDescriptor;
82
import org.netbeans.spi.mobility.project.ProjectPropertiesDescriptor;
87
import org.netbeans.spi.mobility.project.support.DefaultPropertyParsers;
88
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
83
import org.netbeans.spi.mobility.project.ui.customizer.support.VisualPropertySupport;
89
import org.netbeans.spi.project.ProjectConfiguration;
84
import org.netbeans.spi.project.ProjectConfiguration;
90
import org.netbeans.api.project.ui.OpenProjects;
85
import org.netbeans.api.project.ui.OpenProjects;
Lines 97-106 import org.openide.filesystems.Repositor Link Here
97
import org.openide.filesystems.Repository;
92
import org.openide.filesystems.Repository;
98
import org.openide.loaders.DataFolder;
93
import org.openide.loaders.DataFolder;
99
import org.openide.loaders.DataObject;
94
import org.openide.loaders.DataObject;
95
import org.openide.util.Exceptions;
100
import org.openide.util.Lookup;
96
import org.openide.util.Lookup;
101
import org.openide.util.Lookup.Result;
102
import org.openide.util.RequestProcessor;
97
import org.openide.util.RequestProcessor;
103
import org.openide.util.WeakListeners;
104
import org.openide.util.lookup.Lookups;
98
import org.openide.util.lookup.Lookups;
105
import org.netbeans.modules.mobility.project.ui.J2MECustomizerProvider;
99
import org.netbeans.modules.mobility.project.ui.J2MECustomizerProvider;
106
import org.netbeans.modules.mobility.project.ui.J2MEPhysicalViewProvider;
100
import org.netbeans.modules.mobility.project.ui.J2MEPhysicalViewProvider;
Lines 109-121 import org.netbeans.spi.project.Auxiliar Link Here
109
import org.netbeans.spi.project.AuxiliaryConfiguration;
103
import org.netbeans.spi.project.AuxiliaryConfiguration;
110
import org.netbeans.api.project.ProjectInformation;
104
import org.netbeans.api.project.ProjectInformation;
111
import org.netbeans.modules.j2me.cdc.platform.CDCPlatform;
105
import org.netbeans.modules.j2me.cdc.platform.CDCPlatform;
106
import org.netbeans.modules.java.api.common.SourceRoots;
107
import org.netbeans.modules.java.api.common.ant.UpdateHelper;
108
import org.netbeans.modules.java.api.common.queries.QuerySupport;
112
import org.netbeans.modules.mobility.project.classpath.J2MEClassPathProvider;
109
import org.netbeans.modules.mobility.project.classpath.J2MEClassPathProvider;
113
import org.netbeans.modules.mobility.project.deployment.DeploymentPropertiesHandler;
110
import org.netbeans.modules.mobility.project.deployment.DeploymentPropertiesHandler;
114
import org.netbeans.modules.mobility.project.deployment.MobilityDeploymentProperties;
115
import org.netbeans.modules.mobility.project.queries.SourceLevelQueryImpl;
111
import org.netbeans.modules.mobility.project.queries.SourceLevelQueryImpl;
116
import org.netbeans.modules.mobility.project.queries.FileBuiltQueryImpl;
112
import org.netbeans.modules.mobility.project.queries.FileBuiltQueryImpl;
117
import org.netbeans.modules.mobility.project.queries.FileEncodingQueryImpl;
113
import org.netbeans.modules.mobility.project.queries.FileEncodingQueryImpl;
118
import org.netbeans.modules.mobility.project.security.KeyStoreRepository;
114
import org.netbeans.modules.mobility.project.security.KeyStoreRepository;
115
import org.netbeans.modules.mobility.project.ui.customizer.J2MEProjectProperties;
119
import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
116
import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
120
import org.netbeans.spi.mobility.deployment.DeploymentPlugin;
117
import org.netbeans.spi.mobility.deployment.DeploymentPlugin;
121
import org.netbeans.spi.mobility.project.ProjectLookupProvider;
118
import org.netbeans.spi.mobility.project.ProjectLookupProvider;
Lines 124-131 import org.netbeans.spi.project.support. Link Here
124
import org.netbeans.spi.project.support.ant.*;
121
import org.netbeans.spi.project.support.ant.*;
125
import org.netbeans.spi.project.ui.RecommendedTemplates;
122
import org.netbeans.spi.project.ui.RecommendedTemplates;
126
import org.netbeans.spi.project.ui.PrivilegedTemplates;
123
import org.netbeans.spi.project.ui.PrivilegedTemplates;
124
import org.netbeans.spi.project.ui.support.UILookupMergerSupport;
125
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
127
import org.openide.ErrorManager;
126
import org.openide.ErrorManager;
128
import org.openide.modules.InstalledFileLocator;
129
import org.openide.util.LookupEvent;
127
import org.openide.util.LookupEvent;
130
import org.openide.util.LookupListener;
128
import org.openide.util.LookupListener;
131
import org.openide.util.Mutex;
129
import org.openide.util.Mutex;
Lines 161-167 public final class J2MEProject implement Link Here
161
    Lookup lookup;
159
    Lookup lookup;
162
    final MIDletsCacheHelper midletsCacheHelper; 
160
    final MIDletsCacheHelper midletsCacheHelper; 
163
    final ProjectConfigurationsHelper configHelper;
161
    final ProjectConfigurationsHelper configHelper;
164
    
162
163
    private SourceRoots sourceRoots;
164
    private SourceRoots testSourceRoots;
165
166
    //XXX This pointlessly leaks FileObjects.  Cache paths instead. -Tim
165
    private static final Set<FileObject> roots = new HashSet<FileObject>();
167
    private static final Set<FileObject> roots = new HashSet<FileObject>();
166
    private static final Map<FileObject, Boolean> folders = new WeakHashMap<FileObject, Boolean>();
168
    private static final Map<FileObject, Boolean> folders = new WeakHashMap<FileObject, Boolean>();
167
    private final ReferenceHelper refHelper;
169
    private final ReferenceHelper refHelper;
Lines 206-214 public final class J2MEProject implement Link Here
206
        return result;
208
        return result;
207
    }
209
    }
208
    
210
    
209
    protected static void addRoots(final AntProjectHelper helper) {
211
    protected static void addRoots(AntProjectHelper helper, final SourceRoots roots) {
210
        final String src = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
212
        for (FileObject root : roots.getRoots()) {
211
        if (src != null) addRoot(helper.resolveFileObject(src));
213
            addRoot (root);
214
        }
212
    }
215
    }
213
    
216
    
214
    private static void addRoot(final FileObject fo) {
217
    private static void addRoot(final FileObject fo) {
Lines 243-262 public final class J2MEProject implement Link Here
243
        } catch (IOException ioe) {}
246
        } catch (IOException ioe) {}
244
        return false;
247
        return false;
245
    }
248
    }
246
    
249
250
    private final PropertyEvaluator evaluator;
251
247
    J2MEProject(AntProjectHelper helper) {
252
    J2MEProject(AntProjectHelper helper) {
248
        this.helper = helper;
253
        this.helper = helper;
249
        addRoots(helper);
250
        aux = helper.createAuxiliaryConfiguration();
254
        aux = helper.createAuxiliaryConfiguration();
251
        refHelper = new ReferenceHelper(helper, aux, helper.getStandardPropertyEvaluator());
255
        evaluator = helper.getStandardPropertyEvaluator();
252
        configHelper = new ProjectConfigurationsHelper(helper, this);
256
        configHelper = new ProjectConfigurationsHelper(helper, this);
253
        genFilesHelper = new GeneratedFilesHelper(helper);
257
        genFilesHelper = new GeneratedFilesHelper(helper);
254
        midletsCacheHelper = new MIDletsCacheHelper(helper, configHelper);
258
        midletsCacheHelper = new MIDletsCacheHelper(helper, configHelper);
255
        helper.addAntProjectListener(new CDCMainClassHelper(helper));
259
        helper.addAntProjectListener(new CDCMainClassHelper(this, helper));
256
        pcs = new PropertyChangeSupport(this);
260
        pcs = new PropertyChangeSupport(this);
257
        fileBuiltQuery = new FileBuiltQueryImpl(helper, configHelper);
261
        fileBuiltQuery = new FileBuiltQueryImpl(this, helper, configHelper);
262
        refHelper = new ReferenceHelper(helper, aux, evaluator());
258
        this.lookup = this.createLookup(aux);
263
        this.lookup = this.createLookup(aux);
259
        helper.addAntProjectListener(this);
264
        helper.addAntProjectListener(this);
265
        //XXX this aggresively initializes sourceRoots.  Can we delay for
266
        //project open safely?
267
        addRoots(helper, getSourceRoots());
268
    }
269
270
    public PropertyEvaluator evaluator() {
271
        return helper.getStandardPropertyEvaluator();
260
    }
272
    }
261
    
273
    
262
    public void hookNewProjectCreated() {
274
    public void hookNewProjectCreated() {
Lines 276-313 public final class J2MEProject implement Link Here
276
    }
288
    }
277
    
289
    
278
    private Lookup createLookup(final AuxiliaryConfiguration aux) {
290
    private Lookup createLookup(final AuxiliaryConfiguration aux) {
279
        final SourcesHelper sourcesHelper = new SourcesHelper(helper, helper.getStandardPropertyEvaluator());
291
        FileEncodingQueryImplementation encodingQuery = 
280
        sourcesHelper.addPrincipalSourceRoot("${src.dir}", NbBundle.getMessage(J2MEProject.class, "LBL_J2MEProject_Source_Packages"), /*XXX*/null, null); //NOI18N
292
                QuerySupport.createFileEncodingQuery(evaluator(),
281
        // XXX add build dir too?
293
                J2MEProjectProperties.SOURCE_ENCODING);
282
        sourcesHelper.addTypedSourceRoot("${src.dir}", JavaProjectConstants.SOURCES_TYPE_JAVA, NbBundle.getMessage(J2MEProject.class, "LBL_J2MEProject_Source_Packages"), /*XXX*/null, null); //NOI18N
283
        
284
        final SubprojectProvider spp = refHelper.createSubprojectProvider();
294
        final SubprojectProvider spp = refHelper.createSubprojectProvider();
285
        
295
        
286
        Object stdLookups[]=new Object[] {
296
        Object stdLookups[]=new Object[] {
287
            new Info(),
297
            new Info(),
288
            aux,
298
            aux,
299
            encodingQuery,
289
            spp,
300
            spp,
290
            new J2MEActionProvider( this, helper ),
301
            new J2MEActionProvider( this, helper ),
291
            new J2MEPhysicalViewProvider(this, helper, refHelper, configHelper),
302
            new J2MEPhysicalViewProvider(this, helper, refHelper, configHelper),
292
            new J2MECustomizerProvider( this, helper, refHelper, configHelper),
303
            new J2MECustomizerProvider( this, helper, refHelper, configHelper),
293
            new J2MEClassPathProvider(helper),
304
            new J2MEClassPathProvider(helper, getSourceRoots(), getTestSourceRoots()),
294
            new CompiledSourceForBinaryQuery(this, helper),
305
            new CompiledSourceForBinaryQuery(this, helper),
295
            new AntArtifactProviderImpl(),
306
            new AntArtifactProviderImpl(),
296
            new ProjectXmlSavedHookImpl(),
307
            new ProjectXmlSavedHookImpl(),
297
            new ProjectOpenedHookImpl(),
298
            new JavadocForBinaryQueryImpl(this, helper),
308
            new JavadocForBinaryQueryImpl(this, helper),
299
            helper.createSharabilityQuery(helper.getStandardPropertyEvaluator(), new String[]{"${src.dir}"}, new String[]{"${dist.root.dir}", "${build.root.dir}", "${deployment.copy.target}"}), //NOI18N
309
            //XXX does not handle deployment.copy.target yet
310
            QuerySupport.createSharabilityQuery(helper, evaluator(), getSourceRoots(), getTestSourceRoots()),
311
//            helper.createSharabilityQuery(evaluator(),
312
//                    new String[]{"${src.dir}"},
313
//                    new String[]{"${dist.root.dir}",
314
//                    "${build.root.dir}",
315
//                    "${deployment.copy.target}"}), //NOI18N
300
            configHelper,
316
            configHelper,
301
            helper,
317
            helper,
302
            sourcesHelper.createSources(),
318
            new J2MESources(helper, evaluator(), sourceRoots, getTestSourceRoots()),
303
            new RecommendedTemplatesImpl(),
319
            new RecommendedTemplatesImpl(),
304
            new SourceLevelQueryImpl(helper),
320
            new SourceLevelQueryImpl(helper),
305
            midletsCacheHelper,
321
            midletsCacheHelper,
306
            fileBuiltQuery,
322
            fileBuiltQuery,
307
            refHelper,
323
            refHelper,
324
            UILookupMergerSupport.createProjectOpenHookMerger(new ProjectOpenedHookImpl()),
325
308
            new J2MEProjectClassPathExtender(this, helper, refHelper, configHelper),
326
            new J2MEProjectClassPathExtender(this, helper, refHelper, configHelper),
309
            new J2MEProjectOperations(this, helper, refHelper),
327
            new J2MEProjectOperations(this, helper, refHelper),
310
            new PreprocessorFileFilterImplementation(configHelper, helper),
328
            new PreprocessorFileFilterImplementation(configHelper, helper),
329
            QuerySupport.createTemplateAttributesProvider(helper, encodingQuery),
311
            new FileEncodingQueryImpl(helper)
330
            new FileEncodingQueryImpl(helper)
312
        };
331
        };
313
        ArrayList<Object> list=new ArrayList<Object>();
332
        ArrayList<Object> list=new ArrayList<Object>();
Lines 319-324 public final class J2MEProject implement Link Here
319
        return Lookups.fixed(list.toArray());
338
        return Lookups.fixed(list.toArray());
320
        
339
        
321
    }
340
    }
341
342
    public synchronized SourceRoots getSourceRoots() {
343
        if (this.sourceRoots == null) { //Local caching, no project metadata access
344
            this.sourceRoots = SourceRoots.create(new UpdateHelper(new Updater(this, helper, aux), helper),
345
                    evaluator(),
346
                    refHelper,
347
                    J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
348
                    "source-roots", false, "src.{0}{1}.dir"); //NOI18N
349
       }
350
        return this.sourceRoots;
351
    }
352
353
    public synchronized SourceRoots getTestSourceRoots() {
354
        if (this.testSourceRoots == null) { //Local caching, no project metadata access
355
            this.testSourceRoots = SourceRoots.create(new UpdateHelper(new Updater(this, helper, aux), helper),
356
                    evaluator(),
357
                    refHelper,
358
                    J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
359
                    "test-roots", false, "src.{0}{1}.dir"); //NOI18N
360
       }
361
        return this.testSourceRoots;
362
    }
363
322
    
364
    
323
    /** Store configured project name. */
365
    /** Store configured project name. */
324
    public void setName(final String name) {
366
    public void setName(final String name) {
Lines 326-332 public final class J2MEProject implement Link Here
326
            public Object run() {
368
            public Object run() {
327
                final Element data = helper.getPrimaryConfigurationData(true);
369
                final Element data = helper.getPrimaryConfigurationData(true);
328
                // XXX replace by XMLUtil when that has findElement, findText, etc.
370
                // XXX replace by XMLUtil when that has findElement, findText, etc.
329
                final NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name");
371
                final NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "name");
330
                Element nameEl;
372
                Element nameEl;
331
                if (nl.getLength() == 1) {
373
                if (nl.getLength() == 1) {
332
                    nameEl = (Element) nl.item(0);
374
                    nameEl = (Element) nl.item(0);
Lines 335-341 public final class J2MEProject implement Link Here
335
                        nameEl.removeChild(deadKids.item(0));
377
                        nameEl.removeChild(deadKids.item(0));
336
                    }
378
                    }
337
                } else {
379
                } else {
338
                    nameEl = data.getOwnerDocument().createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name");
380
                    nameEl = data.getOwnerDocument().createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "name");
339
                    data.insertBefore(nameEl, /* OK if null */data.getChildNodes().item(0));
381
                    data.insertBefore(nameEl, /* OK if null */data.getChildNodes().item(0));
340
                }
382
                }
341
                nameEl.appendChild(data.getOwnerDocument().createTextNode(name));
383
                nameEl.appendChild(data.getOwnerDocument().createTextNode(name));
Lines 450-456 public final class J2MEProject implement Link Here
450
            public String run() {
492
            public String run() {
451
                final Element data = helper.getPrimaryConfigurationData(true);
493
                final Element data = helper.getPrimaryConfigurationData(true);
452
                // XXX replace by XMLUtil when that has findElement, findText, etc.
494
                // XXX replace by XMLUtil when that has findElement, findText, etc.
453
                NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N
495
                NodeList nl = data.getElementsByTagNameNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N
496
                if (nl.getLength() == 0) {
497
                    nl = data.getElementsByTagNameNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name");
498
                }
454
                if (nl.getLength() == 1) {
499
                if (nl.getLength() == 1) {
455
                    nl = nl.item(0).getChildNodes();
500
                    nl = nl.item(0).getChildNodes();
456
                    if (nl.getLength() == 1 && nl.item(0).getNodeType() == Node.TEXT_NODE) {
501
                    if (nl.getLength() == 1 && nl.item(0).getNodeType() == Node.TEXT_NODE) {
Lines 543-548 public final class J2MEProject implement Link Here
543
        }
588
        }
544
        
589
        
545
        protected synchronized void projectOpened() {
590
        protected synchronized void projectOpened() {
591
            UpdateHelper updater = getLookup().lookup(UpdateHelper.class);
592
            assert updater != null;
593
            try {
594
                if (!updater.isCurrent()) {
595
                    updater.requestUpdate();
596
                }
597
            } catch (IOException ex) {
598
                Exceptions.printStackTrace(ex);
599
            }
546
            //inicialize deployment plugins
600
            //inicialize deployment plugins
547
            deployments = Lookup.getDefault().lookup(new Lookup.Template<DeploymentPlugin>(DeploymentPlugin.class));
601
            deployments = Lookup.getDefault().lookup(new Lookup.Template<DeploymentPlugin>(DeploymentPlugin.class));
548
            deployments.addLookupListener(this);
602
            deployments.addLookupListener(this);
Lines 550-582 public final class J2MEProject implement Link Here
550
            //init keystore, safer than warmup
604
            //init keystore, safer than warmup
551
            KeyStoreRepository.getDefault();
605
            KeyStoreRepository.getDefault();
552
            // Check up on build scripts.
606
            // Check up on build scripts.
553
            addRoots(helper);
607
            addRoots(helper, getSourceRoots());
554
            final SourcesHelper sourcesHelper = getLookup().lookup(SourcesHelper.class);
608
            final SourcesHelper sourcesHelper = getLookup().lookup(SourcesHelper.class);
555
            final String srcDir = helper.getStandardPropertyEvaluator().getProperty(DefaultPropertiesDescriptor.SRC_DIR);
609
556
            final FileObject srcRoot = srcDir == null ? null : helper.resolveFileObject(srcDir);
610
            J2MESources sources = getLookup().lookup(J2MESources.class);
557
            final Project other = srcRoot == null ? null : FileOwnerQuery.getOwner(srcRoot);
611
            Set<Project> notified = new HashSet<Project>();
558
            if (other != null && !J2MEProject.this.equals(other)) {
612
            for (FileObject srcRoot : sources.getSourceRoots()) {
559
                if (Arrays.asList(OpenProjects.getDefault().getOpenProjects()).contains(other)) {
613
                Project other = srcRoot == null ? null : FileOwnerQuery.getOwner(srcRoot);
560
                    final ProjectInformation pi = other.getLookup().lookup(ProjectInformation.class);
614
                if (other != null && !J2MEProject.this.equals(other) && !notified.contains(other)) {
561
                    final String name = pi == null ? other.getProjectDirectory().getPath() : pi.getDisplayName();
615
                    if (Arrays.asList(OpenProjects.getDefault().getOpenProjects()).contains(other)) {
562
                    if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(
616
                        notified.add(other);
563
                            new NotifyDescriptor.Confirmation(NbBundle.getMessage(J2MEProject.class, "MSG_ClashingSourceRoots", J2MEProject.this.getName(), name), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.WARNING_MESSAGE)))) { //NOI18N
617
                        final ProjectInformation pi = other.getLookup().lookup(ProjectInformation.class);
564
                        OpenProjects.getDefault().close(new Project[]{other});
618
                        final String name = pi == null ? other.getProjectDirectory().getPath() : pi.getDisplayName();
565
                    } else {
619
                        if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(
566
                        skipCloseHook = true;
620
                                new NotifyDescriptor.Confirmation(NbBundle.getMessage(J2MEProject.class, "MSG_ClashingSourceRoots", J2MEProject.this.getName(), name), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.WARNING_MESSAGE)))) { //NOI18N
567
                        OpenProjects.getDefault().close(new Project[]{J2MEProject.this});
621
                            OpenProjects.getDefault().close(new Project[]{other});
568
                        return;
622
                        } else {
623
                            skipCloseHook = true;
624
                            OpenProjects.getDefault().close(new Project[]{J2MEProject.this});
625
                            return;
626
                        }
569
                    }
627
                    }
570
                }
628
                }
629
                final FileObject sourceRoot = srcRoot;
630
                ProjectManager.mutex().postWriteRequest(new Runnable() {
631
                    public void run() {
632
                        try {
633
                            if (sourcesHelper != null) sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
634
                        } catch (IllegalStateException ise) {}
635
                        if (sourceRoot != null) FileOwnerQuery.markExternalOwner(sourceRoot, J2MEProject.this, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
636
                    }
637
                });
571
            }
638
            }
572
            ProjectManager.mutex().postWriteRequest(new Runnable() {
573
                public void run() {
574
                    try {
575
                        if (sourcesHelper != null) sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
576
                    } catch (IllegalStateException ise) {}
577
                    if (srcRoot != null) FileOwnerQuery.markExternalOwner(srcRoot, J2MEProject.this, FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
578
                }
579
            });
580
            try {
639
            try {
581
                refreshBuildScripts(true);
640
                refreshBuildScripts(true);
582
                refreshPrivateProperties();
641
                refreshPrivateProperties();
Lines 739-748 public final class J2MEProject implement Link Here
739
        }
798
        }
740
        
799
        
741
        public URI[] getArtifactLocations() {
800
        public URI[] getArtifactLocations() {
742
            final PropertyEvaluator eval = helper.getStandardPropertyEvaluator();
743
            String path = "dist/"; //NOI18N
801
            String path = "dist/"; //NOI18N
744
            if (configuration != null) path += configuration + "/"; //NOI18N
802
            if (configuration != null) path += configuration + "/"; //NOI18N
745
            final String locationResolved = eval.evaluate(path + J2MEProjectUtils.evaluateProperty(helper, "dist.jar", configuration)); //NOI18N
803
            final String locationResolved = evaluator().evaluate(path + J2MEProjectUtils.evaluateProperty(helper, "dist.jar", configuration)); //NOI18N
746
            if (locationResolved == null) {
804
            if (locationResolved == null) {
747
                return new URI[0];
805
                return new URI[0];
748
            }
806
            }
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/J2MEProjectGenerator.java (-5 / +14 lines)
Lines 219-228 public class J2MEProjectGenerator { Link Here
219
        final AntProjectHelper oldHelper = oldProject.getLookup().lookup(AntProjectHelper.class);
219
        final AntProjectHelper oldHelper = oldProject.getLookup().lookup(AntProjectHelper.class);
220
        final Element data = h.getPrimaryConfigurationData(true);
220
        final Element data = h.getPrimaryConfigurationData(true);
221
        final Document doc = data.getOwnerDocument();
221
        final Document doc = data.getOwnerDocument();
222
        final Element nameEl = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
222
        final Element nameEl = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
223
        nameEl.appendChild(doc.createTextNode(name));
223
        nameEl.appendChild(doc.createTextNode(name));
224
        data.appendChild(nameEl);
224
        data.appendChild(nameEl);
225
        final Element minant = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
225
        final Element minant = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
226
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
226
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
227
        data.appendChild(minant);
227
        data.appendChild(minant);
228
        h.putPrimaryConfigurationData(data, true);
228
        h.putPrimaryConfigurationData(data, true);
Lines 404-415 public class J2MEProjectGenerator { Link Here
404
        final AntProjectHelper h = ProjectGenerator.createProject(projectLocation, J2MEProjectType.TYPE);
404
        final AntProjectHelper h = ProjectGenerator.createProject(projectLocation, J2MEProjectType.TYPE);
405
        final Element data = h.getPrimaryConfigurationData(true);
405
        final Element data = h.getPrimaryConfigurationData(true);
406
        final Document doc = data.getOwnerDocument();
406
        final Document doc = data.getOwnerDocument();
407
        final Element nameEl = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
407
        final Element nameEl = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, NAME); // NOI18N
408
        nameEl.appendChild(doc.createTextNode(name));
408
        nameEl.appendChild(doc.createTextNode(name));
409
        data.appendChild(nameEl);
409
        data.appendChild(nameEl);
410
        final Element minant = doc.createElementNS(J2MEProjectType.PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
410
        
411
        final Element srcRoots = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "source-roots");
412
        final Element defaultRoot = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "root");
413
        defaultRoot.setAttribute("id", "src.dir");
414
        srcRoots.appendChild(defaultRoot);
415
        data.appendChild(srcRoots);
416
417
        final Element minant = doc.createElementNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
411
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
418
        minant.appendChild(doc.createTextNode("1.6")); // NOI18N
412
        data.appendChild(minant);
419
        data.appendChild(minant);
420
413
        h.putPrimaryConfigurationData(data, true);
421
        h.putPrimaryConfigurationData(data, true);
414
        EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
422
        EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
415
        EditableProperties priv = h.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
423
        EditableProperties priv = h.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
Lines 869-874 public class J2MEProjectGenerator { Link Here
869
        return null;
877
        return null;
870
    }
878
    }
871
    
879
    
880
    @SuppressWarnings("empty-statement")
872
    private static FileObject createProjectLocation(File dir) throws IOException {
881
    private static FileObject createProjectLocation(File dir) throws IOException {
873
        dir = dir.getCanonicalFile();
882
        dir = dir.getCanonicalFile();
874
        File rootF = dir;
883
        File rootF = dir;
Lines 1132-1138 public class J2MEProjectGenerator { Link Here
1132
    protected static void fillMissingMIDlets(final Project project, final AntProjectHelper helper) {
1141
    protected static void fillMissingMIDlets(final Project project, final AntProjectHelper helper) {
1133
        final ReferenceHelper refHelper = project.getLookup().lookup(ReferenceHelper.class);
1142
        final ReferenceHelper refHelper = project.getLookup().lookup(ReferenceHelper.class);
1134
        final ProjectConfigurationsHelper confHelper = project.getLookup().lookup(ProjectConfigurationsHelper.class);
1143
        final ProjectConfigurationsHelper confHelper = project.getLookup().lookup(ProjectConfigurationsHelper.class);
1135
        final MIDletScanner scanner = MIDletScanner.getDefault(new J2MEProjectProperties(project, helper, refHelper, confHelper));
1144
        final MIDletScanner scanner = MIDletScanner.getDefault(new J2MEProjectProperties((J2MEProject) project, helper, refHelper, confHelper));
1136
        final DefaultComboBoxModel midlets = new DefaultComboBoxModel();
1145
        final DefaultComboBoxModel midlets = new DefaultComboBoxModel();
1137
        scanner.scan(midlets, null, null,
1146
        scanner.scan(midlets, null, null,
1138
                     new ChangeListener() {
1147
                     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 52-58 public final class J2MEProjectType imple Link Here
52
    
52
    
53
    public static final String TYPE = "org.netbeans.modules.kjava.j2meproject";  //NOI18N
53
    public static final String TYPE = "org.netbeans.modules.kjava.j2meproject";  //NOI18N
54
    private static final String PROJECT_CONFIGURATION_NAME = "data";  //NOI18N
54
    private static final String PROJECT_CONFIGURATION_NAME = "data";  //NOI18N
55
    @Deprecated
55
    public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project";  //NOI18N
56
    public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project";  //NOI18N
57
    public static final String MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/multiroot-j2me-project";  //NOI18N
56
    private static final String PRIVATE_CONFIGURATION_NAME = "data";  //NOI18N
58
    private static final String PRIVATE_CONFIGURATION_NAME = "data";  //NOI18N
57
    private static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project-private";  //NOI18N
59
    private static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2me-project-private";  //NOI18N
58
    
60
    
Lines 69-75 public final class J2MEProjectType imple Link Here
69
    }
71
    }
70
    
72
    
71
    public String getPrimaryConfigurationDataElementNamespace(final boolean shared) {
73
    public String getPrimaryConfigurationDataElementNamespace(final boolean shared) {
72
        return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
74
//        return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
75
        return shared ? MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
73
    }
76
    }
74
    
77
    
75
}
78
}
(-)ea8899550edd (+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;
(-)ea8899550edd (+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 / +141 lines)
Lines 41-51 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.SourcePathImplementation;
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;
50
import org.netbeans.spi.java.classpath.ClassPathProvider;
58
import org.netbeans.spi.java.classpath.ClassPathProvider;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
59
import org.netbeans.spi.project.support.ant.AntProjectHelper;
Lines 53-58 import org.netbeans.spi.project.support. Link Here
53
import org.netbeans.spi.project.support.ant.PropertyUtils;
61
import org.netbeans.spi.project.support.ant.PropertyUtils;
54
import org.openide.filesystems.FileObject;
62
import org.openide.filesystems.FileObject;
55
import org.openide.filesystems.FileUtil;
63
import org.openide.filesystems.FileUtil;
64
import org.openide.util.Mutex;
56
import org.openide.util.WeakListeners;
65
import org.openide.util.WeakListeners;
57
66
58
/**
67
/**
Lines 62-74 public class J2MEClassPathProvider imple Link Here
62
public class J2MEClassPathProvider implements ClassPathProvider {
71
public class J2MEClassPathProvider implements ClassPathProvider {
63
    
72
    
64
    private SoftReference<ClassPath> ctcp, rtcp, sp, bcp;    
73
    private SoftReference<ClassPath> ctcp, rtcp, sp, bcp;    
65
    private FileObject srcDir;
66
    
74
    
67
    protected final AntProjectHelper helper;
75
    protected final AntProjectHelper helper;
76
    private final SourceRoots sourceRoots;
77
    private final SourceRoots testSourceRoots;
68
    
78
    
69
    /** Do nothing */
79
    /** Do nothing */
70
    public J2MEClassPathProvider(AntProjectHelper helper) {
80
    public J2MEClassPathProvider(AntProjectHelper helper, SourceRoots sourceRoots, SourceRoots testRoots) {
71
        this.helper = helper;
81
        this.helper = helper;
82
        this.sourceRoots = sourceRoots;
83
        this.testSourceRoots = testRoots;
72
    }
84
    }
73
    
85
    
74
    public ClassPath findClassPath(final FileObject file, final String type) {
86
    public ClassPath findClassPath(final FileObject file, final String type) {
Lines 76-94 public class J2MEClassPathProvider imple Link Here
76
        if (!checkSrcParent(file)) return null;
88
        if (!checkSrcParent(file)) return null;
77
        if (type.equals(ClassPath.COMPILE)) return getCompileTimeClasspath();
89
        if (type.equals(ClassPath.COMPILE)) return getCompileTimeClasspath();
78
        if (type.equals(ClassPath.EXECUTE)) return getRunTimeClasspath();
90
        if (type.equals(ClassPath.EXECUTE)) return getRunTimeClasspath();
79
        if (type.equals(ClassPath.SOURCE)) return getSourcepath();
91
        if (type.equals(ClassPath.SOURCE)) return getSourcepath(0);
80
        // Unrecognized type, ignore.
92
        // Unrecognized type, ignore.
81
        return null;
93
        return null;
82
    }
94
    }
83
    
95
    
84
    public boolean checkSrcParent(final FileObject file) {
96
    public boolean checkSrcParent(final FileObject file) {
85
        if (srcDir == null || !srcDir.isValid()) {
97
        for (FileObject root : sourceRoots.getRoots()) {
86
            final String prop = helper.getStandardPropertyEvaluator().getProperty("src.dir"); //NOI18N
98
            if (root.equals(file) || FileUtil.isParentOf(root, file)) {
87
            if (prop != null) {
99
                return true;
88
                srcDir = helper.resolveFileObject(prop);
89
            }
100
            }
90
        }
101
        }
91
        return (srcDir != null && file != null && (srcDir.equals(file) || FileUtil.isParentOf(srcDir, file)));
102
        return false;
92
    }
103
    }
93
    
104
    
94
    public ClassPath getCompileTimeClasspath() {
105
    public ClassPath getCompileTimeClasspath() {
Lines 107-112 public class J2MEClassPathProvider imple Link Here
107
        }
118
        }
108
        return cp;
119
        return cp;
109
    }
120
    }
121
122
    //COPIED FROM J2SEPROJECT
123
    /**
124
     * Find what a given file represents.
125
     * @param file a file in the project
126
     * @return one of: <dl>
127
     *         <dt>0</dt> <dd>normal source</dd>
128
     *         <dt>1</dt> <dd>test source</dd>
129
     *         <dt>2</dt> <dd>built class (unpacked)</dd>
130
     *         <dt>3</dt> <dd>built test class</dd>
131
     *         <dt>4</dt> <dd>built class (in dist JAR)</dd>
132
     *         <dt>-1</dt> <dd>something else</dd>
133
     *         </dl>
134
     */
135
    private int getType(FileObject file) {
136
        FileObject[] srcPath = getPrimarySrcPath();
137
        for (int i=0; i < srcPath.length; i++) {
138
            FileObject root = srcPath[i];
139
            if (root.equals(file) || FileUtil.isParentOf(root, file)) {
140
                return 0;
141
            }
142
        }
143
        srcPath = getTestSrcDir();
144
        for (int i=0; i< srcPath.length; i++) {
145
            FileObject root = srcPath[i];
146
            if (root.equals(file) || FileUtil.isParentOf(root, file)) {
147
                return 1;
148
            }
149
        }
150
        FileObject dir = getBuildClassesDir();
151
        if (dir != null && (dir.equals(file) || FileUtil.isParentOf(dir, file))) {
152
            return 2;
153
        }
154
        dir = getDistJar(); // not really a dir at all, of course
155
        if (dir != null && dir.equals(FileUtil.getArchiveFile(file))) {
156
            // XXX check whether this is really the root
157
            return 4;
158
        }
159
        dir = getBuildTestClassesDir();
160
        if (dir != null && (dir.equals(file) || FileUtil.isParentOf(dir,file))) {
161
            return 3;
162
        }
163
        return -1;
164
    }
165
166
    private static final String BUILD_CLASSES_DIR = "build.classes.dir"; // NOI18N
167
    private static final String DIST_JAR = DefaultPropertiesDescriptor.DIST_JAR;
168
    private static final String BUILD_TEST_CLASSES_DIR = "build.test.classes.dir"; // NOI18N
169
    private FileObject getBuildClassesDir() {
170
        return getDir(BUILD_CLASSES_DIR);
171
    }
172
173
    private FileObject getDistJar() {
174
        return getDir(DIST_JAR);
175
    }
176
177
    private FileObject getBuildTestClassesDir() {
178
        //XXX probably want test and build dirs the same for ME?
179
        return getDir(BUILD_TEST_CLASSES_DIR);
180
    }
181
182
    private final ClassPath[] cache = new ClassPath[8];
183
    private final Map<String,FileObject> dirCache = new HashMap<String,FileObject>();
184
    private FileObject getDir(final String propname) {
185
        return ProjectManager.mutex().readAccess(new Mutex.Action<FileObject>() {
186
            public FileObject run() {
187
                synchronized (J2MEClassPathProvider.this) {
188
                    FileObject fo = (FileObject) J2MEClassPathProvider.this.dirCache.get (propname);
189
                    if (fo == null ||  !fo.isValid()) {
190
                        String prop = helper.getStandardPropertyEvaluator().getProperty(propname);
191
                        if (prop != null) {
192
                            fo = helper.resolveFileObject(prop);
193
                            J2MEClassPathProvider.this.dirCache.put (propname, fo);
194
                        }
195
                    }
196
                    return fo;
197
                }
198
            }});
199
    }
200
201
    private FileObject[] getPrimarySrcPath() {
202
        return this.sourceRoots.getRoots();
203
    }
204
205
    private FileObject[] getTestSrcDir() {
206
        return this.testSourceRoots.getRoots();
207
    }
208
209
    public ClassPath getSourcepath() {
210
        return getSourcepath(0);
211
    }
212
213
    private synchronized ClassPath getSourcepath(int type) {
214
        System.err.println("getSourcePath " + type);
215
        if (type < 0 || type > 1) {
216
            return null;
217
        }
218
        ClassPath cp = cache[type];
219
        if (cp == null) {
220
            switch (type) {
221
                case 0:
222
                    cp = ClassPathFactory.createClassPath(
223
                            new SourcePathImplementation (sourceRoots,
224
                            helper, helper.getStandardPropertyEvaluator()));
225
                    System.err.println("Returning " + cp);
226
                    System.err.println("  entries:  "  + cp.entries());
227
                    break;
228
                case 1:
229
                    cp = ClassPathFactory.createClassPath(
230
                            new SourcePathImplementation (
231
                            testSourceRoots, helper,
232
                            helper.getStandardPropertyEvaluator()));
233
                    break;
234
            }
235
        }
236
        cache[type] = cp;
237
        return cp;
238
    }
239
240
    //END COPY
110
    
241
    
111
    public ClassPath getRunTimeClasspath() {
242
    public ClassPath getRunTimeClasspath() {
112
        ClassPath cp = null;
243
        ClassPath cp = null;
Lines 114-141 public class J2MEClassPathProvider imple Link Here
114
            cp = ClassPathFactory.createClassPath(
245
            cp = ClassPathFactory.createClassPath(
115
                    new ProjectClassPathImplementation(helper) {
246
                    new ProjectClassPathImplementation(helper) {
116
                protected String evaluatePath() {
247
                protected String evaluatePath() {
117
                    String cp = helper.getStandardPropertyEvaluator().getProperty("build.classes.dir"); //NOI18N
248
                    String cp = helper.getStandardPropertyEvaluator().getProperty(
249
                            J2MEProjectProperties.BUILD_CLASSES_DIR);
118
                    if (cp != null) cp = helper.resolvePath(cp);
250
                    if (cp != null) cp = helper.resolvePath(cp);
119
                    return cp;
251
                    return cp;
120
                }
252
                }
121
            });
253
            });
122
            rtcp = new SoftReference<ClassPath>(cp);
254
            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
        }
255
        }
140
        return cp;
256
        return cp;
141
    }
257
    }
(-)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
(-)ea8899550edd (+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/J2MEPhysicalViewProvider.java (-26 / +75 lines)
Lines 40-45 Link Here
40
 */
40
 */
41
41
42
package org.netbeans.modules.mobility.project.ui;
42
package org.netbeans.modules.mobility.project.ui;
43
import java.awt.Image;
43
import java.io.CharConversionException;
44
import java.io.CharConversionException;
44
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeListener;
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeEvent;
Lines 75-89 import org.openide.util.Utilities; Link Here
75
import org.openide.util.Utilities;
76
import org.openide.util.Utilities;
76
import org.openide.util.actions.SystemAction;
77
import org.openide.util.actions.SystemAction;
77
import org.openide.util.lookup.ProxyLookup;
78
import org.openide.util.lookup.ProxyLookup;
78
import javax.swing.*;
79
import java.awt.*;
80
import java.awt.event.ActionEvent;
79
import java.awt.event.ActionEvent;
81
import java.util.ArrayList;
80
import java.util.ArrayList;
81
import java.util.Arrays;
82
import java.util.Collection;
82
import java.util.Collection;
83
import java.util.Collections;
83
import java.util.Collections;
84
import java.util.Enumeration;
84
import java.util.Enumeration;
85
import java.util.HashMap;
85
import java.util.HashMap;
86
import java.util.LinkedList;
87
import java.util.List;
86
import java.util.ResourceBundle;
88
import java.util.ResourceBundle;
89
import javax.swing.AbstractAction;
90
import javax.swing.Action;
91
import org.netbeans.api.java.project.JavaProjectConstants;
92
import org.netbeans.modules.java.api.common.SourceRoots;
93
import org.netbeans.modules.mobility.project.J2MESources;
87
import org.openide.util.WeakListeners;
94
import org.openide.util.WeakListeners;
88
import org.openide.util.lookup.Lookups;
95
import org.openide.util.lookup.Lookups;
89
import org.openide.xml.XMLUtil;
96
import org.openide.xml.XMLUtil;
Lines 146-151 public class J2MEPhysicalViewProvider im Link Here
146
    protected String[] getBreakableProperties() {
153
    protected String[] getBreakableProperties() {
147
        final ProjectConfiguration pc[] = pcp.getConfigurations().toArray(new ProjectConfiguration[0]);
154
        final ProjectConfiguration pc[] = pcp.getConfigurations().toArray(new ProjectConfiguration[0]);
148
        String s[] = new String[2*pc.length+1];
155
        String s[] = new String[2*pc.length+1];
156
        //XXX fix for multiple roots - need to handle src.*.dir
149
        s[0] = DefaultPropertiesDescriptor.SRC_DIR;
157
        s[0] = DefaultPropertiesDescriptor.SRC_DIR;
150
        for (int i= 0; i<pc.length; i++) {
158
        for (int i= 0; i<pc.length; i++) {
151
            if (pcp.getDefaultConfiguration().equals(pc[i])) {
159
            if (pcp.getDefaultConfiguration().equals(pc[i])) {
Lines 193-203 public class J2MEPhysicalViewProvider im Link Here
193
    }
201
    }
194
202
195
    // Private innerclasses ----------------------------------------------------
203
    // Private innerclasses ----------------------------------------------------
196
    final class LogicalViewChildren extends Children.Keys  
204
    static final class LogicalViewChildren extends Children.Keys implements PropertyChangeListener
197
    {
205
    {
198
        final private J2MEProject project;
206
        public static final String CONFIGURATIONS = "Configurations"; //NOI18N
207
        public static final String RESOURCES = "Resources"; //NOI18N
208
        public static final String SOURCES = "Sources"; //NOI18N
209
        private final J2MEProject project;
199
        final private NodeCache cache;
210
        final private NodeCache cache;
200
        final private HashMap<String,ChildLookup> keyMap = new HashMap<String,ChildLookup>();
211
        final private HashMap<String,ChildLookup> keyMap = new HashMap<String,ChildLookup>();
212
213
        public void propertyChange(PropertyChangeEvent evt) {
214
            if (SourceRoots.PROP_ROOTS.equals(evt.getPropertyName())) {
215
                System.err.println("Got property change from " + evt.getSource() + " with " + evt.getPropertyName());
216
                refreshKey (SOURCES);
217
            }
218
        }
201
        
219
        
202
        private class CfgListener implements PropertyChangeListener, Runnable {
220
        private class CfgListener implements PropertyChangeListener, Runnable {
203
            public void propertyChange(PropertyChangeEvent evt) {
221
            public void propertyChange(PropertyChangeEvent evt) {
Lines 211-259 public class J2MEPhysicalViewProvider im Link Here
211
        
229
        
212
        LogicalViewChildren(J2MEProject proj)
230
        LogicalViewChildren(J2MEProject proj)
213
        {
231
        {
214
            project=proj;
232
            this.project = proj;
215
            cache=new NodeCache(proj);
233
            cache=new NodeCache(proj);
216
            keyMap.put("Sources",new SourcesViewProvider());
234
            keyMap.put(RESOURCES, new ResViewProvider(cache));
217
            keyMap.put("Resources",new ResViewProvider(cache));
235
            keyMap.put(CONFIGURATIONS, new LibResViewProvider(cache));
218
            keyMap.put("Configurations",new LibResViewProvider(cache));
219
            project.getConfigurationHelper().addPropertyChangeListener(new CfgListener());            
236
            project.getConfigurationHelper().addPropertyChangeListener(new CfgListener());            
220
            setKeys(getKeys());            
237
        }
238
239
        @Override
240
        protected void addNotify() {
241
            super.addNotify();
242
            setKeys(getKeys());
243
            project.getSourceRoots().addPropertyChangeListener(this);
244
        }
245
246
        @Override
247
        protected void removeNotify() {
248
            project.getSourceRoots().removePropertyChangeListener(this);
249
            setKeys (Collections.EMPTY_LIST);
250
            super.removeNotify();
221
        }
251
        }
222
        
252
        
223
        public void refreshResources()
253
        public void refreshResources()
224
        {
254
        {
225
            refreshKey("Resources");
255
            refreshKey(RESOURCES);
226
        }
256
        }
227
        
257
        
228
        public void refreshConfigurations()
258
        public void refreshConfigurations()
229
        {
259
        {
230
            refreshKey("Configurations");
260
            refreshKey(CONFIGURATIONS);
231
        }
261
        }
232
        
262
        
233
        public void refreshNode(String name)
263
        public void refreshNode(String name)
234
        {
264
        {
235
            cache.update(name);
265
            if (!name.equals(SOURCES)) {
266
                cache.update(name);
267
            } else {
268
                refresh();
269
            }
236
        }
270
        }
237
        
271
238
        
239
        protected Node[] createNodes(final Object key)
272
        protected Node[] createNodes(final Object key)
240
        {
273
        {
274
            if (SOURCES.equals(key)) {
275
                J2MESources sources = project.getLookup().lookup (J2MESources.class);
276
                SourceGroup[] sg = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
277
                List <Node> result = new LinkedList<Node>();
278
                System.err.println("Project contains " + sg.length + " source groups");
279
                for (SourceGroup group : sg) {
280
                    System.err.println("  source group " + sg);
281
                    result.add (PackageView.createPackageView(group));
282
                }
283
                System.err.println("Nodes for sources: " + result);
284
                return result.toArray(new Node[result.size()]);
285
            }
241
            ChildLookup creator=keyMap.get(key);
286
            ChildLookup creator=keyMap.get(key);
242
            return creator != null ? creator.createNodes(project) : null;
287
            Node[] result = creator == null ? new Node[0] : creator.createNodes(project);
288
            System.err.println("Returning " + Arrays.asList(result));
289
            return result;
243
        }
290
        }
244
291
245
        
292
        
246
        private Collection<String> getKeys() {
293
        private Collection<String> getKeys() {
247
            //#60800, #61584 - when the project is deleted externally do not try to create children, the source groups
294
            //#60800, #61584 - when the project is deleted externally do
295
            //not try to create children, the source groups
248
            //are not valid
296
            //are not valid
249
            if (project.getProjectDirectory() == null || !project.getProjectDirectory().isValid()) {
297
            boolean invalid = project.getProjectDirectory() == null ||
250
                return Collections.EMPTY_LIST;
298
                    !project.getProjectDirectory().isValid();
251
            }
299
            return invalid ? Collections.EMPTY_LIST :
252
            final java.util.List<String> result =  new java.util.ArrayList<String>();
300
                Arrays.asList (SOURCES, RESOURCES, CONFIGURATIONS);
253
            result.add("Sources");
254
            result.add("Resources");
255
            result.add("Configurations");
256
            return result;
257
        }
301
        }
258
    }
302
    }
259
    
303
    
Lines 281-287 public class J2MEPhysicalViewProvider im Link Here
281
        }
325
        }
282
     
326
     
283
        protected boolean testSourceRoot() {
327
        protected boolean testSourceRoot() {
284
            return helper.resolveFileObject(helper.getStandardPropertyEvaluator().getProperty("src.dir")) != null;
328
            J2MESources sources = project == null ? null :
329
                project.getLookup().lookup (J2MESources.class);
330
            return sources != null && sources.getSourceRoots().length > 0;
285
        }
331
        }
286
        
332
        
287
        protected void checkBroken() {
333
        protected void checkBroken() {
Lines 440-446 public class J2MEPhysicalViewProvider im Link Here
440
        
486
        
441
        public void actionPerformed(@SuppressWarnings("unused")
487
        public void actionPerformed(@SuppressWarnings("unused")
442
		final ActionEvent e) {
488
		final ActionEvent e) {
443
            refreshRecursivelly(helper.resolveFileObject(helper.getStandardPropertyEvaluator().getProperty("src.dir")));//NOI18N
489
            J2MESources sources = project.getLookup().lookup(J2MESources.class);
490
            for (FileObject root : sources.getSourceRoots()) {
491
                refreshRecursivelly (root);
492
            }
444
        }
493
        }
445
        
494
        
446
        private void refreshRecursivelly(final FileObject fo) {
495
        private void refreshRecursivelly(final FileObject fo) {
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/NodeFactory.java (+2 lines)
Lines 716-721 static class CfgNode extends ActionNode Link Here
716
    
716
    
717
    private String[] getBreakableProperties(J2MEProject project,ProjectConfiguration cfg) {
717
    private String[] getBreakableProperties(J2MEProject project,ProjectConfiguration cfg) {
718
        String s[] = new String[3];
718
        String s[] = new String[3];
719
        //XXX this will not work with multiple source dirs - need some kind of
720
        //wild-card
719
        s[0] = DefaultPropertiesDescriptor.SRC_DIR;
721
        s[0] = DefaultPropertiesDescriptor.SRC_DIR;
720
        s[1] = usedLibs(cfg);
722
        s[1] = usedLibs(cfg);
721
        if (project.getConfigurationHelper().getDefaultConfiguration().equals(cfg)) {
723
        if (project.getConfigurationHelper().getDefaultConfiguration().equals(cfg)) {
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/SourcesViewProvider.java (-94 lines)
Removed 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
/*
43
 * SourcesViewProvider.java
44
 *
45
 * Created on 21 April 2006, 15:53
46
 *
47
 * To change this template, choose Tools | Template Manager
48
 * and open the template in the editor.
49
 */
50
51
package org.netbeans.modules.mobility.project.ui;
52
53
import org.netbeans.api.java.project.JavaProjectConstants;
54
import org.netbeans.api.project.ProjectUtils;
55
import org.netbeans.api.project.SourceGroup;
56
import org.netbeans.api.project.Sources;
57
import org.netbeans.modules.mobility.project.J2MEProject;
58
import org.netbeans.modules.mobility.project.ui.J2MEPhysicalViewProvider.ChildLookup;
59
import org.netbeans.spi.java.project.support.ui.PackageView;
60
import org.netbeans.spi.project.support.ant.AntProjectHelper;
61
import org.openide.filesystems.FileObject;
62
import org.openide.loaders.DataObject;
63
import org.openide.nodes.FilterNode;
64
import org.openide.nodes.Node;
65
import org.openide.util.Lookup;
66
import org.openide.util.lookup.Lookups;
67
68
/**
69
 *
70
 * @author Lukas Waldmann
71
 */
72
final class SourcesViewProvider extends ChildLookup {
73
    public Node[] createNodes(final J2MEProject project) {
74
        Node n = null;
75
        final AntProjectHelper helper=project.getLookup().lookup(AntProjectHelper.class);
76
        final FileObject root = helper.resolveFileObject (helper.getStandardPropertyEvaluator ().getProperty ("src.dir")); // NOI18N
77
        DataObject dao = null;
78
        try {
79
            dao = root == null ? null : DataObject.find (root);
80
            final Sources src = ProjectUtils.getSources(project);
81
            if (src != null) {
82
                final SourceGroup sg[] = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
83
                if (sg != null && sg.length == 1)
84
                    n = PackageView.createPackageView(sg[0]);
85
            }
86
        } catch (Exception e) {}
87
        if (dao == null || n == null) {
88
            setLookups(new Lookup[] {Lookups.singleton(project)});
89
        } else {
90
            setLookups(new Lookup[] {Lookups.fixed(new Object[] {project, dao}), n.getLookup()});
91
        }
92
        return new Node[] {n == null ? Node.EMPTY : new FilterNode(n)};
93
    }
94
}
(-)a/mobility.project/src/org/netbeans/modules/mobility/project/ui/customizer/Bundle.properties (+64 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 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})
(-)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 42-47 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.nio.charset.Charset;
43
import java.nio.charset.Charset;
44
import javax.swing.JPanel;
44
import javax.swing.JPanel;
45
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
45
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
46
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
46
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
47
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
47
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
48
import org.netbeans.spi.mobility.project.ui.customizer.CustomizerPanel;
Lines 72-78 public class CustomizerCompile extends J Link Here
72
        initAccessibility();
73
        initAccessibility();
73
    }
74
    }
74
    
75
    
75
    public void initValues(ProjectProperties props, String configuration) {
76
    public void initValues(MultiRootProjectProperties props, String configuration) {
76
        vps = VisualPropertySupport.getDefault(props);
77
        vps = VisualPropertySupport.getDefault(props);
77
        vps.register(defaultCheck, configuration, this);
78
        vps.register(defaultCheck, configuration, this);
78
        
79
        
(-)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 (-11 / +44 lines)
Lines 51-60 import java.awt.event.ActionEvent; Link Here
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.util.ArrayList;
53
import java.util.ArrayList;
54
import java.util.Arrays;
55
import java.util.List;
54
import java.util.Map;
56
import java.util.Map;
55
import java.util.regex.Pattern;
57
import java.util.regex.Pattern;
56
import javax.swing.JPanel;
58
import javax.swing.JPanel;
57
import javax.swing.plaf.basic.BasicBorders;
59
import javax.swing.plaf.basic.BasicBorders;
60
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
58
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
61
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
59
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
62
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
60
import org.netbeans.modules.mobility.project.ui.customizer.regex.CheckedTreeBeanView;
63
import org.netbeans.modules.mobility.project.ui.customizer.regex.CheckedTreeBeanView;
Lines 67-74 import org.openide.filesystems.FileUtil; Link Here
67
import org.openide.filesystems.FileUtil;
70
import org.openide.filesystems.FileUtil;
68
import org.openide.loaders.DataObject;
71
import org.openide.loaders.DataObject;
69
import org.openide.loaders.DataObjectNotFoundException;
72
import org.openide.loaders.DataObjectNotFoundException;
73
import org.openide.nodes.AbstractNode;
74
import org.openide.nodes.ChildFactory;
75
import org.openide.nodes.Children;
70
import org.openide.nodes.FilterNode;
76
import org.openide.nodes.FilterNode;
71
import org.openide.nodes.Node;
77
import org.openide.nodes.Node;
78
import org.openide.util.Exceptions;
72
import org.openide.util.NbBundle;
79
import org.openide.util.NbBundle;
73
80
74
/**
81
/**
Lines 91-97 public class CustomizerFiltering extends Link Here
91
    private Pattern filter;
98
    private Pattern filter;
92
    private Map<String,Object> properties;
99
    private Map<String,Object> properties;
93
    private String configuration;
100
    private String configuration;
94
    private FileObject srcRoot;
101
    private FileObject[] srcRoots;
95
    private String excludesTranslatedPropertyName;
102
    private String excludesTranslatedPropertyName;
96
    
103
    
97
    /** Creates new form CustomizerConfigs */
104
    /** Creates new form CustomizerConfigs */
Lines 211-222 public class CustomizerFiltering extends Link Here
211
        treeView.getAccessibleContext().setAccessibleDescription( jLabelTree.getText() );
218
        treeView.getAccessibleContext().setAccessibleDescription( jLabelTree.getText() );
212
    }
219
    }
213
    
220
    
214
    public void initValues(ProjectProperties props, String configuration) {
221
    public void initValues(MultiRootProjectProperties props, String configuration) {
215
        this.vps = VisualPropertySupport.getDefault(props);
222
        this.vps = VisualPropertySupport.getDefault(props);
216
        this.properties = props;
223
        this.properties = props;
217
        this.configuration = configuration;
224
        this.configuration = configuration;
218
        this.srcRoot = props.getSourceRoot();
225
219
        treeView.setSrcRoot(srcRoot);
226
        this.srcRoots = props.getSourceRoots();
227
228
        treeView.setSrcRoots(srcRoots);
220
        vps.register(defaultCheck, configuration, this);
229
        vps.register(defaultCheck, configuration, this);
221
    }
230
    }
222
    
231
    
Lines 255-268 public class CustomizerFiltering extends Link Here
255
            }
264
            }
256
        }
265
        }
257
        this.filter = Pattern.compile(sFilter);
266
        this.filter = Pattern.compile(sFilter);
258
        try {
267
        Node rootNode = new AbstractNode (Children.create(new RootNodeFactory(), false));
259
            final DataObject dob = DataObject.find(srcRoot);
268
        manager.setRootContext(rootNode);
260
            manager.setRootContext(new FOBNode(dob.getNodeDelegate().cloneNode(), dob.getPrimaryFile()));
261
        } catch (DataObjectNotFoundException dnfe) {
262
            manager.setRootContext(Node.EMPTY);
263
        }
264
        treeView.registerProperty(properties, excludesTranslatedPropertyName, filter);
269
        treeView.registerProperty(properties, excludesTranslatedPropertyName, filter);
265
    }
270
    }
271
272
    private final class RootNodeFactory extends ChildFactory<FileObject> {
273
        @Override
274
        protected Node createNodeForKey(FileObject key) {
275
            try {
276
                DataObject dob = DataObject.find(key);
277
                return new FOBNode(dob.getNodeDelegate(), key);
278
            } catch (DataObjectNotFoundException ex) {
279
                Exceptions.printStackTrace(ex);
280
                return null;
281
            }
282
        }
283
284
        @Override
285
        protected boolean createKeys(List<FileObject> toPopulate) {
286
            toPopulate.addAll (Arrays.asList (srcRoots));
287
            return true;
288
        }
289
    }
290
266
    
291
    
267
    // Variables declaration - do not modify//GEN-BEGIN:variables
292
    // Variables declaration - do not modify//GEN-BEGIN:variables
268
    private javax.swing.JCheckBox defaultCheck;
293
    private javax.swing.JCheckBox defaultCheck;
Lines 275-281 public class CustomizerFiltering extends Link Here
275
    // End of variables declaration//GEN-END:variables
300
    // End of variables declaration//GEN-END:variables
276
    
301
    
277
    boolean acceptFileObject(final FileObject fo) {
302
    boolean acceptFileObject(final FileObject fo) {
278
        final String path = FileUtil.getRelativePath(srcRoot, fo);
303
        FileObject root = null;
304
        for (FileObject test : srcRoots) {
305
            if (fo.getPath().startsWith(test.getPath())) {
306
                root = test;
307
            }
308
        }
309
        assert root != null : fo.getPath() + " not a child of any of the " +
310
                "following project source roots: " + Arrays.asList(srcRoots);
311
        final String path = FileUtil.getRelativePath(root, fo);
279
        return path != null && !filter.matcher(path).matches();
312
        return path != null && !filter.matcher(path).matches();
280
    }
313
    }
281
    
314
    
(-)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);
(-)ea8899550edd (+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>
(-)ea8899550edd (+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 (-15 / +167 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 53-61 import java.util.List; Link Here
53
import java.util.List;
56
import java.util.List;
54
import java.util.Map;
57
import java.util.Map;
55
import java.util.Set;
58
import java.util.Set;
59
import java.util.Vector;
60
import javax.swing.ComboBoxModel;
61
import javax.swing.DefaultComboBoxModel;
62
import javax.swing.ListCellRenderer;
63
import javax.swing.table.DefaultTableModel;
56
import org.netbeans.api.mobility.project.PropertyDescriptor;
64
import org.netbeans.api.mobility.project.PropertyDescriptor;
57
import org.netbeans.api.mobility.project.ui.customizer.ProjectProperties;
65
import org.netbeans.api.mobility.project.ui.customizer.MultiRootProjectProperties;
58
import org.netbeans.api.project.Project;
59
import org.netbeans.api.project.ProjectManager;
66
import org.netbeans.api.project.ProjectManager;
60
import org.netbeans.api.project.ProjectUtils;
67
import org.netbeans.api.project.ProjectUtils;
61
import org.netbeans.api.queries.FileEncodingQuery;
68
import org.netbeans.api.queries.FileEncodingQuery;
Lines 65-102 import org.netbeans.spi.mobility.project Link Here
65
import org.netbeans.spi.mobility.project.ProjectPropertiesDescriptor;
72
import org.netbeans.spi.mobility.project.ProjectPropertiesDescriptor;
66
import org.netbeans.spi.mobility.project.PropertyParser;
73
import org.netbeans.spi.mobility.project.PropertyParser;
67
import org.netbeans.spi.mobility.project.support.DefaultPropertyParsers;
74
import org.netbeans.spi.mobility.project.support.DefaultPropertyParsers;
68
import org.netbeans.modules.mobility.project.ui.customizer.VisualClassPathItem;
69
import org.netbeans.api.queries.CollocationQuery;
75
import org.netbeans.api.queries.CollocationQuery;
76
import org.netbeans.modules.java.api.common.SourceRoots;
77
import org.netbeans.modules.java.api.common.ui.PlatformUiSupport;
78
import org.netbeans.modules.mobility.project.J2MEProject;
79
import org.netbeans.modules.mobility.project.J2MEProjectType;
70
import org.netbeans.modules.mobility.project.ProjectConfigurationsHelper;
80
import org.netbeans.modules.mobility.project.ProjectConfigurationsHelper;
81
import org.netbeans.spi.project.AuxiliaryConfiguration;
71
import org.netbeans.spi.project.support.ant.AntProjectHelper;
82
import org.netbeans.spi.project.support.ant.AntProjectHelper;
72
import org.netbeans.spi.project.support.ant.EditableProperties;
83
import org.netbeans.spi.project.support.ant.EditableProperties;
73
import org.netbeans.spi.project.support.ant.PropertyUtils;
84
import org.netbeans.spi.project.support.ant.PropertyUtils;
74
import org.netbeans.spi.project.support.ant.ReferenceHelper;
85
import org.netbeans.spi.project.support.ant.ReferenceHelper;
75
import org.openide.ErrorManager;
76
import org.openide.filesystems.FileObject;
86
import org.openide.filesystems.FileObject;
77
import org.openide.filesystems.FileUtil;
87
import org.openide.filesystems.FileUtil;
88
import org.openide.filesystems.URLMapper;
89
import org.openide.util.Exceptions;
78
import org.openide.util.Lookup;
90
import org.openide.util.Lookup;
79
import org.openide.util.MutexException;
91
import org.openide.util.MutexException;
80
import org.openide.util.Mutex;
92
import org.openide.util.Mutex;
81
import org.openide.util.NbBundle;
93
import org.openide.util.NbBundle;
94
import org.w3c.dom.Document;
95
import org.w3c.dom.Element;
96
import org.w3c.dom.NodeList;
82
97
83
/** Helper class. Defines constants for properties. Knows the proper
98
/** Helper class. Defines constants for properties. Knows the proper
84
 *  place where to store the properties.
99
 *  place where to store the properties.
85
 *
100
 *
86
 * @author Petr Hrebejk, Adam Sotona
101
 * @author Petr Hrebejk, Adam Sotona
87
 */
102
 */
88
public class J2MEProjectProperties implements ProjectProperties {
103
public class J2MEProjectProperties extends MultiRootProjectProperties {
89
    
90
    
91
    
92
    // Special properties of the project
104
    // Special properties of the project
93
    public static final String J2ME_PROJECT_NAME = "j2me.project.name"; //NOI18N
105
    public static final String J2ME_PROJECT_NAME = "j2me.project.name"; //NOI18N
94
    
106
    
95
    public static final String PROP_CONFIGURATIONS = "configurations"; //NOI18N
107
    public static final String PROP_CONFIGURATIONS = "configurations"; //NOI18N
96
    
108
    
97
    public static final String CONFIG_PREFIX = "configs."; //NOI18N
109
    public static final String CONFIG_PREFIX = "configs."; //NOI18N
110
    public static final String SOURCE_ENCODING="source.encoding"; // NOI18N
111
    public static final String BUILD_DIR = "build.dir"; // NOI18N
112
    
113
    /** @since org.netbeans.modules.java.j2seproject/1 1.11 */
114
    public static final String INCLUDES = "includes"; // NOI18N
115
    /** @since org.netbeans.modules.java.j2seproject/1 1.11 */
116
    public static final String EXCLUDES = "excludes"; // NOI18N
117
    
118
    //XXX DIST_DIR probably wrong for ME projects
119
    public static final String DIST_DIR = "dist.dir"; // NOI18N
98
    
120
    
99
    private static final String LIBS="${libs.";
121
    private static final String LIBS="${libs.";
122
    public static final String BUILD_CLASSES_DIR = "build.classes.dir";
100
123
101
    // Info about the property destination
124
    // Info about the property destination
102
    private final Set<PropertyDescriptor> PROPERTY_DESCRIPTORS = new HashSet<PropertyDescriptor>();
125
    private final Set<PropertyDescriptor> PROPERTY_DESCRIPTORS = new HashSet<PropertyDescriptor>();
Lines 121-142 public class J2MEProjectProperties imple Link Here
121
    
144
    
122
    // Private fields ----------------------------------------------------------
145
    // Private fields ----------------------------------------------------------
123
    
146
    
124
    private Project project;                
147
    private J2MEProject project;
125
    
148
    
126
    protected ReferenceHelper refHelper;
149
    protected ReferenceHelper refHelper;
127
    protected AntProjectHelper antProjectHelper;
150
    protected AntProjectHelper antProjectHelper;
128
    protected HashMap<String,PropertyInfo> properties;
151
    protected HashMap<String,PropertyInfo> properties;
129
    protected ProjectConfigurationsHelper configHelper;
152
    protected ProjectConfigurationsHelper configHelper;
130
    protected ProjectConfiguration devConfigs[]; 
153
    protected ProjectConfiguration devConfigs[]; 
154
    public DefaultTableModel SOURCE_ROOTS_MODEL;
155
    public DefaultTableModel TEST_ROOTS_MODEL;
156
    public ComboBoxModel JAVAC_SOURCE_MODEL;
157
    public ListCellRenderer JAVAC_SOURCE_RENDERER;
131
    
158
    
132
    public J2MEProjectProperties( Project project, AntProjectHelper antProjectHelper, ReferenceHelper refHelper, ProjectConfigurationsHelper configHelper) {
159
    public J2MEProjectProperties( J2MEProject project, AntProjectHelper antProjectHelper, ReferenceHelper refHelper, ProjectConfigurationsHelper configHelper) {
133
        this.project = project;
160
        this.project = project;
134
        this.properties = new HashMap<String,PropertyInfo>();
161
        this.properties = new HashMap<String,PropertyInfo>();
135
        this.antProjectHelper = antProjectHelper;
162
        this.antProjectHelper = antProjectHelper;
136
        this.refHelper = refHelper;
163
        this.refHelper = refHelper;
137
        this.configHelper = configHelper;
164
        this.configHelper = configHelper;
165
        SOURCE_ROOTS_MODEL = J2MESourceRootsUi.createModel( project.getSourceRoots() );
166
        TEST_ROOTS_MODEL = J2MESourceRootsUi.createModel( project.getTestSourceRoots() );
167
        JAVAC_SOURCE_MODEL = new DefaultComboBoxModel(); //XXX for testing.  Covered somewhere else already?
168
        JAVAC_SOURCE_RENDERER = PlatformUiSupport.createSourceLevelListCellRenderer ();
138
        initPropertyDescriptors();
169
        initPropertyDescriptors();
139
        read();
170
        read();
171
    }
172
173
    public J2MEProject getProject() {
174
        return project;
140
    }
175
    }
141
    
176
    
142
    public synchronized void setActiveConfiguration(final ProjectConfiguration cfg) {
177
    public synchronized void setActiveConfiguration(final ProjectConfiguration cfg) {
Lines 241-247 public class J2MEProjectProperties imple Link Here
241
    }
276
    }
242
    
277
    
243
    public FileObject getSourceRoot() {
278
    public FileObject getSourceRoot() {
244
        return antProjectHelper.resolveFileObject(antProjectHelper.getStandardPropertyEvaluator().getProperty("src.dir")); //NOI18N
279
        throw new UnsupportedOperationException ("getSourceRoot() deprecated.  " +
280
                "Use getSourceRoots() instead.");
281
    }
282
283
    @Override
284
    public FileObject[] getSourceRoots() {
285
        URL[] urls = project.getSourceRoots().getRootURLs();
286
        FileObject[] result = new FileObject[urls.length];
287
        for (int i=0; i < urls.length; i++) {
288
            result[i] = URLMapper.findFileObject(urls[i]);
289
        }
290
        return result;
245
    }
291
    }
246
    
292
    
247
    /** Reads all the properties of the project and converts them to objects
293
    /** Reads all the properties of the project and converts them to objects
Lines 330-351 public class J2MEProjectProperties imple Link Here
330
                    
376
                    
331
                    //storing global default encoding by dcurrent project (see issue #97855)
377
                    //storing global default encoding by dcurrent project (see issue #97855)
332
                    String enc = sharedProps.getProperty(DefaultPropertiesDescriptor.JAVAC_ENCODING);
378
                    String enc = sharedProps.getProperty(DefaultPropertiesDescriptor.JAVAC_ENCODING);
333
                    if (enc != null) FileEncodingQuery.setDefaultEncoding(Charset.forName(enc));
379
                    if (enc != null) {
380
                        try {
381
                            FileEncodingQuery.setDefaultEncoding(Charset.forName(enc));
382
                        } catch (UnsupportedCharsetException e) {
383
                            //When the encoding is not supported by JVM do not set it as default
384
                        }
385
                    }
386
387
                    Vector srcRoots = SOURCE_ROOTS_MODEL.getDataVector();
388
//                    Element dataElement = getUpdatedConfiguration (srcRoots, antProjectHelper);
389
//                    antProjectHelper.putPrimaryConfigurationData(dataElement, true);
390
                    SourceRoots roots = project.getSourceRoots();
391
                    updateSourceRoots (roots, srcRoots);
334
                    
392
                    
335
                    // save the project under write lock
393
                    // save the project under write lock
336
                    try {
394
                    try {
337
                        ProjectManager.getDefault().saveProject(project);
395
                        ProjectManager.getDefault().saveProject(project);
338
                    } catch (IOException ex) {
396
                    } catch (IOException ex) {
339
                        ErrorManager.getDefault().notify(ex);
397
                        Exceptions.printStackTrace(ex);
340
                    }
398
                    }
341
399
342
                    return null;
400
                    return null;
343
                }
401
                }
344
            });
402
            });
345
        } catch (MutexException e) {
403
        } catch (MutexException e) {
346
            ErrorManager.getDefault().notify(e.getException());
404
            Exceptions.printStackTrace(e);
347
        }
405
        }
348
        
406
    }
407
408
    private final void updateSourceRoots(SourceRoots roots, List srcRoots) {
409
        int max = srcRoots.size();
410
        URL[] urls = new URL[max];
411
        String[] names = new String[max];
412
        try {
413
            for (int i=0; i < max; i++) {
414
                Vector v = (Vector) srcRoots.get(i);
415
                File dir = (File) v.get(0);
416
                String name = (String) v.get(1);
417
                urls[i] = dir.toURI().toURL();
418
                names[i] = name;
419
            }
420
            roots.putRoots(urls, names);
421
        } catch (MalformedURLException mre) {
422
            Exceptions.printStackTrace(mre);
423
        }
424
425
    }
426
427
    private final Element getUpdatedConfiguration (List srcRoots, AntProjectHelper helper) {
428
        assert ProjectManager.mutex().isWriteAccess() : "Saving roots outside" +
429
                " of project manager mutex";
430
        AuxiliaryConfiguration cfg = project.getLookup().lookup(AuxiliaryConfiguration.class);
431
        assert cfg != null;
432
        EditableProperties publicProps =
433
                helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
434
        EditableProperties privateProps =
435
                helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
436
        Element dataElement = cfg.getConfigurationFragment("data", //NOI18N
437
                J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, true);
438
        if (dataElement == null) {
439
            //XXX recreate
440
            throw new IllegalStateException ("Configuration missing <data> section");
441
        }
442
        Document doc = dataElement.getOwnerDocument();
443
        Element srcRootsElement = findSingleChild (dataElement, "source-roots");
444
        dataElement.removeChild(srcRootsElement);
445
        srcRootsElement = doc.createElementNS(
446
                J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
447
                "source-roots"); //NOI18N
448
        boolean pubChanged = false;
449
        boolean privChanged = false;
450
        for (Object o : srcRoots) {
451
            Vector v = (Vector) o;
452
            File dir = (File) v.get(0);
453
            String name = (String) v.get(1);
454
            Element root = doc.createElementNS(
455
                    J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE,
456
                    "root"); //NOI18N
457
            String id;
458
            if (isStandardSrcDir (dir)) {
459
                id = "src.dir";
460
            } else {
461
                id = "src." + dir.getName() + ".dir";
462
            }
463
            root.setAttribute("id", id); //NOI18N
464
            if (!name.equals(dir.getName())) {
465
                root.setAttribute ("name", name);
466
            }
467
            srcRootsElement.appendChild (root);
468
            if (!dir.exists()) {
469
                if (!dir.mkdirs()) {
470
                    throw new IllegalStateException ("Could not create " + dir);
471
                }
472
            }
473
            FileObject asFileObject = FileUtil.toFileObject (FileUtil.normalizeFile(dir));
474
            FileObject projDir = project.getProjectDirectory();
475
            String relPath = FileUtil.getRelativePath(projDir, asFileObject);
476
            if (relPath == null) { //not under the project
477
                privateProps.put (id, dir.getPath().replace('\\', '/'));
478
            } else {
479
                publicProps.put(id, relPath);
480
            }
481
        }
482
        if (pubChanged) {
483
            helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, publicProps);
484
        }
485
        if (privChanged) {
486
            helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, privateProps);
487
        }
488
        dataElement.appendChild(srcRootsElement);
489
        return dataElement;
490
    }
491
492
    private boolean isStandardSrcDir (File file) {
493
        FileObject asFo = FileUtil.toFileObject (file);
494
        FileObject standardDir = project.getProjectDirectory().getFileObject("src");
495
        return standardDir != null && standardDir.equals(asFo);
496
    }
497
498
    private static Element findSingleChild (Element parent, String name) {
499
        NodeList l = parent.getElementsByTagNameNS(J2MEProjectType.MULTIROOT_PROJECT_CONFIGURATION_NAMESPACE, name);
500
        return (Element) ((Element) (l.getLength() == 0 ? null : l.item(0)));
349
    }
501
    }
350
    
502
    
351
    /** Finds out what are new and removed project dependencies and
503
    /** Finds out what are new and removed project dependencies and
(-)ea8899550edd (+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/CheckedTreeBeanView.java (-7 / +29 lines)
Lines 44-49 import org.openide.explorer.view.BeanTre Link Here
44
44
45
import java.awt.event.FocusListener;
45
import java.awt.event.FocusListener;
46
import java.awt.event.MouseListener;
46
import java.awt.event.MouseListener;
47
import java.util.Arrays;
47
import java.util.Enumeration;
48
import java.util.Enumeration;
48
import java.util.HashMap;
49
import java.util.HashMap;
49
import java.util.Map;
50
import java.util.Map;
Lines 60-66 import org.openide.filesystems.FileUtil; Link Here
60
 */
61
 */
61
public class CheckedTreeBeanView extends BeanTreeView {
62
public class CheckedTreeBeanView extends BeanTreeView {
62
    
63
    
63
    private FileObject root;
64
    private FileObject[] roots;
64
    private Pattern filter;
65
    private Pattern filter;
65
    private Map<String,Object> data;
66
    private Map<String,Object> data;
66
    final private CheckedNodeRenderer renderer;
67
    final private CheckedNodeRenderer renderer;
Lines 98-112 public class CheckedTreeBeanView extends Link Here
98
        tree.setBackground(UIManager.getDefaults().getColor(editable ?  "Tree.background" : "TextField.inactiveBackground")); //NOI18N
99
        tree.setBackground(UIManager.getDefaults().getColor(editable ?  "Tree.background" : "TextField.inactiveBackground")); //NOI18N
99
    }
100
    }
100
    
101
    
101
    public void setSrcRoot(final FileObject root) {
102
    public void setSrcRoots(final FileObject[] roots) {
102
        this.root = root;
103
        this.roots = roots;
103
    }
104
    }
104
    
105
    
105
    private boolean acceptPath(final String path) {
106
    private boolean acceptPath(final String path) {
106
        return path != null && (path.length()==0 || !this.filter.matcher(path).matches());
107
        return path != null && (path.length()==0 || !this.filter.matcher(path).matches());
107
    }
108
    }
109
110
    private FileObject rootOf (FileObject file) {
111
        FileObject root = null;
112
        for (FileObject test : roots) {
113
            if (FileUtil.isParentOf(test, file)) {
114
                root = test;
115
                break;
116
            }
117
        }
118
        assert root != null : file.getPath() + " not a child of any of " +
119
                Arrays.asList(roots);
120
        return root;
121
    }
108
    
122
    
109
    private synchronized Object updateState(final FileObject fo) {
123
    private synchronized Object updateState(final FileObject fo) {
124
        FileObject root = rootOf (fo);
110
        final String path = FileUtil.getRelativePath(root, fo);
125
        final String path = FileUtil.getRelativePath(root, fo);
111
        if (!acceptPath(path)) return null; // null means invalid
126
        if (!acceptPath(path)) return null; // null means invalid
112
        Object state = data.get(path);
127
        Object state = data.get(path);
Lines 131-142 public class CheckedTreeBeanView extends Link Here
131
    }
146
    }
132
    
147
    
133
    public Object getState(final FileObject fo) { // finds first SELECTED or UNSELECTED from root
148
    public Object getState(final FileObject fo) { // finds first SELECTED or UNSELECTED from root
149
        FileObject root = rootOf (fo);
134
        final String path = FileUtil.getRelativePath(root, fo);
150
        final String path = FileUtil.getRelativePath(root, fo);
135
        if (!acceptPath(path)) return null; //invalid
151
        if (!acceptPath(path)) return null; //invalid
136
        return data.get(path);
152
        return data.get(path);
137
    }
153
    }
138
    
154
    
139
    public synchronized void setState(FileObject fo, final boolean selected) {
155
    public synchronized void setState(FileObject fo, final boolean selected) {
156
        FileObject root = rootOf (fo);
140
        final String path = FileUtil.getRelativePath(root, fo);
157
        final String path = FileUtil.getRelativePath(root, fo);
141
        if (path == null) return; // invalid file object
158
        if (path == null) return; // invalid file object
142
        data.put(path, selected ? SELECTED : UNSELECTED); // set the one
159
        data.put(path, selected ? SELECTED : UNSELECTED); // set the one
Lines 150-161 public class CheckedTreeBeanView extends Link Here
150
    }
167
    }
151
    
168
    
152
    public String getExcludesRegex() {
169
    public String getExcludesRegex() {
153
        final StringBuffer sb = new StringBuffer();
170
        final StringBuilder sb = new StringBuilder();
154
        addExcludes(root, sb);
171
        for (FileObject root : roots) {
172
            addExcludes(root, sb);
173
        }
155
        return sb.toString();
174
        return sb.toString();
156
    }
175
    }
157
    
176
    
158
    private void addExcludes(final FileObject fo, final StringBuffer sb) {
177
    private void addExcludes(final FileObject fo, final StringBuilder sb) {
178
        FileObject root = rootOf (fo);
159
        final String path = FileUtil.getRelativePath(root, fo);
179
        final String path = FileUtil.getRelativePath(root, fo);
160
        if (!acceptPath(path)) return;
180
        if (!acceptPath(path)) return;
161
        final Object state = data.get(path);
181
        final Object state = data.get(path);
Lines 184-190 public class CheckedTreeBeanView extends Link Here
184
                if (exclude.indexOf('*') < 0) data.put(exclude, UNSELECTED);
204
                if (exclude.indexOf('*') < 0) data.put(exclude, UNSELECTED);
185
            }
205
            }
186
        }
206
        }
187
        updateState(root);
207
        for (FileObject root : roots) {
208
            updateState(root);
209
        }
188
        renderer.setContentStorage(this);
210
        renderer.setContentStorage(this);
189
        editor.setContentStorage(this);
211
        editor.setContentStorage(this);
190
    }
212
    }
(-)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() {
(-)ea8899550edd (+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>
(-)ea8899550edd (+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 243-258 public class LocalizationSupportPanelGUI Link Here
243
        return null;
245
        return null;
244
    }
246
    }
245
    
247
    
246
    public FileObject getRootFolder() {
248
    public FileObject[] getRootFolders() {
247
        return helper.resolveFileObject(helper.getStandardPropertyEvaluator().getProperty("src.dir")); // NOI18N
249
        J2MESources sources = project.getLookup().lookup(J2MESources.class);
250
        return sources == null ? new FileObject[0] : sources.getSourceRoots();
248
    }
251
    }
249
    
252
    
250
    public File getFolder() {
253
    public File getFolder() {
251
        final FileObject root = getRootFolder();
254
        J2MESources sources = project.getLookup().lookup(J2MESources.class);
252
        final File rootFile = FileUtil.toFile(root);
255
        FileObject result = null;
253
        if (rootFile == null)
256
        if (sources != null) {
254
            return null;
257
            //Find any source root that contains the package.  We'll ask the
255
        return new File(rootFile, getPackageFileName());
258
            //user to disambiguate if there are multiple ones later.
259
            for (FileObject root : sources.getSourceRoots()) {
260
                result = root.getFileObject(getPackageFileName());
261
                if (result != null) {
262
                    break;
263
                }
264
            }
265
        }
266
        return result == null ? FileUtil.toFile(result) : null;
256
    }
267
    }
257
    
268
    
258
    
269
    
(-)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 310-316 public class J2MEActionProviderTest exte Link Here
310
            TestUtil.setHelper(hp);
310
            TestUtil.setHelper(hp);
311
            /* try to add another root for better code coverage */
311
            /* try to add another root for better code coverage */
312
            EditableProperties ep=hp.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
312
            EditableProperties ep=hp.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
313
            ep.setProperty("src.dir",System.getProperty("java.io.tmpdir"));
313
            ep.setProperty(DefaultPropertiesDescriptor.SRC_DIR,System.getProperty("java.io.tmpdir"));
314
            hp.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
314
            hp.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
315
            new J2MEProject(hp);
315
            new J2MEProject(hp);
316
        } catch (Exception e) {
316
        } catch (Exception e) {
(-)a/mobility.project/test/unit/src/org/netbeans/modules/mobility/project/queries/CompiledSourceForBinaryQueryTest.java (-1 / +2 lines)
Lines 57-62 import org.netbeans.api.project.ProjectM Link Here
57
import org.netbeans.api.project.ProjectManager;
57
import org.netbeans.api.project.ProjectManager;
58
import org.netbeans.junit.NbTestCase;
58
import org.netbeans.junit.NbTestCase;
59
import org.netbeans.modules.masterfs.MasterFileSystem;
59
import org.netbeans.modules.masterfs.MasterFileSystem;
60
import org.netbeans.modules.mobility.project.DefaultPropertiesDescriptor;
60
import org.netbeans.modules.mobility.project.J2MEProject;
61
import org.netbeans.modules.mobility.project.J2MEProject;
61
import org.netbeans.modules.mobility.project.J2MEProjectGenerator;
62
import org.netbeans.modules.mobility.project.J2MEProjectGenerator;
62
import org.netbeans.modules.mobility.project.TestUtil;
63
import org.netbeans.modules.mobility.project.TestUtil;
Lines 158-164 public class CompiledSourceForBinaryQuer Link Here
158
        result.addChangeListener(list);
159
        result.addChangeListener(list);
159
        result.removeChangeListener(null);
160
        result.removeChangeListener(null);
160
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
161
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
161
        ep.setProperty("src.dir","../src2");
162
        ep.setProperty(DefaultPropertiesDescriptor.SRC_DIR,"../src2");
162
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
163
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
163
        //result.removeChangeListener(list);
164
        //result.removeChangeListener(list);
164
    }
165
    }
(-)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 261-267 public class FileBuiltQueryImplTest exte Link Here
261
        assertNull(ret,ret);
262
        assertNull(ret,ret);
262
        
263
        
263
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
264
        EditableProperties ep=aph.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
264
        ep.setProperty("src.dir","src2");
265
        ep.setProperty(DefaultPropertiesDescriptor.SRC_DIR,"src2");
265
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
266
        aph.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH,ep);
266
        
267
        
267
        
268
        

Return to bug 138228