Java 类javax.swing.table.AbstractTableModel 实例源码

项目:incubator-netbeans    文件:SchemaPanel.java   
public void tableChanged(TableModelEvent e) {
    //System.out.println("TBALE changed");
    //boolean prefixFlag = false;
    int row = e.getFirstRow();
    int column = e.getColumn();
    AbstractTableModel tblModel = (AbstractTableModel) e.getSource();
    Object data = tblModel.getValueAt(row, column);
    if(column == SCHEMA_COL) {
        SchemaObject rowValue = (SchemaObject)data;
        if(rowValue.toString().equals(startString))
            return;
        String genPrefix = (String) tblModel.getValueAt(row, PREFIX_COL);
        if (genPrefix == null || genPrefix.equals(" ")  ) {
            String prefix = generateUniquePrefix();               
            tableModel.setValueAt(prefix, row, PREFIX_COL);                 
        }
        if(row == tableModel.getRowCount() - 1) {
            addRow(startString);
        }
        //if its the first row, then select it as primary
        if(row == 0) {
           // System.out.println("added first row");
            tblModel.setValueAt(new Boolean(true), 0, 0);
        }
    } 
}
项目:marathonv5    文件:RTableTest.java   
public void editCell() throws Throwable {
    final JTable table = (JTable) ComponentUtils.findComponent(JTable.class, frame);
    final LoggingRecorder lr = new LoggingRecorder();
    siw(new Runnable() {
        @Override public void run() {
            table.addRowSelectionInterval(2, 2);
            table.addColumnSelectionInterval(2, 2);
            RTable rTable = new RTable(table, null, null, lr);
            rTable.focusGained(null);
            AbstractTableModel model = (AbstractTableModel) table.getModel();
            model.setValueAt("Rowing", 2, 2);
            rTable.focusLost(null);
        }
    });
    List<Call> calls = lr.getCalls();
    Call call = calls.get(1);
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("rows:[2],columns:[Sport]", call.getState());
    call = calls.get(0);
    AssertJUnit.assertEquals("select", call.getFunction());
    AssertJUnit.assertEquals("Rowing", call.getState());
    AssertJUnit.assertEquals("{2, Sport}", call.getCellinfo());
}
项目:ramus    文件:QualifierView.java   
@Override
protected void createInnerComponent() {
    super.createInnerComponent();
    ((AbstractTableModel) component.getTable().getModel())
            .fireTableStructureChanged();
    component.getTable().setLeafIcon(
            new ImageIcon(getClass().getResource(
                    "/com/ramussoft/gui/table/qualifier.png")));
    getComponent().getRowSet().addRowChildListener(new RowChildAdapter() {

        @Override
        public void added(Row parent, Row row, int index) {
            if (parent.getParent() == null)
                return;
            framework.propertyChanged(
                    "CloseQualifier",
                    StandardAttributesPlugin.getQualifierId(engine,
                            parent.getElementId()));
        }
    });
}
项目:intellij-ce-playground    文件:ImportLayoutPanel.java   
private void removeEntryFromImportLayouts() {
  int selected = myImportLayoutTable.getSelectedRow();
  if (selected < 0) {
    return;
  }
  PackageEntry entry = myImportLayoutList.getEntryAt(selected);
  if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
    return;
  }
  TableUtil.stopEditing(myImportLayoutTable);
  myImportLayoutList.removeEntryAt(selected);
  AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
  model.fireTableRowsDeleted(selected, selected);
  if (selected >= myImportLayoutList.getEntryCount()) {
    selected--;
  }
  if (selected >= 0) {
    myImportLayoutTable.setRowSelectionInterval(selected, selected);
  }
}
项目:SE2    文件:EnvehicleInfoTable.java   
public EnvehicleInfoTable(AbstractTableModel model) {
    super(model);
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    this.getTableHeader().setReorderingAllowed(false);
    this.getTableHeader().setResizingAllowed(false);
    setuiInfo();

    this.setRowHeight(height * 22 / 480);
    this.setRowSelectionAllowed(false);

    tc0 = this.columnModel.getColumn(0);
    tc0.setPreferredWidth(width / 3);

    tc1 = this.columnModel.getColumn(1);
    tc1.setPreferredWidth(width / 8);

    tc2 = this.columnModel.getColumn(2);
    tc2.setPreferredWidth(width / 8);

    tc3 = this.columnModel.getColumn(3);
    tc3.setPreferredWidth(width / 8);

    tc4 = this.columnModel.getColumn(4);
    tc4.setPreferredWidth(width / 8);
}
项目:SE2    文件:VehicleManagementInfoTable.java   
public VehicleManagementInfoTable(AbstractTableModel model) {
    super(model);
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    this.getTableHeader().setReorderingAllowed(false);
    this.getTableHeader().setResizingAllowed(false);
    setuiInfo();

    this.setRowHeight(height * 22 / 480);
    this.setRowSelectionAllowed(false);

    tc0 = this.columnModel.getColumn(0);
    tc0.setPreferredWidth(width * 80 / 720);

    tc1 = this.columnModel.getColumn(1);
    tc1.setPreferredWidth(width * 200 / 720);

    tc2 = this.columnModel.getColumn(2);
    tc2.setPreferredWidth(width * 6 / 72);

    tc3 = this.columnModel.getColumn(3);
    tc3.setPreferredWidth(width * 20 / 72);

    tc4 = this.columnModel.getColumn(4);
    tc4.setPreferredWidth(width * 6 / 72);
}
项目:SE2    文件:TransferingInfoTable.java   
public TransferingInfoTable(AbstractTableModel model) {
    super(model);
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    this.getTableHeader().setReorderingAllowed(false);
    this.getTableHeader().setResizingAllowed(false);
    setuiInfo();

    this.setRowHeight(height * 22 / 480);
    this.setRowSelectionAllowed(false);

    tc0 = this.columnModel.getColumn(0);
    tc0.setPreferredWidth(width / 3);

    tc1 = this.columnModel.getColumn(1);
    tc1.setPreferredWidth(width / 8);

    tc2 = this.columnModel.getColumn(2);
    tc2.setPreferredWidth(width / 8);

    tc3 = this.columnModel.getColumn(3);
    tc3.setPreferredWidth(width / 8);

    tc4 = this.columnModel.getColumn(4);
    tc4.setPreferredWidth(width / 8);
}
项目:SE2    文件:EnvehicleInfoTable.java   
public EnvehicleInfoTable(AbstractTableModel model) {
    super(model);
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    this.getTableHeader().setReorderingAllowed(false);
    this.getTableHeader().setResizingAllowed(false);
    setuiInfo();

    this.setRowHeight(height * 22 / 480);
    this.setRowSelectionAllowed(false);

    tc0 = this.columnModel.getColumn(0);
    tc0.setPreferredWidth(width / 3);

    tc1 = this.columnModel.getColumn(1);
    tc1.setPreferredWidth(width / 8);

    tc2 = this.columnModel.getColumn(2);
    tc2.setPreferredWidth(width / 8);

    tc3 = this.columnModel.getColumn(3);
    tc3.setPreferredWidth(width / 8);

    tc4 = this.columnModel.getColumn(4);
    tc4.setPreferredWidth(width / 8);
}
项目:SE2    文件:VehicleManagementInfoTable.java   
public VehicleManagementInfoTable(AbstractTableModel model) {
    super(model);
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    this.getTableHeader().setReorderingAllowed(false);
    this.getTableHeader().setResizingAllowed(false);
    setuiInfo();

    this.setRowHeight(height * 22 / 480);
    this.setRowSelectionAllowed(false);

    tc0 = this.columnModel.getColumn(0);
    tc0.setPreferredWidth(width * 80 / 720);

    tc1 = this.columnModel.getColumn(1);
    tc1.setPreferredWidth(width * 200 / 720);

    tc2 = this.columnModel.getColumn(2);
    tc2.setPreferredWidth(width * 6 / 72);

    tc3 = this.columnModel.getColumn(3);
    tc3.setPreferredWidth(width * 20 / 72);

    tc4 = this.columnModel.getColumn(4);
    tc4.setPreferredWidth(width * 6 / 72);
}
项目:SE2    文件:TransferingInfoTable.java   
public TransferingInfoTable(AbstractTableModel model) {
    super(model);
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    this.getTableHeader().setReorderingAllowed(false);
    this.getTableHeader().setResizingAllowed(false);
    setuiInfo();

    this.setRowHeight(height * 22 / 480);
    this.setRowSelectionAllowed(false);

    tc0 = this.columnModel.getColumn(0);
    tc0.setPreferredWidth(width / 3);

    tc1 = this.columnModel.getColumn(1);
    tc1.setPreferredWidth(width / 8);

    tc2 = this.columnModel.getColumn(2);
    tc2.setPreferredWidth(width / 8);

    tc3 = this.columnModel.getColumn(3);
    tc3.setPreferredWidth(width / 8);

    tc4 = this.columnModel.getColumn(4);
    tc4.setPreferredWidth(width / 8);
}
项目:swingx    文件:TableRowHeightControllerTest.java   
@Test
public void testSetModelRewiresModelListeners() throws InterruptedException, InvocationTargetException {
    final int smallRowHeight = table.getRowHeight(1);
    final AbstractTableModel oldModel = (AbstractTableModel) table.getModel();
    assertEquals("sanity: model listener installed", true, containsModelListener(oldModel));
    final DefaultTableModel model = createTableModel(true);
    table.setModel(model);

    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            assertEquals("new model must be installed", true, containsModelListener(model));
            assertEquals("oldModel must be released", false, containsModelListener(oldModel));
            assertEquals(smallRowHeight, table.getRowHeight(0));
        }
    });

}
项目:mindraider    文件:OutlineArchiveJPanel.java   
public int refresh() {        
    // outline custodian - get discarded models
    if(MindRaider.profile!=null) {
        final URI activeOutlineUri = MindRaider.profile.getActiveOutlineUri();
        if(tableModel!=null) {
            if(activeOutlineUri!=null) {
                ((AbstractTableModel)table.getModel()).fireTableDataChanged();
                table.updateUI();        
                return tableModel.refresh(activeOutlineUri.toString());
            } else {
                tableModel.clear();
            }
        }
    }
    ((AbstractTableModel)table.getModel()).fireTableDataChanged();                
    table.updateUI();        
    return 0;
}
项目:beast-mcmc    文件:TaxonSetPanel.java   
protected void initTaxonSetsTable(AbstractTableModel tableModel, final String[] columnToolTips) {
    taxonSetsTable = new JTable(tableModel) {
        //Implement table header tool tips.
        protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {
                public String getToolTipText(MouseEvent e) {
                    Point p = e.getPoint();
                    int index = columnModel.getColumnIndexAtX(p.x);
                    int realIndex = columnModel.getColumn(index).getModelIndex();
                    return columnToolTips[realIndex];
                }
            };
        }
    };
    taxonSetsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    taxonSetsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            taxonSetsTableSelectionChanged();
        }
    });
    taxonSetsTable.doLayout();
}
项目:onecmdb    文件:MainTemplateBrowser.java   
public void onEvent(Event e) {
    switch(e.getType()) {
        case(CEvents.ITEM_SELECTED):
        {
            String alias = (String) e.getData();
            graphTab.setTitleAt(0, "References to/from " + alias);
            graphTab.setTitleAt(1, "Instances of " + alias);
            tp.setTitleAt(0, "Attributes for " + alias);
            instanceGraph.setInstanceTemplate(alias, null);
            CiBean bean = TemplateModelControl.get(root).getBean(alias);
            if (bean != null) {
                templatePropertyControl.setRoot(new CIModel(bean, bean));
                TableModel tModel = pTree.getModel();
                if (tModel instanceof AbstractTableModel) {
                    ((AbstractTableModel)tModel).fireTableDataChanged();
                }
            }
        }
        break;
    }

}
项目:onecmdb    文件:MainInstanceView.java   
public void onEvent(Event e) {
    switch(e.getType()) {
    case(CEvents.INSTANCE_ITEM_SELECTED):
    {
        String alias = (String) e.getData();
        CiBean bean = gControl.getResult().findOffspringAlias(alias);
        if (bean != null) {
            CiBean templ = bean;
            if (!bean.isTemplate()) {
                templ = TemplateModelControl.get("Root").getBean(bean.getDerivedFrom());
            }
            //tp.setTitleAt(0, "Attributes for " + bean.getDisplayName());
            instancePropertyControl.setRoot(new CIModel(templ, bean));
            TableModel tModel = pTree.getModel();
            if (tModel instanceof AbstractTableModel) {
                ((AbstractTableModel)tModel).fireTableDataChanged();
            }
        }
    }
    break;

    }
}
项目:onecmdb    文件:MainPanel.java   
private void showProperty(String alias) {

    CiBean bean = OneCMDBConnection.instance().getBeanFromAlias(alias);
    CiBean template = null;

    if (bean == null) {
        return;
    }
    if (bean.isTemplate()) {
        template = bean;
    } else {
        template = OneCMDBConnection.instance().getBeanFromAlias(bean.getDerivedFrom());
    }

    CIModel model = new CIModel(template, bean);

    propertyControl.setRoot(model);
    TableModel tModel = pTree.getModel();
    if (tModel instanceof AbstractTableModel) {
        ((AbstractTableModel)tModel).fireTableDataChanged();
    }

}
项目:onecmdb    文件:MainTemplateBrowser.java   
public void onEvent(Event e) {
    switch(e.getType()) {
        case(CEvents.ITEM_SELECTED):
        {
            String alias = (String) e.getData();
            graphTab.setTitleAt(0, "References to/from " + alias);
            graphTab.setTitleAt(1, "Instances of " + alias);
            tp.setTitleAt(0, "Attributes for " + alias);
            instanceGraph.setInstanceTemplate(alias);
            CiBean bean = TemplateModel.get(root).getBean(alias);
            if (bean != null) {
                templatePropertyControl.setRoot(new CIModel(bean, bean));
                TableModel tModel = pTree.getModel();
                if (tModel instanceof AbstractTableModel) {
                    ((AbstractTableModel)tModel).fireTableDataChanged();
                }
            }
        }
        break;
    }

}
项目:rtl    文件:SelectedAssociationPathView.java   
/**
 * Method initSelectedAssociationPathView initialize the layout of the view 
 * and add the Button "Reset", which pre-defined values can be reset.
 */
void initView(AbstractTableModel model) {
    fTableModel = model; 
    fTable = new JTable(fTableModel); 
    fTable.setPreferredScrollableViewportSize(new Dimension(250, 70));
    fTablePane = new JScrollPane(fTable);

    fBtnReset = new JButton("Reset");
    fBtnReset.setMnemonic('R');
    fBtnReset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            update();
        }
    });
    buttonPane.remove(buttonPane.getComponentCount()-1);
    buttonPane.add(fBtnReset);
    add(fTablePane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.SOUTH);
}
项目:rtl    文件:SelectedClassPathView.java   
/**
 * initSelectionClassPathView initialize the layout of view and add a Button "Reset", 
 * which pre-defined values can be reset.
 */
void initView(AbstractTableModel model) {
    fTableModel = model;
    fTable = new JTable(fTableModel);
    fTable.setPreferredScrollableViewportSize(new Dimension(250, 70));
    fTablePane = new JScrollPane(fTable);

    fBtnReset = new JButton("Reset");
    fBtnReset.setMnemonic('R');
    fBtnReset.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            update();
        }
    });
    buttonPane.add(fBtnReset);

    add(fTablePane, BorderLayout.CENTER);
    add(buttonPane, BorderLayout.SOUTH);
}
项目:studio    文件:QGrid.java   
public void append(K.KBase upd) {
    int n = table.getRowCount();
    if (model instanceof FlipTableModel) {
        K.Flip flip=(Flip) upd;
        ((FlipTableModel) model).append(flip);
        ((AbstractTableModel) model).fireTableRowsInserted(n,table.getRowCount() - n);
        if (scrollToEnd)
            table.scrollRectToVisible(new Rectangle(0,
                                                    table.getRowHeight() * (table.getRowCount()),
                                                    100,
                                                    table.getRowHeight()));

    }else if (model instanceof DictTableModel) {
        K.Dict dict=(Dict) upd;
        ((DictTableModel) model).upsert(dict);
        ((AbstractTableModel) model).fireTableRowsInserted(0,table.getRowCount());
        if (scrollToEnd)
            table.scrollRectToVisible(new Rectangle(0,
                                                    table.getRowHeight() * (table.getRowCount()),
                                                    100,
                                                    table.getRowHeight()));

    }
}
项目:OneCMDBwithMaven    文件:MainTemplateBrowser.java   
public void onEvent(Event e) {
    switch(e.getType()) {
        case(CEvents.ITEM_SELECTED):
        {
            String alias = (String) e.getData();
            graphTab.setTitleAt(0, "References to/from " + alias);
            graphTab.setTitleAt(1, "Instances of " + alias);
            tp.setTitleAt(0, "Attributes for " + alias);
            instanceGraph.setInstanceTemplate(alias, null);
            CiBean bean = TemplateModelControl.get(root).getBean(alias);
            if (bean != null) {
                templatePropertyControl.setRoot(new CIModel(bean, bean));
                TableModel tModel = pTree.getModel();
                if (tModel instanceof AbstractTableModel) {
                    ((AbstractTableModel)tModel).fireTableDataChanged();
                }
            }
        }
        break;
    }

}
项目:OneCMDBwithMaven    文件:MainInstanceView.java   
public void onEvent(Event e) {
    switch(e.getType()) {
    case(CEvents.INSTANCE_ITEM_SELECTED):
    {
        String alias = (String) e.getData();
        CiBean bean = gControl.getResult().findOffspringAlias(alias);
        if (bean != null) {
            CiBean templ = bean;
            if (!bean.isTemplate()) {
                templ = TemplateModelControl.get("Root").getBean(bean.getDerivedFrom());
            }
            //tp.setTitleAt(0, "Attributes for " + bean.getDisplayName());
            instancePropertyControl.setRoot(new CIModel(templ, bean));
            TableModel tModel = pTree.getModel();
            if (tModel instanceof AbstractTableModel) {
                ((AbstractTableModel)tModel).fireTableDataChanged();
            }
        }
    }
    break;

    }
}
项目:tools-idea    文件:ImportLayoutPanel.java   
private void removeEntryFromImportLayouts() {
  int selected = myImportLayoutTable.getSelectedRow();
  if (selected < 0) {
    return;
  }
  PackageEntry entry = myImportLayoutList.getEntryAt(selected);
  if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
    return;
  }
  TableUtil.stopEditing(myImportLayoutTable);
  myImportLayoutList.removeEntryAt(selected);
  AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
  model.fireTableRowsDeleted(selected, selected);
  if (selected >= myImportLayoutList.getEntryCount()) {
    selected--;
  }
  if (selected >= 0) {
    myImportLayoutTable.setRowSelectionInterval(selected, selected);
  }
}
项目:com.opendoorlogistics    文件:ColumnSelectorComboBox.java   
private static String getColumnName(int col){
    class TmpCls extends AbstractTableModel{

        @Override
        public int getRowCount() {
            // TODO Auto-generated method stub
            return 0;
        }

        @Override
        public int getColumnCount() {
            // TODO Auto-generated method stub
            return 0;
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            // TODO Auto-generated method stub
            return null;
        }

    }
    TmpCls cls = new TmpCls();
    return cls.getColumnName(col);
}
项目:cursus-ui    文件:DatabaseTableModel.java   
private TableModel getRealModel() {
    // The sorter needs to get a real view of the data
    // otherwise it'll sort on the row object itself
    return new AbstractTableModel() {
        @Override
        public Object getValueAt(int mRow, int mCol) {
            return columns.get(mCol).getValue(rows.get(mRow), false);
        }

        @Override
        public int getRowCount() {
            return DatabaseTableModel.this.getRowCount();
        }

        @Override
        public int getColumnCount() {
            return DatabaseTableModel.this.getColumnCount();
        }
    };
}
项目:Joeffice    文件:TableStyleable.java   
@Override
public void setFontAttributes(AttributedString attributes) {
    SpreadsheetTopComponent currentTopComponent = OfficeTopComponent.getSelectedComponent(SpreadsheetTopComponent.class);
    if (currentTopComponent != null) {
        JTable table = currentTopComponent.getSelectedTable();

        List<Cell> selectedCells = CellUtils.getSelectedCells(table);
        for (Cell cell : selectedCells) {
            AttributedCharacterIterator attributesIterator = attributes.getIterator();
            for (Attribute attribute : attributesIterator.getAllAttributeKeys()) {
                Object value = attributesIterator.getAttribute(attribute);
                addAttribute(attribute, value, cell);
                ((AbstractTableModel) table.getModel()).fireTableCellUpdated(cell.getRowIndex(), cell.getColumnIndex());
            }
        }
    }
}
项目:PerfCakeIDEA-deprecated    文件:PeriodAddAction.java   
@Override
public void actionPerformed(ActionEvent e) {
    final Destination mockCopy = PerfCakeIdeaUtil.runCreateMockCopy(destination);

    final Period newPeriod = mockCopy.addPeriod();
    final PeriodDialog addDialog = new PeriodDialog(parent, newPeriod, Mode.ADD);
    boolean ok = addDialog.showAndGet();
    if (ok) {

        final Project project = mockCopy.getModule() == null ? null : mockCopy.getModule().getProject();
        final PsiFile containingFile = mockCopy.getXmlElement() == null ? null : mockCopy.getXmlElement().getContainingFile();

        new WriteCommandAction(project, "Add Period", containingFile) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                newPeriod.copyFrom(addDialog.getMockCopy());
                destination.copyFrom(mockCopy);
            }
        }.execute();
        //update changes in tables
        if (parent instanceof JTable) {
            JTable table = (JTable) parent;
            ((AbstractTableModel) table.getModel()).fireTableDataChanged();
        }
    }
}
项目:PerfCakeIDEA-deprecated    文件:EditAction.java   
@Override
public void actionPerformed(ActionEvent e) {
    final T mockCopy = PerfCakeIdeaUtil.runCreateMockCopy(domElement);
    final MyDialogWrapper dialog = DialogFactory.createDialogForElement(mockCopy, parent, Mode.EDIT);
    boolean ok = dialog.showAndGet();

    if (ok) {
        final Project project = mockCopy.getModule() == null ? null : mockCopy.getModule().getProject();
        final PsiFile containingFile = mockCopy.getXmlElement() == null ? null : mockCopy.getXmlElement().getContainingFile();

        new WriteCommandAction(project, (String) getValue(Action.NAME), containingFile) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                domElement.copyFrom(dialog.getMockCopy());
            }
        }.execute();
    }
    //update changes in tables
    if (parent instanceof JTable) {
        JTable table = (JTable) parent;
        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
    }
}
项目:PerfCakeIDEA-deprecated    文件:PropertyAddAction.java   
@Override
public void actionPerformed(ActionEvent e) {

    final IProperties mockCopy = PerfCakeIdeaUtil.runCreateMockCopy(properties);

    final Property newProperty = mockCopy.addProperty();
    final PropertyDialog editDialog = new PropertyDialog(parent, newProperty, Mode.ADD);
    boolean ok = editDialog.showAndGet();
    if (ok) {
        final Project project = newProperty.getModule() == null ? null : newProperty.getModule().getProject();
        final PsiFile containingFile = newProperty.getXmlElement() == null ? null : newProperty.getXmlElement().getContainingFile();

        new WriteCommandAction(project, "Add Property", containingFile) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                newProperty.copyFrom(editDialog.getMockCopy());
                properties.copyFrom(mockCopy);
            }
        }.execute();
        //update changes in tables
        if (parent instanceof JTable) {
            JTable table = (JTable) parent;
            ((AbstractTableModel) table.getModel()).fireTableDataChanged();
        }
    }
}
项目:PerfCakeIDEA-deprecated    文件:DestinationAddAction.java   
@Override
public void actionPerformed(ActionEvent e) {
    final Reporter mockCopy = PerfCakeIdeaUtil.runCreateMockCopy(reporter);
    final Destination newDestination = mockCopy.addDestination();
    final DestinationDialog editDialog = new DestinationDialog(parent, newDestination, Mode.ADD);
    boolean ok = editDialog.showAndGet();
    if (ok) {

        final Project project = mockCopy.getModule() == null ? null : mockCopy.getModule().getProject();
        final PsiFile containingFile = mockCopy.getXmlElement().getContainingFile();

        new WriteCommandAction(project, "Add Destination", containingFile) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                newDestination.copyFrom(editDialog.getMockCopy());
                reporter.copyFrom(mockCopy);
            }
        }.execute();
    } //update changes in tables
    if (parent instanceof JTable) {
        JTable table = (JTable) parent;
        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
    }
}
项目:PerfCakeIDEA-deprecated    文件:HeaderAddAction.java   
@Override
public void actionPerformed(ActionEvent e) {
    final Message mockCopy = PerfCakeIdeaUtil.runCreateMockCopy(message);

    final Header newHeader = mockCopy.addHeader();
    final HeaderDialog addDialog = new HeaderDialog(parent, newHeader, Mode.ADD);
    boolean ok = addDialog.showAndGet();
    if (ok) {

        final Project project = mockCopy.getModule() == null ? null : mockCopy.getModule().getProject();
        final PsiFile containingFile = mockCopy.getXmlElement() == null ? null : mockCopy.getXmlElement().getContainingFile();

        new WriteCommandAction(project, "Add Header", containingFile) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                newHeader.copyFrom(addDialog.getMockCopy());
                message.copyFrom(mockCopy);
            }
        }.execute();
        //update changes in tables
        if (parent instanceof JTable) {
            JTable table = (JTable) parent;
            ((AbstractTableModel) table.getModel()).fireTableDataChanged();
        }
    }
}
项目:PerfCakeIDEA-deprecated    文件:DeleteAction.java   
@Override
public void actionPerformed(ActionEvent e) {
    final Project project = toDelete.get(0).getModule() == null ? null : toDelete.get(0).getModule().getProject();
    final PsiFile containingFile = toDelete.get(0).getXmlElement().getContainingFile();

    new WriteCommandAction(project, (String) getValue(Action.NAME), containingFile) {
        @Override
        protected void run(@NotNull Result result) throws Throwable {
            for (T element : toDelete) {
                element.undefine();
            }
        }
    }.execute();
    if (parent instanceof JTable) {
        JTable table = (JTable) parent;
        ((AbstractTableModel) table.getModel()).fireTableDataChanged();
    }
}
项目:ieo-beast    文件:TaxonSetPanel.java   
protected void initTaxonSetsTable(AbstractTableModel tableModel, final String[] columnToolTips) {
    taxonSetsTable = new JTable(tableModel) {
        //Implement table header tool tips.
        protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {
                public String getToolTipText(MouseEvent e) {
                    Point p = e.getPoint();
                    int index = columnModel.getColumnIndexAtX(p.x);
                    int realIndex = columnModel.getColumn(index).getModelIndex();
                    return columnToolTips[realIndex];
                }
            };
        }
    };
    taxonSetsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    taxonSetsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            taxonSetsTableSelectionChanged();
        }
    });
    taxonSetsTable.doLayout();
}
项目:consulo-java    文件:ImportLayoutPanel.java   
private void removeEntryFromImportLayouts() {
  int selected = myImportLayoutTable.getSelectedRow();
  if (selected < 0) {
    return;
  }
  PackageEntry entry = myImportLayoutList.getEntryAt(selected);
  if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY || entry == PackageEntry.ALL_OTHER_IMPORTS_ENTRY) {
    return;
  }
  TableUtil.stopEditing(myImportLayoutTable);
  myImportLayoutList.removeEntryAt(selected);
  AbstractTableModel model = (AbstractTableModel)myImportLayoutTable.getModel();
  model.fireTableRowsDeleted(selected, selected);
  if (selected >= myImportLayoutList.getEntryCount()) {
    selected--;
  }
  if (selected >= 0) {
    myImportLayoutTable.setRowSelectionInterval(selected, selected);
  }
}
项目:consulo-java    文件:EditMigrationDialog.java   
private void edit()
{
    EditMigrationEntryDialog dialog = new EditMigrationEntryDialog(myProject);
    int selected = myTable.getSelectedRow();
    if(selected < 0)
    {
        return;
    }
    MigrationMapEntry entry = myMigrationMap.getEntryAt(selected);
    dialog.setEntry(entry);
    if(!dialog.showAndGet())
    {
        return;
    }
    dialog.updateEntry(entry);
    AbstractTableModel model = (AbstractTableModel) myTable.getModel();
    model.fireTableRowsUpdated(selected, selected);
}
项目:consulo-java    文件:EditMigrationDialog.java   
private void removeRow()
{
    int selected = myTable.getSelectedRow();
    if(selected < 0)
    {
        return;
    }
    myMigrationMap.removeEntryAt(selected);
    AbstractTableModel model = (AbstractTableModel) myTable.getModel();
    model.fireTableRowsDeleted(selected, selected);
    if(selected >= myMigrationMap.getEntryCount())
    {
        selected--;
    }
    if(selected >= 0)
    {
        myTable.setRowSelectionInterval(selected, selected);
    }
}
项目:STAR-Vote    文件:TableTransferHandler.java   
/**
 * Records the target selected index. Fails if the indices are the same
 */
@Override
protected void importString(JComponent c, String str) {

    JTable target = (JTable) c;
    AbstractTableModel model = (AbstractTableModel) target.getModel();

    /* Pull the selected row */
    addIndex = target.getSelectedRow();

    /* Check if the indices are the same and, if so, set them to -1 and return */
    if (remIndex == addIndex) {
        remIndex = -1;
        addIndex = -1;
        return;
    }

    /* Check to make sure not out of bounds, and, if so, puts it at the end */
    int max = model.getRowCount();
    if (addIndex < 0 || addIndex > max - 1)
        addIndex = max - 1;
}
项目:incubator-netbeans    文件:ETableTest.java   
/**
 * Test that table can be sorted just after a column has been removed. See
 * bug 239045.
 */
public void testRemoveSortedColumn() {
    ETable t = new ETable();
    final int[] size = new int[]{10, 4};
    TableModel tm = new AbstractTableModel() {

        @Override
        public int getRowCount() {
            return size[0];
        }

        @Override
        public int getColumnCount() {
            return size[1];
        }

        @Override
        public Object getValueAt(int rowIndex, int columnIndex) {
            if (rowIndex < size[0] && columnIndex < size[1]) {
                return rowIndex;
            } else {
                throw new IndexOutOfBoundsException();
            }
        }
    };
    t.setModel(tm);
    ETableColumnModel etcm = (ETableColumnModel) t.getColumnModel();
    ETableColumn etc = (ETableColumn) etcm.getColumn(3);
    etcm.toggleSortedColumn(etc, true);
    size[1] = 3;
    t.sortAndFilter();
}
项目:rapidminer    文件:ExampleSourceConfigurationWizardDataTable.java   
public void update() {
    ((AbstractTableModel) getModel()).fireTableStructureChanged();
    TableColumnModel columnModel = getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount(); i++) {
        TableColumn tableColumn = columnModel.getColumn(i);
        tableColumn.setPreferredWidth(120);
    }
}
项目:rapidminer    文件:ExampleSourceConfigurationWizardAttributeTypeTable.java   
public void update() {
    ((AbstractTableModel) getModel()).fireTableStructureChanged();
    TableColumnModel columnModel = getColumnModel();
    for (int i = 0; i < columnModel.getColumnCount(); i++) {
        TableColumn tableColumn = columnModel.getColumn(i);
        tableColumn.setPreferredWidth(120);
    }
}