diff --git a/manifest.mf b/manifest.mf index 9830ee2..9b9a7c8 100644 --- a/manifest.mf +++ b/manifest.mf @@ -2,4 +2,4 @@ Manifest-Version: 1.0 OpenIDE-Module: org.cakephp.netbeans OpenIDE-Module-Layer: org/cakephp/netbeans/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/cakephp/netbeans/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 0.9.3 +OpenIDE-Module-Specification-Version: 0.9.4 diff --git a/src/org/cakephp/netbeans/CakePhpFrameworkProvider.java b/src/org/cakephp/netbeans/CakePhpFrameworkProvider.java index e5fbc56..5629aa3 100644 --- a/src/org/cakephp/netbeans/CakePhpFrameworkProvider.java +++ b/src/org/cakephp/netbeans/CakePhpFrameworkProvider.java @@ -106,12 +106,7 @@ public boolean isInPhpModule(PhpModule phpModule) { if (module == null) { return false; } - FileObject app = module.getDirectory(DIR_TYPE.APP); - if (app == null) { - return false; - } - FileObject cake = module.getDirectory(DIR_TYPE.CORE); - return cake != null && cake.isFolder(); + return module.isInCakePhp(); } @Override @@ -142,7 +137,12 @@ public PhpModuleExtender createPhpModuleExtender(PhpModule phpModule) { @Override public PhpModuleCustomizerExtender createPhpModuleCustomizerExtender(PhpModule phpModule) { - return new CakePhpModuleCustomizerExtender(phpModule); + CakePhpModuleCustomizerExtender customizer = new CakePhpModuleCustomizerExtender(phpModule); + CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule); + if (cakeModule != null) { + customizer.addChangeListener(cakeModule); + } + return customizer; } @Override diff --git a/src/org/cakephp/netbeans/CakePhpIgnoredFilesExtender.java b/src/org/cakephp/netbeans/CakePhpIgnoredFilesExtender.java index 157c94c..28158ce 100755 --- a/src/org/cakephp/netbeans/CakePhpIgnoredFilesExtender.java +++ b/src/org/cakephp/netbeans/CakePhpIgnoredFilesExtender.java @@ -45,6 +45,7 @@ import java.util.Collections; import java.util.Set; import org.cakephp.netbeans.module.CakePhpModule; +import org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE; import org.cakephp.netbeans.preferences.CakePreferences; import org.netbeans.modules.php.api.phpmodule.PhpModule; import org.netbeans.modules.php.spi.framework.PhpModuleIgnoredFilesExtender; @@ -58,7 +59,12 @@ public class CakePhpIgnoredFilesExtender extends PhpModuleIgnoredFilesExtender { public CakePhpIgnoredFilesExtender(PhpModule phpModule) { assert phpModule != null; if (CakePreferences.ignoreTmpDirectory(phpModule)) { - appTmp = new File(FileUtil.toFile(CakePhpModule.getCakePhpDirectory(phpModule)), CakePreferences.getAppName(phpModule) + "/tmp"); // NOI18N + CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule); + if (cakeModule == null) { + appTmp = null; + } else { + appTmp = new File(FileUtil.toFile(cakeModule.getDirectory(DIR_TYPE.APP)), "tmp"); // NOI18N + } } else { appTmp = null; } diff --git a/src/org/cakephp/netbeans/CakePhpModuleCustomizerExtender.java b/src/org/cakephp/netbeans/CakePhpModuleCustomizerExtender.java index 3d55d42..1d7b1dc 100755 --- a/src/org/cakephp/netbeans/CakePhpModuleCustomizerExtender.java +++ b/src/org/cakephp/netbeans/CakePhpModuleCustomizerExtender.java @@ -48,6 +48,7 @@ import org.cakephp.netbeans.ui.customizer.CakePhpCustomizerPanel; import org.netbeans.modules.php.api.phpmodule.PhpModule; import org.netbeans.modules.php.spi.framework.PhpModuleCustomizerExtender; +import org.openide.util.ChangeSupport; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; @@ -57,21 +58,22 @@ */ public class CakePhpModuleCustomizerExtender extends PhpModuleCustomizerExtender { - private final String appName; - private final boolean originalAutoCreateState; private CakePhpCustomizerPanel component; + private final String appDirectoryPath; private final String cakePhpDirPath; private final boolean isProjectDir; - private final boolean originalIgnoreTmpDirectory; private final boolean isShowPopupForOneItem; + private final boolean originalAutoCreateState; + private final boolean originalIgnoreTmpDirectory; + private ChangeSupport changeSupport = new ChangeSupport(this); CakePhpModuleCustomizerExtender(PhpModule phpModule) { - appName = CakePreferences.getAppName(phpModule); originalAutoCreateState = CakePreferences.getAutoCreateView(phpModule); cakePhpDirPath = CakePreferences.getCakePhpDirPath(phpModule); isProjectDir = CakePreferences.useProjectDirectory(phpModule); originalIgnoreTmpDirectory = CakePreferences.ignoreTmpDirectory(phpModule); isShowPopupForOneItem = CakePreferences.isShowPopupForOneItem(phpModule); + appDirectoryPath = CakePreferences.getAppDirectoryPath(phpModule); } @Override @@ -81,10 +83,12 @@ public String getDisplayName() { @Override public void addChangeListener(ChangeListener listener) { + changeSupport.addChangeListener(listener); } @Override public void removeChangeListener(ChangeListener listener) { + changeSupport.removeChangeListener(listener); } @Override @@ -107,13 +111,18 @@ public String getErrorMessage() { return null; } + public void fireChange() { + changeSupport.fireChange(); + } + @Override public EnumSet save(PhpModule phpModule) { EnumSet enumset = EnumSet.of(Change.FRAMEWORK_CHANGE); - String newAppName = getPanel().getAppNameField().getText(); boolean newAutoCreateState = getPanel().isAutoCreateView(); String newCakePhpDirPath = getPanel().getCakePhpDirTextField(); boolean newIgnoreTmpDirectory = getPanel().ignoreTmpDirectory(); + String newAppDirectoryPath = getPanel().getAppDirectoryPath(); + if (newAutoCreateState != originalAutoCreateState) { CakePreferences.setAutoCreateView(phpModule, newAutoCreateState); } @@ -130,8 +139,9 @@ public EnumSet save(PhpModule phpModule) { CakePreferences.setIgnoreTmpDirectory(phpModule, newIgnoreTmpDirectory); enumset.add(Change.IGNORED_FILES_CHANGE); } - if (!newAppName.equals(appName) && !newAppName.equals("")) { // NOI18N - CakePreferences.setAppName(phpModule, newAppName); + if (!newAppDirectoryPath.equals(appDirectoryPath) && !newAppDirectoryPath.isEmpty()) { + CakePreferences.setAppDirectoryPath(phpModule, newAppDirectoryPath); + fireChange(); } return enumset; } @@ -140,13 +150,11 @@ private CakePhpCustomizerPanel getPanel() { if (component == null) { component = new CakePhpCustomizerPanel(); component.setAutoCreateView(originalAutoCreateState); - if (!appName.equals("")) { - component.setAppNameField(appName); - } component.setCakePhpDirTextField(cakePhpDirPath); component.setUseProjectDirectory(isProjectDir); component.setIgnoreTmpDirectory(originalIgnoreTmpDirectory); component.setShowPopupForOneItem(isShowPopupForOneItem); + component.setAppDirectoryPath(appDirectoryPath); } return component; } diff --git a/src/org/cakephp/netbeans/commands/CakeScript.java b/src/org/cakephp/netbeans/commands/CakeScript.java index 09020bb..e3f5cf2 100755 --- a/src/org/cakephp/netbeans/commands/CakeScript.java +++ b/src/org/cakephp/netbeans/commands/CakeScript.java @@ -55,7 +55,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.cakephp.netbeans.module.CakePhpModule; -import org.cakephp.netbeans.preferences.CakePreferences; import org.cakephp.netbeans.util.CakeVersion; import org.netbeans.api.extexecution.ExecutionDescriptor; import org.netbeans.api.extexecution.input.InputProcessor; @@ -148,7 +147,8 @@ public static String getOptionsPath() { } public void runCommand(PhpModule phpModule, List parameters, Runnable postExecution) { - if (!CakePreferences.getAppName(phpModule).equals("app")) { // NOI18N + CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule); + if (!"app".equals(cakeModule.getAppName())) { // NOI18N FileObject app = CakePhpModule.forPhpModule(phpModule).getDirectory(CakePhpModule.DIR_TYPE.APP); appParams.add("-app"); // NOI18N appParams.add(app.getPath()); @@ -358,7 +358,11 @@ private List getFrameworkCommandsInternalConsole(PhpModule php // cakephp1.3+ List commands = new ArrayList(); List shellDirs = new ArrayList(); - String[] shells = {CORE_SHELLS_DIRECTORY, VENDORS_SHELLS_DIRECTORY, CakePreferences.getAppName(phpModule) + "/" + VENDORS_SHELLS_DIRECTORY}; + CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule); + if (cakeModule == null) { + return commands; + } + String[] shells = {CORE_SHELLS_DIRECTORY, VENDORS_SHELLS_DIRECTORY, cakeModule.getAppName() + "/" + VENDORS_SHELLS_DIRECTORY}; for (String shell : shells) { FileObject shellFileObject = CakePhpModule.getCakePhpDirectory(phpModule).getFileObject(shell); @@ -388,7 +392,8 @@ private List getFrameworkCommandsInternalConsole(PhpModule php private String getShellsPlace(PhpModule phpModule, FileObject shellDir) { String place = ""; // NOI18N - String app = CakePreferences.getAppName(phpModule); + CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule); + String app = cakeModule.getAppName(); FileObject source = CakePhpModule.getCakePhpDirectory(phpModule); if (source.getFileObject(CORE_SHELLS_DIRECTORY) == shellDir) { place = "CORE"; // NOI18N diff --git a/src/org/cakephp/netbeans/editor/codecompletion/CakePhp3EditorExtender.java b/src/org/cakephp/netbeans/editor/codecompletion/CakePhp3EditorExtender.java index effb1ee..6d26dc5 100644 --- a/src/org/cakephp/netbeans/editor/codecompletion/CakePhp3EditorExtender.java +++ b/src/org/cakephp/netbeans/editor/codecompletion/CakePhp3EditorExtender.java @@ -43,7 +43,6 @@ import org.cakephp.netbeans.editor.CakePhpEditorExtender; import org.cakephp.netbeans.module.CakePhpModule; -import org.cakephp.netbeans.preferences.CakePreferences; import org.cakephp.netbeans.util.CakePhpUtils; import org.netbeans.modules.php.api.editor.PhpClass; import org.netbeans.modules.php.api.phpmodule.PhpModule; @@ -79,7 +78,9 @@ public PhpClass getComponentPhpClass() { @Override public PhpClass getHelperPhpClass() { String className = "AppHelper"; // NOI18N - String fullyQualifiedName = "\\" + CakePreferences.getAppName(PhpModule.inferPhpModule()) + "\\" + className; // NOI18N + CakePhpModule cakeModule = CakePhpModule.forPhpModule(PhpModule.inferPhpModule()); + String appName = cakeModule == null ? "" : cakeModule.getAppName(); + String fullyQualifiedName = "\\" + appName + "\\" + className; // NOI18N return new PhpClass(className, fullyQualifiedName); } diff --git a/src/org/cakephp/netbeans/module/CakePhp1ModuleImpl.java b/src/org/cakephp/netbeans/module/CakePhp1ModuleImpl.java index a224ec4..70c0d91 100644 --- a/src/org/cakephp/netbeans/module/CakePhp1ModuleImpl.java +++ b/src/org/cakephp/netbeans/module/CakePhp1ModuleImpl.java @@ -46,8 +46,11 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE; +import static org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE.APP; +import static org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE.APP_LIB; +import static org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE.APP_PLUGIN; +import static org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE.APP_VENDOR; import org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE; -import org.cakephp.netbeans.preferences.CakePreferences; import org.cakephp.netbeans.util.CakePhpUtils; import org.netbeans.modules.php.api.editor.PhpBaseElement; import org.netbeans.modules.php.api.editor.PhpClass; @@ -77,6 +80,7 @@ public class CakePhp1ModuleImpl extends CakePhpModuleImpl { private static final String DIR_HELPERS = "helpers"; private static final String DIR_BEHAVIORS = "behaviors"; private static final String DIR_FIXTURES = "fixtures"; + private FileObject appDirectory; public CakePhp1ModuleImpl(PhpModule phpModule) { super(phpModule); @@ -264,20 +268,12 @@ public FileObject getDirectory(DIR_TYPE type) { return null; } String path = ""; // NOI18N - String app = CakePreferences.getAppName(phpModule); switch (type) { case APP: - path = app; - break; case APP_LIB: - path = app + "/libs"; // NOI18N - break; case APP_PLUGIN: - path = app + "/plugins"; // NOI18N - break; case APP_VENDOR: - path = app + "/vendors"; // NOI18N - break; + return getAppDirectory(type); case CORE: path = "cake"; // NOI18N break; @@ -294,6 +290,26 @@ public FileObject getDirectory(DIR_TYPE type) { return cakePhpDirectory.getFileObject(path); } + private FileObject getAppDirectory(DIR_TYPE dirType) { + FileObject appDir = getAppDirectory(); + if (appDir == null) { + return null; + } + + switch (dirType) { + case APP: + return appDir; + case APP_LIB: + return appDir.getFileObject("libs"); // NOI18N + case APP_PLUGIN: + return appDir.getFileObject("plugins"); // NOI18N + case APP_VENDOR: + return appDir.getFileObject("vendors"); // NOI18N + default: + throw new AssertionError(); + } + } + @Override public String getFileNameWithExt(FILE_TYPE type, String name) { if (type == FILE_TYPE.CONTROLLER) { @@ -555,4 +571,8 @@ public FILE_TYPE getFileType(FileObject currentFile) { return FILE_TYPE.NONE; } + + @Override + public void refresh() { + } } diff --git a/src/org/cakephp/netbeans/module/CakePhp2ModuleImpl.java b/src/org/cakephp/netbeans/module/CakePhp2ModuleImpl.java index adfc7f9..8ffb7ab 100644 --- a/src/org/cakephp/netbeans/module/CakePhp2ModuleImpl.java +++ b/src/org/cakephp/netbeans/module/CakePhp2ModuleImpl.java @@ -47,7 +47,6 @@ import java.util.logging.Logger; import org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE; import org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE; -import org.cakephp.netbeans.preferences.CakePreferences; import org.cakephp.netbeans.util.CakePhpUtils; import org.netbeans.modules.php.api.editor.PhpBaseElement; import org.netbeans.modules.php.api.editor.PhpClass; @@ -83,6 +82,11 @@ public CakePhp2ModuleImpl(PhpModule phpModule) { super(phpModule); } + @Override + public void refresh() { + setAppDirectory(); + } + @Override public FileObject getDirectory(DIR_TYPE type, FILE_TYPE fileType, String pluginName) { if (type == null) { @@ -203,20 +207,12 @@ public FileObject getDirectory(DIR_TYPE type) { return null; } String path = ""; // NOI18N - String app = CakePreferences.getAppName(phpModule); switch (type) { case APP: - path = app; - break; case APP_LIB: - path = app + "/Lib"; // NOI18N - break; case APP_PLUGIN: - path = app + "/Plugin"; // NOI18N - break; case APP_VENDOR: - path = app + "/Vendor"; // NOI18N - break; + return getAppDirectory(type); case CORE: path = "lib/Cake"; // NOI18N break; @@ -233,6 +229,26 @@ public FileObject getDirectory(DIR_TYPE type) { return sourceDirectory.getFileObject(path); } + private FileObject getAppDirectory(DIR_TYPE dirType) { + FileObject appDir = getAppDirectory(); + if (appDir == null) { + return null; + } + + switch (dirType) { + case APP: + return appDir; + case APP_LIB: + return appDir.getFileObject("Lib"); // NOI18N + case APP_PLUGIN: + return appDir.getFileObject("Plugin"); // NOI18N + case APP_VENDOR: + return appDir.getFileObject("Vendor"); // NOI18N + default: + throw new AssertionError(); + } + } + @Override public String getFileNameWithExt(FILE_TYPE type, String name) { if (type != null) { diff --git a/src/org/cakephp/netbeans/module/CakePhp3ModuleImpl.java b/src/org/cakephp/netbeans/module/CakePhp3ModuleImpl.java index 5e25858..b31f726 100644 --- a/src/org/cakephp/netbeans/module/CakePhp3ModuleImpl.java +++ b/src/org/cakephp/netbeans/module/CakePhp3ModuleImpl.java @@ -61,7 +61,6 @@ import static org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE.TEST; import static org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE.VIEW; import static org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE.WEBROOT; -import org.cakephp.netbeans.preferences.CakePreferences; import org.netbeans.modules.php.api.phpmodule.PhpModule; import org.openide.filesystems.FileObject; @@ -190,20 +189,12 @@ public FileObject getDirectory(CakePhpModule.DIR_TYPE type) { return null; } String path = ""; // NOI18N - String app = CakePreferences.getAppName(phpModule); switch (type) { case APP: - path = app; - break; case APP_LIB: - path = app + "/Lib"; // NOI18N - break; case APP_PLUGIN: - path = app + "/Plugin"; // NOI18N - break; case APP_VENDOR: - path = app + "/vendor"; // NOI18N - break; + return getAppDirectory(type); case CORE: path = "lib/Cake"; // NOI18N break; @@ -217,6 +208,26 @@ public FileObject getDirectory(CakePhpModule.DIR_TYPE type) { return sourceDirectory.getFileObject(path); } + private FileObject getAppDirectory(CakePhpModule.DIR_TYPE dirType) { + FileObject appDir = getAppDirectory(); + if (appDir == null) { + return null; + } + + switch (dirType) { + case APP: + return appDir; + case APP_LIB: + return appDir.getFileObject("Lib"); // NOI18N + case APP_PLUGIN: + return appDir.getFileObject("Plugin"); // NOI18N + case APP_VENDOR: + return appDir.getFileObject("vendor"); // NOI18N + default: + throw new AssertionError(); + } + } + /** * Get namespace. * diff --git a/src/org/cakephp/netbeans/module/CakePhpModule.java b/src/org/cakephp/netbeans/module/CakePhpModule.java index f5e1887..035b0d7 100644 --- a/src/org/cakephp/netbeans/module/CakePhpModule.java +++ b/src/org/cakephp/netbeans/module/CakePhpModule.java @@ -45,6 +45,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import org.cakephp.netbeans.preferences.CakePreferences; import org.netbeans.modules.php.api.editor.PhpBaseElement; import org.netbeans.modules.php.api.phpmodule.PhpModule; @@ -56,7 +58,7 @@ * * @author junichi11 */ -public class CakePhpModule { +public class CakePhpModule implements ChangeListener { private PhpModule phpModule; private CakePhpModuleImpl impl; @@ -76,6 +78,19 @@ public void fileRenamed(FileRenameEvent fe) { }); } + public String getAppName() { + FileObject appName = getDirectory(DIR_TYPE.APP); + if (appName != null) { + return appName.getName(); + } + return null; + } + + @Override + public void stateChanged(ChangeEvent e) { + impl.refresh(); + } + public enum DIR_TYPE { NONE, @@ -384,7 +399,20 @@ public FileObject createView(FileObject controller, PhpBaseElement phpElement) t return impl.createView(controller, phpElement); } + public boolean isInCakePhp() { + FileObject console = getDirectory(DIR_TYPE.APP, FILE_TYPE.CONSOLE, null); + if (console == null) { + return false; + } + + FileObject cake = getDirectory(DIR_TYPE.CORE); + return cake != null && cake.isFolder(); + } + public static CakePhpModule forPhpModule(PhpModule phpModule) { + if (phpModule == null) { + phpModule = PhpModule.inferPhpModule(); + } CakePhpModuleFactory factory = CakePhpModuleFactory.getInstance(); return factory.create(phpModule); } diff --git a/src/org/cakephp/netbeans/module/CakePhpModuleFactory.java b/src/org/cakephp/netbeans/module/CakePhpModuleFactory.java index 52ec24e..d2cad02 100644 --- a/src/org/cakephp/netbeans/module/CakePhpModuleFactory.java +++ b/src/org/cakephp/netbeans/module/CakePhpModuleFactory.java @@ -43,7 +43,8 @@ import java.util.HashMap; import java.util.Map; -import org.cakephp.netbeans.preferences.CakePreferences; +import org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE; +import org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE; import org.cakephp.netbeans.util.CakeVersion; import org.netbeans.modules.php.api.phpmodule.PhpModule; import org.openide.filesystems.FileObject; @@ -94,9 +95,8 @@ public synchronized CakePhpModule create(PhpModule phpModule) { if (impl == null) { return null; } - String appName = CakePreferences.getAppName(phpModule); - FileObject app = CakePhpModule.getCakePhpDirectory(phpModule).getFileObject(appName); - if (app == null) { + FileObject console = impl.getDirectory(DIR_TYPE.APP, FILE_TYPE.CONSOLE); + if (console == null) { return null; } // create module class diff --git a/src/org/cakephp/netbeans/module/CakePhpModuleImpl.java b/src/org/cakephp/netbeans/module/CakePhpModuleImpl.java index 963bbeb..0a3d180 100644 --- a/src/org/cakephp/netbeans/module/CakePhpModuleImpl.java +++ b/src/org/cakephp/netbeans/module/CakePhpModuleImpl.java @@ -48,6 +48,7 @@ import java.util.regex.Pattern; import org.cakephp.netbeans.module.CakePhpModule.DIR_TYPE; import org.cakephp.netbeans.module.CakePhpModule.FILE_TYPE; +import org.cakephp.netbeans.preferences.CakePreferences; import org.netbeans.modules.php.api.editor.PhpBaseElement; import org.netbeans.modules.php.api.phpmodule.PhpModule; import org.netbeans.modules.php.api.util.StringUtils; @@ -57,11 +58,12 @@ * * @author junichi11 */ -public abstract class CakePhpModuleImpl { +public abstract class CakePhpModuleImpl{ protected PhpModule phpModule; protected static String PHP_EXT = "php"; protected static String CTP_EXT = "ctp"; + private FileObject appDirectory; public CakePhpModuleImpl(PhpModule phpModule) { this.phpModule = phpModule; @@ -275,6 +277,25 @@ protected FileObject getDirectory(DIR_TYPE type, FILE_TYPE fileType) { public abstract FileObject getDirectory(DIR_TYPE type); + protected FileObject getAppDirectory() { + if (appDirectory != null) { + return appDirectory; + } + setAppDirectory(); + + return appDirectory; + } + + protected void setAppDirectory() { + // custom + String appDirectoryPath = CakePreferences.getAppDirectoryPath(phpModule); + if (!StringUtils.isEmpty(appDirectoryPath)) { + appDirectory = phpModule.getProjectDirectory().getFileObject(appDirectoryPath); + return; + } + appDirectory = null; + } + /** * Get DIR_TYPE for current file. * @@ -391,4 +412,6 @@ protected FileObject getFile(String pluginName, DIR_TYPE dirType, FILE_TYPE file targetPath = targetPath + getFileNameWithExt(fileType, fileName); return targetDirectory.getFileObject(targetPath); } + + public abstract void refresh(); } diff --git a/src/org/cakephp/netbeans/preferences/CakePreferences.java b/src/org/cakephp/netbeans/preferences/CakePreferences.java index 1a2b67a..87fe654 100755 --- a/src/org/cakephp/netbeans/preferences/CakePreferences.java +++ b/src/org/cakephp/netbeans/preferences/CakePreferences.java @@ -59,6 +59,7 @@ public class CakePreferences { private static final String USE_PROJECT_DIRECTORY = "use-project-directory"; // NOI18N private static final String IGNORE_TMP_DIRECTORY = "ignore-tmp-directory"; // NOI18N private static final String SHOW_POPUP_FOR_ONE_ITEM = "show-popup-for-one-item"; // NOI18N + private static final String APP_DIRECTORY_PATH = "app-directory-path"; // NOI18N public static void setAppName(PhpModule phpModule, String appName) { getPreferences(phpModule).put(APP_NAME, appName); @@ -118,6 +119,15 @@ public static boolean isShowPopupForOneItem(PhpModule phpModule) { return getPreferences(phpModule).getBoolean(SHOW_POPUP_FOR_ONE_ITEM, true); } + public static String getAppDirectoryPath(PhpModule phpModule) { + String appName = getAppName(phpModule); + return getPreferences(phpModule).get(APP_DIRECTORY_PATH, appName); + } + + public static void setAppDirectoryPath(PhpModule phpModule, String path) { + getPreferences(phpModule).put(APP_DIRECTORY_PATH, path); + } + private static Preferences getPreferences(PhpModule phpModule) { return phpModule.getPreferences(CakePreferences.class, true); } diff --git a/src/org/cakephp/netbeans/ui/customizer/Bundle.properties b/src/org/cakephp/netbeans/ui/customizer/Bundle.properties index ceb8ae9..659ecca 100755 --- a/src/org/cakephp/netbeans/ui/customizer/Bundle.properties +++ b/src/org/cakephp/netbeans/ui/customizer/Bundle.properties @@ -1,45 +1,3 @@ -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. -# -# Copyright 2012 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 2012 Sun Microsystems, Inc. - -CakePhpCustomizerPanel.appNameField.text=app -CakePhpCustomizerPanel.appNameLabel.text=app Folder name : CakePhpCustomizerPanel.autoCreateViewCheckBox.text=Auto create a view file when go to view action is run. CakePhpCustomizerPanel.cakePhpDirLabel.text=CakePHP Directory : CakePhpCustomizerPanel.cakePhpDirTextField.text= @@ -47,3 +5,7 @@ CakePhpCustomizerPanel.useProjectDirectoryCheckBox.text=Use the relative path to CakePhpCustomizerPanel.ignoreTmpCheckBox.text=ignore tmp directory CakePhpCustomizerPanel.goToActionsLabel.text=Go To Actions: CakePhpCustomizerPanel.showPopupForOneItemCheckBox.text=Show the popup for one candidate item. +CakePhpCustomizerPanel.appDirectoryTextField.text= +CakePhpCustomizerPanel.appDirectoryLabel.text=app: +CakePhpCustomizerPanel.customDirectoryPathLabel.text=Custom directory path (from project directory): +CakePhpCustomizerPanel.generalLabel.text=General: diff --git a/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.form b/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.form index 4b76df1..3e2309a 100755 --- a/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.form +++ b/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.form @@ -20,31 +20,52 @@ - - - - - - - - - - - - - + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - @@ -52,12 +73,31 @@ - - - + + + + + + + + + + + + + + + + + + + + + + @@ -65,38 +105,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -110,6 +124,9 @@ + + + @@ -148,5 +165,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.java b/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.java index 018bb47..707bcad 100755 --- a/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.java +++ b/src/org/cakephp/netbeans/ui/customizer/CakePhpCustomizerPanel.java @@ -46,10 +46,7 @@ */ package org.cakephp.netbeans.ui.customizer; -import javax.swing.JTextField; import javax.swing.event.ChangeListener; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import org.openide.util.ChangeSupport; /** @@ -66,34 +63,6 @@ public class CakePhpCustomizerPanel extends javax.swing.JPanel { */ public CakePhpCustomizerPanel() { initComponents(); - init(); - } - - private void init() { - appNameField.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void insertUpdate(DocumentEvent e) { - fireChange(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - fireChange(); - } - - @Override - public void changedUpdate(DocumentEvent e) { - fireChange(); - } - }); - } - - public JTextField getAppNameField() { - return appNameField; - } - - public void setAppNameField(String appName) { - appNameField.setText(appName); } public boolean isAutoCreateView() { @@ -110,6 +79,7 @@ public boolean isUseProjectDirectory() { public void setUseProjectDirectory(boolean isCheck) { useProjectDirectoryCheckBox.setSelected(isCheck); + setEnabledCakePhpDirectory(); } public String getCakePhpDirTextField() { @@ -136,6 +106,14 @@ public void setShowPopupForOneItem(boolean isEnabled) { showPopupForOneItemCheckBox.setSelected(isEnabled); } + public String getAppDirectoryPath() { + return appDirectoryTextField.getText(); + } + + public void setAppDirectoryPath(String path) { + appDirectoryTextField.setText(path); + } + public void addChangeListener(ChangeListener changeListener) { changeSupport.addChangeListener(changeListener); } @@ -148,6 +126,11 @@ void fireChange() { changeSupport.fireChange(); } + public void setEnabledCakePhpDirectory() { + boolean selected = useProjectDirectoryCheckBox.isSelected(); + cakePhpDirTextField.setEnabled(selected); + } + /** * 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 @@ -157,8 +140,6 @@ void fireChange() { // //GEN-BEGIN:initComponents private void initComponents() { - appNameLabel = new javax.swing.JLabel(); - appNameField = new javax.swing.JTextField(); autoCreateViewCheckBox = new javax.swing.JCheckBox(); useProjectDirectoryCheckBox = new javax.swing.JCheckBox(); cakePhpDirLabel = new javax.swing.JLabel(); @@ -167,20 +148,22 @@ private void initComponents() { goToActionsLabel = new javax.swing.JLabel(); goToActionsSeparator = new javax.swing.JSeparator(); showPopupForOneItemCheckBox = new javax.swing.JCheckBox(); + customDirectoryPathLabel = new javax.swing.JLabel(); + customDirectoryPathSeparator = new javax.swing.JSeparator(); + appDirectoryLabel = new javax.swing.JLabel(); + appDirectoryTextField = new javax.swing.JTextField(); + generalLabel = new javax.swing.JLabel(); + generalSeparator = new javax.swing.JSeparator(); - appNameLabel.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.appNameLabel.text")); // NOI18N + autoCreateViewCheckBox.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.autoCreateViewCheckBox.text")); // NOI18N - appNameField.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.appNameField.text")); // NOI18N - appNameField.addActionListener(new java.awt.event.ActionListener() { + useProjectDirectoryCheckBox.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.useProjectDirectoryCheckBox.text")); // NOI18N + useProjectDirectoryCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - appNameFieldActionPerformed(evt); + useProjectDirectoryCheckBoxActionPerformed(evt); } }); - autoCreateViewCheckBox.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.autoCreateViewCheckBox.text")); // NOI18N - - useProjectDirectoryCheckBox.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.useProjectDirectoryCheckBox.text")); // NOI18N - cakePhpDirLabel.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.cakePhpDirLabel.text")); // NOI18N cakePhpDirTextField.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.cakePhpDirTextField.text")); // NOI18N @@ -191,6 +174,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { showPopupForOneItemCheckBox.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.showPopupForOneItemCheckBox.text")); // NOI18N + customDirectoryPathLabel.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.customDirectoryPathLabel.text")); // NOI18N + + appDirectoryLabel.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.appDirectoryLabel.text")); // NOI18N + + appDirectoryTextField.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.appDirectoryTextField.text")); // NOI18N + + generalLabel.setText(org.openide.util.NbBundle.getMessage(CakePhpCustomizerPanel.class, "CakePhpCustomizerPanel.generalLabel.text")); // NOI18N + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -199,62 +190,89 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(appNameLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(appNameField)) - .addGroup(layout.createSequentialGroup() - .addComponent(cakePhpDirLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(cakePhpDirTextField)) - .addGroup(layout.createSequentialGroup() - .addComponent(goToActionsLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(goToActionsSeparator)) - .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(autoCreateViewCheckBox) - .addComponent(useProjectDirectoryCheckBox) - .addComponent(ignoreTmpCheckBox) .addComponent(showPopupForOneItemCheckBox)) - .addGap(0, 0, Short.MAX_VALUE))) - .addContainerGap()) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(goToActionsLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(goToActionsSeparator)) + .addGroup(layout.createSequentialGroup() + .addComponent(customDirectoryPathLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(customDirectoryPathSeparator)) + .addGroup(layout.createSequentialGroup() + .addComponent(generalLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(generalSeparator)) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(useProjectDirectoryCheckBox) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addComponent(cakePhpDirLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(cakePhpDirTextField)) + .addGroup(layout.createSequentialGroup() + .addComponent(appDirectoryLabel) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(appDirectoryTextField)) + .addComponent(ignoreTmpCheckBox)))) + .addContainerGap()))) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(appNameLabel) - .addComponent(appNameField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(generalLabel) + .addComponent(generalSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(ignoreTmpCheckBox) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(goToActionsLabel) + .addComponent(goToActionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(showPopupForOneItemCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(autoCreateViewCheckBox) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(customDirectoryPathLabel) + .addComponent(customDirectoryPathSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(appDirectoryLabel) + .addComponent(appDirectoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(useProjectDirectoryCheckBox) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cakePhpDirLabel) .addComponent(cakePhpDirTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(ignoreTmpCheckBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(goToActionsLabel) - .addComponent(goToActionsSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(showPopupForOneItemCheckBox) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents - private void appNameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_appNameFieldActionPerformed - // TODO add your handling code here: - }//GEN-LAST:event_appNameFieldActionPerformed + private void useProjectDirectoryCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_useProjectDirectoryCheckBoxActionPerformed + setEnabledCakePhpDirectory(); + }//GEN-LAST:event_useProjectDirectoryCheckBoxActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JTextField appNameField; - private javax.swing.JLabel appNameLabel; + private javax.swing.JLabel appDirectoryLabel; + private javax.swing.JTextField appDirectoryTextField; private javax.swing.JCheckBox autoCreateViewCheckBox; private javax.swing.JLabel cakePhpDirLabel; private javax.swing.JTextField cakePhpDirTextField; + private javax.swing.JLabel customDirectoryPathLabel; + private javax.swing.JSeparator customDirectoryPathSeparator; + private javax.swing.JLabel generalLabel; + private javax.swing.JSeparator generalSeparator; private javax.swing.JLabel goToActionsLabel; private javax.swing.JSeparator goToActionsSeparator; private javax.swing.JCheckBox ignoreTmpCheckBox; diff --git a/src/org/cakephp/netbeans/ui/wizards/InstallPluginsVisualPanel.java b/src/org/cakephp/netbeans/ui/wizards/InstallPluginsVisualPanel.java index 4c8e18b..640485f 100755 --- a/src/org/cakephp/netbeans/ui/wizards/InstallPluginsVisualPanel.java +++ b/src/org/cakephp/netbeans/ui/wizards/InstallPluginsVisualPanel.java @@ -49,9 +49,9 @@ import javax.swing.table.AbstractTableModel; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; +import org.cakephp.netbeans.module.CakePhpModule; import org.cakephp.netbeans.options.CakePhpOptions; import org.cakephp.netbeans.options.CakePhpPlugin; -import org.cakephp.netbeans.preferences.CakePreferences; import org.cakephp.netbeans.util.CakeVersion; import org.netbeans.modules.php.api.phpmodule.PhpModule; import org.openide.util.NbBundle; @@ -67,7 +67,11 @@ public final class InstallPluginsVisualPanel extends JPanel { public InstallPluginsVisualPanel(PhpModule pm) { model.setPlugins(CakePhpOptions.getInstance().getPlugins()); initComponents(); - String appName = CakePreferences.getAppName(pm); + CakePhpModule cakeModule = CakePhpModule.forPhpModule(pm); + String appName = ""; // NOI18N + if (cakeModule != null) { + appName = cakeModule.getAppName() == null ? "" : cakeModule.getAppName(); + } if (CakeVersion.getInstance(pm).getMajor() >= 2) { installPathTextField.setText(appName + "/Plugin"); // NOI18N } else {