use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class WhereConnectionCreationTool method performConnectionStartWith.
public void performConnectionStartWith(EditPart sourcePart) {
setConnectionSource(sourcePart);
updateTargetRequest();
Command cmd = ((ColumnPart) sourcePart).getCommand(getTargetRequest());
setCurrentCommand(cmd);
setState(STATE_CONNECTION_STARTED);
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class VarToolBarFigure method removeVar.
@Override
protected void removeVar() {
CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
final List<VarNode> toRemove = new ArrayList<VarNode>();
int minIndex = parentTable.getNodes().size() - 1;
for (Object obj : selectedEditParts) {
if (obj instanceof VarNodeEditPart) {
VarNode model = (VarNode) ((VarNodeEditPart) obj).getModel();
toRemove.add(model);
XmlMapUtil.detachNodeConnections(model, (XmlMapData) parentTable.eContainer(), true);
int index = parentTable.getNodes().indexOf(model);
if (index < minIndex) {
minIndex = index;
}
}
}
parentTable.getNodes().removeAll(toRemove);
if (!tablePart.getChildren().isEmpty()) {
if (minIndex > tablePart.getChildren().size() - 1) {
minIndex = tablePart.getChildren().size() - 1;
}
tablePart.getViewer().select((EditPart) tablePart.getChildren().get(minIndex));
} else {
remove.setEnabled(false);
}
}
});
}
use of org.eclipse.gef.commands.Command in project tdi-studio-se by Talend.
the class VarToolBarFigure method addVar.
@Override
protected void addVar() {
CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
commandStack.execute(new Command() {
@Override
public void execute() {
VarNode newNode = XmlmapFactory.eINSTANCE.createVarNode();
newNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
newNode.setName(XmlMapUtil.findUniqueVarColumnName("Var", parentTable));
parentTable.getNodes().add(newNode);
parentTable.setMinimized(false);
EditPart toSelect = null;
int index = parentTable.getNodes().indexOf(newNode);
if (index < tablePart.getChildren().size()) {
toSelect = (EditPart) tablePart.getChildren().get(index);
tablePart.getViewer().select(toSelect);
}
if (!remove.isEnabled()) {
remove.setEnabled(true);
}
}
});
}
use of org.eclipse.gef.commands.Command in project tesb-studio-se by Talend.
the class ESBService method checkRepository.
private void checkRepository(final Node node, Item item, CommandStack stack) {
final String updataComponentParamName = EParameterName.UPDATE_COMPONENTS.getName();
final List<IElementParameter> repositoryParam = new ArrayList<IElementParameter>();
for (IElementParameter param : node.getElementParameters()) {
if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
String value = (String) param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).getValue();
if (value.equals(EmfComponent.REPOSITORY)) {
IElementParameter schema = param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
if (schema != null && schema.getValue() != null) {
//$NON-NLS-1$
String[] names = ((String) schema.getValue()).split(" - ");
if (names.length > 0 && names[0].equals(item.getProperty().getId())) {
repositoryParam.add(schema);
}
}
}
} else if (param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) {
Object value = param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).getValue();
if (value.equals(EmfComponent.REPOSITORY)) {
IElementParameter property = param.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (property != null && property.getValue() != null) {
String proValue = (String) property.getValue();
if (proValue != null && proValue.contains(" - ")) {
proValue = proValue.split(" - ")[0];
}
if (proValue.equals(item.getProperty().getId())) {
repositoryParam.add(property);
}
}
}
}
}
if (repositoryParam.isEmpty()) {
return;
}
stack.execute(new Command() {
@Override
public void execute() {
node.setPropertyValue(updataComponentParamName, Boolean.TRUE);
for (IElementParameter param : repositoryParam) {
// force to reload label
param.setListItemsDisplayName(new String[0]);
param.setListItemsValue(new String[0]);
}
}
});
}
use of org.eclipse.gef.commands.Command in project tesb-studio-se by Talend.
the class CamelDependenciesEditor method dependencesChanged.
@Override
public void dependencesChanged(Composite source) {
// setDirty(true);
final Command cmd;
if (source == manageRouteResourcePanel) {
cmd = new Command() {
@Override
public void execute() {
RouteResourceUtil.saveResourceDependency(getJobEditorInput().getLoadedProcess().getAdditionalProperties(), manageRouteResourcePanel.getInput());
RelationshipItemBuilder.getInstance().addOrUpdateItem(getJobEditorInput().getItem());
}
};
} else {
cmd = new Command() {
@Override
public void execute() {
//save all datas
DependenciesCoreUtil.saveToMap(getJobEditorInput().getLoadedProcess().getAdditionalProperties(), (Collection<BundleClasspath>) bundleClasspathViewer.getInput(), (Collection<ImportPackage>) importPackageViewer.getInput(), (Collection<RequireBundle>) requireBundleViewer.getInput(), (Collection<ExportPackage>) exportPackageViewer.getInput());
}
};
}
commandStack.execute(cmd);
// doSave(new NullProgressMonitor());
}
Aggregations