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

(-)a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/Bundle.properties (+2 lines)
Lines 74-79 Link Here
74
ERR_Icon_Invalid=Cannot find icon.
74
ERR_Icon_Invalid=Cannot find icon.
75
ERR_Package_Invalid=Package is blank or malformed.
75
ERR_Package_Invalid=Package is blank or malformed.
76
ERR_ToBeCreateFileExists=The file {0} already exists.
76
ERR_ToBeCreateFileExists=The file {0} already exists.
77
ERR_IconNeededForMultiView=Icon is necessary when using multiview!
78
ERR_IconDoesNotExistsForMultiview=Icon {0} does not seem to exist!
77
79
78
ACS_NameAndLocationPanel=Name, Icon and Location Panel  
80
ACS_NameAndLocationPanel=Name, Icon and Location Panel  
79
ACS_CTL_PackageName=Package Name
81
ACS_CTL_PackageName=Package Name
(-)a/apisupport.wizards/src/org/netbeans/modules/apisupport/project/ui/wizard/loader/NameAndLocationPanel.java (-3 / +17 lines)
Lines 77-82 Link Here
77
        putClientProperty("NewFileWizard_Title", getMessage("LBL_LoaderWizardTitle"));
77
        putClientProperty("NewFileWizard_Title", getMessage("LBL_LoaderWizardTitle"));
78
        
78
        
79
        DocumentListener dListener = new UIUtil.DocumentAdapter() {
79
        DocumentListener dListener = new UIUtil.DocumentAdapter() {
80
            @Override
80
            public void insertUpdate(DocumentEvent e) {
81
            public void insertUpdate(DocumentEvent e) {
81
                if (checkValidity()) {
82
                if (checkValidity()) {
82
                    updateData();
83
                    updateData();
Lines 100-105 Link Here
100
        }
101
        }
101
    }
102
    }
102
    
103
    
104
    @Override
103
    protected void storeToDataModel() {
105
    protected void storeToDataModel() {
104
        updateData();
106
        updateData();
105
    }
107
    }
Lines 122-127 Link Here
122
        }
124
        }
123
    }
125
    }
124
    
126
    
127
    @Override
125
    protected void readFromDataModel() {
128
    protected void readFromDataModel() {
126
        if (data.getPackageName() != null) {
129
        if (data.getPackageName() != null) {
127
            comPackageName.setSelectedItem(data.getPackageName());
130
            comPackageName.setSelectedItem(data.getPackageName());
Lines 132-137 Link Here
132
        checkValidity();
135
        checkValidity();
133
    }
136
    }
134
    
137
    
138
    @Override
135
    protected String getPanelName() {
139
    protected String getPanelName() {
136
        return getMessage("LBL_NameLocation_Title");
140
        return getMessage("LBL_NameLocation_Title");
137
    }
141
    }
Lines 162-176 Link Here
162
        
166
        
163
        File icon = (path.length() == 0) ? null : new File(path);
167
        File icon = (path.length() == 0) ? null : new File(path);
164
        if (icon == null || !icon.exists()) {
168
        if (icon == null || !icon.exists()) {
165
            setWarning(WizardUtils.getNoIconSelectedWarning(16,16));
169
            setWarning(WizardUtils.getNoIconSelectedWarning(16,16), !useMultiView.isSelected());
166
        } else if (!WizardUtils.isValidIcon(icon,16,16)) {
170
        } else if (!WizardUtils.isValidIcon(icon,16,16)) {
167
            setWarning(WizardUtils.getIconDimensionWarning(icon,16,16));
171
            setWarning(WizardUtils.getIconDimensionWarning(icon,16,16), !useMultiView.isSelected());
168
        } else {        
172
        } else {
169
            markValid();
173
            markValid();
170
        }
174
        }
171
        return true;
175
        return true;
172
    }
176
    }
173
    
177
    
178
    @Override
174
    protected HelpCtx getHelp() {
179
    protected HelpCtx getHelp() {
175
        return new HelpCtx(NameAndLocationPanel.class);
180
        return new HelpCtx(NameAndLocationPanel.class);
176
    }
181
    }
Lines 345-350 Link Here
345
        add(lblIcon2, gridBagConstraints);
350
        add(lblIcon2, gridBagConstraints);
346
351
347
        org.openide.awt.Mnemonics.setLocalizedText(useMultiView, "&Use MultiView");
352
        org.openide.awt.Mnemonics.setLocalizedText(useMultiView, "&Use MultiView");
353
        useMultiView.addActionListener(new java.awt.event.ActionListener() {
354
            public void actionPerformed(java.awt.event.ActionEvent evt) {
355
                useMultiViewActionPerformed(evt);
356
            }
357
        });
348
        gridBagConstraints = new java.awt.GridBagConstraints();
358
        gridBagConstraints = new java.awt.GridBagConstraints();
349
        gridBagConstraints.gridx = 1;
359
        gridBagConstraints.gridx = 1;
350
        gridBagConstraints.gridy = 2;
360
        gridBagConstraints.gridy = 2;
Lines 361-366 Link Here
361
            txtIcon.setText(file.getAbsolutePath());
371
            txtIcon.setText(file.getAbsolutePath());
362
        }
372
        }
363
    }//GEN-LAST:event_btnIconActionPerformed
373
    }//GEN-LAST:event_btnIconActionPerformed
374
375
    private void useMultiViewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useMultiViewActionPerformed
376
        checkValidity();
377
    }//GEN-LAST:event_useMultiViewActionPerformed
364
    
378
    
365
    // Variables declaration - do not modify//GEN-BEGIN:variables
379
    // Variables declaration - do not modify//GEN-BEGIN:variables
366
    private javax.swing.JButton btnIcon;
380
    private javax.swing.JButton btnIcon;
(-)a/core.multiview/src/org/netbeans/core/multiview/MultiViewProcessor.java (-2 / +5 lines)
Lines 104-115 Link Here
104
                fileBaseName += "-" + binAndMethodNames[1];
104
                fileBaseName += "-" + binAndMethodNames[1];
105
            }
105
            }
106
            for (String type : mvr.mimeType()) {
106
            for (String type : mvr.mimeType()) {
107
                LayerBuilder.File f = layer(e).file("Editors/" + (type.equals("") ? "" : type + '/') + "MultiView/" + fileBaseName + ".instance");
107
                final LayerBuilder builder = layer(e);
108
                LayerBuilder.File f = builder.file("Editors/" + (type.equals("") ? "" : type + '/') + "MultiView/" + fileBaseName + ".instance");
108
                f.methodvalue("instanceCreate", MultiViewFactory.class.getName(), "createMultiViewDescription");
109
                f.methodvalue("instanceCreate", MultiViewFactory.class.getName(), "createMultiViewDescription");
109
                f.stringvalue("instanceClass", ContextAwareDescription.class.getName());
110
                f.stringvalue("instanceClass", ContextAwareDescription.class.getName());
110
                f.stringvalue("class", binAndMethodNames[0]);
111
                f.stringvalue("class", binAndMethodNames[0]);
111
                f.bundlevalue("displayName", mvr.displayName(), mvr, "displayName");
112
                f.bundlevalue("displayName", mvr.displayName(), mvr, "displayName");
112
                f.stringvalue("iconBase", mvr.iconBase());
113
                String fullIconPath = LayerBuilder.absolutizeResource(e, mvr.iconBase());
114
                builder.validateResource(fullIconPath, e, mvr, "iconBase", true);
115
                f.stringvalue("iconBase", fullIconPath);
113
                f.stringvalue("preferredID", mvr.preferredID());
116
                f.stringvalue("preferredID", mvr.preferredID());
114
                f.intvalue("persistenceType", mvr.persistenceType());
117
                f.intvalue("persistenceType", mvr.persistenceType());
115
                f.position(mvr.position());
118
                f.position(mvr.position());
(-)a/core.multiview/test/unit/src/org/netbeans/core/multiview/MultiViewProcessorTest.java (-5 / +58 lines)
Lines 49-54 Link Here
49
import java.beans.PropertyChangeEvent;
49
import java.beans.PropertyChangeEvent;
50
import java.beans.PropertyChangeListener;
50
import java.beans.PropertyChangeListener;
51
import java.io.ByteArrayOutputStream;
51
import java.io.ByteArrayOutputStream;
52
import java.io.File;
53
import java.io.IOException;
52
import java.io.Serializable;
54
import java.io.Serializable;
53
import java.util.Arrays;
55
import java.util.Arrays;
54
import java.util.Collection;
56
import java.util.Collection;
Lines 260-266 Link Here
260
                + "import org.netbeans.core.spi.multiview.MultiViewElement;\n"
262
                + "import org.netbeans.core.spi.multiview.MultiViewElement;\n"
261
                + "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n"
263
                + "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n"
262
        + "@MultiViewElement.Registration(displayName = \"Testing\","
264
        + "@MultiViewElement.Registration(displayName = \"Testing\","
263
        + "iconBase = \"none\","
265
        + "iconBase = \"one.png\","
266
        + "mimeType = \"text/ble\","
267
        + "persistenceType = 0,"
268
        + "preferredID = \"bleple\")"
269
                + "  public static MultiViewElement create() {\n"
270
                + "    return new Test();\n"
271
                + "  }\n"
272
                + "}\n";
273
        generateIcon("one.png");
274
        AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src);
275
        ByteArrayOutputStream os = new ByteArrayOutputStream();
276
        boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
277
        assertTrue("Compilation should succeed:\n" + os.toString(), res);
278
    }
279
    
280
    public void testCompileInAptFullPath() throws Exception {
281
        clearWorkDir();
282
        String src = "\n"
283
                + "import org.netbeans.core.spi.multiview.MultiViewElement;\n"
284
                + "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n"
285
        + "@MultiViewElement.Registration(displayName = \"Testing\","
286
        + "iconBase = \"/pkg/one.png\","
287
        + "mimeType = \"text/ble\","
288
        + "persistenceType = 0,"
289
        + "preferredID = \"bleple\")"
290
                + "  public static MultiViewElement create() {\n"
291
                + "    return new Test();\n"
292
                + "  }\n"
293
                + "}\n";
294
        generateIcon("one.png");
295
        AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src);
296
        ByteArrayOutputStream os = new ByteArrayOutputStream();
297
        boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
298
        assertTrue("Compilation should succeed:\n" + os.toString(), res);
299
    }
300
301
    private void generateIcon(String icon) throws IOException {
302
        File pkg = new File(getWorkDir(), "pkg");
303
        pkg.mkdirs();
304
        File f = new File(pkg, icon);
305
        f.createNewFile();
306
    }
307
308
    public void testFailsWithoutAnIcon() throws Exception {
309
        clearWorkDir();
310
        String src = "\n"
311
                + "import org.netbeans.core.spi.multiview.MultiViewElement;\n"
312
                + "public class Test extends org.netbeans.core.multiview.MultiViewProcessorTest.MVE {\n"
313
        + "@MultiViewElement.Registration(displayName = \"Testing\","
314
        + "iconBase = \"none-existing.png\","
264
        + "mimeType = \"text/ble\","
315
        + "mimeType = \"text/ble\","
265
        + "persistenceType = 0,"
316
        + "persistenceType = 0,"
266
        + "preferredID = \"bleple\")"
317
        + "preferredID = \"bleple\")"
Lines 271-277 Link Here
271
        AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src);
322
        AnnotationProcessorTestUtils.makeSource(getWorkDir(), "pkg.Test", src);
272
        ByteArrayOutputStream os = new ByteArrayOutputStream();
323
        ByteArrayOutputStream os = new ByteArrayOutputStream();
273
        boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
324
        boolean res = AnnotationProcessorTestUtils.runJavac(getWorkDir(), null, getWorkDir(), null, os);
274
        assertTrue("Compilation should succeed:\n" + os.toString(), res);
325
        assertFalse("Compilation should fail:\n" + os.toString(), res);
326
        assertTrue("because of missing icon:\n" + os.toString(), os.toString().contains("iconBase"));
327
        assertTrue("because of missing icon:\n" + os.toString(), os.toString().contains("Cannot find resource pkg/none-existing.png"));
275
    }
328
    }
276
    
329
    
277
    public void testIsSourceView() {
330
    public void testIsSourceView() {
Lines 369-375 Link Here
369
422
370
    @MultiViewElement.Registration(
423
    @MultiViewElement.Registration(
371
        displayName="org.netbeans.core.multiview.TestBundle#FIGARO",
424
        displayName="org.netbeans.core.multiview.TestBundle#FIGARO",
372
        iconBase="none",
425
        iconBase="empty.png",
373
        mimeType="text/figaro",
426
        mimeType="text/figaro",
374
        persistenceType=TopComponent.PERSISTENCE_NEVER,
427
        persistenceType=TopComponent.PERSISTENCE_NEVER,
375
        preferredID="figaro"
428
        preferredID="figaro"
Lines 446-452 Link Here
446
    
499
    
447
    @MultiViewElement.Registration(
500
    @MultiViewElement.Registration(
448
        displayName="Contextual",
501
        displayName="Contextual",
449
        iconBase="none",
502
        iconBase="empty.png",
450
        mimeType="text/context",
503
        mimeType="text/context",
451
        persistenceType=TopComponent.PERSISTENCE_ALWAYS,
504
        persistenceType=TopComponent.PERSISTENCE_ALWAYS,
452
        preferredID="context"
505
        preferredID="context"
Lines 470-476 Link Here
470
523
471
    @MultiViewElement.Registration(
524
    @MultiViewElement.Registration(
472
        displayName="Source",
525
        displayName="Source",
473
        iconBase="none",
526
        iconBase="empty.png",
474
        mimeType="text/plaintest",
527
        mimeType="text/plaintest",
475
        persistenceType=TopComponent.PERSISTENCE_NEVER,
528
        persistenceType=TopComponent.PERSISTENCE_NEVER,
476
        preferredID="source"
529
        preferredID="source"

Return to bug 204174