示例#1
0
  @Override
  public void actionPerformed(ActionEvent e) {

    Object[] options = {"Cancel", "No!", "Ok"};
    int n =
        JOptionPane.showOptionDialog(
            Application.get(),
            "<html>Would you like to <b>delete</b> the selected data layer?",
            "Delete values from heatmap",
            JOptionPane.YES_NO_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE,
            null,
            options,
            options[2]);

    if (n == 1 | n == 0) {
      return;
    }

    AbstractCommand cmd =
        new AbstractCommand() {

          @Override
          public void execute(IProgressMonitor monitor) throws CommandException {

            getHeatmap().removeLayer(layer);
          }
        };

    JobThread.execute(Application.get(), cmd);
    Application.get().showNotification("Data layer deleted");
  }
示例#2
0
  public void show(boolean forceShow) {

    Properties tipProperties = Tips.get().getTips();

    TipOfTheDayModel loadedTips = TipLoader.load(tipProperties);

    final boolean settingsShowDialog = Settings.get().isShowTipsAtStartup();

    JXTipOfTheDay tipOfTheDay = new JXTipOfTheDay(loadedTips);

    Random generator = new Random();
    int i = generator.nextInt(loadedTips.getTipCount());
    tipOfTheDay.setCurrentTip(i);

    tipOfTheDay.showDialog(
        Application.get(),
        new JXTipOfTheDay.ShowOnStartupChoice() {
          @Override
          public void setShowingOnStartup(boolean showOnStartup) {
            Settings.get().setShowTipsAtStartup(showOnStartup);
          }

          @Override
          public boolean isShowingOnStartup() {
            return settingsShowDialog && !Settings.get().isProxyEnabled();
          }
        },
        forceShow);
  }
示例#3
0
  @Override
  public void execute(IProgressMonitor monitor) throws CommandException {
    super.execute(monitor);

    if (Application.get().getEditorsPanel().getSelectedEditor() instanceof HeatmapEditor) {
      final HeatmapEditor currentEditor =
          (HeatmapEditor) Application.get().getEditorsPanel().getSelectedEditor();

      if (saveAsFile != null) {
        currentEditor.doSaveAsNoUI(monitor, saveAsFile, discardHidden, optimize, false);
      } else if (save) {
        currentEditor.doSave(heatmap.getLocator(), monitor, false);
      }
      if (currentEditor.doClose(false)) {
        Application.get().getEditorsPanel().removeEditorNoUI(currentEditor);
      }
    }
  }
  @Override
  public void actionPerformed(ActionEvent e) {

    final EnsemblKeggModulesImporter importer = getImporter();
    final ModulesImportWizard wz = getWizard(importer);

    WizardDialog dlg = new WizardDialog(Application.get(), wz);
    dlg.open();

    if (dlg.isCancelled()) {
      return;
    }

    JobThread.execute(
        Application.get(),
        new JobRunnable() {
          @Override
          public void run(IProgressMonitor monitor) {
            try {
              Map<String, String> descriptions = new HashMap<>();
              IModuleMap mmap = importer.importMap(monitor, descriptions);
              if (!monitor.isCancelled()) {
                String extension = wz.getSaveFilePage().getFormat().getExtension();
                File file = wz.getSaveFilePage().getPathAsFile();
                IResourceLocator resourceLocator = new UrlResourceLocator(file);
                if (GmxModuleMapFormat.EXTENSION.equals(extension)
                    || GmtModuleMapFormat.EXTENSION.equals(extension)) {

                  IMatrix mat = MatrixUtils.moduleMapToMatrix(mmap);
                  IResourceFormat format =
                      ApplicationContext.getPersistenceManager()
                          .getFormat(extension, mat.getClass());
                  ApplicationContext.getPersistenceManager()
                      .store(resourceLocator, mat, format, monitor);
                } else {
                  IResourceFormat format =
                      ApplicationContext.getPersistenceManager()
                          .getFormat(extension, mmap.getClass());
                  ApplicationContext.getPersistenceManager()
                      .store(resourceLocator, mmap, format, monitor);
                }

                // TODO Use PersistenceManager
                String prefix = FilenameUtils.getName(file.getName());
                file = new File(file.getParentFile(), prefix + "_annotations.tsv");
                monitor.begin("Saving module annotations ...", mmap.getModules().size());
                PrintWriter pw = new PrintWriter(file);
                pw.println("id\tname");
                for (String module : mmap.getModules()) {
                  pw.print(module);
                  pw.print('\t');
                  pw.println(descriptions.get(module));
                  monitor.worked(1);
                }
                pw.close();
              } else {
                setStatus("Operation cancelled");
              }
            } catch (Throwable ex) {
              monitor.exception(ex);
            }
          }
        });
  }