List of usage examples for javax.swing DropMode ON
DropMode ON
To view the source code for javax.swing DropMode ON.
Click Source Link
From source file:org.wandora.application.gui.OccurrenceTableSingleType.java
/** Creates a new instance of OccurrenceTableSingleType */ public OccurrenceTableSingleType(Topic topic, Topic type, Options options, Wandora wandora) throws TopicMapException { this.wandora = wandora; this.topic = topic; TopicMap tm = wandora.getTopicMap(); try {//from w w w .j av a 2s . c o m Options opts = options; if (opts == null) opts = wandora.getOptions(); if (opts != null) { tableType = opts.get(VIEW_OPTIONS_KEY); if (tableType == null || tableType.length() == 0) tableType = VIEW_SCHEMA; defaultRowHeight = opts.getInt(ROW_HEIGHT_OPTIONS_KEY); } } catch (Exception e) { e.printStackTrace(); } this.type = type; HashSet<Topic> langSet = new LinkedHashSet(); if (VIEW_USED.equalsIgnoreCase(tableType) || VIEW_USED_AND_SCHEMA.equalsIgnoreCase(tableType)) { Hashtable<Topic, String> occs = null; Topic langTopic = null; occs = topic.getData(type); for (Enumeration<Topic> keys = occs.keys(); keys.hasMoreElements();) { langTopic = keys.nextElement(); langSet.add(langTopic); } } if (VIEW_SCHEMA.equalsIgnoreCase(tableType) || VIEW_USED_AND_SCHEMA.equalsIgnoreCase(tableType)) { Collection<Topic> langTopics = tm.getTopicsOfType(LANGUAGE_SI); langSet.addAll(langTopics); } langs = langSet.toArray(new Topic[langSet.size()]); data = new String[langs.length]; originalData = new String[langs.length]; colors = new Color[langs.length]; for (int j = 0; j < langs.length; j++) { if (langs[j] != null) { data[j] = topic.getData(type, langs[j]); if (data[j] == null) data[j] = ""; originalData[j] = data[j]; colors[j] = wandora.topicHilights.getOccurrenceColor(topic, type, langs[j]); } } dataModel = new DataTableModel(); sorter = new TableRowSorter(dataModel); final TableCellRenderer oldRenderer = this.getTableHeader().getDefaultRenderer(); this.getTableHeader().setPreferredSize(new Dimension(100, 23)); this.getTableHeader().setDefaultRenderer(new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = oldRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); return c; } }); this.setAutoCreateColumnsFromModel(false); TableColumn column = new TableColumn(0, 40, new TopicCellRenderer(), new TopicCellEditor()); this.addColumn(column); column = new TableColumn(1, 400, new DataCellRenderer(), new DataCellEditor()); this.addColumn(column); this.setTableHeader(this.getTableHeader()); this.setModel(dataModel); this.setRowSorter(sorter); sorter.setSortsOnUpdates(true); updateRowHeights(); popupStruct = WandoraMenuManager.getOccurrenceTableMenu(this, options); JPopupMenu popup = UIBox.makePopupMenu(popupStruct, wandora); this.setComponentPopupMenu(popup); this.addMouseListener(this); this.setColumnSelectionAllowed(false); this.setRowSelectionAllowed(false); this.setDragEnabled(true); this.setTransferHandler(new OccurrencesTableTransferHandler()); this.setDropMode(DropMode.ON); this.createDefaultTableSelectionModel(); }