Search in sources :

Example 6 with UserStory

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);
    }
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) UserStory(org.obeonetwork.graal.UserStory)

Example 7 with UserStory

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);
}
Also used : LinkStory(org.obeonetwork.graal.design.command.LinkStory) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) UnlinkStory(org.obeonetwork.graal.design.command.UnlinkStory) ArrayList(java.util.ArrayList) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ICommandService(org.eclipse.ui.commands.ICommandService) UserStory(org.obeonetwork.graal.UserStory) UserStoriesContentProvider(org.obeonetwork.graal.design.ui.view.util.UserStoriesContentProvider) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) EObject(org.eclipse.emf.ecore.EObject) UserStoryLabelProvider(org.obeonetwork.graal.design.ui.view.util.UserStoryLabelProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) UserStoriesCheckStateProvider(org.obeonetwork.graal.design.ui.view.util.UserStoriesCheckStateProvider) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) State(org.eclipse.core.commands.State) Collection(java.util.Collection) EObject(org.eclipse.emf.ecore.EObject) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) UserStoryElement(org.obeonetwork.graal.UserStoryElement) ViewpointMultiSelectionListener(org.obeonetwork.graal.design.ui.view.util.ViewpointMultiSelectionListener) Session(org.eclipse.sirius.business.api.session.Session)

Example 8 with UserStory

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();
    }
}
Also used : UpdateStoryActivationStatus(org.obeonetwork.graal.design.command.UpdateStoryActivationStatus) UserStory(org.obeonetwork.graal.UserStory)

Example 9 with UserStory

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;
}
Also used : UserStoriesView(org.obeonetwork.graal.design.ui.view.UserStoriesView) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) UserStory(org.obeonetwork.graal.UserStory)

Example 10 with UserStory

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;
}
Also used : UserStoriesView(org.obeonetwork.graal.design.ui.view.UserStoriesView) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) UserStoryDialog(org.obeonetwork.graal.design.ui.dialog.UserStoryDialog) UserStory(org.obeonetwork.graal.UserStory) CompoundCommand(org.eclipse.emf.common.command.CompoundCommand)

Aggregations

UserStory (org.obeonetwork.graal.UserStory)10 EObject (org.eclipse.emf.ecore.EObject)3 EditingDomain (org.eclipse.emf.edit.domain.EditingDomain)3 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)3 UserStoriesView (org.obeonetwork.graal.design.ui.view.UserStoriesView)3 ArrayList (java.util.ArrayList)2 UserStoryDialog (org.obeonetwork.graal.design.ui.dialog.UserStoryDialog)2 Collection (java.util.Collection)1 Date (java.util.Date)1 State (org.eclipse.core.commands.State)1 Figure (org.eclipse.draw2d.Figure)1 IFigure (org.eclipse.draw2d.IFigure)1 CompoundCommand (org.eclipse.emf.common.command.CompoundCommand)1 Adapter (org.eclipse.emf.common.notify.Adapter)1 Notification (org.eclipse.emf.common.notify.Notification)1 AdapterImpl (org.eclipse.emf.common.notify.impl.AdapterImpl)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1