Ejemplo n.º 1
0
  @Override
  public void delete() {
    m_addressSpace.removeListener(m_addressSpaceListener);

    if (m_addressSpace.isLoaded()) {
      m_addressSpace.getContent().removeListener(m_contentListener);

      for (final INaviModule module : m_addressSpace.getContent().getModules()) {
        module.removeListener(m_modulesListener);
      }
    }
  }
Ejemplo n.º 2
0
  /**
   * Creates a new model object.
   *
   * @param addressSpace The address space that provides the modules.
   */
  public CProjectModulesModel(final INaviAddressSpace addressSpace) {
    Preconditions.checkNotNull(addressSpace, "IE01955: Address space argument can't be null");

    m_addressSpace = addressSpace;

    addressSpace.addListener(m_addressSpaceListener);

    if (addressSpace.isLoaded()) {
      addressSpace.getContent().addListener(m_contentListener);

      for (final INaviModule module : addressSpace.getContent().getModules()) {
        module.addListener(m_modulesListener);
      }
    }
  }
Ejemplo n.º 3
0
  @Override
  public void setValueAt(final Object value, final int row, final int col) {
    if ((col != NAME_COLUMN) && (col != DESCRIPTION_COLUMN)) {
      throw new IllegalStateException("IE01161: Column can not be edited");
    }

    final INaviModule module = getModules().get(row);

    if (col == NAME_COLUMN) {
      try {
        module.getConfiguration().setName((String) value);
      } catch (final CouldntSaveDataException e) {
        CUtilityFunctions.logException(e);

        final String innerMessage = "E00156: " + "Could not save address space name";
        final String innerDescription =
            CUtilityFunctions.createDescription(
                String.format(
                    "The new name of the address space '%s' could not be saved.",
                    m_addressSpace.getConfiguration().getName()),
                new String[] {"There was a problem with the database connection."},
                new String[] {"The address space keeps its old name."});

        NaviErrorDialog.show(null, innerMessage, innerDescription, e);
      }
    } else if (col == DESCRIPTION_COLUMN) {
      try {
        module.getConfiguration().setDescription((String) value);
      } catch (final CouldntSaveDataException e) {
        CUtilityFunctions.logException(e);

        final String innerMessage = "E00157: " + "Could not save address space description";
        final String innerDescription =
            CUtilityFunctions.createDescription(
                String.format(
                    "The new description of the address space '%s' could not be saved.",
                    m_addressSpace.getConfiguration().getName()),
                new String[] {"There was a problem with the database connection."},
                new String[] {"The address space keeps its old description."});

        NaviErrorDialog.show(null, innerMessage, innerDescription, e);
      }
    }
  }
Ejemplo n.º 4
0
  /**
   * Returns the currently displayed modules.
   *
   * @return The currently displayed modules.
   */
  public List<INaviModule> getModules() {
    List<INaviModule> localCachedValues = m_cachedValues;

    if (localCachedValues == null) {
      final IFilter<INaviModule> filter = getFilter();

      if (m_addressSpace.isLoaded()) {
        localCachedValues =
            filter == null
                ? m_addressSpace.getContent().getModules()
                : filter.get(m_addressSpace.getContent().getModules());
      } else {
        localCachedValues = new ArrayList<INaviModule>();
      }
    }

    m_cachedValues = localCachedValues;
    return new ArrayList<INaviModule>(localCachedValues);
  }
Ejemplo n.º 5
0
  /**
   * Generates a name list from the names of the given address spaces.
   *
   * @param addressSpaces The address spaces that provide the names.
   * @return The generated name list.
   */
  public static String getNameList(final INaviAddressSpace[] addressSpaces) {
    int count = 0;

    final StringBuilder list = new StringBuilder();

    for (final INaviAddressSpace addressSpace : addressSpaces) {
      list.append("- ");
      list.append(addressSpace.getConfiguration().getName());
      list.append('\n');

      count++;

      if ((count == MAX_LIST_LENGTH) && (addressSpaces.length != MAX_LIST_LENGTH)) {
        list.append("\n... ");
        list.append(String.format("%d others ...", addressSpaces.length - count));

        break;
      }
    }

    return list.toString();
  }
Ejemplo n.º 6
0
 @Override
 public void loaded(final INaviAddressSpace addressSpace) {
   addressSpace.getContent().addListener(m_contentListener);
 }