當前位置: 首頁>>代碼示例>>Java>>正文


Java Disposable類代碼示例

本文整理匯總了Java中com.intellij.openapi.Disposable的典型用法代碼示例。如果您正苦於以下問題:Java Disposable類的具體用法?Java Disposable怎麽用?Java Disposable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Disposable類屬於com.intellij.openapi包,在下文中一共展示了Disposable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PhpNewClassDialog

import com.intellij.openapi.Disposable; //導入依賴的package包/類
public PhpNewClassDialog(@NotNull Project project, @Nullable PsiDirectory directory) {
    super(project);

    this.myAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD);

    Disposer.register(this.getDisposable(), new Disposable() {
        public void dispose() {
            PhpNewClassDialog.this.myAlarm.cancelAllRequests();
            PhpNewClassDialog.this.myDisposed = true;
        }
    });

    this.myProperties = new Properties();

    this.myProject = project;
    this.myDirectory = directory;

    init();
}
 
開發者ID:aurimasniekis,項目名稱:idea-php-class-templates,代碼行數:20,代碼來源:PhpNewClassDialog.java

示例2: showComponent

import com.intellij.openapi.Disposable; //導入依賴的package包/類
public void showComponent(RelativePoint point) {
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(this, this)
    .setRequestFocus(true)
    .setCancelOnOtherWindowOpen(true)
    .setCancelOnClickOutside(true)
    .setShowBorder(true)
    .createPopup();

  Disposer.register(ApplicationManager.getApplication(), new Disposable() {
    @Override
    public void dispose() {
      Disposer.dispose(myPopup);
    }
  });

  myPopup.show(point);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:18,代碼來源:StudyStepicUserWidget.java

示例3: runInterruptibly

import com.intellij.openapi.Disposable; //導入依賴的package包/類
public void runInterruptibly(@NotNull ProgressIndicator progress,
                             @NotNull Runnable onCancel,
                             @NotNull Runnable runnable) throws ProcessCanceledException {
  Disposable disposable = addPsiListener(progress);
  try {
    progress.checkCanceled();
    ProgressManager.getInstance().executeProcessUnderProgress(runnable, progress);
  }
  catch (ProcessCanceledException e) {
    progress.cancel();
    //reschedule for later
    onCancel.run();
    throw e;
  }
  finally {
    Disposer.dispose(disposable);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:SliceManager.java

示例4: installProjectDisposer

import com.intellij.openapi.Disposable; //導入依賴的package包/類
private void installProjectDisposer() {
  final Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
  if (c != null) {
    final DataContext context = DataManager.getInstance().getDataContext(c);
    final Project project = CommonDataKeys.PROJECT.getData(context);
    if (project != null) {
      myProjectDisposable = new Disposable() {

        @Override
        public void dispose() {
          if (!AbstractPopup.this.isDisposed()) {
            Disposer.dispose(AbstractPopup.this);
          }
        }
      };
      Disposer.register(project, myProjectDisposable);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:AbstractPopup.java

示例5: evaluate

import com.intellij.openapi.Disposable; //導入依賴的package包/類
@Override
public void evaluate(@NotNull final XFullValueEvaluationCallback callback) throws Exception {
  final T data = getData();
  DebuggerUIUtil.invokeLater(new Runnable() {
    @Override
    public void run() {
      if (callback.isObsolete()) return;
      final JComponent comp = createComponent(data);
      Project project = getEvaluationContext().getProject();
      JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null);
      JFrame frame = WindowManager.getInstance().getFrame(project);
      Dimension frameSize = frame.getSize();
      Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2);
      popup.setSize(size);
      if (comp instanceof Disposable) {
        Disposer.register(popup, (Disposable)comp);
      }
      callback.evaluated("");
      popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2)));
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:CustomPopupFullValueEvaluator.java

示例6: showBalloonForComponent

import com.intellij.openapi.Disposable; //導入依賴的package包/類
public static void showBalloonForComponent(@NotNull Component component, @NotNull final String message, final MessageType type,
                                           final boolean atTop, @Nullable final Disposable disposable) {
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  if (popupFactory == null) return;
  BalloonBuilder balloonBuilder = popupFactory.createHtmlTextBalloonBuilder(message, type, null);
  balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable);
  Balloon balloon = balloonBuilder.createBalloon();
  Dimension size = component.getSize();
  Balloon.Position position;
  int x;
  int y;
  if (size == null) {
    x = y = 0;
    position = Balloon.Position.above;
  }
  else {
    x = Math.min(10, size.width / 2);
    y = size.height;
    position = Balloon.Position.below;
  }
  balloon.show(new RelativePoint(component, new Point(x, y)), position);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:PopupUtil.java

示例7: invokeShow

import com.intellij.openapi.Disposable; //導入依賴的package包/類
@NotNull
private AsyncResult<Boolean> invokeShow() {
  final AsyncResult<Boolean> result = new AsyncResult<Boolean>();

  ensureEventDispatchThread();
  registerKeyboardShortcuts();

  final Disposable uiParent = Disposer.get("ui");
  if (uiParent != null) { // may be null if no app yet (license agreement)
    Disposer.register(uiParent, myDisposable); // ensure everything is disposed on app quit
  }

  Disposer.register(myDisposable, new Disposable() {
    @Override
    public void dispose() {
      result.setDone(isOK());
    }
  });

  myPeer.show();

  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:DialogWrapper.java

示例8: actionPerformed

import com.intellij.openapi.Disposable; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  Disposable disposable = Disposer.newDisposable();
  NewRecentProjectPanel panel = new NewRecentProjectPanel(disposable);
  JList list = UIUtil.findComponentOfType(panel, JList.class);
  JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, list)
    .setTitle("Recent Projects")
    .setFocusable(true)
    .setRequestFocus(true)
    .setMayBeParent(true)
    .setMovable(true)
    .createPopup();
  Disposer.register(popup, disposable);
  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  popup.showCenteredInCurrentWindow(project);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:ManageRecentProjectsAction.java

示例9: registerImplementation

import com.intellij.openapi.Disposable; //導入依賴的package包/類
public final void registerImplementation(final Class domElementClass, final Class implementationClass,
                                         @Nullable final Disposable parentDisposable) {
  final DomImplementationClassEP ep = new DomImplementationClassEP() {
    @Override
    public Class getInterfaceClass() {
      return domElementClass;
    }

    @Override
    public Class getImplementationClass() {
      return implementationClass;
    }
  };
  myImplementationClasses.putValue(domElementClass.getName(), ep);
  if (parentDisposable != null) {
    Disposer.register(parentDisposable, new Disposable() {
      @Override
      public void dispose() {
        myImplementationClasses.remove(domElementClass.getName());
      }
    });
  }
  myCache.clearCache();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:ImplementationClassCache.java

示例10: injectAll

import com.intellij.openapi.Disposable; //導入依賴的package包/類
public void injectAll(Disposable parent) {
  injectVariousStuffEverywhere(parent, myPsiManager);

  Project project = myPsiManager.getProject();
  Language ql = Language.findLanguageByID("JPAQL");
  Language js = Language.findLanguageByID("JavaScript");
  registerForStringVarInitializer(parent, project, ql, "ql", null, null);
  registerForStringVarInitializer(parent, project, ql, "qlPrefixed", "xxx", null);
  registerForStringVarInitializer(parent, project, js, "js", null, null);
  registerForStringVarInitializer(parent, project, js, "jsSeparated", " + ", " + 'separator'");
  registerForStringVarInitializer(parent, project, js, "jsBrokenPrefix", "xx ", "");

  registerForStringVarInitializer(parent, project, Language.findLanguageByID("Oracle"), "oracle", null, null);

  registerForParameterValue(parent, project, Language.findLanguageByID("Groovy"), "groovy");
  registerForStringVarInitializer(parent, project, JavaLanguage.INSTANCE, "java", "", "");
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:MyTestInjector.java

示例11: createMockApplication

import com.intellij.openapi.Disposable; //導入依賴的package包/類
public static void createMockApplication(Disposable parentDisposable) {
  final BlazeMockApplication instance = new BlazeMockApplication(parentDisposable);

  // If there was no previous application,
  // ApplicationManager leaves the MockApplication in place, which can break future tests.
  Application oldApplication = ApplicationManager.getApplication();
  if (oldApplication == null) {
    Disposer.register(
        parentDisposable,
        () -> {
          new ApplicationManager() {
            {
              ourApplication = null;
            }
          };
        });
  }

  ApplicationManager.setApplication(instance, FileTypeManager::getInstance, parentDisposable);
  instance.registerService(EncodingManager.class, EncodingManagerImpl.class);
}
 
開發者ID:bazelbuild,項目名稱:intellij,代碼行數:22,代碼來源:TestUtils.java

示例12: ContainingBranchesGetter

import com.intellij.openapi.Disposable; //導入依賴的package包/類
ContainingBranchesGetter(@NotNull VcsLogDataHolder dataHolder, @NotNull Disposable parentDisposable) {
  myDataHolder = dataHolder;
  myTaskExecutor = new SequentialLimitedLifoExecutor<Task>(parentDisposable, 10, new ThrowableConsumer<Task, Throwable>() {
    @Override
    public void consume(final Task task) throws Throwable {
      final List<String> branches = task.getContainingBranches(myDataHolder);
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          // if cache is cleared (because of log refresh) during this task execution,
          // this will put obsolete value into the old instance we don't care anymore
          task.cache.put(task.hash, branches);
          notifyListener();
        }
      });
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:ContainingBranchesGetter.java

示例13: checkNoDifferenceAndNotify

import com.intellij.openapi.Disposable; //導入依賴的package包/類
private boolean checkNoDifferenceAndNotify(DiffPanel diffPanel, DiffRequest data, final Window window, final boolean showMessage) {
  if (diffPanel.hasDifferences() || data.getHints().contains(HINT_ALLOW_NO_DIFFERENCES)) {
    return false;
  }

  DiffManagerImpl manager = (DiffManagerImpl)DiffManager.getInstance();
  ComparisonPolicy oldPolicy = manager.getComparisonPolicy();
  if (oldPolicy != ComparisonPolicy.DEFAULT) {
    manager.setComparisonPolicy(ComparisonPolicy.DEFAULT);
    Disposable parentDisposable = Disposer.newDisposable();
    DiffPanel maybeDiffPanel = DiffManagerImpl.createDiffPanel(data, window, parentDisposable, this);
    manager.setComparisonPolicy(oldPolicy);

    boolean hasDiffs = maybeDiffPanel.hasDifferences();
    Disposer.dispose(parentDisposable);

    if (hasDiffs) {
      return false;
    }
  }

  return !showMessage || !askForceOpenDiff(data);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:FrameDiffTool.java

示例14: showDialog

import com.intellij.openapi.Disposable; //導入依賴的package包/類
private static void showDialog(MergeRequestImpl data) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("MergeTool - dialog");
  }
  DialogBuilder builder = new DialogBuilder(data.getProject());
  builder.setDimensionServiceKey(data.getGroupKey());
  builder.setTitle(data.getWindowTitle());
  Disposable parent = Disposer.newDisposable();
  builder.addDisposable(parent);
  MergePanel2 mergePanel = createMergeComponent(data, builder, parent);
  builder.setCenterPanel(mergePanel.getComponent());
  builder.setPreferredFocusComponent(mergePanel.getPreferredFocusedComponent());
  builder.setHelpId(data.getHelpId());
  int result = builder.show();
  MergeRequestImpl lastData = mergePanel.getMergeRequest();
  if (lastData != null) {
    lastData.setResult(result);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:MergeTool.java

示例15: getDiffComponent

import com.intellij.openapi.Disposable; //導入依賴的package包/類
@Nullable
public JComponent getDiffComponent(DiffElement element, Project project, Window parentWindow, Disposable disposableParent) throws FilesTooBigForDiffException {
  disposeDiffComponent();

  DiffRequest request;
  try {
    request = createRequest(project, element);
  }
  catch (IOException e) {
    // TODO
    LOG.error(e);
    return null;
  }
  if (request != null) {
    myDiffPanel = DiffManager.getInstance().createDiffPanel(parentWindow, project, disposableParent, null);
    myDiffPanel.setRequestFocus(false);
    myDiffPanel.setDiffRequest(request);
    myDiffPanel.setTitle1(getName());
    myDiffPanel.setTitle2(element.getName());
    return myDiffPanel.getComponent();
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:DiffElement.java


注:本文中的com.intellij.openapi.Disposable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。