blob: 8cc0a692f38304ad0d937e98ff3447b2cdc586ed [file] [log] [blame]
/**
* Copyright (c) 2011, 2014 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.vaaclipse.addons.problems.handler;
import org.eclipse.e4.core.contexts.Active;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.MContext;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.menu.MItem;
import org.eclipse.osbp.vaaclipse.addons.problems.views.ProblemsView;
import org.eclipse.osbp.vaaclipse.addons.problems.views.ProblemsView.Mode;
/**
* The Class ShowAllMessagesHandler.
*/
public class ShowAllMessagesHandler {
/**
* Execute.
*
* @param context
* the context
* @param part
* the part
* @param item
* the item
*/
@Execute
public void execute(@Active MContext context, @Active MPart part,
@Active MItem item) {
ProblemsView view = (ProblemsView) part.getObject();
view.setMode(toMode(item));
}
/**
* To mode.
*
* @param item
* the item
* @return the mode
*/
private Mode toMode(MItem item) {
if (item.isSelected()) {
return Mode.SHOW_ALL;
} else {
return Mode.FOLLOW_ACTIVE_PART;
}
}
/**
* Can execute.
*
* @param item
* the item
* @return true, if successful
*/
@CanExecute
public boolean canExecute(@Active MItem item) {
return true;
}
}