@NotNull private List<WorkingCopyFormat> getSupportedFormats() { List<WorkingCopyFormat> result = ContainerUtil.newArrayList(); ClientFactory factory = myVcs.getFactory(); ClientFactory otherFactory = myVcs.getOtherFactory(factory); try { result.addAll(factory.createUpgradeClient().getSupportedFormats()); result.addAll(SvnFormatWorker.getOtherFactoryFormats(otherFactory)); } catch (VcsException e) { LOG.info(e); } return result; }
public CopiesPanel(final Project project) { myProject = project; myConnection = myProject.getMessageBus().connect(myProject); myVcs = SvnVcs.getInstance(myProject); myCurrentInfoList = null; final Runnable focus = new Runnable() { @Override public void run() { IdeFocusManager.getInstance(myProject).requestFocus(myRefreshLabel, true); } }; final Runnable refreshView = new Runnable() { @Override public void run() { final List<WCInfo> infoList = myVcs.getWcInfosWithErrors(); final boolean hasErrors = !myVcs.getSvnFileUrlMapping().getErrorRoots().isEmpty(); final List<WorkingCopyFormat> supportedFormats = getSupportedFormats(); Runnable runnable = new Runnable() { @Override public void run() { if (myCurrentInfoList != null) { final List<OverrideEqualsWrapper<WCInfo>> newList = ObjectsConvertor.convert( infoList, new Convertor<WCInfo, OverrideEqualsWrapper<WCInfo>>() { @Override public OverrideEqualsWrapper<WCInfo> convert(WCInfo o) { return new OverrideEqualsWrapper<WCInfo>( InfoEqualityPolicy.getInstance(), o); } }, ObjectsConvertor.NOT_NULL); if (Comparing.haveEqualElements(newList, myCurrentInfoList)) { myRefreshLabel.setEnabled(true); return; } myCurrentInfoList = newList; } Collections.sort(infoList, WCComparator.getInstance()); updateList(infoList, supportedFormats); myRefreshLabel.setEnabled(true); showErrorNotification(hasErrors); SwingUtilities.invokeLater(focus); } }; ApplicationManager.getApplication().invokeLater(runnable, ModalityState.NON_MODAL); } }; final Consumer<Boolean> refreshOnPooled = new Consumer<Boolean>() { @Override public void consume(Boolean somethingNew) { if (Boolean.TRUE.equals(somethingNew)) { if (ApplicationManager.getApplication().isUnitTestMode()) { refreshView.run(); } else { ApplicationManager.getApplication().executeOnPooledThread(refreshView); } } else { ApplicationManager.getApplication() .invokeLater( new Runnable() { @Override public void run() { myRefreshLabel.setEnabled(true); } }, ModalityState.NON_MODAL); } } }; myConnection.subscribe(SvnVcs.ROOTS_RELOADED, refreshOnPooled); final JPanel holderPanel = new JPanel(new BorderLayout()); FontMetrics fm = holderPanel.getFontMetrics(holderPanel.getFont()); myTextHeight = (int) (fm.getHeight() * 1.3); myPanel = new JPanel(new GridBagLayout()); final JPanel panel = new JPanel(new BorderLayout()); panel.add(myPanel, BorderLayout.NORTH); holderPanel.add(panel, BorderLayout.WEST); myRefreshLabel = new MyLinkLabel( myTextHeight, "Refresh", new LinkListener() { @Override public void linkSelected(LinkLabel aSource, Object aLinkData) { if (myRefreshLabel.isEnabled()) { myVcs.invokeRefreshSvnRoots(); myRefreshLabel.setEnabled(false); } } }); final JScrollPane pane = ScrollPaneFactory.createScrollPane(holderPanel); myHolder = pane; final JScrollBar vBar = pane.getVerticalScrollBar(); vBar.setBlockIncrement(vBar.getBlockIncrement() * 5); vBar.setUnitIncrement(vBar.getUnitIncrement() * 5); myHolder.setBorder(null); setFocusableForLinks(myRefreshLabel); refreshOnPooled.consume(true); initView(); }