/* (non-Javadoc)
  * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
  */
 public void setEnabled(boolean enabled) {
   fTree.getControl().setEnabled(enabled);
   if (enabled) {
     updateButtons();
   } else {
     fSelectButton.setEnabled(false);
     fSelectAllButton.setEnabled(false);
     fDeselectButton.setEnabled(false);
     fDeselectAllButton.setEnabled(false);
     fSelectRequiredButton.setEnabled(false);
     fCountLabel.setText(""); // $NON-NLS-1$
   }
   fModeLabel.setEnabled(enabled);
   fPluginModeButton.setEnabled(enabled);
   fFeaureModeButton.setEnabled(enabled);
   fShowLabel.setEnabled(enabled);
   fShowPluginsButton.setEnabled(enabled);
   fShowSourceButton.setEnabled(enabled);
   boolean isPluginMode = !fFeaureModeButton.getSelection();
   fGroupLabel.setEnabled(enabled && isPluginMode);
   if (fGroupCombo != null) {
     fGroupCombo.setEnabled(enabled && isPluginMode);
   } else {
     fGroupComboPart.setEnabled(enabled && isPluginMode);
   }
 }
  private void updateButtonEnablement(boolean doAddEnablement, boolean doRemoveEnablement) {
    updateCount();
    int availableCount = fAvailableListViewer.getTable().getItemCount();
    int importCount = fImportListViewer.getTable().getItemCount();

    if (doAddEnablement) updateSelectionBasedEnablement(fAvailableListViewer.getSelection(), true);
    if (doRemoveEnablement) updateSelectionBasedEnablement(fImportListViewer.getSelection(), false);

    fAddAllButton.setEnabled(availableCount > 0);
    fRemoveAllButton.setEnabled(importCount > 0);
    fAddRequiredButton.setEnabled(importCount > 0);
  }
  public void addSelectedFilesToTargetList() {
    ISelection selection = sourceFileViewer.getSelection();

    if (isValidSourceFileViewerSelection(selection)) {
      java.util.List list = null;
      if (selection instanceof IStructuredSelection) {
        list = ((IStructuredSelection) selection).toList();

        if (list != null) {
          list = ((IStructuredSelection) selection).toList();
          for (Iterator i = list.iterator(); i.hasNext(); ) {
            IResource resource = (IResource) i.next();
            if (resource instanceof IFile) {
              // Check if its in the list. Don't add it if it is.
              String resourceName = resource.getFullPath().toString();
              if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName);
            }
          }
          setFiles(selectedListBox.getItems());
        }

        setAddButtonEnabled(false);

        if (selectedListBox.getItemCount() > 0) {
          removeAllButton.setEnabled(true);
          if (isFileMandatory) setPageComplete(true);
          if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true);
          else setRemoveButtonEnabled(false);
        }
      }
    }
  }
  private void createButtonPanel(Composite pageContent) {
    Composite buttonPanel = new Composite(pageContent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    buttonPanel.setLayout(layout);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = false;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalAlignment = GridData.CENTER;
    gridData.horizontalAlignment = GridData.CENTER;
    buttonPanel.setLayoutData(gridData);

    addButton = new Button(buttonPanel, SWT.PUSH);
    addButton.setText(Messages._UI_ADD_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    addButton.setLayoutData(gridData);
    addButton.addSelectionListener(new ButtonSelectListener());
    addButton.setToolTipText(Messages._UI_ADD_BUTTON_TOOL_TIP);
    addButton.setEnabled(false);

    removeButton = new Button(buttonPanel, SWT.PUSH);
    removeButton.setText(Messages._UI_REMOVE_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    removeButton.setLayoutData(gridData);
    removeButton.addSelectionListener(new ButtonSelectListener());
    removeButton.setToolTipText(Messages._UI_REMOVE_BUTTON_TOOL_TIP);
    removeButton.setEnabled(false);

    removeAllButton = new Button(buttonPanel, SWT.PUSH);
    removeAllButton.setText(Messages._UI_REMOVE_ALL_BUTTON);
    gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.CENTER;
    removeAllButton.setLayoutData(gridData);
    removeAllButton.addSelectionListener(new ButtonSelectListener());
    removeAllButton.setToolTipText(Messages._UI_REMOVE_ALL_BUTTON_TOOL_TIP);
    removeAllButton.setEnabled(false);
  }
 private void updateNewFolderButtonState() {
   IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
   fSelectedContainer = null;
   if (selection.size() == 1) {
     Object first = selection.getFirstElement();
     if (first instanceof IContainer) {
       fSelectedContainer = (IContainer) first;
     }
   }
   fNewFolderButton.setEnabled(fSelectedContainer != null);
 }
 public void setRemoveButtonEnabled(boolean isEnabled) {
   removeButton.setEnabled(isEnabled);
 }
 public void setAddButtonEnabled(boolean isEnabled) {
   addButton.setEnabled(isEnabled);
 }
 private void updateSelectionBasedEnablement(ISelection theSelection, boolean available) {
   if (available) fAddButton.setEnabled(!theSelection.isEmpty());
   else fRemoveButton.setEnabled(!theSelection.isEmpty());
 }
Пример #9
0
 void setVirtual(boolean virtual) {
   virtCheck.setSelection(virtual);
   tblRate.setEnabled(!virtual);
   addBtn.setEnabled(!virtual);
   delBtn.setEnabled(!virtual);
 }
Пример #10
0
 public void clearAll() {
   txtName.setText("");
   txtAbbrev.setText("");
   txtComment.setText("");
   virtCheck.setEnabled(false);
 }
 private void updateImpButtons() {
   boolean empty = fElementViewer.getSelection().isEmpty();
   fRemoveButton.setEnabled(!empty);
   boolean hasElements = fElementViewer.getTable().getItemCount() > 0;
   fRemoveAllButton.setEnabled(hasElements);
 }
  /** Updates the state (enabled, not enabled) of the buttons */
  private void updateEnabledState() {
    TableItem[] itemsIdMaps = fIdMapsTable.getSelection();
    if (itemsIdMaps.length > 0) {
      IdMap idmap = (IdMap) itemsIdMaps[0].getData();
      if (idmap.isInternal()) {
        fRenameIdMapButton.setEnabled(false);
        fRemoveIdMapButton.setEnabled(false);
        fEditIdMapButton.setEnabled(true);

        fNewMappingsButton.setEnabled(false);
        fEditMappingsButton.setEnabled(false);
        fRemoveMappingsButton.setEnabled(false);

        fNewOrderedButton.setEnabled(false);
        fEditOrderedButton.setEnabled(false);
        fRemoveOrderedButton.setEnabled(false);
      } else {
        fRenameIdMapButton.setEnabled(true);
        fRemoveIdMapButton.setEnabled(true);
        fEditIdMapButton.setEnabled(false);

        fNewMappingsButton.setEnabled(true);
        fEditMappingsButton.setEnabled(true);
        fRemoveMappingsButton.setEnabled(true);

        fNewOrderedButton.setEnabled(true);
        fEditOrderedButton.setEnabled(true);
        fRemoveOrderedButton.setEnabled(true);
      }
    }
  }
  private void updateButtons() {
    if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) {
      Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
      boolean hasResolveBundle = false;
      boolean hasParent = false;
      boolean allSelected = true;
      boolean noneSelected = true;
      for (int i = 0; i < selection.length; i++) {
        if (!hasResolveBundle || !hasParent) {
          if (selection[i] instanceof IResolvedBundle) {
            hasResolveBundle = true;
          } else {
            hasParent = true;
          }
        }
        boolean checked = fTree.getChecked(selection[i]);
        if (checked) {
          noneSelected = false;
        } else {
          allSelected = false;
        }
      }
      // Selection is available if not everything is already selected and not both a parent and
      // child item are selected
      fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent));
      fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent));
    } else {
      fSelectButton.setEnabled(false);
      fDeselectButton.setEnabled(false);
    }

    int total = fAllBundles.size();
    if (fFeaureModeButton.getSelection()) {
      if (fTargetDefinition == null) {
        total = 0;
      } else {
        total = fTargetDefinition.getAllFeatures().length;
        total += ((TargetDefinition) fTargetDefinition).getOtherBundles().length;
      }
    }
    if (fMissing != null) {
      total += fMissing.size();
    }

    fSelectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != total);
    fDeselectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != 0);
    fSelectRequiredButton.setEnabled(
        fTargetDefinition != null
            && fTree.getCheckedLeafCount() > 0
            && fTree.getCheckedLeafCount() != total);

    if (fTargetDefinition != null) {
      fCountLabel.setText(
          MessageFormat.format(
              Messages.TargetContentsGroup_9,
              new String[] {
                Integer.toString(fTree.getCheckedLeafCount()), Integer.toString(total)
              }));
    } else {
      fCountLabel.setText(""); // $NON-NLS-1$
    }
  }