Skip to content

Commit

Permalink
Shorten up display labels #12
Browse files Browse the repository at this point in the history
Support NB8.0 #10
Remove close all/other projects action, because it is provided by NB8 itself #11
  • Loading branch information
markiewb committed Jul 5, 2015
1 parent 0861827 commit 0bd7739
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 264 deletions.

This file was deleted.

Expand Up @@ -39,7 +39,7 @@
@ActionReference(path = "Menu/File", position = 1010)
})

@Messages("CTL_DataObjectAwareCloseDocumentsInProjectAction=Close All Documents From This Project")
@Messages("CTL_DataObjectAwareCloseDocumentsInProjectAction=Close Documents From Project")
public final class DataObjectAwareCloseDocumentsInProjectAction implements ActionListener {

private final DataObject context;
Expand Down
Expand Up @@ -38,7 +38,7 @@
@ActionReference(path = "Editors/TabActions", position = 10),
@ActionReference(path = "Menu/File", position = 1005)
})
@Messages("CTL_DataObjectAwareCloseDocumentsNotInProjectAction=Close All Documents From Other Projects")
@Messages("CTL_DataObjectAwareCloseDocumentsNotInProjectAction=Close Documents From Other Projects")
public final class DataObjectAwareCloseDocumentsNotInProjectAction implements ActionListener {

private final DataObject context;
Expand Down
Expand Up @@ -87,52 +87,6 @@ public Collection<TopComponent> getDocumentsForProject(Project projectToMatch, b
return result;
}

public Collection<TopComponent> getUnchangedDocuments() {

Image emptyImage = ImageUtilities.icon2Image(new EmptyIcon());
final WindowManager wm = WindowManager.getDefault();
final LinkedHashSet<TopComponent> result = new LinkedHashSet<TopComponent>();
for (TopComponent tc : getCurrentEditors()) {
if (!wm.isEditorTopComponent(tc)) {
continue;
}

//check for the format of an unsaved file
boolean isUnsaved = null != tc.getLookup().lookup(SaveCookie.class);
if (isUnsaved) {
continue;
}

DataObject dob = tc.getLookup().lookup(DataObject.class);
if (dob != null) {
try {
final FileObject file = dob.getPrimaryFile();
FileSystem fileSystem = file.getFileSystem();
if (fileSystem.getStatus() instanceof FileSystem.HtmlStatus) {
FileSystem.HtmlStatus status = (FileSystem.HtmlStatus) fileSystem.getStatus();

//HACK B: There is a change if the icon is annotated
Image annotateIcon = status.annotateIcon(emptyImage, 0, new HashSet<FileObject>(Arrays.asList(file)));
boolean isUnchanged = annotateIcon == emptyImage;
// System.out.println(String.format("%s html for '%s' image=%s %s", !isUnchanged, html, annotateIcon, file));

if (isUnchanged) {
result.add(tc);
}
} else {
//could not determine status, keep this document
}
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
} else {
//close diff windows too
result.add(tc);
}
}
return result;
}

private Collection<TopComponent> getCurrentEditors() {
final ArrayList<TopComponent> result = new ArrayList<TopComponent>();
final WindowManager wm = WindowManager.getDefault();
Expand All @@ -143,34 +97,4 @@ private Collection<TopComponent> getCurrentEditors() {
}
return result;
}

public final class EmptyIcon implements Icon {

private int height;
private int width;

public EmptyIcon() {
this(1, 1);
}

public EmptyIcon(int width, int height) {
this.width = width;
this.height = height;
}

@Override
public int getIconHeight() {
return height;
}

@Override
public int getIconWidth() {
return width;
}

@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
}

}
}
Expand Up @@ -37,7 +37,7 @@
@ActionReferences({
@ActionReference(path = "Projects/Actions", position = 10)})

@Messages("CTL_ProjectAwareCloseDocumentsInProjectAction=Close All Documents From This Project")
@Messages("CTL_ProjectAwareCloseDocumentsInProjectAction=Close Documents From Project")
public final class ProjectAwareCloseDocumentsInProjectAction implements ActionListener {

private final Project context;
Expand Down
Expand Up @@ -36,7 +36,7 @@
)
@ActionReferences({
@ActionReference(path = "Projects/Actions", position = 0, separatorBefore = -50)})
@Messages("CTL_ProjectAwareCloseDocumentsNotInProjectAction=Close All Documents From Other Projects")
@Messages("CTL_ProjectAwareCloseDocumentsNotInProjectAction=Close Documents From Other Projects")
public final class ProjectAwareCloseDocumentsNotInProjectAction implements ActionListener {

private final Project context;
Expand Down
@@ -1,9 +1,8 @@
OpenIDE-Module-Display-Category=Tools
OpenIDE-Module-Long-Description=\
<ul>\n<li>Adds "Close Other Projects"/"Close All Projects" actions to the context menu of projects.\
</li>\n<li>Adds "Close All Documents From This Project"/"Close All Documents From Other Projects"/ "Close Unmodified Files" action to the editor tab, to the context menu of a project and to the main menu "File".\
</li>\n</ul>\n<img src="https://raw.github.com/markiewb/nb-close-other-projects/master/src/de/markiew/netbeans/plugin/actions/closeprojects/example.png"/>\n\n<p>\nChanges:\n<li>1.4.0.1\n<ul>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/2">Issue 2</a>: Add "Close Unmodified Files" action to editor tab</li>\n</ul>\n<li>1.3.1\n<ul>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/7">Issue 7</a>: Do not call "close projects" within EDT</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/6">Issue 6</a>: Remove "Close all/other projects" from main menu because of NB8 (context menu items are kept)</li>\n</ul>\n</li>\n</ul>\n<li>1.3\n<ul>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/3">Issue 3</a>: NPE when no project for the DataObject can be found</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/4">Issue 4</a>: "Close All Documents From Other Projects" doesn't close files without a project</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/5">Issue 5</a>: Add "Close documents from this/other project(s)" to the main menu too</li>\n</ul>\n</li>\n</ul>\n<li>1.2\n<ul><li>Rebuild of distribution package, because of missing bundles</li></ul>\n</li>\n</ul>\n<ul>\n<li>1.1\n<ul><li>Add actions "Close All Documents From This Project"/"Close All Documents From Other Projects"</li></ul>\n</li>\n</ul>\n\n</p>\n<p>\nProvide defects, request for enhancements and feedback at <a href="https://github.com/markiewb/nb-close-other-projects/issues">https://github.com/markiewb/nb-close-other-projects/issues</a>\n</p>\n<p>Compatible to >=NB7.0. \
<ul>\n<li>Adds "Close Documents From Project"/"Close Documents From Other Projects" action to the editor tab, to the context menu of a project and to the main menu "File".\
</li>\n</ul>\n<img src="https://raw.github.com/markiewb/nb-close-other-projects/master/src/de/markiew/netbeans/plugin/actions/closeprojects/example.png"/>\n\n<p>\nChanges:\n<li>1.4.0\n<ul>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/pull/9">Issue 9</a>: Performance improvement for "Close All Documents From Other/This Project(s) (Pull-Request by Shredder121)</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/12">Issue 12</a>: Shorten up display labels</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/11">Issue 11</a>: Remove close all/other projects actions, because it is provided by NB8 itself</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/10">Issue 10</a>: Support only NB8+</li>\n</ul>\n</li>\n\n<li>1.3.1\n<ul>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/7">Issue 7</a>: Do not call "close projects" within EDT</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/6">Issue 6</a>: Remove "Close all/other projects" from main menu because of NB8 (context menu items are kept)</li>\n</ul>\n</li>\n</ul>\n<li>1.3\n<ul>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/3">Issue 3</a>: NPE when no project for the DataObject can be found</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/4">Issue 4</a>: "Close All Documents From Other Projects" doesn't close files without a project</li>\n<li><a href="https://github.com/markiewb/nb-close-other-projects/issues/5">Issue 5</a>: Add "Close documents from this/other project(s)" to the main menu too</li>\n</ul>\n</li>\n</ul>\n<li>1.2\n<ul><li>Rebuild of distribution package, because of missing bundles</li></ul>\n</li>\n</ul>\n<ul>\n<li>1.1\n<ul><li>Add actions "Close All Documents From This Project"/"Close All Documents From Other Projects"</li></ul>\n</li>\n</ul>\n\n</p>\n<p>\nProvide defects, request for enhancements and feedback at <a href="https://github.com/markiewb/nb-close-other-projects/issues">https://github.com/markiewb/nb-close-other-projects/issues</a>\n</p>\n<p>Compatible to >=NB7.0. \
Apache 2.0 license.\
</p>
OpenIDE-Module-Name=Close other projects/documents
OpenIDE-Module-Short-Description=Add actions "Close Other Projects"/"Close All Projects"/"Close All Documents From This Project"/"Close All Documents From Other Projects"
OpenIDE-Module-Name=Close other documents
OpenIDE-Module-Short-Description=Add actions "Close Documents From Project"/"Close Documents From Other Projects"

This file was deleted.

This file was deleted.

0 comments on commit 0bd7739

Please sign in to comment.