Skip to content

Commit

Permalink
Merge pull request #600 from Mailaender/file-close
Browse files Browse the repository at this point in the history
Added Close and Close All to the file menu
  • Loading branch information
eselmeister authored May 19, 2021
2 parents 491c48a + c65b52d commit 31695a3
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
<children xsi:type="menu:MenuSeparator" xmi:id="_08BOgL7lEeKcwbn54SGPtA" elementId="org.eclipse.chemclipse.rcp.app.ui.menuseparator.1"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_q2y48EaqEeKL9t3RgmYB_g" elementId="org.eclipse.chemclipse.rcp.app.ui.menu.item.import" label="Import" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/import.png" command="_w-HcgEaqEeKL9t3RgmYB_g"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_tZ1dcEaqEeKL9t3RgmYB_g" elementId="org.eclipse.chemclipse.rcp.app.ui.menu.item.export" label="Export" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/export.png" command="_zmfM8EaqEeKL9t3RgmYB_g"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_oiu1oLiaEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.rcp.app.ui.menuseparator.2"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_pliscEaqEeKL9t3RgmYB_g" elementId="org.eclipse.chemclipse.rcp.app.ui.menuseparator.file.2"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_KMcBILfgEeuq4LYKjrje2g" elementId="org.eclipse.chemclipse.rcp.app.ui.menuseparator.file.3"/>
<children xsi:type="menu:MenuSeparator" xmi:id="_ky5jULiZEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.rcp.app.ui.menuseparator.file.4"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_h0BcRTLzEeKMEOdllHiEaA" elementId="org.eclipse.chemclipse.rcp.app.ui.menu.item.quit" label="Quit" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/quit.gif" command="_h0A1OjLzEeKMEOdllHiEaA"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_QrQhQDiVEeKDEdWQrkwLnQ" elementId="org.eclipse.chemclipse.rcp.app.ui.menu.plugins" label="Plug-ins">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<elements xsi:type="commands:Command" xmi:id="_x1FVQFxCEeOAeeYL1z-yzQ" elementId="org.eclipse.chemclipse.ux.extension.ui.command.nextChromatogram" commandName="Next Chromatogram"/>
<elements xsi:type="commands:Command" xmi:id="_F7hAgENOEeaHxO-Ahlk0cA" elementId="org.eclipse.chemclipse.ux.extension.ui.command.infoSpectra" commandName="Info Spectra"/>
<elements xsi:type="commands:Command" xmi:id="_JZm4AENOEeaHxO-Ahlk0cA" elementId="org.eclipse.chemclipse.ux.extension.ui.command.infoControls" commandName="Info Controls"/>
<elements xsi:type="commands:Command" xmi:id="_pJXCsLiYEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.ux.extension.ui.command.closeall" commandName="Close All"/>
<elements xsi:type="commands:Command" xmi:id="_4lggQLibEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.ux.extension.ui.command.close" commandName="Close"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_gmcSADL3EeKMEOdllHiEaA" featurename="handlers" parentElementId="org.eclipse.chemclipse.rcp.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_lUw1UDhoEeKHL-DfrT7KNQ" elementId="org.eclipse.chemclipse.ux.extension.ui.handler.createSnapshot" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.ui/org.eclipse.chemclipse.ux.extension.ui.handlers.CreateSnapshotHandler" command="_hheJ4DhoEeKHL-DfrT7KNQ"/>
Expand All @@ -16,6 +18,8 @@
<elements xsi:type="commands:Handler" xmi:id="_5k-ZIFxCEeOAeeYL1z-yzQ" elementId="org.eclipse.chemclipse.ux.extension.ui.handler.nextChromatogram" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.ui/org.eclipse.chemclipse.ux.extension.ui.handlers.NextChromatogramHandler" command="_x1FVQFxCEeOAeeYL1z-yzQ"/>
<elements xsi:type="commands:Handler" xmi:id="_MpzdcENOEeaHxO-Ahlk0cA" elementId="org.eclipse.chemclipse.ux.extension.ui.handler.infoSpectra" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.ui/org.eclipse.chemclipse.ux.extension.ui.handlers.InfoSpectraHandler" command="_F7hAgENOEeaHxO-Ahlk0cA"/>
<elements xsi:type="commands:Handler" xmi:id="_NPzGcENOEeaHxO-Ahlk0cA" elementId="org.eclipse.chemclipse.ux.extension.ui.handler.infoControls" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.ui/org.eclipse.chemclipse.ux.extension.ui.handlers.InfoControlsHandler" command="_JZm4AENOEeaHxO-Ahlk0cA"/>
<elements xsi:type="commands:Handler" xmi:id="_t_ZkkLiYEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.ux.extension.ui.handler.closeall" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.ui/org.eclipse.chemclipse.ux.extension.ui.handlers.CloseAllHandler" command="_pJXCsLiYEeu05KeOzWexnw"/>
<elements xsi:type="commands:Handler" xmi:id="_6Y7lsLibEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.ux.extension.ui.handler.close" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.ui/org.eclipse.chemclipse.ux.extension.ui.handlers.CloseHandler" command="_4lggQLibEeu05KeOzWexnw"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_yuL6gDL3EeKMEOdllHiEaA" featurename="children" parentElementId="org.eclipse.chemclipse.rcp.app.ui.menu.main" positionInList="after:org.eclipse.chemclipse.rcp.app.ui.menu.file">
<elements xsi:type="menu:Menu" xmi:id="_QKMFgDL4EeKMEOdllHiEaA" elementId="org.eclipse.chemclipse.ux.extension.ui.menu" label="Chromatogram">
Expand Down Expand Up @@ -87,4 +91,8 @@
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_9O66YK1-EeeOj_frlqyeaw" featurename="children" parentElementId="org.eclipse.chemclipse.rcp.app.ui.menu.main" positionInList="after:org.eclipse.chemclipse.ux.extension.ui.menu">
<elements xsi:type="menu:Menu" xmi:id="_9qTloDL-EeKMEOdllHiEaA" elementId="org.eclipse.chemclipse.ux.extension.ui.menu.process" label="Processors"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_QC5CoLiaEeu05KeOzWexnw" featurename="children" parentElementId="org.eclipse.chemclipse.rcp.app.ui.menu.file" positionInList="after:org.eclipse.chemclipse.rcp.app.ui.menuseparator.2">
<elements xsi:type="menu:HandledMenuItem" xmi:id="_9FhHwLibEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.ux.extension.ui.handledmenuitem.closeall" label="Close All" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/close_all.png" command="_pJXCsLiYEeu05KeOzWexnw"/>
<elements xsi:type="menu:HandledMenuItem" xmi:id="_juofYLiYEeu05KeOzWexnw" elementId="org.eclipse.chemclipse.ux.extension.ui.handledmenuitem.close" label="Close" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/close.png" command="_4lggQLibEeu05KeOzWexnw"/>
</fragments>
</fragment:ModelFragments>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2021 Lablicate GmbH.
*
* 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:
* Matthias Mailänder - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.ui.handlers;

import org.eclipse.chemclipse.ux.extension.ui.editors.IChemClipseEditor;
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.workbench.modeling.EPartService;

public class CloseAllHandler {

@CanExecute
boolean canExecute(EPartService partService) {

for(MPart part : partService.getParts()) {
if(part.getObject() instanceof IChemClipseEditor) {
return true;
}
}
return false;
}

@Execute
void execute(EPartService partService) {

for(MPart part : partService.getParts()) {
if(part.getObject() instanceof IChemClipseEditor) {
partService.hidePart(part, true);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2021 Lablicate GmbH.
*
* 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:
* Matthias Mailänder - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.ui.handlers;

import javax.inject.Named;

import org.eclipse.chemclipse.ux.extension.ui.editors.IChemClipseEditor;
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 CloseHandler {

@CanExecute
boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart part) {

if(part != null) {
if(part.getObject() instanceof IChemClipseEditor) {
return true;
}
}
return false;
}

@Execute
void execute(EPartService partService, @Named(IServiceConstants.ACTIVE_PART) MPart part) {

if(part != null) {
Object object = part.getObject();
if(object != null) {
if(object instanceof IChemClipseEditor) {
partService.hidePart(part, true);
}
}
}
}
}

0 comments on commit 31695a3

Please sign in to comment.