blob: 54c183992d56b6b2bb1c09eeda89886d98d8b061 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.modules.docker.editor;
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.annotations.common.NonNull;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.MIMEResolver;
import org.openide.util.lookup.ServiceProvider;
/**
*
* @author Tomas Zezula
*/
@ActionReferences({
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "System", id = "org.openide.actions.OpenAction"),
position = 100,
separatorAfter = 200
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "Edit", id = "org.openide.actions.CutAction"),
position = 300
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "Edit", id = "org.openide.actions.CopyAction"),
position = 400
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "Edit", id = "org.openide.actions.PasteAction"),
position = 500,
separatorAfter = 600
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "Edit", id = "org.openide.actions.DeleteAction"),
position = 700
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "System", id = "org.openide.actions.RenameAction"),
position = 800,
separatorAfter = 900
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "System", id = "org.openide.actions.SaveAsTemplateAction"),
position = 1000,
separatorAfter = 1100
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "System", id = "org.openide.actions.FileSystemAction"),
position = 1200,
separatorAfter = 1300
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "System", id = "org.openide.actions.ToolsAction"),
position = 1400
),
@ActionReference(
path = "Loaders/text/x-dockerfile/Actions",
id = @ActionID(category = "System", id = "org.openide.actions.PropertiesAction"),
position = 1500
)
})
@ServiceProvider(service = MIMEResolver.class)
public final class DockerfileResolver extends MIMEResolver {
public static final String MIME_TYPE = "text/x-dockerfile"; //NOI18N
private static final String FILE_NAME = "dockerfile"; //NOI18N
public DockerfileResolver() {
super(MIME_TYPE);
}
@CheckForNull
@Override
public String findMIMEType(@NonNull final FileObject fo) {
final String ext = fo.getExt();
final String nameWithExt = fo.getNameExt().toLowerCase();
return FILE_NAME.equalsIgnoreCase(ext) || nameWithExt.startsWith(FILE_NAME)?
MIME_TYPE :
null;
}
}