Search in sources :

Example 1 with WSResourceItem

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

the class MdmPropertiesWizard method addPages.

@Override
public void addPages() {
    mainPage = new // $NON-NLS-1$
    PropertiesWizardPage(// $NON-NLS-1$
    "WizardPage", // $NON-NLS-1$
    object.getProperty(), // $NON-NLS-1$
    path, // $NON-NLS-1$
    isReadOnly(), // $NON-NLS-1$
    false, // $NON-NLS-1$
    lastVersionFound) {

        @Override
        public void createControl(Composite parent) {
            Composite container = new Composite(parent, SWT.NONE);
            GridLayout layout = new GridLayout(2, false);
            container.setLayout(layout);
            if (alreadyEditedByUser) {
                Label label = new Label(container, SWT.NONE);
                label.setForeground(ColorConstants.red);
                label.setText(Messages.MdmPropertiesWizard_lockedByOther);
                GridData gridData = new GridData();
                gridData.horizontalSpan = 2;
                label.setLayoutData(gridData);
            }
            super.createControl(container);
            setControl(container);
            updateContent();
            nameText.setEnabled(canEditObjectName());
            addListeners();
            setPageComplete(false);
            // add catalog field for resource node
            if (object.getProperty().getItem() instanceof WSResourceItem) {
                final WSResourceItem item = (WSResourceItem) object.getProperty().getItem();
                final Text imageCatalog = addImageCatalogField(container, item);
                // add listener
                if (imageCatalog != null) {
                    imageCatalog.addModifyListener(new ModifyListener() {

                        public void modifyText(ModifyEvent e) {
                            item.getResource().setImageCatalog(imageCatalog.getText());
                            updatePageStatus();
                        }
                    });
                }
            }
        }

        @Override
        protected void evaluateTextField() {
            if (isReadOnly()) {
                return;
            }
            if (nameText == null || nameText.isDisposed()) {
                return;
            }
            // 
            String errorMsg = null;
            String newText = nameText.getText();
            if (newText.length() == 0) {
                nameStatus = createStatus(IStatus.ERROR, Messages.Common_nameCanNotBeEmpty);
            } else {
                if (!isValid(newText)) {
                    errorMsg = Messages.Common_nameIsUsed;
                } else {
                    ERepositoryObjectType objectType = object.getRepositoryObjectType();
                    if (objectType.equals(IServerObjectRepositoryType.TYPE_VIEW)) {
                        if (!ValidateUtil.matchViewProcessRegex(newText)) {
                            errorMsg = Messages.Common_nameInvalid;
                        }
                    } else if (objectType.equals(IServerObjectRepositoryType.TYPE_TRANSFORMERV2)) {
                        if (newText.startsWith(ITransformerV2NodeConsDef.PREFIX_SMARTVIEW_UPPER)) {
                            if (!ValidateUtil.matchSmartViewRegex(newText)) {
                                errorMsg = Messages.Common_nameInvalid;
                            }
                        }
                        if (errorMsg == null && !ValidateUtil.matchViewProcessRegex(newText)) {
                            errorMsg = Messages.Common_nameInvalid;
                        }
                    } else if (objectType.equals(IServerObjectRepositoryType.TYPE_CUSTOM_FORM)) {
                        if (!ValidateUtil.matchCustomFormRegex(newText)) {
                            errorMsg = Messages.Common_nameInvalid;
                        }
                    } else if (objectType.equals(IServerObjectRepositoryType.TYPE_ROLE)) {
                        if (!ValidateUtil.matchRoleRegex(newText)) {
                            errorMsg = Messages.Common_nameInvalid;
                        }
                    } else {
                        if (!ValidateUtil.matchCommonRegex(newText)) {
                            errorMsg = Messages.Common_nameInvalid;
                        }
                    }
                }
                if (errorMsg != null) {
                    nameStatus = createStatus(IStatus.ERROR, errorMsg);
                } else {
                    nameStatus = createOkStatus();
                }
            }
            if (property != null && nameStatus.getSeverity() == IStatus.OK) {
                property.setLabel(getPropertyLabel(newText.trim().isEmpty() ? null : newText.trim()));
                property.setDisplayName(newText.trim().isEmpty() ? null : newText.trim());
                property.setModificationDate(new Date());
            }
            updatePageStatus();
        }

        @Override
        public ERepositoryObjectType getRepositoryObjectType() {
            return object.getRepositoryObjectType();
        }
    };
    addPage(mainPage);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) Text(org.eclipse.swt.widgets.Text) Date(java.util.Date) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 2 with WSResourceItem

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

the class ResourceRepositoryFileEditorInput method getReferenceFile.

public IFile getReferenceFile() {
    if (file == null) {
        Item item = getInputItem();
        String fileExtension = ((WSResourceItem) item).getResource().getFileExtension();
        file = RepositoryResourceUtil.findReferenceFile(IServerObjectRepositoryType.TYPE_RESOURCE, item, fileExtension);
    }
    return file;
}
Also used : WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) Item(org.talend.core.model.properties.Item)

Example 3 with WSResourceItem

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

the class MDMServerDecorator method decorateRepositoryObject.

private void decorateRepositoryObject(Item item, IDecoration decoration) {
    if (item != null) {
        String version = item.getProperty().getVersion();
        if (item instanceof WSResourceItem) {
            // resource image show catalog
            WSResourceItem ritem = (WSResourceItem) item;
            String imageCatalog = ritem.getResource().getImageCatalog();
            if (imageCatalog != null) {
                // $NON-NLS-1$
                decoration.addSuffix(" " + imageCatalog);
            }
        } else if (version != null) {
            // $NON-NLS-1$
            decoration.addSuffix(" " + version);
        }
        MDMServerDef serverDef = RepositoryResourceUtil.getLastServerDef(item);
        if (serverDef != null) {
            decoration.addOverlay(IMG_SERVER, IDecoration.TOP_RIGHT);
            // $NON-NLS-1$
            decoration.addSuffix(" " + serverDef.getName());
        }
    }
}
Also used : WSResourceItem(org.talend.mdm.repository.model.mdmproperties.WSResourceItem) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)

Example 4 with WSResourceItem

use of org.talend.mdm.repository.model.mdmproperties.WSResourceItem 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

WSResourceItem (org.talend.mdm.repository.model.mdmproperties.WSResourceItem)4 Item (org.talend.core.model.properties.Item)2 MDMServerDef (org.talend.mdm.repository.model.mdmmetadata.MDMServerDef)2 Date (java.util.Date)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)1 WSResourceE (org.talend.mdm.repository.model.mdmserverobject.WSResourceE)1