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

Collapse All | Expand All

(-)core.windows/nbproject/project.xml (+9 lines)
 Lines 68-73    Link Here 
68
                    </run-dependency>
68
                    </run-dependency>
69
                </dependency>
69
                </dependency>
70
                <dependency>
70
                <dependency>
71
                    <code-name-base>org.netbeans.modules.sendopts</code-name-base>
72
                    <build-prerequisite/>
73
                    <compile-dependency/>
74
                    <run-dependency>
75
                        <release-version>2</release-version>
76
                        <specification-version>2.13</specification-version>
77
                    </run-dependency>
78
                </dependency>
79
                <dependency>
71
                    <code-name-base>org.netbeans.modules.settings</code-name-base>
80
                    <code-name-base>org.netbeans.modules.settings</code-name-base>
72
                    <build-prerequisite/>
81
                    <build-prerequisite/>
73
                    <compile-dependency/>
82
                    <compile-dependency/>
(-)core.windows/src/org/netbeans/core/windows/model/Bundle.properties (+47 lines)
Added Link Here 
1
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
#
3
# Copyright 2011 Oracle and/or its affiliates. All rights reserved.
4
#
5
# Oracle and Java are registered trademarks of Oracle and/or its affiliates.
6
# Other names may be trademarks of their respective owners.
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.  Oracle designates this
19
# particular file as subject to the "Classpath" exception as provided
20
# by Oracle 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
# If you wish your version of this file to be governed by only the CDDL
27
# or only the GPL Version 2, indicate your decision by adding
28
# "[Contributor] elects to include this software in this distribution
29
# under the [CDDL or GPL Version 2] license." If you do not indicate a
30
# single choice of license, a recipient has the option to distribute
31
# your version of this file under either the CDDL, the GPL Version 2 or
32
# to extend the choice of license to its licensees as provided above.
33
# However, if you add GPL Version 2 code and therefore, elected the GPL
34
# Version 2 license, then the option applies only if the new code is
35
# made subject to such option by the copyright holder.
36
#
37
# Contributor(s):
38
#
39
# Portions Copyrighted 2011 Sun Microsystems, Inc.
40
41
HINT_DesignLayout=Switches Window System into Design Mode Allowing Definition of Layout of Modes
42
CTL_DesignViewComponentTopComponent=Mode Component
43
HINT_DesignViewComponentTopComponent=Represents a mode and allows its rename
44
DesignViewComponent.modeName.text=
45
DesignViewComponent.jLabel1.text=Mode Name:
46
DesignViewComponent.jButton1.text=Rename Mode
47
(-)core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java (-2 / +6 lines)
 Lines 62-68    Link Here 
62
62
63
63
64
    /** Programatic name of mode. */
64
    /** Programatic name of mode. */
65
    private final String name;
65
    private String name;
66
66
67
    private final Rectangle bounds = new Rectangle();
67
    private final Rectangle bounds = new Rectangle();
68
68
 Lines 108-114    Link Here 
108
        this.permanent = permanent;
108
        this.permanent = permanent;
109
        this.topComponentSubModel = new TopComponentSubModel(kind);
109
        this.topComponentSubModel = new TopComponentSubModel(kind);
110
    }
110
    }
111
111
    
112
    /////////////////////////////////////
112
    /////////////////////////////////////
113
    // Mutator methods >>
113
    // Mutator methods >>
114
    /////////////////////////////////////
114
    /////////////////////////////////////
 Lines 357-362    Link Here 
357
        }
357
        }
358
        return topComponentContextSubModel;
358
        return topComponentContextSubModel;
359
    }
359
    }
360
361
    final void setName(String name) {
362
        this.name = name;
363
    }
360
    
364
    
361
}
365
}
362
366
(-)core.windows/src/org/netbeans/core/windows/model/DefaultModel.java (+10 lines)
 Lines 155-162    Link Here 
155
    
155
    
156
    private final Object LOCK_PROJECT_NAME = new Object();
156
    private final Object LOCK_PROJECT_NAME = new Object();
157
157
158
    static DefaultModel INSTANCE;
158
    
159
    
159
    public DefaultModel() {
160
    public DefaultModel() {
161
        assert INSTANCE == null;
162
        INSTANCE = this;
160
    }
163
    }
161
    
164
    
162
165
 Lines 728-733    Link Here 
728
            return null;
731
            return null;
729
        }
732
        }
730
    }
733
    }
734
735
    final void setModeName(ModeImpl mode, String name) {
736
        ModeModel modeModel = getModelForMode(mode);
737
        if(modeModel instanceof DefaultModeModel) {
738
            ((DefaultModeModel)modeModel).setName(name);
739
        }
740
    }
731
    
741
    
732
    /** Gets bounds. */
742
    /** Gets bounds. */
733
    public Rectangle getModeBounds(ModeImpl mode) {
743
    public Rectangle getModeBounds(ModeImpl mode) {
(-)core.windows/src/org/netbeans/core/windows/model/DesignView.java (+173 lines)
Added Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2011 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.core.windows.model;
43
44
import java.awt.event.ActionEvent;
45
import java.awt.event.ActionListener;
46
import java.io.IOException;
47
import java.util.Collections;
48
import java.util.Map;
49
import java.util.Set;
50
import org.netbeans.api.sendopts.CommandException;
51
import org.netbeans.core.windows.Constants;
52
import org.netbeans.core.windows.SplitConstraint;
53
import org.netbeans.core.windows.WindowManagerImpl;
54
import org.netbeans.spi.sendopts.Env;
55
import org.netbeans.spi.sendopts.Option;
56
import org.netbeans.spi.sendopts.OptionProcessor;
57
import org.openide.awt.ActionID;
58
import org.openide.awt.ActionRegistration;
59
import org.openide.filesystems.FileObject;
60
import org.openide.filesystems.FileUtil;
61
import org.openide.util.Exceptions;
62
import org.openide.util.NbBundle.Messages;
63
import org.openide.util.lookup.ServiceProvider;
64
import org.openide.windows.Mode;
65
import org.openide.windows.TopComponent;
66
import org.openide.windows.WindowManager;
67
68
/**
69
 *
70
 * @author Jaroslav Tulach <jtulach@netbeans.org>
71
 */
72
@ServiceProvider(service=OptionProcessor.class)
73
public final class DesignView extends OptionProcessor implements Runnable {
74
    private static final Option designLayout = Option.shortDescription(
75
        Option.withoutArgument(Option.NO_SHORT_NAME, "designlayout"),
76
        "org.netbeans.core.windows.model.Bundle", "HINT_DesignLayout"
77
    );
78
    static int designModeCounter;
79
    
80
    @Override
81
    protected Set<Option> getOptions() {
82
        return Collections.singleton(designLayout);
83
    }
84
85
    @Override
86
    protected void process(Env env, Map<Option, String[]> optionValues) throws CommandException {
87
        if (optionValues.containsKey(designLayout)) {
88
            cleanToolbarsAndMenu();
89
            WindowManager.getDefault().invokeWhenUIReady(this);
90
        }
91
    }
92
    
93
    public void cleanToolbarsAndMenu() {
94
        FileObject tb = FileUtil.getConfigFile("Toolbars");
95
96
        if (tb != null) {
97
            for (FileObject fileObject : tb.getChildren()) {
98
                try {
99
                    fileObject.delete();
100
                } catch (IOException ex) {
101
                    Exceptions.printStackTrace(ex);
102
                }
103
            }
104
            FileObject shadow;
105
            try {
106
                shadow = tb.createFolder("DesignView").createData("org-netbeans-core-windows-model-NewMode.shadow");
107
                shadow.setAttribute("originalFile", "Actions/System/org-netbeans-core-windows-model-NewMode.instance");
108
            } catch (IOException ex) {
109
                Exceptions.printStackTrace(ex);
110
            }
111
        }
112
        FileObject mb = FileUtil.getConfigFile("Menu");
113
114
        if (mb != null) {
115
            for (FileObject fileObject : mb.getChildren()) {
116
                try {
117
                    fileObject.delete();
118
                } catch (IOException ex) {
119
                    Exceptions.printStackTrace(ex);
120
                }
121
            }
122
        }
123
        FileObject ws = FileUtil.getConfigFile("Windows2Local");
124
125
        if (ws != null) {
126
            try {
127
                ws.delete();
128
            } catch (IOException ex) {
129
                Exceptions.printStackTrace(ex);
130
            }
131
        }
132
133
        WindowManager.getDefault().invokeWhenUIReady(this);
134
    }
135
    
136
    @Override
137
    public void run() {
138
        BIG: for (Mode m : WindowManager.getDefault().getModes()) {
139
            for (TopComponent topComponent : m.getTopComponents()) {
140
                if (topComponent instanceof DesignViewComponent) {
141
                    continue BIG;
142
                }
143
            }
144
            final DesignViewComponent mc = new DesignViewComponent();
145
            m.dockInto(mc);
146
            mc.open();
147
        }
148
    }
149
150
    @ActionID(category = "System", id = "org.netbeans.core.windows.model.NewMode")
151
    @ActionRegistration(iconBase = "org/netbeans/core/windows/model/DesignView.png",
152
    displayName = "#CTL_NewMode")
153
    @Messages("CTL_NewMode=New Mode")
154
    public static ActionListener newModeAction() {
155
        return new ActionListener() {
156
            @Override
157
            public void actionPerformed(ActionEvent e) {
158
                DesignViewComponent dvc = new DesignViewComponent();
159
                /*
160
                WindowManagerImpl wmi = (WindowManagerImpl)WindowManager.getDefault();
161
                Mode m = wmi.createMode("mode_" + (++designModeCounter),
162
                    Constants.MODE_KIND_VIEW, Constants.MODE_KIND_VIEW, true,
163
                    new SplitConstraint[]{new SplitConstraint(Constants.HORIZONTAL, 1, 0.2)}
164
                );
165
                m.dockInto(dvc);
166
                 */
167
                dvc.open();
168
                dvc.requestAttention(true);
169
            }
170
        };
171
    }
172
    
173
}
(-)core.windows/src/org/netbeans/core/windows/model/DesignViewComponent.form (+119 lines)
Added Link Here 
1
<?xml version="1.1" 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="true"/>
9
    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
10
    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
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" attributes="0">
20
              <EmptySpace max="-2" attributes="0"/>
21
              <Group type="103" groupAlignment="0" attributes="0">
22
                  <Group type="102" alignment="0" attributes="0">
23
                      <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
24
                      <EmptySpace pref="424" max="32767" attributes="0"/>
25
                  </Group>
26
                  <Group type="102" alignment="1" attributes="0">
27
                      <Group type="103" groupAlignment="1" attributes="0">
28
                          <Component id="modeName" alignment="0" pref="500" max="32767" attributes="0"/>
29
                          <Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
30
                          <Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
31
                      </Group>
32
                      <EmptySpace max="-2" attributes="0"/>
33
                  </Group>
34
                  <Group type="102" alignment="0" attributes="0">
35
                      <Component id="jButton1" min="-2" max="-2" attributes="0"/>
36
                      <EmptySpace pref="378" max="32767" attributes="0"/>
37
                  </Group>
38
              </Group>
39
          </Group>
40
      </Group>
41
    </DimensionLayout>
42
    <DimensionLayout dim="1">
43
      <Group type="103" groupAlignment="0" attributes="0">
44
          <Group type="102" max="-2" attributes="0">
45
              <EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
46
              <Component id="jPanel1" max="32767" attributes="0"/>
47
              <EmptySpace max="-2" attributes="0"/>
48
              <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
49
              <EmptySpace max="-2" attributes="0"/>
50
              <Component id="modeName" min="-2" max="-2" attributes="0"/>
51
              <EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
52
              <Component id="jButton1" min="-2" max="-2" attributes="0"/>
53
              <EmptySpace max="-2" attributes="0"/>
54
              <Component id="jPanel2" max="32767" attributes="0"/>
55
              <EmptySpace min="-2" max="-2" attributes="0"/>
56
          </Group>
57
      </Group>
58
    </DimensionLayout>
59
  </Layout>
60
  <SubComponents>
61
    <Component class="javax.swing.JTextField" name="modeName">
62
      <Properties>
63
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
64
          <ResourceString bundle="org/netbeans/core/windows/model/Bundle.properties" key="DesignViewComponent.modeName.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;, {arguments})"/>
65
        </Property>
66
      </Properties>
67
      <Events>
68
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="modeNameActionPerformed"/>
69
      </Events>
70
    </Component>
71
    <Container class="javax.swing.JPanel" name="jPanel1">
72
73
      <Layout>
74
        <DimensionLayout dim="0">
75
          <Group type="103" groupAlignment="0" attributes="0">
76
              <EmptySpace min="0" pref="500" max="32767" attributes="0"/>
77
          </Group>
78
        </DimensionLayout>
79
        <DimensionLayout dim="1">
80
          <Group type="103" groupAlignment="0" attributes="0">
81
              <EmptySpace min="0" pref="88" max="32767" attributes="0"/>
82
          </Group>
83
        </DimensionLayout>
84
      </Layout>
85
    </Container>
86
    <Container class="javax.swing.JPanel" name="jPanel2">
87
88
      <Layout>
89
        <DimensionLayout dim="0">
90
          <Group type="103" groupAlignment="0" attributes="0">
91
              <EmptySpace min="0" pref="500" max="32767" attributes="0"/>
92
          </Group>
93
        </DimensionLayout>
94
        <DimensionLayout dim="1">
95
          <Group type="103" groupAlignment="0" attributes="0">
96
              <EmptySpace min="0" pref="63" max="32767" attributes="0"/>
97
          </Group>
98
        </DimensionLayout>
99
      </Layout>
100
    </Container>
101
    <Component class="javax.swing.JLabel" name="jLabel1">
102
      <Properties>
103
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
104
          <ResourceString bundle="org/netbeans/core/windows/model/Bundle.properties" key="DesignViewComponent.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;, {arguments})"/>
105
        </Property>
106
      </Properties>
107
    </Component>
108
    <Component class="javax.swing.JButton" name="jButton1">
109
      <Properties>
110
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
111
          <ResourceString bundle="org/netbeans/core/windows/model/Bundle.properties" key="DesignViewComponent.jButton1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;, {arguments})"/>
112
        </Property>
113
      </Properties>
114
      <Events>
115
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
116
      </Events>
117
    </Component>
118
  </SubComponents>
119
</Form>
(-)core.windows/src/org/netbeans/core/windows/model/DesignViewComponent.java (+215 lines)
Added Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
package org.netbeans.core.windows.model;
45
46
import org.openide.util.NbBundle;
47
import org.openide.windows.Mode;
48
import org.openide.windows.TopComponent;
49
import org.netbeans.api.settings.ConvertAsProperties;
50
import org.netbeans.core.windows.ModeImpl;
51
import org.openide.windows.WindowManager;
52
53
@ConvertAsProperties(
54
    dtd = "-//org.netbeans.core.windows.model//DesignViewComponent//EN",
55
    autostore = false
56
)
57
@TopComponent.Description(preferredID = "DesignViewComponentTopComponent",
58
    iconBase = "org/netbeans/core/windows/model/DesignView.png",
59
    persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED
60
)
61
final class DesignViewComponent extends TopComponent {
62
    DesignViewComponent() {
63
        initComponents();
64
        setName(NbBundle.getMessage(DesignViewComponent.class, "CTL_DesignViewComponentTopComponent"));
65
        setToolTipText(NbBundle.getMessage(DesignViewComponent.class, "HINT_DesignViewComponentTopComponent"));
66
        putClientProperty("TopComponentAllowDockAnywhere", true);
67
        refresh();
68
    }
69
70
    /** This method is called from within the constructor to
71
     * initialize the form.
72
     * WARNING: Do NOT modify this code. The content of this method is
73
     * always regenerated by the Form Editor.
74
     */
75
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
76
    private void initComponents() {
77
78
        modeName = new javax.swing.JTextField();
79
        jPanel1 = new javax.swing.JPanel();
80
        jPanel2 = new javax.swing.JPanel();
81
        jLabel1 = new javax.swing.JLabel();
82
        jButton1 = new javax.swing.JButton();
83
84
        modeName.setText(org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.modeName.text", new Object[] {})); // NOI18N
85
        modeName.addActionListener(new java.awt.event.ActionListener() {
86
            public void actionPerformed(java.awt.event.ActionEvent evt) {
87
                modeNameActionPerformed(evt);
88
            }
89
        });
90
91
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
92
        jPanel1.setLayout(jPanel1Layout);
93
        jPanel1Layout.setHorizontalGroup(
94
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
95
            .addGap(0, 500, Short.MAX_VALUE)
96
        );
97
        jPanel1Layout.setVerticalGroup(
98
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
99
            .addGap(0, 88, Short.MAX_VALUE)
100
        );
101
102
        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
103
        jPanel2.setLayout(jPanel2Layout);
104
        jPanel2Layout.setHorizontalGroup(
105
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
106
            .addGap(0, 500, Short.MAX_VALUE)
107
        );
108
        jPanel2Layout.setVerticalGroup(
109
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
110
            .addGap(0, 63, Short.MAX_VALUE)
111
        );
112
113
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.jLabel1.text", new Object[] {})); // NOI18N
114
115
        org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.jButton1.text", new Object[] {})); // NOI18N
116
        jButton1.addActionListener(new java.awt.event.ActionListener() {
117
            public void actionPerformed(java.awt.event.ActionEvent evt) {
118
                jButton1ActionPerformed(evt);
119
            }
120
        });
121
122
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
123
        this.setLayout(layout);
124
        layout.setHorizontalGroup(
125
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
126
            .addGroup(layout.createSequentialGroup()
127
                .addContainerGap()
128
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
129
                    .addGroup(layout.createSequentialGroup()
130
                        .addComponent(jLabel1)
131
                        .addContainerGap(424, Short.MAX_VALUE))
132
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
133
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
134
                            .addComponent(modeName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)
135
                            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
136
                            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
137
                        .addContainerGap())
138
                    .addGroup(layout.createSequentialGroup()
139
                        .addComponent(jButton1)
140
                        .addContainerGap(378, Short.MAX_VALUE))))
141
        );
142
        layout.setVerticalGroup(
143
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144
            .addGroup(layout.createSequentialGroup()
145
                .addGap(9, 9, 9)
146
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
147
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
148
                .addComponent(jLabel1)
149
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
150
                .addComponent(modeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
151
                .addGap(3, 3, 3)
152
                .addComponent(jButton1)
153
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
154
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
155
                .addContainerGap())
156
        );
157
    }// </editor-fold>//GEN-END:initComponents
158
159
    private void refresh() {
160
        Mode mode = WindowManager.getDefault().findMode(this);
161
        if (mode != null) {
162
            modeName.setText(mode.getName());
163
            setName(mode.getName());
164
        }
165
    }
166
    
167
    private void modeNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modeNameActionPerformed
168
        Mode mode = WindowManager.getDefault().findMode(this);
169
        if (mode instanceof ModeImpl) {
170
            ModeImpl mi = (ModeImpl)mode;
171
            DefaultModel.INSTANCE.setModeName(mi, modeName.getText());
172
        }
173
174
        for (TopComponent tc : mode.getTopComponents()) {
175
            if (tc instanceof DesignViewComponent) {
176
                DesignViewComponent dvc = (DesignViewComponent)tc;
177
                dvc.refresh();
178
            }
179
        }
180
    }//GEN-LAST:event_modeNameActionPerformed
181
182
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
183
        modeNameActionPerformed(evt);
184
    }//GEN-LAST:event_jButton1ActionPerformed
185
186
    // Variables declaration - do not modify//GEN-BEGIN:variables
187
    private javax.swing.JButton jButton1;
188
    private javax.swing.JLabel jLabel1;
189
    private javax.swing.JPanel jPanel1;
190
    private javax.swing.JPanel jPanel2;
191
    private javax.swing.JTextField modeName;
192
    // End of variables declaration//GEN-END:variables
193
    
194
    @Override
195
    public void componentOpened() {
196
        refresh();
197
    }
198
199
    @Override
200
    protected void componentActivated() {
201
        refresh();
202
    }
203
204
    void writeProperties(java.util.Properties p) {
205
        // better to version settings since initial version as advocated at
206
        // http://wiki.apidesign.org/wiki/PropertyFiles
207
        p.setProperty("version", "1.0");
208
        // TODO store your settings
209
    }
210
211
    void readProperties(java.util.Properties p) {
212
        String version = p.getProperty("version");
213
        // TODO read your settings according to their version
214
    }
215
}

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