コード例 #1
0
    /** Run function */
    public void run() {
      // Display the waiting item during the process instead of the compute button
      snake_.start();
      myCardLayout.show(cards, /*snake_.getName()*/ "snake");

      try {
        extractor_ = new SubnetExtractor((ImodNetwork) network_);
        if (extractAllRegulators_) {
          output_ = new Structure[1];
          output_[0] = extractor_.extractRegulators();
        } else if (seeds_ == null)
          output_ = extractor_.runExtraction(subnetRootName_.getText(), size_, numSubnets_);
        else output_ = extractor_.runExtraction(subnetRootName_.getText(), size_, seeds_);

        if (output_ != null) done();
        else log.info("Subnetwork extraction canceled !");
      } catch (final java.lang.OutOfMemoryError oome) {
        log.log(Level.SEVERE, oome.getMessage());
        SubnetExtraction.this.escapeAction();
        String title = "Memory Error";
        String msg =
            "Java doesn't have access to enough memory for the current operation.<br>"
                + "Large networks require a lot of memory, please increase the max heap<br>"
                + "size in your Java configuration. See the GeneNetWeaver documentation<br>"
                + "for details.";
        msg = "<html>" + msg + "</html>";
        JOptionPane.showMessageDialog(
            GnwGuiSettings.getInstance().getGnwGui().getFrame(),
            msg,
            title,
            JOptionPane.WARNING_MESSAGE);
      }
    }
コード例 #2
0
ファイル: MuPDFActivity.java プロジェクト: BrandonGk/Mupdf
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    mAlertBuilder = new AlertDialog.Builder(this);
    gAlertBuilder = mAlertBuilder; //  keep a static copy of this that other classes can use

    if (core == null) {
      core = (MuPDFCore) getLastNonConfigurationInstance();

      if (savedInstanceState != null && savedInstanceState.containsKey("FileName")) {
        mFileName = savedInstanceState.getString("FileName");
      }
    }
    if (core == null) {
      Intent intent = getIntent();
      byte buffer[] = null;

      if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        Uri uri = intent.getData();
        System.out.println("URI to open is: " + uri);
        if (uri.toString().startsWith("content://")) {
          String reason = null;
          try {
            InputStream is = getContentResolver().openInputStream(uri);
            int len = is.available();
            buffer = new byte[len];
            is.read(buffer, 0, len);
            is.close();
          } catch (java.lang.OutOfMemoryError e) {
            System.out.println("Out of memory during buffer reading");
            reason = e.toString();
          } catch (Exception e) {
            System.out.println("Exception reading from stream: " + e);

            // Handle view requests from the Transformer Prime's file manager
            // Hopefully other file managers will use this same scheme, if not
            // using explicit paths.
            // I'm hoping that this case below is no longer needed...but it's
            // hard to test as the file manager seems to have changed in 4.x.
            try {
              Cursor cursor =
                  getContentResolver().query(uri, new String[] {"_data"}, null, null, null);
              if (cursor.moveToFirst()) {
                String str = cursor.getString(0);
                if (str == null) {
                  reason = "Couldn't parse data in intent";
                } else {
                  uri = Uri.parse(str);
                }
              }
            } catch (Exception e2) {
              System.out.println("Exception in Transformer Prime file manager code: " + e2);
              reason = e2.toString();
            }
          }
          if (reason != null) {
            buffer = null;
            Resources res = getResources();
            AlertDialog alert = mAlertBuilder.create();
            setTitle(String.format(res.getString(R.string.cannot_open_document_Reason), reason));
            alert.setButton(
                AlertDialog.BUTTON_POSITIVE,
                getString(R.string.dismiss),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    finish();
                  }
                });
            alert.show();
            return;
          }
        }
        if (buffer != null) {
          core = openBuffer(buffer, intent.getType());
        } else {
          String path = Uri.decode(uri.getEncodedPath());
          if (path == null) {
            path = uri.toString();
          }
          core = openFile(path);
        }
        SearchTaskResult.set(null);
      }
      if (core != null && core.needsPassword()) {
        requestPassword(savedInstanceState);
        return;
      }
      if (core != null && core.countPages() == 0) {
        core = null;
      }
    }
    if (core == null) {
      AlertDialog alert = mAlertBuilder.create();
      alert.setTitle(R.string.cannot_open_document);
      alert.setButton(
          AlertDialog.BUTTON_POSITIVE,
          getString(R.string.dismiss),
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              finish();
            }
          });
      alert.setOnCancelListener(
          new OnCancelListener() {

            @Override
            public void onCancel(DialogInterface dialog) {
              finish();
            }
          });
      alert.show();
      return;
    }

    createUI(savedInstanceState);

    //  hide the proof button if this file can't be proofed
    if (!core.canProof()) {
      mProofButton.setVisibility(View.INVISIBLE);
    }

    if (isProofing()) {

      //  start the activity with a new array
      mSepEnabled = null;

      //  show the separations button
      mSepsButton.setVisibility(View.VISIBLE);

      //  hide some other buttons
      mLinkButton.setVisibility(View.INVISIBLE);
      mReflowButton.setVisibility(View.INVISIBLE);
      mOutlineButton.setVisibility(View.INVISIBLE);
      mSearchButton.setVisibility(View.INVISIBLE);
      mMoreButton.setVisibility(View.INVISIBLE);
    } else {
      //  hide the separations button
      mSepsButton.setVisibility(View.INVISIBLE);
    }
  }