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 Oct 11, 2013
2 parents 80bc976 + e38167f commit 1e4e0bd
Show file tree
Hide file tree
Showing 18 changed files with 704 additions and 155 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This plugin provides support for CakePHP.

## About CakePHP 3.x

This plugin recognizes CakePHP3. But many features might not work yet.
Currently, This plugin doesn't recognize CakePHP3.

## WHAT WORKS

Expand Down Expand Up @@ -82,16 +82,10 @@ CakePHP 2.x
NewProject (Ctrl + Shift + N) > PHP > PHP Application with Existing Source
Please select your cakephp dir(e.g. /home/NetBeansProjects/myproject)

### App Directory Name
### App Directory Path

Multiple app directory names support.

#### Change app directory name

Please set the following if you would like to different app directory name.

1. Project properties > Framework > CakePHP
2. `app Folder name` : please set your new app folder name
You can set app directory path from source directory.
Project properties > Framework > CakePHP > Custom directory path > app

#### Use multiple app directories

Expand Down Expand Up @@ -146,8 +140,8 @@ myproject(e.g. myapp)
```

1. Project properties > Framework > CakePHP
2. Check `Use the relative path to the CakePHP directory from the project directory.`
3. `CakePHP Directory` : "../"
2. `app` : "" (empty or ".")
3. `CakePHP Root` : "../"

Please notice that Code Completion is not available. You have to add the cakephp core path to include path.

Expand Down
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.5
OpenIDE-Module-Specification-Version: 0.9.6
14 changes: 9 additions & 5 deletions src/org/cakephp/netbeans/CakePhpFrameworkProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.cakephp.netbeans.editor.codecompletion.CakePhpEditorExtenderFactory;
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.framework.BadgeIcon;
import org.netbeans.modules.php.api.phpmodule.PhpModule;
import org.netbeans.modules.php.api.phpmodule.PhpModuleProperties;
Expand Down Expand Up @@ -102,11 +103,14 @@ public BadgeIcon getBadgeIcon() {

@Override
public boolean isInPhpModule(PhpModule phpModule) {
CakePhpModule module = CakePhpModule.forPhpModule(phpModule);
if (module == null) {
return false;
Boolean enabled = CakePreferences.isEnabled(phpModule);
if (enabled != null) {
// manually
return enabled;
}
return module.isInCakePhp();
// automatically
CakePhpModule cakeModule = CakePhpModule.forPhpModule(phpModule);
return cakeModule == null ? false : cakeModule.isInCakePhp();
}

@Override
Expand All @@ -115,7 +119,7 @@ public File[] getConfigurationFiles(PhpModule phpModule) {
List<File> configFiles = new LinkedList<File>();
FileObject config = CakePhpModule.forPhpModule(phpModule).getConfigDirectory(DIR_TYPE.APP);
assert config != null : "app/config or app/Config not found for CakePHP project " + phpModule.getDisplayName();
if (config != null && config.isFolder()) {
if (config.isFolder()) {
Enumeration<? extends FileObject> children = config.getChildren(true);
while (children.hasMoreElements()) {
FileObject child = children.nextElement();
Expand Down
74 changes: 62 additions & 12 deletions src/org/cakephp/netbeans/CakePhpModuleCustomizerExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@
import java.util.EnumSet;
import javax.swing.JComponent;
import javax.swing.event.ChangeListener;
import org.cakephp.netbeans.module.CakePhpModule;
import org.cakephp.netbeans.preferences.CakePreferences;
import org.cakephp.netbeans.ui.customizer.CakePhpCustomizerPanel;
import org.cakephp.netbeans.validator.CakePhpCustomizerValidator;
import org.netbeans.modules.php.api.phpmodule.PhpModule;
import org.netbeans.modules.php.api.validation.ValidationResult;
import org.netbeans.modules.php.spi.framework.PhpModuleCustomizerExtender;
import org.openide.filesystems.FileObject;
import org.openide.util.ChangeSupport;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
Expand All @@ -61,19 +65,24 @@ public class CakePhpModuleCustomizerExtender extends PhpModuleCustomizerExtender
private CakePhpCustomizerPanel component;
private final String appDirectoryPath;
private final String cakePhpDirPath;
private final boolean isProjectDir;
private final boolean isShowPopupForOneItem;
private final boolean originalAutoCreateState;
private final boolean originalIgnoreTmpDirectory;
private final boolean isEnabled;
private ChangeSupport changeSupport = new ChangeSupport(this);
private String errorMessage;
private boolean isValid;
private final PhpModule phpModule;

CakePhpModuleCustomizerExtender(PhpModule phpModule) {
this.phpModule = 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);
Boolean enabled = CakePreferences.isEnabled(phpModule);
isEnabled = enabled == null ? false : enabled;
}

@Override
Expand All @@ -83,12 +92,18 @@ public String getDisplayName() {

@Override
public void addChangeListener(ChangeListener listener) {
changeSupport.addChangeListener(listener);
if (listener instanceof CakePhpModule) {
changeSupport.addChangeListener(listener);
}
getPanel().addChangeListener(listener);
}

@Override
public void removeChangeListener(ChangeListener listener) {
changeSupport.removeChangeListener(listener);
if (listener instanceof CakePhpModule) {
changeSupport.removeChangeListener(listener);
}
getPanel().removeChangeListener(listener);
}

@Override
Expand All @@ -103,31 +118,33 @@ public HelpCtx getHelp() {

@Override
public boolean isValid() {
return true;
validate();
return isValid;
}

@Override
public String getErrorMessage() {
return null;
validate();
return errorMessage;
}

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

@Override
public EnumSet<Change> save(PhpModule phpModule) {
EnumSet<Change> enumset = EnumSet.of(Change.FRAMEWORK_CHANGE);
boolean newAutoCreateState = getPanel().isAutoCreateView();
String newCakePhpDirPath = getPanel().getCakePhpDirTextField();
String newCakePhpDirPath = getPanel().getCakePhpDirPath();
boolean newIgnoreTmpDirectory = getPanel().ignoreTmpDirectory();
String newAppDirectoryPath = getPanel().getAppDirectoryPath();

if (newAutoCreateState != originalAutoCreateState) {
CakePreferences.setAutoCreateView(phpModule, newAutoCreateState);
}
if (isProjectDir != getPanel().isUseProjectDirectory()) {
CakePreferences.setUseProjectDirectory(phpModule, !isProjectDir);
if (isEnabled != getPanel().isEnabledCakePhp()) {
CakePreferences.setEnabled(phpModule, !isEnabled);
}
if (isShowPopupForOneItem != getPanel().isShowPopupForOneItem()) {
CakePreferences.setShowPopupForOneItem(phpModule, !isShowPopupForOneItem);
Expand All @@ -150,12 +167,45 @@ private CakePhpCustomizerPanel getPanel() {
if (component == null) {
component = new CakePhpCustomizerPanel();
component.setAutoCreateView(originalAutoCreateState);
component.setCakePhpDirTextField(cakePhpDirPath);
component.setUseProjectDirectory(isProjectDir);
component.setCakePhpDirPath(cakePhpDirPath);
component.setIgnoreTmpDirectory(originalIgnoreTmpDirectory);
component.setShowPopupForOneItem(isShowPopupForOneItem);
component.setAppDirectoryPath(appDirectoryPath);
component.setEnabledCakePhp(isEnabled);
}
return component;
}

@NbBundle.Messages("CakePhpModuleCustomizerExtender.error.source.invalid=Can't find source directory. Project might be broken.")
void validate() {
CakePhpCustomizerPanel panel = getPanel();
if (!panel.isEnabledCakePhp()) {
isValid = true;
errorMessage = null;
return;
}

// get source directory
FileObject sourceDirectory = phpModule.getSourceDirectory();
if (sourceDirectory == null) {
// broken project
isValid = false;
errorMessage = Bundle.CakePhpModuleCustomizerExtender_error_source_invalid();
return;
}

// validate
CakePhpCustomizerValidator validator = new CakePhpCustomizerValidator()
.validateCakePhpPath(sourceDirectory, panel.getCakePhpDirPath())
.validateAppPath(sourceDirectory, panel.getAppDirectoryPath());
ValidationResult result = validator.getResult();
if (result.hasWarnings()) {
isValid = false;
errorMessage = result.getWarnings().get(0).getMessage();
return;
}
// no problem
isValid = true;
errorMessage = null;
}
}
Loading

0 comments on commit 1e4e0bd

Please sign in to comment.