Skip to content

Commit

Permalink
added ability to remove files from project.
Browse files Browse the repository at this point in the history
  • Loading branch information
eyecreate committed Mar 14, 2012
1 parent 0a2e4c2 commit 3597b84
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion res/menu/editormenu.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/savefile" android:showAsAction="withText" android:title="@string/savefile"></item>
<item android:id="@+id/savefile" android:showAsAction="ifRoom|withText" android:title="@string/savefile"></item>
<item android:id="@+id/removefile" android:showAsAction="ifRoom|withText" android:title="@string/remove_file"></item>


</menu>
1 change: 1 addition & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
<string name="pickfiletype">Filetype</string>
<string name="new_file_location">Location to Put File</string>
<string name="create_file">Create</string>
<string name="remove_file">Remove Opened File</string>
</resources>
5 changes: 5 additions & 0 deletions src/com/eyecreate/AndroidProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ public void addNewFileToProject(File file)
triggerProjectStateSave();
}

public void removeFileFromProject(File file)
{
if(!projectFiles.remove(file)) triggerProjectStateSave();
}

public File getMainProjectFile()
{
return mainProjectFile;
Expand Down
7 changes: 7 additions & 0 deletions src/com/eyecreate/DroiddeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ public void openFileInEditor(File f)
EditorFragment edFragment = (EditorFragment) fragman.findFragmentById(R.id.fileeditor);
edFragment.openFile(f);
}

public void removeFileFromProject(File f)
{
ProjectFilesFragment projectFiles = (ProjectFilesFragment) fragman.findFragmentById(R.id.filelist);
loadedProject.removeFileFromProject(f);
projectFiles.AddFilesToList(loadedProject.getProjectFiles());
}

private boolean checkFileForProject(String path) {
DocumentBuilder builder;
Expand Down
8 changes: 8 additions & 0 deletions src/com/eyecreate/EditorFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.savefile:
if(openedFile != null) saveFile(openedFile);
return true;
case R.id.removefile:
if(openedFile != null) removeFile(openedFile);
return true;
default:
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -110,6 +113,11 @@ public void openFile(File f)

}

public void removeFile(File f)
{
((DroiddeActivity)this.getActivity()).removeFileFromProject(f);
}

public void saveFile(File f)
{
RichEditText ret = (RichEditText) getActivity().findViewById(R.id.editorcontent);
Expand Down
2 changes: 2 additions & 0 deletions src/com/eyecreate/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ public interface Project {
public abstract void setMainProjectFile(File f);

public abstract void addNewFileToProject(File f);

public abstract void removeFileFromProject(File f);

}

0 comments on commit 3597b84

Please sign in to comment.