diff -r 0b68df27a7c0 apisupport.ant/nbproject/project.xml --- a/apisupport.ant/nbproject/project.xml Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.ant/nbproject/project.xml Tue Jul 26 12:21:33 2011 +0200 @@ -109,7 +109,7 @@ 1 - 1.48 + 1.49 diff -r 0b68df27a7c0 apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java Tue Jul 26 12:21:33 2011 +0200 @@ -72,6 +72,7 @@ import org.netbeans.modules.apisupport.project.NbModuleProject; import org.netbeans.modules.apisupport.project.NbModuleType; import org.netbeans.modules.apisupport.project.api.Util; +import org.netbeans.modules.apisupport.project.spi.ExecProject; import org.netbeans.modules.apisupport.project.suite.SuiteProject; import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerProviderImpl; import org.netbeans.modules.apisupport.project.ui.customizer.SuiteProperties; @@ -97,10 +98,11 @@ import org.openide.util.Mutex; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; +import org.openide.util.Task; import org.openide.util.Utilities; import org.openide.util.actions.SystemAction; -public final class ModuleActions implements ActionProvider { +public final class ModuleActions implements ActionProvider, ExecProject { static final String TEST_USERDIR_LOCK_PROP_NAME = "run.args.ide"; // NOI18N static final String TEST_USERDIR_LOCK_PROP_VALUE = "--test-userdir-lock-with-invalid-arg"; // NOI18N @@ -109,6 +111,18 @@ COMMAND_DEBUG_SINGLE )); + @Override + public Task execute(String... args) throws IOException { + StringBuilder sb = new StringBuilder(); + for (String r : args) { + sb.append(r).append(' '); + } + Properties p = new Properties(); + p.setProperty("run.args", sb.substring(0, sb.length() - 1)); + + return ActionUtils.runTarget(findBuildXml(project), new String[]{"run"}, p); + } + static Action[] getProjectActions(NbModuleProject project) { List actions = new ArrayList(); actions.add(CommonProjectActions.newFileAction()); diff -r 0b68df27a7c0 apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/SuiteActions.java --- a/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/SuiteActions.java Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/SuiteActions.java Tue Jul 26 12:21:33 2011 +0200 @@ -44,6 +44,7 @@ package org.netbeans.modules.apisupport.project.ui; +import org.openide.util.Task; import java.awt.event.ActionEvent; import java.io.IOException; import java.util.ArrayList; @@ -63,6 +64,7 @@ import org.netbeans.modules.apisupport.project.suite.SuiteBrandingModel; import org.netbeans.modules.apisupport.project.suite.SuiteProject; import org.netbeans.modules.apisupport.project.spi.BrandingModel; +import org.netbeans.modules.apisupport.project.spi.ExecProject; import org.netbeans.modules.apisupport.project.ui.customizer.SuiteCustomizer; import org.netbeans.modules.apisupport.project.ui.customizer.SuiteProperties; import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils; @@ -94,7 +96,18 @@ * Defines actions available on a suite. * @author Jesse Glick */ -public final class SuiteActions implements ActionProvider { +public final class SuiteActions implements ActionProvider, ExecProject { + @Override + public Task execute(String... args) throws IOException { + StringBuilder sb = new StringBuilder(); + for (String r : args) { + sb.append(r).append(' '); + } + Properties p = new Properties(); + p.setProperty("run.args", sb.substring(0, sb.length() - 1)); + + return ActionUtils.runTarget(findBuildXml(project), new String[]{"run"}, p); + } static Action[] getProjectActions(SuiteProject project) { NbPlatform platform = project.getPlatform(true); //true -> #96095 diff -r 0b68df27a7c0 apisupport.project/apichanges.xml --- a/apisupport.project/apichanges.xml Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/apichanges.xml Tue Jul 26 12:21:33 2011 +0200 @@ -110,6 +110,20 @@ + Execute the project + + + + + + Layout designer seeks for ExecProject interface + in project's lookup when it needs to execute the application + with additional parameters. + + + + + Added prepareContext method diff -r 0b68df27a7c0 apisupport.project/manifest.mf --- a/apisupport.project/manifest.mf Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/manifest.mf Tue Jul 26 12:21:33 2011 +0200 @@ -4,5 +4,5 @@ OpenIDE-Module-Requires: javax.script.ScriptEngine.freemarker OpenIDE-Module-Layer: org/netbeans/modules/apisupport/project/ui/resources/layer.xml AutoUpdate-Show-In-Client: false -OpenIDE-Module-Specification-Version: 1.48 +OpenIDE-Module-Specification-Version: 1.49 diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/spi/ExecProject.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/spi/ExecProject.java Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,60 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.apisupport.project.spi; + +import java.io.IOException; +import org.openide.util.Task; + +/** Abstraction over executing a project. + * + * @author Jaroslav Tulach + * @since 1.49 + */ +public interface ExecProject { + /** Asks the project to execute itself given provided arguments. + * + * @param args arguments for the execution + * @return task that will finish as soon as execution is over + * @throws IOException if the launch fails + */ + public Task execute(String... args) throws IOException; +} diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/Bundle.properties --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/Bundle.properties Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/Bundle.properties Tue Jul 26 12:21:33 2011 +0200 @@ -134,3 +134,5 @@ WindowSystemBrandingPanel.cbEnableModeSliding.text=Sliding Window Groups WindowSystemBrandingPanel.cbEnableModeClosing.text=Closing of Window Groups WindowSystemBrandingPanel.cbEnableAutoSlideInMinimizedMode.text=Auto-slide Windows in Minimized Window Groups +WindowSystemBrandingPanel.jButton1.text=jButton1 +WindowSystemBrandingPanel.redefineLayout.text=Redefine &Layout diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/WindowSystemBrandingPanel.form --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/WindowSystemBrandingPanel.form Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/WindowSystemBrandingPanel.form Tue Jul 26 12:21:33 2011 +0200 @@ -1,6 +1,15 @@
+ + + + + + + + + @@ -21,26 +30,31 @@ - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + @@ -82,6 +96,8 @@ + + @@ -259,5 +275,15 @@ + + + + + + + + + + diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/WindowSystemBrandingPanel.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/WindowSystemBrandingPanel.java Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/branding/WindowSystemBrandingPanel.java Tue Jul 26 12:21:33 2011 +0200 @@ -47,6 +47,7 @@ import org.netbeans.modules.apisupport.project.spi.BrandingModel; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import org.netbeans.modules.apisupport.project.ui.wizard.winsys.DesignSupport; import org.openide.util.NbBundle; /** @@ -159,6 +160,7 @@ // //GEN-BEGIN:initComponents private void initComponents() { + jButton1 = new javax.swing.JButton(); cbEnableDnd = new javax.swing.JCheckBox(); cbEnableFloating = new javax.swing.JCheckBox(); cbEnableSliding = new javax.swing.JCheckBox(); @@ -175,6 +177,9 @@ cbEnableEditorModeDnD = new javax.swing.JCheckBox(); cbEnableModeClosing = new javax.swing.JCheckBox(); cbEnableAutoSlideInMinimizedMode = new javax.swing.JCheckBox(); + redefineLayout = new javax.swing.JButton(); + + org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(WindowSystemBrandingPanel.class, "WindowSystemBrandingPanel.jButton1.text", new Object[] {})); // NOI18N cbEnableDnd.setMnemonic('D'); org.openide.awt.Mnemonics.setLocalizedText(cbEnableDnd, org.openide.util.NbBundle.getMessage(WindowSystemBrandingPanel.class, "LBL_EnableDnD")); // NOI18N @@ -216,30 +221,40 @@ org.openide.awt.Mnemonics.setLocalizedText(cbEnableAutoSlideInMinimizedMode, NbBundle.getMessage(WindowSystemBrandingPanel.class, "WindowSystemBrandingPanel.cbEnableAutoSlideInMinimizedMode.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(redefineLayout, org.openide.util.NbBundle.getMessage(WindowSystemBrandingPanel.class, "WindowSystemBrandingPanel.redefineLayout.text", new Object[] {})); // NOI18N + redefineLayout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + redefineLayoutActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(cbEnableAutoSlideInMinimizedMode) - .addComponent(cbEnableModeClosing) - .addComponent(cbEnableEditorModeDnD) - .addComponent(cbEnableViewModeDnD) - .addComponent(cbEnableEditorModeUndocking) - .addComponent(cbEnableViewModeUndocking) - .addComponent(cbEnableModeSliding) - .addComponent(cbEnableEditorClosing) - .addComponent(cbEnableMinimumSize) - .addComponent(cbEnableFloating) - .addComponent(cbEnableSliding) - .addComponent(cbEnableMaximization) - .addComponent(cbEnableViewClosing) - .addComponent(cbEnableResizing) - .addComponent(cbEnableDnd)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(cbEnableAutoSlideInMinimizedMode) + .addComponent(cbEnableModeClosing) + .addComponent(cbEnableEditorModeDnD) + .addComponent(cbEnableViewModeDnD) + .addComponent(cbEnableEditorModeUndocking) + .addComponent(cbEnableViewModeUndocking) + .addComponent(cbEnableModeSliding) + .addComponent(cbEnableEditorClosing) + .addComponent(cbEnableMinimumSize) + .addComponent(cbEnableFloating) + .addComponent(cbEnableSliding) + .addComponent(cbEnableMaximization) + .addComponent(cbEnableViewClosing) + .addComponent(cbEnableResizing) + .addComponent(cbEnableDnd))) + .addComponent(redefineLayout)) .addContainerGap(127, Short.MAX_VALUE)) ); layout.setVerticalGroup( @@ -277,6 +292,8 @@ .addComponent(cbEnableResizing) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cbEnableMinimumSize) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(redefineLayout) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); @@ -294,6 +311,11 @@ getAccessibleContext().setAccessibleName(NbBundle.getMessage(WindowSystemBrandingPanel.class, "SuiteCustomizerWindowSystemBranding.AccessibleContext.accessibleName")); // NOI18N }// //GEN-END:initComponents + +private void redefineLayoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redefineLayoutActionPerformed + redefineLayout.setEnabled(false); + DesignSupport.redefineLayout(getBranding().getProject(), redefineLayout); +}//GEN-LAST:event_redefineLayoutActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables @@ -312,6 +334,8 @@ private javax.swing.JCheckBox cbEnableViewClosing; private javax.swing.JCheckBox cbEnableViewModeDnD; private javax.swing.JCheckBox cbEnableViewModeUndocking; + private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; + private javax.swing.JButton redefineLayout; // End of variables declaration//GEN-END:variables } diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.form --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.form Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.form Tue Jul 26 12:21:33 2011 +0200 @@ -1,4 +1,4 @@ - +
@@ -167,5 +167,18 @@ + + + + + + + + + + + + + diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.java Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/BasicSettingsPanel.java Tue Jul 26 12:21:33 2011 +0200 @@ -45,18 +45,34 @@ package org.netbeans.modules.apisupport.project.ui.wizard.winsys; import java.awt.Cursor; +import java.awt.EventQueue; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; +import java.util.MissingResourceException; +import java.util.Properties; +import java.util.Set; +import java.util.TreeSet; +import java.util.concurrent.atomic.AtomicReference; import javax.swing.DefaultComboBoxModel; +import org.netbeans.api.project.Project; +import org.netbeans.modules.apisupport.project.api.Util; import org.netbeans.modules.apisupport.project.layers.LayerUtils; +import org.netbeans.modules.apisupport.project.spi.ExecProject; import org.netbeans.modules.apisupport.project.ui.wizard.common.BasicWizardIterator; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; import org.openide.WizardDescriptor; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileSystem; +import org.openide.filesystems.FileUtil; import org.openide.util.AsyncGUIJob; +import org.openide.util.Exceptions; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; +import org.openide.util.Task; +import org.openide.util.TaskListener; import org.openide.util.Utilities; /** @@ -93,7 +109,7 @@ markInvalid(); } } - + // public void addNotify() { // super.addNotify(); // attachDocumentListeners(); @@ -138,6 +154,7 @@ for (FileObject fo : fos) { if (fo.isData() && "wsmode".equals(fo.getExt())) { //NOI18N col.add(fo.getName()); + data.existingMode(fo.getName()); } } modes = col.toArray(new String[col.size()]); @@ -224,6 +241,7 @@ cbUndockingNotAllowed = new javax.swing.JCheckBox(); cbDraggingNotAllowed = new javax.swing.JCheckBox(); cbMaximizationNotAllowed = new javax.swing.JCheckBox(); + redefine = new javax.swing.JButton(); setLayout(new java.awt.GridBagLayout()); @@ -320,6 +338,17 @@ gridBagConstraints.weighty = 0.1; gridBagConstraints.insets = new java.awt.Insets(12, 6, 0, 0); add(cbMaximizationNotAllowed, gridBagConstraints); + + org.openide.awt.Mnemonics.setLocalizedText(redefine, "&Redefine..."); + redefine.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + redefineActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.PAGE_END; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12); + add(redefine, gridBagConstraints); }// //GEN-END:initComponents private void windowPosChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_windowPosChanged @@ -330,6 +359,63 @@ if( !cbSlidingNotAllowed.isEnabled() ) cbSlidingNotAllowed.setSelected( false ); }//GEN-LAST:event_windowPosChanged + +private void redefineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redefineActionPerformed + try { + final AtomicReference userDir = new AtomicReference(); + Task task = DesignSupport.invokeDesignMode(data.getProject(), userDir); + redefine.setEnabled(false); + if (task == null) { + return; + } + redefine.setText(org.openide.util.NbBundle.getMessage(BasicSettingsPanel.class, "MSG_LaunchingLayout", new Object[]{})); + + class PostProcess implements TaskListener, Runnable { + Set modeNames; + + @Override + public void taskFinished(Task task) { + FileObject modes = userDir.get().getFileObject("config/Windows2Local/Modes"); + if (modes != null) { + modeNames = new TreeSet(); + for (FileObject m : modes.getChildren()) { + if (m.isData() && "wsmode".equals(m.getExt())) { //NOI18N + modeNames.add(m.getName()); + try { + data.defineMode(m.getName(), DesignSupport.readMode(m)); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + } + EventQueue.invokeLater(this); + } + } + + @Override + public void run() { + redefine.setEnabled(true); + redefine.setText(org.openide.util.NbBundle.getMessage(BasicSettingsPanel.class, "MSG_RedefineLayout", new Object[] {})); + int s = comMode.getModel().getSize(); + for (int i = 0; i < s; i++) { + modeNames.remove((String)comMode.getModel().getElementAt(i)); + } + boolean first = true; + for (String mn : modeNames) { + ((DefaultComboBoxModel)comMode.getModel()).addElement(mn); + if (first) { + comMode.getModel().setSelectedItem(mn); + } + first = false; + } + } + } + task.addTaskListener(new PostProcess()); + } catch (IOException e) { + Util.err.notify(e); + } + +}//GEN-LAST:event_redefineActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox cbClosingNotAllowed; @@ -341,6 +427,7 @@ private javax.swing.JCheckBox cbUndockingNotAllowed; private javax.swing.JComboBox comMode; private javax.swing.JLabel lblMode; + private javax.swing.JButton redefine; // End of variables declaration//GEN-END:variables private void initAccessibility() { diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/Bundle.properties --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/Bundle.properties Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/Bundle.properties Tue Jul 26 12:21:33 2011 +0200 @@ -84,3 +84,15 @@ CTL_UndockingNotAllowed=&Undocking not allowed CTL_DraggingNotAllowed=&Dragging not allowed CTL_MaximizationNotAllowed=&Maximization not allowed +MSG_RedefineLayout=Redefine... +MSG_LaunchingLayout=Launching... +MSG_ReallyLaunch=Following action needs to start your application in a special mode.\n\ +This requires your application is compilable, executable and does\n\ +not do anything strange.\n\ +\n\ +\As soon as the application is launched, you can play with the layout,\n\ +create new modes, rename existing. Close the application to save changes.\n\ +\n\ +Do you want to proceed? +MSG_AlreadyLaunched=Your application may have already been started in design mode.\nContinue with another launch anyway? +MSG_ModesGenerated=Following modes has been generated:\\n{0} diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/DesignSupport.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/DesignSupport.java Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,202 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.apisupport.project.ui.wizard.winsys; + +import java.awt.EventQueue; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.StringWriter; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.concurrent.atomic.AtomicReference; +import javax.swing.JButton; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import org.netbeans.api.project.Project; +import org.netbeans.modules.apisupport.project.layers.LayerUtils; +import org.netbeans.modules.apisupport.project.spi.ExecProject; +import org.netbeans.modules.apisupport.project.spi.NbModuleProvider; +import org.netbeans.spi.project.SubprojectProvider; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileSystem; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle; +import org.openide.util.Task; +import org.openide.util.TaskListener; + +public final class DesignSupport implements TaskListener, Runnable { + private final Project project; + private final JButton toEnable; + private final AtomicReference userDir; + + + private DesignSupport(Project p, JButton toEnable, AtomicReference ud) { + this.project = p; + this.toEnable = toEnable; + this.userDir = ud; + } + + + public static Task invokeDesignMode(Project prj, AtomicReference userDir) throws IOException { + ExecProject es = prj.getLookup().lookup(ExecProject.class); + if (es == null) { + return null; + } + NotifyDescriptor nd = new NotifyDescriptor.Confirmation(org.openide.util.NbBundle.getMessage(BasicSettingsPanel.class, "MSG_ReallyLaunch", new Object[]{})); + nd.setOptions(new Object[]{NotifyDescriptor.YES_OPTION, NotifyDescriptor.CANCEL_OPTION}); + if (DialogDisplayer.getDefault().notify(nd) != NotifyDescriptor.YES_OPTION) { + return null; + } + FileObject fo = prj.getProjectDirectory().getFileObject("build/designdir"); // NOI18N + if (fo != null) { + nd = new NotifyDescriptor.Confirmation(org.openide.util.NbBundle.getMessage(BasicSettingsPanel.class, "MSG_AlreadyLaunched", new Object[]{})); + nd.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION); + if (DialogDisplayer.getDefault().notify(nd) != NotifyDescriptor.OK_OPTION) { + return null; + } + fo.delete(); + } + fo = FileUtil.createFolder(prj.getProjectDirectory(), "build/designdir"); // NOI18N + File path = FileUtil.toFile(fo); + userDir.set(fo); + return es.execute( + "--nosplash", // NOI18N + "-J-Dorg.netbeans.core.WindowSystem.designMode=true", // NOI18N + "--userdir " + path // NOI18N + ); + } + + public static String readMode(FileObject fo) throws IOException { + final InputStream is = fo.getInputStream(); + try { + StringWriter w = new StringWriter(); + Source t = new StreamSource(DesignSupport.class.getResourceAsStream("polishing.xsl")); // NOI18N + Transformer tr = TransformerFactory.newInstance().newTransformer(t); + Source s = new StreamSource(is); + Result r = new StreamResult(w); + tr.transform(s, r); + return w.toString(); + } catch (TransformerException ex) { + throw new IOException(ex); + } finally { + is.close(); + } + } + public static void redefineLayout(Project p, JButton toEnable) { + try { + AtomicReference userDir = new AtomicReference(); + Task task = invokeDesignMode(p, userDir); + if (task == null) { + toEnable.setEnabled(true); + } + task.addTaskListener(new DesignSupport(p, toEnable, userDir)); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + + @Override + public void taskFinished(Task task) { + FileObject modeDir = userDir.get().getFileObject("config/Windows2Local/Modes"); + OutputStream os; + if (modeDir != null) { + StringBuilder sb = new StringBuilder(); + try { + + FileSystem layer = findLayer(project); + if (layer == null) { + throw new IOException("Cannot find layer in " + project); // NOI18N + } + for (FileObject m : modeDir.getChildren()) { + if (m.isData() && "wsmode".equals(m.getExt())) { + final String name = "Windows2/Modes/" + m.getNameExt(); // NOI18N + FileObject mode = FileUtil.createData(layer.getRoot(), name); // NOI18N + os = mode.getOutputStream(); + os.write(DesignSupport.readMode(m).getBytes("UTF-8")); // NOI18N + os.close(); + sb.append(name).append("\n"); + } + } + NotifyDescriptor nd = new NotifyDescriptor.Message( + NbBundle.getMessage(DesignSupport.class, "MSG_ModesGenerated", new Object[] {sb}), + NotifyDescriptor.INFORMATION_MESSAGE + ); + DialogDisplayer.getDefault().notifyLater(nd); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + EventQueue.invokeLater(this); + } + + @Override + public void run() { + toEnable.setEnabled(true); + } + + private static FileSystem findLayer(Project p) throws IOException { + if (p.getLookup().lookup(NbModuleProvider.class) != null) { + return LayerUtils.getEffectiveSystemFilesystem(p); + } + SubprojectProvider lookup = p.getLookup().lookup(SubprojectProvider.class); + if (lookup == null) { + return null; + } + for (Project project : lookup.getSubprojects()) { + FileSystem fs = findLayer(project); + if (fs != null) { + return fs; + } + } + return null; + } +} diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/NewTCIterator.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/NewTCIterator.java Sun Jul 24 12:34:51 2011 +0400 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/NewTCIterator.java Tue Jul 26 12:21:33 2011 +0200 @@ -46,10 +46,14 @@ import java.io.File; import java.io.IOException; +import java.io.OutputStream; import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.api.project.Project; @@ -111,6 +115,8 @@ private boolean draggingNotAllowed = false; private boolean undockingNotAllowed = false; private boolean maximizationNotAllowed = false; + private Map newModes; + private Set existingModes; private CreatedModifiedFiles files; @@ -153,6 +159,28 @@ public String getMode() { return mode; } + + public void defineMode(String name, String definition) { + if (newModes == null) { + newModes = new TreeMap(); + } + newModes.put(name, definition); + } + void existingMode(String name) { + if (existingModes == null) { + existingModes = new TreeSet(); + } + existingModes.add(name); + } + + Map getNewModes() { + if (newModes == null) { + return null; + } + TreeMap copy = new TreeMap(newModes); + copy.keySet().removeAll(existingModes); + return copy.isEmpty() ? null : copy; + } public void setMode(String mode) { this.mode = mode; @@ -215,7 +243,7 @@ } } - public static void generateFileChanges(DataModel model) { + public static void generateFileChanges(final DataModel model) { CreatedModifiedFiles fileChanges = new CreatedModifiedFiles(model.getProject()); Project project = model.getProject(); NbModuleProvider moduleInfo = model.getModuleInfo(); @@ -377,6 +405,30 @@ fileChanges.add(fileChanges.bundleKey(bundlePath, "HINT_" + name + "TopComponent", // NOI18N "This is a " + name + " window")); //NOI18N + final Map newModes = model.getNewModes(); + if (newModes != null) { + Set files = new HashSet(); + for (String wsmode : newModes.keySet()) { + files.add(wsmode + ".wsmode"); + } + + fileChanges.add(fileChanges.layerModifications(new CreatedModifiedFiles.LayerOperation() { + @Override + public void run(FileSystem layer) throws IOException { + FileObject fo = FileUtil.createFolder(layer.getRoot(), "Windows2/Modes"); + for (Map.Entry entry : newModes.entrySet()) { + FileObject wsmode = fo.createData(entry.getKey() + ".wsmode"); + OutputStream os = wsmode.getOutputStream(); + try { + os.write(entry.getValue().getBytes("UTF-8")); + } finally { + os.close(); + } + } + } + }, files)); + } + model.setCreatedModifiedFiles(fileChanges); } diff -r 0b68df27a7c0 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/polishing.xsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/polishing.xsl Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff -r 0b68df27a7c0 apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/DesignSupportTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ui/wizard/winsys/DesignSupportTest.java Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,76 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.apisupport.project.ui.wizard.winsys; + +import java.io.IOException; +import java.io.OutputStream; +import org.netbeans.junit.NbTestCase; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileSystem; +import org.openide.filesystems.FileUtil; + + +public class DesignSupportTest extends NbTestCase { + private FileObject fo; + + public DesignSupportTest(String n) { + super(n); + } + + @Override + protected void setUp() throws IOException { + FileSystem ms = FileUtil.createMemoryFileSystem(); + fo = ms.getRoot().createData("my.wsmode"); + OutputStream os = fo.getOutputStream(); + FileUtil.copy(DesignSupportTest.class.getResourceAsStream("testWsmode.xml"), os); + os.close(); + } + public void testReadingOfAMode() throws Exception { + String read = DesignSupport.readMode(fo); + if (read.contains("active-tc")) { + fail("No active-tc:\n" + read); + } + if (read.indexOf("path orientation") == -1) { + fail(" + + + + + + + + + + + + + + diff -r 0b68df27a7c0 core.windows/arch.xml --- a/core.windows/arch.xml Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/arch.xml Tue Jul 26 12:21:33 2011 +0200 @@ -583,6 +583,15 @@ Action obj = (Action)fo.getAttribute("instanceCreate");
+ + Special property for apisupport project to run an application in a + design mode to define new layout. + In such mode user components are removed and replaced with uniform ones + allowing change of a mode name. Don't rely on this property much, it may + soon go away - as soon as apisupport is rewritten to have quasi-preview + editor. +

diff -r 0b68df27a7c0 core.windows/nbproject/project.xml --- a/core.windows/nbproject/project.xml Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/nbproject/project.xml Tue Jul 26 12:21:33 2011 +0200 @@ -67,7 +67,7 @@ 1.6
- + org.netbeans.modules.settings diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/Central.java --- a/core.windows/src/org/netbeans/core/windows/Central.java Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/src/org/netbeans/core/windows/Central.java Tue Jul 26 12:21:33 2011 +0200 @@ -557,6 +557,10 @@ WindowManagerImpl.getInstance().doFirePropertyChange( WindowManager.PROP_MODES, null, null); } + + final void setModeName(ModeImpl mode, String text) { + model.setModeName(mode, text); + } /** Removes mode from model and requests view (if needed). */ public void removeMode(ModeImpl mode) { diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/ModeImpl.java --- a/core.windows/src/org/netbeans/core/windows/ModeImpl.java Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/src/org/netbeans/core/windows/ModeImpl.java Tue Jul 26 12:21:33 2011 +0200 @@ -565,6 +565,10 @@ // Utility methods<< //////////////////// + public void setModeName(String text) { + getCentral().setModeName(this, text); + } + } diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/WindowSystemImpl.java --- a/core.windows/src/org/netbeans/core/windows/WindowSystemImpl.java Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/src/org/netbeans/core/windows/WindowSystemImpl.java Tue Jul 26 12:21:33 2011 +0200 @@ -48,6 +48,7 @@ import java.awt.EventQueue; import org.netbeans.core.WindowSystem; +import org.netbeans.core.windows.design.DesignView; import org.netbeans.core.windows.services.DialogDisplayerImpl; import org.netbeans.core.windows.view.ui.MainWindow; import org.openide.util.lookup.ServiceProvider; @@ -64,6 +65,9 @@ @Override public void init() { assert !EventQueue.isDispatchThread(); + if (Boolean.getBoolean("org.netbeans.core.WindowSystem.designMode")) { // NOI18N + DesignView.initialize(); + } MainWindow.init(); } diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/design/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core.windows/src/org/netbeans/core/windows/design/Bundle.properties Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,46 @@ +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# +# Copyright 2011 Oracle and/or its affiliates. All rights reserved. +# +# Oracle and Java are registered trademarks of Oracle and/or its affiliates. +# Other names may be trademarks of their respective owners. +# +# The contents of this file are subject to the terms of either the GNU +# General Public License Version 2 only ("GPL") or the Common +# Development and Distribution License("CDDL") (collectively, the +# "License"). You may not use this file except in compliance with the +# License. You can obtain a copy of the License at +# http://www.netbeans.org/cddl-gplv2.html +# or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the +# specific language governing permissions and limitations under the +# License. When distributing the software, include this License Header +# Notice in each file and include the License file at +# nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the GPL Version 2 section of the License file that +# accompanied this code. If applicable, add the following below the +# License Header, with the fields enclosed by brackets [] replaced by +# your own identifying information: +# "Portions Copyrighted [year] [name of copyright owner]" +# +# If you wish your version of this file to be governed by only the CDDL +# or only the GPL Version 2, indicate your decision by adding +# "[Contributor] elects to include this software in this distribution +# under the [CDDL or GPL Version 2] license." If you do not indicate a +# single choice of license, a recipient has the option to distribute +# your version of this file under either the CDDL, the GPL Version 2 or +# to extend the choice of license to its licensees as provided above. +# However, if you add GPL Version 2 code and therefore, elected the GPL +# Version 2 license, then the option applies only if the new code is +# made subject to such option by the copyright holder. +# +# Contributor(s): +# +# Portions Copyrighted 2011 Sun Microsystems, Inc. + +CTL_DesignViewComponentTopComponent=Mode Component +HINT_DesignViewComponentTopComponent=Represents a mode and allows its rename +DesignViewComponent.modeName.text= +DesignViewComponent.jLabel1.text=Mode Name: +DesignViewComponent.jButton1.text=Rename Mode + diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/design/DesignView.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core.windows/src/org/netbeans/core/windows/design/DesignView.java Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,174 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + * + * Contributor(s): + * + * Portions Copyrighted 2011 Sun Microsystems, Inc. + */ +package org.netbeans.core.windows.design; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.IOException; +import org.openide.awt.ActionID; +import org.openide.awt.ActionRegistration; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle.Messages; +import org.openide.windows.Mode; +import org.openide.windows.TopComponent; +import org.openide.windows.WindowManager; + +/** + * + * @author Jaroslav Tulach + */ +public final class DesignView implements Runnable, PropertyChangeListener { + private static final DesignView INSTANCE = new DesignView(); + static int designModeCounter; + + private DesignView() { + } + + public static void initialize() { + INSTANCE.cleanToolbarsAndMenu(); + WindowManager.getDefault().invokeWhenUIReady(INSTANCE); + TopComponent.getRegistry().addPropertyChangeListener(INSTANCE); + } + + private void cleanToolbarsAndMenu() { + FileObject tb = FileUtil.getConfigFile("Toolbars"); + + if (tb != null) { + for (FileObject fileObject : tb.getChildren()) { + try { + fileObject.delete(); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + FileObject shadow; + try { + shadow = tb.createFolder("DesignView").createData("org-netbeans-core-windows-model-NewMode.shadow"); + shadow.setAttribute("originalFile", "Actions/System/org-netbeans-core-windows-model-NewMode.instance"); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + FileObject mb = FileUtil.getConfigFile("Menu"); + + if (mb != null) { + for (FileObject fileObject : mb.getChildren()) { + try { + fileObject.delete(); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + } + FileObject ws = FileUtil.getConfigFile("Windows2Local"); + + if (ws != null) { + try { + ws.delete(); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + + WindowManager.getDefault().invokeWhenUIReady(this); + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (TopComponent.Registry.PROP_OPENED.equals(evt.getPropertyName())) { + for (Mode m : WindowManager.getDefault().getModes()) { + for (TopComponent topComponent : m.getTopComponents()) { + if (topComponent instanceof DesignViewComponent) { + continue; + } + topComponent.close(); + } + } + } + } + + @Override + public void run() { + BIG: for (Mode m : WindowManager.getDefault().getModes()) { + boolean found = false; + for (TopComponent topComponent : m.getTopComponents()) { + if (topComponent instanceof DesignViewComponent) { + found = true; + continue; + } + topComponent.close(); + } + if (!found) { + final DesignViewComponent mc = new DesignViewComponent(); + m.dockInto(mc); + mc.open(); + } + } + } + + @ActionID(category = "System", id = "org.netbeans.core.windows.model.NewMode") + @ActionRegistration(iconBase = "org/netbeans/core/windows/design/DesignView.png", + displayName = "#CTL_NewMode") + @Messages("CTL_NewMode=New Mode") + public static ActionListener newModeAction() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignViewComponent dvc = new DesignViewComponent(); + /* + WindowManagerImpl wmi = (WindowManagerImpl)WindowManager.getDefault(); + Mode m = wmi.createMode("mode_" + (++designModeCounter), + Constants.MODE_KIND_VIEW, Constants.MODE_KIND_VIEW, true, + new SplitConstraint[]{new SplitConstraint(Constants.HORIZONTAL, 1, 0.2)} + ); + m.dockInto(dvc); + */ + dvc.open(); + dvc.requestAttention(true); + } + }; + } +} diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/design/DesignView.png Binary file core.windows/src/org/netbeans/core/windows/design/DesignView.png has changed diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/design/DesignViewComponent.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core.windows/src/org/netbeans/core/windows/design/DesignViewComponent.form Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,109 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/design/DesignViewComponent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core.windows/src/org/netbeans/core/windows/design/DesignViewComponent.java Tue Jul 26 12:21:33 2011 +0200 @@ -0,0 +1,209 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2011 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.core.windows.design; + +import org.openide.util.NbBundle; +import org.openide.windows.Mode; +import org.openide.windows.TopComponent; +import org.netbeans.api.settings.ConvertAsProperties; +import org.netbeans.core.windows.ModeImpl; +import org.openide.windows.WindowManager; + +@ConvertAsProperties( + dtd = "-//org.netbeans.core.windows.model//DesignViewComponent//EN", + autostore = false +) +@TopComponent.Description(preferredID = "DesignViewComponentTopComponent", + iconBase = "org/netbeans/core/windows/model/DesignView.png", + persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED +) +final class DesignViewComponent extends TopComponent { + DesignViewComponent() { + initComponents(); + setName(NbBundle.getMessage(DesignViewComponent.class, "CTL_DesignViewComponentTopComponent")); + setToolTipText(NbBundle.getMessage(DesignViewComponent.class, "HINT_DesignViewComponentTopComponent")); + putClientProperty("TopComponentAllowDockAnywhere", true); + refresh(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + modeName = new javax.swing.JTextField(); + jPanel1 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + + modeName.setText(org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.modeName.text", new Object[] {})); // NOI18N + modeName.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + modeNameActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 500, Short.MAX_VALUE) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 88, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 500, Short.MAX_VALUE) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 63, Short.MAX_VALUE) + ); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.jLabel1.text", new Object[] {})); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jButton1, org.openide.util.NbBundle.getMessage(DesignViewComponent.class, "DesignViewComponent.jButton1.text", new Object[] {})); // NOI18N + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1) + .addComponent(modeName, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton1)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(9, 9, 9) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(modeName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(3, 3, 3) + .addComponent(jButton1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + private void refresh() { + Mode mode = WindowManager.getDefault().findMode(this); + if (mode != null) { + modeName.setText(mode.getName()); + setName(mode.getName()); + } + } + + private void modeNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modeNameActionPerformed + Mode mode = WindowManager.getDefault().findMode(this); + if (mode instanceof ModeImpl) { + ModeImpl mi = (ModeImpl)mode; + mi.setModeName(modeName.getText()); + } + + for (TopComponent tc : mode.getTopComponents()) { + if (tc instanceof DesignViewComponent) { + DesignViewComponent dvc = (DesignViewComponent)tc; + dvc.refresh(); + } + } + }//GEN-LAST:event_modeNameActionPerformed + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + modeNameActionPerformed(evt); + }//GEN-LAST:event_jButton1ActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JTextField modeName; + // End of variables declaration//GEN-END:variables + + @Override + public void componentOpened() { + refresh(); + } + + @Override + protected void componentActivated() { + refresh(); + } + + void writeProperties(java.util.Properties p) { + // better to version settings since initial version as advocated at + // http://wiki.apidesign.org/wiki/PropertyFiles + p.setProperty("version", "1.0"); + // TODO store your settings + } + + void readProperties(java.util.Properties p) { + String version = p.getProperty("version"); + // TODO read your settings according to their version + } +} diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java --- a/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/src/org/netbeans/core/windows/model/DefaultModeModel.java Tue Jul 26 12:21:33 2011 +0200 @@ -73,7 +73,7 @@ /** Programatic name of mode. */ - private final String name; + private String name; private final Set otherNames = new HashSet(3); @@ -123,7 +123,7 @@ this.permanent = permanent; this.topComponentSubModel = new TopComponentSubModel(kind); } - + ///////////////////////////////////// // Mutator methods >> ///////////////////////////////////// @@ -380,6 +380,11 @@ return topComponentSubModel.getOpenedTopComponents(); } } + + @Override + public final void setName(String name) { + this.name = name; + } // XXX @Override diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/model/DefaultModel.java --- a/core.windows/src/org/netbeans/core/windows/model/DefaultModel.java Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/src/org/netbeans/core/windows/model/DefaultModel.java Tue Jul 26 12:21:33 2011 +0200 @@ -796,6 +796,12 @@ return null; } } + + @Override + public final void setModeName(ModeImpl mode, String name) { + ModeModel modeModel = getModelForMode(mode); + modeModel.setName(name); + } /** Gets bounds. */ @Override diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/model/ModeModel.java --- a/core.windows/src/org/netbeans/core/windows/model/ModeModel.java Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/src/org/netbeans/core/windows/model/ModeModel.java Tue Jul 26 12:21:33 2011 +0200 @@ -62,6 +62,8 @@ interface ModeModel { // Mutators + /** Change name of the mode */ + public void setName(String name); /** Sets state. */ public void setState(int state); /** Sets bounds. */ diff -r 0b68df27a7c0 core.windows/src/org/netbeans/core/windows/model/Model.java --- a/core.windows/src/org/netbeans/core/windows/model/Model.java Sun Jul 24 12:34:51 2011 +0400 +++ b/core.windows/src/org/netbeans/core/windows/model/Model.java Tue Jul 26 12:21:33 2011 +0200 @@ -108,6 +108,8 @@ public void addModeAroundEditor(ModeImpl mode, String side); /** Removes mode. */ public void removeMode(ModeImpl mode); + /** Renames a mode */ + public void setModeName(ModeImpl mode, String name); /** Sets mode constraints. */ public void setModeConstraints(ModeImpl mode, SplitConstraint[] constraints); /** Adds top component group. */