Skip to content

Commit

Permalink
Merge branch 'netbeans73dev' into netbeans73
Browse files Browse the repository at this point in the history
  • Loading branch information
junichi11 committed Sep 20, 2013
2 parents 1bfc4b2 + 16b764b commit 0084057
Show file tree
Hide file tree
Showing 17 changed files with 387 additions and 226 deletions.
2 changes: 1 addition & 1 deletion manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions src/org/cakephp/netbeans/CakePhpFrameworkProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/org/cakephp/netbeans/CakePhpIgnoredFilesExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
28 changes: 18 additions & 10 deletions src/org/cakephp/netbeans/CakePhpModuleCustomizerExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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
Expand All @@ -107,13 +111,18 @@ public String getErrorMessage() {
return null;
}

public void fireChange() {
changeSupport.fireChange();
}

@Override
public EnumSet<Change> save(PhpModule phpModule) {
EnumSet<Change> 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);
}
Expand All @@ -130,8 +139,9 @@ public EnumSet<Change> 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;
}
Expand All @@ -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;
}
Expand Down
13 changes: 9 additions & 4 deletions src/org/cakephp/netbeans/commands/CakeScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -148,7 +147,8 @@ public static String getOptionsPath() {
}

public void runCommand(PhpModule phpModule, List<String> 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());
Expand Down Expand Up @@ -358,7 +358,11 @@ private List<FrameworkCommand> getFrameworkCommandsInternalConsole(PhpModule php
// cakephp1.3+
List<FrameworkCommand> commands = new ArrayList<FrameworkCommand>();
List<FileObject> shellDirs = new ArrayList<FileObject>();
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);
Expand Down Expand Up @@ -388,7 +392,8 @@ private List<FrameworkCommand> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
40 changes: 30 additions & 10 deletions src/org/cakephp/netbeans/module/CakePhp1ModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -555,4 +571,8 @@ public FILE_TYPE getFileType(FileObject currentFile) {

return FILE_TYPE.NONE;
}

@Override
public void refresh() {
}
}
36 changes: 26 additions & 10 deletions src/org/cakephp/netbeans/module/CakePhp2ModuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit 0084057

Please sign in to comment.