View | Details | Raw Unified | Return to bug 198318 | Differences between
and this patch

Collapse All | Expand All

(-)apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.form (-1 / +14 lines)
 Lines 1-4    Link Here 
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.1" encoding="UTF-8" ?>
2
2
3
<Form version="1.2" maxVersion="1.2" 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>
 Lines 167-171    Link Here 
167
        </Constraint>
167
        </Constraint>
168
      </Constraints>
168
      </Constraints>
169
    </Component>
169
    </Component>
170
    <Component class="javax.swing.JButton" name="redefine">
171
      <Properties>
172
        <Property name="text" type="java.lang.String" value="&amp;Redefine..."/>
173
      </Properties>
174
      <Events>
175
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="redefineActionPerformed"/>
176
      </Events>
177
      <Constraints>
178
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
179
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="20" weightX="0.0" weightY="0.0"/>
180
        </Constraint>
181
      </Constraints>
182
    </Component>
170
  </SubComponents>
183
  </SubComponents>
171
</Form>
184
</Form>
(-)apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.java (+97 lines)
 Lines 45-62    Link Here 
45
package org.netbeans.modules.apisupport.project.ui.wizard.winsys;
45
package org.netbeans.modules.apisupport.project.ui.wizard.winsys;
46
46
47
import java.awt.Cursor;
47
import java.awt.Cursor;
48
import java.awt.EventQueue;
49
import java.io.File;
48
import java.io.IOException;
50
import java.io.IOException;
49
import java.util.ArrayList;
51
import java.util.ArrayList;
50
import java.util.Collection;
52
import java.util.Collection;
53
import java.util.Properties;
54
import java.util.Set;
55
import java.util.TreeSet;
51
import javax.swing.DefaultComboBoxModel;
56
import javax.swing.DefaultComboBoxModel;
57
import org.apache.tools.ant.module.api.support.ActionUtils;
58
import org.netbeans.api.project.Project;
59
import org.netbeans.modules.apisupport.project.NbModuleProject;
60
import org.netbeans.modules.apisupport.project.Util;
52
import org.netbeans.modules.apisupport.project.layers.LayerUtils;
61
import org.netbeans.modules.apisupport.project.layers.LayerUtils;
53
import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator;
62
import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator;
63
import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
54
import org.openide.WizardDescriptor;
64
import org.openide.WizardDescriptor;
65
import org.openide.execution.ExecutorTask;
55
import org.openide.filesystems.FileObject;
66
import org.openide.filesystems.FileObject;
56
import org.openide.filesystems.FileSystem;
67
import org.openide.filesystems.FileSystem;
68
import org.openide.filesystems.FileUtil;
57
import org.openide.util.AsyncGUIJob;
69
import org.openide.util.AsyncGUIJob;
70
import org.openide.util.Exceptions;
58
import org.openide.util.HelpCtx;
71
import org.openide.util.HelpCtx;
59
import org.openide.util.NbBundle;
72
import org.openide.util.NbBundle;
73
import org.openide.util.Task;
74
import org.openide.util.TaskListener;
60
import org.openide.util.Utilities;
75
import org.openide.util.Utilities;
61
76
62
/**
77
/**
 Lines 138-143    Link Here 
138
                        for (FileObject fo : fos) {
153
                        for (FileObject fo : fos) {
139
                            if (fo.isData() && "wsmode".equals(fo.getExt())) { //NOI18N
154
                            if (fo.isData() && "wsmode".equals(fo.getExt())) { //NOI18N
140
                                col.add(fo.getName());
155
                                col.add(fo.getName());
156
                                data.existingMode(fo.getName());
141
                            }
157
                            }
142
                        }
158
                        }
143
                        modes = col.toArray(new String[col.size()]);
159
                        modes = col.toArray(new String[col.size()]);
 Lines 224-229    Link Here 
224
        cbUndockingNotAllowed = new javax.swing.JCheckBox();
240
        cbUndockingNotAllowed = new javax.swing.JCheckBox();
225
        cbDraggingNotAllowed = new javax.swing.JCheckBox();
241
        cbDraggingNotAllowed = new javax.swing.JCheckBox();
226
        cbMaximizationNotAllowed = new javax.swing.JCheckBox();
242
        cbMaximizationNotAllowed = new javax.swing.JCheckBox();
243
        redefine = new javax.swing.JButton();
227
244
228
        setLayout(new java.awt.GridBagLayout());
245
        setLayout(new java.awt.GridBagLayout());
229
246
 Lines 320-325    Link Here 
320
        gridBagConstraints.weighty = 0.1;
337
        gridBagConstraints.weighty = 0.1;
321
        gridBagConstraints.insets = new java.awt.Insets(12, 6, 0, 0);
338
        gridBagConstraints.insets = new java.awt.Insets(12, 6, 0, 0);
322
        add(cbMaximizationNotAllowed, gridBagConstraints);
339
        add(cbMaximizationNotAllowed, gridBagConstraints);
340
341
        org.openide.awt.Mnemonics.setLocalizedText(redefine, "&Redefine...");
342
        redefine.addActionListener(new java.awt.event.ActionListener() {
343
            public void actionPerformed(java.awt.event.ActionEvent evt) {
344
                redefineActionPerformed(evt);
345
            }
346
        });
347
        gridBagConstraints = new java.awt.GridBagConstraints();
348
        gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_END;
349
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
350
        add(redefine, gridBagConstraints);
323
    }// </editor-fold>//GEN-END:initComponents
351
    }// </editor-fold>//GEN-END:initComponents
324
352
325
private void windowPosChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_windowPosChanged
353
private void windowPosChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_windowPosChanged
 Lines 330-335    Link Here 
330
    if( !cbSlidingNotAllowed.isEnabled() )
358
    if( !cbSlidingNotAllowed.isEnabled() )
331
        cbSlidingNotAllowed.setSelected( false );
359
        cbSlidingNotAllowed.setSelected( false );
332
}//GEN-LAST:event_windowPosChanged
360
}//GEN-LAST:event_windowPosChanged
361
362
    private static FileObject findBuildXml(Project project) {
363
        return project.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH);
364
    }
365
    
366
private void redefineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redefineActionPerformed
367
    final Project prj = data.getProject();
368
    final Properties p = new Properties();
369
    redefine.setEnabled(false);
370
    redefine.setText("Launching...");
371
    
372
    try {
373
        FileObject fo = prj.getProjectDirectory().getFileObject("build/designdir");
374
        if (fo != null) {
375
            return;
376
        }
377
        fo = FileUtil.createFolder(prj.getProjectDirectory(), "build/designdir");
378
        final FileObject finalFO = fo;
379
        File path = FileUtil.toFile(fo);
380
        p.setProperty("run.args", "--nosplash --designlayout --userdir " + path);
381
        
382
        ExecutorTask task = ActionUtils.runTarget(findBuildXml(prj), new String[] { "run" }, p);
383
        class PostProcess implements TaskListener, Runnable {
384
            Set<String> modeNames;
385
            
386
            @Override
387
            public void taskFinished(Task task) {
388
                FileObject modes = finalFO.getFileObject("config/Windows2Local/Modes");
389
                if (modes != null) {
390
                    modeNames = new TreeSet<String>();
391
                    for (FileObject m : modes.getChildren()) {
392
                        if (m.isData() && "wsmode".equals(m.getExt())) { //NOI18N
393
                            modeNames.add(m.getName());
394
                            try {
395
                                data.defineMode(m.getName(), m.asText());
396
                            } catch (IOException ex) {
397
                                Exceptions.printStackTrace(ex);
398
                            }
399
                        }
400
                    }
401
                    EventQueue.invokeLater(this);
402
                }
403
            }
404
405
            @Override
406
            public void run() {
407
                redefine.setEnabled(true);
408
                redefine.setText("Redefine...");
409
                int s = comMode.getModel().getSize();
410
                for (int i = 0; i < s; i++) {
411
                    modeNames.remove((String)comMode.getModel().getElementAt(i));
412
                }
413
                boolean first = true;
414
                for (String mn : modeNames) {
415
                    ((DefaultComboBoxModel)comMode.getModel()).addElement(mn);
416
                    if (first) {
417
                        comMode.getModel().setSelectedItem(mn);
418
                    }
419
                    first = false;
420
                }
421
            }
422
        }
423
        task.addTaskListener(new PostProcess());
424
    } catch (IOException e) {
425
        Util.err.notify(e);
426
    }
427
    
428
}//GEN-LAST:event_redefineActionPerformed
333
    
429
    
334
    // Variables declaration - do not modify//GEN-BEGIN:variables
430
    // Variables declaration - do not modify//GEN-BEGIN:variables
335
    private javax.swing.JCheckBox cbClosingNotAllowed;
431
    private javax.swing.JCheckBox cbClosingNotAllowed;
 Lines 341-346    Link Here 
341
    private javax.swing.JCheckBox cbUndockingNotAllowed;
437
    private javax.swing.JCheckBox cbUndockingNotAllowed;
342
    private javax.swing.JComboBox comMode;
438
    private javax.swing.JComboBox comMode;
343
    private javax.swing.JLabel lblMode;
439
    private javax.swing.JLabel lblMode;
440
    private javax.swing.JButton redefine;
344
    // End of variables declaration//GEN-END:variables
441
    // End of variables declaration//GEN-END:variables
345
    
442
    
346
    private void initAccessibility() {
443
    private void initAccessibility() {
(-)apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/NewTCIterator.java (-1 / +53 lines)
 Lines 46-55    Link Here 
46
46
47
import java.io.File;
47
import java.io.File;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.io.OutputStream;
49
import java.util.Collections;
50
import java.util.Collections;
50
import java.util.HashMap;
51
import java.util.HashMap;
52
import java.util.HashSet;
51
import java.util.Map;
53
import java.util.Map;
52
import java.util.Set;
54
import java.util.Set;
55
import java.util.TreeMap;
56
import java.util.TreeSet;
53
import java.util.logging.Level;
57
import java.util.logging.Level;
54
import java.util.logging.Logger;
58
import java.util.logging.Logger;
55
import org.netbeans.api.project.Project;
59
import org.netbeans.api.project.Project;
 Lines 111-116    Link Here 
111
        private boolean draggingNotAllowed = false;
115
        private boolean draggingNotAllowed = false;
112
        private boolean undockingNotAllowed = false;
116
        private boolean undockingNotAllowed = false;
113
        private boolean maximizationNotAllowed = false;
117
        private boolean maximizationNotAllowed = false;
118
        private Map<String,String> newModes;
119
        private Set<String> existingModes;
114
        
120
        
115
        private CreatedModifiedFiles files;
121
        private CreatedModifiedFiles files;
116
        
122
        
 Lines 153-158    Link Here 
153
        public String getMode() {
159
        public String getMode() {
154
            return mode;
160
            return mode;
155
        }
161
        }
162
        
163
        public void defineMode(String name, String definition) {
164
            if (newModes == null) {
165
                newModes = new TreeMap<String, String>();
166
            }
167
            newModes.put(name, definition);
168
        }
169
        void existingMode(String name) {
170
            if (existingModes == null) {
171
                existingModes = new TreeSet<String>();
172
            }
173
            existingModes.add(name);
174
        }
175
        
176
        Map<String,String> getNewModes() {
177
            if (newModes == null) {
178
                return null;
179
            }
180
            TreeMap<String,String> copy = new TreeMap<String,String>(newModes);
181
            copy.keySet().removeAll(existingModes);
182
            return copy.isEmpty() ? null : copy;
183
        }
156
184
157
        public void setMode(String mode) {
185
        public void setMode(String mode) {
158
            this.mode = mode;
186
            this.mode = mode;
 Lines 215-221    Link Here 
215
        }
243
        }
216
    }
244
    }
217
    
245
    
218
    public static void generateFileChanges(DataModel model) {
246
    public static void generateFileChanges(final DataModel model) {
219
        CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject());
247
        CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject());
220
        Project project = model.getProject();
248
        Project project = model.getProject();
221
        NbModuleProvider moduleInfo = model.getModuleInfo();
249
        NbModuleProvider moduleInfo = model.getModuleInfo();
 Lines 377-382    Link Here 
377
        fileChanges.add(fileChanges.bundleKey(bundlePath, "HINT_" + name + "TopComponent",  // NOI18N
405
        fileChanges.add(fileChanges.bundleKey(bundlePath, "HINT_" + name + "TopComponent",  // NOI18N
378
                                "This is a " + name + " window")); //NOI18N
406
                                "This is a " + name + " window")); //NOI18N
379
        
407
        
408
        final Map<String, String> newModes = model.getNewModes();
409
        if (newModes != null) {
410
            Set<String> files = new HashSet<String>();
411
            for (String wsmode : newModes.keySet()) {
412
                files.add(wsmode + ".wsmode");
413
            }
414
            
415
            fileChanges.add(fileChanges.layerModifications(new CreatedModifiedFiles.LayerOperation() {
416
                @Override
417
                public void run(FileSystem layer) throws IOException {
418
                    FileObject fo = FileUtil.createFolder(layer.getRoot(), "Windows2/Modes");
419
                    for (Map.Entry<String, String> entry : newModes.entrySet()) {
420
                        FileObject wsmode = fo.createData(entry.getKey() + ".wsmode");
421
                        OutputStream os = wsmode.getOutputStream();
422
                        try {
423
                            os.write(entry.getValue().getBytes("UTF-8"));
424
                        } finally {
425
                            os.close();
426
                        }
427
                    }
428
                }   
429
            }, files));
430
        }
431
        
380
        model.setCreatedModifiedFiles(fileChanges);
432
        model.setCreatedModifiedFiles(fileChanges);
381
    }
433
    }
382
434

Return to bug 198318
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo