Skip to main content
summaryrefslogtreecommitdiffstats
blob: 9e507c734d105c39ca1cf13265fe5502bfdbb75a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*******************************************************************************
 * Copyright (c) 2010 BestSolution.at and others.
 * 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:
 *     Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
 ******************************************************************************/
package org.eclipse.e4.tools.emf.liveeditor;

import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
import org.eclipse.e4.ui.model.application.commands.MHandler;
import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;

public class ModelProcessor {
	
	@Execute
	public void process(MApplication application) {
		MCommand command = MCommandsFactory.INSTANCE.createCommand();
		command.setElementId("e4.tooling.livemodel");
		command.setCommandName("Show running app model");
		command.setDescription("Show the running application model");
		application.getCommands().add(command);
		
		MHandler handler = MCommandsFactory.INSTANCE.createHandler();
		handler.setContributionURI("platform:/plugin/org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.OpenLiveDialogHandler");
		handler.setCommand(command);
		application.getHandlers().add(handler);
		
		MKeyBinding binding = MCommandsFactory.INSTANCE.createKeyBinding();
		binding.setKeySequence("ALT+SHIFT+F9");
		binding.setCommand(command);
		if( application.getBindingTables().size() > 0 ) {
			application.getBindingTables().get(0).getBindings().add(binding);	
		}
		
		MPartDescriptor descriptor = org.eclipse.e4.ui.model.application.descriptor.basic.MBasicFactory.INSTANCE.createPartDescriptor();
		descriptor.setCategory("org.eclipse.e4.secondaryDataStack");
		descriptor.setElementId("org.eclipse.e4.tools.emf.liveeditor.view");
		descriptor.getTags().add("View");
		descriptor.getTags().add("categoryTag:General");
		
		descriptor.setLabel("Live Application Model");
		descriptor.setContributionURI("platform:/plugin/org.eclipse.e4.tools.emf.liveeditor/org.eclipse.e4.tools.emf.liveeditor.LivePartDelegator");
		descriptor.setContributorURI("platform:/plugin/org.eclipse.e4.tools.emf.liveeditor");
		descriptor.setIconURI("platform:/plugin/org.eclipse.e4.tools.emf.liveeditor/icons/full/obj16/application_lightning.png");
		application.getDescriptors().add(descriptor);
	}
}

Back to the top