Skip to content

Commit

Permalink
Merge pull request #847 from Mailaender/toolbar-visibility-icons
Browse files Browse the repository at this point in the history
Added icons to the toolbar visibility switches
  • Loading branch information
eselmeister authored Dec 15, 2021
2 parents 42dbf57 + 82693b2 commit a69ba42
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
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 @@ -9,6 +9,7 @@
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Christoph Läubrich - remove references to ModelAddon
* Matthias Mailänder - add a method to find descriptor and icon
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.ui.support;

Expand All @@ -19,6 +20,7 @@

import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
Expand Down Expand Up @@ -91,9 +93,9 @@ public class PartSupport {
//
private static final String COMPATIBILITY_EDITOR_ELEMENT_ID = "org.eclipse.e4.ui.compatibility.editor";
//
private static Set<String> hiddenPartStacks = new HashSet<String>();
private static Set<String> hiddenPartStacks = new HashSet<>();
//
private static Map<String, String> partMap = new HashMap<String, String>();
private static Map<String, String> partMap = new HashMap<>();
//
static {
hiddenPartStacks.add(PARTSTACK_LEFT_CENTER);
Expand Down Expand Up @@ -225,7 +227,7 @@ public static boolean isPartToBeRendered(String partId, EModelService modelServi
* @param partStackId
* @return boolean
*/
public static boolean togglePartVisibility(MPart part, String partStackId, EPartService partService) {
public static boolean togglePartVisibility(MPart part, EPartService partService) {

boolean isVisible = false;
if(part != null) {
Expand Down Expand Up @@ -357,6 +359,16 @@ public static void setPartVisibility(String partId, String partStackId, boolean
setPartVisibility(part, partService, visible);
}

public static String getIconURI(String partId, MApplication application) {

MPartDescriptor descriptor = getDescriptor(partId, application);
if(descriptor != null) {
return descriptor.getIconURI();
} else {
return "";
}
}

public static void setPartVisibility(MPart part, EPartService partService, boolean visible) {

if(part != null) {
Expand Down Expand Up @@ -426,7 +438,7 @@ public static boolean togglePartVisibility(String partId, String partStackId, EP
* Toggle visibility.
*/
MPart part = getPart(partId, partStackId, partService, modelService, application);
visible = togglePartVisibility(part, partStackId, partService);
visible = togglePartVisibility(part, partService);
}
//
return visible;
Expand All @@ -450,4 +462,14 @@ private static boolean is3xEditorPart(MPart mPart, String editorId) {

return mPart.getElementId().equals(COMPATIBILITY_EDITOR_ELEMENT_ID) && mPart.getTags().contains(editorId);
}

private static MPartDescriptor getDescriptor(String partId, MApplication application) {

for(MPartDescriptor descriptor : application.getDescriptors()) {
if(descriptor.getElementId().equals(partId)) {
return descriptor;
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<children xsi:type="menu:DirectToolItem" xmi:id="_MAcJ4EQOEeqZCItiXRBtNw" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.directtoolitem.lockzoom" label="Lock Zoom" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/zoomLocked.png" tooltip="Lock the Zoom level on the current view" type="Check" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.ChromatogramOverlayPart$LockZoomHandler"/>
</toolbar>
</elements>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_SV6Z0LMzEeeiidEQULk7vQ" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.headerDataPartDescriptor" label="Header Data" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/chromatogramOverviewDefault.gif" closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.HeaderDataPart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_SV6Z0LMzEeeiidEQULk7vQ" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.headerDataPartDescriptor" label="Header Data" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/header.gif" closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.HeaderDataPart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_S_s9sLMzEeeiidEQULk7vQ" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.chromatogramOverviewPartDescriptor" label="Chromatogram Overview" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/chromatogramOverviewDefault.gif" closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.ChromatogramOverviewPart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_he8RgLcwEeeUlJlQX6rCTQ" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.scanChartPartDescriptor" label="Scan Chart" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/selectedScansDefault.gif" tooltip="Show the selected scan , library entry or peak maximum as a chart." closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.ScanChartPart"/>
<elements xsi:type="basic_1:PartDescriptor" xmi:id="_UjRpoL-yEeeUeOZtwaWyDg" elementId="org.eclipse.chemclipse.ux.extension.xxd.ui.part.scanTablePartDescriptor" label="Scan Table" iconURI="platform:/plugin/org.eclipse.chemclipse.rcp.ui.icons/icons/16x16/ion.gif" tooltip="Show the selected scan , library entry or peak maximum as a table." closeable="true" contributionURI="bundleclass://org.eclipse.chemclipse.ux.extension.xxd.ui/org.eclipse.chemclipse.ux.extension.xxd.ui.parts.ScanTablePart"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 Lablicate GmbH.
* Copyright (c) 2020, 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
Expand All @@ -8,6 +8,7 @@
*
* Contributors:
* Philip Wenig - initial API and implementation
* Matthias Mailänder - set the part icon in the toolbar
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.toolbar;

Expand Down Expand Up @@ -58,6 +59,14 @@ public MApplication getApplication() {
return application != null ? application : ContextAddon.getApplication();
}

@Override
public String getIconURI() {

String partId = getPartStackReference().getPartId();
MApplication application = getApplication();
return PartSupport.getIconURI(partId, application);
}

@Evaluate
public boolean isVisible(IEclipseContext context) {

Expand Down

0 comments on commit a69ba42

Please sign in to comment.