1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package org.openoffice.netbeans.modules.office.actions; 25 26 import org.openide.nodes.Node; 27 import org.openide.util.HelpCtx; 28 import org.openide.util.RequestProcessor; 29 import org.openide.util.actions.CookieAction; 30 31 /** 32 * 33 * @author adams 34 * @version 1.0 35 */ 36 public class MountDocumentAction extends CookieAction 37 { MountDocumentAction()38 public MountDocumentAction() 39 { 40 } 41 getName()42 public java.lang.String getName() 43 { 44 return "Mount Document"; //NOI18N 45 } 46 getHelpCtx()47 public HelpCtx getHelpCtx() 48 { 49 return HelpCtx.DEFAULT_HELP; 50 } 51 mode()52 protected int mode() 53 { 54 // enable duplication for as many qualifying nodes as are selected: 55 return CookieAction.MODE_ALL; 56 } 57 cookieClasses()58 protected java.lang.Class[] cookieClasses() 59 { 60 // just the DuplicateCookie: 61 return new Class[] {OfficeDocumentCookie.class}; 62 } 63 performAction(final Node[] activatedNodes)64 protected void performAction(final Node[] activatedNodes) 65 { 66 RequestProcessor.getDefault().post(new Runnable() 67 { 68 public void run() 69 { 70 for (int i=0; i<activatedNodes.length; i++) 71 { 72 OfficeDocumentCookie cookie = (OfficeDocumentCookie)activatedNodes[i].getCookie(OfficeDocumentCookie.class); 73 if (cookie != null) 74 { 75 cookie.mount(); 76 } 77 } 78 } 79 }); 80 } 81 } 82