001: /*
002: * Sun Public License Notice
003: *
004: * The contents of this file are subject to the Sun Public License
005: * Version 1.0 (the "License"). You may not use this file except in
006: * compliance with the License. A copy of the License is available at
007: * http://www.sun.com/
008: *
009: * The Original Code is NetBeans. The Initial Developer of the Original
010: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
011: * Microsystems, Inc. All Rights Reserved.
012: If you wish your version of this file to be governed by only the CDDL
013: or only the GPL Version 2, indicate your decision by adding
014: "[Contributor] elects to include this software in this distribution
015: under the [CDDL or GPL Version 2] license." If you do not indicate a
016: single choice of license, a recipient has the option to distribute
017: your version of this file under either the CDDL, the GPL Version 2 or
018: to extend the choice of license to its licensees as provided above.
019: However, if you add GPL Version 2 code and therefore, elected the GPL
020: Version 2 license, then the option applies only if the new code is
021: made subject to such option by the copyright holder.
022:
023: If you wish your version of this file to be governed by only the CDDL
024: or only the GPL Version 2, indicate your decision by adding
025: "[Contributor] elects to include this software in this distribution
026: under the [CDDL or GPL Version 2] license." If you do not indicate a
027: single choice of license, a recipient has the option to distribute
028: your version of this file under either the CDDL, the GPL Version 2 or
029: to extend the choice of license to its licensees as provided above.
030: However, if you add GPL Version 2 code and therefore, elected the GPL
031: Version 2 license, then the option applies only if the new code is
032: made subject to such option by the copyright holder.
033: */
034:
035: package org.netbeans.modules.etl.ui;
036:
037: import java.io.IOException;
038:
039: import net.java.hulp.i18n.Logger;
040: import org.netbeans.modules.etl.logger.Localizer;
041: import org.netbeans.modules.etl.logger.LogUtil;
042: import org.netbeans.modules.etl.ui.view.graph.actions.ConfigureParametersAction;
043: import org.openide.actions.CopyAction;
044: import org.openide.actions.CutAction;
045: import org.openide.actions.DeleteAction;
046: import org.openide.actions.FileSystemAction;
047: import org.openide.actions.OpenAction;
048: import org.openide.actions.PasteAction;
049: import org.openide.actions.RenameAction;
050: import org.openide.filesystems.FileObject;
051: import org.openide.loaders.DataObjectExistsException;
052: import org.openide.loaders.ExtensionList;
053: import org.openide.loaders.MultiDataObject;
054: import org.openide.loaders.UniFileLoader;
055: import org.openide.util.actions.SystemAction;
056:
057: /**
058: * Recognizes .etl files as a single DataObject.
059: *
060: * @author radval
061: */
062: public class ETLDataLoader extends UniFileLoader {
063: public static final String PROP_EXTENSIONS = "extensions"; // NOI18N
064: private static transient final Logger mLogger = LogUtil
065: .getLogger(ETLDataLoader.class.getName());
066: private static transient final Localizer mLoc = Localizer.get();
067:
068: // if we use text/*xml mime type then data editor support
069: // automatically recognize this mime type and show xml editor
070: // but there is another mime resolver registered with web svc module
071: // which has text/xml-wsdl as mime type and even though
072: // we install out wsdl editor data object before their data object
073: // it still picks mime resolver registered by web servc module
074: // so work around is to use same mime resovlver as websvc
075: // we need to ask them to disable mime resolver there-->
076:
077: public static final String MIME_TYPE = "text/x-etl+xml"; // NOI18N
078:
079: private static final long serialVersionUID = -4579746482156152493L;
080:
081: public ETLDataLoader() {
082: super ("org.netbeans.modules.etl.ui.ETLDataObject");// Fix for IllegalStateException when loading netbeans
083: //super("org.netbeans.modules.etl.ETLDataObject");
084: }
085:
086: /** Does initialization. Initializes display name,
087: * extension list and the actions. */
088: protected void initialize() {
089: super .initialize();
090: ExtensionList ext = getExtensions();
091: ext.addMimeType(MIME_TYPE);
092: }
093:
094: protected String defaultDisplayName() {
095: String nbBundle1 = mLoc.t("PRSR001: ETL Data Loader");
096: return Localizer.parse(nbBundle1);
097: }
098:
099: protected SystemAction[] defaultActions() {
100: return new SystemAction[] { SystemAction.get(OpenAction.class),
101: SystemAction.get(FileSystemAction.class), null, null,
102: SystemAction.get(CutAction.class),
103: SystemAction.get(CopyAction.class),
104: SystemAction.get(PasteAction.class), null,
105: SystemAction.get(DeleteAction.class),
106: SystemAction.get(RenameAction.class), null,
107: SystemAction.get(ConfigureParametersAction.class) };
108: }
109:
110: protected MultiDataObject createMultiObject(FileObject primaryFile)
111: throws DataObjectExistsException, IOException {
112: return new ETLDataObject(primaryFile, this);
113: }
114: }
|