package org.simantics.workbench.internal.contributions.e4; import javax.inject.Inject; import javax.inject.Named; import org.eclipse.e4.core.di.annotations.CanExecute; import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.ui.model.application.ui.basic.MPart; import org.eclipse.e4.ui.services.IServiceConstants; import org.eclipse.e4.ui.workbench.modeling.EPartService; public class ClosePartHandler { @Inject EPartService partService; @CanExecute public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) { if (activePart == null) return false; return activePart.isCloseable(); } @Execute public void closePart(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) { partService.hidePart(activePart); } }