use of org.apache.hop.git.model.UIFile in project hop by apache.
the class GitInfoExplorerFileTypeHandler method getStatusDescription.
private String getStatusDescription(GitGuiPlugin guiPlugin) {
Map<String, UIFile> changedFiles = guiPlugin.getChangedFiles();
Map<String, String> ignoredFiles = guiPlugin.getIgnoredFiles();
UIFile file = changedFiles.get(explorerFile.getFilename());
if (file == null) {
String ignored = ignoredFiles.get(explorerFile.getFilename());
if (ignored == null) {
return "Not changed";
} else {
return "Ignored";
}
} else {
switch(file.getChangeType()) {
case ADD:
return "Not added";
case COPY:
return "Copied";
case MODIFY:
return "Modified";
case DELETE:
return "Deleted";
case RENAME:
return "Renamed";
default:
return "Changed";
}
}
}
use of org.apache.hop.git.model.UIFile in project hop by apache.
the class GitGuiPlugin method filePainted.
/**
* If we have a git project we can take a look and see if a file is changed.
*
* @param tree
* @param treeItem
* @param path
* @param name
*/
@Override
public void filePainted(Tree tree, TreeItem treeItem, String path, String name) {
GuiResource guiResource = GuiResource.getInstance();
UIFile file = null;
// Changed git file colored blue
try {
file = changedFiles.get(HopVfs.getFileObject(path).getName().getPath());
} catch (HopFileException e) {
// do nothing
}
if (file != null) {
switch(file.getChangeType()) {
case DELETE:
case MODIFY:
case RENAME:
case COPY:
treeItem.setForeground(colorStaged);
break;
case ADD:
if (file.getIsStaged()) {
treeItem.setForeground(colorStaged);
} else {
treeItem.setForeground(colorUnstaged);
}
break;
}
}
String ignored = ignoredFiles.get(path);
if (ignored != null) {
treeItem.setForeground(colorIgnored);
}
}
use of org.apache.hop.git.model.UIFile in project hop by apache.
the class GitGuiPlugin method refreshChangedFiles.
private void refreshChangedFiles() {
changedFiles = new HashMap<>();
ignoredFiles = new HashMap<>();
if (git != null) {
// List the staged and unstaged files...
//
List<UIFile> files = new ArrayList<>(git.getStagedFiles());
files.addAll(git.getUnstagedFiles());
for (UIFile file : files) {
String path = getAbsoluteFilename(git.getDirectory(), file.getName());
changedFiles.put(path, file);
}
Set<String> ignored = git.getIgnored(null);
for (String ignore : ignored) {
String filename = getAbsoluteFilename(git.getDirectory(), ignore);
ignoredFiles.put(filename, ignore);
}
}
}
use of org.apache.hop.git.model.UIFile in project hop by apache.
the class GitInfoExplorerFileTypeHandler method refreshChangedFiles.
private void refreshChangedFiles() {
GitGuiPlugin guiPlugin = GitGuiPlugin.getInstance();
UIGit git = guiPlugin.getGit();
List<UIFile> changedFiles;
String selectedFile = wFile.getText();
String rootFolder = git.getDirectory();
boolean showStaged = true;
//
if (wRevisions.table.getSelectionCount() == 0) {
changedFiles = new ArrayList<>(guiPlugin.getChangedFiles().values());
} else {
String revisionId = wRevisions.table.getSelection()[0].getText(1);
if (UIGit.WORKINGTREE.equals(revisionId)) {
changedFiles = new ArrayList<>();
for (UIFile changedFile : guiPlugin.getChangedFiles().values()) {
if (isFilteredPath(rootFolder, changedFile.getName(), selectedFile)) {
changedFiles.add(changedFile);
}
}
} else {
showStaged = false;
changedFiles = new ArrayList<>();
try {
RevCommit commit = git.resolve(revisionId);
RevTree tree = commit.getTree();
try (TreeWalk treeWalk = new TreeWalk(git.getGit().getRepository())) {
treeWalk.setRecursive(true);
treeWalk.reset(tree);
while (treeWalk.next()) {
String path = treeWalk.getPathString();
if (isFilteredPath(rootFolder, path, selectedFile)) {
changedFiles.add(new UIFile(path, DiffEntry.ChangeType.MODIFY, false));
}
}
}
} catch (Exception e) {
LogChannel.UI.logError("Error getting changed file in revision " + revisionId, e);
}
}
}
wFiles.removeAll();
for (UIFile file : changedFiles) {
TableItem item = new TableItem(wFiles.table, SWT.NONE);
item.setText(1, Const.NVL(file.getName(), ""));
if (showStaged) {
item.setText(2, Const.NVL(file.getChangeType().name(), ""));
item.setText(3, file.getIsStaged() ? "Y" : "N");
}
}
wFiles.optimizeTableView();
}
Aggregations