private void addCondition(@NotNull ArrangementUiComponent component) { mySkipStateChange = true; try { component.setSelected(true); Collection<Set<ArrangementSettingsToken>> mutexes = mySettingsManager.getMutexes(); // Update 'mutex conditions', i.e. conditions which can't be active at the same time (e.g. // type 'field' and type 'method'). for (Set<ArrangementSettingsToken> mutex : mutexes) { if (!mutex.contains(component.getToken())) { continue; } for (ArrangementSettingsToken key : mutex) { if (key.equals(component.getToken())) { continue; } ArrangementUiComponent c = myComponents.get(key); if (c != null && c.isEnabled()) { removeCondition(c); } } } refreshConditions(); } finally { mySkipStateChange = false; } }
private void onMouseClicked(@NotNull MouseEvent e) { if (myRow < 0) { return; } Point locationOnScreen = e.getLocationOnScreen(); for (ArrangementUiComponent component : myComponents.values()) { Rectangle screenBounds = component.getScreenBounds(); if (screenBounds == null || !screenBounds.contains(locationOnScreen)) { continue; } if (component.isEnabled()) { if (component.isSelected()) { removeCondition(component); } else { addCondition(component); } } apply(); return; } }
@Nullable private Pair<ArrangementMatchCondition, ArrangementSettingsToken> buildCondition() { List<ArrangementMatchCondition> conditions = ContainerUtilRt.newArrayList(); ArrangementSettingsToken orderType = null; for (ArrangementUiComponent component : myComponents.values()) { if (!component.isEnabled() || !component.isSelected()) { continue; } ArrangementSettingsToken token = component.getToken(); if (token != null && StdArrangementTokens.Order.is(token)) { orderType = token; } else { conditions.add(component.getMatchCondition()); } } if (orderType != null && !conditions.isEmpty()) { return Pair.create( ArrangementUtil.combine( conditions.toArray(new ArrangementMatchCondition[conditions.size()])), orderType); } else { return null; } }