use of org.obeonetwork.graal.UserStory in project InformationSystem by ObeoNetwork.
the class UserStoryLabelProvider method update.
/**
* {@inheritDoc}
* @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
*/
@Override
public void update(ViewerCell cell) {
Object element = cell.getElement();
String label;
if (element instanceof UserStory) {
label = ((UserStory) element).getName();
} else {
label = delegateLabelProvider.getText(element);
}
StyledString str = new StyledString(label, getStyle(cell));
cell.setText(str.getString());
cell.setStyleRanges(str.getStyleRanges());
if (isActivatedStory(cell)) {
cell.setImage(null);
cell.setImage(highlightImage);
} else {
cell.setImage(null);
cell.setImage(noHighlightImage);
}
}
use of org.obeonetwork.graal.UserStory in project InformationSystem by ObeoNetwork.
the class UserStoriesView method createPartControl.
/**
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
public void createPartControl(Composite parent) {
viewer = new CheckboxTreeViewer(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
viewer.setUseHashlookup(true);
viewer.setContentProvider(new UserStoriesContentProvider());
viewer.setLabelProvider(new UserStoryLabelProvider(this, adapterFactory));
viewer.setCheckStateProvider(new UserStoriesCheckStateProvider(viewer));
viewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (event.getElement() instanceof UserStory) {
UserStory story = (UserStory) event.getElement();
if (viewer.getInput() instanceof UserStoryElement) {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(viewer.getInput());
if (editingDomain != null) {
if (event.getChecked()) {
LinkStory command = new LinkStory(story, (UserStoryElement) viewer.getInput());
editingDomain.getCommandStack().execute(command);
} else {
UnlinkStory command = new UnlinkStory(story, (UserStoryElement) viewer.getInput());
editingDomain.getCommandStack().execute(command);
}
}
} else if (viewer.getInput() instanceof Collection<?>) {
List<UserStoryElement> selection = new ArrayList<UserStoryElement>();
for (Object next : (Collection<?>) viewer.getInput()) {
if (next instanceof UserStoryElement) {
selection.add((UserStoryElement) next);
}
}
if (!selection.isEmpty()) {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(selection.get(0));
if (editingDomain != null) {
if (event.getChecked()) {
LinkStory command = new LinkStory(story, selection);
editingDomain.getCommandStack().execute(command);
} else {
UnlinkStory command = new UnlinkStory(story, selection);
editingDomain.getCommandStack().execute(command);
}
}
}
}
}
viewer.refresh();
}
});
ColumnViewerToolTipSupport.enableFor(viewer);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
State state = service.getCommand(HighlightUserStoryCommand.COMMAND_ID).getState(HighlightUserStoryCommand.STATE_ID);
state.setValue(getSelectedStories().size() == 1 && isActiveUserStory(getSelectedStories().get(0)));
service.refreshElements(HighlightUserStoryCommand.COMMAND_ID, null);
}
});
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
updateUserStoryHighlightment();
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
State state = service.getCommand(HighlightUserStoryCommand.COMMAND_ID).getState(HighlightUserStoryCommand.STATE_ID);
state.setValue(getSelectedStories().size() == 1 && isActiveUserStory(getSelectedStories().get(0)));
service.refreshElements(HighlightUserStoryCommand.COMMAND_ID, null);
}
});
getSite().setSelectionProvider(viewer);
selectionListener = new ViewpointMultiSelectionListener(this) {
@Override
protected void eObjectSelected(Session session, List<EObject> selectedEObjects) {
update(session, selectedEObjects);
}
};
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(selectionListener);
}
use of org.obeonetwork.graal.UserStory in project InformationSystem by ObeoNetwork.
the class UserStoriesView method updateUserStoryHighlightment.
public void updateUserStoryHighlightment() {
if (getSelectedStories().size() == 1) {
UserStory currentStory = getSelectedStories().get(0);
getEditingDomain().getCommandStack().execute(new UpdateStoryActivationStatus(activeAnalysis, currentStory));
viewer.refresh();
}
}
use of org.obeonetwork.graal.UserStory in project InformationSystem by ObeoNetwork.
the class DeleteUserStoriesHandler method execute.
/**
* {@inheritDoc}
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof UserStoriesView) {
UserStoriesView view = (UserStoriesView) activePart;
boolean openConfirm = MessageDialog.openConfirm(view.getSite().getShell(), "Delete User Stories", "Delete the selected user stories ?");
if (openConfirm == true) {
EditingDomain editingDomain = view.getEditingDomain();
if (editingDomain != null) {
List<UserStory> selectedStories = view.getSelectedStories();
editingDomain.getCommandStack().execute(DeleteCommand.create(editingDomain, selectedStories));
view.refresh();
}
}
}
return null;
}
use of org.obeonetwork.graal.UserStory in project InformationSystem by ObeoNetwork.
the class EditUserStoryHandler method execute.
/**
* {@inheritDoc}
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof UserStoriesView) {
UserStoriesView view = (UserStoriesView) activePart;
EditingDomain editingDomain = view.getEditingDomain();
if (editingDomain != null) {
UserStory userStory = view.getSelectedStories().get(0);
UserStoryDialog dialog = new UserStoryDialog(HandlerUtil.getActiveShell(event), userStory);
int open = dialog.open();
if (open == Window.OK) {
CompoundCommand cc = new CompoundCommand();
cc.append(SetCommand.create(editingDomain, userStory, GraalPackage.eINSTANCE.getNamedElement_Name(), dialog.getName()));
cc.append(SetCommand.create(editingDomain, userStory, EnvironmentPackage.eINSTANCE.getObeoDSMObject_Description(), dialog.getDescription()));
editingDomain.getCommandStack().execute(cc);
view.refresh();
}
}
}
return null;
}
Aggregations