private void propagateType(IContextManager contextManager, IContextParameter param) { for (IContext context : contextManager.getListContext()) { IContextParameter paramToModify = context.getContextParameter(param.getName()); paramToModify.setType(param.getType()); paramToModify.setComment(param.getComment()); paramToModify.setSource(param.getSource()); } }
/* * (non-Javadoc) * * @see org.eclipse.gef.commands.Command#undo() */ @Override public void undo() { boolean modified = false; if (modelManager.getContextManager() != null) { for (IContext context : modelManager.getContextManager().getListContext()) { for (IContextParameter contextParameter : context.getContextParameterList()) { if (param.getName().equals(contextParameter.getName())) { contextParameter.setType(oldValue); modified = true; } } } } if (modified) { updateRelation(); } }
private void setPropertyValue( IContextModelManager manager, Object dataElement, String contextParaName, int columnIndex, Object newValue) { String currentColumnName = getColumnProperty(columnIndex); if (this.groupModel.isPartOfAGroup(columnIndex)) { String columnGroupName = this.groupModel.getColumnGroupByIndex(columnIndex).getName(); IContextManager contextManger = manager.getContextManager(); if (contextManger != null) { // change the property of context such as prompt,promptyNeeded,value etc. List<Object> list = new ArrayList<Object>(); list.add(dataElement); IContextParameter para = null; para = getRealParameter(contextManger, columnGroupName, dataElement); if (para == null) { return; } Command cmd = new SetContextGroupParameterCommand(manager, para, currentColumnName, newValue); runCommand(cmd, manager); if (currentColumnName.equals(ContextTableConstants.COLUMN_CHECK_PROPERTY)) { manager.refresh(); } } } else { if (currentColumnName.equals(ContextTableConstants.COLUMN_TYPE_PROPERTY)) { ContextTableTabParentModel parent = (ContextTableTabParentModel) dataElement; IContextParameter contextPara = parent.getContextParameter(); if (contextPara.getType() == ((String) newValue)) { return; } String newType = getRealType((String) newValue); contextPara.setType(newType); Command cmd = new SetContextTypeCommand(manager, contextPara, newType); runCommand(cmd, manager); } else if (currentColumnName.equals(ContextTableConstants.COLUMN_NAME_PROPERTY)) { ContextTableTabParentModel parent = (ContextTableTabParentModel) dataElement; IContextParameter contextPara = parent.getContextParameter(); String sourceId = contextPara.getSource(); String newParaName = (String) newValue; if (manager.getContextManager() instanceof JobContextManager) { // in case joblet rename will propagate to the job,just record it JobContextManager contextManager = (JobContextManager) manager.getContextManager(); contextManager.addNewName(newParaName, contextPara.getName()); contextManager.setModified(true); } Command cmd = new SetContextNameCommand(manager, contextPara, newParaName, sourceId); runCommand(cmd, manager); } else if (currentColumnName.equals(ContextTableConstants.COLUMN_COMMENT_PROPERTY)) { ContextTableTabParentModel parent = (ContextTableTabParentModel) dataElement; IContextParameter contextPara = parent.getContextParameter(); if (contextPara.getComment() == ((String) newValue)) { return; } Command cmd = new setContextCommentCommand(manager, contextPara, (String) newValue); runCommand(cmd, manager); } } }