IDEA-50121
[fedora-idea.git] / java / java-impl / src / com / intellij / slicer / SliceForwardHandler.java
blob4209ca70e341eddbe816e39988a45c1d48b825c4
1 /*
2 * Copyright 2000-2010 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.slicer;
18 import com.intellij.analysis.AnalysisScope;
19 import com.intellij.analysis.AnalysisUIOptions;
20 import com.intellij.analysis.BaseAnalysisActionDialog;
21 import com.intellij.openapi.module.Module;
22 import com.intellij.openapi.module.ModuleUtil;
23 import com.intellij.openapi.project.Project;
24 import com.intellij.psi.*;
26 import javax.swing.*;
28 /**
29 * @author cdr
31 public class SliceForwardHandler extends SliceHandler {
32 public SliceForwardHandler() {
33 super(false);
36 public SliceAnalysisParams askForParams(PsiElement element, boolean dataFlowToThis, SliceManager.StoredSettingsBean storedSettingsBean, String dialogTitle) {
37 AnalysisScope analysisScope = new AnalysisScope(element.getContainingFile());
38 Module module = ModuleUtil.findModuleForPsiElement(element);
39 String name = module == null ? null : module.getName();
41 Project myProject = element.getProject();
42 final SliceForwardForm form = new SliceForwardForm();
43 form.init(storedSettingsBean.showDereferences);
45 AnalysisUIOptions analysisUIOptions = new AnalysisUIOptions();
46 analysisUIOptions.save(storedSettingsBean.analysisUIOptions);
48 BaseAnalysisActionDialog dialog = new BaseAnalysisActionDialog(dialogTitle, "Analyze scope", myProject, analysisScope, name, true,
49 analysisUIOptions,
50 element) {
51 @Override
52 protected JComponent getAdditionalActionSettings(Project project) {
53 return form.getComponent();
56 dialog.show();
57 if (!dialog.isOK()) return null;
59 storedSettingsBean.analysisUIOptions.save(analysisUIOptions);
60 storedSettingsBean.showDereferences = form.isToShowDerefs();
62 AnalysisScope scope = dialog.getScope(analysisUIOptions, analysisScope, myProject, module);
64 SliceAnalysisParams params = new SliceAnalysisParams();
65 params.scope = scope;
66 params.dataFlowToThis = dataFlowToThis;
67 params.showInstanceDereferences = form.isToShowDerefs();
68 return params;