package jetbrains.mps.workbench.dialogs.project.components.parts.actions;
/*Generated by MPS */
import javax.swing.ListSelectionModel;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnActionEvent;
import java.util.List;
import java.util.ArrayList;
public abstract class BaseAddAction extends BaseValidatedAction {
private ListSelectionModel mySelectionModel;
protected BaseAddAction(ListSelectionModel model) {
super("Add", "Add", AllIcons.General.Add);
mySelectionModel = model;
}
@Override
public final void doPerform(AnActionEvent e) {
List<Integer> indices = doAddMul(e);
getSelectionModel().clearSelection();
for (int index : indices) {
getSelectionModel().addSelectionInterval(index, index);
}
}
protected ListSelectionModel getSelectionModel() {
return mySelectionModel;
}
protected List<Integer> doAddMul(AnActionEvent e) {
ArrayList<Integer> result = new ArrayList<Integer>();
int addResult = doAdd(e);
if (addResult >= 0) {
result.add(addResult);
}
return result;
}
protected int doAdd(AnActionEvent e) {
return -1;
}
}