Search in sources :

Example 6 with WSResourceE

use of org.talend.mdm.repository.model.mdmserverobject.WSResourceE in project tmdm-studio-se by Talend.

the class CopyUrlAction method multiCopy.

private void multiCopy() {
    StringBuilder result = new StringBuilder();
    List<Object> selectedObject = getSelectedObject();
    for (Object obj : selectedObject) {
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        // picture file info
        Item item = viewObject.getProperty().getItem();
        WSResourceE wsItem = null;
        if (!(item instanceof WSResourceItem)) {
            continue;
        }
        wsItem = ((WSResourceItem) item).getResource();
        String catalog = wsItem.getImageCatalog();
        if (catalog == null) {
            continue;
        }
        String fileName = viewObject.getLabel() + '.' + wsItem.getFileExtension();
        // MDMServerDef thing
        MDMServerDef serverDef = RepositoryResourceUtil.getLastServerDef(viewObject);
        if (serverDef == null) {
            continue;
        }
        // all picture url string
        String contextPath = Util.getContextPath(serverDef.getPath());
        String uripre = serverDef.getProtocol() + serverDef.getHost() + ':' + serverDef.getPort() + contextPath;
        result.append(uripre);
        // $NON-NLS-1$
        result.append("/imageserver/upload/" + catalog + '/' + fileName);
        result.append('\n');
    }
    // copy url to clipboard
    if (result.length() != 0) {
        Clipboard cb = new Clipboard(Display.getCurrent());
        String textData = result.toString();
        TextTransfer transfer = TextTransfer.getInstance();
        cb.setContents(new Object[] { textData }, new Transfer[] { transfer });
        cb.dispose();
    }
}
Also used : Item(org.talend.core.model.properties.Item) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) Clipboard(org.eclipse.swt.dnd.Clipboard) WSResourceE(org.talend.mdm.repository.model.mdmserverobject.WSResourceE) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) TextTransfer(org.eclipse.swt.dnd.TextTransfer)

Aggregations

WSResourceE (org.talend.mdm.repository.model.mdmserverobject.WSResourceE)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 TreeParent (com.amalto.workbench.models.TreeParent)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Item (org.talend.core.model.properties.Item)2 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)2 MDMServerObject (org.talend.mdm.repository.model.mdmserverobject.MDMServerObject)2 TreeObject (com.amalto.workbench.models.TreeObject)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)1 WSResourceItem (org.talend.mdm.repository.model.mdmproperties.WSResourceItem)1