Java 类com.intellij.ui.GuiUtils 实例源码

项目:intellij-ce-playground    文件:UnscrambleDialog.java   
private void createLogFileChooser() {
  myLogFile = new TextFieldWithHistory();
  JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
      FileChooser.chooseFiles(descriptor, myProject, null, new Consumer<List<VirtualFile>>() {
        @Override
        public void consume(List<VirtualFile> files) {
          myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath()));
        }
      });
    }
  });
  myLogFileChooserPanel.setLayout(new BorderLayout());
  myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
项目:intellij-ce-playground    文件:UsageLimitUtil.java   
private static int runOrInvokeAndWait(@NotNull final Computable<Integer> f) {
  final int[] answer = new int[1];
  try {
    GuiUtils.runOrInvokeAndWait(new Runnable() {
      @Override
      public void run() {
        answer[0] = f.compute();
      }
    });
  }
  catch (Exception e) {
    answer[0] = 0;
  }

  return answer[0];
}
项目:intellij-ce-playground    文件:InterruptibleActivity.java   
protected int processTimeoutInEDT() {
  final int[] retcode = new int[1];

  try {
    GuiUtils.runOrInvokeAndWait(new Runnable() {
      public void run() {
        retcode[0] = processTimeout();
      }
    });
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }

  return retcode[0];
}
项目:intellij-ce-playground    文件:TableView.java   
@Override
protected void createDefaultRenderers() {
  super.createDefaultRenderers();

  UIDefaults.LazyValue booleanRenderer = new UIDefaults.LazyValue() {
    @Override
    public Object createValue(@NotNull UIDefaults table) {
      DefaultCellEditor editor = new DefaultCellEditor(GuiUtils.createUndoableTextField());
      editor.setClickCountToStart(1);
      return new BooleanTableCellRenderer();
    }
  };
  //noinspection unchecked
  defaultRenderersByColumnClass.put(boolean.class, booleanRenderer);
  //noinspection unchecked
  defaultRenderersByColumnClass.put(Boolean.class, booleanRenderer);
}
项目:intellij-ce-playground    文件:TableView.java   
@Override
protected void createDefaultEditors() {
  super.createDefaultEditors();

  //noinspection unchecked
  defaultEditorsByColumnClass.put(String.class, new UIDefaults.LazyValue() {
    @Override
    public Object createValue(@NotNull UIDefaults table) {
      DefaultCellEditor editor = new DefaultCellEditor(GuiUtils.createUndoableTextField());
      editor.setClickCountToStart(1);
      return editor;
    }
  });

  //noinspection unchecked
  defaultEditorsByColumnClass.put(boolean.class, defaultEditorsByColumnClass.get(Boolean.class));
}
项目:intellij-ce-playground    文件:GitChangeProviderVersionedTest.java   
@Test
public void testDeleteDirRecursively() throws Exception {
  GuiUtils.runOrInvokeAndWait(new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          final VirtualFile dir = myProjectRoot.findChild("dir");
          myDirtyScope.addDirtyDirRecursively(VcsUtil.getFilePath(dir));
          FileUtil.delete(VfsUtilCore.virtualToIoFile(dir));
        }
      });
    }
  });
  assertChanges(new VirtualFile[] { dir_ctxt, subdir_dtxt },
                new FileStatus[] { DELETED, DELETED });
}
项目:tools-idea    文件:UnscrambleDialog.java   
private void createLogFileChooser() {
  myLogFile = new TextFieldWithHistory();
  JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
      FileChooser.chooseFiles(descriptor, myProject, null, new Consumer<List<VirtualFile>>() {
        @Override
        public void consume(List<VirtualFile> files) {
          myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath()));
        }
      });
    }
  });
  myLogFileChooserPanel.setLayout(new BorderLayout());
  myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
项目:tools-idea    文件:UsageLimitUtil.java   
private static int runOrInvokeAndWait(final Computable<Integer> f) {
  final int[] answer = new int[1];
  try {
    GuiUtils.runOrInvokeAndWait(new Runnable() {
      @Override
      public void run() {
        answer[0] = f.compute();
      }
    });
  }
  catch (Exception e) {
    answer[0] = 0;
  }

  return answer[0];
}
项目:tools-idea    文件:InterruptibleActivity.java   
protected int processTimeoutInEDT() {
  final int[] retcode = new int[1];

  try {
    GuiUtils.runOrInvokeAndWait(new Runnable() {
      public void run() {
        retcode[0] = processTimeout();
      }
    });
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }

  return retcode[0];
}
项目:tools-idea    文件:WriteCommandAction.java   
@Override
public RunResult<T> execute() {
  final RunResult<T> result = new RunResult<T>(this);

  try {
    Runnable runnable = new Runnable() {
      @Override
      public void run() {
        performWriteCommandAction(result);
      }
    };
    Application application = ApplicationManager.getApplication();
    if (application.isWriteAccessAllowed() || application.isDispatchThread()) {
      runnable.run();
    }
    else {
      GuiUtils.invokeAndWait(runnable);
    }
  }
  catch (InvocationTargetException e) {
    throw new RuntimeException(e.getCause()); // save both stacktraces: current & EDT
  }
  catch (InterruptedException ignored) { }
  return result;
}
项目:tools-idea    文件:GitTest.java   
@AfterMethod
protected void tearDown() throws Exception {
  GuiUtils.runOrInvokeAndWait(new Runnable() {
    @Override
    public void run() {
      try {
        tearDownProject();
        myProjectDirFixture.tearDown();
        myBrotherDirFixture.tearDown();
        myParentDirFixture.tearDown();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  });
}
项目:tools-idea    文件:GitChangeProviderVersionedTest.java   
@Test
public void testDeleteDirRecursively() throws Exception {
  GuiUtils.runOrInvokeAndWait(new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          final VirtualFile dir = myRepo.getVFRootDir().findChild("dir");
          myDirtyScope.addDirtyDirRecursively(new FilePathImpl(dir));
          FileUtil.delete(VfsUtil.virtualToIoFile(dir));
        }
      });
    }
  });
  assertChanges(new VirtualFile[] { myFiles.get("dir/c.txt"), myFiles.get("dir/subdir/d.txt") }, new FileStatus[] { DELETED, DELETED });
}
项目:tools-idea    文件:PropertiesDocumentationProvider.java   
public String generateDoc(final PsiElement element, @Nullable final PsiElement originalElement) {
  if (element instanceof IProperty) {
    IProperty property = (IProperty)element;
    String text = property.getDocCommentText();

    @NonNls String info = "";
    if (text != null) {
      TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(PropertiesHighlighter.PROPERTY_COMMENT).clone();
      Color background = attributes.getBackgroundColor();
      if (background != null) {
        info +="<div bgcolor=#"+ GuiUtils.colorToHex(background)+">";
      }
      String doc = StringUtil.join(StringUtil.split(text, "\n"), "<br>");
      info += "<font color=#" + GuiUtils.colorToHex(attributes.getForegroundColor()) + ">" + doc + "</font>\n<br>";
      if (background != null) {
        info += "</div>";
      }
    }
    info += "\n<b>" + property.getName() + "</b>=\"" + renderPropertyValue(((IProperty)element)) + "\"";
    info += getLocationString(element);
    return info;
  }
  return null;
}
项目:DeftIDEA    文件:DylanDefinitionDocumentationProvider.java   
public String generateDoc(final PsiElement element, @Nullable final PsiElement originalElement) {
  if (element instanceof DylanDefinition) {
    DylanDefinition definition = (DylanDefinition)element;
    String text = "Not supported yet";

    @NonNls String info = "";
    if (text != null) {
      TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DylanSyntaxHighlighterColors.COMMENT).clone();
      Color background = attributes.getBackgroundColor();
      if (background != null) {
        info +="<div bgcolor=#"+ GuiUtils.colorToHex(background)+">";
      }
      String doc = StringUtil.join(StringUtil.split(text, "\n"), "<br>");
      info += "<font color=#" + GuiUtils.colorToHex(attributes.getForegroundColor()) + ">" + doc + "</font>\n<br>";
      if (background != null) {
        info += "</div>";
      }
    }
    info += "\n<b>" + definition.getName() + "</b>";
    info += getLocationString(element);
    return info;
  }
  return null;
}
项目:consulo    文件:UsageLimitUtil.java   
private static int runOrInvokeAndWait(@Nonnull final Computable<Integer> f) {
  final int[] answer = new int[1];
  try {
    GuiUtils.runOrInvokeAndWait(new Runnable() {
      @Override
      public void run() {
        answer[0] = f.compute();
      }
    });
  }
  catch (Exception e) {
    answer[0] = 0;
  }

  return answer[0];
}
项目:consulo    文件:InterruptibleActivity.java   
protected int processTimeoutInEDT() {
  final int[] retcode = new int[1];

  try {
    GuiUtils.runOrInvokeAndWait(new Runnable() {
      public void run() {
        retcode[0] = processTimeout();
      }
    });
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }

  return retcode[0];
}
项目:consulo    文件:StartupManagerImpl.java   
public void scheduleInitialVfsRefresh() {
  GuiUtils.invokeLaterIfNeeded(() -> {
    if (myProject.isDisposed() || myInitialRefreshScheduled) return;

    myInitialRefreshScheduled = true;
    ((ProjectRootManagerImpl)ProjectRootManager.getInstance(myProject)).markRootsForRefresh();

    Application app = ApplicationManager.getApplication();
    if (!app.isCommandLine()) {
      final long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
      final MessageBusConnection connection = app.getMessageBus().connect();
      connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener() {
        @Override
        public void afterProjectClosed(@Nonnull Project project) {
          if (project != myProject) return;

          RefreshQueue.getInstance().cancelSession(sessionId);
          connection.disconnect();
        }
      });
    }
    else {
      VirtualFileManager.getInstance().syncRefresh();
    }
  }, ModalityState.defaultModalityState());
}
项目:consulo    文件:StartupManagerImpl.java   
@Override
public void runWhenProjectIsInitialized(@Nonnull final Runnable action) {
  final Application application = ApplicationManager.getApplication();
  if (application == null) return;

  Runnable runnable = () -> {
    if (myProject.isDisposed()) return;

    //noinspection SynchronizeOnThis
    synchronized (this) {
      // in tests which simulate project opening, post-startup activities could have been run already.
      // Then we should act as if the project was initialized
      boolean initialized = myProject.isInitialized() || myProject.isDefault() || application.isUnitTestMode() && myPostStartupActivitiesPassed;
      if (!initialized) {
        registerPostStartupActivity(action);
        return;
      }
    }

    action.run();
  };
  GuiUtils.invokeLaterIfNeeded(runnable, ModalityState.NON_MODAL);
}
项目:consulo-java    文件:UnscrambleDialog.java   
public UnscrambleDialog(Project project)
{
    super(false);
    myProject = project;

    populateRegisteredUnscramblerList();
    myUnscrambleChooser.addActionListener(e ->
    {
        UnscrambleSupport unscrambleSupport = getSelectedUnscrambler();
        GuiUtils.enableChildren(myLogFileChooserPanel, unscrambleSupport != null);
    });
    myUseUnscrambler.addActionListener(e -> useUnscramblerChanged());
    myOnTheFly.setSelected(UnscrambleManager.getInstance().isEnabled());
    myOnTheFly.addActionListener(e -> UnscrambleManager.getInstance().setEnabled(myOnTheFly.isSelected()));
    createLogFileChooser();
    createEditor();
    reset();

    setTitle(IdeBundle.message("unscramble.dialog.title"));
    init();
}
项目:intellij-ce-playground    文件:ComponentWithBrowseButton.java   
public void setTextFieldPreferredWidth(final int charCount) {
  final Comp comp = getChildComponent();
  Dimension size = GuiUtils.getSizeByChars(charCount, comp);
  comp.setPreferredSize(size);
  final Dimension preferredSize = myBrowseButton.getPreferredSize();
  setPreferredSize(new Dimension(size.width + preferredSize.width + 2, UIUtil.isUnderAquaLookAndFeel() ? preferredSize.height : preferredSize.height + 2));
}
项目:intellij-ce-playground    文件:PostfixTemplatesConfigurable.java   
@NotNull
@Override
public JComponent createComponent() {
  GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
  if (null == myInnerPostfixDescriptionPanel) {
    myInnerPostfixDescriptionPanel = new PostfixDescriptionPanel();
    myDescriptionPanel.add(myInnerPostfixDescriptionPanel.getComponent());
  }
  if (null == myCheckboxTree) {
    createTree();
    myCheckboxTree.initTree(templateMultiMap);
  }

  return myPanel;
}
项目:intellij-ce-playground    文件:ProjectViewImpl.java   
public synchronized void setupImpl(@NotNull ToolWindow toolWindow, final boolean loadPaneExtensions) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  myActionGroup = new DefaultActionGroup();

  myAutoScrollFromSourceHandler.install();

  myContentManager = toolWindow.getContentManager();
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    toolWindow.setDefaultContentUiType(ToolWindowContentUiType.COMBO);
    ((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
    toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
  }

  GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      splitterProportions.restoreSplitterProportions(myPanel);
    }
  });

  if (loadPaneExtensions) {
    ensurePanesLoaded();
  }
  isInitialized = true;
  doAddUninitializedPanes();

  myContentManager.addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
        viewSelectionChanged();
      }
    }
  });
  viewSelectionChanged();
}
项目:intellij-ce-playground    文件:HgUtil.java   
/**
 * Runs the given task as a write action in the event dispatching thread and waits for its completion.
 */
public static void runWriteActionAndWait(@NotNull final Runnable runnable) throws InvocationTargetException, InterruptedException {
  GuiUtils.runOrInvokeAndWait(new Runnable() {
    public void run() {
      ApplicationManager.getApplication().runWriteAction(runnable);
    }
  });
}
项目:intellij-ce-playground    文件:HgTest.java   
@AfterMethod
protected void tearDown() throws Exception {
  GuiUtils.runOrInvokeAndWait(new Runnable() {
    @Override
    public void run() {
      try {
        tearDownProject();
        tearDownRepositories();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  });
}
项目:intellij-ce-playground    文件:PropertiesDocumentationProvider.java   
public String generateDoc(final PsiElement element, @Nullable final PsiElement originalElement) {
  if (element instanceof IProperty) {
    IProperty property = (IProperty)element;
    String text = property.getDocCommentText();

    @NonNls String info = "";
    if (text != null) {
      TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(PropertiesHighlighter.PROPERTY_COMMENT).clone();
      Color background = attributes.getBackgroundColor();
      if (background != null) {
        info +="<div bgcolor=#"+ GuiUtils.colorToHex(background)+">";
      }
      String doc = StringUtil.join(ContainerUtil.map(StringUtil.split(text, "\n"), new Function<String, String>() {
        @Override
        public String fun(String s) {
          return StringUtil.trimStart(StringUtil.trimStart(s, "#"), "!").trim();
        }
      }), "<br>");
      info += "<font color=#" + GuiUtils.colorToHex(attributes.getForegroundColor()) + ">" + doc + "</font>\n<br>";
      if (background != null) {
        info += "</div>";
      }
    }
    info += "\n<b>" + property.getName() + "</b>=\"" + renderPropertyValue(((IProperty)element)) + "\"";
    info += getLocationString(element);
    return info;
  }
  return null;
}
项目:js-graphql-intellij-plugin    文件:JSGraphQLDocumentationProvider.java   
@NotNull
private String createIndex(Color borderColor) {
    if(borderColor == null) {
        final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
        borderColor = globalScheme.getDefaultForeground();
    }
    return "<div style=\"border-bottom: 1px outset "+ GuiUtils.colorToHex(borderColor)+"; padding: 0 2px 8px 0; margin-bottom: 16px; text-align: right;\">Index: "+ getTypeHyperLink("Query", "Queries") + " - "+ getTypeHyperLink("Mutation", "Mutations")+"</div>";
}
项目:review-board-idea-plugin    文件:ReviewsPanel.java   
public void setReviewsList(final int pageNumber, final List<Review> reviews) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            reviewsTable.setModel(new ReviewTableModel(reviews));
            reviewsTable.getColumnModel().getColumn(ReviewTableModel.Columns.SUMMARY.getIndex()).setPreferredWidth(400);
            reviewsTable.getColumnModel().getColumn(ReviewTableModel.Columns.SUBMITTED_TO.getIndex()).setPreferredWidth(50);
            reviewsTable.getColumnModel().getColumn(ReviewTableModel.Columns.SUBMITTER.getIndex()).setPreferredWidth(50);
            reviewsTable.getColumnModel().getColumn(ReviewTableModel.Columns.LAST_MODIFIED.getIndex()).setPreferredWidth(50);
            page.setText(String.valueOf(pageNumber));
            GuiUtils.enableChildren(true, ReviewsPanel.this);
        }
    });
}
项目:review-board-idea-plugin    文件:ReviewsPanel.java   
public void setCurrentReview(List<Review.File> files) {
    final List<Change> changes = new ArrayList<>();
    for (Review.File file : files) {
        FilePath srcFilePath;
        FilePath patchFilePath;
        try {
            Class<?> aClass = Class.forName("com.intellij.openapi.vcs.LocalFilePath");
            srcFilePath = (FilePath) aClass.getDeclaredConstructor(String.class, boolean.class).newInstance(file.srcFileName, false);
            patchFilePath = (FilePath) aClass.getDeclaredConstructor(String.class, boolean.class).newInstance(file.dstFileName, false);
        } catch (Exception e) {
            try {
                srcFilePath = (FilePath) Class.forName("com.intellij.openapi.vcs.FilePathImpl")
                        .getDeclaredMethod("createNonLocal", String.class, boolean.class)
                        .invoke(null, file.srcFileName, false);
                patchFilePath = (FilePath) Class.forName("com.intellij.openapi.vcs.FilePathImpl")
                        .getDeclaredMethod("createNonLocal", String.class, boolean.class)
                        .invoke(null, file.dstFileName, false);
            } catch (Exception e1) {
                throw new RuntimeException(e1);
            }
        }
        SimpleContentRevision original = new SimpleContentRevision(file.srcFileContents, srcFilePath, file.sourceRevision);
        SimpleContentRevision patched = new SimpleContentRevision(file.dstFileContents, patchFilePath, "New Change");
        changes.add(new Change(original, patched));
    }
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        public void run() {
            changesTree.setChangesToDisplay(changes);
            GuiUtils.enableChildren(true, ReviewsPanel.this);
        }
    });
}
项目:review-board-idea-plugin    文件:ReviewsPanel.java   
public void enablePanel(final boolean enable) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        public void run() {
            GuiUtils.enableChildren(ReviewsPanel.this, enable, mainReviewToolbar);
        }
    });
}
项目:tools-idea    文件:WriteAction.java   
public RunResult<T> execute() {
  final RunResult<T> result = new RunResult<T>(this);

  if (canWriteNow()) {
    result.run();
    return result;
  }

  try {
    GuiUtils.runOrInvokeAndWait(new Runnable() {
      public void run() {
        final AccessToken accessToken = start();
        try {
          result.run();
        }
        finally {
          accessToken.finish();
        }
      }
    });
  }
  catch (Exception e) {
    if (isSilentExecution()) {
      result.setThrowable(e);
    }
    else {
      if (e instanceof RuntimeException) throw (RuntimeException)e;
      throw new Error(e);
    }
  }
  return result;
}
项目:tools-idea    文件:ProjectViewImpl.java   
public synchronized void setupImpl(final ToolWindow toolWindow, final boolean loadPaneExtensions) {
  myActionGroup = new DefaultActionGroup();

  myAutoScrollFromSourceHandler.install();

  if (toolWindow != null) {
    myContentManager = toolWindow.getContentManager();
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      toolWindow.setContentUiType(ToolWindowContentUiType.getInstance("combo"), null);
      ((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
      toolWindow.getComponent().putClientProperty(ToolWindowContentUi.HIDE_ID_LABEL, "true");
    }
  } else {
    final ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
    myContentManager = contentFactory.createContentManager(false, myProject);
  }

  GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      splitterProportions.restoreSplitterProportions(myPanel);
    }
  });

  if (loadPaneExtensions) {
    ensurePanesLoaded();
  }
  isInitialized = true;
  doAddUninitializedPanes();

  myContentManager.addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
        viewSelectionChanged();
      }
    }
  });
}
项目:tools-idea    文件:HgUtil.java   
/**
 * Runs the given task as a write action in the event dispatching thread and waits for its completion.
 */
public static void runWriteActionAndWait(@NotNull final Runnable runnable) throws InvocationTargetException, InterruptedException {
  GuiUtils.runOrInvokeAndWait(new Runnable() {
    public void run() {
      ApplicationManager.getApplication().runWriteAction(runnable);
    }
  });
}
项目:tools-idea    文件:HgTest.java   
@AfterMethod
protected void tearDown() throws Exception {
  GuiUtils.runOrInvokeAndWait(new Runnable() {
    @Override
    public void run() {
      try {
        tearDownProject();
        tearDownRepositories();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  });
}
项目:intellij-xquery    文件:ContextItemPanel.java   
private void contextItemSourceChanged() {
    final boolean editorAsSource = isContextItemFromEditorEnabled();
    if (isContextItemEnabled()) {
        GuiUtils.enableChildren(contextItemEditorContent, editorAsSource);
        GuiUtils.enableChildren(contextItemPathField, ! editorAsSource);
    }
    contextItemEditorContent.invalidate();
    contextItemPathField.invalidate();
}
项目:consulo-javaee    文件:JavaeeBaseEditor.java   
protected final void enableChildren(JComponent container, boolean enabled) {
    final Set<JComponent> excluded = new HashSet<JComponent>();
    GuiUtils.iterateChildren(container, new Consumer<Component>() {
        public void consume(Component component) {
            if ((component instanceof JComponent) && (((JComponent) component).getClientProperty(ROOT) != null)) {
                excluded.add((JComponent) component);
            }
        }
    });
    excluded.remove(container);
    GuiUtils.enableChildren(container, enabled, excluded.toArray(new JComponent[excluded.size()]));
}
项目:consulo    文件:ComponentWithBrowseButton.java   
public void setTextFieldPreferredWidth(final int charCount) {
  final Comp comp = getChildComponent();
  Dimension size = GuiUtils.getSizeByChars(charCount, comp);
  comp.setPreferredSize(size);
  final Dimension preferredSize = myBrowseButton.getPreferredSize();
  setPreferredSize(new Dimension(size.width + preferredSize.width + 2, UIUtil.isUnderAquaLookAndFeel() ? preferredSize.height : preferredSize.height + 2));
}
项目:consulo    文件:ProjectViewImpl.java   
@RequiredUIAccess
@Override
public void setupToolWindow(@Nonnull ToolWindow toolWindow, final boolean loadPaneExtensions) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  myActionGroup = new DefaultActionGroup();

  myAutoScrollFromSourceHandler.install();

  myContentManager = toolWindow.getContentManager();
  if (!ApplicationManager.getApplication().isUnitTestMode()) {
    toolWindow.setDefaultContentUiType(ToolWindowContentUiType.COMBO);
    ((ToolWindowEx)toolWindow).setAdditionalGearActions(myActionGroup);
    toolWindow.getComponent().putClientProperty(ToolWindowContentUI.HIDE_ID_LABEL, "true");
  }

  GuiUtils.replaceJSplitPaneWithIDEASplitter(myPanel);
  SwingUtilities.invokeLater(() -> splitterProportions.restoreSplitterProportions(myPanel));

  if (loadPaneExtensions) {
    ensurePanesLoaded();
  }
  isInitialized = true;
  doAddUninitializedPanes();

  getContentManager().addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      if (event.getOperation() == ContentManagerEvent.ContentOperation.add) {
        viewSelectionChanged();
      }
    }
  });
  viewSelectionChanged();
}
项目:consulo    文件:BaseRefactoringProcessor.java   
protected void prepareSuccessful() {
  if (myPrepareSuccessfulSwingThreadCallback != null) {
    // make sure that dialog is closed in swing thread
    try {
      GuiUtils.runOrInvokeAndWait(myPrepareSuccessfulSwingThreadCallback);
    }
    catch (InterruptedException | InvocationTargetException e) {
      LOG.error(e);
    }
  }
}
项目:consulo-java    文件:UnscrambleDialog.java   
private void createLogFileChooser()
{
    myLogFile = new TextFieldWithHistory();
    JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, e ->
    {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
        FileChooser.chooseFiles(descriptor, myProject, null, files -> myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath())));
    });
    myLogFileChooserPanel.setLayout(new BorderLayout());
    myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
项目:CodeGen    文件:VariableUI.java   
public VariableUI() {
    $$$setupUI$$$();
    GuiUtils.replaceJSplitPaneWithIDEASplitter(splitPanel);
    setVariables(settingManager.getVariables());
}