use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class PropertyTypeController method processPattern.
// Added TDQ-13192 20170222
private Command processPattern(IElement elem) {
CompoundCommand compoundCommand = new CompoundCommand();
ITDQPatternService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQPatternService.class)) {
service = (ITDQPatternService) GlobalServiceRegister.getDefault().getService(ITDQPatternService.class);
}
if (service != null && elem instanceof Node) {
Node node = (Node) elem;
//$NON-NLS-1$
IElementParameter typeParam = node.getElementParameter("TYPE");
boolean hadSelected = service.selectPattern(typeParam, elem);
if (hadSelected) {
// create the command
//$NON-NLS-1$
final String showId = (String) node.getElementParameter("PATTERN_ID").getValue();
compoundCommand = new CompoundCommand();
Command command = new PropertyChangeCommand(elem, EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), showId);
compoundCommand.add(command);
IElementParameter elementParameter = node.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String[] displayName = new String[1];
//$NON-NLS-1$
displayName[0] = (String) node.getElementParameter("PATTERN_NAME").getValue();
elementParameter.setListItemsDisplayName(displayName);
elementParameter.setListItemsValue(new String[] { showId });
}
}
return compoundCommand;
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class PropertyTypeController method initCDC.
private void initCDC(CompoundCommand cc, ConnectionItem originalConnectionItem) {
if (!(elem instanceof Node)) {
return;
}
Node node = (Node) elem;
// ConnectionItem originalConnectionItem = repositoryConnectionItem;
ConnectionItem connectionItem = originalConnectionItem;
Connection originalConnection = connectionItem.getConnection();
Connection connection = connectionItem.getConnection();
if (node.getComponent().getName().contains("CDC")) {
// to replace by a flag CDC in component? //$NON-NLS-1$
if (originalConnectionItem instanceof DatabaseConnectionItem) {
final DatabaseConnection databaseConnection = (DatabaseConnection) connection;
CDCConnection cdcConn = databaseConnection.getCdcConns();
if (cdcConn != null) {
EList cdcTypes = cdcConn.getCdcTypes();
if (cdcTypes != null && !cdcTypes.isEmpty()) {
CDCType cdcType = (CDCType) cdcTypes.get(0);
// replace property by CDC property.
String propertyId = cdcType.getLinkDB();
try {
IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
if (object != null) {
if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbConnItem = (DatabaseConnectionItem) object.getProperty().getItem();
// replace connection by CDC connection
connectionItem = dbConnItem;
connection = dbConnItem.getConnection();
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// set cdc type mode.
IElementParameter logModeParam = node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
if (logModeParam != null) {
String cdcTypeMode = ((DatabaseConnection) originalConnection).getCdcTypeMode();
Command logModeCmd = new PropertyChangeCommand(node, EParameterName.CDC_TYPE_MODE.getName(), CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
cc.add(logModeCmd);
}
// set lib for as400 so far.
//$NON-NLS-1$
final String name = "SOURCE_LIB";
IElementParameter libParam = node.getElementParameter(name);
if (libParam != null) {
Object propValue;
if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(databaseConnection.getSID())) {
propValue = databaseConnection.getSID();
} else {
propValue = TalendTextUtils.addQuotes(databaseConnection.getSID());
}
Command libSettingCmd = new PropertyChangeCommand(node, name, propValue);
cc.add(libSettingCmd);
}
}
}
}
}
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class DocumentBusinessItemNameEditPart method createDefaultEditPolicies.
/**
* @generated
*/
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {
protected List createSelectionHandles() {
List handles = new ArrayList();
NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
return handles;
}
public Command getCommand(Request request) {
return null;
}
public boolean understandsRequest(Request request) {
return false;
}
});
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class GearBusinessItemNameEditPart method createDefaultEditPolicies.
/**
* @generated
*/
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {
protected List createSelectionHandles() {
List handles = new ArrayList();
NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
return handles;
}
public Command getCommand(Request request) {
return null;
}
public boolean understandsRequest(Request request) {
return false;
}
});
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class EllipseBusinessItemNameEditPart method createDefaultEditPolicies.
/**
* @generated
*/
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {
protected List createSelectionHandles() {
List handles = new ArrayList();
NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
return handles;
}
public Command getCommand(Request request) {
return null;
}
public boolean understandsRequest(Request request) {
return false;
}
});
}
Aggregations