private Content createTerminalInContentPanel(
      @NotNull AbstractTerminalRunner terminalRunner, final @NotNull ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    final Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);

    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    myTerminalWidget.addTabListener(
        new TabbedTerminalWidget.TabListener() {
          @Override
          public void tabClosed(JediTermWidget terminal) {
            UIUtil.invokeLaterIfNeeded(
                () -> {
                  if (myTerminalWidget != null) {
                    hideIfNoActiveSessions(toolWindow, myTerminalWidget);
                  }
                });
          }
        });

    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(createFocusListener());

    ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.getComponent().addFocusListener(createFocusListener());
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent());

    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());

    return content;
  }
  private JPanel createToolbarPanel() {
    RunAction runAction = new RunAction(this);
    runAction.registerCustomShortcutSet(CommonShortcuts.getRerun(), this);

    DefaultActionGroup leftActionGroup = new DefaultActionGroup();
    leftActionGroup.add(runAction);
    leftActionGroup.add(new PauseOutputAction(this));
    leftActionGroup.add(new StopAction(this));
    leftActionGroup.add(new CloseAction());
    leftActionGroup.add(new PreviousOccurenceToolbarAction(this));
    leftActionGroup.add(new NextOccurenceToolbarAction(this));
    leftActionGroup.add(new ContextHelpAction(HelpID.ANT));

    DefaultActionGroup rightActionGroup = new DefaultActionGroup();
    rightActionGroup.add(new ChangeViewAction(this));
    rightActionGroup.add(new VerboseAction(this));
    rightActionGroup.add(
        CommonActionsManager.getInstance().createExpandAllAction(myTreeExpander, this));
    rightActionGroup.add(
        CommonActionsManager.getInstance().createCollapseAllAction(myTreeExpander, this));
    rightActionGroup.add(myTreeView.createToggleAutoscrollAction());

    myLeftToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.ANT_MESSAGES_TOOLBAR, leftActionGroup, false);
    JPanel toolbarPanel = new JPanel(new GridLayout(1, 2, 2, 0));
    toolbarPanel.add(myLeftToolbar.getComponent());
    myRightToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.ANT_MESSAGES_TOOLBAR, rightActionGroup, false);
    toolbarPanel.add(myRightToolbar.getComponent());

    return toolbarPanel;
  }
Esempio n. 3
0
  @Override
  public void updateTabs() {
    if (isDisposed()) {
      return;
    }

    if (getEditedNode() != null && getEditedNode().resolve(getProject().getRepository()) == null) {
      editNode(myBaseNode);
    }

    myRealTabs.clear();

    final NodeChangeCallback callback =
        new NodeChangeCallback() {
          @Override
          public void changeNode(SNodeReference newNode) {
            editNode(newNode);
          }
        };
    TabEditorLayout newContent = updateDocumentsAndNodes();
    for (RelationDescriptor tabDescriptor : myPossibleTabs) {
      if (newContent.covers(tabDescriptor)) {
        final ButtonEditorTab tab =
            new ButtonEditorTab(
                this, myRealTabs.size(), tabDescriptor, newContent.get(tabDescriptor));
        final SelectTabAction action = new SelectTabAction(getProject(), tab, callback);
        tab.setSelectTabAction(action);
        action.registerShortcut(myEditor);
        myRealTabs.add(tab);
      }
    }
    updateTabColors();

    DefaultActionGroup group = new DefaultActionGroup();
    for (ButtonEditorTab tab : myRealTabs) {
      group.add(tab.getSelectTabAction());
    }
    if (myToolbar != null) {
      removeContent(myToolbar.getComponent());
    }
    ActionToolbar actionToolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    actionToolbar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY);
    myToolbar = actionToolbar;
    setContent(myToolbar.getComponent());
    if (getEditedNode() != null) {
      // MPS-22337: getEditedNode() exists even if node was deleted.
      // So we need to check if tab created for such node as tabs was created only for non deleted
      // aspects.
      boolean isTabExists = false;
      for (ButtonEditorTab tab : myRealTabs) {
        if (tab.isEditingTabFor(getEditedNode())) {
          isTabExists = true;
          break;
        }
      }
      editNode(isTabExists ? getEditedNode() : myBaseNode);
    }
  }
  protected void buildToolbar(@Nullable List<AnAction> viewerActions) {
    ActionGroup group = collectToolbarActions(viewerActions);
    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.DIFF_TOOLBAR, group, true);

    DataManager.registerDataProvider(toolbar.getComponent(), myMainPanel);
    toolbar.setTargetComponent(toolbar.getComponent());

    myToolbarPanel.setContent(toolbar.getComponent());
    for (AnAction action : group.getChildren(null)) {
      DiffUtil.registerAction(action, myMainPanel);
    }
  }
  public AliCheckinHandler(CheckinProjectPanel checkinProjectPanel) {
    this.checkinProjectPanel = checkinProjectPanel;
    this.project = checkinProjectPanel.getProject();
    this.restService = project.getComponent(RestService.class);
    final ActiveItemService activeItemService = project.getComponent(ActiveItemService.class);
    this.ref = activeItemService.getActiveItem();

    this.projConf = project.getComponent(AliProjectConfiguration.class);

    panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.setBorder(BorderFactory.createTitledBorder("HP ALI"));

    if (ref == null) {
      activeItemService.addListener(this);
      DefaultActionGroup group = new DefaultActionGroup();
      ChooseEntityTypeAction choose =
          new ChooseEntityTypeAction(
              project,
              panel,
              Arrays.asList("defect", "requirement"),
              new ChooseEntityTypePopup.Listener() {
                @Override
                public void selected(final String entityType) {
                  PopupDialog popup =
                      new PopupDialog(
                          project,
                          entityType,
                          false,
                          false,
                          PopupDialog.Selection.FOLLOW_ID,
                          false);
                  popup.setVisible(true);
                  String selectedId = popup.getSelectedValue();
                  if (selectedId != null && !selectedId.isEmpty()) {
                    activeItemService.activate(
                        new Entity(entityType, Integer.valueOf(selectedId)), true, false);
                  }
                }
              });
      group.add(choose);
      panel.add(new JLabel("Not associated with any work item"), BorderLayout.WEST);
      ActionToolbar toolbar =
          ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
      panel.add(toolbar.getComponent(), BorderLayout.EAST);
      choose.setComponent(toolbar.getComponent());
    } else {
      setupPanel(checkinProjectPanel, ref);
    }
  }
  private JComponent createToolbar() {
    ActionGroup group =
        (ActionGroup)
            CustomActionsSchema.getInstance().getCorrectedAction(IdeActions.GROUP_MAIN_TOOLBAR);
    final ActionToolbar toolBar =
        myActionManager.createActionToolbar(ActionPlaces.MAIN_TOOLBAR, group, true);
    toolBar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY);

    DefaultActionGroup menuGroup = new DefaultActionGroup();
    menuGroup.add(new ViewToolbarAction());
    menuGroup.add(new CustomizeUIAction());
    PopupHandler.installUnknownPopupHandler(toolBar.getComponent(), menuGroup, myActionManager);

    return toolBar.getComponent();
  }
Esempio n. 7
0
 private void closeTreeComponent() {
   myActionGroup.unregisterCustomShortcutSet(myComponent);
   myGoToNeighbourRootActions.previous().unregisterCustomShortcutSet(myComponent);
   myGoToNeighbourRootActions.next().unregisterCustomShortcutSet(myComponent);
   myPanel.setFirstComponent(null);
   myComponent.remove(myToolbar.getComponent());
 }
Esempio n. 8
0
  @Nullable
  @Override
  protected JComponent createCenterPanel() {
    myPanel.setSplitterProportionKey(getClass().getName() + "ModelTreeSplitter");
    myTree = new ModelDifferenceDialog.ModelDifferenceTree();
    myPanel.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree));
    myPanel.setSecondComponent(myNoRootPanel);

    myGoToNeighbourRootActions = new ModelDifferenceDialog.MyGoToNeighbourRootActions();
    myGoToNeighbourRootActions
        .previous()
        .registerCustomShortcutSet(GoToNeighbourRootActions.PREV_ROOT_SHORTCUT, myComponent);
    myGoToNeighbourRootActions
        .next()
        .registerCustomShortcutSet(GoToNeighbourRootActions.NEXT_ROOT_SHORTCUT, myComponent);

    myToolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, myActionGroup, true);
    myToolbar.updateActionsImmediately();

    myComponent.add(myToolbar.getComponent(), BorderLayout.NORTH);
    myComponent.add(myPanel, BorderLayout.CENTER);
    myComponent.add(myStatusBar, BorderLayout.SOUTH);

    Dimension size = DimensionService.getInstance().getSize(getDimensionServiceKey());
    if (size == null) {
      myComponent.setPreferredSize(new Dimension(500, 700));
    }

    return myComponent;
  }
  private JComponent createToolbar() {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new CloseAction());
    group.add(new RerunAction(this));
    group.add(new FlattenPackagesAction());
    group.add(new ShowFilesAction());
    if (ModuleManager.getInstance(myProject).getModules().length > 1) {
      group.add(new ShowModulesAction());
      group.add(new ShowModuleGroupsAction());
    }
    group.add(new GroupByScopeTypeAction());
    // group.add(new GroupByFilesAction());
    group.add(new FilterLegalsAction());
    group.add(new MarkAsIllegalAction());
    group.add(new ChooseScopeTypeAction());
    group.add(new EditDependencyRulesAction());
    group.add(
        CommonActionsManager.getInstance()
            .createExportToTextFileAction(new DependenciesExporterToTextFile()));
    group.add(new ContextHelpAction("dependency.viewer.tool.window"));

    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    return toolbar.getComponent();
  }
Esempio n. 10
0
  protected void initConsoleTab(@Nullable final String history) {
    getProject()
        .getModelAccess()
        .executeCommand(
            new Runnable() {
              public void run() {
                createConsoleModel();
                addBuiltInImports();
                loadHistory(history);
                createEditor();
                myFileEditor = new ConsoleFileEditor(myEditor);
              }
            });

    this.setLayout(new BorderLayout());

    DefaultActionGroup group = new DefaultActionGroup();
    registerActions(group);
    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false);
    JPanel toolbarComponent = new JPanel(new BorderLayout());
    toolbarComponent.add(toolbar.getComponent(), BorderLayout.CENTER);

    this.add(toolbarComponent, BorderLayout.WEST);
    this.add(myEditor.getExternalComponent(), BorderLayout.CENTER);

    myHighlighter = check_6q36mf_a0o0ic(myTool.getProject());
    myHighlighter.addAdditionalEditorComponent(myEditor);
  }
Esempio n. 11
0
 public JComponent createActionsToolbar(ConsoleView console) {
   DefaultActionGroup group = new DefaultActionGroup(console.createConsoleActions());
   ActionManager manager = ActionManager.getInstance();
   ActionToolbar toolbar = manager.createActionToolbar(ActionPlaces.UNKNOWN, group, false);
   toolbar.setLayoutPolicy(ActionToolbar.WRAP_LAYOUT_POLICY);
   return toolbar.getComponent();
 }
Esempio n. 12
0
  private JComponent createToolbar() {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(ActionManager.getInstance().getAction(SERVERS_TOOL_WINDOW_TOOLBAR));
    group.add(new Separator());
    group.add(new ContextHelpAction(HELP_ID));

    ActionToolbar actionToolBar =
        ActionManager.getInstance().createActionToolbar(PLACE_TOOLBAR, group, false);

    myTree.putClientProperty(
        DataManager.CLIENT_PROPERTY_DATA_PROVIDER,
        new DataProvider() {

          @Override
          public Object getData(@NonNls String dataId) {
            if (KEY.getName().equals(dataId)) {
              return ServersToolWindowContent.this;
            }
            for (RemoteServersViewContributor contributor :
                RemoteServersViewContributor.EP_NAME.getExtensions()) {
              Object data = contributor.getData(dataId, ServersToolWindowContent.this);
              if (data != null) {
                return data;
              }
            }
            return null;
          }
        });
    actionToolBar.setTargetComponent(myTree);
    return actionToolBar.getComponent();
  }
  private JComponent createTreeToolbar() {
    final DefaultActionGroup group = new DefaultActionGroup();
    final Runnable update =
        new Runnable() {
          public void run() {
            rebuild(true);
          }
        };
    if (ProjectViewDirectoryHelper.getInstance(myProject).supportsFlattenPackages()) {
      group.add(new FlattenPackagesAction(update));
    }
    final PatternDialectProvider[] dialectProviders =
        Extensions.getExtensions(PatternDialectProvider.EP_NAME);
    for (PatternDialectProvider provider : dialectProviders) {
      for (AnAction action : provider.createActions(myProject, update)) {
        group.add(action);
      }
    }
    group.add(new ShowFilesAction(update));
    final Module[] modules = ModuleManager.getInstance(myProject).getModules();
    if (modules.length > 1) {
      group.add(new ShowModulesAction(update));
      group.add(new ShowModuleGroupsAction(update));
    }
    group.add(new FilterLegalsAction(update));

    if (dialectProviders.length > 1) {
      group.add(new ChooseScopeTypeAction(update));
    }

    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    return toolbar.getComponent();
  }
 private JComponent toUsageViewToolbar(final DefaultActionGroup group) {
   ActionToolbar actionToolbar =
       ActionManager.getInstance()
           .createActionToolbar(ActionPlaces.USAGE_VIEW_TOOLBAR, group, false);
   actionToolbar.setTargetComponent(myRootPanel);
   return actionToolbar.getComponent();
 }
 private JPanel createToolbarPanel(Collection<AnAction> actions) {
   final DefaultActionGroup group = new DefaultActionGroup();
   for (AnAction action : actions) {
     group.add(action);
   }
   final ActionToolbar actionToolBar =
       ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false);
   final JPanel panel = new JPanel(new BorderLayout());
   panel.add(actionToolBar.getComponent(), BorderLayout.CENTER);
   return panel;
 }
  private void initConsoleUI(Process process) {
    // Init console view
    myConsoleView = createConsoleView();
    myConsoleView.setBorder(new SideBorder(UIUtil.getBorderColor(), SideBorder.LEFT));

    myProcessHandler = createProcessHandler(process, myProvider.getCommandLineString());

    myConsoleExecuteActionHandler = createConsoleExecuteActionHandler();

    ProcessTerminatedListener.attach(myProcessHandler);

    myProcessHandler.addProcessListener(
        new ProcessAdapter() {
          @Override
          public void processTerminated(ProcessEvent event) {
            finishConsole();
          }
        });

    // Attach to process
    myConsoleView.attachToProcess(myProcessHandler);

    // Runner creating
    final Executor defaultExecutor =
        ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
    final DefaultActionGroup toolbarActions = new DefaultActionGroup();
    final ActionToolbar actionToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);

    // Runner creating
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
    panel.add(myConsoleView.getComponent(), BorderLayout.CENTER);

    actionToolbar.setTargetComponent(panel);

    final RunContentDescriptor contentDescriptor =
        new RunContentDescriptor(
            myConsoleView, myProcessHandler, panel, constructConsoleTitle(myConsoleTitle));

    // tool bar actions
    final List<AnAction> actions =
        fillToolBarActions(toolbarActions, defaultExecutor, contentDescriptor);
    registerActionShortcuts(actions, getLanguageConsole().getConsoleEditor().getComponent());
    registerActionShortcuts(actions, panel);
    panel.updateUI();
    showConsole(defaultExecutor, contentDescriptor);

    // Run
    myProcessHandler.startNotify();
  }
  protected void init() {
    addActionsTo(myToolbarGroup);
    myToolbarGroup.add(new MyCloseAction());
    myToolbarGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_CONTEXT_HELP));

    ActionToolbar toolbar =
        ActionManager.getInstance()
            .createActionToolbar(
                ActionPlaces.FILEHISTORY_VIEW_TOOLBAR, myToolbarGroup, !myVerticalToolbar);
    JComponent centerPanel = createCenterPanel();
    toolbar.setTargetComponent(centerPanel);
    for (AnAction action : myToolbarGroup.getChildren(null)) {
      action.registerCustomShortcutSet(action.getShortcutSet(), centerPanel);
    }

    add(centerPanel, BorderLayout.CENTER);
    if (myVerticalToolbar) {
      add(toolbar.getComponent(), BorderLayout.WEST);
    } else {
      add(toolbar.getComponent(), BorderLayout.NORTH);
    }
  }
Esempio n. 18
0
  @NotNull
  private static JPanel createLayerConfigurationPanel(@NotNull final ModuleEditor moduleEditor) {
    BorderLayoutPanel panel = JBUI.Panels.simplePanel();

    ModifiableRootModel moduleRootModel = moduleEditor.getModifiableRootModelProxy();

    final MutableCollectionComboBoxModel<String> model =
        new MutableCollectionComboBoxModel<String>(
            new ArrayList<String>(moduleRootModel.getLayers().keySet()),
            moduleRootModel.getCurrentLayerName());

    final ComboBox comboBox = new ComboBox(model);
    comboBox.setEnabled(model.getSize() > 1);

    moduleEditor.addChangeListener(
        new ModuleEditor.ChangeListener() {
          @Override
          public void moduleStateChanged(ModifiableRootModel moduleRootModel) {
            model.update(new ArrayList<String>(moduleRootModel.getLayers().keySet()));
            model.setSelectedItem(moduleRootModel.getCurrentLayerName());
            model.update();

            comboBox.setEnabled(comboBox.getItemCount() > 1);
          }
        });

    comboBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              moduleEditor
                  .getModifiableRootModelProxy()
                  .setCurrentLayer((String) comboBox.getSelectedItem());
            }
          }
        });

    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new NewLayerAction(moduleEditor, false));
    group.add(new DeleteLayerAction(moduleEditor));
    group.add(new NewLayerAction(moduleEditor, true));

    ActionToolbar actionToolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    JComponent toolbarComponent = actionToolbar.getComponent();
    toolbarComponent.setBorder(JBUI.Borders.empty());

    panel.addToLeft(LabeledComponent.left(comboBox, "Layer")).addToRight(toolbarComponent);
    return panel;
  }
  private ActiveComponent createPinButton(
      final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor,
      final UsageViewImpl usageView,
      final FindUsagesOptions options,
      final JBPopup[] popup,
      DefaultActionGroup pinGroup) {
    final AnAction pinAction =
        new AnAction(
            "Open Find Usages Toolwindow",
            "Show all usages in a separate toolwindow",
            AllIcons.General.AutohideOff) {
          {
            AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_USAGES);
            setShortcutSet(action.getShortcutSet());
          }

          @Override
          public void actionPerformed(AnActionEvent e) {
            hideHints();
            popup[0].cancel();
            FindUsagesManager findUsagesManager =
                ((FindManagerImpl) FindManager.getInstance(usageView.getProject()))
                    .getFindUsagesManager();
            FindUsagesManager.SearchData data = new FindUsagesManager.SearchData();
            data.myOptions = options;
            List<SmartPsiElementPointer<PsiElement>> plist = descriptor.getAllElementPointers();

            data.myElements = plist.toArray(new SmartPsiElementPointer[plist.size()]);
            findUsagesManager.rerunAndRecallFromHistory(data);
          }
        };
    pinGroup.add(pinAction);
    final ActionToolbar pinToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.USAGE_VIEW_TOOLBAR, pinGroup, true);
    pinToolbar.setReservePlaceAutoPopupIcon(false);
    final JComponent pinToolBar = pinToolbar.getComponent();
    pinToolBar.setBorder(null);
    pinToolBar.setOpaque(false);

    return new ActiveComponent() {
      @Override
      public void setActive(boolean active) {}

      @Override
      public JComponent getComponent() {
        return pinToolBar;
      }
    };
  }
Esempio n. 20
0
  @Override
  public JComponent createComponent() {
    myComponent = new MyPanel();

    mySplitter = new JBSplitter(false, .15f);
    mySplitter.setSplitterProportionKey("ProjectStructure.TopLevelElements");
    mySplitter.setHonorComponentsMinimumSize(true);
    if (Registry.is("ide.new.project.settings")) {
      mySplitter.setOnePixelMode();
    }

    initSidePanel();

    final JPanel left =
        new JPanel(new BorderLayout()) {
          @Override
          public Dimension getMinimumSize() {
            final Dimension original = super.getMinimumSize();
            return new Dimension(Math.max(original.width, 100), original.height);
          }
        };

    final DefaultActionGroup toolbarGroup = new DefaultActionGroup();
    toolbarGroup.add(new BackAction(myComponent));
    toolbarGroup.add(new ForwardAction(myComponent));
    final ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarGroup, true);
    toolbar.setTargetComponent(myComponent);
    myToolbarComponent = toolbar.getComponent();
    if (Registry.is("ide.new.project.settings")) {
      left.setBackground(UIUtil.getSidePanelColor());
    } else {
      left.add(myToolbarComponent, BorderLayout.NORTH);
    }
    left.add(mySidePanel, BorderLayout.CENTER);

    mySplitter.setFirstComponent(left);
    mySplitter.setSecondComponent(myDetails);

    myComponent.add(mySplitter, BorderLayout.CENTER);
    myErrorsComponent = new ConfigurationErrorsComponent(myProject);
    if (!Registry.is("ide.new.project.settings")) {
      myComponent.add(myErrorsComponent, BorderLayout.SOUTH);
    }

    myUiInitialized = true;

    return myComponent;
  }
  private JPanel createActionsPanel() {
    DefaultActionGroup commonActionGroup = new DefaultActionGroup();
    commonActionGroup.add(new MyAddAction());
    commonActionGroup.add(new MyRemoveAction());
    commonActionGroup.add(new MyCopyAction());

    ActionToolbar actionToolbar =
        ActionManager.getInstance()
            .createActionToolbar(
                CvsActionPlaces.CVS_CONFIGURATIONS_TOOLBAR, commonActionGroup, true);

    JPanel actionPanel = new JPanel(new BorderLayout());
    actionPanel.add(actionToolbar.getComponent(), BorderLayout.WEST);
    return actionPanel;
  }
  /**
   * Create a tool window for the given project.
   *
   * @param project the project.
   */
  public CheckStyleToolWindowPanel(final ToolWindow toolWindow, final Project project) {
    super(new BorderLayout());

    this.toolWindow = toolWindow;
    this.project = project;

    checkStylePlugin = project.getComponent(CheckStylePlugin.class);
    if (checkStylePlugin == null) {
      throw new IllegalStateException("Couldn't get checkstyle plugin");
    }

    configurationChanged();
    checkStylePlugin.getConfiguration().addConfigurationListener(this);

    final ActionGroup mainActionGroup =
        (ActionGroup) ActionManager.getInstance().getAction(MAIN_ACTION_GROUP);
    final ActionToolbar mainToolbar =
        ActionManager.getInstance().createActionToolbar(ID_TOOLWINDOW, mainActionGroup, false);

    final ActionGroup treeActionGroup =
        (ActionGroup) ActionManager.getInstance().getAction(TREE_ACTION_GROUP);
    final ActionToolbar treeToolbar =
        ActionManager.getInstance().createActionToolbar(ID_TOOLWINDOW, treeActionGroup, false);

    final Box toolBarBox = Box.createHorizontalBox();
    toolBarBox.add(mainToolbar.getComponent());
    toolBarBox.add(treeToolbar.getComponent());

    setBorder(new EmptyBorder(1, 1, 1, 1));
    add(toolBarBox, BorderLayout.WEST);
    add(createToolPanel(), BorderLayout.CENTER);

    expandTree();

    mainToolbar.getComponent().setVisible(true);
  }
  @NotNull
  protected JComponent createToolbar() {
    DefaultActionGroup toolbarGroups = new DefaultActionGroup();
    myToolBarGroup = new DefaultActionGroup();
    toolbarGroups.add(myToolBarGroup);
    buildToolBar(myToolBarGroup);

    toolbarGroups.addSeparator();
    DefaultActionGroup treeActionsGroup = new DefaultActionGroup();
    toolbarGroups.add(treeActionsGroup);
    for (AnAction action : myViewer.getTreeActions()) {
      treeActionsGroup.add(action);
    }

    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.TOOLBAR, toolbarGroups, true);
    toolbar.setTargetComponent(this);
    return toolbar.getComponent();
  }
  public void setTarget(ItemViewWrapper view) {
    //        debug("setTarget=" + view);
    setBackground(Color.WHITE);
    setVisible(false);
    setLayout(new BorderLayout(0, 0));
    removeAll();

    // todo
    //        if(view == null){
    //            int hh =0;
    //            return;
    //        }

    ActionManager actionManager = ActionManager.getInstance();
    DefaultActionGroup actionGroup = new DefaultActionGroup("PsiActionGroup22", false);

    for (ToggleAction act : view.getActions()) {
      actionGroup.add(act);
    }
    ActionToolbar toolBar =
        actionManager.createActionToolbar("PsiActionToolbar33", actionGroup, true);
    add(toolBar.getComponent(), "North");

    //        JButton button = new JButton();
    //        button.setName("Activate");
    //        button.setActionCommand("Activate");
    //        button.setToolTipText("Activate me!");
    //        button.setIcon(IconLoader.getIcon("/fileTypes/javaScript.png"));
    //
    //        JToolBar toolBar = new JToolBar("Still draggable");
    //        toolBar.add(button);
    //        add(toolBar, BorderLayout.PAGE_START);

    //        ItemViewWrapper wrp = (ItemViewWrapper) view;
    add(
        createTable(view.getTabularData(), view.getColumnNames(), view.getPopupMenu()),
        BorderLayout.CENTER);
    //        add(createTable(wrp.getTabularData(), wrp.getColumnNames()));
    setVisible(true);
  }
  @Override
  public void createToolWindowContent(final Project project, ToolWindow toolWindow) {
    Component component = toolWindow.getComponent();

    changeListPanel = new GerritChangeListPanel(Lists.<ChangeInfo>newArrayList(), null);

    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    ActionToolbar toolbar = createToolbar();
    toolbar.setTargetComponent(changeListPanel);
    panel.setToolbar(toolbar.getComponent());

    myRepositoryChangesBrowser = createRepositoryChangesBrowser(project);

    myDetailsSplitter = new Splitter(true, 0.6f);
    myDetailsSplitter.setShowDividerControls(true);

    changeListPanel.setBorder(
        IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.RIGHT | SideBorder.BOTTOM));
    myDetailsSplitter.setFirstComponent(changeListPanel);

    myDetailsPanel = new GerritChangeDetailsPanel(project);
    JPanel details = myDetailsPanel.getComponent();
    details.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.RIGHT));
    myDetailsSplitter.setSecondComponent(details);

    Splitter myHorizontalSplitter = new Splitter(false, 0.7f);
    myHorizontalSplitter.setShowDividerControls(true);
    myHorizontalSplitter.setFirstComponent(myDetailsSplitter);
    myHorizontalSplitter.setSecondComponent(myRepositoryChangesBrowser);

    panel.setContent(myHorizontalSplitter);

    component.getParent().add(panel);

    reloadChanges(project, false);

    setupRefreshTask(project);
  }
  public void buildUi() {
    myTopPanel = new JPanel(new BorderLayout());
    final JPanel wrapper = new JPanel();
    // final BoxLayout boxLayout = new BoxLayout(wrapper, BoxLayout.X_AXIS);
    wrapper.setLayout(new BorderLayout());
    myTitleLabel.setBorder(BorderFactory.createEmptyBorder(1, 2, 0, 0));
    wrapper.add(myTitleLabel, BorderLayout.WEST);
    DefaultActionGroup dag = new DefaultActionGroup();
    myPreviousDiff.copyShortcutFrom(ActionManager.getInstance().getAction("PreviousDiff"));
    myNextDiff.copyShortcutFrom(ActionManager.getInstance().getAction("NextDiff"));
    dag.add(new MyChangeContextAction());
    dag.add(myPreviousDiff);
    dag.add(myNextDiff);
    myPreviousDiff.registerCustomShortcutSet(myPreviousDiff.getShortcutSet(), myPanel);
    myNextDiff.registerCustomShortcutSet(myNextDiff.getShortcutSet(), myPanel);

    dag.add(new PopupAction());
    ActionToolbar toolbar =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, dag, true);
    wrapper.add(toolbar.getComponent(), BorderLayout.EAST);

    myTopPanel.add(wrapper, BorderLayout.CENTER);

    final JPanel wrapperDiffs = new JPanel(new GridBagLayout());
    final JPanel oneMore = new JPanel(new BorderLayout());
    oneMore.add(wrapperDiffs, BorderLayout.NORTH);

    myCurrentHorizontal = myConfiguration.SHORT_DIFF_HORISONTALLY;
    myHorizontal = createPanel(true);
    myVertical = createPanel(false);

    myPanel.add(myTopPanel, BorderLayout.NORTH);
    myPanel.add(getCurrentPanel().getComponent(), BorderLayout.CENTER);

    myPreviousDiff.registerCustomShortcutSet(myPreviousDiff.getShortcutSet(), myParent);
    myNextDiff.registerCustomShortcutSet(myNextDiff.getShortcutSet(), myParent);
  }
  @Before
  public void setUp() {
    MockApplication application = new MyMockApplicationEx(parent);
    ActionManagerEx manager = Mockito.mock(ActionManagerEx.class);
    ActionToolbar actionToolbar = Mockito.mock(ActionToolbar.class);
    Mockito.when(actionToolbar.getComponent()).thenReturn(new JComponent() {});
    Mockito.when(
            manager.createActionToolbar(
                Mockito.anyString(), Mockito.any(ActionGroup.class), Mockito.anyBoolean()))
        .thenReturn(actionToolbar);
    Mockito.when(
            manager.createActionToolbar(
                Mockito.anyString(),
                Mockito.any(ActionGroup.class),
                Mockito.anyBoolean(),
                Mockito.anyBoolean()))
        .thenReturn(actionToolbar);
    application.addComponent(ActionManager.class, manager);
    ApplicationManager.setApplication(application, parent);

    XDebugSession session = Mockito.mock(XDebugSession.class);
    Mockito.when(handler.getProcess()).thenReturn(mockProcess);
    Mockito.when(mockProcess.getXDebugSession()).thenReturn(session);
  }
  public DocumentationComponent(
      final DocumentationManager manager, final AnAction[] additionalActions) {
    myManager = manager;
    myIsEmpty = true;
    myIsShown = false;

    myEditorPane =
        new JEditorPane(UIUtil.HTML_MIME, "") {
          @Override
          public Dimension getPreferredScrollableViewportSize() {
            if (getWidth() == 0 || getHeight() == 0) {
              setSize(MAX_WIDTH, MAX_HEIGHT);
            }
            Insets ins = myEditorPane.getInsets();
            View rootView = myEditorPane.getUI().getRootView(myEditorPane);
            rootView.setSize(
                MAX_WIDTH,
                MAX_HEIGHT); // Necessary! Without this line, size will not increase then you go
            // from small page to bigger one
            int prefHeight = (int) rootView.getPreferredSpan(View.Y_AXIS);
            prefHeight +=
                ins.bottom
                    + ins.top
                    + myScrollPane.getHorizontalScrollBar().getMaximumSize().height;
            return new Dimension(MAX_WIDTH, Math.max(MIN_HEIGHT, Math.min(MAX_HEIGHT, prefHeight)));
          }

          {
            enableEvents(AWTEvent.KEY_EVENT_MASK);
          }

          @Override
          protected void processKeyEvent(KeyEvent e) {
            KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(e);
            ActionListener listener = myKeyboardActions.get(keyStroke);
            if (listener != null) {
              listener.actionPerformed(new ActionEvent(DocumentationComponent.this, 0, ""));
              e.consume();
              return;
            }
            super.processKeyEvent(e);
          }

          @Override
          protected void paintComponent(Graphics g) {
            GraphicsUtil.setupAntialiasing(g);
            super.paintComponent(g);
          }
        };
    DataProvider helpDataProvider =
        new DataProvider() {
          @Override
          public Object getData(@NonNls String dataId) {
            return PlatformDataKeys.HELP_ID.is(dataId) ? DOCUMENTATION_TOPIC_ID : null;
          }
        };
    myEditorPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider);
    myText = "";
    myEditorPane.setEditable(false);
    myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
    myEditorPane.setEditorKit(UIUtil.getHTMLEditorKit());
    myScrollPane =
        new JBScrollPane(myEditorPane) {
          @Override
          protected void processMouseWheelEvent(MouseWheelEvent e) {
            if (!EditorSettingsExternalizable.getInstance().isWheelFontChangeEnabled()
                || !EditorUtil.isChangeFontSize(e)) {
              super.processMouseWheelEvent(e);
              return;
            }

            int change = Math.abs(e.getWheelRotation());
            boolean increase = e.getWheelRotation() <= 0;
            EditorColorsManager colorsManager = EditorColorsManager.getInstance();
            EditorColorsScheme scheme = colorsManager.getGlobalScheme();
            FontSize newFontSize = scheme.getQuickDocFontSize();
            for (; change > 0; change--) {
              if (increase) {
                newFontSize = newFontSize.larger();
              } else {
                newFontSize = newFontSize.smaller();
              }
            }

            if (newFontSize == scheme.getQuickDocFontSize()) {
              return;
            }

            scheme.setQuickDocFontSize(newFontSize);
            applyFontSize();
            setFontSizeSliderSize(newFontSize);
          }
        };
    myScrollPane.setBorder(null);
    myScrollPane.putClientProperty(DataManager.CLIENT_PROPERTY_DATA_PROVIDER, helpDataProvider);

    final MouseAdapter mouseAdapter =
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            myManager.requestFocus();
            myShowSettingsButton.hideSettings();
          }
        };
    myEditorPane.addMouseListener(mouseAdapter);
    Disposer.register(
        this,
        new Disposable() {
          @Override
          public void dispose() {
            myEditorPane.removeMouseListener(mouseAdapter);
          }
        });

    final FocusAdapter focusAdapter =
        new FocusAdapter() {
          @Override
          public void focusLost(FocusEvent e) {
            Component previouslyFocused =
                WindowManagerEx.getInstanceEx()
                    .getFocusedComponent(manager.getProject(getElement()));

            if (!(previouslyFocused == myEditorPane)) {
              if (myHint != null && !myHint.isDisposed()) myHint.cancel();
            }
          }
        };
    myEditorPane.addFocusListener(focusAdapter);

    Disposer.register(
        this,
        new Disposable() {
          @Override
          public void dispose() {
            myEditorPane.removeFocusListener(focusAdapter);
          }
        });

    setLayout(new BorderLayout());
    JLayeredPane layeredPane =
        new JBLayeredPane() {
          @Override
          public void doLayout() {
            final Rectangle r = getBounds();
            for (Component component : getComponents()) {
              if (component instanceof JScrollPane) {
                component.setBounds(0, 0, r.width, r.height);
              } else {
                int insets = 2;
                Dimension d = component.getPreferredSize();
                component.setBounds(r.width - d.width - insets, insets, d.width, d.height);
              }
            }
          }

          @Override
          public Dimension getPreferredSize() {
            Dimension editorPaneSize = myEditorPane.getPreferredScrollableViewportSize();
            Dimension controlPanelSize = myControlPanel.getPreferredSize();
            return new Dimension(
                Math.max(editorPaneSize.width, controlPanelSize.width),
                editorPaneSize.height + controlPanelSize.height);
          }
        };
    layeredPane.add(myScrollPane);
    layeredPane.setLayer(myScrollPane, 0);

    mySettingsPanel = createSettingsPanel();
    layeredPane.add(mySettingsPanel);
    layeredPane.setLayer(mySettingsPanel, JLayeredPane.POPUP_LAYER);
    add(layeredPane, BorderLayout.CENTER);
    setOpaque(true);
    myScrollPane.setViewportBorder(JBScrollPane.createIndentBorder());

    final DefaultActionGroup actions = new DefaultActionGroup();
    final BackAction back = new BackAction();
    final ForwardAction forward = new ForwardAction();
    actions.add(back);
    actions.add(forward);
    actions.add(myExternalDocAction = new ExternalDocAction());
    back.registerCustomShortcutSet(CustomShortcutSet.fromString("LEFT"), this);
    forward.registerCustomShortcutSet(CustomShortcutSet.fromString("RIGHT"), this);
    myExternalDocAction.registerCustomShortcutSet(CustomShortcutSet.fromString("UP"), this);
    if (additionalActions != null) {
      for (final AnAction action : additionalActions) {
        actions.add(action);
      }
    }

    myToolBar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.JAVADOC_TOOLBAR, actions, true);

    myControlPanel = new JPanel();
    myControlPanel.setLayout(new BorderLayout());
    myControlPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
    JPanel dummyPanel = new JPanel();

    myElementLabel = new JLabel();

    dummyPanel.setLayout(new BorderLayout());
    dummyPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));

    dummyPanel.add(myElementLabel, BorderLayout.EAST);

    myControlPanel.add(myToolBar.getComponent(), BorderLayout.WEST);
    myControlPanel.add(dummyPanel, BorderLayout.CENTER);
    myControlPanel.add(myShowSettingsButton = new MyShowSettingsButton(), BorderLayout.EAST);
    myControlPanelVisible = false;

    final HyperlinkListener hyperlinkListener =
        new HyperlinkListener() {
          @Override
          public void hyperlinkUpdate(HyperlinkEvent e) {
            HyperlinkEvent.EventType type = e.getEventType();
            if (type == HyperlinkEvent.EventType.ACTIVATED) {
              manager.navigateByLink(DocumentationComponent.this, e.getDescription());
            }
          }
        };
    myEditorPane.addHyperlinkListener(hyperlinkListener);
    Disposer.register(
        this,
        new Disposable() {
          @Override
          public void dispose() {
            myEditorPane.removeHyperlinkListener(hyperlinkListener);
          }
        });

    registerActions();

    updateControlState();
  }
  public ImplementationViewComponent(PsiElement[] elements, final int index) {
    super(new BorderLayout());

    final Project project = elements.length > 0 ? elements[0].getProject() : null;
    EditorFactory factory = EditorFactory.getInstance();
    Document doc = factory.createDocument("");
    doc.setReadOnly(true);
    myEditor = factory.createEditor(doc, project);
    ((EditorEx) myEditor).setBackgroundColor(EditorFragmentComponent.getBackgroundColor(myEditor));

    final EditorSettings settings = myEditor.getSettings();
    settings.setAdditionalLinesCount(1);
    settings.setAdditionalColumnsCount(1);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setLineNumbersShown(false);
    settings.setFoldingOutlineShown(false);

    myBinarySwitch = new CardLayout();
    myViewingPanel = new JPanel(myBinarySwitch);
    myEditor.setBorder(null);
    ((EditorEx) myEditor).getScrollPane().setViewportBorder(JBScrollPane.createIndentBorder());
    myViewingPanel.add(myEditor.getComponent(), TEXT_PAGE_KEY);

    myBinaryPanel = new JPanel(new BorderLayout());
    myViewingPanel.add(myBinaryPanel, BINARY_PAGE_KEY);

    add(myViewingPanel, BorderLayout.CENTER);

    myToolbar = createToolbar();
    myLocationLabel = new JLabel();
    myCountLabel = new JLabel();

    final JPanel header = new JPanel(new BorderLayout(2, 0));
    header.setBorder(
        BorderFactory.createCompoundBorder(
            IdeBorderFactory.createBorder(SideBorder.BOTTOM),
            IdeBorderFactory.createEmptyBorder(0, 0, 0, 5)));
    final JPanel toolbarPanel = new JPanel(new GridBagLayout());
    final GridBagConstraints gc =
        new GridBagConstraints(
            GridBagConstraints.RELATIVE,
            0,
            1,
            1,
            0,
            0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(0, 2, 0, 0),
            0,
            0);
    toolbarPanel.add(myToolbar.getComponent(), gc);

    setPreferredSize(new Dimension(600, 400));

    update(
        elements,
        new PairFunction<PsiElement[], List<FileDescriptor>, Boolean>() {
          @Override
          public Boolean fun(
              final PsiElement[] psiElements, final List<FileDescriptor> fileDescriptors) {
            if (psiElements.length == 0) return false;
            myElements = psiElements;

            myIndex = index < myElements.length ? index : 0;
            PsiFile psiFile = getContainingFile(myElements[myIndex]);

            VirtualFile virtualFile = psiFile.getVirtualFile();
            EditorHighlighter highlighter;
            if (virtualFile != null)
              highlighter = HighlighterFactory.createHighlighter(project, virtualFile);
            else {
              String fileName = psiFile.getName(); // some artificial psi file, lets do best we can
              highlighter = HighlighterFactory.createHighlighter(project, fileName);
            }

            ((EditorEx) myEditor).setHighlighter(highlighter);

            gc.fill = GridBagConstraints.HORIZONTAL;
            gc.weightx = 1;
            if (myElements.length > 1) {
              myFileChooser =
                  new ComboBox(
                      fileDescriptors.toArray(new FileDescriptor[fileDescriptors.size()]), 250);
              updateRenderer(project);

              myFileChooser.addActionListener(
                  new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                      int index = myFileChooser.getSelectedIndex();
                      if (myIndex != index) {
                        myIndex = index;
                        updateControls();
                      }
                    }
                  });

              myLabel = new JLabel();
              myLabel.setVisible(false);
              toolbarPanel.add(myFileChooser, gc);
            } else {
              myFileChooser = new ComboBox();
              myFileChooser.setVisible(false);
              myCountLabel.setVisible(false);

              myLabel = new JLabel();
              VirtualFile file = psiFile.getVirtualFile();
              if (file != null) {
                myLabel.setIcon(getIconForFile(psiFile));
                myLabel.setForeground(
                    FileStatusManager.getInstance(project).getStatus(file).getColor());
                myLabel.setText(file.getPresentableName());
                myLabel.setBorder(
                    new CompoundBorder(
                        IdeBorderFactory.createRoundedBorder(),
                        IdeBorderFactory.createEmptyBorder(0, 0, 0, 5)));
              }
              toolbarPanel.add(myLabel, gc);
            }

            gc.fill = GridBagConstraints.NONE;
            gc.weightx = 0;
            toolbarPanel.add(myCountLabel, gc);

            header.add(toolbarPanel, BorderLayout.CENTER);
            header.add(myLocationLabel, BorderLayout.EAST);

            add(header, BorderLayout.NORTH);

            updateControls();
            return true;
          }
        });
  }
Esempio n. 30
0
  public RegistryUi() {
    myContent.setLayout(new BorderLayout(UIUtil.DEFAULT_HGAP, UIUtil.DEFAULT_VGAP));

    myModel = new MyTableModel();
    myTable = new JBTable(myModel);
    myTable.setCellSelectionEnabled(true);
    myTable.setEnableAntialiasing(true);
    final MyRenderer r = new MyRenderer();

    final TableColumn c0 = myTable.getColumnModel().getColumn(0);
    c0.setCellRenderer(r);
    c0.setMaxWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setMinWidth(RESTART_ICON.getIconWidth() + 12);
    c0.setHeaderValue(null);

    final TableColumn c1 = myTable.getColumnModel().getColumn(1);
    c1.setCellRenderer(r);
    c1.setHeaderValue("Key");

    final TableColumn c2 = myTable.getColumnModel().getColumn(2);
    c2.setCellRenderer(r);
    c2.setHeaderValue("Value");
    c2.setCellEditor(new MyEditor());
    myTable.setStriped(true);

    myDescriptionLabel = new JTextArea(3, 50);
    myDescriptionLabel.setEditable(false);
    final JScrollPane label = ScrollPaneFactory.createScrollPane(myDescriptionLabel);
    final JPanel descriptionPanel = new JPanel(new BorderLayout());
    descriptionPanel.add(label, BorderLayout.CENTER);
    descriptionPanel.setBorder(
        IdeBorderFactory.createTitledBorder("Description", false, false, true));

    myContent.add(ScrollPaneFactory.createScrollPane(myTable), BorderLayout.CENTER);
    myContent.add(descriptionPanel, BorderLayout.SOUTH);

    myTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) return;

                final int selected = myTable.getSelectedRow();
                if (selected != -1) {
                  final RegistryValue value = myModel.getRegistryValue(selected);
                  String desc = value.getDescription();
                  if (value.isRestartRequired()) {
                    String required = "Requires IDE restart.";
                    if (desc.endsWith(".")) {
                      desc += required;
                    } else {
                      desc += (". " + required);
                    }
                  }
                  myDescriptionLabel.setText(desc);
                } else {
                  myDescriptionLabel.setText(null);
                }
              }
            });

    myRestoreDefaultsAction = new RestoreDefaultsAction();

    final DefaultActionGroup tbGroup = new DefaultActionGroup();
    tbGroup.add(new EditAction());
    tbGroup.add(new RevertAction());

    final ActionToolbar tb =
        ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, tbGroup, true);
    tb.setTargetComponent(myTable);

    myContent.add(tb.getComponent(), BorderLayout.NORTH);
    new TableSpeedSearch(myTable).setComparator(new SpeedSearchComparator(false));
  }