Merge branch 'master' into upsource-master
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
|
||||
public class BreakpointChooser {
|
||||
private Project myProject;
|
||||
|
||||
private DetailView myDetailView;
|
||||
|
||||
private ActionToolbar myActionToolbar;
|
||||
private BreakpointItem myBreakpointItem;
|
||||
|
||||
private Delegate myDelegate;
|
||||
private final ComboBoxAction myComboBoxAction;
|
||||
private BreakpointMasterDetailPopupBuilder myPopupBuilder;
|
||||
|
||||
private Object mySelectedBreakpoint;
|
||||
|
||||
public void setDetailView(DetailView detailView) {
|
||||
myDetailView = detailView;
|
||||
}
|
||||
|
||||
public Object getSelectedBreakpoint() {
|
||||
return mySelectedBreakpoint;
|
||||
}
|
||||
|
||||
public BreakpointItem getBreakpointItem() {
|
||||
return myBreakpointItem;
|
||||
}
|
||||
|
||||
public void setSelectedBreakpoint(Object selectedBreakpoint) {
|
||||
mySelectedBreakpoint = selectedBreakpoint;
|
||||
myBreakpointItem = selectedBreakpoint != null ? new JavaBreakpointItem(null, (Breakpoint)selectedBreakpoint) : null;
|
||||
updatePresentation(myComboBoxAction.getTemplatePresentation(), myBreakpointItem);
|
||||
myActionToolbar.getComponent().repaint();
|
||||
}
|
||||
|
||||
private void pop(DetailView.PreviewEditorState pushed) {
|
||||
if (pushed.getFile() != null) {
|
||||
myDetailView
|
||||
.navigateInPreviewEditor(
|
||||
new DetailView.PreviewEditorState(pushed.getFile(), pushed.getNavigate(), pushed.getAttributes()));
|
||||
}
|
||||
else {
|
||||
myDetailView.clearEditor();
|
||||
}
|
||||
}
|
||||
public interface Delegate {
|
||||
void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup);
|
||||
}
|
||||
|
||||
public BreakpointChooser(Project project, Delegate delegate) {
|
||||
myProject = project;
|
||||
myDelegate = delegate;
|
||||
|
||||
myPopupBuilder = new BreakpointMasterDetailPopupBuilder(myProject);
|
||||
myPopupBuilder.setPlainView(true);
|
||||
|
||||
myComboBoxAction = new ComboBoxAction() {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
updatePresentation(presentation, BreakpointChooser.this.myBreakpointItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComboBoxButton createComboBoxButton(final Presentation presentation) {
|
||||
return new ComboBoxButton(presentation) {
|
||||
@Override
|
||||
protected JBPopup createPopup(final Runnable onDispose) {
|
||||
final DetailView.PreviewEditorState pushed = myDetailView.getEditorState();
|
||||
myPopupBuilder.setIsViewer(true);
|
||||
myPopupBuilder.setAddDetailViewToEast(false);
|
||||
myPopupBuilder.setDetailView(new MyDetailView(pushed));
|
||||
myPopupBuilder.setCallback(new BreakpointMasterDetailPopupBuilder.BreakpointChosenCallback() {
|
||||
@Override
|
||||
public void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup) {
|
||||
popup.cancel();
|
||||
myBreakpointItem = breakpointItem;
|
||||
mySelectedBreakpoint = breakpointItem.getBreakpoint();
|
||||
updatePresentation(myComboBoxAction.getTemplatePresentation(), myBreakpointItem);
|
||||
updatePresentation(presentation, myBreakpointItem);
|
||||
|
||||
if (myDelegate != null) {
|
||||
myDelegate.breakpointChosen(project, breakpointItem, popup);
|
||||
}
|
||||
}
|
||||
});
|
||||
myPopupBuilder.setIsViewer(true);
|
||||
JBPopup popup = myPopupBuilder.createPopup();
|
||||
popup.addListener(new JBPopupListener() {
|
||||
@Override
|
||||
public void beforeShown(LightweightWindowEvent event) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(LightweightWindowEvent event) {
|
||||
onDispose.run();
|
||||
pop(pushed);
|
||||
}
|
||||
});
|
||||
return popup;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
|
||||
assert false : "should not be here";
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
myActionToolbar = ActionManager.getInstance().createActionToolbar("asdad", new DefaultActionGroup(myComboBoxAction), true);
|
||||
|
||||
}
|
||||
|
||||
public void setBreakpointItems(Collection<BreakpointItem> items) {
|
||||
myPopupBuilder.setBreakpointItems(items);
|
||||
}
|
||||
|
||||
private void updatePresentation(Presentation presentation, BreakpointItem breakpointItem) {
|
||||
if (breakpointItem != null) {
|
||||
presentation.setIcon(breakpointItem.getIcon());
|
||||
presentation.setText(breakpointItem.getDisplayText());
|
||||
}
|
||||
else {
|
||||
presentation.setText(DebuggerBundle.message("value.none"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public JComponent getComponent() {
|
||||
return myActionToolbar.getComponent();
|
||||
}
|
||||
|
||||
private class MyDetailView implements DetailView {
|
||||
|
||||
private final PreviewEditorState myPushed;
|
||||
|
||||
public MyDetailView(PreviewEditorState pushed) {
|
||||
myPushed = pushed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor getEditor() {
|
||||
return myDetailView.getEditor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateInPreviewEditor(PreviewEditorState editorState) {
|
||||
if (myDetailView != null) {
|
||||
myDetailView.navigateInPreviewEditor(editorState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getDetailPanel() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDetailPanel(@Nullable JPanel panel) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearEditor() {
|
||||
pop(myPushed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviewEditorState getEditorState() {
|
||||
return myDetailView.getEditorState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getUserData(@NotNull Key<T> key) {
|
||||
return myDetailView.getUserData(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
|
||||
myDetailView.putUserData(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
package com.intellij.debugger.ui.breakpoints;
|
||||
|
||||
import com.intellij.debugger.DebuggerBundle;
|
||||
import com.intellij.debugger.DebuggerManagerEx;
|
||||
import com.intellij.debugger.InstanceFilter;
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentKind;
|
||||
@@ -30,12 +29,12 @@ import com.intellij.debugger.settings.DebuggerSettings;
|
||||
import com.intellij.debugger.ui.CompletionEditor;
|
||||
import com.intellij.debugger.ui.DebuggerExpressionComboBox;
|
||||
import com.intellij.debugger.ui.DebuggerStatementEditor;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.ide.util.ClassFilter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.FixedSizeButton;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
@@ -44,7 +43,10 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.ui.FieldPanel;
|
||||
import com.intellij.ui.MultiLineTooltipUI;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -58,6 +60,16 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
private final BreakpointChooser myMasterBreakpointChooser;
|
||||
|
||||
public void setDetailView(DetailView detailView) {
|
||||
myDetailView = detailView;
|
||||
myMasterBreakpointChooser.setDetailView(detailView);
|
||||
}
|
||||
|
||||
private DetailView myDetailView;
|
||||
|
||||
protected final Project myProject;
|
||||
private final Key<? extends Breakpoint> myBreakpointCategory;
|
||||
private boolean myCompact;
|
||||
@@ -104,7 +116,6 @@ public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
ButtonGroup mySuspendPolicyGroup;
|
||||
@NonNls public static final String CONTROL_LOG_MESSAGE = "logMessage";
|
||||
private BreakpointComboboxHandler myBreakpointComboboxHandler;
|
||||
private static final int MAX_COMBO_WIDTH = 300;
|
||||
private final FixedSizeButton myConditionMagnifierButton;
|
||||
private boolean myMoreOptionsVisible = true;
|
||||
@@ -139,6 +150,10 @@ public abstract class BreakpointPropertiesPanel {
|
||||
};
|
||||
}
|
||||
|
||||
public DetailView getDetailView() {
|
||||
return myDetailView;
|
||||
}
|
||||
|
||||
public interface Delegate {
|
||||
|
||||
void showActionsPanel();
|
||||
@@ -153,10 +168,6 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (myBreakpointComboboxHandler != null) {
|
||||
myBreakpointComboboxHandler.dispose();
|
||||
myBreakpointComboboxHandler = null;
|
||||
}
|
||||
if (myConditionCombo != null) {
|
||||
myConditionCombo.dispose();
|
||||
}
|
||||
@@ -212,7 +223,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
panel.add(component, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
public BreakpointPropertiesPanel(Project project, final Key<? extends Breakpoint> breakpointCategory, boolean compact) {
|
||||
public BreakpointPropertiesPanel(final Project project, final Key<? extends Breakpoint> breakpointCategory, boolean compact) {
|
||||
myProject = project;
|
||||
myBreakpointCategory = breakpointCategory;
|
||||
myCompact = compact;
|
||||
@@ -226,7 +237,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
final String defaultPolicy =
|
||||
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().getDefaultSuspendPolicy(breakpointCategory);
|
||||
getBreakpointManager(myProject).getDefaultSuspendPolicy(breakpointCategory);
|
||||
myMakeDefaultButton.setEnabled(!defaultPolicy.equals(getSelectedSuspendPolicy()));
|
||||
}
|
||||
}
|
||||
@@ -247,7 +258,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
myMakeDefaultButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager();
|
||||
final BreakpointManager breakpointManager = getBreakpointManager(myProject);
|
||||
final String suspendPolicy = getSelectedSuspendPolicy();
|
||||
breakpointManager.setDefaultSuspendPolicy(breakpointCategory, suspendPolicy);
|
||||
updateSuspendPolicyRbFont();
|
||||
@@ -272,20 +283,25 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
myLogExpressionCombo = new DebuggerExpressionComboBox(project, "LineBreakpoint logMessage");
|
||||
|
||||
final ComboBox baseBreakpointCombo = new ComboBox(100);
|
||||
|
||||
myBreakpointComboboxHandler = new BreakpointComboboxHandler(myProject, baseBreakpointCombo);
|
||||
baseBreakpointCombo.setRenderer(new BreakpointComboRenderer(baseBreakpointCombo.getRenderer()));
|
||||
baseBreakpointCombo.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(final ItemEvent e) {
|
||||
ComboboxItem item = (ComboboxItem)baseBreakpointCombo.getSelectedItem();
|
||||
myMasterBreakpointChooser = new BreakpointChooser(project, new BreakpointChooser.Delegate() {
|
||||
@Override
|
||||
public void breakpointChosen(Project project, BreakpointItem item, JBPopup popup) {
|
||||
final boolean enabled = item != null && item.getBreakpoint() != null;
|
||||
myLeaveEnabledRadioButton.setEnabled(enabled);
|
||||
myDisableAgainRadio.setEnabled(enabled);
|
||||
myEnableOrDisableLabel.setEnabled(enabled);
|
||||
|
||||
if (item != null) {
|
||||
|
||||
saveMasterBreakpoint();
|
||||
}
|
||||
|
||||
updateMasterBreakpointPanel(findMasterBreakpointRule());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
myInstanceFiltersField = new FieldPanel(new MyTextField(), "", null,
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -341,7 +357,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
|
||||
insert(myConditionComboPanel, conditionPanel);
|
||||
insert(myLogExpressionComboPanel, myLogExpressionCombo);
|
||||
insert(myDependentBreakpointComboPanel, baseBreakpointCombo);
|
||||
//insert(myDependentBreakpointComboPanel, baseBreakpointCombo);
|
||||
insert(myDependentBreakpointComboPanel, myMasterBreakpointChooser.getComponent());
|
||||
insert(myInstanceFiltersFieldPanel, myInstanceFiltersField);
|
||||
insert(myClassFiltersFieldPanel, myClassFiltersField);
|
||||
|
||||
@@ -364,6 +381,51 @@ public abstract class BreakpointPropertiesPanel {
|
||||
IJSwingUtilities.adjustComponentsOnMac(myLogMessageCheckBox);
|
||||
}
|
||||
|
||||
private List<BreakpointItem> getBreakpointItemsExceptMy() {
|
||||
List<BreakpointItem> items = new ArrayList<BreakpointItem>();
|
||||
findJavaDebuggerSupport().getBreakpointPanelProvider().provideBreakpointItems(myProject, items);
|
||||
for (BreakpointItem item : items) {
|
||||
if (item.getBreakpoint() == myBreakpoint) {
|
||||
items.remove(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
private DebuggerSupport findJavaDebuggerSupport() {
|
||||
DebuggerSupport[] supports = DebuggerSupport.getDebuggerSupports();
|
||||
DebuggerSupport support = null;
|
||||
for (DebuggerSupport s : supports) {
|
||||
if (s instanceof JavaDebuggerSupport) {
|
||||
support = s;
|
||||
}
|
||||
}
|
||||
return support;
|
||||
}
|
||||
|
||||
private void saveMasterBreakpoint() {
|
||||
|
||||
|
||||
Breakpoint masterBreakpoint = (Breakpoint)myMasterBreakpointChooser.getSelectedBreakpoint();
|
||||
if (masterBreakpoint == null) {
|
||||
getBreakpointManager(myProject).removeBreakpointRule(myBreakpoint);
|
||||
}
|
||||
else {
|
||||
EnableBreakpointRule rule = findMasterBreakpointRule();
|
||||
boolean selected = myLeaveEnabledRadioButton.isSelected();
|
||||
if (rule != null && (rule.getMasterBreakpoint() != masterBreakpoint || rule.isLeaveEnabled() != selected ) ) {
|
||||
getBreakpointManager(myProject).removeBreakpointRule(rule);
|
||||
|
||||
}
|
||||
getBreakpointManager(myProject).addBreakpointRule(new EnableBreakpointRule(getBreakpointManager(myProject),
|
||||
masterBreakpoint,
|
||||
myBreakpoint,
|
||||
selected));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getSelectedSuspendPolicy() {
|
||||
if (!mySuspendJBCheckBox.isSelected()) {
|
||||
return DebuggerSettings.SUSPEND_NONE;
|
||||
@@ -375,7 +437,7 @@ public abstract class BreakpointPropertiesPanel {
|
||||
}
|
||||
|
||||
private void updateSuspendPolicyRbFont() {
|
||||
final String defPolicy = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().getDefaultSuspendPolicy(myBreakpointCategory);
|
||||
final String defPolicy = getBreakpointManager(myProject).getDefaultSuspendPolicy(myBreakpointCategory);
|
||||
|
||||
final Font font = mySuspendAllRadio.getFont().deriveFont(Font.PLAIN);
|
||||
final Font boldFont = font.deriveFont(Font.BOLD);
|
||||
@@ -410,7 +472,9 @@ public abstract class BreakpointPropertiesPanel {
|
||||
myBreakpoint = breakpoint;
|
||||
boolean moreOptionsVisible = moreOptionsVisible1;
|
||||
boolean actionsPanelVisible = moreOptionsVisible1;
|
||||
myBreakpointComboboxHandler.initFrom(breakpoint);
|
||||
|
||||
initMasterBreakpointPanel();
|
||||
|
||||
if (breakpoint.COUNT_FILTER > 0) {
|
||||
myPassCountField.setText(Integer.toString(breakpoint.COUNT_FILTER));
|
||||
moreOptionsVisible = true;
|
||||
@@ -504,6 +568,31 @@ public abstract class BreakpointPropertiesPanel {
|
||||
setMoreOptionsVisible(moreOptionsVisible);
|
||||
}
|
||||
|
||||
private void initMasterBreakpointPanel() {
|
||||
myMasterBreakpointChooser.setBreakpointItems(getBreakpointItemsExceptMy());
|
||||
|
||||
final EnableBreakpointRule rule = findMasterBreakpointRule();
|
||||
|
||||
final Breakpoint baseBreakpoint = rule != null ? rule.getMasterBreakpoint() : null;
|
||||
updateMasterBreakpointPanel(rule);
|
||||
|
||||
myMasterBreakpointChooser.setSelectedBreakpoint(baseBreakpoint);
|
||||
}
|
||||
|
||||
private @Nullable EnableBreakpointRule findMasterBreakpointRule() {
|
||||
return myBreakpoint != null? getBreakpointManager(myProject).findBreakpointRule(myBreakpoint) : null;
|
||||
}
|
||||
|
||||
private void updateMasterBreakpointPanel(@Nullable EnableBreakpointRule rule) {
|
||||
final boolean leaveEnabled = rule != null && rule.isLeaveEnabled();
|
||||
if (leaveEnabled) {
|
||||
myLeaveEnabledRadioButton.setSelected(true);
|
||||
}
|
||||
else {
|
||||
myDisableAgainRadio.setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
private TextWithImportsImpl emptyText() {
|
||||
return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "");
|
||||
}
|
||||
@@ -512,7 +601,8 @@ public abstract class BreakpointPropertiesPanel {
|
||||
* Save values in the UI components to the breakpoint object
|
||||
*/
|
||||
public void saveTo(Breakpoint breakpoint, @NotNull Runnable afterUpdate) {
|
||||
myBreakpointComboboxHandler.saveTo(breakpoint, myLeaveEnabledRadioButton.isSelected());
|
||||
|
||||
saveMasterBreakpoint();
|
||||
try {
|
||||
String text = myPassCountField.getText().trim();
|
||||
int count = !"".equals(text)? Integer.parseInt(text) : 0;
|
||||
@@ -702,37 +792,6 @@ public abstract class BreakpointPropertiesPanel {
|
||||
public JPanel getPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
private static class BreakpointComboboxModel extends DefaultComboBoxModel {
|
||||
private final ComboboxItem[] myItems;
|
||||
|
||||
public BreakpointComboboxModel(Breakpoint[] breakpoints) {
|
||||
myItems = new ComboboxItem[breakpoints.length + 1];
|
||||
myItems[0] = new ComboboxItem();
|
||||
for (int idx = 0; idx < breakpoints.length; idx++) {
|
||||
myItems[idx + 1] = new ComboboxItem(breakpoints[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return myItems.length;
|
||||
}
|
||||
|
||||
public ComboboxItem getElementAt(int index) {
|
||||
return myItems[index];
|
||||
}
|
||||
|
||||
public void selectBreakpoint(Breakpoint breakpoint) {
|
||||
for (final ComboboxItem item : myItems) {
|
||||
if (breakpoint == null ? item.getBreakpoint() == null : breakpoint.equals(item.getBreakpoint())) {
|
||||
if (!item.equals(getSelectedItem())) {
|
||||
setSelectedItem(item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ComboboxItem {
|
||||
private final Breakpoint breakpoint;
|
||||
@@ -764,83 +823,9 @@ public abstract class BreakpointPropertiesPanel {
|
||||
return breakpoint != null ? breakpoint.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private class BreakpointComboboxHandler implements BreakpointManagerListener{
|
||||
private final JComboBox myCombo;
|
||||
private final BreakpointManager myBreakpointManager;
|
||||
private Breakpoint myCurrentBreakpoint = null;
|
||||
|
||||
public BreakpointComboboxHandler(final Project project, final JComboBox breakpointCombo) {
|
||||
myCombo = breakpointCombo;
|
||||
myBreakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
|
||||
myBreakpointManager.addBreakpointManagerListener(this);
|
||||
}
|
||||
|
||||
public void initFrom(Breakpoint breakpoint) {
|
||||
myCurrentBreakpoint = breakpoint;
|
||||
fillCombobox();
|
||||
}
|
||||
|
||||
public void saveTo(Breakpoint slaveBreakpoint, final boolean leaveEnabled) {
|
||||
myBreakpointManager.removeBreakpointRule(slaveBreakpoint);
|
||||
final Breakpoint masterBreakpoint = ((ComboboxItem)myCombo.getSelectedItem()).getBreakpoint();
|
||||
if (masterBreakpoint != null) {
|
||||
myBreakpointManager.addBreakpointRule(new EnableBreakpointRule(myBreakpointManager, masterBreakpoint, slaveBreakpoint, leaveEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
public void breakpointsChanged() {
|
||||
fillCombobox();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
myBreakpointManager.removeBreakpointManagerListener(this);
|
||||
}
|
||||
|
||||
private void fillCombobox() {
|
||||
final List<Breakpoint> breakpoints = new ArrayList<Breakpoint>(myBreakpointManager.getBreakpoints());
|
||||
if (myCurrentBreakpoint != null) {
|
||||
// avoid depending on itself
|
||||
breakpoints.remove(myCurrentBreakpoint);
|
||||
}
|
||||
myCombo.setModel(new BreakpointComboboxModel(breakpoints.toArray(new Breakpoint[breakpoints.size()])));
|
||||
final EnableBreakpointRule rule = myCurrentBreakpoint != null? myBreakpointManager.findBreakpointRule(myCurrentBreakpoint) : null;
|
||||
final Breakpoint baseBreakpoint = rule != null? rule.getMasterBreakpoint() : null;
|
||||
final boolean leaveEnabled = rule != null && rule.isLeaveEnabled();
|
||||
if (leaveEnabled) {
|
||||
myLeaveEnabledRadioButton.setSelected(true);
|
||||
}
|
||||
else {
|
||||
myDisableAgainRadio.setSelected(true);
|
||||
}
|
||||
((BreakpointComboboxModel)myCombo.getModel()).selectBreakpoint(baseBreakpoint);
|
||||
}
|
||||
}
|
||||
|
||||
private static class BreakpointComboRenderer extends ListCellRendererWrapper {
|
||||
public BreakpointComboRenderer(final ListCellRenderer listCellRenderer) {
|
||||
super(listCellRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
|
||||
Breakpoint breakpoint = ((ComboboxItem)value).getBreakpoint();
|
||||
final String text = breakpoint != null ? index == -1 ? breakpoint.getShortName() : breakpoint.getDisplayName() : DebuggerBundle.message("value.none");
|
||||
setText(text);
|
||||
|
||||
final Icon icon;
|
||||
if (breakpoint != null) {
|
||||
icon = breakpoint instanceof BreakpointWithHighlighter
|
||||
? breakpoint.ENABLED
|
||||
? ((BreakpointWithHighlighter)breakpoint).getSetIcon(false)
|
||||
: ((BreakpointWithHighlighter)breakpoint).getDisabledIcon(false)
|
||||
: breakpoint.getIcon();
|
||||
}
|
||||
else {
|
||||
icon = null;
|
||||
}
|
||||
setIcon(icon);
|
||||
}
|
||||
private BreakpointManager getBreakpointManager(Project project) {
|
||||
return DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
|
||||
}
|
||||
|
||||
private static class MagnifierButtonAction implements ActionListener {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -37,17 +38,29 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
private final Breakpoint myBreakpoint;
|
||||
private BreakpointFactory myBreakpointFactory;
|
||||
|
||||
public JavaBreakpointItem(BreakpointFactory breakpointFactory, Breakpoint breakpoint) {
|
||||
public JavaBreakpointItem(@Nullable BreakpointFactory breakpointFactory, Breakpoint breakpoint) {
|
||||
myBreakpointFactory = breakpointFactory;
|
||||
myBreakpoint = breakpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer) {
|
||||
//renderer.setIcon(myBreakpoint.getIcon());
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
|
||||
if (plainView) {
|
||||
renderer.setIcon(myBreakpoint.getIcon());
|
||||
}
|
||||
renderer.append(myBreakpoint.getShortName(), isEnabled() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return myBreakpoint.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayText() {
|
||||
return myBreakpoint.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String speedSearchText() {
|
||||
return myBreakpoint.getDisplayName();
|
||||
@@ -59,11 +72,12 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetailView(DetailView panel) {
|
||||
BreakpointPropertiesPanel breakpointPropertiesPanel = myBreakpointFactory
|
||||
.createBreakpointPropertiesPanel(myBreakpoint.getProject(), false);
|
||||
protected void doUpdateDetailView(DetailView panel) {
|
||||
BreakpointPropertiesPanel breakpointPropertiesPanel = myBreakpointFactory != null ? myBreakpointFactory
|
||||
.createBreakpointPropertiesPanel(myBreakpoint.getProject(), false) : null;
|
||||
if (breakpointPropertiesPanel != null) {
|
||||
breakpointPropertiesPanel.setSaveOnRemove(true);
|
||||
breakpointPropertiesPanel.setDetailView(panel);
|
||||
}
|
||||
|
||||
if (breakpointPropertiesPanel != null) {
|
||||
@@ -86,7 +100,7 @@ class JavaBreakpointItem extends BreakpointItem {
|
||||
|
||||
@Override
|
||||
public boolean allowedToRemove() {
|
||||
return myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint);
|
||||
return myBreakpointFactory != null && myBreakpointFactory.breakpointCanBeRemoved(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -248,7 +248,7 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
PsiParameter[] parms = baseConstructor.getParameterList().getParameters();
|
||||
for (PsiParameter parm : parms) {
|
||||
PsiParameter newParam = factory.createParameter(parm.getName(), parm.getType());
|
||||
copyModifierList(parm, newParam);
|
||||
replaceModifierList(parm, newParam);
|
||||
constructor.getParameterList().add(newParam);
|
||||
}
|
||||
}
|
||||
@@ -291,11 +291,24 @@ public class GenerateConstructorHandler extends GenerateMembersHandlerBase {
|
||||
return constructor;
|
||||
}
|
||||
|
||||
static void copyModifierList(PsiParameter parm, PsiParameter newParam) {
|
||||
static void copyModifierList(JVMElementFactory factory, PsiParameter parm, PsiParameter newParam) {
|
||||
PsiModifierList modifierList = parm.getModifierList();
|
||||
PsiModifierList newMList = newParam.getModifierList();
|
||||
if (modifierList != null && newMList != null) {
|
||||
newMList.replace(modifierList);
|
||||
for (PsiAnnotation annotation : modifierList.getAnnotations()) {
|
||||
newMList.add(factory.createAnnotationFromText(annotation.getText(), newParam));
|
||||
}
|
||||
for (@PsiModifier.ModifierConstant String m : PsiModifier.MODIFIERS) {
|
||||
newMList.setModifierProperty(m, parm.hasModifierProperty(m));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void replaceModifierList(PsiParameter sourceParam, PsiParameter targetParam) {
|
||||
PsiModifierList sourceModifierList = sourceParam.getModifierList();
|
||||
PsiModifierList targetModifierList = targetParam.getModifierList();
|
||||
if (sourceModifierList != null && targetModifierList != null) {
|
||||
targetModifierList.replace(sourceModifierList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ public class GenerateMembersUtil {
|
||||
}
|
||||
}
|
||||
else {
|
||||
GenerateConstructorHandler.copyModifierList(parameter, newParameter);
|
||||
GenerateConstructorHandler.copyModifierList(factory,parameter, newParameter);
|
||||
}
|
||||
newMethod.getParameterList().add(newParameter);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JavaModuleType extends ModuleType<JavaModuleBuilder> {
|
||||
}
|
||||
|
||||
private static class IconHolder {
|
||||
private static final Icon JAVA_MODULE_ICON = AllIcons.Modules.JavaModule;
|
||||
private static final Icon JAVA_MODULE_ICON = AllIcons.Modules.Types.JavaModule;
|
||||
}
|
||||
|
||||
private static Icon getJavaModuleIcon() {
|
||||
|
||||
@@ -11,7 +11,7 @@ public interface JpsElement {
|
||||
|
||||
interface BulkModificationSupport<E extends JpsElement> extends JpsElement {
|
||||
@NotNull
|
||||
E createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent);
|
||||
E createCopy();
|
||||
|
||||
void applyChanges(@NotNull E modified);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ public interface JpsElementCollection<E extends JpsElement> extends JpsParentEle
|
||||
List<E> getElements();
|
||||
|
||||
@NotNull
|
||||
<P> E addChild(@NotNull JpsElementFactoryWithParameter<E,P> factory, @NotNull P param);
|
||||
<P> E addChild(@NotNull JpsElementParameterizedCreator<E,P> factory, @NotNull P param);
|
||||
|
||||
@NotNull
|
||||
E addChild(@NotNull JpsElementFactory<E> factory);
|
||||
E addChild(@NotNull JpsElementCreator<E> creator);
|
||||
|
||||
E addChild(E element);
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ public interface JpsElementContainer {
|
||||
T getChild(@NotNull JpsElementKind<T> kind);
|
||||
|
||||
@NotNull
|
||||
<T extends JpsElement, K extends JpsElementKind<T>&JpsElementFactory<T>>
|
||||
<T extends JpsElement, K extends JpsElementKind<T>&JpsElementCreator<T>>
|
||||
T setChild(@NotNull K kind);
|
||||
|
||||
@NotNull
|
||||
<T extends JpsElement, P, K extends JpsElementKind<T>&JpsElementFactoryWithParameter<T, P>>
|
||||
<T extends JpsElement, P, K extends JpsElementKind<T>&JpsElementParameterizedCreator<T, P>>
|
||||
T setChild(@NotNull K kind, @NotNull P param);
|
||||
|
||||
<T extends JpsElement>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementCreator<E extends JpsElement> {
|
||||
@NotNull
|
||||
E create();
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementFactory<E extends JpsElement> {
|
||||
public abstract class JpsElementFactory {
|
||||
public static JpsElementFactory getInstance() {
|
||||
return JpsServiceManager.getInstance().getService(JpsElementFactory.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
E create(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent);
|
||||
public abstract JpsModuleReference createModuleReference(@NotNull String moduleName);
|
||||
|
||||
@NotNull
|
||||
public abstract JpsLibraryReference createLibraryReference(@NotNull String libraryName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementFactoryWithParameter<E extends JpsElement, P> {
|
||||
@NotNull
|
||||
E create(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent, @NotNull P param);
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsElementKind<E extends JpsElement> {
|
||||
|
||||
public void fireElementAdded(@NotNull JpsEventDispatcher dispatcher, @NotNull E element) {
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsElementParameterizedCreator<E extends JpsElement, P> {
|
||||
@NotNull
|
||||
E create(@NotNull P param);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -8,4 +9,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface JpsElementReference<T extends JpsElement> extends JpsElement {
|
||||
@Nullable
|
||||
T resolve();
|
||||
|
||||
JpsElementReference<T> asExternal(@NotNull JpsModel model);
|
||||
}
|
||||
|
||||
@@ -15,5 +15,7 @@ public interface JpsModel {
|
||||
@NotNull
|
||||
JpsModel createModifiableModel(@NotNull JpsEventDispatcher eventDispatcher);
|
||||
|
||||
void registerExternalReference(@NotNull JpsElementReference<?> reference);
|
||||
|
||||
void commit();
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public interface JpsReferenceableElement<E extends JpsElement> {
|
||||
@NotNull
|
||||
JpsElementReference<E> createReference(JpsParentElement parent);
|
||||
JpsElementReference<E> createReference();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.jetbrains.jps.model.library;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsNamedElement;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.JpsReferenceableElement;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,5 +21,5 @@ public interface JpsLibrary extends JpsNamedElement, JpsReferenceableElement<Jps
|
||||
void delete();
|
||||
|
||||
@NotNull
|
||||
JpsLibraryReference createReference(JpsParentElement parent);
|
||||
JpsLibraryReference createReference();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.jps.model.library;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -9,4 +10,7 @@ import org.jetbrains.jps.model.JpsElementReference;
|
||||
public interface JpsLibraryReference extends JpsElementReference<JpsLibrary> {
|
||||
@NotNull
|
||||
String getLibraryName();
|
||||
|
||||
@Override
|
||||
JpsLibraryReference asExternal(@NotNull JpsModel model);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.jetbrains.jps.model.module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,9 +15,15 @@ public interface JpsDependenciesList extends JpsElement {
|
||||
@NotNull
|
||||
JpsModuleDependency addModuleDependency(@NotNull JpsModule module);
|
||||
|
||||
@NotNull
|
||||
JpsModuleDependency addModuleDependency(@NotNull JpsModuleReference moduleReference);
|
||||
|
||||
@NotNull
|
||||
JpsLibraryDependency addLibraryDependency(@NotNull JpsLibrary libraryElement);
|
||||
|
||||
@NotNull
|
||||
JpsLibraryDependency addLibraryDependency(@NotNull JpsLibraryReference libraryReference);
|
||||
|
||||
void addModuleSourceDependency();
|
||||
|
||||
void addSdkDependency(@NotNull JpsSdkType<?> sdkType);
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,7 +37,10 @@ public interface JpsModule extends JpsNamedElement, JpsReferenceableElement<JpsM
|
||||
JpsElementContainer getContainer();
|
||||
|
||||
@NotNull
|
||||
JpsModuleReference createReference(JpsParentElement parent);
|
||||
JpsModuleReference createReference();
|
||||
|
||||
@NotNull
|
||||
JpsLibrary addModuleLibrary(@NotNull JpsLibraryType<?> type, @NotNull String name);
|
||||
|
||||
void delete();
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -9,4 +10,7 @@ import org.jetbrains.jps.model.JpsElementReference;
|
||||
public interface JpsModuleReference extends JpsElementReference<JpsModule> {
|
||||
@NotNull
|
||||
String getModuleName();
|
||||
|
||||
@Override
|
||||
JpsModuleReference asExternal(@NotNull JpsModel model);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.jetbrains.jps.model.module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsCompositeElement;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
|
||||
@@ -14,5 +13,5 @@ public interface JpsSdkReferencesTable extends JpsCompositeElement {
|
||||
@Nullable
|
||||
JpsLibraryReference getSdkReference(@NotNull JpsSdkType<?> type);
|
||||
|
||||
void setSdkReference(@NotNull JpsSdkType<?> type, @NotNull JpsLibrary sdk);
|
||||
void setSdkReference(@NotNull JpsSdkType<?> type, @NotNull JpsLibraryReference sdkReference);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.jetbrains.jps.service;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsServiceManager {
|
||||
public static JpsServiceManager getInstance() {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public abstract <T> T getService(Class<T> serviceClass);
|
||||
|
||||
private static class InstanceHolder {
|
||||
private static final JpsServiceManager INSTANCE;
|
||||
static {
|
||||
INSTANCE = ServiceLoader.load(JpsServiceManager.class).iterator().next();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.jps.model.impl.JpsElementFactoryImpl
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.jps.service.impl.JpsServiceManagerImpl
|
||||
@@ -8,19 +8,13 @@ import org.jetbrains.jps.model.*;
|
||||
*/
|
||||
public abstract class JpsCompositeElementBase<Self extends JpsCompositeElementBase<Self>> extends JpsElementBase<Self> implements JpsCompositeElement {
|
||||
protected final JpsElementContainerImpl myContainer;
|
||||
protected final JpsModel myModel;
|
||||
|
||||
protected JpsCompositeElementBase(JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
myModel = model;
|
||||
myContainer = new JpsElementContainerImpl(model, eventDispatcher, this);
|
||||
protected JpsCompositeElementBase() {
|
||||
myContainer = new JpsElementContainerImpl(this);
|
||||
}
|
||||
|
||||
protected JpsCompositeElementBase(JpsCompositeElementBase<Self> original, JpsModel model, JpsEventDispatcher dispatcher,
|
||||
JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
myModel = model;
|
||||
myContainer = new JpsElementContainerImpl(original.myContainer, model, dispatcher, this);
|
||||
protected JpsCompositeElementBase(JpsCompositeElementBase<Self> original) {
|
||||
myContainer = new JpsElementContainerImpl(original.myContainer, this);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull Self element) {
|
||||
|
||||
@@ -1,27 +1,52 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.*;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsElementBase<Self extends JpsElementBase<Self>> implements JpsElement, JpsElement.BulkModificationSupport<Self> {
|
||||
private JpsEventDispatcher myEventDispatcher;
|
||||
protected JpsParentElement myParent;
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.model.impl.JpsElementBase");
|
||||
protected JpsElementBase<?> myParent;
|
||||
|
||||
protected JpsElementBase(JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myEventDispatcher = eventDispatcher;
|
||||
protected JpsElementBase() {
|
||||
}
|
||||
|
||||
public void setParent(@Nullable JpsElementBase<?> parent) {
|
||||
if (myParent != null && parent != null) {
|
||||
LOG.error("Parent for " + this + " is already set");
|
||||
}
|
||||
myParent = parent;
|
||||
}
|
||||
|
||||
public JpsElementBase(JpsElementBase original, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myEventDispatcher = eventDispatcher;
|
||||
myParent = parent;
|
||||
protected void fireElementChanged() {
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void setParent(@NotNull JpsElement element, @Nullable JpsElementBase<?> parent) {
|
||||
((JpsElementBase<?>)element).setParent(parent);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected JpsEventDispatcher getEventDispatcher() {
|
||||
return myEventDispatcher;
|
||||
if (myParent != null) {
|
||||
return myParent.getEventDispatcher();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected JpsModel getModel() {
|
||||
if (myParent != null) {
|
||||
return myParent.getModel();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -31,11 +56,11 @@ public abstract class JpsElementBase<Self extends JpsElementBase<Self>> implemen
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract Self createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent);
|
||||
public abstract Self createCopy();
|
||||
|
||||
public abstract void applyChanges(@NotNull Self modified);
|
||||
|
||||
public JpsParentElement getParent() {
|
||||
public JpsElementBase<?> getParent() {
|
||||
return myParent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,30 +11,23 @@ import java.util.*;
|
||||
*/
|
||||
public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBase<JpsElementCollectionImpl<E>> implements JpsElementCollection<E> {
|
||||
private final List<E> myElements;
|
||||
private final JpsModel myModel;
|
||||
private final Map<E, E> myCopyToOriginal;
|
||||
private final JpsElementKind<E> myKind;
|
||||
|
||||
public JpsElementCollectionImpl(JpsElementKind<E> kind, JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl(JpsElementKind<E> kind) {
|
||||
myKind = kind;
|
||||
myModel = model;
|
||||
myElements = new SmartList<E>();
|
||||
myCopyToOriginal = null;
|
||||
}
|
||||
|
||||
public JpsElementCollectionImpl(JpsElementCollectionImpl<E> original,
|
||||
JpsModel model,
|
||||
JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
super(original, eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl(JpsElementCollectionImpl<E> original) {
|
||||
myKind = original.myKind;
|
||||
myModel = model;
|
||||
myElements = new SmartList<E>();
|
||||
myCopyToOriginal = new HashMap<E, E>();
|
||||
for (E e : original.myElements) {
|
||||
//noinspection unchecked
|
||||
final E copy = (E)e.getBulkModificationSupport().createCopy(model, eventDispatcher, parent);
|
||||
final E copy = (E)e.getBulkModificationSupport().createCopy();
|
||||
setParent(copy, this);
|
||||
myElements.add(copy);
|
||||
myCopyToOriginal.put(copy, e);
|
||||
}
|
||||
@@ -47,20 +40,24 @@ public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBa
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <P> E addChild(@NotNull JpsElementFactoryWithParameter<E, P> factory, @NotNull P param) {
|
||||
return addChild(factory.create(myModel, getEventDispatcher(), myParent, param));
|
||||
public <P> E addChild(@NotNull JpsElementParameterizedCreator<E, P> factory, @NotNull P param) {
|
||||
return addChild(factory.create(param));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public E addChild(@NotNull JpsElementFactory<E> factory) {
|
||||
return addChild(factory.create(myModel, getEventDispatcher(), myParent));
|
||||
public E addChild(@NotNull JpsElementCreator<E> creator) {
|
||||
return addChild(creator.create());
|
||||
}
|
||||
|
||||
@Override
|
||||
public E addChild(E element) {
|
||||
myElements.add(element);
|
||||
getEventDispatcher().fireElementAdded(element, myKind);
|
||||
setParent(element, this);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementAdded(element, myKind);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -68,16 +65,18 @@ public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBa
|
||||
public void removeChild(@NotNull E element) {
|
||||
final boolean removed = myElements.remove(element);
|
||||
if (removed) {
|
||||
getEventDispatcher().fireElementRemoved(element, myKind);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementRemoved(element, myKind);
|
||||
}
|
||||
setParent(element, null);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementCollectionImpl<E> createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsElementCollectionImpl<E>(this, model, eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl<E> createCopy() {
|
||||
return new JpsElementCollectionImpl<E>(this);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsElementCollectionImpl<E> modified) {
|
||||
@@ -93,7 +92,7 @@ public class JpsElementCollectionImpl<E extends JpsElement> extends JpsElementBa
|
||||
}
|
||||
else {
|
||||
//noinspection unchecked
|
||||
final E copy = (E)element.getBulkModificationSupport().createCopy(myModel, getEventDispatcher(), myParent);
|
||||
final E copy = (E)element.getBulkModificationSupport().createCopy();
|
||||
toAdd.add(copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.jps.model.*;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsElementCollectionKind<E extends JpsElement> extends JpsElementKind<JpsElementCollectionImpl<E>>
|
||||
implements JpsElementFactory<JpsElementCollectionImpl<E>> {
|
||||
implements JpsElementCreator<JpsElementCollectionImpl<E>> {
|
||||
private final JpsElementKind<E> myElementKind;
|
||||
|
||||
public JpsElementCollectionKind(JpsElementKind<E> elementKind) {
|
||||
@@ -16,9 +16,7 @@ public class JpsElementCollectionKind<E extends JpsElement> extends JpsElementKi
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementCollectionImpl<E> create(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsElementCollectionImpl<E>(myElementKind, model, eventDispatcher, parent);
|
||||
public JpsElementCollectionImpl<E> create() {
|
||||
return new JpsElementCollectionImpl<E>(myElementKind);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -11,25 +12,19 @@ import java.util.Map;
|
||||
*/
|
||||
public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
private final Map<JpsElementKind<?>, JpsElement> myElements = new HashMap<JpsElementKind<?>, JpsElement>();
|
||||
private final @NotNull JpsModel myModel;
|
||||
private final @NotNull JpsEventDispatcher myEventDispatcher;
|
||||
private final @NotNull JpsParentElement myParent;
|
||||
private final @NotNull JpsCompositeElementBase<?> myParent;
|
||||
|
||||
public JpsElementContainerImpl(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myModel = model;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
public JpsElementContainerImpl(@NotNull JpsCompositeElementBase<?> parent) {
|
||||
myParent = parent;
|
||||
}
|
||||
|
||||
public JpsElementContainerImpl(@NotNull JpsElementContainerImpl original, @NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
myModel = model;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
public JpsElementContainerImpl(@NotNull JpsElementContainerImpl original, @NotNull JpsCompositeElementBase<?> parent) {
|
||||
myParent = parent;
|
||||
for (Map.Entry<JpsElementKind<?>, JpsElement> entry : original.myElements.entrySet()) {
|
||||
final JpsElementKind kind = entry.getKey();
|
||||
myElements.put(kind, entry.getValue().getBulkModificationSupport().createCopy(myModel, myEventDispatcher, myParent));
|
||||
final JpsElement copy = entry.getValue().getBulkModificationSupport().createCopy();
|
||||
JpsElementBase.setParent(copy, myParent);
|
||||
myElements.put(kind, copy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,23 +36,27 @@ public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends JpsElement, P, K extends JpsElementKind<T> & JpsElementFactoryWithParameter<T, P>> T setChild(@NotNull K kind,
|
||||
public <T extends JpsElement, P, K extends JpsElementKind<T> & JpsElementParameterizedCreator<T, P>> T setChild(@NotNull K kind,
|
||||
@NotNull P param) {
|
||||
final T child = kind.create(myModel, myEventDispatcher, myParent, param);
|
||||
final T child = kind.create(param);
|
||||
return setChild(kind, child);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T extends JpsElement, K extends JpsElementKind<T> & JpsElementFactory<T>> T setChild(@NotNull K kind) {
|
||||
final T child = kind.create(myModel, myEventDispatcher, myParent);
|
||||
public <T extends JpsElement, K extends JpsElementKind<T> & JpsElementCreator<T>> T setChild(@NotNull K kind) {
|
||||
final T child = kind.create();
|
||||
return setChild(kind, child);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends JpsElement> T setChild(JpsElementKind<T> kind, T child) {
|
||||
myElements.put(kind, child);
|
||||
myEventDispatcher.fireElementAdded(child, kind);
|
||||
JpsElementBase.setParent(child, myParent);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementAdded(child, kind);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -65,7 +64,11 @@ public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
public <T extends JpsElement> void removeChild(@NotNull JpsElementKind<T> kind) {
|
||||
//noinspection unchecked
|
||||
final T removed = (T)myElements.remove(kind);
|
||||
myEventDispatcher.fireElementRemoved(removed, kind);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementRemoved(removed, kind);
|
||||
}
|
||||
JpsElementBase.setParent(removed, null);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsElementContainerImpl modified) {
|
||||
@@ -92,7 +95,12 @@ public class JpsElementContainerImpl implements JpsElementContainer {
|
||||
}
|
||||
else {
|
||||
//noinspection unchecked
|
||||
setChild(kind, (T)modifiedChild.getBulkModificationSupport().createCopy(myModel, myEventDispatcher, myParent));
|
||||
setChild(kind, (T)modifiedChild.getBulkModificationSupport().createCopy());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JpsEventDispatcher getEventDispatcher() {
|
||||
return myParent.getEventDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.impl.JpsLibraryReferenceImpl;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
import org.jetbrains.jps.model.module.impl.JpsModuleReferenceImpl;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsElementFactoryImpl extends JpsElementFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleReference createModuleReference(@NotNull String moduleName) {
|
||||
return new JpsModuleReferenceImpl(moduleName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryReference createLibraryReference(@NotNull String libraryName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference) {
|
||||
return new JpsLibraryReferenceImpl(libraryName, parentReference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsElementReferenceBase<E extends JpsElementReferenceBase<E, T>, T extends JpsElement> extends JpsElementBase<E> implements JpsElementReference<T> {
|
||||
@Override
|
||||
public JpsElementReference<T> asExternal(@NotNull JpsModel model) {
|
||||
model.registerExternalReference(this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -6,25 +6,17 @@ import org.jetbrains.jps.model.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsGlobalElementReference extends JpsElementBase<JpsGlobalElementReference> implements JpsElementReference<JpsGlobal> {
|
||||
private final JpsModel myModel;
|
||||
|
||||
public JpsGlobalElementReference(JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
myModel = model;
|
||||
}
|
||||
|
||||
public class JpsGlobalElementReference extends JpsElementReferenceBase<JpsGlobalElementReference, JpsGlobal> {
|
||||
@Override
|
||||
public JpsGlobal resolve() {
|
||||
return myModel.getGlobal();
|
||||
final JpsModel model = getModel();
|
||||
return model != null ? model.getGlobal() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsGlobalElementReference createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsGlobalElementReference(model, eventDispatcher, parent);
|
||||
public JpsGlobalElementReference createCopy() {
|
||||
return new JpsGlobalElementReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,32 +10,26 @@ import org.jetbrains.jps.model.library.impl.JpsLibraryKind;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsGlobalImpl extends JpsCompositeElementBase<JpsGlobalImpl> implements JpsGlobal {
|
||||
public class JpsGlobalImpl extends JpsRootElementBase<JpsGlobalImpl> implements JpsGlobal {
|
||||
public JpsGlobalImpl(JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(model, eventDispatcher, null);
|
||||
super(model, eventDispatcher);
|
||||
myContainer.setChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
}
|
||||
|
||||
public JpsGlobalImpl(JpsGlobalImpl original, JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(original, model, eventDispatcher, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsGlobalImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsGlobalImpl(this, model, eventDispatcher);
|
||||
super(original, model, eventDispatcher);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibrary addLibrary(@NotNull JpsLibraryType libraryType, @NotNull final String name) {
|
||||
final JpsElementCollectionImpl<JpsLibraryImpl> collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType, myModel, getEventDispatcher(), collection));
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementReference<JpsGlobal> createReference(JpsParentElement parent) {
|
||||
return new JpsGlobalElementReference(myModel, getEventDispatcher(), parent);
|
||||
public JpsElementReference<JpsGlobal> createReference() {
|
||||
return new JpsGlobalElementReference();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementReference;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
@@ -11,14 +12,17 @@ public class JpsModelImpl implements JpsModel {
|
||||
private JpsProjectImpl myProject;
|
||||
private JpsGlobalImpl myGlobal;
|
||||
private JpsModelImpl myOriginalModel;
|
||||
private final JpsEventDispatcher myEventDispatcher;
|
||||
|
||||
public JpsModelImpl(JpsEventDispatcher eventDispatcher) {
|
||||
myEventDispatcher = eventDispatcher;
|
||||
myProject = new JpsProjectImpl(this, eventDispatcher);
|
||||
myGlobal = new JpsGlobalImpl(this, eventDispatcher);
|
||||
}
|
||||
|
||||
private JpsModelImpl(JpsModelImpl original, JpsEventDispatcher eventDispatcher) {
|
||||
myOriginalModel = original;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
myProject = new JpsProjectImpl(original.myProject, this, eventDispatcher);
|
||||
myGlobal = new JpsGlobalImpl(original.myGlobal, this, eventDispatcher);
|
||||
}
|
||||
@@ -39,6 +43,11 @@ public class JpsModelImpl implements JpsModel {
|
||||
return new JpsModelImpl(this, eventDispatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerExternalReference(@NotNull JpsElementReference<?> reference) {
|
||||
myProject.addExternalReference(reference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
myOriginalModel.applyChanges(this);
|
||||
|
||||
@@ -11,17 +11,13 @@ public abstract class JpsNamedCompositeElementBase<Self extends JpsNamedComposit
|
||||
implements JpsNamedElement {
|
||||
private String myName;
|
||||
|
||||
protected JpsNamedCompositeElementBase(JpsModel model,
|
||||
JpsEventDispatcher eventDispatcher,
|
||||
@NotNull String name, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
protected JpsNamedCompositeElementBase(@NotNull String name) {
|
||||
super();
|
||||
myName = name;
|
||||
}
|
||||
|
||||
protected JpsNamedCompositeElementBase(JpsNamedCompositeElementBase<Self, Parent> original,
|
||||
JpsModel model,
|
||||
JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
protected JpsNamedCompositeElementBase(JpsNamedCompositeElementBase<Self, Parent> original) {
|
||||
super(original);
|
||||
myName = original.myName;
|
||||
}
|
||||
|
||||
@@ -41,7 +37,10 @@ public abstract class JpsNamedCompositeElementBase<Self extends JpsNamedComposit
|
||||
if (!myName.equals(name)) {
|
||||
String oldName = myName;
|
||||
myName = name;
|
||||
getEventDispatcher().fireElementRenamed(this, oldName, name);
|
||||
final JpsEventDispatcher eventDispatcher = getEventDispatcher();
|
||||
if (eventDispatcher != null) {
|
||||
eventDispatcher.fireElementRenamed(this, oldName, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,17 @@ public abstract class JpsNamedElementReferenceBase<T extends JpsNamedElement, Se
|
||||
private final JpsElementCollectionKind<? extends T> myCollectionKind;
|
||||
protected final String myElementName;
|
||||
|
||||
protected JpsNamedElementReferenceBase(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, @NotNull JpsElementCollectionKind<? extends T> kind, @NotNull String elementName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
protected JpsNamedElementReferenceBase(@NotNull JpsElementCollectionKind<? extends T> kind,
|
||||
@NotNull String elementName,
|
||||
@NotNull JpsElementReference<? extends JpsCompositeElement> parentReference) {
|
||||
super();
|
||||
myCollectionKind = kind;
|
||||
myElementName = elementName;
|
||||
myContainer.setChild(PARENT_REFERENCE_KIND, parentReference);
|
||||
}
|
||||
|
||||
protected JpsNamedElementReferenceBase(JpsNamedElementReferenceBase<T, Self> original,
|
||||
JpsModel model, JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
protected JpsNamedElementReferenceBase(JpsNamedElementReferenceBase<T, Self> original) {
|
||||
super(original);
|
||||
myCollectionKind = original.myCollectionKind;
|
||||
myElementName = original.myElementName;
|
||||
}
|
||||
|
||||
@@ -6,25 +6,17 @@ import org.jetbrains.jps.model.*;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsProjectElementReference extends JpsElementBase<JpsProjectElementReference> implements JpsElementReference<JpsProject> {
|
||||
private final JpsModel myModel;
|
||||
|
||||
public JpsProjectElementReference(JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
myModel = model;
|
||||
}
|
||||
|
||||
public class JpsProjectElementReference extends JpsElementReferenceBase<JpsProjectElementReference, JpsProject> {
|
||||
@Override
|
||||
public JpsProject resolve() {
|
||||
return myModel.getProject();
|
||||
final JpsModel model = getModel();
|
||||
return model != null ? model.getProject() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsProjectElementReference createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsProjectElementReference(model, eventDispatcher, parent);
|
||||
public JpsProjectElementReference createCopy() {
|
||||
return new JpsProjectElementReference();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,29 +16,36 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsProjectImpl extends JpsCompositeElementBase<JpsProjectImpl> implements JpsProject {
|
||||
public class JpsProjectImpl extends JpsRootElementBase<JpsProjectImpl> implements JpsProject {
|
||||
private static final JpsElementCollectionKind<JpsElementReference<?>> EXTERNAL_REFERENCES_COLLECTION_KIND = new JpsElementCollectionKind<JpsElementReference<?>>(new JpsElementKind<JpsElementReference<?>>());
|
||||
|
||||
public JpsProjectImpl(JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(model, eventDispatcher, null);
|
||||
super(model, eventDispatcher);
|
||||
myContainer.setChild(JpsModuleKind.MODULE_COLLECTION_KIND);
|
||||
myContainer.setChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
myContainer.setChild(EXTERNAL_REFERENCES_COLLECTION_KIND);
|
||||
}
|
||||
|
||||
public JpsProjectImpl(JpsProjectImpl original, JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super(original, model, eventDispatcher, null);
|
||||
super(original, model, eventDispatcher);
|
||||
}
|
||||
|
||||
public void addExternalReference(@NotNull JpsElementReference<?> reference) {
|
||||
myContainer.getChild(EXTERNAL_REFERENCES_COLLECTION_KIND).addChild(reference);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModule addModule(@NotNull JpsModuleType<?> moduleType, @NotNull final String name) {
|
||||
final JpsElementCollectionImpl<JpsModuleImpl> collection = myContainer.getChild(JpsModuleKind.MODULE_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsModuleImpl(myModel, getEventDispatcher(), moduleType, name, collection));
|
||||
return collection.addChild(new JpsModuleImpl(moduleType, name));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibrary addLibrary(@NotNull JpsLibraryType<?> libraryType, @NotNull final String name) {
|
||||
final JpsElementCollectionImpl<JpsLibraryImpl> collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType, myModel, getEventDispatcher(), collection));
|
||||
return collection.addChild(new JpsLibraryImpl(name, libraryType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -55,13 +62,7 @@ public class JpsProjectImpl extends JpsCompositeElementBase<JpsProjectImpl> impl
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsElementReference<JpsProject> createReference(JpsParentElement parent) {
|
||||
return new JpsProjectElementReference(myModel, getEventDispatcher(), parent);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsProjectImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsProjectImpl(this, model, eventDispatcher);
|
||||
public JpsElementReference<JpsProject> createReference() {
|
||||
return new JpsProjectElementReference();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.jetbrains.jps.model.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsRootElementBase<E extends JpsRootElementBase<E>> extends JpsCompositeElementBase<E> {
|
||||
private final JpsModel myModel;
|
||||
private final JpsEventDispatcher myEventDispatcher;
|
||||
|
||||
protected JpsRootElementBase(JpsModel model, JpsEventDispatcher eventDispatcher) {
|
||||
super();
|
||||
myModel = model;
|
||||
myEventDispatcher = eventDispatcher;
|
||||
}
|
||||
|
||||
protected JpsRootElementBase(JpsCompositeElementBase<E> original, JpsModel model, JpsEventDispatcher dispatcher) {
|
||||
super(original);
|
||||
myModel = model;
|
||||
myEventDispatcher = dispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JpsEventDispatcher getEventDispatcher() {
|
||||
return myEventDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JpsModel getModel() {
|
||||
return myModel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public E createCopy() {
|
||||
throw new UnsupportedOperationException("'createCopy' not implemented in " + getClass().getName());
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,12 @@ public class JpsTypedDataImpl<T extends JpsElementType<?>> extends JpsElementBas
|
||||
private final T myType;
|
||||
private JpsElementProperties myProperties;
|
||||
|
||||
public JpsTypedDataImpl(T type, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsTypedDataImpl(T type) {
|
||||
myType = type;
|
||||
myProperties = type.createDefaultProperties();
|
||||
}
|
||||
|
||||
public JpsTypedDataImpl(JpsTypedDataImpl<T> original,
|
||||
JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, eventDispatcher, parent);
|
||||
public JpsTypedDataImpl(JpsTypedDataImpl<T> original) {
|
||||
myType = original.getType();
|
||||
final JpsElementType<?> type = original.getType();
|
||||
myProperties = createCopy(type, original.myProperties);
|
||||
@@ -44,8 +41,8 @@ public class JpsTypedDataImpl<T extends JpsElementType<?>> extends JpsElementBas
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsTypedDataImpl<T> createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsTypedDataImpl<T>(this, eventDispatcher, parent);
|
||||
public JpsTypedDataImpl<T> createCopy() {
|
||||
return new JpsTypedDataImpl<T>(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -56,7 +53,7 @@ public class JpsTypedDataImpl<T extends JpsElementType<?>> extends JpsElementBas
|
||||
public void setProperties(@NotNull JpsElementProperties properties) {
|
||||
if (!myProperties.equals(properties)) {
|
||||
myProperties = properties;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,19 +12,17 @@ import java.util.List;
|
||||
public class JpsUrlListImpl extends JpsElementBase<JpsUrlListImpl> implements JpsUrlList {
|
||||
private List<String> myUrls = new ArrayList<String>();
|
||||
|
||||
public JpsUrlListImpl(JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsUrlListImpl() {
|
||||
}
|
||||
|
||||
public JpsUrlListImpl(JpsUrlListImpl list, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(list, dispatcher, parent);
|
||||
public JpsUrlListImpl(JpsUrlListImpl list) {
|
||||
myUrls.addAll(list.myUrls);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsUrlListImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsUrlListImpl(this, eventDispatcher, parent);
|
||||
public JpsUrlListImpl createCopy() {
|
||||
return new JpsUrlListImpl(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -36,20 +34,20 @@ public class JpsUrlListImpl extends JpsElementBase<JpsUrlListImpl> implements Jp
|
||||
@Override
|
||||
public void addUrl(@NotNull String url) {
|
||||
myUrls.add(url);
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUrl(@NotNull String url) {
|
||||
myUrls.remove(url);
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsUrlListImpl modified) {
|
||||
if (!myUrls.equals(modified.myUrls)) {
|
||||
myUrls.clear();
|
||||
myUrls.addAll(modified.myUrls);
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,12 @@ import org.jetbrains.jps.model.*;
|
||||
public class SimpleJpsElementImpl<P extends JpsElementProperties> extends JpsElementBase<SimpleJpsElementImpl<P>> implements SimpleJpsElement<P> {
|
||||
private P myProperties;
|
||||
|
||||
public SimpleJpsElementImpl(JpsEventDispatcher eventDispatcher, P properties, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public SimpleJpsElementImpl(P properties) {
|
||||
myProperties = properties;
|
||||
}
|
||||
|
||||
public SimpleJpsElementImpl(SimpleJpsElementImpl<P> original, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
public SimpleJpsElementImpl(SimpleJpsElementImpl<P> original) {
|
||||
myProperties = original.myProperties;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -28,14 +27,14 @@ public class SimpleJpsElementImpl<P extends JpsElementProperties> extends JpsEle
|
||||
public void setProperties(@NotNull P properties) {
|
||||
if (!myProperties.equals(properties)) {
|
||||
myProperties = properties;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SimpleJpsElementImpl<P> createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new SimpleJpsElementImpl<P>(this, eventDispatcher, parent);
|
||||
public SimpleJpsElementImpl<P> createCopy() {
|
||||
return new SimpleJpsElementImpl<P>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,9 +2,6 @@ package org.jetbrains.jps.model.java.impl;
|
||||
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsElementBase;
|
||||
import org.jetbrains.jps.model.java.JavaModuleExtension;
|
||||
import org.jetbrains.jps.model.java.LanguageLevel;
|
||||
@@ -17,12 +14,10 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
private String myTestOutputUrl;
|
||||
private LanguageLevel myLanguageLevel;
|
||||
|
||||
public JavaModuleExtensionImpl(JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JavaModuleExtensionImpl() {
|
||||
}
|
||||
|
||||
public JavaModuleExtensionImpl(JavaModuleExtensionImpl original, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
public JavaModuleExtensionImpl(JavaModuleExtensionImpl original) {
|
||||
myOutputUrl = original.myOutputUrl;
|
||||
myTestOutputUrl = original.myTestOutputUrl;
|
||||
myLanguageLevel = original.myLanguageLevel;
|
||||
@@ -30,8 +25,8 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaModuleExtensionImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JavaModuleExtensionImpl(this, eventDispatcher, parent);
|
||||
public JavaModuleExtensionImpl createCopy() {
|
||||
return new JavaModuleExtensionImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,7 +38,7 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
public void setOutputUrl(String outputUrl) {
|
||||
if (!Comparing.equal(myOutputUrl, outputUrl)) {
|
||||
myOutputUrl = outputUrl;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +51,7 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
public void setTestOutputUrl(String testOutputUrl) {
|
||||
if (!Comparing.equal(myTestOutputUrl, testOutputUrl)) {
|
||||
myTestOutputUrl = testOutputUrl;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +64,7 @@ public class JavaModuleExtensionImpl extends JpsElementBase<JavaModuleExtensionI
|
||||
public void setLanguageLevel(LanguageLevel languageLevel) {
|
||||
if (!Comparing.equal(myLanguageLevel, languageLevel)) {
|
||||
myLanguageLevel = languageLevel;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ import org.jetbrains.jps.model.module.JpsModule;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JavaModuleExtensionKind extends JpsElementKind<JavaModuleExtensionImpl> implements JpsElementFactory<JavaModuleExtensionImpl> {
|
||||
public class JavaModuleExtensionKind extends JpsElementKind<JavaModuleExtensionImpl> implements JpsElementCreator<JavaModuleExtensionImpl> {
|
||||
private static final JavaModuleExtensionKind INSTANCE = new JavaModuleExtensionKind();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JavaModuleExtensionImpl create(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JavaModuleExtensionImpl(eventDispatcher, parent);
|
||||
public JavaModuleExtensionImpl create() {
|
||||
return new JavaModuleExtensionImpl();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jps.model.java.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsElementBase;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyExtension;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyScope;
|
||||
@@ -15,14 +12,13 @@ public class JpsJavaDependencyExtensionImpl extends JpsElementBase<JpsJavaDepend
|
||||
private boolean myExported;
|
||||
private JpsJavaDependencyScope myScope;
|
||||
|
||||
public JpsJavaDependencyExtensionImpl(JpsEventDispatcher eventDispatcher, JpsParentElement parent, boolean exported, JpsJavaDependencyScope scope) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsJavaDependencyExtensionImpl(boolean exported,
|
||||
JpsJavaDependencyScope scope) {
|
||||
myExported = exported;
|
||||
myScope = scope;
|
||||
}
|
||||
|
||||
public JpsJavaDependencyExtensionImpl(JpsJavaDependencyExtensionImpl original, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, eventDispatcher, parent);
|
||||
public JpsJavaDependencyExtensionImpl(JpsJavaDependencyExtensionImpl original) {
|
||||
myExported = original.myExported;
|
||||
myScope = original.myScope;
|
||||
}
|
||||
@@ -36,7 +32,7 @@ public class JpsJavaDependencyExtensionImpl extends JpsElementBase<JpsJavaDepend
|
||||
public void setExported(boolean exported) {
|
||||
if (myExported != exported) {
|
||||
myExported = exported;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,16 +46,14 @@ public class JpsJavaDependencyExtensionImpl extends JpsElementBase<JpsJavaDepend
|
||||
public void setScope(@NotNull JpsJavaDependencyScope scope) {
|
||||
if (!scope.equals(myScope)) {
|
||||
myScope = scope;
|
||||
getEventDispatcher().fireElementChanged(this);
|
||||
fireElementChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsJavaDependencyExtensionImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsJavaDependencyExtensionImpl(this, eventDispatcher, parent);
|
||||
public JpsJavaDependencyExtensionImpl createCopy() {
|
||||
return new JpsJavaDependencyExtensionImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,16 +9,13 @@ import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsJavaDependencyExtensionKind extends JpsElementKind<JpsJavaDependencyExtensionImpl>
|
||||
implements JpsElementFactory<JpsJavaDependencyExtensionImpl> {
|
||||
public class JpsJavaDependencyExtensionKind extends JpsElementKind<JpsJavaDependencyExtensionImpl> implements JpsElementCreator<JpsJavaDependencyExtensionImpl> {
|
||||
public static final JpsJavaDependencyExtensionKind INSTANCE = new JpsJavaDependencyExtensionKind();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsJavaDependencyExtensionImpl create(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsJavaDependencyExtensionImpl(eventDispatcher, parent, false, JpsJavaDependencyScope.COMPILE);
|
||||
public JpsJavaDependencyExtensionImpl create() {
|
||||
return new JpsJavaDependencyExtensionImpl(false, JpsJavaDependencyScope.COMPILE);
|
||||
}
|
||||
|
||||
public static JpsJavaDependencyExtension getExtension(@NotNull JpsDependencyElement element) {
|
||||
|
||||
@@ -18,15 +18,14 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase<JpsLibraryImpl,
|
||||
private static final JpsElementCollectionKind<JpsLibraryRootImpl> LIBRARY_ROOTS_COLLECTION = new JpsElementCollectionKind<JpsLibraryRootImpl>(JpsLibraryRootKind.INSTANCE);
|
||||
private static final JpsTypedDataKind<JpsLibraryType<?>> TYPED_DATA_KIND = new JpsTypedDataKind<JpsLibraryType<?>>();
|
||||
|
||||
public JpsLibraryImpl(@NotNull String name, @NotNull JpsLibraryType<?> type, @NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher, JpsElementCollection<JpsLibraryImpl> parent) {
|
||||
super(model, eventDispatcher, name, parent);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsLibraryType<?>>(type, eventDispatcher, this));
|
||||
public JpsLibraryImpl(@NotNull String name, @NotNull JpsLibraryType<?> type) {
|
||||
super(name);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsLibraryType<?>>(type));
|
||||
myContainer.setChild(LIBRARY_ROOTS_COLLECTION);
|
||||
}
|
||||
|
||||
public JpsLibraryImpl(@NotNull JpsLibraryImpl original, JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
private JpsLibraryImpl(@NotNull JpsLibraryImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -43,7 +42,7 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase<JpsLibraryImpl,
|
||||
|
||||
@Override
|
||||
public void addUrl(@NotNull final String url, @NotNull final JpsLibraryRootType rootType) {
|
||||
getRootsCollection().addChild(new JpsLibraryRootImpl(getEventDispatcher(), url, rootType, this));
|
||||
getRootsCollection().addChild(new JpsLibraryRootImpl(url, rootType));
|
||||
}
|
||||
|
||||
private JpsElementCollectionImpl<JpsLibraryRootImpl> getRootsCollection() {
|
||||
@@ -67,21 +66,20 @@ public class JpsLibraryImpl extends JpsNamedCompositeElementBase<JpsLibraryImpl,
|
||||
}
|
||||
|
||||
public JpsElementCollectionImpl<JpsLibraryImpl> getParent() {
|
||||
//noinspection unchecked
|
||||
return (JpsElementCollectionImpl<JpsLibraryImpl>)myParent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsLibraryImpl(this, model, eventDispatcher, parent);
|
||||
public JpsLibraryImpl createCopy() {
|
||||
return new JpsLibraryImpl(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryReference createReference(JpsParentElement parent) {
|
||||
public JpsLibraryReference createReference() {
|
||||
//noinspection unchecked
|
||||
final JpsElementReference<JpsCompositeElement> parentReference = ((JpsReferenceableElement<JpsCompositeElement>)getParent().getParent()).createReference(parent);
|
||||
return new JpsLibraryReferenceImpl(myModel, getEventDispatcher(), getName(), parentReference, parent);
|
||||
final JpsElementReference<JpsCompositeElement> parentReference = ((JpsReferenceableElement<JpsCompositeElement>)getParent().getParent()).createReference();
|
||||
return new JpsLibraryReferenceImpl(getName(), parentReference);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsLibraryReferenceImpl extends JpsNamedElementReferenceBase<JpsLibrary, JpsLibraryReferenceImpl> implements JpsLibraryReference {
|
||||
public JpsLibraryReferenceImpl(JpsModel model, JpsEventDispatcher eventDispatcher, String elementName, JpsElementReference<? extends JpsCompositeElement> parentReference,
|
||||
JpsParentElement parent) {
|
||||
super(model, eventDispatcher, JpsLibraryKind.LIBRARIES_COLLECTION_KIND, elementName, parentReference, parent);
|
||||
public JpsLibraryReferenceImpl(String elementName, JpsElementReference<? extends JpsCompositeElement> parentReference) {
|
||||
super(JpsLibraryKind.LIBRARIES_COLLECTION_KIND, elementName, parentReference);
|
||||
}
|
||||
|
||||
public JpsLibraryReferenceImpl(JpsLibraryReferenceImpl original, JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
private JpsLibraryReferenceImpl(JpsLibraryReferenceImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -27,9 +26,13 @@ public class JpsLibraryReferenceImpl extends JpsNamedElementReferenceBase<JpsLib
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryReferenceImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsLibraryReferenceImpl(this, model, eventDispatcher, parent);
|
||||
public JpsLibraryReferenceImpl createCopy() {
|
||||
return new JpsLibraryReferenceImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsLibraryReference asExternal(@NotNull JpsModel model) {
|
||||
model.registerExternalReference(this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jps.model.library.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsElementBase;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryRoot;
|
||||
@@ -16,14 +13,13 @@ public class JpsLibraryRootImpl extends JpsElementBase<JpsLibraryRootImpl> imple
|
||||
private final String myUrl;
|
||||
private final JpsLibraryRootType myRootType;
|
||||
|
||||
public JpsLibraryRootImpl(JpsEventDispatcher eventDispatcher, @NotNull String url, @NotNull JpsLibraryRootType rootType, @NotNull JpsParentElement parent) {
|
||||
super(eventDispatcher, parent);
|
||||
public JpsLibraryRootImpl(@NotNull String url,
|
||||
@NotNull JpsLibraryRootType rootType) {
|
||||
myUrl = url;
|
||||
myRootType = rootType;
|
||||
}
|
||||
|
||||
public JpsLibraryRootImpl(JpsLibraryRootImpl original, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, dispatcher, parent);
|
||||
public JpsLibraryRootImpl(JpsLibraryRootImpl original) {
|
||||
myUrl = original.myUrl;
|
||||
myRootType = original.myRootType;
|
||||
}
|
||||
@@ -41,8 +37,8 @@ public class JpsLibraryRootImpl extends JpsElementBase<JpsLibraryRootImpl> imple
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryRootImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsLibraryRootImpl(this, eventDispatcher, parent);
|
||||
public JpsLibraryRootImpl createCopy() {
|
||||
return new JpsLibraryRootImpl(this);
|
||||
}
|
||||
|
||||
public void applyChanges(@NotNull JpsLibraryRootImpl modified) {
|
||||
@@ -51,6 +47,6 @@ public class JpsLibraryRootImpl extends JpsElementBase<JpsLibraryRootImpl> imple
|
||||
@Override
|
||||
@NotNull
|
||||
public JpsLibrary getLibrary() {
|
||||
return (JpsLibrary)myParent;
|
||||
return (JpsLibrary)myParent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,10 @@ package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementKind;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
|
||||
import org.jetbrains.jps.model.impl.JpsElementCollectionKind;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
|
||||
@@ -20,13 +18,13 @@ public class JpsDependenciesListImpl extends JpsCompositeElementBase<JpsDependen
|
||||
public static final JpsElementKind<JpsDependencyElementBase<?>> DEPENDENCY_ELEMENT_KIND = new JpsElementKind<JpsDependencyElementBase<?>>();
|
||||
public static final JpsElementCollectionKind<JpsDependencyElementBase<?>> DEPENDENCY_COLLECTION_KIND = new JpsElementCollectionKind<JpsDependencyElementBase<?>>(DEPENDENCY_ELEMENT_KIND);
|
||||
|
||||
public JpsDependenciesListImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsModuleImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
public JpsDependenciesListImpl() {
|
||||
super();
|
||||
myContainer.setChild(DEPENDENCY_COLLECTION_KIND);
|
||||
}
|
||||
|
||||
public JpsDependenciesListImpl(JpsDependenciesListImpl original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
private JpsDependenciesListImpl(JpsDependenciesListImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,7 +36,13 @@ public class JpsDependenciesListImpl extends JpsCompositeElementBase<JpsDependen
|
||||
@Override
|
||||
@NotNull
|
||||
public JpsModuleDependency addModuleDependency(@NotNull JpsModule module) {
|
||||
final JpsModuleDependencyImpl dependency = new JpsModuleDependencyImpl(myModel, getEventDispatcher(), module, this);
|
||||
return addModuleDependency(module.createReference());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleDependency addModuleDependency(@NotNull JpsModuleReference moduleReference) {
|
||||
final JpsModuleDependencyImpl dependency = new JpsModuleDependencyImpl(moduleReference);
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(dependency);
|
||||
return dependency;
|
||||
}
|
||||
@@ -46,25 +50,31 @@ public class JpsDependenciesListImpl extends JpsCompositeElementBase<JpsDependen
|
||||
@Override
|
||||
@NotNull
|
||||
public JpsLibraryDependency addLibraryDependency(@NotNull JpsLibrary libraryElement) {
|
||||
JpsLibraryDependencyImpl dependency = new JpsLibraryDependencyImpl(myModel, getEventDispatcher(), libraryElement, this);
|
||||
return addLibraryDependency(libraryElement.createReference());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryDependency addLibraryDependency(@NotNull JpsLibraryReference libraryReference) {
|
||||
final JpsLibraryDependencyImpl dependency = new JpsLibraryDependencyImpl(libraryReference);
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(dependency);
|
||||
return dependency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModuleSourceDependency() {
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsModuleSourceDependency(myModel, getEventDispatcher(), this));
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsModuleSourceDependency());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSdkDependency(@NotNull JpsSdkType<?> sdkType) {
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsSdkDependencyImpl(sdkType, myModel, getEventDispatcher(), this));
|
||||
myContainer.getChild(DEPENDENCY_COLLECTION_KIND).addChild(new JpsSdkDependencyImpl(sdkType));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsDependenciesListImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsDependenciesListImpl(this, model, eventDispatcher, parent);
|
||||
public JpsDependenciesListImpl createCopy() {
|
||||
return new JpsDependenciesListImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
|
||||
import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
|
||||
@@ -10,16 +7,16 @@ import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsDependencyElementBase<Self extends JpsDependencyElementBase<Self>> extends JpsCompositeElementBase<Self> implements JpsDependencyElement {
|
||||
protected JpsDependencyElementBase(JpsModel model, JpsEventDispatcher eventDispatcher, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
protected JpsDependencyElementBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected JpsDependencyElementBase(JpsDependencyElementBase<Self> original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
protected JpsDependencyElementBase(JpsDependencyElementBase<Self> original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
((JpsDependenciesListImpl)myParent).getContainer().getChild(JpsDependenciesListImpl.DEPENDENCY_COLLECTION_KIND).removeChild(this);
|
||||
((JpsDependenciesListImpl)myParent.getParent()).getContainer().getChild(JpsDependenciesListImpl.DEPENDENCY_COLLECTION_KIND).removeChild(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.module.JpsLibraryDependency;
|
||||
|
||||
@@ -12,13 +11,13 @@ import org.jetbrains.jps.model.module.JpsLibraryDependency;
|
||||
public class JpsLibraryDependencyImpl extends JpsDependencyElementBase<JpsLibraryDependencyImpl> implements JpsLibraryDependency {
|
||||
public static final JpsElementKind<JpsLibraryReference> LIBRARY_REFERENCE_KIND = new JpsElementKind<JpsLibraryReference>();
|
||||
|
||||
public JpsLibraryDependencyImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsLibrary library, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
myContainer.setChild(LIBRARY_REFERENCE_KIND, library.createReference(parent));
|
||||
public JpsLibraryDependencyImpl(final JpsLibraryReference reference) {
|
||||
super();
|
||||
myContainer.setChild(LIBRARY_REFERENCE_KIND, reference);
|
||||
}
|
||||
|
||||
public JpsLibraryDependencyImpl(JpsLibraryDependencyImpl original, @NotNull JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
public JpsLibraryDependencyImpl(JpsLibraryDependencyImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -29,9 +28,7 @@ public class JpsLibraryDependencyImpl extends JpsDependencyElementBase<JpsLibrar
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibraryDependencyImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsLibraryDependencyImpl(this, model, eventDispatcher, parent);
|
||||
public JpsLibraryDependencyImpl createCopy() {
|
||||
return new JpsLibraryDependencyImpl(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.module.JpsModuleDependency;
|
||||
import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
|
||||
@@ -12,13 +11,13 @@ import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
public class JpsModuleDependencyImpl extends JpsDependencyElementBase<JpsModuleDependencyImpl> implements JpsModuleDependency {
|
||||
private static final JpsElementKind<JpsModuleReference> MODULE_REFERENCE_KIND = new JpsElementKind<JpsModuleReference>();
|
||||
|
||||
public JpsModuleDependencyImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsModule module, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
myContainer.setChild(MODULE_REFERENCE_KIND, module.createReference(this));
|
||||
public JpsModuleDependencyImpl(final JpsModuleReference moduleReference) {
|
||||
super();
|
||||
myContainer.setChild(MODULE_REFERENCE_KIND, moduleReference);
|
||||
}
|
||||
|
||||
public JpsModuleDependencyImpl(JpsModuleDependencyImpl original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
public JpsModuleDependencyImpl(JpsModuleDependencyImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -29,9 +28,7 @@ public class JpsModuleDependencyImpl extends JpsDependencyElementBase<JpsModuleD
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleDependencyImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsModuleDependencyImpl(this, model, eventDispatcher, parent);
|
||||
public JpsModuleDependencyImpl createCopy() {
|
||||
return new JpsModuleDependencyImpl(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package org.jetbrains.jps.model.module.impl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.*;
|
||||
import org.jetbrains.jps.model.impl.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryType;
|
||||
import org.jetbrains.jps.model.library.impl.JpsLibraryImpl;
|
||||
import org.jetbrains.jps.model.library.impl.JpsLibraryKind;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -16,24 +20,26 @@ public class JpsModuleImpl extends JpsNamedCompositeElementBase<JpsModuleImpl, J
|
||||
private static final JpsElementKind<JpsUrlListImpl> EXCLUDED_ROOTS_KIND = new JpsElementKind<JpsUrlListImpl>();
|
||||
public static final JpsElementKind<JpsDependenciesListImpl> DEPENDENCIES_LIST_KIND = new JpsElementKind<JpsDependenciesListImpl>();
|
||||
|
||||
public JpsModuleImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsModuleType type, @NotNull String name, JpsElementCollectionImpl<JpsModuleImpl> parent) {
|
||||
super(model, eventDispatcher, name, parent);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsModuleType<?>>(type, eventDispatcher, this));
|
||||
myContainer.setChild(CONTENT_ROOTS_KIND, new JpsUrlListImpl(eventDispatcher, this));
|
||||
myContainer.setChild(EXCLUDED_ROOTS_KIND, new JpsUrlListImpl(eventDispatcher, this));
|
||||
myContainer.setChild(DEPENDENCIES_LIST_KIND, new JpsDependenciesListImpl(model, eventDispatcher, this));
|
||||
public JpsModuleImpl(JpsModuleType type,
|
||||
@NotNull String name) {
|
||||
super(name);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsModuleType<?>>(type));
|
||||
myContainer.setChild(CONTENT_ROOTS_KIND, new JpsUrlListImpl());
|
||||
myContainer.setChild(EXCLUDED_ROOTS_KIND, new JpsUrlListImpl());
|
||||
myContainer.setChild(DEPENDENCIES_LIST_KIND, new JpsDependenciesListImpl());
|
||||
myContainer.setChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
myContainer.setChild(JpsModuleSourceRootKind.ROOT_COLLECTION_KIND);
|
||||
myContainer.setChild(JpsSdkReferencesTableImpl.KIND, new JpsSdkReferencesTableImpl(model, eventDispatcher, this));
|
||||
myContainer.setChild(JpsSdkReferencesTableImpl.KIND, new JpsSdkReferencesTableImpl());
|
||||
}
|
||||
|
||||
public JpsModuleImpl(JpsModuleImpl original, JpsEventDispatcher eventDispatcher, JpsModel model, JpsParentElement parent) {
|
||||
super(original, model, eventDispatcher, parent);
|
||||
private JpsModuleImpl(JpsModuleImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsModuleImpl(this, eventDispatcher, model, parent);
|
||||
public JpsModuleImpl createCopy() {
|
||||
return new JpsModuleImpl(this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -65,7 +71,7 @@ public class JpsModuleImpl extends JpsNamedCompositeElementBase<JpsModuleImpl, J
|
||||
public <P extends JpsElementProperties> JpsModuleSourceRoot addSourceRoot(@NotNull JpsModuleSourceRootType<P> rootType,
|
||||
@NotNull String url,
|
||||
@NotNull P properties) {
|
||||
final JpsModuleSourceRootImpl root = new JpsModuleSourceRootImpl(myModel, getEventDispatcher(), url, rootType, this);
|
||||
final JpsModuleSourceRootImpl root = new JpsModuleSourceRootImpl(url, rootType);
|
||||
myContainer.getChild(JpsModuleSourceRootKind.ROOT_COLLECTION_KIND).addChild(root);
|
||||
root.setProperties(rootType, properties);
|
||||
return root;
|
||||
@@ -102,7 +108,14 @@ public class JpsModuleImpl extends JpsNamedCompositeElementBase<JpsModuleImpl, J
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleReference createReference(JpsParentElement parent) {
|
||||
return new JpsModuleReferenceImpl(myModel, getName(), getEventDispatcher(), parent);
|
||||
public JpsModuleReference createReference() {
|
||||
return new JpsModuleReferenceImpl(getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsLibrary addModuleLibrary(@NotNull JpsLibraryType<?> type, @NotNull String name) {
|
||||
final JpsElementCollectionImpl<JpsLibraryImpl> collection = myContainer.getChild(JpsLibraryKind.LIBRARIES_COLLECTION_KIND);
|
||||
return collection.addChild(new JpsLibraryImpl(name, type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsCompositeElement;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsNamedElementReferenceBase;
|
||||
import org.jetbrains.jps.model.impl.JpsProjectElementReference;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
@@ -14,16 +11,14 @@ import org.jetbrains.jps.model.module.JpsModuleReference;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsModuleReferenceImpl extends JpsNamedElementReferenceBase<JpsModule, JpsModuleReferenceImpl> implements JpsModuleReference {
|
||||
public JpsModuleReferenceImpl(JpsModel model, String elementName, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, JpsModuleKind.MODULE_COLLECTION_KIND, elementName, new JpsProjectElementReference(model, eventDispatcher, parent), parent);
|
||||
public JpsModuleReferenceImpl(String elementName) {
|
||||
super(JpsModuleKind.MODULE_COLLECTION_KIND, elementName, new JpsProjectElementReference());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleReferenceImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsModuleReferenceImpl(model, myElementName, eventDispatcher, parent);
|
||||
public JpsModuleReferenceImpl createCopy() {
|
||||
return new JpsModuleReferenceImpl(myElementName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -31,4 +26,10 @@ public class JpsModuleReferenceImpl extends JpsNamedElementReferenceBase<JpsModu
|
||||
public String getModuleName() {
|
||||
return myElementName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsModuleReference asExternal(@NotNull JpsModel model) {
|
||||
model.registerExternalReference(this);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,19 +9,17 @@ import org.jetbrains.jps.model.JpsParentElement;
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsModuleSourceDependency extends JpsDependencyElementBase<JpsModuleSourceDependency> {
|
||||
public JpsModuleSourceDependency(JpsModel model, JpsEventDispatcher eventDispatcher, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
public JpsModuleSourceDependency() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JpsModuleSourceDependency(JpsModuleSourceDependency original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
public JpsModuleSourceDependency(JpsModuleSourceDependency original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleSourceDependency createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsModuleSourceDependency(this, model, eventDispatcher, parent);
|
||||
public JpsModuleSourceDependency createCopy() {
|
||||
return new JpsModuleSourceDependency(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,16 +15,15 @@ public class JpsModuleSourceRootImpl extends JpsCompositeElementBase<JpsModuleSo
|
||||
private static final JpsTypedDataKind<JpsModuleSourceRootType<?>> TYPED_DATA_KIND = new JpsTypedDataKind<JpsModuleSourceRootType<?>>();
|
||||
private String myUrl;
|
||||
|
||||
public JpsModuleSourceRootImpl(JpsModel model, JpsEventDispatcher eventDispatcher,
|
||||
String url,
|
||||
JpsModuleSourceRootType type, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsModuleSourceRootType<?>>(type, eventDispatcher, this));
|
||||
public JpsModuleSourceRootImpl(String url,
|
||||
JpsModuleSourceRootType type) {
|
||||
super();
|
||||
myContainer.setChild(TYPED_DATA_KIND, new JpsTypedDataImpl<JpsModuleSourceRootType<?>>(type));
|
||||
myUrl = url;
|
||||
}
|
||||
|
||||
public JpsModuleSourceRootImpl(JpsModuleSourceRootImpl original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
private JpsModuleSourceRootImpl(JpsModuleSourceRootImpl original) {
|
||||
super(original);
|
||||
myUrl = original.myUrl;
|
||||
}
|
||||
|
||||
@@ -51,7 +50,7 @@ public class JpsModuleSourceRootImpl extends JpsCompositeElementBase<JpsModuleSo
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleSourceRootImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsModuleSourceRootImpl(this, model, eventDispatcher, parent);
|
||||
public JpsModuleSourceRootImpl createCopy() {
|
||||
return new JpsModuleSourceRootImpl(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
@@ -15,20 +12,20 @@ import org.jetbrains.jps.model.module.JpsSdkDependency;
|
||||
public class JpsSdkDependencyImpl extends JpsDependencyElementBase<JpsSdkDependencyImpl> implements JpsSdkDependency {
|
||||
private final JpsSdkType<?> mySdkType;
|
||||
|
||||
public JpsSdkDependencyImpl(@NotNull JpsSdkType<?> sdkType, JpsModel model, JpsEventDispatcher eventDispatcher, JpsDependenciesListImpl parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
public JpsSdkDependencyImpl(@NotNull JpsSdkType<?> sdkType) {
|
||||
super();
|
||||
mySdkType = sdkType;
|
||||
}
|
||||
|
||||
public JpsSdkDependencyImpl(JpsSdkDependencyImpl original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
public JpsSdkDependencyImpl(JpsSdkDependencyImpl original) {
|
||||
super(original);
|
||||
mySdkType = original.mySdkType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsSdkDependencyImpl createCopy(@NotNull JpsModel model, @NotNull JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
return new JpsSdkDependencyImpl(this, model, eventDispatcher, parent);
|
||||
public JpsSdkDependencyImpl createCopy() {
|
||||
return new JpsSdkDependencyImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,12 +36,11 @@ public class JpsSdkDependencyImpl extends JpsDependencyElementBase<JpsSdkDepende
|
||||
|
||||
@Override
|
||||
public JpsLibrary resolveSdk() {
|
||||
final JpsLibraryReference reference = getParent().getParent().getSdkReferencesTable().getSdkReference(mySdkType);
|
||||
final JpsLibraryReference reference = getDependenciesList().getParent().getSdkReferencesTable().getSdkReference(mySdkType);
|
||||
return reference != null ? reference.resolve() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsDependenciesListImpl getParent() {
|
||||
return (JpsDependenciesListImpl)super.getParent();
|
||||
public JpsDependenciesListImpl getDependenciesList() {
|
||||
return (JpsDependenciesListImpl)myParent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,7 @@ package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElementKind;
|
||||
import org.jetbrains.jps.model.JpsEventDispatcher;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsParentElement;
|
||||
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsSdkType;
|
||||
import org.jetbrains.jps.model.module.JpsSdkReferencesTable;
|
||||
@@ -17,25 +13,23 @@ import org.jetbrains.jps.model.module.JpsSdkReferencesTable;
|
||||
public class JpsSdkReferencesTableImpl extends JpsCompositeElementBase<JpsSdkReferencesTableImpl> implements JpsSdkReferencesTable {
|
||||
public static final JpsElementKind<JpsSdkReferencesTableImpl> KIND = new JpsElementKind<JpsSdkReferencesTableImpl>();
|
||||
|
||||
public JpsSdkReferencesTableImpl(JpsModel model, JpsEventDispatcher eventDispatcher, JpsParentElement parent) {
|
||||
super(model, eventDispatcher, parent);
|
||||
public JpsSdkReferencesTableImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JpsSdkReferencesTableImpl(JpsSdkReferencesTableImpl original, JpsModel model, JpsEventDispatcher dispatcher, JpsParentElement parent) {
|
||||
super(original, model, dispatcher, parent);
|
||||
private JpsSdkReferencesTableImpl(JpsSdkReferencesTableImpl original) {
|
||||
super(original);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsSdkReferencesTableImpl createCopy(@NotNull JpsModel model,
|
||||
@NotNull JpsEventDispatcher eventDispatcher,
|
||||
JpsParentElement parent) {
|
||||
return new JpsSdkReferencesTableImpl(this, model, eventDispatcher, parent);
|
||||
public JpsSdkReferencesTableImpl createCopy() {
|
||||
return new JpsSdkReferencesTableImpl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSdkReference(@NotNull JpsSdkType<?> type, @NotNull JpsLibrary sdk) {
|
||||
myContainer.setChild(new JpsSdkReferenceKind(type), sdk.createReference(this));
|
||||
public void setSdkReference(@NotNull JpsSdkType<?> type, @NotNull JpsLibraryReference sdkReference) {
|
||||
myContainer.setChild(new JpsSdkReferenceKind(type), sdkReference);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.jetbrains.jps.service.impl;
|
||||
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsServiceManagerImpl extends JpsServiceManager {
|
||||
private final ConcurrentHashMap<Class, Object> myServices = new ConcurrentHashMap<Class, Object>();
|
||||
|
||||
@Override
|
||||
public <T> T getService(Class<T> serviceClass) {
|
||||
//noinspection unchecked
|
||||
T service = (T)myServices.get(serviceClass);
|
||||
if (service == null) {
|
||||
final Iterator<T> iterator = ServiceLoader.load(serviceClass).iterator();
|
||||
if (!iterator.hasNext()) {
|
||||
throw new ServiceConfigurationError("Implementation for " + serviceClass + " not found");
|
||||
}
|
||||
service = iterator.next();
|
||||
if (iterator.hasNext()) {
|
||||
throw new ServiceConfigurationError("More than one implementation for " + serviceClass + " found: " + service.getClass() + " and " + iterator.next().getClass());
|
||||
}
|
||||
myServices.putIfAbsent(serviceClass, service);
|
||||
}
|
||||
return service;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyExtension;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependencyScope;
|
||||
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
|
||||
import org.jetbrains.jps.model.java.JpsJavaModuleType;
|
||||
import org.jetbrains.jps.model.java.impl.JavaModuleExtensionKind;
|
||||
import org.jetbrains.jps.model.java.impl.JpsJavaDependencyExtensionImpl;
|
||||
import org.jetbrains.jps.model.java.impl.JpsJavaDependencyExtensionKind;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.module.JpsDependencyElement;
|
||||
@@ -31,7 +31,7 @@ public class JpsJavaExtensionTest extends JpsModelTestCase {
|
||||
model.commit();
|
||||
|
||||
final JpsDependencyElement dep = assertOneElement(assertOneElement(myModel.getProject().getModules()).getDependenciesList().getDependencies());
|
||||
final JpsJavaDependencyExtensionImpl extension = dep.getContainer().getChild(JpsJavaDependencyExtensionKind.INSTANCE);
|
||||
final JpsJavaDependencyExtension extension = dep.getContainer().getChild(JpsJavaDependencyExtensionKind.INSTANCE);
|
||||
assertTrue(extension.isExported());
|
||||
assertSame(JpsJavaDependencyScope.TEST, extension.getScope());
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.jps.model.impl.JpsProjectImpl;
|
||||
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryReference;
|
||||
import org.jetbrains.jps.model.library.JpsLibraryRootType;
|
||||
import org.jetbrains.jps.model.library.impl.JpsLibraryReferenceImpl;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
@@ -31,14 +29,13 @@ public class JpsLibraryTest extends JpsModelTestCase {
|
||||
|
||||
public void testCreateReferenceByLibrary() {
|
||||
final JpsLibrary library = myModel.getProject().addLibrary(JpsJavaLibraryType.INSTANCE, "l");
|
||||
final JpsLibraryReference reference = library.createReference(myModel.getProject());
|
||||
final JpsLibraryReference reference = library.createReference().asExternal(myModel);
|
||||
assertEquals("l", reference.getLibraryName());
|
||||
assertSame(library, reference.resolve());
|
||||
}
|
||||
|
||||
public void testCreateReferenceByName() {
|
||||
final JpsProjectImpl project = myModel.getProject();
|
||||
JpsLibraryReference reference = new JpsLibraryReferenceImpl(myModel, myDispatcher, "l", myModel.getProject().createReference(project), project);
|
||||
JpsLibraryReference reference = JpsElementFactory.getInstance().createLibraryReference("l", myModel.getProject().createReference()).asExternal(myModel);
|
||||
assertEquals("l", reference.getLibraryName());
|
||||
assertNull(reference.resolve());
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.jps.model.impl.JpsModelImpl;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsModelTestCase extends UsefulTestCase {
|
||||
protected JpsModelImpl myModel;
|
||||
protected JpsModel myModel;
|
||||
protected TestJpsEventDispatcher myDispatcher;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import org.jetbrains.jps.model.impl.JpsProjectImpl;
|
||||
import org.jetbrains.jps.model.java.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
import org.jetbrains.jps.model.module.impl.JpsModuleReferenceImpl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -74,32 +72,31 @@ public class JpsModuleTest extends JpsModelTestCase {
|
||||
m.getDependenciesList().getDependencies().get(0).remove();
|
||||
m.getDependenciesList().addModuleDependency(dep);
|
||||
modifiableModel.commit();
|
||||
assertSame(library, assertOneElement(myDispatcher.retrieveRemoved(JpsLibraryDependency.class)).getLibraryReference().resolve());
|
||||
assertOneElement(myDispatcher.retrieveRemoved(JpsLibraryDependency.class));
|
||||
assertSame(dep, assertOneElement(myDispatcher.retrieveAdded(JpsModuleDependency.class)).getModuleReference().resolve());
|
||||
assertSame(dep, assertInstanceOf(assertOneElement(module.getDependenciesList().getDependencies()), JpsModuleDependency.class).getModuleReference().resolve());
|
||||
}
|
||||
|
||||
public void testCreateReferenceByModule() {
|
||||
final JpsModule module = myModel.getProject().addModule(JpsJavaModuleType.INSTANCE, "m");
|
||||
final JpsModuleReference reference = module.createReference(myModel.getProject());
|
||||
final JpsModuleReference reference = module.createReference().asExternal(myModel);
|
||||
assertEquals("m", reference.getModuleName());
|
||||
assertSame(module, reference.resolve());
|
||||
}
|
||||
|
||||
public void testCreateReferenceByName() {
|
||||
final JpsProjectImpl project = myModel.getProject();
|
||||
final JpsModuleReference reference = new JpsModuleReferenceImpl(myModel, "m", myDispatcher, project);
|
||||
final JpsModuleReference reference = JpsElementFactory.getInstance().createModuleReference("m").asExternal(myModel);
|
||||
assertEquals("m", reference.getModuleName());
|
||||
assertNull(reference.resolve());
|
||||
|
||||
final JpsModule module = project.addModule(JpsJavaModuleType.INSTANCE, "m");
|
||||
final JpsModule module = myModel.getProject().addModule(JpsJavaModuleType.INSTANCE, "m");
|
||||
assertSame(module, reference.resolve());
|
||||
}
|
||||
|
||||
public void testSdkDependency() {
|
||||
JpsLibrary sdk = myModel.getGlobal().addLibrary(JpsJavaSdkType.INSTANCE, "sdk");
|
||||
final JpsModule module = myModel.getProject().addModule(JpsJavaModuleType.INSTANCE, "m");
|
||||
module.getSdkReferencesTable().setSdkReference(JpsJavaSdkType.INSTANCE, sdk);
|
||||
module.getSdkReferencesTable().setSdkReference(JpsJavaSdkType.INSTANCE, sdk.createReference());
|
||||
module.getDependenciesList().addSdkDependency(JpsJavaSdkType.INSTANCE);
|
||||
|
||||
final JpsSdkDependency dependency = assertInstanceOf(assertOneElement(module.getDependenciesList().getDependencies()), JpsSdkDependency.class);
|
||||
|
||||
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 818 B After Width: | Height: | Size: 818 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -18,6 +18,7 @@ package com.intellij.ui.popup.util;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -30,16 +31,75 @@ import javax.swing.*;
|
||||
* Time: 5:34 AM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface DetailView {
|
||||
void updateWithItem(ItemWrapper wrapper);
|
||||
public interface DetailView extends UserDataHolder {
|
||||
|
||||
Editor getEditor();
|
||||
|
||||
void navigateInPreviewEditor(VirtualFile file, LogicalPosition positionToNavigate, TextAttributes lineAttributes);
|
||||
void navigateInPreviewEditor(PreviewEditorState editorState);
|
||||
|
||||
JPanel getDetailPanel();
|
||||
|
||||
void setDetailPanel(@Nullable JPanel panel);
|
||||
|
||||
void clearEditor();
|
||||
|
||||
PreviewEditorState getEditorState();
|
||||
|
||||
class PreviewEditorState {
|
||||
|
||||
public static PreviewEditorState EMPTY = new PreviewEditorState(null, null, null);
|
||||
|
||||
public static PreviewEditorState create(VirtualFile file, int line) {
|
||||
return new PreviewEditorState(file, new LogicalPosition(line, 0), null);
|
||||
}
|
||||
|
||||
public static PreviewEditorState create(VirtualFile file, int line, TextAttributes attributes) {
|
||||
return new PreviewEditorState(file, new LogicalPosition(line, 0), attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PreviewEditorState state = (PreviewEditorState)o;
|
||||
|
||||
if (myAttributes != null ? !myAttributes.equals(state.myAttributes) : state.myAttributes != null) return false;
|
||||
if (myFile != null ? !myFile.equals(state.myFile) : state.myFile != null) return false;
|
||||
if (myNavigate != null ? !myNavigate.equals(state.myNavigate) : state.myNavigate != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = myFile != null ? myFile.hashCode() : 0;
|
||||
result = 31 * result + (myNavigate != null ? myNavigate.hashCode() : 0);
|
||||
result = 31 * result + (myAttributes != null ? myAttributes.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
public VirtualFile getFile() {
|
||||
return myFile;
|
||||
}
|
||||
|
||||
public LogicalPosition getNavigate() {
|
||||
return myNavigate;
|
||||
}
|
||||
|
||||
public TextAttributes getAttributes() {
|
||||
return myAttributes;
|
||||
}
|
||||
|
||||
private final VirtualFile myFile;
|
||||
private final LogicalPosition myNavigate;
|
||||
private final TextAttributes myAttributes;
|
||||
|
||||
public PreviewEditorState(VirtualFile file, LogicalPosition navigate, TextAttributes attributes) {
|
||||
|
||||
myFile = file;
|
||||
myNavigate = navigate;
|
||||
myAttributes = attributes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,12 @@
|
||||
package com.intellij.ui.popup.util;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
import com.intellij.ui.ColoredTreeCellRenderer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: zajac
|
||||
* Date: 5/6/12
|
||||
* Time: 2:05 AM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public interface ItemWrapper {
|
||||
void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected);
|
||||
|
||||
@@ -37,8 +29,6 @@ public interface ItemWrapper {
|
||||
|
||||
void updateAccessoryView(JComponent label);
|
||||
|
||||
void execute(Project project, JBPopup popup);
|
||||
|
||||
String speedSearchText();
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -56,11 +56,6 @@ public class SplitterItem implements ItemWrapper {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Project project, JBPopup popup) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String speedSearchText() {
|
||||
return ""; //To change body of implemented methods use File | Settings | File Templates.
|
||||
|
||||
@@ -273,8 +273,10 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
|
||||
|
||||
myLeadPanel.add(myToolbarComponent);
|
||||
|
||||
if (myToolbarComponent instanceof ActionToolbarImpl) {
|
||||
new ShowMoreOptions(myToolbarComponent, mySearchField);
|
||||
if (secondaryActionsAvailable()) {
|
||||
if (myToolbarComponent instanceof ActionToolbarImpl) {
|
||||
new ShowMoreOptions(myToolbarComponent, mySearchField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -358,11 +360,11 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
|
||||
myActionsToolbar.setSecondaryActionsTooltip("More Options(" + ShowMoreOptions.SHORT_CUT + ")");
|
||||
|
||||
actionGroup.addAction(new ToggleWholeWordsOnlyAction(this));
|
||||
if (FindManagerImpl.ourHasSearchInCommentsAndLiterals) {
|
||||
if (secondaryActionsAvailable()) {
|
||||
actionGroup.addAction(new ToggleInCommentsAction(this)).setAsSecondary(true);
|
||||
actionGroup.addAction(new ToggleInLiteralsOnlyAction(this)).setAsSecondary(true);
|
||||
}
|
||||
actionGroup.addAction(new TogglePreserveCaseAction(this)).setAsSecondary(true);
|
||||
actionGroup.addAction(new TogglePreserveCaseAction(this));
|
||||
actionGroup.addAction(new ToggleSelectionOnlyAction(this));
|
||||
|
||||
|
||||
@@ -372,6 +374,10 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
|
||||
myToolbarComponent.setOpaque(false);
|
||||
}
|
||||
|
||||
private boolean secondaryActionsAvailable() {
|
||||
return FindManagerImpl.ourHasSearchInCommentsAndLiterals;
|
||||
}
|
||||
|
||||
private void setupSearchFieldListener() {
|
||||
mySearchField.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
@@ -484,9 +490,9 @@ public class EditorSearchComponent extends EditorHeaderComponent implements Data
|
||||
myReplaceField = createTextField(myReplacementPane);
|
||||
myReplaceUndo = new TextComponentUndoProvider(myReplaceField);
|
||||
|
||||
if (myToolbarComponent instanceof ActionToolbarImpl) {
|
||||
new ShowMoreOptions(myToolbarComponent, myReplaceField);
|
||||
}
|
||||
//if (myToolbarComponent instanceof ActionToolbarImpl) {
|
||||
// new ShowMoreOptions(myToolbarComponent, myReplaceField);
|
||||
//}
|
||||
|
||||
DocumentListener replaceFieldListener = new DocumentListener() {
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.intellij.find.FindSettings;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
|
||||
public class ToggleMatchCase extends EditorHeaderToggleAction {
|
||||
private static final String CASE_SENSITIVE = "&Case Sensitive";
|
||||
private static final String CASE_SENSITIVE = "&Match Case";
|
||||
|
||||
public ToggleMatchCase(EditorSearchComponent editorSearchComponent) {
|
||||
super(editorSearchComponent, CASE_SENSITIVE);
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.intellij.find.FindModel;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
|
||||
public class TogglePreserveCaseAction extends EditorHeaderToggleAction implements SecondaryHeaderAction {
|
||||
private static final String TEXT = "&Preserve Case";
|
||||
private static final String TEXT = "Preserve &Case";
|
||||
|
||||
public TogglePreserveCaseAction(EditorSearchComponent editorSearchComponent) {
|
||||
super(editorSearchComponent, TEXT);
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.intellij.find.EditorSearchComponent;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
|
||||
public class ToggleSelectionOnlyAction extends EditorHeaderToggleAction {
|
||||
private static final String SELECTION_ONLY = "&Selection Only";
|
||||
private static final String SELECTION_ONLY = "In &Selection";
|
||||
|
||||
public ToggleSelectionOnlyAction(EditorSearchComponent editorSearchComponent) {
|
||||
super(editorSearchComponent, SELECTION_ONLY);
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.intellij.find.FindSettings;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
|
||||
public class ToggleWholeWordsOnlyAction extends EditorHeaderToggleAction {
|
||||
private static final String WHOLE_WORDS_ONLY = "W&hole Words";
|
||||
private static final String WHOLE_WORDS_ONLY = "W&ords";
|
||||
|
||||
public ToggleWholeWordsOnlyAction(EditorSearchComponent editorSearchComponent) {
|
||||
super(editorSearchComponent, WHOLE_WORDS_ONLY);
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
*/
|
||||
package com.intellij.ide.bookmarks;
|
||||
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.markup.EffectType;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
@@ -110,22 +108,17 @@ public class BookmarkItem implements ItemWrapper {
|
||||
return myBookmark.getFile().getName() + " " + myBookmark.getDescription();
|
||||
}
|
||||
|
||||
public void execute(Project project, JBPopup popup) {
|
||||
popup.cancel();
|
||||
myBookmark.navigate();
|
||||
popup.cancel();
|
||||
}
|
||||
|
||||
public String footerText() {
|
||||
return myBookmark.getFile().getPresentableUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetailView(final DetailView panel) {
|
||||
VirtualFile file = myBookmark.getFile();
|
||||
LogicalPosition positionToNavigate = new LogicalPosition(myBookmark.getLine(), 0);
|
||||
doUpdateDetailView(panel);
|
||||
}
|
||||
|
||||
panel.navigateInPreviewEditor(file, positionToNavigate, null);
|
||||
private void doUpdateDetailView(DetailView panel) {
|
||||
panel.navigateInPreviewEditor(DetailView.PreviewEditorState.create(myBookmark.getFile(), myBookmark.getLine()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,8 @@ import com.intellij.ide.bookmarks.Bookmark;
|
||||
import com.intellij.ide.bookmarks.BookmarkItem;
|
||||
import com.intellij.ide.bookmarks.BookmarkManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -32,6 +33,8 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.popup.util.DetailViewImpl;
|
||||
import com.intellij.ui.popup.util.ItemWrapper;
|
||||
import com.intellij.ui.popup.util.MasterDetailPopupBuilder;
|
||||
import com.intellij.ui.speedSearch.FilteringListModel;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -121,6 +124,15 @@ public class BookmarksAction extends AnAction implements DumbAware, MasterDetail
|
||||
return new Object[0]; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void itemChosen(ItemWrapper item, Project project, JBPopup popup) {
|
||||
if (item instanceof BookmarkItem) {
|
||||
Bookmark bookmark = ((BookmarkItem)item).getBookmark();
|
||||
popup.cancel();
|
||||
bookmark.navigate();
|
||||
}
|
||||
}
|
||||
|
||||
private static DefaultListModel buildModel(Project project) {
|
||||
final DefaultListModel model = new DefaultListModel();
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
|
||||
private boolean myDisposed = false;
|
||||
private RelativePoint myLocationCache;
|
||||
|
||||
public NavBarPanel(final Project project) {
|
||||
public NavBarPanel(final Project project, boolean docked) {
|
||||
super(new FlowLayout(FlowLayout.LEFT, 0 , 0));
|
||||
myProject = project;
|
||||
myModel = new NavBarModel(myProject);
|
||||
@@ -123,11 +123,14 @@ public class NavBarPanel extends JPanel implements DataProvider, PopupOwner, Dis
|
||||
}
|
||||
};
|
||||
|
||||
final ActionCallback typeAheadDone = new ActionCallback();
|
||||
IdeFocusManager.getInstance(project).typeAheadUntil(typeAheadDone);
|
||||
myUpdateQueue.queueModelUpdateFromFocus();
|
||||
myUpdateQueue.queueRebuildUi();
|
||||
myUpdateQueue.queueTypeAheadDone(typeAheadDone);
|
||||
if (!docked) {
|
||||
final ActionCallback typeAheadDone = new ActionCallback();
|
||||
IdeFocusManager.getInstance(project).typeAheadUntil(typeAheadDone);
|
||||
myUpdateQueue.queueTypeAheadDone(typeAheadDone);
|
||||
}
|
||||
|
||||
Disposer.register(project, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -191,7 +191,7 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
|
||||
if (myNavigationBar != null && !Disposer.isDisposed(myNavigationBar)) {
|
||||
Disposer.dispose(myNavigationBar);
|
||||
}
|
||||
myNavigationBar = new NavBarPanel(myProject);
|
||||
myNavigationBar = new NavBarPanel(myProject, true);
|
||||
myWrapperPanel.putClientProperty("NavBarPanel", myNavigationBar);
|
||||
myNavigationBar.getModel().setFixedComponent(true);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,7 +39,7 @@ public class ShowNavBarAction extends AnAction implements DumbAware, PopupAction
|
||||
final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(context);
|
||||
if (!isInsideNavBar(component)) {
|
||||
final Editor editor = PlatformDataKeys.EDITOR.getData(context);
|
||||
final NavBarPanel toolbarPanel = new NavBarPanel(project);
|
||||
final NavBarPanel toolbarPanel = new NavBarPanel(project, false);
|
||||
toolbarPanel.showHint(editor, context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import javax.swing.*;
|
||||
|
||||
public class EmptyModuleType extends ModuleType<EmptyModuleBuilder> {
|
||||
private static final Icon ICON = AllIcons.Modules.EmptyProjectType;
|
||||
private static final Icon ICON = AllIcons.Modules.Types.EmptyProjectType;
|
||||
@NonNls public static final String EMPTY_MODULE = "EMPTY_MODULE";
|
||||
//private static final EmptyModuleType ourInstance = new EmptyModuleType();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import javax.swing.*;
|
||||
public abstract class WebModuleTypeBase<T extends ModuleBuilder> extends ModuleType<T> {
|
||||
@NonNls public static final String WEB_MODULE = "WEB_MODULE";
|
||||
|
||||
private static final Icon MODULE_ICON = AllIcons.Javaee.WebModuleBig;
|
||||
private static final Icon MODULE_ICON = AllIcons.Modules.Types.WebModule;
|
||||
private static final Icon MODULE_NODE_ICON_OPEN = AllIcons.Nodes.ModuleOpen;
|
||||
private static final Icon MODULE_NODE_ICON_CLOSED = AllIcons.Nodes.ModuleClosed;
|
||||
|
||||
|
||||
@@ -26,8 +26,12 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.UserDataHolderBase;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -40,7 +44,7 @@ import java.awt.*;
|
||||
* Time: 2:04 AM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class DetailViewImpl extends JPanel implements DetailView {
|
||||
public class DetailViewImpl extends JPanel implements DetailView, UserDataHolder {
|
||||
private final Project myProject;
|
||||
private Editor myEditor;
|
||||
private ItemWrapper myWrapper;
|
||||
@@ -51,6 +55,7 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
private JLabel myNothingToShow = new JLabel("Nothing to show");
|
||||
private JLabel myNothingToShowInEditor = new JLabel("Nothing to show");
|
||||
private RangeHighlighter myHighlighter;
|
||||
private PreviewEditorState myEditorState = PreviewEditorState.EMPTY;
|
||||
|
||||
public DetailViewImpl(Project project) {
|
||||
super(new BorderLayout());
|
||||
@@ -60,34 +65,24 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
myNothingToShowInEditor.setHorizontalAlignment(JLabel.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateWithItem(ItemWrapper wrapper) {
|
||||
if (myWrapper != wrapper) {
|
||||
myWrapper = wrapper;
|
||||
if (wrapper != null) {
|
||||
wrapper.updateDetailView(this);
|
||||
}
|
||||
else {
|
||||
clearEditor();
|
||||
repaint();
|
||||
}
|
||||
|
||||
revalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearEditor() {
|
||||
if (getEditor() != null) {
|
||||
clearHightlighting();
|
||||
remove(getEditor().getComponent());
|
||||
EditorFactory.getInstance().releaseEditor(getEditor());
|
||||
myEditorState = PreviewEditorState.EMPTY;
|
||||
setEditor(null);
|
||||
add(myNothingToShowInEditor, BorderLayout.CENTER);
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreviewEditorState getEditorState() {
|
||||
return myEditorState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
super.removeNotify();
|
||||
@@ -104,7 +99,12 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateInPreviewEditor(VirtualFile file, LogicalPosition positionToNavigate, @Nullable TextAttributes lineAttributes) {
|
||||
public void navigateInPreviewEditor(PreviewEditorState editorState) {
|
||||
myEditorState = editorState;
|
||||
|
||||
final VirtualFile file = editorState.getFile();
|
||||
final LogicalPosition positionToNavigate = editorState.getNavigate();
|
||||
final TextAttributes lineAttributes = editorState.getAttributes();
|
||||
Document document = FileDocumentManager.getInstance().getDocument(file);
|
||||
Project project = myProject;
|
||||
|
||||
@@ -134,10 +134,9 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
getEditor().getScrollingModel().scrollToCaret(ScrollType.CENTER);
|
||||
|
||||
clearHightlighting();
|
||||
if (lineAttributes != null){
|
||||
if (lineAttributes != null) {
|
||||
myHighlighter = getEditor().getMarkupModel().addLineHighlighter(positionToNavigate.line, HighlighterLayer.SELECTION - 1,
|
||||
lineAttributes);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -188,4 +187,16 @@ public class DetailViewImpl extends JPanel implements DetailView {
|
||||
}
|
||||
myDetailPanel = panel;
|
||||
}
|
||||
|
||||
final UserDataHolderBase myDataHolderBase = new UserDataHolderBase();
|
||||
|
||||
@Override
|
||||
public <T> T getUserData(@NotNull Key<T> key) {
|
||||
return myDataHolderBase.getUserData(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void putUserData(@NotNull Key<T> key, @Nullable T value) {
|
||||
myDataHolderBase.putUserData(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.ActionToolbar;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
@@ -42,13 +44,6 @@ import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: zajac
|
||||
* Date: 5/6/12
|
||||
* Time: 2:06 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class MasterDetailPopupBuilder {
|
||||
|
||||
private static final Color BORDER_COLOR = Gray._135;
|
||||
@@ -57,26 +52,27 @@ public class MasterDetailPopupBuilder {
|
||||
private Delegate myDelegate;
|
||||
private boolean myCloseOnEnter;
|
||||
|
||||
public DetailViewImpl getDetailView() {
|
||||
return myDetailView;
|
||||
}
|
||||
private DetailView myDetailView;
|
||||
|
||||
private DetailViewImpl myDetailView;
|
||||
private JLabel myPathLabel;
|
||||
|
||||
private JBPopup myPopup;
|
||||
private Alarm myUpdateAlarm;
|
||||
|
||||
|
||||
private JComponent myChooserComponent;
|
||||
private ActionToolbar myActionToolbar;
|
||||
private boolean myAddDetailViewToEast = true;
|
||||
|
||||
|
||||
public MasterDetailPopupBuilder setDetailView(DetailView detailView) {
|
||||
myDetailView = detailView;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionToolbar getActionToolbar() {
|
||||
return myActionToolbar;
|
||||
}
|
||||
|
||||
private ActionToolbar myActionToolbar;
|
||||
|
||||
public MasterDetailPopupBuilder(Project project) {
|
||||
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@@ -106,11 +102,20 @@ public class MasterDetailPopupBuilder {
|
||||
myUpdateAlarm.cancelAllRequests();
|
||||
myUpdateAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
myDetailView.updateWithItem(wrapper1);
|
||||
doUpdateDetailViewWithItem(wrapper1);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
protected void doUpdateDetailViewWithItem(ItemWrapper wrapper1) {
|
||||
if (wrapper1 != null) {
|
||||
wrapper1.updateDetailView(myDetailView);
|
||||
}
|
||||
else {
|
||||
myDetailView.clearEditor();
|
||||
}
|
||||
}
|
||||
|
||||
public JBPopup createMasterDetailPopup() {
|
||||
|
||||
setupRenderer();
|
||||
@@ -122,7 +127,10 @@ public class MasterDetailPopupBuilder {
|
||||
myPathLabel.setFont(font.deriveFont((float)10));
|
||||
|
||||
myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);
|
||||
myDetailView = new DetailViewImpl(myProject);
|
||||
|
||||
if (myDetailView == null) {
|
||||
myDetailView = new DetailViewImpl(myProject);
|
||||
}
|
||||
|
||||
JPanel footerPanel = new JPanel(new BorderLayout()) {
|
||||
@Override
|
||||
@@ -139,14 +147,13 @@ public class MasterDetailPopupBuilder {
|
||||
IdeFocusManager.getInstance(myProject).doWhenFocusSettlesDown(new Runnable() {
|
||||
public void run() {
|
||||
Object[] values = getSelectedItems();
|
||||
|
||||
if (values.length == 1) {
|
||||
((ItemWrapper)values[0]).execute(myProject, myPopup);
|
||||
myDelegate.itemChosen((ItemWrapper)values[0], myProject, myPopup);
|
||||
}
|
||||
else {
|
||||
for (Object value : values) {
|
||||
if (value instanceof ItemWrapper) {
|
||||
((ItemWrapper)value).execute(myProject, myPopup);
|
||||
myDelegate.itemChosen((ItemWrapper)value, myProject, myPopup);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -158,21 +165,34 @@ public class MasterDetailPopupBuilder {
|
||||
footerPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
|
||||
footerPanel.add(myPathLabel);
|
||||
|
||||
myActionToolbar = ActionManager.getInstance().createActionToolbar("", myActions, true);
|
||||
myActionToolbar.setReservePlaceAutoPopupIcon(false);
|
||||
myActionToolbar.setMinimumButtonSize(new Dimension(20, 20));
|
||||
final JComponent toolBar = myActionToolbar.getComponent();
|
||||
toolBar.setOpaque(false);
|
||||
JComponent toolBar = null;
|
||||
if (myActions != null) {
|
||||
myActionToolbar = ActionManager.getInstance().createActionToolbar("", myActions, true);
|
||||
myActionToolbar.setReservePlaceAutoPopupIcon(false);
|
||||
myActionToolbar.setMinimumButtonSize(new Dimension(20, 20));
|
||||
toolBar = myActionToolbar.getComponent();
|
||||
toolBar.setOpaque(false);
|
||||
}
|
||||
|
||||
final PopupChooserBuilder builder = createInnerBuilder();
|
||||
myPopup = builder.
|
||||
setTitle(myDelegate.getTitle()).
|
||||
final PopupChooserBuilder builder = createInnerBuilder().
|
||||
setMovable(true).
|
||||
setResizable(true).
|
||||
setAutoselectOnMouseMove(false).
|
||||
setSettingButton(toolBar).
|
||||
setSouthComponent(footerPanel).
|
||||
setEastComponent(myDetailView).
|
||||
setSouthComponent(footerPanel);
|
||||
|
||||
if (myAddDetailViewToEast) {
|
||||
builder.
|
||||
setEastComponent((JComponent)myDetailView);
|
||||
}
|
||||
|
||||
String title = myDelegate.getTitle();
|
||||
if (title != null) {
|
||||
builder.setTitle(title);
|
||||
}
|
||||
|
||||
|
||||
builder.
|
||||
setItemChoosenCallback(runnable).
|
||||
setCloseOnEnter(myCloseOnEnter).
|
||||
setMayBeParent(true).
|
||||
@@ -181,7 +201,20 @@ public class MasterDetailPopupBuilder {
|
||||
public String fun(Object o) {
|
||||
return ((ItemWrapper)o).speedSearchText();
|
||||
}
|
||||
}).createPopup();
|
||||
});
|
||||
|
||||
myPopup = builder.createPopup();
|
||||
myPopup.addListener(new JBPopupListener() {
|
||||
@Override
|
||||
public void beforeShown(LightweightWindowEvent event) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(LightweightWindowEvent event) {
|
||||
myDetailView.clearEditor();
|
||||
}
|
||||
});
|
||||
return myPopup;
|
||||
}
|
||||
|
||||
@@ -214,11 +247,16 @@ public class MasterDetailPopupBuilder {
|
||||
|
||||
private void updateDetailViewLater() {
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
doUpdateDetailView();
|
||||
}
|
||||
});
|
||||
//SwingUtilities.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// doUpdateDetailView();
|
||||
// }
|
||||
//});
|
||||
doUpdateDetailView();
|
||||
}
|
||||
|
||||
public void setAddDetailViewToEast(boolean addDetailViewToEast) {
|
||||
myAddDetailViewToEast = addDetailViewToEast;
|
||||
}
|
||||
|
||||
public static boolean allowedToRemoveItems(Object[] values) {
|
||||
@@ -271,7 +309,7 @@ public class MasterDetailPopupBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public MasterDetailPopupBuilder setActionsGroup(ActionGroup actions) {
|
||||
public MasterDetailPopupBuilder setActionsGroup(@Nullable ActionGroup actions) {
|
||||
myActions = actions;
|
||||
return this;
|
||||
}
|
||||
@@ -332,6 +370,7 @@ public class MasterDetailPopupBuilder {
|
||||
}
|
||||
|
||||
public interface Delegate {
|
||||
@Nullable
|
||||
String getTitle();
|
||||
|
||||
void handleMnemonic(KeyEvent e, Project project, JBPopup popup);
|
||||
@@ -340,6 +379,8 @@ public class MasterDetailPopupBuilder {
|
||||
JComponent createAccessoryView(Project project);
|
||||
|
||||
Object[] getSelectedItemsInTree();
|
||||
|
||||
void itemChosen(ItemWrapper item, Project project, JBPopup popup);
|
||||
}
|
||||
|
||||
public static class ListItemRenderer extends JPanel implements ListCellRenderer {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.openapi.actionSystem.ex;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -160,7 +161,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
}
|
||||
};
|
||||
|
||||
ListPopup popup = createPopup(onDispose);
|
||||
JBPopup popup = createPopup(onDispose);
|
||||
|
||||
popup.show(new RelativePoint(this, new Point(0, this.getHeight() - 1)));
|
||||
}
|
||||
@@ -171,7 +172,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
return myForcePressed ? null : super.getToolTipText();
|
||||
}
|
||||
|
||||
protected ListPopup createPopup(Runnable onDispose) {
|
||||
protected JBPopup createPopup(Runnable onDispose) {
|
||||
DefaultActionGroup group = createPopupActionGroup(this);
|
||||
|
||||
DataContext context = getDataContext();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.openapi.ui.popup;
|
||||
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
/**
|
||||
@@ -52,4 +53,5 @@ public interface ListPopup extends JBPopup {
|
||||
*/
|
||||
void setHandleAutoSelectionBeforeShow(boolean autoHandle);
|
||||
|
||||
void addListSelectionListener(ListSelectionListener listSelectionListener);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
|
||||
protected boolean myFocused;
|
||||
|
||||
protected JTree myTree;
|
||||
private boolean myOpaque = true;
|
||||
|
||||
private boolean myOpaque = true;
|
||||
public final Component getTreeCellRendererComponent(
|
||||
JTree tree,
|
||||
Object value,
|
||||
@@ -122,6 +122,10 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
|
||||
return this;
|
||||
}
|
||||
|
||||
public JTree getTree() {
|
||||
return myTree;
|
||||
}
|
||||
|
||||
protected boolean isFocused() {
|
||||
return myTree.hasFocus();
|
||||
}
|
||||
|
||||
@@ -364,6 +364,7 @@ public class ListPopupImpl extends WizardPopup implements ListPopup {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addListSelectionListener(ListSelectionListener listSelectionListener) {
|
||||
myList.addListSelectionListener(listSelectionListener);
|
||||
}
|
||||
|
||||
@@ -629,7 +629,6 @@ public class AllIcons {
|
||||
public static final Icon Ejb_jar_xml = IconLoader.getIcon("/javaee/ejb-jar_xml.png");
|
||||
public static final Icon EjbClass = IconLoader.getIcon("/javaee/ejbClass.png");
|
||||
public static final Icon EjbModule = IconLoader.getIcon("/javaee/ejbModule.png");
|
||||
public static final Icon EjbModuleBig = IconLoader.getIcon("/javaee/ejbModuleBig.png");
|
||||
public static final Icon EmbeddedAttributeOverlay = IconLoader.getIcon("/javaee/embeddedAttributeOverlay.png");
|
||||
public static final Icon EntityBean = IconLoader.getIcon("/javaee/entityBean.png");
|
||||
public static final Icon EntityBeanBig = IconLoader.getIcon("/javaee/entityBeanBig.png");
|
||||
@@ -638,12 +637,10 @@ public class AllIcons {
|
||||
public static final Icon InterceptorClass = IconLoader.getIcon("/javaee/interceptorClass.png");
|
||||
public static final Icon InterceptorMethod = IconLoader.getIcon("/javaee/interceptorMethod.png");
|
||||
public static final Icon JavaeeAppModule = IconLoader.getIcon("/javaee/JavaeeAppModule.png");
|
||||
public static final Icon JavaeeAppModuleBig = IconLoader.getIcon("/javaee/JavaeeAppModuleBig.png");
|
||||
public static final Icon JpaFacet = IconLoader.getIcon("/javaee/jpaFacet.png");
|
||||
public static final Icon Local = IconLoader.getIcon("/javaee/local.png");
|
||||
public static final Icon LocalHome = IconLoader.getIcon("/javaee/localHome.png");
|
||||
public static final Icon MessageBean = IconLoader.getIcon("/javaee/messageBean.png");
|
||||
public static final Icon MessageBeanBig = IconLoader.getIcon("/javaee/messageBeanBig.png");
|
||||
public static final Icon PersistenceAttribute = IconLoader.getIcon("/javaee/persistenceAttribute.png");
|
||||
public static final Icon PersistenceEmbeddable = IconLoader.getIcon("/javaee/persistenceEmbeddable.png");
|
||||
public static final Icon PersistenceEntity = IconLoader.getIcon("/javaee/persistenceEntity.png");
|
||||
@@ -655,11 +652,9 @@ public class AllIcons {
|
||||
public static final Icon PersistenceUnit = IconLoader.getIcon("/javaee/persistenceUnit.png");
|
||||
public static final Icon Remote = IconLoader.getIcon("/javaee/remote.png");
|
||||
public static final Icon SessionBean = IconLoader.getIcon("/javaee/sessionBean.png");
|
||||
public static final Icon SessionBeanBig = IconLoader.getIcon("/javaee/sessionBeanBig.png");
|
||||
public static final Icon UpdateRunningApplication = IconLoader.getIcon("/javaee/updateRunningApplication.png");
|
||||
public static final Icon Web_xml = IconLoader.getIcon("/javaee/web_xml.png");
|
||||
public static final Icon WebModule = IconLoader.getIcon("/javaee/webModule.png");
|
||||
public static final Icon WebModuleBig = IconLoader.getIcon("/javaee/webModuleBig.png");
|
||||
public static final Icon WebModuleGroup = IconLoader.getIcon("/javaee/webModuleGroup.png");
|
||||
public static final Icon WebService = IconLoader.getIcon("/javaee/WebService.png");
|
||||
public static final Icon WebServiceClient = IconLoader.getIcon("/javaee/WebServiceClient.png");
|
||||
@@ -681,16 +676,13 @@ public class AllIcons {
|
||||
public static final Icon DeleteContentFolderRollover = IconLoader.getIcon("/modules/deleteContentFolderRollover.png");
|
||||
public static final Icon DeleteContentRoot = IconLoader.getIcon("/modules/deleteContentRoot.png");
|
||||
public static final Icon DeleteContentRootRollover = IconLoader.getIcon("/modules/deleteContentRootRollover.png");
|
||||
public static final Icon EmptyProjectType = IconLoader.getIcon("/modules/emptyProjectType.png");
|
||||
public static final Icon ExcludeFolder = IconLoader.getIcon("/modules/excludeFolder.png");
|
||||
public static final Icon ExcludeRootClosed = IconLoader.getIcon("/modules/excludeRootClosed.png");
|
||||
public static final Icon ExcludeRootOpened = IconLoader.getIcon("/modules/excludeRootOpened.png");
|
||||
public static final Icon JavaModule = IconLoader.getIcon("/modules/javaModule.png");
|
||||
public static final Icon Library = IconLoader.getIcon("/modules/library.png");
|
||||
public static final Icon Merge = IconLoader.getIcon("/modules/merge.png");
|
||||
public static final Icon ModulesNode = IconLoader.getIcon("/modules/modulesNode.png");
|
||||
public static final Icon Output = IconLoader.getIcon("/modules/output.png");
|
||||
public static final Icon PluginModule = IconLoader.getIcon("/modules/pluginModule.png");
|
||||
public static final Icon SetPackagePrefix = IconLoader.getIcon("/modules/setPackagePrefix.png");
|
||||
public static final Icon SetPackagePrefixRollover = IconLoader.getIcon("/modules/setPackagePrefixRollover.png");
|
||||
public static final Icon SourceClosed = IconLoader.getIcon("/modules/sourceClosed.png");
|
||||
@@ -703,6 +695,16 @@ public class AllIcons {
|
||||
public static final Icon TestRootOpened = IconLoader.getIcon("/modules/testRootOpened.png");
|
||||
public static final Icon TestSourceClosed = IconLoader.getIcon("/modules/testSourceClosed.png");
|
||||
public static final Icon TestSourceOpened = IconLoader.getIcon("/modules/testSourceOpened.png");
|
||||
|
||||
public static class Types {
|
||||
public static final Icon EjbModule = IconLoader.getIcon("/modules/types/ejbModule.png");
|
||||
public static final Icon EmptyProjectType = IconLoader.getIcon("/modules/types/emptyProjectType.png");
|
||||
public static final Icon JavaeeAppModule = IconLoader.getIcon("/modules/types/JavaeeAppModule.png");
|
||||
public static final Icon JavaModule = IconLoader.getIcon("/modules/types/javaModule.png");
|
||||
public static final Icon PluginModule = IconLoader.getIcon("/modules/types/pluginModule.png");
|
||||
public static final Icon WebModule = IconLoader.getIcon("/modules/types/webModule.png");
|
||||
|
||||
}
|
||||
public static final Icon UnmarkWebroot = IconLoader.getIcon("/modules/unmarkWebroot.png");
|
||||
public static final Icon WebRoot = IconLoader.getIcon("/modules/webRoot.png");
|
||||
|
||||
|
||||
@@ -16,14 +16,13 @@
|
||||
package com.intellij.xdebugger.breakpoints.ui;
|
||||
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.impl.DocumentMarkupModel;
|
||||
import com.intellij.openapi.editor.markup.MarkupModel;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.ColoredListCellRenderer;
|
||||
@@ -43,17 +42,25 @@ import javax.swing.*;
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public abstract class BreakpointItem implements ItemWrapper {
|
||||
protected static final Key<Object> BREAKPOINT_ITEM = Key.create("BreakpointItem");
|
||||
|
||||
public abstract Object getBreakpoint();
|
||||
|
||||
public abstract boolean isEnabled();
|
||||
|
||||
public abstract void setEnabled(boolean state);
|
||||
|
||||
protected void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
|
||||
protected boolean showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
|
||||
TextAttributes attributes =
|
||||
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
|
||||
|
||||
panel.navigateInPreviewEditor(virtualFile, new LogicalPosition(line, 0), attributes);
|
||||
DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);
|
||||
|
||||
if (state.equals(panel.getEditorState())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
panel.navigateInPreviewEditor(state);
|
||||
|
||||
TextAttributes softerAttributes = attributes.clone();
|
||||
softerAttributes.setBackgroundColor(ColorUtil.softer(softerAttributes.getBackgroundColor()));
|
||||
@@ -72,10 +79,7 @@ public abstract class BreakpointItem implements ItemWrapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Project project, JBPopup popup) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,14 +90,49 @@ public abstract class BreakpointItem implements ItemWrapper {
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
|
||||
setupGenericRenderer(renderer);
|
||||
setupGenericRenderer(renderer, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredTreeCellRenderer renderer) {
|
||||
setupGenericRenderer(renderer);
|
||||
boolean plainView = renderer.getTree().getClientProperty("plainView") != null;
|
||||
setupGenericRenderer(renderer, plainView);
|
||||
}
|
||||
|
||||
protected abstract void setupGenericRenderer(SimpleColoredComponent renderer);
|
||||
@Override
|
||||
public void updateDetailView(DetailView panel) {
|
||||
|
||||
if (panel.getUserData(BREAKPOINT_ITEM) == getBreakpoint()) {
|
||||
return;
|
||||
}
|
||||
|
||||
doUpdateDetailView(panel);
|
||||
|
||||
panel.putUserData(BREAKPOINT_ITEM, getBreakpoint());
|
||||
}
|
||||
|
||||
protected abstract void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView);
|
||||
|
||||
public abstract Icon getIcon();
|
||||
|
||||
public abstract String getDisplayText();
|
||||
|
||||
protected abstract void doUpdateDetailView(DetailView panel);
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BreakpointItem item = (BreakpointItem)o;
|
||||
|
||||
if (getBreakpoint() != null ? !getBreakpoint().equals(item.getBreakpoint()) : item.getBreakpoint() != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getBreakpoint() != null ? getBreakpoint().hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,22 +46,28 @@ class XBreakpointItem extends BreakpointItem {
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredListCellRenderer renderer, Project project, boolean selected) {
|
||||
setupGenericRenderer(renderer);
|
||||
setupGenericRenderer(renderer, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupRenderer(ColoredTreeCellRenderer renderer) {
|
||||
setupGenericRenderer(renderer);
|
||||
setupGenericRenderer(renderer, false);
|
||||
}
|
||||
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer) {
|
||||
//renderer.setIcon(getIcon());
|
||||
protected void setupGenericRenderer(SimpleColoredComponent renderer, boolean plainView) {
|
||||
if (plainView) {
|
||||
renderer.setIcon(getIcon());
|
||||
}
|
||||
final SimpleTextAttributes attributes =
|
||||
myBreakpoint.isEnabled() ? SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES : SimpleTextAttributes.GRAYED_ATTRIBUTES;
|
||||
renderer.append(XBreakpointUtil.getShortText(myBreakpoint), attributes);
|
||||
renderer.append(getDisplayText(), attributes);
|
||||
}
|
||||
|
||||
private Icon getIcon() {
|
||||
public String getDisplayText() {
|
||||
return XBreakpointUtil.getShortText(myBreakpoint);
|
||||
}
|
||||
|
||||
public Icon getIcon() {
|
||||
return ((XBreakpointBase)myBreakpoint).getIcon();
|
||||
}
|
||||
|
||||
@@ -75,21 +81,22 @@ class XBreakpointItem extends BreakpointItem {
|
||||
return ((XBreakpointBase)myBreakpoint).getType().getDisplayText(myBreakpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDetailView(DetailView panel) {
|
||||
public void doUpdateDetailView(DetailView panel) {
|
||||
Project project = ((XBreakpointBase)myBreakpoint).getProject();
|
||||
|
||||
XSourcePosition sourcePosition = myBreakpoint.getSourcePosition();
|
||||
if (sourcePosition != null) {
|
||||
if (!showInEditor(panel, sourcePosition.getFile(), sourcePosition.getLine())) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
panel.clearEditor();
|
||||
}
|
||||
|
||||
XLightBreakpointPropertiesPanel<XBreakpoint<?>> propertiesPanel =
|
||||
new XLightBreakpointPropertiesPanel<XBreakpoint<?>>(project, getManager(), myBreakpoint, true);
|
||||
propertiesPanel.loadProperties();
|
||||
panel.setDetailPanel(propertiesPanel.getMainPanel());
|
||||
|
||||
XSourcePosition sourcePosition = myBreakpoint.getSourcePosition();
|
||||
if (sourcePosition != null) {
|
||||
showInEditor(panel, sourcePosition.getFile(), sourcePosition.getLine());
|
||||
} else {
|
||||
panel.clearEditor();
|
||||
}
|
||||
}
|
||||
|
||||
private XBreakpointManagerImpl getManager() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.xdebugger.impl.DebuggerSupport;
|
||||
import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,22 +32,26 @@ import java.util.List;
|
||||
|
||||
public class BreakpointsMasterDetailPopupFactory {
|
||||
|
||||
private final List<BreakpointPanelProvider> myBreakpointPanelProviders;
|
||||
private Project myProject;
|
||||
private Balloon myBalloonToHide;
|
||||
|
||||
public BreakpointsMasterDetailPopupFactory(Project project) {
|
||||
myProject = project;
|
||||
myBreakpointPanelProviders = new ArrayList<BreakpointPanelProvider>();
|
||||
collectPanelProviders();
|
||||
}
|
||||
|
||||
public static List<BreakpointPanelProvider> collectPanelProviders() {
|
||||
List<BreakpointPanelProvider> panelProviders = new ArrayList<BreakpointPanelProvider>();
|
||||
for (DebuggerSupport debuggerSupport : DebuggerSupport.getDebuggerSupports()) {
|
||||
myBreakpointPanelProviders.add(debuggerSupport.getBreakpointPanelProvider());
|
||||
panelProviders.add(debuggerSupport.getBreakpointPanelProvider());
|
||||
}
|
||||
Collections.sort(myBreakpointPanelProviders, new Comparator<BreakpointPanelProvider>() {
|
||||
Collections.sort(panelProviders, new Comparator<BreakpointPanelProvider>() {
|
||||
@Override
|
||||
public int compare(BreakpointPanelProvider o1, BreakpointPanelProvider o2) {
|
||||
return o2.getPriority() - o1.getPriority();
|
||||
}
|
||||
});
|
||||
return panelProviders;
|
||||
}
|
||||
|
||||
public void setBalloonToHide(Balloon balloonToHide) {
|
||||
@@ -60,7 +65,7 @@ public class BreakpointsMasterDetailPopupFactory {
|
||||
public JBPopup createPopup(@Nullable Object initialBreakpoint) {
|
||||
BreakpointMasterDetailPopupBuilder builder = new BreakpointMasterDetailPopupBuilder(myProject);
|
||||
builder.setInitialBreakpoint(initialBreakpoint);
|
||||
builder.setBreakpointsPanelProviders(myBreakpointPanelProviders);
|
||||
builder.setBreakpointsPanelProviders(collectPanelProviders());
|
||||
final JBPopup popup = builder.createPopup();
|
||||
popup.addListener(new JBPopupListener() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.xdebugger.impl.breakpoints.ui.tree;
|
||||
|
||||
import com.intellij.ui.CheckedTreeNode;
|
||||
import com.intellij.xdebugger.breakpoints.ui.BreakpointItem;
|
||||
|
||||
class BreakpointItemNode extends CheckedTreeNode {
|
||||
private final BreakpointItem myBreakpoint;
|
||||
|
||||
BreakpointItemNode(final BreakpointItem breakpoint) {
|
||||
super(breakpoint);
|
||||
myBreakpoint = breakpoint;
|
||||
setChecked(breakpoint.isEnabled());
|
||||
}
|
||||
|
||||
public BreakpointItem getBreakpointItem() {
|
||||
return myBreakpoint;
|
||||
}
|
||||
}
|
||||