# HG changeset patch # User Jaroslav Tulach # Date 1410189318 -7200 # Node ID 9073c01ba497de5fd0b4c1cb4622a8a3a079e6fa # Parent caac10b379ae0da8e53391f3f7b5a82dea79b536 When there is HTML/Java project, clicking on 'Develop' should open the project wizard diff -r caac10b379ae -r 9073c01ba497 minesweeper/pom.xml --- a/minesweeper/pom.xml Mon Sep 08 17:13:40 2014 +0200 +++ b/minesweeper/pom.xml Mon Sep 08 17:15:18 2014 +0200 @@ -582,6 +582,34 @@ ${nb.html.version} compile + + org-openide-filesystems + org.netbeans.api + jar + RELEASE80 + compile + + + org-openide-awt + org.netbeans.api + jar + RELEASE80 + compile + + + org-openide-util + org.netbeans.api + jar + RELEASE80 + compile + + + org-openide-util-lookup + org.netbeans.api + jar + RELEASE80 + compile + diff -r caac10b379ae -r 9073c01ba497 minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java --- a/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java Mon Sep 08 17:13:40 2014 +0200 +++ b/minesweeper/src/main/java/org/apidesign/demo/minesweeper/MinesModel.java Mon Sep 08 17:15:18 2014 +0200 @@ -23,15 +23,28 @@ */ package org.apidesign.demo.minesweeper; +import java.awt.event.ActionEvent; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.Action; import net.java.html.json.ComputedProperty; import net.java.html.json.Function; import net.java.html.json.Model; import net.java.html.json.ModelOperation; import net.java.html.json.Property; import net.java.html.sound.AudioClip; +import org.openide.awt.HtmlBrowser; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.ContextAwareAction; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; +import org.openide.util.Utilities; /** Model of the mine field. */ @@ -114,6 +127,42 @@ } } + private static final Logger LOG = Logger.getLogger(MinesModel.class.getName()); + @Function static void develop(Mines model) { + Action a = null; + try { + ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class); + if (l == null) { + l = Thread.currentThread().getContextClassLoader(); + } + if (l == null) { + l = MinesModel.class.getClassLoader(); + } + Class newPrj = Class.forName("org.netbeans.spi.project.ui.support.CommonProjectActions", true, l); // NOI18N + a = (Action) newPrj.getMethod("newProjectAction").invoke(null); // NOI18N + } catch (Exception ex) { + LOG.log(Level.FINE, "Cannot find New project action!", ex); + } + if (a != null) { + FileObject fo = FileUtil.getConfigFile("Templates/Project/ClientSide"); // NOI18N + if (fo != null) { + a.putValue("PRESELECT_CATEGORY", "ClientSide"); // NOI18N + for (FileObject template : fo.getChildren()) { + if (template.getName().contains("htmljava")) { // NOI18N + a.putValue("PRESELECT_TEMPLATE", template.getName()); // NOI18N + a.actionPerformed(new ActionEvent(model, 0, null)); + return; + } + } + } + } + try { + HtmlBrowser.URLDisplayer.getDefault().showURL(new URL("http://wiki.apidesign.org/wiki/DukeScriptInNetBeans")); // NO18N + } catch (MalformedURLException ex) { + Exceptions.printStackTrace(ex); + } + } + @ModelOperation static void init(Mines model, int width, int height, int mines) { List rows = model.getRows(); if (rows.size() != height || rows.get(0).getColumns().size() != width) { diff -r caac10b379ae -r 9073c01ba497 minesweeper/src/main/webapp/pages/index.html --- a/minesweeper/src/main/webapp/pages/index.html Mon Sep 08 17:13:40 2014 +0200 +++ b/minesweeper/src/main/webapp/pages/index.html Mon Sep 08 17:15:18 2014 +0200 @@ -226,6 +226,7 @@ Develop »

diff -r caac10b379ae -r 9073c01ba497 minesweeper/src/main/webapp/pages/index_cs.html --- a/minesweeper/src/main/webapp/pages/index_cs.html Mon Sep 08 17:13:40 2014 +0200 +++ b/minesweeper/src/main/webapp/pages/index_cs.html Mon Sep 08 17:15:18 2014 +0200 @@ -229,6 +229,7 @@ Vyvíjejte »