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);
}
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;
}
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());
}
}
}
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();
}
}
Aggregations