protected void doOKAction() { final LogicalPosition currentPosition = myEditor.getCaretModel().getLogicalPosition(); int lineNumber = getLineNumber(currentPosition.line + 1); if (isInternal() && myOffsetField.getText().length() > 0) { try { final int offset = Integer.parseInt(myOffsetField.getText()); if (offset < myEditor.getDocument().getTextLength()) { myEditor.getCaretModel().removeSecondaryCarets(); myEditor.getCaretModel().moveToOffset(offset); myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); myEditor.getSelectionModel().removeSelection(); IdeFocusManager.getGlobalInstance().requestFocus(myEditor.getContentComponent(), true); super.doOKAction(); } return; } catch (NumberFormatException e) { return; } } if (lineNumber < 0) return; int columnNumber = getColumnNumber(currentPosition.column); myEditor.getCaretModel().removeSecondaryCarets(); myEditor .getCaretModel() .moveToLogicalPosition( new LogicalPosition(Math.max(0, lineNumber - 1), Math.max(0, columnNumber - 1))); myEditor.getScrollingModel().scrollToCaret(ScrollType.CENTER); myEditor.getSelectionModel().removeSelection(); IdeFocusManager.getGlobalInstance().requestFocus(myEditor.getContentComponent(), true); super.doOKAction(); }
private void showDialog() { if (myDialog == null) { // System.out.println("showDialog()"); myDialog = new DialogWrapper(myProject, false) { { getWindow().setBounds(0, 0, 1, 1); setResizable(false); } @Override protected boolean isProgressDialog() { return true; } @Override protected JComponent createCenterPanel() { return null; } }; myDialog.setModal(true); myDialog.setUndecorated(true); myDialog.show(); } }
public void focusLost(final FocusEvent e) { if (myPanel.getProject().isDisposed()) { myPanel.setContextComponent(null); myPanel.hideHint(); return; } final DialogWrapper dialog = DialogWrapper.findInstance(e.getOppositeComponent()); shouldFocusEditor = dialog != null; if (dialog != null) { Disposer.register( dialog.getDisposable(), new Disposable() { @Override public void dispose() { if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) { shouldFocusEditor = false; } } }); } // required invokeLater since in current call sequence KeyboardFocusManager is not initialized // yet // but future focused component //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { public void run() { processFocusLost(e); } }); }
public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) { try { EditorComponent component = ((EditorComponent) ((Editor) MapSequence.fromMap(_params).get("editor")).getCurrentEditorComponent()); if (component == null) { return; } Set<String> enabledHints = component.getEnabledHints(); ConceptEditorHintSettings settings = new ConceptEditorHintSettings(); settings.putAll( ConceptEditorHintSettingsComponent.getInstance( ((Project) MapSequence.fromMap(_params).get("project"))) .getSettings()); for (String lang : settings.getLanguagesNames()) { for (ConceptEditorHint hint : SetSequence.fromSet(settings.getHints(lang))) { settings.put(lang, hint, false); } } settings.updateSettings(enabledHints); final ConceptEditorHintPreferencesPage page = new ConceptEditorHintPreferencesPage(settings); DialogWrapper dialog = new HintsDialog( ((Project) MapSequence.fromMap(_params).get("project")), page, settings, component); dialog.show(); } catch (Throwable t) { if (LOG.isEnabledFor(Priority.ERROR)) { LOG.error("User's action execute method failed. Action:" + "PushEditorHints", t); } } }
@Override public void windowClosing(WindowEvent e) { DialogWrapper dialogWrapper = getDialogWrapper(); if (dialogWrapper.shouldCloseOnCross()) { dialogWrapper.doCancelAction(e); } }
@Override public Object getData(@NonNls String dataId) { final DialogWrapper wrapper = myDialogWrapper.get(); return wrapper != null && PlatformDataKeys.UI_DISPOSABLE.is(dataId) ? wrapper.getDisposable() : null; }
private static boolean invoke( final PsiMethod method, final Project project, @Nullable final Editor editor, ChangeSignatureHandler initSubstisutor) { PsiMethod newMethod = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor")); if (newMethod == null) return false; if (!newMethod.equals(method)) { ChangeSignatureUtil.invokeChangeSignatureOn(newMethod, project); return true; } if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return false; final PsiClass containingClass = method.getContainingClass(); final PsiReferenceExpression refExpr = editor != null ? TargetElementUtil.findReferenceExpression(editor) : null; final boolean allowDelegation = containingClass != null && !containingClass.isInterface(); final DialogWrapper dialog = new GosuChangeSignatureDialog( project, new GosuMethodDescriptor((IGosuMethod) method, initSubstisutor), allowDelegation, refExpr, initSubstisutor); return dialog.showAndGet(); }
private DialogWrapper getActiveWrapper() { DialogWrapper activeWrapper = getDialogWrapper(); if (activeWrapper == null || !activeWrapper.isShowing()) { return null; } return activeWrapper; }
public void show() { DialogWrapper dialog = new DialogWrapper(true) { { setTitle("Registry"); setModal(true); init(); revaliateActions(); } protected JComponent createCenterPanel() { return myContent; } @Override protected void dispose() { super.dispose(); RegistryUi.this.dispose(); } @Override protected String getDimensionServiceKey() { return "Registry"; } @Override public JComponent getPreferredFocusedComponent() { return myTable; } @Override protected Action[] createActions() { return new Action[] { myRestoreDefaultsAction, new AbstractAction("Close") { public void actionPerformed(ActionEvent e) { processClose(); doOKAction(); } } }; } @Override public void doCancelAction() { final TableCellEditor cellEditor = myTable.getCellEditor(); if (cellEditor != null) { cellEditor.stopCellEditing(); } processClose(); super.doCancelAction(); } }; dialog.show(); }
@Override public Component getMostRecentFocusOwner() { if (!myOpened) { final DialogWrapper wrapper = getDialogWrapper(); if (wrapper != null) { JComponent toFocus = wrapper.getPreferredFocusedComponent(); if (toFocus != null) { return toFocus; } } } return super.getMostRecentFocusOwner(); }
@Override protected final void doOKAction() { if (!validateAndApply()) { return; } super.doOKAction(); }
@Override protected void doOKAction() { apply((SeverityBasedTextAttributes) myOptionsList.getSelectedValue()); final Collection<SeverityBasedTextAttributes> infoTypes = new HashSet<SeverityBasedTextAttributes>( SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar)); final ListModel listModel = myOptionsList.getModel(); final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>(); for (int i = listModel.getSize() - 1; i >= 0; i--) { final SeverityBasedTextAttributes info = (SeverityBasedTextAttributes) listModel.getElementAt(i); order.add(info.getSeverity()); if (!mySeverityRegistrar.isDefaultSeverity(info.getSeverity())) { infoTypes.remove(info); final Color stripeColor = info.getAttributes().getErrorStripeColor(); mySeverityRegistrar.registerSeverity( info, stripeColor != null ? stripeColor : LightColors.YELLOW); } } for (SeverityBasedTextAttributes info : infoTypes) { mySeverityRegistrar.unregisterSeverity(info.getSeverity()); } mySeverityRegistrar.setOrder(order); super.doOKAction(); }
@Override protected void init() { createDocumentListener(txtName); createDocumentListener(txtThumb); myOKAction.setEnabled(false); super.init(); }
@Override public void show() { final BorderDrawer drawer = new BorderDrawer(); drawer.start(); super.show(); drawer.setDone(); }
@Override protected void doOKAction() { VirtualFile root = getGitRoot(); GitLineHandler h = handler(); final AtomicBoolean conflict = new AtomicBoolean(); h.addLineListener( new GitLineHandlerAdapter() { public void onLineAvailable(String line, Key outputType) { if (line.contains("Merge conflict")) { conflict.set(true); } } }); int rc = GitHandlerUtil.doSynchronously( h, GitBundle.getString("unstash.unstashing"), h.printableCommandLine(), false); root.refresh(true, true); if (conflict.get()) { boolean conflictsResolved = new UnstashConflictResolver(myProject, root, getSelectedStash()).merge(); LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved); } else if (rc != 0) { GitUIUtil.showOperationErrors(myProject, h.errors(), h.printableCommandLine()); } super.doOKAction(); }
protected void init() { super.init(); java.util.List<Macro> macros = new ArrayList<Macro>(MacroManager.getInstance().getMacros()); Collections.sort( macros, new Comparator<Macro>() { public int compare(Macro macro1, Macro macro2) { String name1 = macro1.getName(); String name2 = macro2.getName(); if (!StringUtil.startsWithChar(name1, '/')) { name1 = ZERO + name1; } if (!StringUtil.startsWithChar(name2, '/')) { name2 = ZERO + name2; } return name1.compareToIgnoreCase(name2); } private final String ZERO = new String(new char[] {0}); }); for (Macro macro : macros) { myMacrosModel.addElement(new MacroWrapper(macro)); } addListeners(); if (myMacrosModel.size() > 0) { myMacrosList.setSelectedIndex(0); } else { setOKActionEnabled(false); } }
protected void init() { setTitle(myTitle); myTfUrl = new JTextField(); myTfPath = new JTextField(); myBtnBrowseLocalPath = new FixedSizeButton(myTfPath); super.init(); }
@Override protected void doOKAction() { myColorPicker.appendRecentColor(); myColorPicker.saveRecentColors(); super.doOKAction(); }
@Override protected void dispose() { if (myRootDifferencePane != null) { myRootDifferencePane.dispose(); } super.dispose(); }
@Override protected void init() { super.init(); final ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(myCreateNewRepoButton); buttonGroup.add(myUseParentRepoButton); }
@Override protected void doOKAction() { try { apply(); } catch (ConfigurationException ignored) { } super.doOKAction(); }
@Override public void dispose() { if (myBuilder != null) { Disposer.dispose(myBuilder); myBuilder = null; } super.dispose(); }
protected void dispose() { myNameField.removeDataChangedListener(myNameChangedListener); if (myCbReplaceAll != null) { myCbReplaceAll.removeItemListener(myReplaceAllListener); } myCbFinal.removeItemListener(myFinalListener); super.dispose(); }
@Override protected void doOKAction() { List<VirtualFile> extractedVirtualFiles = extractAdapterFiles(); if (extractedVirtualFiles != null) { installCodeAssistance(extractedVirtualFiles); } super.doOKAction(); }
public void show(@NotNull Issue issue) { this.issue = issue; currentForm = (create) ? createMainForm : updateTabbedPane; currentForm.updateUI(issue.getReview(), issue, true); cardLayout.show(centerPanel, currentForm.getClass().getName()); super.show(); }
@Override public boolean canShow(DiffRequest request) { final DiffContent[] contents = request.getContents(); final DialogWrapper instance = DialogWrapper.findInstance( IdeFocusManager.getInstance(request.getProject()).getFocusOwner()); if (instance != null && instance.isModal()) return false; if (contents.length == 2) { final VirtualFile file1 = contents[0].getFile(); final VirtualFile file2 = contents[1].getFile(); if (file1 != null && file2 != null) { final FileType type1 = contents[0].getContentType(); final FileType type2 = contents[1].getContentType(); return type1 == type2 && type1 instanceof ArchiveFileType; } } return false; }
protected void doOKAction() { if (!myValidator.isOK(this)) return; myNameSuggestionsManager.nameSelected(); myTypeSelectorManager.typeSelected(getSelectedType()); if (myCbFinal.isEnabled()) { JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_FINALS = myCbFinal.isSelected(); } super.doOKAction(); }
@Override protected void doOKAction() { super.doOKAction(); myLastRunOptions.saveOptimizeImportsState(isOptimizeImports()); myLastRunOptions.saveRearrangeCodeState(isRearrangeCode()); if (myEnableOnlyVCSChangedTextCb) { myLastRunOptions.saveProcessVcsChangedTextState( getTextRangeType() == TextRangeType.VCS_CHANGED_TEXT); } }
protected DialogWrapperPeerImpl( @NotNull DialogWrapper wrapper, @Nullable Project project, boolean canBeParent, @NotNull DialogWrapper.IdeModalityType ideModalityType) { myWrapper = wrapper; myTypeAheadCallback = myWrapper.isTypeAheadEnabled() ? new ActionCallback() : null; myWindowManager = null; Application application = ApplicationManager.getApplication(); if (application != null && application.hasComponent(WindowManager.class)) { myWindowManager = (WindowManagerEx) WindowManager.getInstance(); } Window window = null; if (myWindowManager != null) { if (project == null) { //noinspection deprecation project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext()); } myProject = project; window = myWindowManager.suggestParentWindow(project); if (window == null) { Window focusedWindow = myWindowManager.getMostRecentFocusedWindow(); if (focusedWindow instanceof IdeFrameImpl) { window = focusedWindow; } } if (window == null) { IdeFrame[] frames = myWindowManager.getAllProjectFrames(); for (IdeFrame frame : frames) { if (frame instanceof IdeFrameImpl && ((IdeFrameImpl) frame).isActive()) { window = (IdeFrameImpl) frame; break; } } } } Window owner; if (window != null) { owner = window; } else { if (!isHeadless()) { owner = JOptionPane.getRootFrame(); } else { owner = null; } } createDialog(owner, canBeParent, ideModalityType); }
@Override public void doCancelAction(final AWTEvent source) { if (source instanceof KeyEvent || source instanceof ActionEvent) { if (myEditor.getContext().isHoldingFilter()) { myEditor.clearFilter(); return; } } super.doCancelAction(source); }