mCheckFilterObsolete.setSelection(false);
Link linkSelectNew = new Link(mGroupOptions, SWT.NONE);
- linkSelectNew.setText("<a>Select New/Updates</a>");
+ // Note for i18n: we need to identify which link is used, and this is done by using the
+ // text itself so for translation purposes we want to keep the <a> link strings separate.
+ final String strLinkNew = "New";
+ final String strLinkUpdates = "Updates";
+ linkSelectNew.setText(
+ String.format("Select <a>%1$s</a> or <a>%2$s</a>", strLinkNew, strLinkUpdates));
linkSelectNew.setToolTipText("Selects all items that are either new or updates.");
GridDataBuilder.create(linkSelectNew).hFill().hGrab();
linkSelectNew.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
- onSelectNewUpdates();
+ boolean selectNew = e.text == null || e.text.equals(strLinkNew);
+ onSelectNewUpdates(selectNew, !selectNew);
}
});
// automatically select all new and update packages.
Object[] checked = mTreeViewer.getCheckedElements();
if (checked == null || checked.length == 0) {
- onSelectNewUpdates();
+ onSelectNewUpdates(true, true);
}
}
}
/**
* Checks all PkgItems that are either new or have updates.
*/
- private void onSelectNewUpdates() {
+ private void onSelectNewUpdates(boolean selectNew, boolean selectUpdates) {
// This does not update the tree itself, syncViewerSelection does it below.
- mDiffLogic.checkNewUpdateItems();
+ mDiffLogic.checkNewUpdateItems(selectNew, selectUpdates);
syncViewerSelection();
updateButtonsState();
}
assertFalse(m.isFirstLoadComplete());
}
- public void testCheckNewUpdateItems() {
+ public void testCheckNewUpdateItems_NewOnly() {
// Populate the list with a few items and an update
SdkSource src1 = new SdkRepoSource("http://example.com/url", "repo1");
m.updateStart();
"-- <INSTALLED, pkg:MockEmptyPackage 'no update' rev=4>\n",
getTree(m, false /*displaySortByApi*/));
- // Now request to check new and update items
- m.checkNewUpdateItems();
+ // Now request to check new items only
+ m.checkNewUpdateItems(true, false);
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
"PkgCategoryApi <API=EXTRAS, label=Extras, #items=3>\n" +
- "-- < * INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
"-- < * NEW, pkg:MockEmptyPackage 'new stuff' rev=3>\n" +
"-- <INSTALLED, pkg:MockEmptyPackage 'no update' rev=4>\n",
getTree(m, true /*displaySortByApi*/));
assertEquals(
"PkgCategorySource <source=repo1 (example.com), #items=3>\n" +
- "-- < * INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
"-- < * NEW, pkg:MockEmptyPackage 'new stuff' rev=3>\n" +
"-- <INSTALLED, pkg:MockEmptyPackage 'no update' rev=4>\n",
getTree(m, false /*displaySortByApi*/));
}
+ public void testCheckNewUpdateItems_UpdateOnly() {
+ // Populate the list with a few items and an update
+ SdkSource src1 = new SdkRepoSource("http://example.com/url", "repo1");
+ m.updateStart();
+ m.updateSourcePackages(true /*sortByApi*/, null /*locals*/, new Package[] {
+ new MockEmptyPackage(src1, "has update", 1),
+ new MockEmptyPackage(src1, "no update", 4)
+ });
+ m.updateSourcePackages(true /*sortByApi*/, src1, new Package[] {
+ new MockEmptyPackage(src1, "has update", 2),
+ new MockEmptyPackage(src1, "new stuff", 3),
+ });
+ m.updateEnd(true /*sortByApi*/);
+ // Nothing is checked at first
+ assertEquals(
+ "PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
+ "PkgCategoryApi <API=EXTRAS, label=Extras, #items=3>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
+ "-- <NEW, pkg:MockEmptyPackage 'new stuff' rev=3>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'no update' rev=4>\n",
+ getTree(m, true /*displaySortByApi*/));
+ assertEquals(
+ "PkgCategorySource <source=repo1 (example.com), #items=3>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
+ "-- <NEW, pkg:MockEmptyPackage 'new stuff' rev=3>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'no update' rev=4>\n",
+ getTree(m, false /*displaySortByApi*/));
+
+ // Now request to check update items only
+ m.checkNewUpdateItems(false, true);
+
+ assertEquals(
+ "PkgCategoryApi <API=TOOLS, label=Tools, #items=0>\n" +
+ "PkgCategoryApi <API=EXTRAS, label=Extras, #items=3>\n" +
+ "-- < * INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
+ "-- <NEW, pkg:MockEmptyPackage 'new stuff' rev=3>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'no update' rev=4>\n",
+ getTree(m, true /*displaySortByApi*/));
+ assertEquals(
+ "PkgCategorySource <source=repo1 (example.com), #items=3>\n" +
+ "-- < * INSTALLED, pkg:MockEmptyPackage 'has update' rev=1, updated by:MockEmptyPackage 'has update' rev=2>\n" +
+ "-- <NEW, pkg:MockEmptyPackage 'new stuff' rev=3>\n" +
+ "-- <INSTALLED, pkg:MockEmptyPackage 'no update' rev=4>\n",
+ getTree(m, false /*displaySortByApi*/));
+ }
+
public void testCheckNewUpdateItems_SelectInitial() {
// Populate the list with typical items: tools, platforms tools, extras, 2 platforms.
// With nothing installed, this should pick the tools, extras and the top platform.
});
m.updateEnd(true /*sortByApi*/);
- m.checkNewUpdateItems();
+ m.checkNewUpdateItems(true, true);
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=2>\n" +
});
m.updateEnd(true /*sortByApi*/);
- m.checkNewUpdateItems();
+ m.checkNewUpdateItems(true, true);
assertEquals(
"PkgCategoryApi <API=TOOLS, label=Tools, #items=2>\n" +