* @param props The properties parsed from the addon manifest (not the source.properties).\r
* @param error The error indicating why this addon failed to be loaded.\r
*/\r
- static Package create(String archiveOsPath, Map<String, String> props, String error) {\r
+ static Package createBroken(String archiveOsPath, Map<String, String> props, String error) {\r
String name = props.get(SdkManager.ADDON_NAME);\r
String vendor = props.get(SdkManager.ADDON_VENDOR);\r
String api = props.get(SdkManager.ADDON_API);\r
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITableFontProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.TreeColumnViewerLabelProvider;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
}
});
+ mTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ onTreeDoubleClick(event); //$hide$
+ }
+ });
+
mTree = mTreeViewer.getTree();
mTree.setLinesVisible(true);
mTree.setHeaderVisible(true);
updateButtonsState();
}
+ private void onTreeDoubleClick(DoubleClickEvent event) {
+ assert event.getSource() == mTreeViewer;
+ ISelection sel = event.getSelection();
+ if (sel.isEmpty() || !(sel instanceof ITreeSelection)) {
+ return;
+ }
+ ITreeSelection tsel = (ITreeSelection) sel;
+ Object elem = tsel.getFirstElement();
+ if (elem == null) {
+ return;
+ }
+
+ ITreeContentProvider provider = (ITreeContentProvider) mTreeViewer.getContentProvider();
+ Object[] children = provider.getElements(elem);
+ if (children == null) {
+ return;
+ }
+
+ if (children.length > 0) {
+ // If the element has children, expand/collapse it.
+ if (mTreeViewer.getExpandedState(elem)) {
+ mTreeViewer.collapseToLevel(elem, 1);
+ } else {
+ mTreeViewer.expandToLevel(elem, 1);
+ }
+ } else {
+ // If the element is a terminal one, select/deselect it.
+ checkAndExpandItem(
+ elem,
+ !mTreeViewer.getChecked(elem),
+ false /*fixChildren*/,
+ true /*fixParent*/);
+ updateButtonsState();
+ }
+ }
+
private void checkAndExpandItem(
Object elem,
boolean checked,