Exemplo n.º 1
0
  public Object run(ExecutionEvent event) throws ExecutionException {

    DBSelection dbSel =
        event == null ? null : new DBSelection(HandlerUtil.getCurrentSelection(event));

    if (model == null) {
      ElementDBNode sel = dbSel.getSel();

      if (sel instanceof InstanceDBNode)
        model = addSibling ? ((InstanceDBNode) sel).getInstDB().modelRoot() : dbSel.getModel();
      else if (sel instanceof ModelDBNode) model = ((ModelDBNode) sel).model();
    }

    if (model == null) {
      ViewUtils.setErrorMessage("no model selected to add the instance to, request ignored");
      return null;
    }

    Shell activeShell = ViewUtils.getTopShellActivePage();

    if (!ToolsDesignLib.isEditable(model.getDb())) {
      MessageDialog.openError(
          activeShell,
          "Add model",
          "Attempting to add a new model to the library "
              + model.getDb().getName()
              + ". Only the work library is editable, all others are read-only");
      return null;
    }

    SelectionDialogModel dialog = new SelectionDialogModel(activeShell, model.techno());

    if (dialog.open() == Window.OK) {
      for (ModelDB m : dialog.getDataModel().getSelectedModels()) {
        DBJobParam param = new DBJobParam();
        param.setSrcModel(m);
        param.setDstModel(model);

        InstanceAddDBJob job = new InstanceAddDBJob(param);

        job.launch();
      }
    }
    model = null;

    return null;
  }
 @Override
 public void run() {
   ClonePadBundleDialog dialog = new ClonePadBundleDialog(ViewUtils.getTopShellActivePage());
   dialog.open();
 }