This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GitPlugin jEdit plugin".
The branch, master has been updated
via 8ca31c51d5b97c5a0966d89b44f2cb4586aac42a (commit)
from 4083d022166656b799859d4f324b499359d445b2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit: http://jedit.git.sourceforge.net/git/gitweb.cgi?p=jedit/GitPlugin;a=commit;h=8ca31c51d5b97c5a0966d89b44f2cb4586aac42a
commitdiff: http://jedit.git.sourceforge.net/git/gitweb.cgi?p=jedit/GitPlugin;a=commitdiff;h=8ca31c51d5b97c5a0966d89b44f2cb4586aac42a
tree: http://jedit.git.sourceforge.net/git/gitweb.cgi?p=jedit/GitPlugin;a=tree;h=8ca31c51d5b97c5a0966d89b44f2cb4586aac42a;hb=8ca31c51d5b97c5a0966d89b44f2cb4586aac42a
commit 8ca31c51d5b97c5a0966d89b44f2cb4586aac42a
Author: Dale Anson <danson@...>
Date: Fri Jan 18 16:44:57 2013 -0700
Added status command and icons to show status in ProjectViewer.
diff --git a/build.xml b/build.xml
index 8f69db4..1d18ca8 100644
--- a/build.xml
+++ b/build.xml
@@ -30,6 +30,7 @@
<selector id="packageFiles">
<or>
<filename name="index.html" />
+ <filename name="**/*.png"/>
</or>
</selector>
diff --git a/git/GitCommand.java b/git/GitCommand.java
index df8a7b9..0d16de4 100644
--- a/git/GitCommand.java
+++ b/git/GitCommand.java
@@ -28,8 +28,11 @@ import org.gjt.sp.util.Log;
import common.io.ProcessExecutor;
import common.io.ProcessExecutor.BufferingVisitor;
-import common.io.ProcessExecutor.LineVisitor;
+// TODO: this class uses internal dialogs to show errors. That's fine if there
+// is only one error, but in the case of calling for vcs status from ProjectViewer,
+// or other commands, there could be hundreds at once. Replace the internal dialogs
+// with ErrorList.
public class GitCommand {
private final ProcessExecutor proc;
@@ -112,6 +115,7 @@ public class GitCommand {
* @param view Parent window.
*/
public void showErrorDialog(final View view) {
+ // TODO: use ErrorList!!!
Runnable dialog = new Runnable() {
public void run() {
showErrorDialogInternal(view);
@@ -130,6 +134,7 @@ public class GitCommand {
}
private void showErrorDialogInternal(View view) {
+ // TODO: use ErrorList!!!
final JTextArea message = new JTextArea(24, 80);
message.setText(stderr);
message.setEditable(false);
diff --git a/git/GitService.java b/git/GitService.java
index c6036ac..7ac0cb1 100644
--- a/git/GitService.java
+++ b/git/GitService.java
@@ -16,31 +16,77 @@
*/
package git;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
import javax.swing.Icon;
+import javax.swing.ImageIcon;
import org.gjt.sp.jedit.OptionGroup;
import org.gjt.sp.jedit.OptionPane;
+import org.gjt.sp.jedit.View;
+import org.gjt.sp.jedit.jEdit;
import projectviewer.config.VersionControlService;
import projectviewer.importer.ImporterFileFilter;
import projectviewer.vpt.VPTNode;
import projectviewer.vpt.VPTProject;
+import git.command.Status;
+
/**
* Implement's a ProjectViewer version control service for git.
*/
public class GitService implements VersionControlService
{
-
+
+ // icon definitions for the various states. These were copied from the
+ // Subversion plugin, so they don't all apply to Git.
+ public static final ImageIcon UNMODIFIED_ICON = createIcon( "git/icons/unmodified.png" );
+ public static final ImageIcon MODIFIED_ICON = createIcon( "git/icons/modified.png" );
+ public static final ImageIcon ADDED_ICON = createIcon( "git/icons/added.png" );
+ public static final ImageIcon DELETED_ICON = createIcon( "git/icons/deleted.png" );
+ public static final ImageIcon RENAMED_ICON = createIcon( "git/icons/ignored.png" );
+ public static final ImageIcon COPIED_ICON = createIcon( "git/icons/copied.png" );
+ public static final ImageIcon UPDATED_ICON = createIcon( "git/icons/updated.png" );
+ public static final ImageIcon UNTRACKED_ICON = createIcon( "git/icons/untracked.png" );
+ public static final ImageIcon IGNORED_ICON = createIcon( "git/icons/ignored.png" );
+
+ private static final ImageIcon[] iconArray = new ImageIcon[]{UNMODIFIED_ICON, MODIFIED_ICON, ADDED_ICON, DELETED_ICON, RENAMED_ICON, COPIED_ICON, UPDATED_ICON, UNTRACKED_ICON, IGNORED_ICON};
+
+ private static ImageIcon createIcon( String name ) {
+ return new ImageIcon( GitService.class.getClassLoader().getResource( name ) );
+ }
+
+
+ /**
+ * See description of status in Status.java comments.
+ */
public int getNodeState(VPTNode f)
{
- return 0;
+ if (f == null) {
+ return VC_STATUS_NORMAL;
+ }
+ Status statusCmd = new Status(f.getNodePath());
+ View view = jEdit.getActiveView();
+ if (statusCmd.execute(view)) {
+ return statusCmd.getStatus();
+ }
+ return VC_STATUS_NORMAL; // indicates to PV that the file has no vcs status
}
-
+
+ /**
+ * @param state See Status.java for details of 'state', this is a two digit number
+ * with the first digit representing 'X' and the second digit representing 'Y'.
+ */
public Icon getIcon(int state)
{
- return null;
+ int x = (state / 10) % 10;
+ int y = state % 10;
+ ImageIcon top = iconArray[x];
+ ImageIcon bottom = iconArray[y];
+ return combineIcons(top, bottom);
}
public Class getPlugin()
@@ -66,6 +112,18 @@ public class GitService implements VersionControlService
{
return null;
}
+
+ private Icon combineIcons(ImageIcon top, ImageIcon bottom)
+ {
+ int width = 8;
+ int height = 8;
+ BufferedImage combinedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ Graphics2D graphics = combinedImage.createGraphics();
+ graphics.drawImage(top.getImage(), 0, 0, null);
+ graphics.drawImage(bottom.getImage(), 0, 4, null);
+ return new ImageIcon(combinedImage);
+ }
+
}
diff --git a/git/command/Status.java b/git/command/Status.java
new file mode 100644
index 0000000..722abe0
--- /dev/null
+++ b/git/command/Status.java
@@ -0,0 +1,136 @@
+/* DO WHAT THE FRAK YOU WANT TO PUBLIC LICENSE (WTFPL)
+ Version 4, October 2012
+ Based on the wtfpl: http://sam.zoy.org/wtfpl/
+
+ Copyright (C) 2012 Marcelo Vanzin
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FRAK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FRAK YOU WANT TO.
+ 1. It is provided "as is" without any warranty whatsoever.
+*/
+package git.command;
+
+import common.io.ProcessExecutor.LineVisitor;
+
+import git.GitCommand;
+
+/**
+ * Gets the current status of a file.
+ * From 'git status --help' :
+ * <pre>
+ * Git status codes:
+ * ' ' unmodified
+ * M modified
+ * A added
+ * D deleted
+ * R renamed
+ * C copied
+ * U updated but unmerged
+ * ? untracked
+ * ! ignored
+ *
+ * 'git status --short' will produce XY path where XY are:
+ *
+ * X Y Meaning
+ * -------------------------------------------------
+ * [MD] not updated
+ * M [ MD] updated in index
+ * A [ MD] added to index
+ * D [ M] deleted from index
+ * R [ MD] renamed in index
+ * C [ MD] copied in index
+ * [MARC] index and work tree matches
+ * [ MARC] M work tree changed since index
+ * [ MARC] D deleted in work tree
+ * -------------------------------------------------
+ * D D unmerged, both deleted
+ * A U unmerged, added by us
+ * U D unmerged, deleted by them
+ * U A unmerged, added by them
+ * D U unmerged, deleted by us
+ * A A unmerged, both added
+ * U U unmerged, both modified
+ * -------------------------------------------------
+ * ? ? untracked
+ * ! ! ignored
+ * -------------------------------------------------
+ * </pre>
+ * The status returned from this class converts XY into an integer, where X is
+ * in the 10's place and Y is in the 1's place, so if XY is " M", the status will
+ * be 01. This would be a file that has local changes that have not yet been added
+ * to the index. A file that is added to the index, then has subsequent changes
+ * would have XY of "MM" and the status would be 11.
+ */
+public class Status extends GitCommand implements LineVisitor {
+
+ // version control states for Git
+ public static final int UNMODIFIED = 0; // green
+ public static final int MODIFIED = 1; // yellow
+ public static final int ADDED = 2; // blue
+ public static final int DELETED = 3; // black
+ public static final int RENAMED = 4; // cyan
+ public static final int COPIED = 5; // orange
+ public static final int UPDATED = 6; // magenta
+ public static final int UNTRACKED = 7; // gray
+ public static final int IGNORED = 8; // red
+
+ private int status = UNMODIFIED;
+
+ public Status( String path ) {
+ super( new java.io.File( path ).getParent(), "status", "--porcelain", path );
+ getExecutor().addVisitor( this );
+ }
+
+ public boolean process( String line, boolean isError ) {
+ if ( !isError ) {
+ if (line != null && line.length() >= 2) {
+ char a = line.charAt(0);
+ char b = line.charAt(1);
+ status = getValue(a) * 10 + getValue(b);
+ }
+ return false;
+ }
+ return true;
+ }
+
+ private int getValue( char c ) {
+ // these values for 'c' are those produced when using --porcelain
+ switch ( c ) {
+ case 'M':
+ return MODIFIED;
+ case 'A':
+ return ADDED;
+ case 'D':
+ return DELETED;
+ case 'R':
+ return RENAMED;
+ case 'C':
+ return COPIED;
+ case 'U':
+ return UPDATED;
+ case '!':
+ return IGNORED;
+ case '?':
+ return UNTRACKED;
+ case ' ':
+ default:
+ return UNMODIFIED;
+ }
+ }
+
+ /**
+ * @return The value from finding the status of the file given in the constructor.
+ * See the class javadoc (above) about what this value means exactly.
+ */
+ public int getStatus() {
+ return status;
+ }
+
+}
+
diff --git a/git/icons/added.png b/git/icons/added.png
new file mode 100644
index 0000000..6d914eb
Binary files /dev/null and b/git/icons/added.png differ
diff --git a/git/icons/copied.png b/git/icons/copied.png
new file mode 100644
index 0000000..df1f9e2
Binary files /dev/null and b/git/icons/copied.png differ
diff --git a/git/icons/deleted.png b/git/icons/deleted.png
new file mode 100644
index 0000000..f97e82c
Binary files /dev/null and b/git/icons/deleted.png differ
diff --git a/git/icons/ignored.png b/git/icons/ignored.png
new file mode 100644
index 0000000..f4e1dbc
Binary files /dev/null and b/git/icons/ignored.png differ
diff --git a/git/icons/modified.png b/git/icons/modified.png
new file mode 100644
index 0000000..29c8a0a
Binary files /dev/null and b/git/icons/modified.png differ
diff --git a/git/icons/renamed.png b/git/icons/renamed.png
new file mode 100644
index 0000000..ccb59a5
Binary files /dev/null and b/git/icons/renamed.png differ
diff --git a/git/icons/unmodified.png b/git/icons/unmodified.png
new file mode 100644
index 0000000..49fccbc
Binary files /dev/null and b/git/icons/unmodified.png differ
diff --git a/git/icons/untracked.png b/git/icons/untracked.png
new file mode 100644
index 0000000..2e44ff9
Binary files /dev/null and b/git/icons/untracked.png differ
diff --git a/git/icons/updated.png b/git/icons/updated.png
new file mode 100644
index 0000000..f32ba57
Binary files /dev/null and b/git/icons/updated.png differ
-----------------------------------------------------------------------
Summary of changes:
build.xml | 1 +
git/GitCommand.java | 7 ++-
git/GitService.java | 66 +++++++++++++++++++++--
git/command/Status.java | 136 ++++++++++++++++++++++++++++++++++++++++++++++
git/icons/added.png | Bin 0 -> 155 bytes
git/icons/copied.png | Bin 0 -> 153 bytes
git/icons/deleted.png | Bin 0 -> 146 bytes
git/icons/ignored.png | Bin 0 -> 151 bytes
git/icons/modified.png | Bin 0 -> 153 bytes
git/icons/renamed.png | Bin 0 -> 155 bytes
git/icons/unmodified.png | Bin 0 -> 153 bytes
git/icons/untracked.png | Bin 0 -> 155 bytes
git/icons/updated.png | Bin 0 -> 154 bytes
13 files changed, 205 insertions(+), 5 deletions(-)
create mode 100644 git/command/Status.java
create mode 100644 git/icons/added.png
create mode 100644 git/icons/copied.png
create mode 100644 git/icons/deleted.png
create mode 100644 git/icons/ignored.png
create mode 100644 git/icons/modified.png
create mode 100644 git/icons/renamed.png
create mode 100644 git/icons/unmodified.png
create mode 100644 git/icons/untracked.png
create mode 100644 git/icons/updated.png
hooks/post-receive
--
GitPlugin jEdit plugin
|