/trunk/FAHView-v6project/src/main/java/com/googlecode/fahview/v6project/files/config/ConfigFileDataObject.java

https://gitlab.com/BGCX067/fahview-svn-to-git · Java · 149 lines · 102 code · 6 blank · 41 comment · 0 complexity · ba439d525b84d798bdcafb6fa6a52cce MD5 · raw file

  1. package com.googlecode.fahview.v6project.files.config;
  2. /*
  3. * #%L
  4. * This file is part of FAHView-v6project.
  5. * %%
  6. * Copyright (C) 2011 - 2013 Michael Thomas <mikepthomas@outlook.com>
  7. * %%
  8. * FAHView is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. * %
  13. * FAHView is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. * %
  18. * You should have received a copy of the GNU General Public License
  19. * along with FAHView. If not, see <http://www.gnu.org/licenses/>.
  20. * #L%
  21. */
  22. import java.io.IOException;
  23. import org.netbeans.core.spi.multiview.MultiViewElement;
  24. import org.netbeans.core.spi.multiview.text.MultiViewEditorElement;
  25. import org.openide.awt.ActionID;
  26. import org.openide.awt.ActionReference;
  27. import org.openide.awt.ActionReferences;
  28. import org.openide.filesystems.FileObject;
  29. import org.openide.filesystems.MIMEResolver;
  30. import org.openide.loaders.DataObject;
  31. import org.openide.loaders.DataObjectExistsException;
  32. import org.openide.loaders.MultiDataObject;
  33. import org.openide.loaders.MultiFileLoader;
  34. import org.openide.util.Lookup;
  35. import org.openide.util.NbBundle.Messages;
  36. import org.openide.windows.TopComponent;
  37. /**
  38. * <p>ConfigFileDataObject class.</p>
  39. *
  40. * @author <a href="mailto:mikepthomas@outlook.com">Michael Thomas</a>
  41. * @version $Id: $Id
  42. */
  43. @Messages({
  44. "LBL_ConfigFile_LOADER=Files of ConfigFile"
  45. })
  46. @MIMEResolver.ExtensionRegistration(
  47. displayName = "#LBL_ConfigFile_LOADER",
  48. mimeType = "text/x-fahconfig",
  49. extension = {"cfg", "CFG"},
  50. position = 100)
  51. @DataObject.Registration(
  52. mimeType = "text/x-fahconfig",
  53. iconBase = "com/googlecode/fahview/v6project/files/config/ConfigFile.png",
  54. displayName = "#LBL_ConfigFile_LOADER",
  55. position = 300)
  56. @ActionReferences({
  57. @ActionReference(
  58. path = "Loaders/text/x-fahconfig/Actions",
  59. id =
  60. @ActionID(category = "System", id = "org.openide.actions.OpenAction"),
  61. position = 100,
  62. separatorAfter = 200),
  63. @ActionReference(
  64. path = "Loaders/text/x-fahconfig/Actions",
  65. id =
  66. @ActionID(category = "Edit", id = "org.openide.actions.CutAction"),
  67. position = 300),
  68. @ActionReference(
  69. path = "Loaders/text/x-fahconfig/Actions",
  70. id =
  71. @ActionID(category = "Edit", id = "org.openide.actions.CopyAction"),
  72. position = 400,
  73. separatorAfter = 500),
  74. @ActionReference(
  75. path = "Loaders/text/x-fahconfig/Actions",
  76. id =
  77. @ActionID(category = "Edit", id = "org.openide.actions.DeleteAction"),
  78. position = 600),
  79. @ActionReference(
  80. path = "Loaders/text/x-fahconfig/Actions",
  81. id =
  82. @ActionID(category = "System", id = "org.openide.actions.RenameAction"),
  83. position = 700,
  84. separatorAfter = 800),
  85. @ActionReference(
  86. path = "Loaders/text/x-fahconfig/Actions",
  87. id =
  88. @ActionID(category = "System", id = "org.openide.actions.SaveAsTemplateAction"),
  89. position = 900,
  90. separatorAfter = 1000),
  91. @ActionReference(
  92. path = "Loaders/text/x-fahconfig/Actions",
  93. id =
  94. @ActionID(category = "System", id = "org.openide.actions.FileSystemAction"),
  95. position = 1100,
  96. separatorAfter = 1200),
  97. @ActionReference(
  98. path = "Loaders/text/x-fahconfig/Actions",
  99. id =
  100. @ActionID(category = "System", id = "org.openide.actions.ToolsAction"),
  101. position = 1300),
  102. @ActionReference(
  103. path = "Loaders/text/x-fahconfig/Actions",
  104. id =
  105. @ActionID(category = "System", id = "org.openide.actions.PropertiesAction"),
  106. position = 1400)
  107. })
  108. public class ConfigFileDataObject extends MultiDataObject {
  109. /**
  110. * <p>Constructor for ConfigFileDataObject.</p>
  111. *
  112. * @param pf a {@link org.openide.filesystems.FileObject} object.
  113. * @param loader a {@link org.openide.loaders.MultiFileLoader} object.
  114. * @throws org.openide.loaders.DataObjectExistsException if any.
  115. * @throws java.io.IOException if any.
  116. */
  117. public ConfigFileDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
  118. super(pf, loader);
  119. registerEditor("text/x-fahconfig", true);
  120. }
  121. /** {@inheritDoc} */
  122. @Override
  123. protected int associateLookup() {
  124. return 1;
  125. }
  126. /**
  127. * <p>createEditor.</p>
  128. *
  129. * @param lkp a {@link org.openide.util.Lookup} object.
  130. * @return a {@link org.netbeans.core.spi.multiview.text.MultiViewEditorElement} object.
  131. */
  132. @MultiViewElement.Registration(
  133. displayName = "#LBL_ConfigFile_EDITOR",
  134. iconBase = "com/googlecode/fahview/v6project/files/config/ConfigFile.png",
  135. mimeType = "text/x-fahconfig",
  136. persistenceType = TopComponent.PERSISTENCE_ONLY_OPENED,
  137. preferredID = "ConfigFile",
  138. position = 1000)
  139. @Messages("LBL_ConfigFile_EDITOR=Source")
  140. public static MultiViewEditorElement createEditor(Lookup lkp) {
  141. return new MultiViewEditorElement(lkp);
  142. }
  143. }