Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.openide.util.Lookup;
import org.openide.util.actions.SystemAction;
import org.netbeans.modules.tomcat5.customizer.Customizer;
import org.netbeans.modules.tomcat5.ui.nodes.actions.EditContextXmlAction;
import org.netbeans.modules.tomcat5.ui.nodes.actions.SharedContextLogAction;
import org.netbeans.modules.tomcat5.ui.nodes.actions.EditServerXmlAction;
import org.netbeans.modules.tomcat5.ui.nodes.actions.OpenServerOutputAction;
Expand Down Expand Up @@ -94,14 +95,15 @@ public TomcatManager getTomcatManager() {

@Override
public javax.swing.Action[] getActions(boolean context) {
java.util.List actions = new LinkedList();
java.util.List<SystemAction> actions = new LinkedList<>();
// terminate does not work on Windows, see issue #63157
if (!Utilities.isWindows()) {
actions.add(null);
actions.add(SystemAction.get(TerminateAction.class));
}
actions.add(null);
actions.add(SystemAction.get(EditServerXmlAction.class));
actions.add(SystemAction.get(EditContextXmlAction.class));
if (tm.isTomcat50() || tm.isTomcat55()) {
actions.add(SystemAction.get(AdminConsoleAction.class));
}
Expand All @@ -112,15 +114,15 @@ public javax.swing.Action[] getActions(boolean context) {
actions.add(SystemAction.get(ServerLogAction.class));
}
actions.add(SystemAction.get(OpenServerOutputAction.class));
return (SystemAction[])actions.toArray(new SystemAction[0]);
return actions.toArray(new SystemAction[0]);
}

private FileObject getTomcatConf() {
tm.ensureCatalinaBaseReady(); // generated the catalina base folder if empty
TomcatProperties tp = tm.getTomcatProperties();
return FileUtil.toFileObject(tp.getServerXml());
}

/**
* Open server.xml file in editor.
*/
Expand All @@ -144,6 +146,35 @@ public void editServerXml() {
}
}

private FileObject getTomcatContextXml() {
tm.ensureCatalinaBaseReady(); // generated the catalina base folder if empty
TomcatProperties tp = tm.getTomcatProperties();
return FileUtil.toFileObject(tp.getContextXml());
}

/**
* Open context.xml file in editor.
*/
public void editContextXml() {
FileObject fileObject = getTomcatContextXml();
if (fileObject != null) {
DataObject dataObject = null;
try {
dataObject = DataObject.find(fileObject);
} catch (DataObjectNotFoundException ex) {
Logger.getLogger(TomcatInstanceNode.class.getName()).log(Level.INFO, null, ex);
}
if (dataObject != null) {
EditorCookie editorCookie = dataObject.getLookup().lookup(EditorCookie.class);
if (editorCookie != null) {
editorCookie.open();
} else {
Logger.getLogger(TomcatInstanceNode.class.getName()).log(Level.INFO, "Cannot find EditorCookie."); // NOI18N
}
}
}
}

/**
* Open the server log (output).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ LBL_TerminateAction=&Terminate
MSG_terminate=Do you really want to terminate the running {0} process?
LBL_AdminConsoleAction=View &Admin Console
LBL_ServerLogAction=View Server &Log
LBL_EditContextXmlAction=Edit context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.tomcat5.ui.nodes.actions;

import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.NodeAction;
import org.netbeans.modules.tomcat5.ui.nodes.TomcatInstanceNode;

/**
* Opens context.xml file in editor.
*/
public class EditContextXmlAction extends NodeAction {

@Override
protected boolean enable(Node[] nodes) {
return true;
}

@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}

@Override
public String getName() {
return NbBundle.getMessage(SharedContextLogAction.class, "LBL_EditContextXmlAction"); // NOI18N
}

@Override
protected boolean asynchronous() {
return false;
}

@Override
protected void performAction(Node[] nodes) {
for (int i = 0; i < nodes.length; i++) {
TomcatInstanceNode cookie = nodes[i].getLookup().lookup(TomcatInstanceNode.class);
if (cookie != null) {
cookie.editContextXml();
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,28 @@ public File getTomeeXml() {
}
return null;
}


/**
* Return context.xml file from the catalina base folder if the base folder
* is used or from the catalina home folder otherwise.
* <p>
* <b>BEWARE</b>: If the catalina base folder is used but has not bee
* generated yet, the context.xml file from the catalina home folder will be
* returned.
* </p>
*/
public File getContextXml() {
String confContextXml = "conf/context.xml"; // NIO18N
File contextXml = null;
if (baseDir != null) {
contextXml = new File(baseDir, confContextXml);
}
if (contextXml == null || !contextXml.exists()) {
contextXml = new File(getCatalinaHome(), confContextXml);
}
return contextXml;
}

public String getHost () {
String val = ip.getProperty(PROP_HOST);
return val != null ? val : DEF_VALUE_HOST;
Expand Down
Loading