本文整理了Java中org.openide.windows.Mode
类的一些代码示例,展示了Mode
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mode
类的具体详情如下:
包路径:org.openide.windows.Mode
类名称:Mode
[英]Instances of this interface represent places or containers which TopComponent
has to be added to in order to be managed by window system.
There is always present default document mode named "editor". Modules can add their own modes by declaring them using XML.
Modules can get a set of current modes by calling WindowManager#getModes.
Each mode must have a unique name.
Important note: Do not provide implementation of this interface unless you are window system provider!
[中]此接口的实例表示必须添加TopComponent
才能由Windows系统管理的位置或容器。
始终存在名为“编辑器”的默认文档模式。模块可以通过使用XML声明来添加自己的模式。
模块可以通过调用WindowManager#getModes获得一组当前模式。
每个模式必须有一个唯一的名称。
重要提示:除非您是Windows系统提供商,否则不要提供此接口的实现
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** Dock this top component to editor mode if it is not docked
* in some mode at this time */
private void dockIfNeeded(Workspace workspace) {
// dock into editor mode if possible
Mode ourMode = workspace.findMode(this);
if (ourMode == null) {
editorMode(workspace).dockInto(this);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public Mode findMode(String name) {
if(name == null) {
return null;
}
for(Iterator it = getModes().iterator(); it.hasNext(); ) {
Mode m = (Mode)it.next();
if(name.equals(m.getName())) {
return m;
}
}
return null;
}
代码示例来源:origin: senbox-org/snap-desktop
/**
* Opens a top component in the given mode.
*
* @param topComponent The top component to open.
* @param modeName The mode's name.
* @return {@code true} on success.
*/
public static boolean openInMode(TopComponent topComponent, String modeName) {
Mode mode = WindowManager.getDefault().findMode(modeName);
if (mode != null) {
if (!Arrays.asList(mode.getTopComponents()).contains(topComponent)) {
if (mode.dockInto(topComponent)) {
topComponent.open();
return true;
}
} else {
topComponent.open();
return true;
}
}
return false;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-dlight-core-ui
private DLightIndicatorsTopComponent(boolean dock) {
initComponents();
this.dock = dock;
setSession(null);
setName(getMessage("CTL_DLightIndicatorsTopComponent")); // NOI18N
setToolTipText(getMessage("CTL_DLightIndicatorsTopComponent"));//NOI18N
setIcon(ImageUtilities.loadImage(ICON_PATH, true));
if (dock) {
if (WindowManager.getDefault().findMode(this) == null || WindowManager.getDefault().findMode(this).getName().equals("navigator")) { // NOI18N
if (WindowManager.getDefault().findMode("navigator") != null) { // NOI18N
WindowManager.getDefault().findMode("navigator").dockInto(this);//NOI18N
}
}
}
setFocusTraversalPolicyProvider(true);
setFocusTraversalPolicy(focusPolicy);
// ActionMap map = new ActionMap();
// map.put("org.openide.actions.PopupAction", popupAction);//NOI18N
// this.associateLookup(ExplorerUtils.createLookup(manager, map));
// installActions();
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io
public void propertyChange (PropertyChangeEvent evt) {
if (! TopComponent.Registry.PROP_ACTIVATED.equals (evt.getPropertyName ()))
return;
// System.out.println ("!! Global Context Lookup Result = " + Utilities.actionsGlobalContext ().lookupAll (Object.class));
Mode m = findEditorMode ();
TopComponent component = m != null ? m.getSelectedTopComponent () : null;
if (result != null)
result.removeLookupListener (this);
result = component != null ? component.getLookup ().lookupResult (DataEditorView.class) : null;
if (result != null)
result.addLookupListener (this);
update ();
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public Mode findMode(TopComponent tc) {
for(Iterator it = getModes().iterator(); it.hasNext(); ) {
Mode m = (Mode)it.next();
if(Arrays.asList(m.getTopComponents()).contains(tc)) {
return m;
}
}
return null;
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-cnd-gizmo
private GizmoIndicatorsTopComponent(boolean dock) {
initComponents();
this.dock = dock;
setSession(null);
setName(getMessage("CTL_DLightIndicatorsTopComponent")); // NOI18N
setToolTipText(getMessage("CTL_DLightIndicatorsTopComponent"));//NOI18N
setIcon(ImageUtilities.loadImage(ICON_PATH, true));
if (dock) {
if (WindowManager.getDefault().findMode(this) == null || WindowManager.getDefault().findMode(this).getName().equals("navigator")) { // NOI18N
if (WindowManager.getDefault().findMode("navigator") != null) { // NOI18N
WindowManager.getDefault().findMode("navigator").dockInto(this);//NOI18N
}
}
}
setFocusTraversalPolicyProvider(true);
setFocusTraversalPolicy(focusPolicy);
ActionMap map = new ActionMap();
map.put("org.openide.actions.PopupAction", popupAction);//NOI18N
this.associateLookup(ExplorerUtils.createLookup(manager, map));
installActions();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui
private TopComponent selectedEditorComponent() {
Mode editor = WindowManager.getDefault().findMode("editor");//NOI18N
TopComponent tc = editor.getSelectedTopComponent();
TopComponent topComponent = getTopComponent(EditorRegistry.lastFocusedComponent());
if (topComponent == tc) {
return tc;
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public Mode findMode(TopComponent tc) {
for(Iterator it = getModes().iterator(); it.hasNext(); ) {
Mode m = (Mode)it.next();
if(Arrays.asList(m.getTopComponents()).contains(tc)) {
return m;
}
}
return null;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** Dock this top component to editor mode if it is not docked
* in some mode at this time */
private void dockIfNeeded(Workspace workspace) {
// dock into editor mode if possible
Mode ourMode = workspace.findMode(this);
if (ourMode == null) {
editorMode(workspace).dockInto(this);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-designer
TopComponent[] tcs = m.getTopComponents();
mode.dockInto(btc);
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public Mode findMode(String name) {
if(name == null) {
return null;
}
for(Iterator it = getModes().iterator(); it.hasNext(); ) {
Mode m = (Mode)it.next();
if(name.equals(m.getName())) {
return m;
}
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-insync
private List<FacesModel> getVisibleModels() {
List<FacesModel> visibleModels = new ArrayList<FacesModel>();
for(Mode mode : WindowManager.getDefault().getModes()) {
TopComponent tc = mode.getSelectedTopComponent();
if(tc != null && tc.isOpened() && isMultiViewTopComponent(tc)){
TopComponent topComponent = getSelectedMultiView(tc);
if(topComponent != null && isDesignerTopComponent(topComponent)) {
// DataObject dObj = topComponent.getActivatedNodes()[0].getLookup().lookup(DataObject.class);
// XXX #131996 Defend against possible NPE's.
org.openide.nodes.Node[] activatedNodes = topComponent.getActivatedNodes();
if (activatedNodes == null || activatedNodes.length == 0) {
info(new NullPointerException("TopComponent doesn't have any activated nodes, topComponent="
+ topComponent + ", nodes=" + activatedNodes)); // NOI18N
continue;
}
DataObject dObj = activatedNodes[0].getLookup().lookup(DataObject.class);
if (dObj == null) {
info(new NullPointerException("Activated node from top component"
+ " doesn't contain DataObject in its first activated node lookup, topComponent="
+ topComponent + ", node=" + activatedNodes[0])); // NOI18N
continue;
}
visibleModels.add((FacesModel)getModel(dObj.getPrimaryFile()));
}
}
}
return visibleModels;
}
代码示例来源:origin: nl.cloudfarming.client/nbtaskfocus-core
@Override
public void run() {
Mode tcMode = WindowManager.getDefault().findMode("editor"); // NOI18N
TopComponent[] topComponents = tcMode.getTopComponents();
TopComponent tcToClose = null;
for (TopComponent tc : topComponents) {
Lookup lookup = tc.getLookup();
FileObject fileObject = getFileObject(lookup);
if (null != fileObject) {
String path = fileObject.getPath();
if (path.equals(filePath)) {
tcToClose = tc;
break;
}
}
}
if (null != tcToClose) {
tcToClose.close();
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
public void open() {
if (needsDocking()) { // needs docking
Mode mode = WindowManager.getDefault().findMode(Bundle.ProfilerControlPanel2_WindowMode());
if (mode != null) {
mode.dockInto(this);
}
}
super.open();
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io
private static Mode findEditorMode () {
Set modes = WindowManager.getDefault ().getModes ();
for (Object o : modes) {
Mode m = (Mode) o;
if (m != null && MODE_EDITOR.equals (m.getName ()))
return m;
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui
TopComponent tc = editor.getSelectedTopComponent();
dropDownMenu.add(new InsertLinkAction(issues[i], outbox, isIssueRelated(tc)));
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
public void open() {
if (needsDocking()) { // needs docking
Mode mode = WindowManager.getDefault().findMode(Bundle.TelemetryOverviewPanel_WindowMode());
if (mode != null) {
mode.dockInto(this);
}
}
super.open();
}
代码示例来源:origin: it.tidalwave.netbeans/it-tidalwave-netbeans-docking
@Override
public void propertyChange (@Nonnull final PropertyChangeEvent event)
{
if (TopComponent.Registry.PROP_ACTIVATED.equals(event.getPropertyName()))
{
activeComponent = (TopComponent)event.getNewValue();
boolean enabled = false;
if (activeComponent != null)
{
final Mode mode = WindowManager.getDefault().findMode(activeComponent);
enabled = testEnabled(mode.getName());
}
setEnabled(enabled);
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect
/**
* Returns the file selected in the editor.
*
* @return file selected in the editor.
*/
private static FileObject selectedEditorFile() {
WindowManager manager = WindowManager.getDefault();
TopComponent.Registry registry = manager.getRegistry();
TopComponent active = registry.getActivated();
if ((active == null) || !manager.isOpenedEditorTopComponent(active)) {
active = null;
for (Mode mode : manager.getModes()) {
if (manager.isEditorMode(mode)) {
active = mode.getSelectedTopComponent();
if (active != null) {
break;
}
}
}
}
FileObject selectedFile = null;
if (active != null) {
selectedFile = active.getLookup().lookup(FileObject.class);
}
return selectedFile;
}
内容来源于网络,如有侵权,请联系作者删除!