Skip to content

Commit

Permalink
Add Create Test Action #10
Browse files Browse the repository at this point in the history
  • Loading branch information
junichi11 committed Mar 12, 2013
1 parent 96def61 commit 6d30196
Show file tree
Hide file tree
Showing 6 changed files with 414 additions and 14 deletions.
4 changes: 2 additions & 2 deletions nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=31d4805f
build.xml.data.CRC32=85c45b08
build.xml.script.CRC32=13f27564
build.xml.stylesheet.CRC32=[email protected]
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=31d4805f
nbproject/build-impl.xml.data.CRC32=85c45b08
nbproject/build-impl.xml.script.CRC32=56425413
nbproject/build-impl.xml.stylesheet.CRC32=[email protected]
8 changes: 8 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@
<specification-version>1.35</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.loaders</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.44.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.nodes</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.text.JTextComponent;
import org.nbphpcouncil.modules.php.yii.util.YiiDocUtils;
import org.nbphpcouncil.modules.php.yii.util.YiiUtils;
import org.netbeans.api.editor.EditorRegistry;
import org.netbeans.modules.php.api.phpmodule.PhpModule;
import org.netbeans.modules.php.spi.framework.actions.BaseAction;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.actions.Presenter;

/**
Expand All @@ -66,31 +69,38 @@
@ActionRegistration(
lazy = false,
displayName = "#LBL_Yii")
@ActionReference(path = "Editors/text/x-php5/Popup", position = 550)
@ActionReferences({
@ActionReference(path = "Editors/text/x-php5/Popup", position = 550),
@ActionReference(path = "Loaders/text/x-php5/Actions", position = 1150)
})
@NbBundle.Messages("LBL_Yii=Yii")
public class YiiEditorPresenterPopup extends BaseAction implements Presenter.Popup {
public class YiiActionPresenterPopup extends BaseAction implements Presenter.Popup {

private static final long serialVersionUID = 274389136242107099L;
private static YiiEditorPresenterPopup INSTANCE = new YiiEditorPresenterPopup();
private static YiiActionPresenterPopup INSTANCE = new YiiActionPresenterPopup();

private YiiEditorPresenterPopup() {
private YiiActionPresenterPopup() {
}

public static YiiEditorPresenterPopup getInstance() {
public static YiiActionPresenterPopup getInstance() {
return INSTANCE;
}

@Override
public JMenuItem getPopupPresenter() {
// get current editor
JTextComponent editor = EditorRegistry.lastFocusedComponent();
if (editor != null) {
FileObject fileObject = YiiDocUtils.getFileObject(editor.getDocument());
PhpModule phpModule = PhpModule.forFileObject(fileObject);
Lookup context = Utilities.actionsGlobalContext();
JTextComponent editor = EditorRegistry.focusedComponent();
DataObject dataObject = context.lookup(DataObject.class);
FileObject currentFile = dataObject.getPrimaryFile();
if (currentFile != null) {
PhpModule phpModule = PhpModule.forFileObject(currentFile);
if (YiiUtils.isYii(phpModule)) {
// set menu
JMenu menu = new JMenu(Bundle.LBL_Yii());
menu.add(new JMenuItem(YiiRunActionAction.getInstance()));
if (editor != null) {
menu.add(new JMenuItem(YiiRunActionAction.getInstance()));
}
menu.add(new JMenuItem(YiiCreateTestAction.getInstance()));
return menu;
}
}
Expand Down
Loading

0 comments on commit 6d30196

Please sign in to comment.