コード例 #1
0
ファイル: GridViewer.java プロジェクト: Tagin/aurora-ide
 public void setAllChecked(Table table, boolean state) {
   TableItem[] children = table.getItems();
   for (int i = 0; i < children.length; i++) {
     TableItem item = children[i];
     item.setChecked(state);
   }
 }
コード例 #2
0
ファイル: UIUtils.java プロジェクト: ralic/dbeaver
  public static void sortTable(Table table, Comparator<TableItem> comparator) {
    int columnCount = table.getColumnCount();
    String[] values = new String[columnCount];
    TableItem[] items = table.getItems();
    for (int i = 1; i < items.length; i++) {
      for (int j = 0; j < i; j++) {
        TableItem item = items[i];
        if (comparator.compare(item, items[j]) < 0) {
          for (int k = 0; k < columnCount; k++) {
            values[k] = item.getText(k);
          }
          Object data = item.getData();
          boolean checked = item.getChecked();
          item.dispose();

          item = new TableItem(table, SWT.NONE, j);
          item.setText(values);
          item.setData(data);
          item.setChecked(checked);
          items = table.getItems();
          break;
        }
      }
    }
  }
コード例 #3
0
 private void updateItem(TableItem item) {
   TeaVMProfile profile = (TeaVMProfile) item.getData();
   item.setText(0, profile.getName());
   item.setText(1, profile.getTargetDirectory());
   item.setText(2, profile.getTargetFileName());
   item.setChecked(profile.isEnabled());
 }
コード例 #4
0
 @Override
 protected void performDefaults() {
   for (TableItem item : keyTable.getItems()) {
     item.setChecked(false);
   }
   beforeAction.clear();
 }
コード例 #5
0
 private void init() {
   if (input != null) {
     summaryFieldViewer.setInput(input);
     for (int i = 0; i < summaryFieldViewer.getTable().getItemCount(); i++) {
       TableItem item = summaryFieldViewer.getTable().getItem(i);
       if (item.getData() != null && item.getData() instanceof MeasureInfo) {
         item.setChecked(((MeasureInfo) item.getData()).isShow());
       }
     }
   }
 }
コード例 #6
0
ファイル: FunctionGroup.java プロジェクト: rampage/erlide
 /**
  * TODO Write description of addFunction in FunctionGroup.
  *
  * @param name
  * @param arity
  * @param type
  * @param exported
  */
 void addFunction(final String name, final int arity, final int type, final boolean exported) {
   final TableItem item = fEditingItem != null ? fEditingItem : new TableItem(fTable, SWT.NULL, 0);
   item.setChecked(exported);
   item.setText(0, name + getPostfix(type));
   item.setText(1, "" + arity);
   fEditingItem = null;
   final TableItem lastItem = fTable.getItem(fTable.getItemCount() - 1);
   if ("".equals(lastItem.getText(0))) {
     fTable.remove(fTable.getItemCount() - 1);
   }
 }
コード例 #7
0
  public void updateTableCheckboxes() {
    ICheckboxTreeContentProvider contentProvider = contentProvider();
    Table table = tableViewer.getTable();
    int count = table.getItemCount();

    for (int i = 0; i < count; i++) {
      TableItem item = table.getItem(i);

      item.setChecked(contentProvider.isChecked(item.getData()));
    }
  }
コード例 #8
0
 private void checkItem(IConnectionPoint item) {
   TableItem[] items = connectionTable.getItems();
   for (TableItem ti : items) {
     if (ti.getData() == item) {
       ti.setChecked(true);
       site = item;
       setErrorMessage(null);
       setPageComplete(true);
       break;
     }
   }
 }
コード例 #9
0
  private void listRoles() {
    // clear table.
    userRolesTable.removeAll();

    UserManagerUtils.getInstance()
        .init(
            serverUrlText.getText().trim(),
            userNameText.getText().trim(),
            passwordText.getText().trim());

    String filter;
    if (StringUtils.isNotBlank(roleNamePatternText.getText())) {
      filter = roleNamePatternText.getText().trim();
    } else {
      filter = "*";
    }

    List<String> roles;
    try {
      roles = UserManagerUtils.getInstance().getRoles(filter, 1000);
    } catch (Exception e) {
      // If the server connection fails due to connectivity issues or invalid credentials, showing
      // an error message
      MessageBox msg = new MessageBox(getShell(), SWT.ICON_ERROR);
      msg.setMessage(SecurityFormMessageConstants.SERVER_CONNECTION_FAILURE_MESSAGE);
      msg.open();
      return;
    }

    for (final String role : roles) {
      if (!role.equals("false")) {
        TableItem item = new TableItem(userRolesTable, SWT.RIGHT);
        item.setText(new String[] {role, role});
        if (selectedRoles.contains(role)) {
          item.setChecked(true);
        }
      }
    }

    userRolesTable.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            updateSelectedRolesFromServer(event);
          }
        });
  }
コード例 #10
0
ファイル: ProjectTableModel.java プロジェクト: asgeirf/okapi
 void updateTable(int[] selection, int index) {
   table.removeAll();
   for (ResourceInfo info : project.getResources()) {
     TableItem item = new TableItem(table, SWT.NONE);
     item.setText(0, info.getName());
     item.setText(1, info.getId());
     item.setChecked(info.getSelected());
   }
   if (selection == null) {
     if (table.getItemCount() > 0) {
       if (index > -1) {
         if (index > table.getItemCount() - 1) {
           index = table.getItemCount() - 1;
         }
       } else index = 0;
       table.setSelection(index);
     }
     // Else: nothing to select
   } else table.setSelection(selection);
 }
コード例 #11
0
ファイル: TagSelectionDialog.java プロジェクト: seanws/tagsea
 public void setCheckedElements(Object[] elements) {
   for (Object element : elements) {
     assert (element != null);
   }
   HashSet<Object> set = new HashSet<Object>();
   for (int i = 0; i < elements.length; ++i) {
     set.add(elements[i]);
   }
   TableItem[] items = tableViewer.getTable().getItems();
   for (int i = 0; i < items.length; ++i) {
     TableItem item = items[i];
     Object element = item.getData();
     if (element != null) {
       boolean check = set.contains(element);
       // only set if different, to avoid flicker
       if (item.getChecked() != check) {
         item.setChecked(check);
       }
     }
   }
 }
コード例 #12
0
  @SuppressWarnings("unused")
  @Override
  protected Control createDialogArea(Composite parent) {
    creatingContents = true;
    if (isEdit) {
      setTitle(EDIT_TITLE);
    } else {
      setTitle(CREATE_TITLE);
    }

    Composite dialogComposite = (Composite) super.createDialogArea(parent);

    Composite composite = WidgetFactory.createPanel(dialogComposite);
    // ------------------------------
    // Set layout for the Composite
    // ------------------------------
    GridLayout gridLayout = new GridLayout();
    composite.setLayout(gridLayout);
    gridLayout.numColumns = 2;
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.grabExcessHorizontalSpace = true;
    gridData.widthHint = 500;
    composite.setLayoutData(gridData);

    Label label = new Label(composite, SWT.NONE | SWT.RIGHT);
    label.setText(UILabelUtil.getLabel(UiLabelConstants.LABEL_IDS.NAME));
    label.setLayoutData(new GridData());

    final Text indexNameText = new Text(composite, SWT.BORDER | SWT.SINGLE);
    indexNameText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
    indexNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    indexNameText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent event) {
            String value = indexNameText.getText();
            if (value == null) {
              value = EMPTY_STRING;
            }
            editedIndex.setName(value);
            validate();
          }
        });

    label = new Label(composite, SWT.NONE | SWT.RIGHT);
    label.setText(Messages.nameInSourceLabel);
    label.setLayoutData(new GridData());

    final Text indexNISText = new Text(composite, SWT.BORDER | SWT.SINGLE);
    indexNISText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
    indexNISText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    indexNISText.addModifyListener(
        new ModifyListener() {
          @Override
          public void modifyText(final ModifyEvent event) {
            String value = indexNISText.getText();
            if (value == null) {
              value = EMPTY_STRING;
            }
            editedIndex.setNameInSource(value);
            validate();
          }
        });

    // Group to present properties widgets
    PROPERTIES_GROUP:
    {
      this.autoUpdateCB = new Button(composite, SWT.CHECK | SWT.RIGHT);
      this.autoUpdateCB.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
      this.autoUpdateCB.setText(Messages.autoUpdateLabel);
      this.autoUpdateCB.addSelectionListener(
          new SelectionAdapter() {
            /**
             * {@inheritDoc}
             *
             * @see
             *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
              editedIndex.setAutoUpdate(autoUpdateCB.getSelection());
              validate();
            }
          });
      new Label(composite, SWT.NONE);

      this.nullableCB = new Button(composite, SWT.CHECK | SWT.RIGHT);
      this.nullableCB.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
      this.nullableCB.setText(Messages.nullableLabel);
      this.nullableCB.addSelectionListener(
          new SelectionAdapter() {
            /**
             * {@inheritDoc}
             *
             * @see
             *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
              editedIndex.setNullable(nullableCB.getSelection());
              validate();
            }
          });
      new Label(composite, SWT.NONE);

      this.uniqueCB = new Button(composite, SWT.CHECK | SWT.RIGHT);
      this.uniqueCB.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
      this.uniqueCB.setText(Messages.uniqueLabel);
      this.uniqueCB.addSelectionListener(
          new SelectionAdapter() {
            /**
             * {@inheritDoc}
             *
             * @see
             *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
             */
            @Override
            public void widgetSelected(SelectionEvent e) {
              editedIndex.setUnique(uniqueCB.getSelection());
              validate();
            }
          });
      new Label(composite, SWT.NONE);

      label = new Label(composite, SWT.NONE | SWT.RIGHT);
      label.setText(Messages.filterConditionLabel);
      label.setLayoutData(new GridData());

      filterConditionText = new Text(composite, SWT.BORDER | SWT.SINGLE);
      filterConditionText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE));
      filterConditionText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      filterConditionText.addModifyListener(
          new ModifyListener() {
            @Override
            public void modifyText(final ModifyEvent event) {
              String value = filterConditionText.getText();
              if (value == null) {
                value = EMPTY_STRING;
              }
              editedIndex.setFilterCondition(value);
              validate();
            }
          });
    }

    Group theColumnsGroup =
        WidgetFactory.createGroup(
            dialogComposite, Messages.selectColumnReferencesForIndex, SWT.NONE, 1, 1);
    theColumnsGroup.setLayout(new GridLayout(1, false));
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 120;
    gd.widthHint = 500;
    theColumnsGroup.setLayoutData(gd);

    Table tableWidget =
        new Table(
            theColumnsGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.CHECK);
    tableWidget.setHeaderVisible(false);
    tableWidget.setLinesVisible(true);
    tableWidget.setLayout(new TableLayout());
    tableWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    theColumnDataViewer = new TableViewer(tableWidget);
    gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 160;
    gd.horizontalSpan = 2;
    theColumnDataViewer.getControl().setLayoutData(gd);
    theColumnDataViewer.setContentProvider(
        new ITreeContentProvider() {

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // TODO Auto-generated method stub
          }

          @Override
          public void dispose() {
            // TODO Auto-generated method stub
          }

          @Override
          public boolean hasChildren(Object element) {
            return !theTable.getColumns().isEmpty();
          }

          @Override
          public Object getParent(Object element) {
            return null;
          }

          @Override
          public Object[] getElements(Object inputElement) {
            if (inputElement instanceof RelationalTable) {
              return theTable.getColumns().toArray(new Object[0]);
            }
            return new Object[0];
          }

          @Override
          public Object[] getChildren(Object parentElement) {
            // TODO Auto-generated method stub
            return new Object[0];
          }
        });

    this.theColumnDataViewer
        .getTable()
        .addSelectionListener(
            new SelectionListener() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                editedIndex.getColumns().clear();
                for (TableItem item : theColumnDataViewer.getTable().getItems()) {

                  if (item.getChecked()) {
                    editedIndex.addColumn((RelationalColumn) item.getData());
                  }
                }
                validate();
              }

              @Override
              public void widgetDefaultSelected(SelectionEvent e) {}
            });

    theColumnDataViewer.setLabelProvider(new ColumnDataLabelProvider(0));

    theColumnDataViewer.setInput(this.theTable);

    for (RelationalColumn col : this.editedIndex.getColumns()) {
      for (TableItem item : theColumnDataViewer.getTable().getItems()) {
        if (item.getData() == col) {
          item.setChecked(true);
        }
      }
    }

    DESCRIPTION_GROUP:
    {
      final Group descGroup =
          WidgetFactory.createGroup(
              dialogComposite,
              UILabelUtil.getLabel(UiLabelConstants.LABEL_IDS.DESCRIPTION),
              GridData.FILL_BOTH,
              3);
      descriptionTextEditor =
          new StyledTextEditor(
              descGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP | SWT.BORDER);
      final GridData descGridData = new GridData(GridData.FILL_BOTH);
      descGridData.horizontalSpan = 1;
      descGridData.heightHint = 120;
      //            descGridData.minimumHeight = 30;
      descGridData.grabExcessVerticalSpace = true;
      descriptionTextEditor.setLayoutData(descGridData);
      descriptionTextEditor.setText(""); // $NON-NLS-1$
      descriptionTextEditor
          .getTextWidget()
          .addModifyListener(
              new ModifyListener() {

                @Override
                public void modifyText(ModifyEvent e) {
                  editedIndex.setDescription(descriptionTextEditor.getText());
                }
              });
    }

    setMessage(Messages.newIndexMessage);
    if (editedIndex.getName() != null) {
      indexNameText.setText(editedIndex.getName());
    }
    if (editedIndex.getNameInSource() != null) {
      indexNISText.setText(editedIndex.getNameInSource());
    }
    this.autoUpdateCB.setSelection(editedIndex.isAutoUpdate());
    this.nullableCB.setSelection(editedIndex.isNullable());
    this.uniqueCB.setSelection(editedIndex.isUnique());
    if (editedIndex.getFilterCondition() != null) {
      filterConditionText.setText(editedIndex.getFilterCondition());
    }
    if (editedIndex.getDescription() != null) {
      descriptionTextEditor.setText(editedIndex.getDescription());
    }

    creatingContents = false;

    return composite;
  }
コード例 #13
0
ファイル: ExistingOrNewPage.java プロジェクト: blizzy78/egit
  public void createControl(Composite parent) {
    final RepositoryUtil util = Activator.getDefault().getRepositoryUtil();
    Composite main = new Composite(parent, SWT.NONE);
    // use zero spacing to save some real estate here
    GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(main);

    final Button internalModeButton = new Button(main, SWT.CHECK);
    internalModeButton.setText(UIText.ExistingOrNewPage_InternalModeCheckbox);
    internalModeButton.setToolTipText(UIText.ExistingOrNewPage_CreationInWorkspaceWarningTooltip);
    internalModeButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            internalMode = internalModeButton.getSelection();
            updateControls();
          }
        });

    externalComposite = new Composite(main, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(externalComposite);
    externalComposite.setLayout(new GridLayout(3, false));

    new Label(externalComposite, SWT.NONE)
        .setText(UIText.ExistingOrNewPage_ExistingRepositoryLabel);
    final Combo existingRepoCombo = new Combo(externalComposite, SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(existingRepoCombo);
    final ComboViewer v = new ComboViewer(existingRepoCombo);
    v.setContentProvider(new RepoComboContentProvider());
    v.setLabelProvider(new RepoComboLabelProvider());
    v.setInput(new Object());
    // the default ViewerSorter seems to do the right thing
    // i.e. sort as String
    v.setSorter(new ViewerSorter());

    existingRepoCombo.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            selectedRepository = null;
            IStructuredSelection sel = (IStructuredSelection) v.getSelection();
            setRepository((Repository) sel.getFirstElement());
            updateControls();
          }
        });

    Button createRepoWizard = new Button(externalComposite, SWT.PUSH);
    createRepoWizard.setText(UIText.ExistingOrNewPage_CreateRepositoryButton);
    createRepoWizard.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            NewRepositoryWizard wiz = new NewRepositoryWizard(true);
            if (new WizardDialog(getShell(), wiz).open() == Window.OK) {
              v.refresh();
              selectedRepository = wiz.getCreatedRepository();
              v.setSelection(new StructuredSelection(selectedRepository));
              updateControls();
            }
          }
        });

    new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_WorkingDirectoryLabel);
    workDir = new Text(externalComposite, SWT.BORDER | SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(workDir);
    GridDataFactory.fillDefaults().applyTo(workDir);
    // leave the space between the "Create" and "Browse" buttons empty (i.e.
    // do not fill to the right border
    new Label(externalComposite, SWT.NONE);

    new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_RelativePathLabel);
    relPath = new Text(externalComposite, SWT.BORDER);
    relPath.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            updateControls();
          }
        });

    GridDataFactory.fillDefaults().grab(true, false).applyTo(relPath);
    browseRepository = new Button(externalComposite, SWT.PUSH);
    browseRepository.setEnabled(false);
    browseRepository.setText(UIText.ExistingOrNewPage_BrowseRepositoryButton);
    browseRepository.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            dlg.setFilterPath(selectedRepository.getWorkTree().getPath());
            String directory = dlg.open();
            if (directory != null) {
              setRelativePath(directory);
              updateControls();
            }
          }
        });

    Table projectMoveTable =
        new Table(externalComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK | SWT.BORDER);
    projectMoveViewer = new CheckboxTableViewer(projectMoveTable);
    GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(projectMoveTable);

    TableColumn tc;
    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_ProjectNameColumnHeader);
    tc.setWidth(100);

    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_CurrentLocationColumnHeader);
    tc.setWidth(250);

    tc = new TableColumn(projectMoveTable, SWT.NONE);
    tc.setText(UIText.ExistingOrNewPage_NewLocationTargetHeader);
    tc.setWidth(350);

    projectMoveTable.setHeaderVisible(true);
    projectMoveViewer.setContentProvider(ArrayContentProvider.getInstance());
    projectMoveViewer.setLabelProvider(moveProjectsLabelProvider);
    projectMoveViewer.setInput(myWizard.projects);
    projectMoveViewer.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            updateControls();
          }
        });
    TableItem[] children = projectMoveViewer.getTable().getItems();
    for (int i = 0; i < children.length; i++) {
      TableItem item = children[i];
      IProject data = (IProject) item.getData();
      RepositoryFinder repositoryFinder = new RepositoryFinder(data);
      repositoryFinder.setFindInChildren(false);
      try {
        Collection<RepositoryMapping> find = repositoryFinder.find(new NullProgressMonitor());
        if (find.size() != 1) item.setChecked(true);
      } catch (CoreException e1) {
        item.setText(2, e1.getMessage());
      }
    }

    parentRepoComposite = new Composite(main, SWT.NONE);
    parentRepoComposite.setLayout(new GridLayout(3, false));
    GridDataFactory.fillDefaults().grab(true, true).applyTo(parentRepoComposite);

    tree = new Tree(parentRepoComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);
    viewer = new CheckboxTreeViewer(tree);
    tree.setHeaderVisible(true);
    tree.setLayout(new GridLayout());
    tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create());
    viewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
              ProjectAndRepo checkable = (ProjectAndRepo) event.getElement();
              for (TreeItem ti : tree.getItems()) {
                if (ti.getItemCount() > 0
                    || ((ProjectAndRepo) ti.getData()).getRepo().equals("")) // $NON-NLS-1$
                ti.setChecked(false);
                for (TreeItem subTi : ti.getItems()) {
                  IProject project = ((ProjectAndRepo) subTi.getData()).getProject();
                  if (checkable.getProject() != null
                      && !subTi.getData().equals(checkable)
                      && checkable.getProject().equals(project)) subTi.setChecked(false);
                }
              }
            }
          }
        });
    TreeColumn c1 = new TreeColumn(tree, SWT.NONE);
    c1.setText(UIText.ExistingOrNewPage_HeaderProject);
    c1.setWidth(100);
    TreeColumn c2 = new TreeColumn(tree, SWT.NONE);
    c2.setText(UIText.ExistingOrNewPage_HeaderLocation);
    c2.setWidth(400);
    TreeColumn c3 = new TreeColumn(tree, SWT.NONE);
    c3.setText(UIText.ExistingOrNewPage_HeaderRepository);
    c3.setWidth(200);
    boolean allProjectsInExistingRepos = true;
    for (IProject project : myWizard.projects) {
      RepositoryFinder repositoryFinder = new RepositoryFinder(project);
      repositoryFinder.setFindInChildren(false);
      try {
        Collection<RepositoryMapping> mappings;
        mappings = repositoryFinder.find(new NullProgressMonitor());
        Iterator<RepositoryMapping> mi = mappings.iterator();
        RepositoryMapping m = mi.hasNext() ? mi.next() : null;
        if (m == null) {
          // no mapping found, enable repository creation
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          treeItem.setText(2, ""); // $NON-NLS-1$
          treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$
          allProjectsInExistingRepos = false;
        } else if (!mi.hasNext()) {
          // exactly one mapping found
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          fillTreeItemWithGitDirectory(m, treeItem, false);
          treeItem.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString()));
          treeItem.setChecked(true);
        } else {
          TreeItem treeItem = new TreeItem(tree, SWT.NONE);
          updateProjectTreeItem(treeItem, project);
          treeItem.setText(1, project.getLocation().toOSString());
          treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$

          TreeItem treeItem2 = new TreeItem(treeItem, SWT.NONE);
          updateProjectTreeItem(treeItem2, project);
          fillTreeItemWithGitDirectory(m, treeItem2, true);
          treeItem2.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString()));
          while (mi.hasNext()) { // fill in additional mappings
            m = mi.next();
            treeItem2 = new TreeItem(treeItem, SWT.NONE);
            updateProjectTreeItem(treeItem2, project);
            fillTreeItemWithGitDirectory(m, treeItem2, true);
            treeItem2.setData(
                new ProjectAndRepo(
                    m.getContainer().getProject(), m.getGitDirAbsolutePath().toOSString()));
          }
          treeItem.setExpanded(true);
          allProjectsInExistingRepos = false;
        }
      } catch (CoreException e) {
        TreeItem treeItem2 = new TreeItem(tree, SWT.BOLD | SWT.ITALIC);
        treeItem2.setText(e.getMessage());
      }
    }

    createRepo = new Button(parentRepoComposite, SWT.PUSH);
    createRepo.setLayoutData(GridDataFactory.fillDefaults().create());
    createRepo.setText(UIText.ExistingOrNewPage_CreateButton);
    createRepo.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            File gitDir = new File(repositoryToCreate.getText(), Constants.DOT_GIT);
            try {
              Repository repository = FileRepositoryBuilder.create(gitDir);
              repository.create();
              for (IProject project : getProjects(false).keySet()) {
                // If we don't refresh the project directories right
                // now we won't later know that a .git directory
                // exists within it and we won't mark the .git
                // directory as a team-private member. Failure
                // to do so might allow someone to delete
                // the .git directory without us stopping them.
                // (Half lie, we should optimize so we do not
                // refresh when the .git is not within the project)
                //
                if (!gitDir.toString().contains("..")) // $NON-NLS-1$
                project.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
              }
              util.addConfiguredRepository(gitDir);
            } catch (IOException e1) {
              String msg =
                  NLS.bind(
                      UIText.ExistingOrNewPage_ErrorFailedToCreateRepository, gitDir.toString());
              org.eclipse.egit.ui.Activator.handleError(msg, e1, true);
            } catch (CoreException e2) {
              String msg =
                  NLS.bind(UIText.ExistingOrNewPage_ErrorFailedToRefreshRepository, gitDir);
              org.eclipse.egit.ui.Activator.handleError(msg, e2, true);
            }
            for (TreeItem ti : tree.getSelection()) {
              IPath projectPath = new Path(ti.getText(1));
              IPath gitPath = new Path(gitDir.toString());
              IPath relative = gitPath.makeRelativeTo(projectPath);
              ti.setText(2, relative.toOSString());
              ((ProjectAndRepo) ti.getData()).repo = gitDir.toString();
              ti.setChecked(true);
            }
            updateControls();
          }
        });
    repositoryToCreate = new Text(parentRepoComposite, SWT.SINGLE | SWT.BORDER);
    repositoryToCreate.setLayoutData(
        GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
    repositoryToCreate.addListener(
        SWT.Modify,
        new Listener() {
          public void handleEvent(Event e) {
            if (repositoryToCreate.getText().equals("")) { // $NON-NLS-1$
              createRepo.setEnabled(false);
              return;
            }
            IPath fromOSString = Path.fromOSString(repositoryToCreate.getText());
            createRepo.setEnabled(
                minumumPath.matchingFirstSegments(fromOSString) == fromOSString.segmentCount());
          }
        });
    dotGitSegment = new Label(parentRepoComposite, SWT.NONE);
    dotGitSegment.setEnabled(false);
    dotGitSegment.setText(File.separatorChar + Constants.DOT_GIT);
    dotGitSegment.setLayoutData(
        GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());

    tree.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            tree.select((TreeItem) e.item);
            updateControls();
          }
        });

    Dialog.applyDialogFont(main);
    setControl(main);

    if (allProjectsInExistingRepos) {
      internalMode = true;
      internalModeButton.setSelection(true);
      updateControls();
    }
  }
コード例 #14
0
 private void selectionHelper(Boolean active) {
   for (TableItem ti : available.getItems()) {
     if (active == null) ti.setChecked(!ti.getChecked());
     else ti.setChecked(active);
   }
 }
コード例 #15
0
 private void selectAll(boolean select) {
   for (TableItem ti : m_table.getItems()) {
     ti.setChecked(select);
   }
 }
コード例 #16
0
ファイル: LogFileColumn.java プロジェクト: paulcager/andmore
 public void checkAll(boolean selectionValue) {
   for (TableItem item : tableLogFile.getItems()) {
     item.setChecked(selectionValue);
   }
 }