Java Code Examples for org.eclipse.jface.viewers.TableViewer#getSelection()

The following examples show how to use org.eclipse.jface.viewers.TableViewer#getSelection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntroduceParameterObjectWizard.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void updateButtons(final TableViewer tv, Button upButton, Button downButton, Button editButton) {
	IStructuredSelection selection= (IStructuredSelection) tv.getSelection();
	ParameterInfo firstElement= (ParameterInfo) selection.getFirstElement();
	if (selection.isEmpty()) {
		upButton.setEnabled(false);
		downButton.setEnabled(false);
		editButton.setEnabled(false);
	} else {
		int[] selectionIndex= tv.getTable().getSelectionIndices();
		upButton.setEnabled(selectionIndex[0] != 0);
		downButton.setEnabled(selectionIndex[selectionIndex.length-1] != tv.getTable().getItemCount() - 1);
		editButton.setEnabled(firstElement.isCreateField() && selectionIndex.length==1);
	}
	fProcessor.updateParameterPosition();
	updateSignaturePreview();
}
 
Example 2
Source File: UnDefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void handleUnDefineEditButton(TableViewer tableViewer) {
  final IStructuredSelection selection = (IStructuredSelection) tableViewer
      .getSelection();
  if (selection.size() == 1) {
    Object cmakeDefine = selection.getFirstElement();
    // edit the selected variable in-place..
    final Shell shell = tableViewer.getControl().getShell();
    AddCmakeUndefineDialog dlg = new AddCmakeUndefineDialog(shell,
        (CmakeUnDefine) cmakeDefine);
    if (dlg.open() == Dialog.OK) {
      tableViewer.update(cmakeDefine, null); // updates the display
    }
  }
}
 
Example 3
Source File: UnDefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void handleUnDefineDelButton(TableViewer tableViewer) {
  final IStructuredSelection selection = (IStructuredSelection) tableViewer
      .getSelection();
  final Shell shell = tableViewer.getControl().getShell();
  if (MessageDialog.openQuestion(shell,
      "CMake-Undefine deletion confirmation",
      "Are you sure to delete the selected CMake-undefines?")) {
    @SuppressWarnings("unchecked")
    ArrayList<String> undefines = (ArrayList<String>) tableViewer.getInput();
    undefines.removeAll(selection.toList());
    tableViewer.remove(selection.toArray());// updates the display
  }
}
 
Example 4
Source File: DefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void handleDefineEditButton(TableViewer tableViewer) {
  final IStructuredSelection selection = (IStructuredSelection) tableViewer
      .getSelection();
  if (selection.size() == 1) {
    Object cmakeDefine = selection.getFirstElement();
    // edit the selected variable in-place..
    final Shell shell = tableViewer.getControl().getShell();
    AddCmakeDefineDialog dlg = new AddCmakeDefineDialog(shell,
        cfgd, (CmakeDefine) cmakeDefine);
    if (dlg.open() == Dialog.OK) {
      tableViewer.update(cmakeDefine, null); // updates the display
    }
  }
}
 
Example 5
Source File: DefinesViewer.java    From cmake4eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void handleDefineDelButton(TableViewer tableViewer) {
  final IStructuredSelection selection = (IStructuredSelection) tableViewer
      .getSelection();
  final Shell shell = tableViewer.getControl().getShell();
  if (MessageDialog.openQuestion(shell, "CMake-Define deletion confirmation",
      "Are you sure to delete the selected CMake-defines?")) {
    @SuppressWarnings("unchecked")
    ArrayList<CmakeDefine> defines = (ArrayList<CmakeDefine>) tableViewer
        .getInput();
    defines.removeAll(selection.toList());
    tableViewer.remove(selection.toArray());// updates the display
  }
}