本文整理汇总了Java中org.openide.windows.TopComponent类的典型用法代码示例。如果您正苦于以下问题:Java TopComponent类的具体用法?Java TopComponent怎么用?Java TopComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TopComponent类属于org.openide.windows包,在下文中一共展示了TopComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTitle
import org.openide.windows.TopComponent; //导入依赖的package包/类
/**
* Updates the title of the enclosing view.
*/
void updateTitle() {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
if (active) {
TopComponent tc = WindowManager.getDefault().findTopComponent("CssStylesTC"); // NOI18N
if(tc != null) {
FileObject fob = getContext();
if(fob != null) {
((CssStylesTC)tc).setTitle(fob.getNameExt());
}
}
}
}
});
}
示例2: setContextAwareOptions
import org.openide.windows.TopComponent; //导入依赖的package包/类
/**
* Set options that depend on current context, and listeners that ensure
* they stay valid when the context changes.
*/
private void setContextAwareOptions(boolean searchAndReplace) {
if (!searchAndReplace) {
updateSearchInGeneratedForActiveTopComponent();
topComponentRegistryListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(
TopComponent.Registry.PROP_ACTIVATED)) {
updateSearchInGeneratedForActiveTopComponent();
}
}
};
TopComponent.getRegistry().addPropertyChangeListener(
WeakListeners.propertyChange(topComponentRegistryListener,
TopComponent.getRegistry()));
}
}
示例3: CssStylesTCController
import org.openide.windows.TopComponent; //导入依赖的package包/类
public CssStylesTCController() {
//register a weak property change listener to the window manager registry
//XXX is the weak listener really necessary? Is the registry ever GCed?
Registry reg = WindowManager.getDefault().getRegistry();
reg.addPropertyChangeListener(
WeakListeners.propertyChange(this, reg));
Lookup.Result<PageInspector> lookupResult = Lookup.getDefault().lookupResult(PageInspector.class);
lookupResult.addLookupListener(this);
resultChanged(new LookupEvent(lookupResult));
//called from CssCaretAwareSourceTask constructor when the caret is set to a css source code
//for the first time, which means if we initialize the window listener now, we won't get the component
//activated event since it happened just before the caret was set.
//fire an artificial even so the rule editor possibly opens
//the active TC should be the editor which triggered the css caret event
propertyChange(new PropertyChangeEvent(this, TopComponent.Registry.PROP_ACTIVATED, null,
TopComponent.getRegistry().getActivated()));
}
示例4: attachTopComponent
import org.openide.windows.TopComponent; //导入依赖的package包/类
/** Uses Central.userDroppedTopComponents(ModeImpl mode, TopComponentDraggable draggable, String side)
* to attach source TopComponent to target Mode according to sideConstant
* value.
* @param sourceTc source TopComponent
* @param mode target mode
* @param sideConstant side constant
*/
private static void attachTopComponent(TopComponent sourceTc, Mode mode, String sideConstant) {
try {
Class<?> centralClass = classForName("org.netbeans.core.windows.Central");
Class<?> tcdClass = classForName("org.netbeans.core.windows.view.dnd.TopComponentDraggable");
Class<?> modeImplClass = classForName("org.netbeans.core.windows.ModeImpl");
Method attachMethod = centralClass.getMethod("userDroppedTopComponents", modeImplClass, tcdClass, String.class);
Method getCentralMethod = WindowManager.getDefault().getClass().getDeclaredMethod("getCentral", (Class<?>[]) null);
getCentralMethod.setAccessible(true);
Object centralInstance = getCentralMethod.invoke(WindowManager.getDefault(), (Object[]) null);
Constructor<?> tcdConstructor = tcdClass.getDeclaredConstructor(TopComponent.class);
tcdConstructor.setAccessible(true);
Object tcdInstance = tcdConstructor.newInstance(sourceTc);
attachMethod.setAccessible(true);
attachMethod.invoke(centralInstance, mode, tcdInstance, sideConstant);
} catch (Exception e) {
throw new JemmyException("Cannot attach TopComponent.", e);
}
}
示例5: getTopComponents
import org.openide.windows.TopComponent; //导入依赖的package包/类
public Set<TopComponent> getTopComponents() {
Set<String> s;
synchronized(LOCK_TOPCOMPONENTS) {
s = new HashSet<String>(topComponents);
}
Set<TopComponent> result = new HashSet<TopComponent>(s.size());
for(String tcId: s) {
TopComponent tc = getTopComponent(tcId);
if(tc != null) {
result.add(tc);
}
}
return result;
}
示例6: dropIndication
import org.openide.windows.TopComponent; //导入依赖的package包/类
@Override
public Rectangle dropIndication( TopComponent draggedTC, Point location ) {
int tabIndex = dropIndexOfPoint( location );
if( tabIndex < 0 )
return null;
if( tabIndex == getModel().size() )
tabIndex--;
Rectangle rect = getTabBounds( tabIndex );
if( orientation == JTabbedPane.VERTICAL ) {
if( location.y <= rect.y + rect.height/2 ) {
rect.y -= rect.height / 2;
} else {
rect.y += rect.height / 2;
}
} else {
if( location.x <= rect.x + rect.width/2 ) {
rect.x -= rect.width / 2;
} else {
rect.x += rect.width / 2;
}
}
return rect;
}
示例7: getOpenedTopComponents
import org.openide.windows.TopComponent; //导入依赖的package包/类
public Set<TopComponent> getOpenedTopComponents() {
Set<String> s;
synchronized(LOCK_OPENED) {
s = new HashSet<String>(openedTopComponents);
}
Set<TopComponent> result = new HashSet<TopComponent>(s.size());
for(String tcId: s) {
TopComponent tc = getTopComponent(tcId);
if(tc != null) {
result.add(tc);
}
}
return result;
}
示例8: enable
import org.openide.windows.TopComponent; //导入依赖的package包/类
@Override
public boolean enable(Node[] nodes) {
if (super.enable(nodes)) {
Context ctx = getCachedContext(nodes);
if(!Subversion.getInstance().getStatusCache().containsFiles(ctx, enabledForStatus, true)) {
return false;
}
TopComponent activated = TopComponent.getRegistry().getActivated();
if (activated instanceof DiffSetupSource) {
return true;
}
return Lookup.getDefault().lookup(DiffProvider.class) != null;
} else {
return false;
}
}
示例9: doFullRefactoring
import org.openide.windows.TopComponent; //导入依赖的package包/类
private void doFullRefactoring() {
releaseAll();
final TopComponent activetc = TopComponent.getRegistry().getActivated();
final Runnable task = new Runnable() {
@Override
public void run() {
SHOW.show(ui.getRefactoringUI(), activetc);
}
};
if(!EventQueue.isDispatchThread()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
UIUtilities.runWhenScanFinished(task, "Instant Refactoring");
}
});
} else {
UIUtilities.runWhenScanFinished(task, "Instant Refactoring");
}
}
示例10: addModeOpenedTopComponentNoNotify
import org.openide.windows.TopComponent; //导入依赖的package包/类
/** Adds opened TopComponent into model and requests view (if needed). */
void addModeOpenedTopComponentNoNotify(ModeImpl mode, TopComponent tc) {
if(getModeOpenedTopComponents(mode).contains(tc)) {
return;
}
// Validate the TopComponent was removed from other modes.
removeTopComponentFromOtherModes(mode, tc);
model.addModeOpenedTopComponent(mode, tc);
if(isVisible()) {
viewRequestor.scheduleRequest(
new ViewRequest(mode, View.CHANGE_MODE_TOPCOMPONENT_ADDED,
null, tc));
}
}
示例11: showScene
import org.openide.windows.TopComponent; //导入依赖的package包/类
/** Shows given Scene wrapped in TopComponent and JFrame.
* @param scene Scene to be shown
* @return TopComponent instance where scene resides
*/
public static TopComponent showScene(Scene scene) {
JComponent sceneView = scene.getView();
if (sceneView == null) {
sceneView = scene.createView();
}
int width = 450, height = 250;
JFrame frame = new JFrame("Test Scene");
TopComponent tc = new TopComponent();
tc.setLayout(new BorderLayout());
tc.add(sceneView);
frame.add(tc);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
frame.setBounds((screenSize.width - width) / 2, (screenSize.height - height) / 2, width, height);
frame.setVisible(true);
return tc;
}
示例12: testDelegatesAsArrayOfAction
import org.openide.windows.TopComponent; //导入依赖的package包/类
public void testDelegatesAsArrayOfAction () throws Exception {
OurAction[] arr = {
new OurAction ()
};
action.putValue ("delegates", arr);
//arr[0].setEnabled (true);
TopComponent tc = new TopComponent();
tc.getActionMap ().put(javax.swing.text.DefaultEditorKit.pasteAction, action);
tc.requestActive();
CharSequence log = Log.enable(PasteAction.class.getName(), Level.WARNING);
global.actionPerformed (new ActionEvent (this, 0, "waitFinished"));
assertEquals("Log is empty", "", log.toString());
arr[0].assertCnt ("Performed on delegate", 1);
action.assertCnt ("Not performed on action", 0);
}
示例13: show
import org.openide.windows.TopComponent; //导入依赖的package包/类
@Override
public void show(RefactoringUI ui, TopComponent activetc) {
if (ui!=null) {
UI.openRefactoringUI(ui, activetc);
} else {
JOptionPane.showMessageDialog(null,NbBundle.getMessage(RefactoringActionsProvider.class, "ERR_CannotRenameKeyword"));
}
}
示例14: isFromEditorWindow
import org.openide.windows.TopComponent; //导入依赖的package包/类
protected boolean isFromEditorWindow(DataObject dobj,
final TopComponent tc) {
final EditorCookie editor = dobj.getLookup().lookup(
EditorCookie.class);
if (editor != null) {
return Mutex.EVENT.readAccess(new Action<Boolean>() {
@Override
public Boolean run() {
return (tc instanceof CloneableTopComponent) // #246597
|| NbDocument.findRecentEditorPane(editor) != null;
}
});
}
return false;
}
示例15: someoneActivated
import org.openide.windows.TopComponent; //导入依赖的package包/类
private void someoneActivated() {
TopComponent win = TopComponent.getRegistry().getActivated();
if (LOG.isLoggable(Level.FINER)) {
String winId;
if (win == null) {
winId = "<null>";
} else {
String winName = win.getDisplayName();
if (winName == null) {
winName = win.getHtmlDisplayName();
}
if (winName == null) {
winName = win.getName();
}
if (winName != null) {
winName = '"' + winName + '"';
} else {
winName = "<noname>";
}
winId = winName + '(' + win.getClass().getName() + ')';
}
LOG.log(Level.FINER, "someoneActivated ({0})", winId);
}
if ((win == null) || (win instanceof CloneableEditorSupport.Pane)) {
return;
}
Object key = getActionMapKey();
ActionMap actionMap = win.getActionMap();
if ((actionMap.get(key) == null) && activatedOnWindows.add(win)) {
Action ls = getAction();
actionMap.put(key, ls);
win.putClientProperty(getMappedActionKey(),
new WeakReference<Action>(ls));
}
}