/** @see com.ixora.rms.ui.artefacts.ArtefactSelectorPanel#handleRemoveArtefact() */
 protected void handleRemoveArtefact() {
   try {
     JTable table = getJTableArtefacts();
     int[] sel = table.getSelectedRows();
     if (Utils.isEmptyArray(sel)) {
       return;
     }
     for (int idx : sel) {
       DashboardInfo gi = (DashboardInfo) table.getModel().getValueAt(idx, 1);
       DashboardMap map = fDashboardRepository.getDashboardMap(fContext);
       if (map == null) {
         logger.error("Couldn't find query gruop map for context: " + this.fContext);
         return;
       }
       // ask for confitmation
       if (!UIUtils.getBooleanOkCancelInput(
           this.fViewContainer.getAppFrame(),
           MessageRepository.get(Msg.TITLE_CONFIRM_REMOVE_DASHBOARD),
           MessageRepository.get(
               Msg.TEXT_CONFIRM_REMOVE_DASHBOARD, new String[] {gi.getTranslatedName()}))) {
         return;
       }
       // remove the dashboard only for the current fSUOVersion
       map.remove(gi.getDashboard().getName(), fSUOVersion);
       fDashboardRepository.setDashboardMap(fContext, map);
       fDashboardRepository.save();
       // update model
       fSessionData.getDashboardHelper().removeDashboard(fContext, gi.getDashboard().getName());
       // refresh table model
       refreshTableModel();
     }
   } catch (Exception ex) {
     UIExceptionMgr.userException(ex);
   }
 }
예제 #2
0
 /** @see java.lang.Throwable#getLocalizedMessage() */
 public String getLocalizedMessage() {
   // TODO localize
   String caused =
       getCause() != null && this != getCause()
           ? " Caused by: " + getCause().getLocalizedMessage()
           : "";
   String returned = null;
   if (this.messageKey == null) {
     returned = getMessage();
   } else {
     if (this.messageTokens == null) {
       if (this.component == null) {
         returned = MessageRepository.get(this.messageKey);
       } else {
         returned = MessageRepository.get(this.component, this.messageKey);
       }
     } else {
       if (this.component == null) {
         returned = MessageRepository.get(this.messageKey, this.messageTokens);
       } else {
         returned = MessageRepository.get(this.component, this.messageKey, this.messageTokens);
       }
     }
   }
   return returned + caused;
 }
예제 #3
0
  /** Initializes this dialog. */
  private void initialize() {
    this.fPadding = 0;
    this.eventHandler = new EventHandler();
    setTitle(MessageRepository.get(Msg.COMMON_UI_TEXT_ABOUT));
    setPreferredSize(new Dimension(396, 570));
    htmlPane = UIFactoryMgr.createHtmlPane();
    htmlPane.addHyperlinkListener(this.eventHandler);

    // fill in the table with deployment modules and their versions
    StringBuffer components = new StringBuffer(100);
    Module[] modules = UpdateMgr.getAllRegisteredModules();
    if (modules != null) {
      components.append("<br>");
      for (int i = 0; i < modules.length; i++) {
        Module module = modules[i];
        components.append(module.getName());
        components.append("(");
        components.append(module.getVersion());
        components.append(")");
        if (i != modules.length - 1) {
          components.append(", ");
        }
      }
    }
    StringBuffer jvm = new StringBuffer();
    jvm.append(System.getProperty("java.vendor"))
        .append(" ")
        .append(System.getProperty("java.version"));
    StringBuffer os = new StringBuffer();
    os.append(System.getProperty("os.name")).append(" ").append(System.getProperty("os.version"));

    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    int year = cal.get(Calendar.YEAR);

    htmlPane.setText(
        MessageRepository.get(
            Msg.COMMON_UI_TEXT_ABOUT_DOCUMENT,
            new String[] {
              Product.getProductInfo().getVersion().toString(), // version
              String.valueOf(year), // year
              components.toString(), //  components
              jvm.toString(), // JVM
              os.toString()
            })); // OS
    htmlPane.setBorder(null);
    buildContentPane();
  }
  /** @see com.ixora.rms.ui.artefacts.ArtefactSelectorPanel#handlePlotArtefact() */
  protected void handlePlotArtefact() {
    try {
      final JTable table = getJTableArtefacts();
      final int[] sel = table.getSelectedRows();
      if (Utils.isEmptyArray(sel)) {
        return;
      }

      this.fViewContainer
          .getAppWorker()
          .runJobSynch(
              new UIWorkerJobDefault(
                  fViewContainer.getAppFrame(),
                  Cursor.WAIT_CURSOR,
                  MessageRepository.get(Msg.TEXT_PLOTTING_DASHBOARD)) {
                public void work() throws Exception {
                  for (int idx : sel) {
                    DashboardInfo di = (DashboardInfo) table.getModel().getValueAt(idx, 1);

                    Dashboard dtls = di.getDashboard();
                    if (dtls == null) {
                      logger.error("No dashboard");
                      return;
                    }

                    DataViewId[] members = dtls.getViews();
                    ResourceId[] counters = dtls.getCounters();
                    if (Utils.isEmptyArray(members) && Utils.isEmptyArray(counters)) {
                      // TODO localize
                      throw new RMSException(
                          "Dashboard " + di.getTranslatedName() + " has no data views.");
                    }

                    if (!di.getFlag(DataViewInfo.ENABLED) && di.isCommitted()) {
                      // enable it first
                      ((DashboardTableModel) fTableModelArtefacts).enableDashboard(idx);
                      applyChangesLocally();
                    }

                    callback.plot(new DashboardId(fContext, dtls.getName()));
                  }
                }

                public void finished(Throwable ex) {
                  ; // nothing, synched job
                }
              });
    } catch (Exception ex) {
      UIExceptionMgr.userException(ex);
    }
  }
  /**
   * @param logName
   * @param scanEndCallback
   */
  private void runScanJob(final String logName, final ScanEndCallback scanEndCallback) {
    fViewContainer
        .getAppWorker()
        .runJob(
            new UIWorkerJobDefaultCancelable(
                this, Cursor.WAIT_CURSOR, MessageRepository.get(Msg.TEXT_SCANNING_LOG)) {
              private DataLogScanningService.ScanListener listener =
                  new DataLogScanningService.ScanListener() {
                    public void fatalScanError(LogRepositoryInfo rep, Exception e) {
                      wakeUp();
                    }

                    public void finishedScanningLog(LogRepositoryInfo rep, BoundedTimeInterval ti) {
                      handleFinishedScanning(rep, ti);
                      wakeUp();
                    }

                    public void newAgent(LogRepositoryInfo rep, HostId host, AgentDescriptor ad) {}

                    public void newEntity(
                        LogRepositoryInfo rep, HostId host, AgentId aid, EntityDescriptor ed) {}
                  };

              public void cancel() {
                super.cancel();
                try {
                  fScanningService.stopScanning();
                } catch (DataLogException e) {
                  UIExceptionMgr.userException(e);
                }
              }

              public void work() throws Throwable {
                fScanningService.addScanListener(listener);
                fScanningService.startScanning(new LogRepositoryInfo(fRepositoryType, logName));
                hold();
              }

              public void finished(Throwable ex) {
                fScanningService.removeScanListener(listener);
                if (!canceled()) {
                  scanEndCallback.finishedScanning(ex);
                }
              }
            });
  }
  /** Applies only changes made to the current context. */
  private void applyChangesLocally() {
    // get all dashboards  to realize
    Collection<DashboardInfo> dashboards = getDashboardTableModel().getDashboardsToRealize();
    if (dashboards != null) {
      for (DashboardInfo dinfo : dashboards) {
        // register views with the query realizer
        DataViewId[] views = dinfo.getDashboard().getViews();
        if (!Utils.isEmptyArray(views)) {
          for (DataViewId view : views) {
            if (fContext != null) {
              view = view.complete(fContext);
            }
            // ask the locator for info on the required data view
            final SessionDataViewInfo dvInfo = this.fArtefactInfoLocator.getDataViewInfo(view);
            if (dvInfo == null) {
              if (logger.isTraceEnabled()) {
                logger.error("Couldn't find data view info for: " + view + ". Skipping...");
              }
              continue;
            }
            final DataViewId fv = view;
            // Note: this method is reading from the session model
            // and as a result it can only be used safely from
            // the event dispatching thread
            this.fViewContainer
                .getAppWorker()
                .runJobSynch(
                    new UIWorkerJobDefault(
                        fViewContainer.getAppFrame(),
                        Cursor.WAIT_CURSOR,
                        MessageRepository.get(
                            Msg.TEXT_REALIZING_DATAVIEW,
                            new String[] {dvInfo.getTranslatedName()})) {
                      public void work() throws Exception {
                        fQueryRealizer.realizeQuery(
                            fv.getContext(),
                            dvInfo.getDataView().getQueryDef(),
                            new QueryRealizer.Callback() {
                              public boolean acceptIncreaseInMonitoringLevel(
                                  List<ResourceInfo> counters) {
                                boolean ret =
                                    UIUtils.getBooleanYesNoInput(
                                        fViewContainer.getAppFrame(),
                                        MessageRepository.get(
                                            Msg.TITLE_CONFIRM_MONITORING_LEVEL_INCREASE),
                                        MessageRepository.get(
                                            Msg
                                                .TEXT_CONFIRM_MONITORING_LEVEL_INCREASE_FOR_DATA_VIEW,
                                            new String[] {dvInfo.getTranslatedName()}));
                                if (!ret) {
                                  // undo changes
                                  fSessionData
                                      .getDataViewHelper()
                                      .rollbackDataView(fv.getContext(), fv.getName());
                                }
                                return ret;
                              }
                            });
                      }

                      public void finished(Throwable ex) {}
                    });
          }
        }
        // register counters with the query realizer
        // for every counter create a query and register it
        ResourceId[] counters = dinfo.getDashboard().getCounters();
        if (!Utils.isEmptyArray(counters)) {
          for (ResourceId counter : counters) {
            if (fContext != null) {
              counter = counter.complete(fContext);
            }
            final SingleCounterQueryDef query = new SingleCounterQueryDef(counter, null, null);
            final ResourceId counterContext = counter.getSubResourceId(ResourceId.ENTITY);

            // add query to the model
            fSessionData.getQueryHelper().addQuery(counterContext, query);

            String translatedCounterName = counter.getCounterId().toString();
            // ask the locator for info on this counter
            SessionResourceInfo rInfo = this.fArtefactInfoLocator.getResourceInfo(counter);
            if (rInfo != null && rInfo.getCounterInfo() != null) {
              translatedCounterName = rInfo.getCounterInfo().getTranslatedName();
            }
            final String finalTranslatedCounterName = translatedCounterName;
            final ResourceId fc = counter;
            // Note: this method is reading from the session model
            // and as a result it can only be used safely from
            // the event dispatching thread
            this.fViewContainer
                .getAppWorker()
                .runJobSynch(
                    new UIWorkerJobDefault(
                        fViewContainer.getAppFrame(),
                        Cursor.WAIT_CURSOR,
                        MessageRepository.get(
                            Msg.TEXT_REALIZING_DATAVIEW, new String[] {translatedCounterName})) {
                      public void work() throws Exception {
                        fQueryRealizer.realizeQuery(
                            counterContext,
                            query,
                            new QueryRealizer.Callback() {
                              public boolean acceptIncreaseInMonitoringLevel(
                                  List<ResourceInfo> counters) {
                                boolean ret =
                                    UIUtils.getBooleanYesNoInput(
                                        fViewContainer.getAppFrame(),
                                        MessageRepository.get(
                                            Msg.TITLE_CONFIRM_MONITORING_LEVEL_INCREASE),
                                        MessageRepository.get(
                                            Msg.TEXT_CONFIRM_MONITORING_LEVEL_INCREASE_FOR_COUNTER,
                                            new String[] {finalTranslatedCounterName}));
                                if (!ret) {
                                  // undo changes
                                  fSessionData.getCounterHelper().rollbackCounter(fc, true);
                                }
                                return ret;
                              }
                            });
                      }

                      public void finished(Throwable ex) {
                        if (ex != null) {
                          UIExceptionMgr.userException(ex);
                        }
                      }
                    });
          }
        }
      }
    }

    // get all dashboards to unrealize
    dashboards = getDashboardTableModel().getDashboardsToUnRealize();
    if (dashboards != null) {
      for (DashboardInfo dinfo : dashboards) {
        // unregister views with the query realizer
        DataViewId[] views = dinfo.getDashboard().getViews();
        // get views
        if (!Utils.isEmptyArray(views)) {
          for (DataViewId view : views) {
            if (fContext != null) {
              view = view.complete(fContext);
            }
            // ask the locator for info on the required data view
            String viewTranslatedName = view.getName();
            final SessionDataViewInfo dvInfo = this.fArtefactInfoLocator.getDataViewInfo(view);
            if (dvInfo == null) {
              if (logger.isTraceEnabled()) {
                logger.error("Couldn't find data view info for: " + view);
              }
            } else {
              viewTranslatedName = dvInfo.getTranslatedName();
            }
            final DataViewId fv = view;
            // Note: this method is reading from the session model
            // and as a result it can only be used safely from
            // the event dispatching thread
            this.fViewContainer
                .getAppWorker()
                .runJobSynch(
                    new UIWorkerJobDefault(
                        fViewContainer.getAppFrame(),
                        Cursor.WAIT_CURSOR,
                        MessageRepository.get(
                            Msg.TEXT_REALIZING_DATAVIEW, new String[] {viewTranslatedName})) {
                      public void work() throws Exception {
                        QueryId qid = new QueryId(fv.getContext(), fv.getName());
                        fQueryRealizer.unrealizeQuery(qid, false);
                      }

                      public void finished(Throwable ex) {
                        if (ex != null) {
                          UIExceptionMgr.userException(ex);
                        }
                      }
                    });
          }

          // unregister counters with the query realizer
          ResourceId[] counters = dinfo.getDashboard().getCounters();
          if (!Utils.isEmptyArray(counters)) {
            for (ResourceId counter : counters) {
              if (fContext != null) {
                counter = counter.complete(fContext);
              }
              final ResourceId counterContext = counter.getSubResourceId(ResourceId.ENTITY);
              String translatedCounterName = counter.getCounterId().toString();
              // ask the locator for info on this counter
              SessionResourceInfo rInfo = this.fArtefactInfoLocator.getResourceInfo(counter);
              if (rInfo != null && rInfo.getCounterInfo() != null) {
                translatedCounterName = rInfo.getCounterInfo().getTranslatedName();
              }
              final ResourceId finalCounter = counter;
              // Note: this method is reading from the session model
              // and as a result it can only be used safely from
              // the event dispatching thread
              this.fViewContainer
                  .getAppWorker()
                  .runJobSynch(
                      new UIWorkerJobDefault(
                          fViewContainer.getAppFrame(),
                          Cursor.WAIT_CURSOR,
                          MessageRepository.get(
                              Msg.TEXT_REALIZING_DATAVIEW, new String[] {translatedCounterName})) {
                        public void work() throws Exception {
                          QueryId queryId =
                              new QueryId(counterContext, finalCounter.getCounterId().toString());
                          fQueryRealizer.unrealizeQuery(queryId, false);
                        }

                        public void finished(Throwable ex) {
                          if (ex != null) {
                            UIExceptionMgr.userException(ex);
                          }
                        }
                      });
            }
          }

          String dashboardName = dinfo.getDashboard().getName();
          fSessionData
              .getDashboardHelper()
              .setDashboardFlag(ArtefactInfo.ENABLED, fContext, dashboardName, false, true);
        }
      }
    }
    fSessionData.getDashboardHelper().recalculateDashboardsStatus(fContext);
    getDashboardTableModel().fireTableDataChanged();
    fActionApply.setEnabled(false);
    fActionCancel.setEnabled(false);
  }
  /**
   * @param parent
   * @param conf
   * @param rep
   */
  @SuppressWarnings("serial")
  public DataLogReplayConfigurationDialog(RMSViewContainer container) {
    super(container.getAppFrame(), VERTICAL);
    setModal(true);
    setTitle(MessageRepository.get(Msg.TITLE_REPLAY_CONFIGURATION));
    fViewContainer = container;
    fEventHandler = new EventHandler();
    fForm = new FormPanel(FormPanel.VERTICAL1);

    fTextFieldAggStep = UIFactoryMgr.createTextField();
    fTextFieldLogOne = UIFactoryMgr.createTextField();
    fCheckBoxNoAgg = UIFactoryMgr.createCheckBox();
    fCheckBoxNoAgg.setText(MessageRepository.get(Msg.TEXT_NO_AGGREGATION));

    fPaneSelectTimeIntervalOne = UIFactoryMgr.createHtmlPane();
    fPaneSelectTimeIntervalOne.setPreferredSize(new Dimension(300, 20));
    fPaneSelectTimeIntervalOne.setText(
        "<html><a href='#'>" + MessageRepository.get(Msg.LINK_SETUP_TIME_INTERVAL) + "</a></html>");
    fPaneSelectTimeIntervalOne.addHyperlinkListener(fEventHandler);

    fButtonBrowseOne =
        UIFactoryMgr.createButton(
            new ActionBrowse() {
              public void actionPerformed(ActionEvent e) {
                handleBrowseOne();
              }
            });

    Box box1 = new Box(BoxLayout.Y_AXIS);
    box1.add(fTextFieldLogOne);
    box1.add(Box.createHorizontalStrut(UIConfiguration.getPanelPadding()));
    box1.add(fPaneSelectTimeIntervalOne);

    Box box11 = new Box(BoxLayout.X_AXIS);
    box11.add(box1);
    box11.add(Box.createHorizontalStrut(UIConfiguration.getPanelPadding()));
    box11.add(fButtonBrowseOne);

    Box box3 = new Box(BoxLayout.X_AXIS);
    box3.add(fTextFieldAggStep);
    box3.add(Box.createHorizontalStrut(UIConfiguration.getPanelPadding()));
    box3.add(fCheckBoxNoAgg);

    fForm.addPairs(
        new String[] {
          MessageRepository.get(Msg.LABEL_LOG), MessageRepository.get(Msg.LABEL_AGGREGATION_STEP)
        },
        new Component[] {box11, box3});

    int aggStep;
    aggStep =
        ConfigurationMgr.getInt(
            LogComponent.NAME, LogConfigurationConstants.LOG_AGGREGATION_PERIOD);
    fTextFieldAggStep.setText(String.valueOf(aggStep));
    if (aggStep == 0) {
      fCheckBoxNoAgg.setSelected(true);
    } else {
      fCheckBoxNoAgg.setSelected(false);
    }
    fActionOk =
        new ActionOk() {
          public void actionPerformed(ActionEvent e) {
            handleOk();
          }
        };
    fActionOk.setEnabled(false);
    fTextFieldLogOne.setEnabled(false);

    fCheckBoxNoAgg.addItemListener(fEventHandler);
    fTextFieldLogOne.getDocument().addDocumentListener(fEventHandler);

    fScanningService = RMS.getDataLogScanning();

    buildContentPane();
  }