Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4de500e544ca34f3eefbefb7b52a945c4fb0ec40 (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
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * 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
 *     Steven Spungin <steven@spungin.tv> - Bug 404136, Bug 424730
 ******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs;

import org.eclipse.core.resources.IProject;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.tools.emf.ui.internal.Messages;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.swt.widgets.Shell;

public abstract class AbstractIconDialog extends AbstractIconDialogWithScopeAndFilter {
	private IProject project;
	private MApplicationElement element;
	private EStructuralFeature feature;
	private EditingDomain editingDomain;
	// private Map<IFile, Image> icons = Collections.synchronizedMap(new
	// HashMap<IFile, Image>());

	protected Messages Messages;

	public AbstractIconDialog(Shell parentShell, IEclipseContext context, IProject project, EditingDomain editingDomain, MApplicationElement element, EStructuralFeature feature, Messages Messages) {
		super(parentShell, context);
		this.editingDomain = editingDomain;
		this.element = element;
		this.feature = feature;
		this.project = project;
		this.Messages = Messages;
		context.set(Messages.class, Messages);
	}

	@Override
	protected String getFilterTextMessage() {
		return "Type to start search";
	}

	@Override
	protected String getResourceNameText() {
		return "Icon Name";
	}

	@Override
	protected void okPressed() {
		super.okPressed();
		String uri = getValue();
		if (uri != null) {
			Command cmd = SetCommand.create(editingDomain, element, feature, uri);
			if (cmd.canExecute()) {
				editingDomain.getCommandStack().execute(cmd);
			}
		}
	}
}

Back to the top