X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=cms%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Fcontrollers%2FArtifactLabelProvider.java;fp=cms%2Forg.argeo.slc.client.ui.dist%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fdist%2Fcontrollers%2FArtifactLabelProvider.java;h=0000000000000000000000000000000000000000;hb=6fc94d69efe089414ac9e63bde3efab1cbf7b7ca;hp=197921e8934d4aba9084c179732153538e564b9e;hpb=b36c62642bd0db11b3133b369cc026fd4b7a1ec6;p=gpl%2Fargeo-slc.git diff --git a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java b/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java deleted file mode 100644 index 197921e89..000000000 --- a/cms/org.argeo.slc.client.ui.dist/src/org/argeo/slc/client/ui/dist/controllers/ArtifactLabelProvider.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.argeo.slc.client.ui.dist.controllers; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; - -import javax.jcr.Node; -import javax.jcr.Property; -import javax.jcr.RepositoryException; - -import org.argeo.jcr.JcrUtils; -import org.argeo.slc.SlcException; -import org.argeo.slc.SlcTypes; -import org.argeo.slc.client.ui.dist.DistConstants; -import org.argeo.slc.client.ui.dist.DistImages; -import org.eclipse.jface.viewers.ColumnLabelProvider; -import org.eclipse.jface.viewers.ViewerCell; -import org.eclipse.swt.graphics.Image; - -/** Retrieve artifact information to be displayed in an artifact tree or table */ -public class ArtifactLabelProvider extends ColumnLabelProvider implements - DistConstants, SlcTypes { - private static final long serialVersionUID = 8672622174076959016L; - - // To be able to change column order easily - public static final int COLUMN_TREE = 0; - public static final int COLUMN_DATE = 1; - public static final int COLUMN_SIZE = 2; - - // Utils - protected static DateFormat timeFormatter = new SimpleDateFormat( - DATE_TIME_FORMAT); - - public void update(ViewerCell cell) { - int colIndex = cell.getColumnIndex(); - Object element = cell.getElement(); - cell.setText(getColumnText(element, colIndex)); - if (element instanceof Node && colIndex == 0) { - Node node = (Node) element; - try { - if (node.isNodeType(SLC_ARTIFACT_BASE)) - cell.setImage(DistImages.IMG_ARTIFACT_BASE); - else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) - cell.setImage(DistImages.IMG_ARTIFACT_VERSION_BASE); - } catch (RepositoryException e) { - // Silent - } - } - } - - @Override - public Image getImage(Object element) { - - if (element instanceof Node) { - Node node = (Node) element; - try { - if (node.isNodeType(SLC_ARTIFACT_BASE)) { - return DistImages.IMG_ARTIFACT_BASE; - } else if (node.isNodeType(SLC_ARTIFACT_VERSION_BASE)) { - return DistImages.IMG_ARTIFACT_VERSION_BASE; - } - } catch (RepositoryException e) { - // Silent - } - } - return null; - } - - public String getColumnText(Object element, int columnIndex) { - try { - if (element instanceof Node) { - Node node = (Node) element; - switch (columnIndex) { - case COLUMN_TREE: - return node.getName(); - case COLUMN_SIZE: - long size = JcrUtils.getNodeApproxSize(node) / 1024; - if (size > 1024) - return size / 1024 + " MB"; - else - return size + " KB"; - case COLUMN_DATE: - if (node.hasProperty(Property.JCR_LAST_MODIFIED)) - return timeFormatter.format(node - .getProperty(Property.JCR_LAST_MODIFIED) - .getDate().getTime()); - else - return null; - } - } - } catch (RepositoryException re) { - throw new SlcException( - "Unexepected error while getting property values", re); - } - return null; - } -}