2020-03-21 11:30:30 +01:00
|
|
|
|
|
|
|
package com.minres.scviewer.e4.application.handlers;
|
|
|
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
2020-03-25 23:01:28 +01:00
|
|
|
import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
2020-03-21 11:30:30 +01:00
|
|
|
import org.eclipse.e4.core.contexts.Active;
|
|
|
|
import org.eclipse.e4.core.di.annotations.Execute;
|
|
|
|
import org.eclipse.e4.ui.model.application.MApplication;
|
|
|
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
|
|
|
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
|
|
|
|
import org.eclipse.e4.ui.model.application.ui.menu.MHandledItem;
|
|
|
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
2020-03-25 23:01:28 +01:00
|
|
|
import org.eclipse.jface.preference.IPreferenceStore;
|
2020-03-21 11:30:30 +01:00
|
|
|
|
|
|
|
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
2020-03-25 23:01:28 +01:00
|
|
|
import com.opcoach.e4.preferences.ScopedPreferenceStore;
|
2020-03-21 11:30:30 +01:00
|
|
|
|
|
|
|
public class EnableHover {
|
|
|
|
static final String TAG_NAME = "EnableHover"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
MApplication application;
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
public void initialize(EModelService modelService) {
|
|
|
|
List<String> tags = new LinkedList<>();
|
|
|
|
tags.add(TAG_NAME);
|
|
|
|
List<MHandledItem> elements = modelService.findElements(application, null, MHandledItem.class, tags );
|
|
|
|
// cover initialization stuff, sync it with code
|
2020-03-25 23:01:28 +01:00
|
|
|
IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
|
|
|
boolean state = store.getBoolean(PreferenceConstants.SHOW_HOVER);
|
2020-03-21 11:30:30 +01:00
|
|
|
for( MHandledItem hi : elements ){
|
2020-03-25 23:01:28 +01:00
|
|
|
hi.setSelected(state);
|
2020-03-21 11:30:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Execute
|
|
|
|
public void execute(@Active MPart part, @Active MWindow window, MHandledItem handledItem, EModelService modelService ) {
|
2020-03-25 23:01:28 +01:00
|
|
|
IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
|
|
|
store.setValue(PreferenceConstants.SHOW_HOVER, handledItem.isSelected());
|
2020-03-21 11:30:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|