当前位置: 首页>>代码示例>>Java>>正文


Java JBTable.setSelectionMode方法代码示例

本文整理汇总了Java中com.intellij.ui.table.JBTable.setSelectionMode方法的典型用法代码示例。如果您正苦于以下问题:Java JBTable.setSelectionMode方法的具体用法?Java JBTable.setSelectionMode怎么用?Java JBTable.setSelectionMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.ui.table.JBTable的用法示例。


在下文中一共展示了JBTable.setSelectionMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initComponent

import com.intellij.ui.table.JBTable; //导入方法依赖的package包/类
@Override
public void initComponent() {
    model = new DateTimeTableModel();

    final KeyStroke shortcutPaste = KeymapUtil.getKeyStroke(CommonShortcuts.getPaste());
    final DateTimeColumnModel columns = new DateTimeColumnModel("Unix timestamp (ms)", "Datetime", "Format");

    final ComboBox defaultPatterns = new ComboBox(DateTimePattern.getPatterns());
    defaultPatterns.setEditable(true);
    columns.getColumn(2).setCellEditor(new DefaultCellEditor(defaultPatterns));

    final JBTable table = new JBTable(model, columns);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setAutoCreateRowSorter(true);
    table.registerKeyboardAction(e -> model.addRows(DateTimeUtil.getClipboardDateTimes()), shortcutPaste, JComponent.WHEN_FOCUSED);

    final JBScrollPane scrollPane = new JBScrollPane(table);

    final DefaultActionGroup group = new DefaultActionGroup();
    group.add(new AddRowAction(model));
    group.add(new DeleteRowAction(model, table));

    final SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false);

    final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("datetimeconverterbar", group, false);
    toolbar.setTargetComponent(panel);

    panel.add(scrollPane);
    panel.setToolbar(toolbar.getComponent());

    component = panel;
}
 
开发者ID:imgruntw,项目名称:date-time-converter-plugin,代码行数:33,代码来源:DateTimeConverterView.java

示例2: init

import com.intellij.ui.table.JBTable; //导入方法依赖的package包/类
public void init() {
  setLayout(new BorderLayout());
  myTable = new JBTable();
  myTextArea = new JTextArea(0, 0);
  myTextArea.setEditable(false);
  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable);
  mySplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, scrollPane, ScrollPaneFactory.createScrollPane(myTextArea));
  add(mySplitPane, BorderLayout.CENTER);
  add(createToolbar(), BorderLayout.WEST);
  final DefaultTableModel model = new DefaultTableModel(createTableModel(new HashMap<String, String>()), new Object[]{"Name", "Value"}) {
    public boolean isCellEditable(final int row, final int column) {
      return false;
    }
  };
  myTable.setModel(model);
  myTable.setShowVerticalLines(true);
  myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      int index = myTable.getSelectedRow();
      if (index >= 0) {
        Object value = myTable.getValueAt(index, 1);
        if (value instanceof String) {
          myTextArea.setText(((String) value));
        } else {
          myTextArea.setText("");
        }
      } else {
        myTextArea.setText("");
      }
    }
  });
  myPopupActionGroup = createPopup();
  PopupHandler.installPopupHandler(myTable, myPopupActionGroup, ActionPlaces.UNKNOWN, ActionManager.getInstance());
  PopupHandler.installPopupHandler(scrollPane, myPopupActionGroup, ActionPlaces.UNKNOWN, ActionManager.getInstance());
  final Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_CLOSE_ACTIVE_TAB);
  myCloseAction.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), this);
  myRefreshAction.registerCustomShortcutSet(CommonShortcuts.getRerun(), this);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:PropertiesComponent.java

示例3: createVariablesTable

import com.intellij.ui.table.JBTable; //导入方法依赖的package包/类
private JComponent createVariablesTable() {
  final String[] names = {
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined")
  };

  // Create a model of the data.
  TableModel dataModel = new VariablesModel(names);

  // Create the table
  myTable = new JBTable(dataModel);
  myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
  myTable.getColumn(names[0]).setPreferredWidth(120);
  myTable.getColumn(names[1]).setPreferredWidth(200);
  myTable.getColumn(names[2]).setPreferredWidth(200);
  myTable.getColumn(names[3]).setPreferredWidth(100);
  if (myVariables.size() > 0) {
    myTable.getSelectionModel().setSelectionInterval(0, 0);
  }

  ComboBox comboField = new ComboBox();
  Macro[] macros = MacroFactory.getMacros();
  Arrays.sort(macros, new Comparator<Macro> () {
    @Override
    public int compare(@NotNull Macro m1, @NotNull Macro m2) {
      return m1.getPresentableName().compareTo(m2.getPresentableName());
    }
  });
  eachMacro:
  for (Macro macro : macros) {
    for (TemplateContextType contextType : myContextTypes) {
      if (macro.isAcceptableInContext(contextType)) {
        comboField.addItem(macro.getPresentableName());
        continue eachMacro;
      }
    }
  }
  comboField.setEditable(true);
  DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
  cellEditor.setClickCountToStart(1);
  myTable.getColumn(names[1]).setCellEditor(cellEditor);
  myTable.setRowHeight(comboField.getPreferredSize().height);

  JTextField textField = new JTextField();

  /*textField.addMouseListener(
    new PopupHandler(){
      public void invokePopup(Component comp,int x,int y){
        showCellPopup((JTextField)comp,x,y);
      }
    }
  );*/

  cellEditor = new DefaultCellEditor(textField);
  cellEditor.setClickCountToStart(1);
  myTable.setDefaultEditor(String.class, cellEditor);

  final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
  return decorator.createPanel();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:64,代码来源:EditVariableDialog.java

示例4: GitRebaseEditor

import com.intellij.ui.table.JBTable; //导入方法依赖的package包/类
protected GitRebaseEditor(@NotNull Project project, @NotNull VirtualFile gitRoot, @NotNull List<GitRebaseEntry> entries)
  throws IOException {
  super(project, true);
  myProject = project;
  myRoot = gitRoot;
  setTitle(GitBundle.getString("rebase.editor.title"));
  setOKButtonText(GitBundle.getString("rebase.editor.button"));

  myTableModel = new MyTableModel(entries);
  myCommitsTable = new JBTable(myTableModel);
  myCommitsTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
  myCommitsTable.setIntercellSpacing(JBUI.emptySize());

  final JComboBox editorComboBox = new ComboBox();
  for (Object option : GitRebaseEntry.Action.values()) {
    editorComboBox.addItem(option);
  }
  TableColumn actionColumn = myCommitsTable.getColumnModel().getColumn(MyTableModel.ACTION_COLUMN);
  actionColumn.setCellEditor(new DefaultCellEditor(editorComboBox));
  actionColumn.setCellRenderer(ComboBoxTableCellRenderer.INSTANCE);

  myCommitsTable.setDefaultRenderer(String.class, new ColoredTableCellRenderer() {
    @Override
    protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
      if (value != null) {
        append(value.toString());
        SpeedSearchUtil.applySpeedSearchHighlighting(myCommitsTable, this, true, selected);
      }
    }
  });

  myTableModel.addTableModelListener(new TableModelListener() {
    public void tableChanged(final TableModelEvent e) {
      validateFields();
    }
  });

  installSpeedSearch();
  myCopyProvider = new MyCopyProvider();

  adjustColumnWidth(0);
  adjustColumnWidth(1);
  init();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:GitRebaseEditor.java

示例5: createVariablesTable

import com.intellij.ui.table.JBTable; //导入方法依赖的package包/类
private JComponent createVariablesTable() {
  final String[] names = {
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined")
  };

  // Create a model of the data.
  TableModel dataModel = new VariablesModel(names);

  // Create the table
  myTable = new JBTable(dataModel);
  myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
  myTable.getColumn(names[0]).setPreferredWidth(120);
  myTable.getColumn(names[1]).setPreferredWidth(200);
  myTable.getColumn(names[2]).setPreferredWidth(200);
  myTable.getColumn(names[3]).setPreferredWidth(100);
  if (myVariables.size() > 0) {
    myTable.getSelectionModel().setSelectionInterval(0, 0);
  }

  JComboBox comboField = new JComboBox();
  Macro[] macros = MacroFactory.getMacros();
  Arrays.sort(macros, new Comparator<Macro> () {
    @Override
    public int compare(Macro m1, Macro m2) {
      return m1.getPresentableName().compareTo(m2.getPresentableName());
    }
  });
  eachMacro:
  for (Macro macro : macros) {
    for (TemplateContextType contextType : myContextTypes) {
      if (macro.isAcceptableInContext(contextType)) {
        comboField.addItem(macro.getPresentableName());
        continue eachMacro;
      }
    }
  }
  comboField.setEditable(true);
  DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
  cellEditor.setClickCountToStart(1);
  myTable.getColumn(names[1]).setCellEditor(cellEditor);
  myTable.setRowHeight(comboField.getPreferredSize().height);

  JTextField textField = new JTextField();

  /*textField.addMouseListener(
    new PopupHandler(){
      public void invokePopup(Component comp,int x,int y){
        showCellPopup((JTextField)comp,x,y);
      }
    }
  );*/

  cellEditor = new DefaultCellEditor(textField);
  cellEditor.setClickCountToStart(1);
  myTable.setDefaultEditor(String.class, cellEditor);

  final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
  return decorator.createPanel();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:64,代码来源:EditVariableDialog.java

示例6: CruciblePanel

import com.intellij.ui.table.JBTable; //导入方法依赖的package包/类
public CruciblePanel(@NotNull final Project project) {
  super(false);
  myProject = project;

  final JBSplitter splitter = new JBSplitter(false, 0.2f);

  myReviewModel = new CrucibleReviewModel(project);
  myReviewTable = new JBTable(myReviewModel);
  myReviewTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myReviewTable.setStriped(true);
  myReviewTable.setExpandableItemsEnabled(false);

  final TableColumnModel columnModel = myReviewTable.getColumnModel();
  columnModel.getColumn(1).setCellRenderer(new DescriptionCellRenderer());

  setUpColumnWidths(myReviewTable);
  myReviewTable.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() == 2) {
        final int viewRow = myReviewTable.getSelectedRow();
        if (viewRow >= 0 &&  viewRow < myReviewTable.getRowCount()) {
          ApplicationManager.getApplication().invokeLater(new Runnable() {
            @Override
            public void run() {
              final Review review =
                CrucibleManager.getInstance(myProject).getDetailsForReview((String)myReviewTable.
                  getValueAt(viewRow, myReviewTable.getColumnModel().getColumnIndex(CrucibleBundle.message("crucible.id"))));
              if (review != null) {
                openDetailsToolWindow(review);
                myReviewTable.clearSelection();
              }
            }
          }, ModalityState.stateForComponent(myReviewTable));

        }
      }
  }});

  final TableRowSorter<TableModel> rowSorter = new TableRowSorter<TableModel>(myReviewModel);
  rowSorter.setSortKeys(Collections.singletonList(new RowSorter.SortKey(4, SortOrder.ASCENDING)));
  rowSorter.sort();
  myReviewTable.setRowSorter(rowSorter);

  final JScrollPane detailsScrollPane = ScrollPaneFactory.createScrollPane(myReviewTable);

  final SimpleTreeStructure reviewTreeStructure = createTreeStructure();
  final DefaultTreeModel model = new CrucibleTreeModel();
  final SimpleTree reviewTree = new SimpleTree(model);

  new AbstractTreeBuilder(reviewTree, model, reviewTreeStructure, null);
  reviewTree.invalidate();

  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(reviewTree);
  splitter.setFirstComponent(scrollPane);
  splitter.setSecondComponent(detailsScrollPane);
  setContent(splitter);
}
 
开发者ID:ktisha,项目名称:Crucible4IDEA,代码行数:58,代码来源:CruciblePanel.java


注:本文中的com.intellij.ui.table.JBTable.setSelectionMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。