use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class BrowseViewAction method doRun.
@Override
protected void doRun() {
Object obj = getSelectedObject().get(0);
if (obj instanceof IRepositoryViewObject) {
IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
WSViewItem item = (WSViewItem) viewObject.getProperty().getItem();
WSViewE wsView = item.getWsView();
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
SelectServerDefDialog dlg = new SelectServerDefDialog(getShell());
dlg.create();
dlg.setSelectServer(lastServerDef);
if (dlg.open() == IDialogConstants.OK_ID) {
ViewBrowserInput input = new ViewBrowserInput(viewObject);
input.setServerDef(dlg.getSelectedServerDef());
if (page == null) {
page = commonViewer.getCommonNavigator().getSite().getWorkbenchWindow().getActivePage();
}
try {
IEditorPart oldEditor = page.findEditor(input);
if (oldEditor != null) {
page.closeEditor(oldEditor, false);
}
page.openEditor(input, XObjectBrowser2.EDITOR_ID);
} catch (PartInitException e) {
log.error(e.getMessage(), e);
}
}
}
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class RenameProcessAction method renameProcessObject.
private void renameProcessObject(IRepositoryViewObject viewObj) {
MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
MDMServerObject serverObject = item.getMDMServerObject();
int type = getType(item);
if (serverObject != null) {
String oldName = serverObject.getName();
RenameProcessDialog dialog = getRenameDialog(getSite(), oldName, type, getInputValidator());
int returnCode = dialog.open();
if (returnCode == Window.OK) {
IProxyRepositoryFactory factory = getFactory();
String newName = dialog.getValue();
transformPath(viewObj, newName);
try {
if (factory.isEditableAndLockIfPossible(item)) {
serverObject.setName(newName);
viewObj.getProperty().setLabel(newName);
viewObj.getProperty().setDisplayName(newName);
factory.save(item, false);
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
if (lastServerDef != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
}
}
commonViewer.refresh(viewObj);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} finally {
try {
factory.unlock(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
}
}
}
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class ViewMainPage2 method getLastServerDef.
private MDMServerDef getLastServerDef() {
XObjectEditorInput2 input = (XObjectEditorInput2) getEditor().getEditorInput();
Item item = input.getInputItem();
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
return lastServerDef;
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class XObjectEditor2 method saveResourceToRepository.
private boolean saveResourceToRepository() {
XObjectEditorInput2 editorInput = (XObjectEditorInput2) this.getEditorInput();
TreeObject xobject = (TreeObject) editorInput.getModel();
IRepositoryViewObject viewObject = editorInput.getViewObject();
IRepositoryViewObject refreshViewObject = RepositoryResourceUtil.assertViewObject(viewObject);
if (viewObject != refreshViewObject) {
editorInput.updateViewObject(refreshViewObject);
}
MDMServerObjectItem serverObjectItem = (MDMServerObjectItem) editorInput.getInputItem();
MDMServerObject serverObject = serverObjectItem.getMDMServerObject();
EObject eObj = Bean2EObjUtil.getInstance().convertFromBean2EObj(xobject.getWsObject(), serverObject);
if (eObj != null) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
try {
factory.save(serverObjectItem);
// TODO should call the following,but the page in editor has many call to remote webService ,it will
// search ServerRoot which cause a NPE
// xobject.fireEvent(IXObjectModelListener.SAVE, xobject.getParent(), xobject);
editorDirtyStateChanged();
refreshDirtyCue();
DeployService deployService = DeployService.getInstance();
if (deployService.isAutoDeploy()) {
autoDeployProcess(deployService);
} else {
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(serverObjectItem);
if (lastServerDef != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, editorInput.getViewObject());
}
}
return true;
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
}
}
return false;
}
use of org.talend.mdm.repository.model.mdmmetadata.MDMServerDef in project tmdm-studio-se by Talend.
the class XSDEditor2 method innerSave.
private void innerSave(final IProgressMonitor monitor) {
IRepositoryViewObject viewObject = getCurrentViewObject();
final Item item = viewObject.getProperty().getItem();
int activePage = getActivePage();
//
final TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) getAdapter(TransactionalEditingDomain.class);
if (editingDomain != null && (activePage != MODEL_PAGE_INDEX && activePage != SOURCE_PAGE_INDEX)) {
editingDomain.getCommandStack().execute(new AbstractCommand() {
@Override
public boolean canExecute() {
return true;
}
@Override
public void redo() {
// do nothing
}
@Override
public void execute() {
doSave(item, monitor);
}
});
} else {
doSave(item, monitor);
}
DeployService deployService = DeployService.getInstance();
if (deployService.isAutoDeploy()) {
deployService.autoDeploy(getSite().getShell(), viewObject);
} else {
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(item);
if (lastServerDef != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_MODIFY, viewObject);
}
}
}
Aggregations