X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.eclipse.ui%2Fsrc%2Forg%2Fargeo%2Feclipse%2Fui%2Ffs%2FAdvancedFsBrowser.java;h=136eb5055b3f7e0f59ca97b4630694b5350e01b9;hb=c53fec78daddb69c489686844188036b04e1615a;hp=6de426104e9ff75abaf6da44cd3fc848b3c54a92;hpb=e78d5435d12c2df2100838e090ae6d045a980f8d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/fs/AdvancedFsBrowser.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/fs/AdvancedFsBrowser.java index 6de426104..136eb5055 100644 --- a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/fs/AdvancedFsBrowser.java +++ b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/fs/AdvancedFsBrowser.java @@ -22,7 +22,6 @@ import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; @@ -32,11 +31,13 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Text; +/** Simple UI provider that populates a composite parent given a NIO path */ public class AdvancedFsBrowser { private final static Log log = LogFactory.getLog(AdvancedFsBrowser.class); // Some local constants to experiment. should be cleaned - private final static int THUMBNAIL_WIDTH = 400; + // private final static int THUMBNAIL_WIDTH = 400; + // private Point imageWidth = new Point(250, 0); private final static int COLUMN_WIDTH = 160; private Path initialPath; @@ -104,6 +105,7 @@ public class AdvancedFsBrowser { scrolledCmpBody = new Composite(scrolledCmp, SWT.NO_FOCUS); scrolledCmp.setContent(scrolledCmpBody); scrolledCmpBody.addControlListener(new ControlAdapter() { + private static final long serialVersionUID = 183238447102854553L; @Override public void controlResized(ControlEvent e) { @@ -284,11 +286,9 @@ public class AdvancedFsBrowser { } } - private Point imageWidth = new Point(250, 0); - /** - * Recreates the content of the box that displays information about the - * current selected node. + * Recreates the content of the box that displays information about the current + * selected node. */ private void populateCurrEditedDisplay(Composite parent, Path context) { parent.setLayout(new GridLayout()); @@ -354,8 +354,8 @@ public class AdvancedFsBrowser { } /** - * Enable highlighting the correct element in the table when externally - * browsing (typically via the command-line-like Text field) + * Enable highlighting the correct element in the table when externally browsing + * (typically via the command-line-like Text field) */ void setSelected(Path selected) { // to prevent change selection event to be thrown @@ -398,13 +398,19 @@ public class AdvancedFsBrowser { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); if (selection.isEmpty()) return; - else { - Path newSelected = (Path) selection.getFirstElement(); - if (newSelected.equals(currSelected)) - return; - currSelected = newSelected; - setEdited(newSelected); - } + Object obj = selection.getFirstElement(); + Path newSelected; + if (obj instanceof Path) + newSelected = (Path) obj; + else if (obj instanceof ParentDir) + newSelected = ((ParentDir) obj).getPath(); + else + return; + if (newSelected.equals(currSelected)) + return; + currSelected = newSelected; + setEdited(newSelected); + } });