This repository has been archived by the owner on Sep 13, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoffeeScript project support progress
- Loading branch information
Showing
9 changed files
with
568 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
build.xml.data.CRC32=39c7e7df | ||
build.xml.data.CRC32=475d1f5a | ||
build.xml.script.CRC32=97de7681 | ||
build.xml.stylesheet.CRC32=a56c6a5b@1.45.1 | ||
# 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=39c7e7df | ||
nbproject/build-impl.xml.data.CRC32=475d1f5a | ||
nbproject/build-impl.xml.script.CRC32=f1c6dc8e | ||
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
src/coffeescript/nb/project/CoffeeScriptLogicalView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright 2011 Denis Stepanov | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package coffeescript.nb.project; | ||
|
||
import java.awt.Image; | ||
import javax.swing.Action; | ||
import org.netbeans.spi.project.ui.LogicalViewProvider; | ||
import org.netbeans.spi.project.ui.support.CommonProjectActions; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.loaders.DataFolder; | ||
import org.openide.loaders.DataObjectNotFoundException; | ||
import org.openide.nodes.AbstractNode; | ||
import org.openide.nodes.Children; | ||
import org.openide.nodes.FilterNode; | ||
import org.openide.nodes.Node; | ||
import org.openide.util.Exceptions; | ||
import org.openide.util.ImageUtilities; | ||
import org.openide.util.Lookup; | ||
import org.openide.util.lookup.Lookups; | ||
import org.openide.util.lookup.ProxyLookup; | ||
|
||
/** | ||
* | ||
* @author Denis Stepanov | ||
*/ | ||
public class CoffeeScriptLogicalView implements LogicalViewProvider { | ||
|
||
private final CoffeeScriptProject project; | ||
|
||
public CoffeeScriptLogicalView(CoffeeScriptProject project) { | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
public org.openide.nodes.Node createLogicalView() { | ||
try { | ||
FileObject text = project.getConfigFile(true); | ||
DataFolder textDataObject = DataFolder.findFolder(text.getParent()); | ||
return new TextNode(textDataObject.getNodeDelegate(), project); | ||
} catch (DataObjectNotFoundException donfe) { | ||
Exceptions.printStackTrace(donfe); | ||
return new AbstractNode(Children.LEAF); | ||
} | ||
} | ||
|
||
@Override | ||
public Node findPath(Node root, Object target) { | ||
return null; | ||
} | ||
|
||
private static final class TextNode extends FilterNode { | ||
|
||
private final CoffeeScriptProject project; | ||
|
||
public TextNode(Node node, CoffeeScriptProject project) throws DataObjectNotFoundException { | ||
super(node, new FilterNode.Children(node), | ||
new ProxyLookup(new Lookup[]{ | ||
Lookups.singleton(project), | ||
node.getLookup() | ||
})); | ||
this.project = project; | ||
} | ||
|
||
@Override | ||
public Action[] getActions(boolean arg0) { | ||
return new Action[]{ | ||
CommonProjectActions.newFileAction(), | ||
CommonProjectActions.copyProjectAction(), | ||
CommonProjectActions.deleteProjectAction(), | ||
CommonProjectActions.setAsMainProjectAction(), | ||
CommonProjectActions.closeProjectAction(), | ||
CommonProjectActions.customizeProjectAction() | ||
}; | ||
} | ||
|
||
@Override | ||
public Image getIcon(int type) { | ||
return ImageUtilities.loadImage("coffeescript/nb/resources/coffeescript-icon.png"); | ||
} | ||
|
||
@Override | ||
public Image getOpenedIcon(int type) { | ||
return getIcon(type); | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return project.getProjectDirectory().getName(); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/coffeescript/nb/project/CoffeeScriptPanelProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2011 Denis Stepanov | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package coffeescript.nb.project; | ||
|
||
import coffeescript.nb.project.ui.CoffeeScriptActionSettingsPanel; | ||
import javax.swing.JComponent; | ||
import org.netbeans.spi.project.ui.support.ProjectCustomizer; | ||
import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category; | ||
import org.openide.util.Lookup; | ||
|
||
/** | ||
* | ||
* @author Denis Stepanov | ||
*/ | ||
@ProjectCustomizer.CompositeCategoryProvider.Registration(projectType = "coffeescript-nb-project") | ||
public class CoffeeScriptPanelProvider implements ProjectCustomizer.CompositeCategoryProvider { | ||
|
||
public Category createCategory(Lookup context) { | ||
return ProjectCustomizer.Category.create("Build", " ", null); | ||
} | ||
|
||
public JComponent createComponent(Category category, Lookup context) { | ||
return new CoffeeScriptActionSettingsPanel(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
// Copyright 2011 Denis Stepanov | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package coffeescript.nb.project; | ||
|
||
import java.beans.PropertyChangeListener; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import javax.swing.Icon; | ||
import javax.swing.ImageIcon; | ||
import org.netbeans.api.project.Project; | ||
import org.netbeans.api.project.ProjectInformation; | ||
import org.netbeans.spi.project.ActionProvider; | ||
import org.netbeans.spi.project.CopyOperationImplementation; | ||
import org.netbeans.spi.project.DeleteOperationImplementation; | ||
import org.netbeans.spi.project.ProjectState; | ||
import org.netbeans.spi.project.ui.support.DefaultProjectOperations; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.util.Exceptions; | ||
import org.openide.util.ImageUtilities; | ||
import org.openide.util.Lookup; | ||
import org.openide.util.lookup.Lookups; | ||
|
||
/** | ||
* | ||
* @author Denis Stepanov | ||
*/ | ||
public class CoffeeScriptProject implements Project { | ||
|
||
private FileObject projectDirectory; | ||
private ProjectState state; | ||
private Lookup lookup; | ||
|
||
public CoffeeScriptProject(FileObject projectDirectory, ProjectState state) { | ||
this.projectDirectory = projectDirectory; | ||
this.state = state; | ||
} | ||
|
||
public FileObject getProjectDirectory() { | ||
return projectDirectory; | ||
} | ||
|
||
FileObject getConfigFile(boolean create) { | ||
FileObject result = | ||
projectDirectory.getFileObject(CoffeeScriptProjectFactory.PROJECT_CONFIG_FILE); | ||
if (result == null && create) { | ||
try { | ||
projectDirectory.createData(CoffeeScriptProjectFactory.PROJECT_CONFIG_FILE); | ||
} catch (IOException ioe) { | ||
Exceptions.printStackTrace(ioe); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
@Override | ||
public Lookup getLookup() { | ||
if (lookup == null) { | ||
lookup = Lookups.fixed(new Object[]{ | ||
this, | ||
state, | ||
new CoffeeScriptActionProvider(), | ||
new CoffeeScriptDeleteOperation(), | ||
new CoffeeScriptCopyOperation(this), | ||
new CoffeeScriptProjectInfo(), | ||
new CoffeeScriptLogicalView(this), | ||
new CoffeeScriptProjectCustomizer(this) | ||
}); | ||
} | ||
return lookup; | ||
} | ||
|
||
private final class CoffeeScriptActionProvider implements ActionProvider { | ||
|
||
private String[] supported = new String[]{ | ||
ActionProvider.COMMAND_DELETE, | ||
ActionProvider.COMMAND_COPY,}; | ||
|
||
@Override | ||
public String[] getSupportedActions() { | ||
return supported; | ||
} | ||
|
||
@Override | ||
public void invokeAction(String string, Lookup lookup) throws IllegalArgumentException { | ||
if (string.equalsIgnoreCase(ActionProvider.COMMAND_DELETE)) { | ||
DefaultProjectOperations.performDefaultDeleteOperation(CoffeeScriptProject.this); | ||
} | ||
if (string.equalsIgnoreCase(ActionProvider.COMMAND_COPY)) { | ||
DefaultProjectOperations.performDefaultCopyOperation(CoffeeScriptProject.this); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isActionEnabled(String command, Lookup lookup) throws IllegalArgumentException { | ||
if ((command.equals(ActionProvider.COMMAND_DELETE))) { | ||
return true; | ||
} else if ((command.equals(ActionProvider.COMMAND_COPY))) { | ||
return true; | ||
} else { | ||
throw new IllegalArgumentException(command); | ||
} | ||
} | ||
} | ||
|
||
private final class CoffeeScriptDeleteOperation implements DeleteOperationImplementation { | ||
|
||
public void notifyDeleting() throws IOException { | ||
} | ||
|
||
public void notifyDeleted() throws IOException { | ||
} | ||
|
||
public List<FileObject> getMetadataFiles() { | ||
List<FileObject> dataFiles = new ArrayList<FileObject>(); | ||
return dataFiles; | ||
} | ||
|
||
public List<FileObject> getDataFiles() { | ||
List<FileObject> dataFiles = new ArrayList<FileObject>(); | ||
return dataFiles; | ||
} | ||
} | ||
|
||
private final class CoffeeScriptCopyOperation implements CopyOperationImplementation { | ||
|
||
private final CoffeeScriptProject project; | ||
private final FileObject projectDir; | ||
|
||
public CoffeeScriptCopyOperation(CoffeeScriptProject project) { | ||
this.project = project; | ||
this.projectDir = project.getProjectDirectory(); | ||
} | ||
|
||
public List<FileObject> getMetadataFiles() { | ||
return Collections.EMPTY_LIST; | ||
} | ||
|
||
public List<FileObject> getDataFiles() { | ||
return Collections.EMPTY_LIST; | ||
} | ||
|
||
public void notifyCopying() throws IOException { | ||
} | ||
|
||
public void notifyCopied(Project arg0, File arg1, String arg2) throws IOException { | ||
} | ||
} | ||
|
||
private final class CoffeeScriptProjectInfo implements ProjectInformation { | ||
|
||
@Override | ||
public Icon getIcon() { | ||
return new ImageIcon(ImageUtilities.loadImage( | ||
"coffeescript/nb/resources/coffeescript-icon.png")); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return getProjectDirectory().getName(); | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return getName(); | ||
} | ||
|
||
@Override | ||
public void addPropertyChangeListener(PropertyChangeListener pcl) { | ||
//do nothing, won't change | ||
} | ||
|
||
@Override | ||
public void removePropertyChangeListener(PropertyChangeListener pcl) { | ||
//do nothing, won't change | ||
} | ||
|
||
@Override | ||
public Project getProject() { | ||
return CoffeeScriptProject.this; | ||
} | ||
} | ||
} |
Oops, something went wrong.