@Override public void reset() { myPairs = new ArrayList<NameLocationPair>(myNewPairs); ExternalResourceManagerEx manager = ExternalResourceManagerEx.getInstanceEx(); String[] urls = manager.getAvailableUrls(); for (String url : urls) { String loc = myProject == null ? manager.getResourceLocation(url, (String) null) : manager.getResourceLocation(url, myProject); myPairs.add(new NameLocationPair(url, FileUtil.toSystemDependentName(loc), true)); } if (myProject != null) { urls = manager.getAvailableUrls(myProject); for (String url : urls) { String loc = manager.getResourceLocation(url, myProject); myPairs.add(new NameLocationPair(url, FileUtil.toSystemDependentName(loc), false)); } } Collections.sort(myPairs); myIgnoredUrls = new ArrayList<String>(); final String[] ignoredResources = manager.getIgnoredResources(); ContainerUtil.addAll(myIgnoredUrls, ignoredResources); Collections.sort(myIgnoredUrls); if (myExtPanel != null) { myExtPanel.setData(myPairs); myIgnorePanel.setData(myIgnoredUrls); if (!myNewPairs.isEmpty()) { ListSelectionModel selectionModel = myExtPanel.getTable().getSelectionModel(); selectionModel.clearSelection(); for (NameLocationPair newPair : myNewPairs) { int index = myPairs.indexOf(newPair); selectionModel.addSelectionInterval(index, index); } } } setModified(!myNewPairs.isEmpty()); }
@Override public JComponent createComponent() { myPanel = new JPanel(new GridBagLayout()) { @Override public Dimension getPreferredSize() { return new Dimension(-1, 400); } }; myExtPanel = new AddEditRemovePanel<NameLocationPair>( new ExtUrlsTableModel(), myPairs, XmlBundle.message("label.edit.external.resource.configure.external.resources")) { @Override protected NameLocationPair addItem() { return addExtLocation(); } @Override protected boolean removeItem(NameLocationPair o) { setModified(true); return true; } @Override protected NameLocationPair editItem(NameLocationPair o) { return editExtLocation(o); } }; myExtPanel.getTable().setShowColumns(true); myExtPanel.setRenderer(1, new PathRenderer()); JTable table = myExtPanel.getTable(); if (myProject != null) { TableColumn column = table.getColumn(table.getColumnName(2)); column.setMaxWidth(50); column.setCellEditor(JBTable.createBooleanEditor()); } table .getModel() .addTableModelListener( new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { setModified(true); } }); myIgnorePanel = new AddEditRemovePanel<String>( new IgnoredUrlsModel(), myIgnoredUrls, XmlBundle.message("label.edit.external.resource.configure.ignored.resources")) { @Override protected String addItem() { return addIgnoreLocation(); } @Override protected boolean removeItem(String o) { setModified(true); return true; } @Override protected String editItem(String o) { return editIgnoreLocation(o); } }; myPanel.add( myExtPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); myPanel.add( myIgnorePanel, new GridBagConstraints( 0, 1, 1, 1, 1, 1, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); myExtPanel.setData(myPairs); myIgnorePanel.setData(myIgnoredUrls); myExtPanel.getEmptyText().setText(XmlBundle.message("no.external.resources")); myIgnorePanel.getEmptyText().setText(XmlBundle.message("no.ignored.resources")); return myPanel; }