Пример #1
0
  @Inject
  public AllocatableEditUI(RaplaContext context) throws RaplaException {
    super(context);
    classificationField = new ClassificationField<Allocatable>(context);
    permissionField = new PermissionListField(context, getString("permissions"));

    permissionField.setPermissionLevels(
        Permission.DENIED,
        Permission.READ_NO_ALLOCATION,
        Permission.READ,
        Permission.ALLOCATE,
        Permission.ALLOCATE_CONFLICTS,
        Permission.EDIT,
        Permission.ADMIN);
    final JComponent permissionPanel = permissionField.getComponent();
    editPanel.setLayout(new BorderLayout());
    editPanel.add(classificationField.getComponent(), BorderLayout.CENTER);
    holdBackConflictsField = new BooleanField(context, getString("holdbackconflicts"));
    holdBackConflictPanel = new JPanel();
    holdBackConflictPanel.setLayout(new BorderLayout());
    holdBackConflictPanel.add(
        new JLabel(holdBackConflictsField.getFieldName() + ": "), BorderLayout.WEST);
    holdBackConflictPanel.add(holdBackConflictsField.getComponent(), BorderLayout.CENTER);

    classificationField.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            final boolean mainTabSelected = classificationField.isMainTabSelected();
            permissionPanel.setVisible(!mainTabSelected);
            if (!mainTabSelected && !editPanel.isAncestorOf(permissionPanel)) {
              editPanel.remove(holdBackConflictPanel);
              editPanel.add(permissionPanel, BorderLayout.SOUTH);
              editPanel.repaint();
            }

            if (mainTabSelected && (!editPanel.isAncestorOf(holdBackConflictPanel))) {
              editPanel.remove(permissionPanel);
              editPanel.add(holdBackConflictPanel, BorderLayout.SOUTH);
              editPanel.repaint();
            }
            AllocatableEditUI.this.stateChanged(e);
          }
        });
    editPanel.setPreferredSize(new Dimension(800, 600));
  }
Пример #2
0
  @SuppressWarnings("unchecked")
  @Inject
  public AllocatableEditUI(
      ClientFacade facade,
      RaplaResources i18n,
      RaplaLocale raplaLocale,
      Logger logger,
      ClassificationFieldFactory classificationFieldFactory,
      PermissionListFieldFactory permissionListFieldFactory,
      BooleanFieldFactory booleanFieldFactory)
      throws RaplaInitializationException {
    super(facade, i18n, raplaLocale, logger);
    this.permissionController = facade.getRaplaFacade().getPermissionController();
    classificationField = classificationFieldFactory.create();
    try {
      this.permissionListField = permissionListFieldFactory.create(getString("permissions"));
    } catch (RaplaException e1) {
      throw new RaplaInitializationException(e1);
    }

    this.permissionListField.setPermissionLevels(
        Permission.DENIED,
        Permission.READ_NO_ALLOCATION,
        Permission.READ,
        Permission.ALLOCATE,
        Permission.ALLOCATE_CONFLICTS,
        Permission.EDIT,
        Permission.ADMIN);
    final JComponent permissionPanel = permissionListField.getComponent();
    editPanel.setLayout(new BorderLayout());
    editPanel.add(classificationField.getComponent(), BorderLayout.CENTER);
    holdBackConflictsField = booleanFieldFactory.create(getString("holdbackconflicts"));
    holdBackConflictPanel = new JPanel();
    holdBackConflictPanel.setLayout(new BorderLayout());
    holdBackConflictPanel.add(
        new JLabel(holdBackConflictsField.getFieldName() + ": "), BorderLayout.WEST);
    holdBackConflictPanel.add(holdBackConflictsField.getComponent(), BorderLayout.CENTER);

    classificationField.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            final boolean mainTabSelected = classificationField.isMainTabSelected();
            permissionPanel.setVisible(!mainTabSelected);
            if (!mainTabSelected && !editPanel.isAncestorOf(permissionPanel)) {
              editPanel.remove(holdBackConflictPanel);
              editPanel.add(permissionPanel, BorderLayout.SOUTH);
              editPanel.repaint();
            }

            if (mainTabSelected && (!editPanel.isAncestorOf(holdBackConflictPanel))) {
              editPanel.remove(permissionPanel);
              editPanel.add(holdBackConflictPanel, BorderLayout.SOUTH);
              editPanel.repaint();
            }
            AllocatableEditUI.this.stateChanged(e);
          }
        });
    editPanel.setPreferredSize(new Dimension(800, 600));
  }