blob: 842f41ebaaf9db0293aa3be90179946879c2d8f2 [file] [log] [blame]
/**
********************************************************************************
* Copyright (c) 2021 Robert Bosch GmbH and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Robert Bosch GmbH - initial API and implementation
********************************************************************************
*/
package org.eclipse.app4mc.amalthea.model.editor.handler;
import javax.inject.Named;
import org.eclipse.app4mc.amalthea.model.editor.util.AmaltheaEditorUtil;
import org.eclipse.app4mc.amalthea.model.io.AmaltheaFileHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.e4.core.di.annotations.Evaluate;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
public class CompressedExpression {
@Evaluate
public boolean evaluate(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) IStructuredSelection selection) {
if (selection != null && !selection.isEmpty()
&& selection.size() == 1
&& selection.getFirstElement() instanceof IFile
&& AmaltheaFileHelper.isModelFileExtension(((IFile)selection.getFirstElement()).getFileExtension())) {
return AmaltheaEditorUtil.isZipFile((IFile) selection.getFirstElement());
}
return false;
}
}