Skip to main content
summaryrefslogtreecommitdiffstats
blob: baf26262325d3e6c1ec2aaa0a2d12ec63bf5a36c (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
/*******************************************************************************
 * Copyright (c) 2010 Oracle Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Oracle Corporation - initial API and implementation and/or initial documentation
 *******************************************************************************/
package org.eclipse.jst.pagedesigner.elementedit.html;

import java.util.LinkedHashMap;
import java.util.Map;

import org.eclipse.gef.commands.Command;
import org.eclipse.jface.action.Action;
import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants;
import org.eclipse.jst.pagedesigner.IHTMLConstants;
import org.eclipse.jst.pagedesigner.PDPlugin;
import org.eclipse.jst.pagedesigner.commands.single.AddSubNodeCommand;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;

/**
 */
public class InsertStylesheetLinkAction extends Action
{
	private IDOMElement _parentElement;

	/**
	 * @param parentElement 
	 */
	public InsertStylesheetLinkAction(IDOMElement parentElement) {
		setText(PDPlugin.getResourceString("HeadElementEdit.Submenu.InsertStylesheetLink"));//$NON-NLS-1$
		_parentElement = parentElement;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.action.IAction#run()
	 */
	public void run() {
		// TODO: figure out how to get the default attributes from
		// the tag create metadata. Get a tag creation provider?
		Map attributes = new LinkedHashMap();
		attributes.put("href", "");  //$NON-NLS-1$//$NON-NLS-2$
		attributes.put("rel", "Stylesheet");  //$NON-NLS-1$//$NON-NLS-2$
		attributes.put("type", "text/css");  //$NON-NLS-1$//$NON-NLS-2$
		Command command = new AddSubNodeCommand(
				PDPlugin.getResourceString("ItemCreationEditPolicy.CommandLabel.CreateItem"),//$NON-NLS-1$
				_parentElement, IHTMLConstants.TAG_LINK, ITLDConstants.URI_HTML,
				attributes);
		command.execute();
	}
}

Back to the top