PageRenderTime 43ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/java/com/google/code/p/keytooliui/shared/swing/panel/PEditorDefaultJar.java

http://keytool-iui.googlecode.com/
Java | 222 lines | 144 code | 52 blank | 26 comment | 17 complexity | 4e440c7981010c024c11d7c0cfbe9f5b MD5 | raw file
  1. /*
  2. *
  3. * Copyright (c) 2001-2011 keyTool IUI Project.
  4. * LGPL License.
  5. * http://code.google.com/p/keytool-iui/
  6. *
  7. *
  8. * You shall not disclose such confidential information and shall use it only in
  9. * accordance with the terms of keyTool IUI Project's license agreement.
  10. *
  11. * THE SOFTWARE IS PROVIDED AND LICENSED "AS IS" WITHOUT WARRANTY OF ANY KIND,
  12. * EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
  13. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * LICENSE FOR THE SOFTWARE DOES NOT INCLUDE ANY CONSIDERATION FOR ASSUMPTION OF RISK
  16. * BY KEYTOOL IUI PROJECT, AND KEYTOOL IUI PROJECT DISCLAIMS ANY AND ALL LIABILITY FOR INCIDENTAL
  17. * OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF OR INABILITY
  18. * TO USE THE SOFTWARE, EVEN IF KEYTOOL IUI PROJECT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  19. *
  20. */
  21. package com.google.code.p.keytooliui.shared.swing.panel;
  22. import com.google.code.p.keytooliui.shared.lang.*;
  23. import com.google.code.p.keytooliui.shared.awt.awtevent.*;
  24. import com.google.code.p.keytooliui.shared.awt.awteventmulticaster.*;
  25. import com.google.code.p.keytooliui.shared.util.eventlistener.*;
  26. import com.google.code.p.keytooliui.shared.swing.toolbar.*;
  27. import com.google.code.p.keytooliui.shared.swing.menubar.*;
  28. import com.google.code.p.keytooliui.shared.swing.scrollpane.*;
  29. import com.google.code.p.keytooliui.shared.io.*;
  30. import javax.swing.*;
  31. import java.awt.*;
  32. public final class PEditorDefaultJar extends PEditorAbstract
  33. {
  34. // ---------------------------
  35. // PRIVATE STATIC FINAL STRING
  36. private static final String _f_s_strClass = "com.google.code.p.keytooliui.shared.swing.panel.PEditorDefaultJar.";
  37. // ------
  38. // PUBLIC
  39. public boolean doFileOpen(byte[] bytsBuffer, String strPathRelative)
  40. throws Exception
  41. {
  42. String f_strMethod = "doFileOpen(bytsBuffer, strPathRelative)";
  43. if (! ((SPEditorDefaultJar)super._nsl_).doFileOpen(bytsBuffer))
  44. {
  45. MySystem.s_printOutError(this, f_strMethod, "failed");
  46. return false;
  47. }
  48. if (! super._ntl_.doFileOpen())
  49. {
  50. MySystem.s_printOutError(this, f_strMethod, "failed");
  51. return false;
  52. }
  53. if (! super._nbr_.doFileOpen())
  54. {
  55. MySystem.s_printOutError(this, f_strMethod, "failed");
  56. return false;
  57. }
  58. if (super._bar_ == null)
  59. {
  60. MySystem.s_printOutError(this, f_strMethod, "nil super._bar_");
  61. return false;
  62. }
  63. if (! ((PBarContainerPathAbstract)super._bar_).setPath(strPathRelative))
  64. {
  65. MySystem.s_printOutError(this, f_strMethod, "failed");
  66. return false;
  67. }
  68. if (! ((PBarContainerPathAbstract)super._bar_).setVisiblePath(true))
  69. {
  70. MySystem.s_printOutError(this, f_strMethod, "failed");
  71. return false;
  72. }
  73. setEnabled(true);
  74. return true;
  75. }
  76. public boolean doFileNew(String strPathRelative)
  77. throws Exception
  78. {
  79. String f_strMethod = "doFileNew(strPathRelative)";
  80. if (! super._nsl_.doFileNew())
  81. {
  82. MySystem.s_printOutError(this, f_strMethod, "failed");
  83. return false;
  84. }
  85. if (! super._ntl_.doFileNew())
  86. {
  87. MySystem.s_printOutError(this, f_strMethod, "failed");
  88. return false;
  89. }
  90. if (! super._nbr_.doFileNew())
  91. {
  92. MySystem.s_printOutError(this, f_strMethod, "failed");
  93. return false;
  94. }
  95. if (super._bar_ == null)
  96. {
  97. MySystem.s_printOutError(this, f_strMethod, "nil super._bar_");
  98. return false;
  99. }
  100. if (! ((PBarContainerPathAbstract)super._bar_).setPath(strPathRelative))
  101. {
  102. MySystem.s_printOutError(this, f_strMethod, "failed");
  103. return false;
  104. }
  105. if (! ((PBarContainerPathAbstract)super._bar_).setVisiblePath(true))
  106. {
  107. MySystem.s_printOutError(this, f_strMethod, "failed");
  108. return false;
  109. }
  110. setEnabled(true);
  111. return true;
  112. }
  113. public boolean writeTo(FileJar fjr, String strPathRelativeFile)
  114. throws Exception
  115. {
  116. return ((SPEditorDefaultJar)super._nsl_).writeTo(fjr, strPathRelativeFile);
  117. }
  118. public PEditorDefaultJar(
  119. PEditorAbstractListener pndListenerParent,
  120. Component cmpFrameOwner)
  121. {
  122. super(pndListenerParent, cmpFrameOwner);
  123. String f_strMethod = "PEditorDefaultJar(pndListenerParent, cmpFrameOwner)";
  124. // ----
  125. super._nsl_ = new SPEditorDefaultJar();
  126. if (! super._nsl_.init())
  127. {
  128. MySystem.s_printOutExit(this, f_strMethod, "failed");
  129. }
  130. // ----
  131. super._nbr_ = new MBEditorDefault(
  132. cmpFrameOwner,
  133. (java.awt.event.ActionListener) this,
  134. super._nfeListenerThis_);
  135. super._ntl_ = new TBEditorDefault((java.awt.event.ActionListener) this, super._ntlListenerThis_);
  136. super._bar_ = new PBarContainerPathRelative();
  137. }
  138. public void destroy()
  139. {
  140. super._destroy_();
  141. }
  142. public static void main(String[] args)
  143. {
  144. final String f_strWhere = _f_s_strClass + "main(strsArg)";
  145. try
  146. {
  147. JFrame frame = new JFrame();
  148. frame.getContentPane().setLayout(new BorderLayout());
  149. PEditorAbstract ntp = new PEditorDefaultJar(null, frame);
  150. if (! ntp.init())
  151. MySystem.s_printOutExit(f_strWhere, "failed");
  152. frame.getContentPane().add("Center", ntp);
  153. com.google.code.p.keytooliui.shared.awt.event.WindowCloser acr = new com.google.code.p.keytooliui.shared.awt.event.WindowCloser();
  154. frame.addWindowListener(acr);
  155. Toolkit.getDefaultToolkit().beep();
  156. frame.pack();
  157. int intPreferredW = frame.getPreferredSize().width;
  158. int intW = 400;
  159. if (intPreferredW < intW)
  160. intW = intPreferredW;
  161. frame.setSize(intW, 400);
  162. frame.setVisible(true);
  163. }
  164. catch (Exception exc)
  165. {
  166. exc.printStackTrace();
  167. MySystem.s_printOutExit(f_strWhere, "exc caught");
  168. }
  169. }
  170. }