コード例 #1
0
  private void widgetDisposed() {
    if (store != null) store.updateActive(serialize());
    else preferences.setValue(identifier, serialize());

    if (contextMenu != null) contextMenu.dispose();

    if (store != null) store.dispose();
  }
コード例 #2
0
 protected void setUp() throws ConfigurationException {
   ConfigurationStore store = ConfigurationStore.getInstance();
   ClassLoader loader = getClass().getClassLoader();
   System.setProperty("ambra.virtualJournals.templateDir", loader.getResource(".").getFile());
   store.loadConfiguration(loader.getResource("ambra/configuration/defaults-dev.xml"));
   conf = store.getConfiguration();
   /*
    * We want to use a test version of global-defaults.
    * However there is no way to override it. So we add this
    * at the end (last place looked).
    */
   ConfigurationStore.addResources(
       (CombinedConfiguration) conf, "/ambra/configuration/global-defaults-test.xml");
 }
コード例 #3
0
  public void writeLogEntry(LogEntry logEntry) throws Throwable {
    List<Mutation> slice = new ArrayList<Mutation>();
    slice.add(getMutation(LogEntryColumns.KS.toString(), logEntry.getKeyspace()));
    slice.add(getMutation(LogEntryColumns.CF.toString(), logEntry.getColumnFamily()));
    slice.add(getMutation(LogEntryColumns.ROW.toString(), logEntry.getRowKey()));
    slice.add(getMutation(LogEntryColumns.STATUS.toString(), logEntry.getStatus().toString()));
    slice.add(
        getMutation(LogEntryColumns.TIMESTAMP.toString(), Long.toString(logEntry.getTimestamp())));
    slice.add(getMutation(LogEntryColumns.HOST.toString(), logEntry.getHost()));
    if (logEntry.hasErrors()) {
      for (String errorKey : logEntry.getErrors().keySet()) {
        slice.add(getMutation(errorKey, logEntry.getErrors().get(errorKey)));
      }
    }

    if (ConfigurationStore.getStore().shouldWriteColumns()) {
      for (ColumnOperation operation : logEntry.getOperations()) {
        if (operation.isDelete()) {
          slice.add(getMutation(operation.getName(), OperationType.DELETE));
        } else {
          slice.add(getMutation(operation.getName(), OperationType.UPDATE));
        }
      }
    }
    Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap =
        new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
    Map<String, List<Mutation>> cfMutations = new HashMap<String, List<Mutation>>();
    cfMutations.put(COLUMN_FAMILY, slice);

    ByteBuffer rowKey = ByteBufferUtil.bytes(logEntry.getUuid());
    mutationMap.put(rowKey, cfMutations);
    getConnection(KEYSPACE).batch_mutate(mutationMap, logEntry.getConsistencyLevel());
  }
コード例 #4
0
  private void createFromColumnConfig() {
    // if a configuration store is used, then migrate the preferences into
    // the store. This is done once. Unfortunately, if the user then does
    // not save the file subsequently, the configuration is lost (e.g. the
    // order and size of the displayed columns). Therefore the key is saved
    // for manual recovery.

    // if no configuration store is used (i.e. column configuration cannot
    // be saved), we continue to use the preferences to store configuration

    String configInPreferences = preferences.getString(identifier);

    if (store != null && !configInPreferences.isEmpty()) {
      preferences.setToDefault(identifier);
      preferences.setValue("__backup__" + identifier, configInPreferences); // $NON-NLS-1$
      store.insertMigratedConfiguration(configInPreferences);
    }

    String config = store != null ? store.getActive() : configInPreferences;
    createFromColumnConfig(config);
  }
コード例 #5
0
 private static List<LogEntry> toLogEntry(List<KeySlice> rows) throws Exception, Throwable {
   List<LogEntry> logEntries = new ArrayList<LogEntry>();
   if (rows == null || rows.size() == 0) {
     return logEntries;
   }
   for (KeySlice keySlice : rows) {
     if (keySlice.columns.size() > 0) {
       LogEntry logEntry = new LogEntry();
       logEntry.setUuid(ByteBufferUtil.string(keySlice.key));
       for (ColumnOrSuperColumn cc : keySlice.columns) {
         if (ConfigurationStore.getStore().shouldWriteColumns()) {
           ColumnOperation operation = new ColumnOperation();
           operation.setName(cc.column.name);
           operation.setOperationType(cc.column.value);
         } else {
           switch (LogEntryColumns.valueOf(ByteBufferUtil.string(cc.column.name))) {
             case KS:
               logEntry.setKeyspace(ByteBufferUtil.string(cc.column.value));
               break;
             case CF:
               logEntry.setColumnFamily(ByteBufferUtil.string(cc.column.value));
               break;
             case ROW:
               logEntry.setRowKey(cc.column.value);
               break;
             case STATUS:
               logEntry.setStatus(LogEntryStatus.valueOf(ByteBufferUtil.string(cc.column.value)));
               break;
             case TIMESTAMP:
               logEntry.setTimestamp(Long.valueOf(ByteBufferUtil.string(cc.column.value)));
               break;
             case HOST:
               logEntry.setHost(ByteBufferUtil.string(cc.column.value));
               break;
           }
         }
       }
       logEntries.add(logEntry);
     }
   }
   return logEntries;
 }
コード例 #6
0
  private void doResetColumns() {
    try {
      // first add, then remove columns
      // (otherwise rendering of first column is broken)
      policy.setRedraw(false);

      int count = policy.getColumnCount();

      for (Column column : columns) {
        if (column.isVisible())
          policy.create(column, null, column.getDefaultSortDirection(), column.getDefaultWidth());
      }

      for (int ii = 0; ii < count; ii++) policy.getColumn(0).dispose();
    } finally {
      policy.getViewer().refresh();
      policy.setRedraw(true);
    }

    if (store != null) store.updateActive(serialize());
  }
コード例 #7
0
 @Override
 public void beforeConfigurationPicked() {
   store.updateActive(serialize());
 }
コード例 #8
0
  public void showSaveMenu(Shell shell) {
    if (store == null) throw new UnsupportedOperationException();

    store.showSaveMenu(shell);
  }