예제 #1
0
 private JButton createRemoveButton(final Datastore datastore) {
   final String name = datastore.getName();
   final JButton removeButton = WidgetFactory.createSmallButton(IconUtils.ACTION_REMOVE);
   removeButton.setToolTipText("Remove datastore");
   removeButton.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           int result =
               JOptionPane.showConfirmDialog(
                   DatastorePanel.this,
                   "Are you sure you wish to remove the datastore '" + name + "'?",
                   "Confirm remove",
                   JOptionPane.YES_NO_OPTION);
           if (result == JOptionPane.YES_OPTION) {
             _datastoreCatalog.removeDatastore(datastore);
           }
         }
       });
   if (!_datastoreCatalog.isDatastoreMutable(name)) {
     removeButton.setEnabled(false);
   }
   return removeButton;
 }
예제 #2
0
  private JButton createEditButton(final Datastore datastore) {
    final JButton editButton = WidgetFactory.createSmallButton("images/actions/edit.png");
    editButton.setToolTipText("Edit datastore");

    if (datastore instanceof JdbcDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injectorWithDatastore =
                  _injectorBuilder.with(JdbcDatastore.class, datastore).createInjector();
              JdbcDatastoreDialog dialog =
                  injectorWithDatastore.getInstance(JdbcDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof CsvDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(CsvDatastore.class, datastore).createInjector();
              CsvDatastoreDialog dialog = injector.getInstance(CsvDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof AccessDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(AccessDatastore.class, datastore).createInjector();
              AccessDatastoreDialog dialog = injector.getInstance(AccessDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof ExcelDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(ExcelDatastore.class, datastore).createInjector();
              ExcelDatastoreDialog dialog = injector.getInstance(ExcelDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof SasDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(SasDatastore.class, datastore).createInjector();
              SasDatastoreDialog dialog = injector.getInstance(SasDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof XmlDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(XmlDatastore.class, datastore).createInjector();
              XmlDatastoreDialog dialog = injector.getInstance(XmlDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof OdbDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(OdbDatastore.class, datastore).createInjector();
              OdbDatastoreDialog dialog = injector.getInstance(OdbDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof FixedWidthDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(FixedWidthDatastore.class, datastore).createInjector();
              FixedWidthDatastoreDialog dialog =
                  injector.getInstance(FixedWidthDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof DbaseDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(DbaseDatastore.class, datastore).createInjector();
              DbaseDatastoreDialog dialog = injector.getInstance(DbaseDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof CouchDbDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(CouchDbDatastore.class, datastore).createInjector();
              CouchDbDatastoreDialog dialog = injector.getInstance(CouchDbDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof MongoDbDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(MongoDbDatastore.class, datastore).createInjector();
              MongoDbDatastoreDialog dialog = injector.getInstance(MongoDbDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof SalesforceDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(SalesforceDatastore.class, datastore).createInjector();
              SalesforceDatastoreDialog dialog =
                  injector.getInstance(SalesforceDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof SugarCrmDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              Injector injector =
                  _injectorBuilder.with(SugarCrmDatastore.class, datastore).createInjector();
              SugarCrmDatastoreDialog dialog = injector.getInstance(SugarCrmDatastoreDialog.class);
              dialog.open();
            }
          });
    } else if (datastore instanceof CompositeDatastore) {
      editButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              CompositeDatastoreDialog dialog =
                  new CompositeDatastoreDialog(
                      (CompositeDatastore) datastore, _datastoreCatalog, _windowContext);
              dialog.open();
            }
          });
    } else {
      editButton.setEnabled(false);
    }

    if (!_datastoreCatalog.isDatastoreMutable(datastore.getName())) {
      editButton.setEnabled(false);
    }

    return editButton;
  }