当前位置: 首页>>代码示例>>Java>>正文


Java MultiViewFactory.createUnsafeCloseState方法代码示例

本文整理汇总了Java中org.netbeans.core.spi.multiview.MultiViewFactory.createUnsafeCloseState方法的典型用法代码示例。如果您正苦于以下问题:Java MultiViewFactory.createUnsafeCloseState方法的具体用法?Java MultiViewFactory.createUnsafeCloseState怎么用?Java MultiViewFactory.createUnsafeCloseState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.netbeans.core.spi.multiview.MultiViewFactory的用法示例。


在下文中一共展示了MultiViewFactory.createUnsafeCloseState方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCreateUnsafeCloseState

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
public void testCreateUnsafeCloseState () throws Exception {
    CloseOperationState state = MultiViewFactory.createUnsafeCloseState("ID_UNSAFE", 
                                        MultiViewFactory.NOOP_CLOSE_ACTION, MultiViewFactory.NOOP_CLOSE_ACTION);
    assertNotNull(state);
    assertFalse(state.canClose());
    assertNotNull(state.getDiscardAction());
    assertNotNull(state.getProceedAction());
    assertEquals("ID_UNSAFE", state.getCloseWarningID());
    
    state = MultiViewFactory.createUnsafeCloseState( null, null, null);
    assertNotNull(state);
    assertFalse(state.canClose());
    assertNotNull(state.getDiscardAction());
    assertNotNull(state.getProceedAction());
    assertNotNull(state.getCloseWarningID());
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MultiViewFactoryTest.java

示例2: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
@Override
public CloseOperationState canCloseElement() {
    if (dObj == null || dObj.canClose()) {
        return CloseOperationState.STATE_OK;
    } else if (!this.callback.isSelectedElement()) {
        return CloseOperationState.STATE_OK;
    } else if (!dObj.isModified()) {
        return CloseOperationState.STATE_OK;
    } else {
        boolean differ = false;
        String message = dObj.getEditorSupport().messageSave();
        try {
            String encoding = dObj.encoding();
            differ = dObj.encodingDiffer(encoding);
            if (differ) {
                message += " <b>" + dObj.encodingMessage(encoding) + "</b>";
            }
        } catch (IOException ex) {
            LOGGER.log(Level.INFO, null, ex);
        }
        message = "<html>" + message + "</html>";
        return MultiViewFactory.createUnsafeCloseState(
                message, new SaveAction(differ), new DiscardAction());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:AbstractMultiViewElement.java

示例3: testMultiViewsCreate

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
public void testMultiViewsCreate() {
       TopComponent mvc = MultiViews.createMultiView("text/figaro", new LP(Lookup.EMPTY));
       assertNotNull("MultiViewComponent created", mvc);
       mvc.open();
       mvc.requestActive();
       
       MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
       assertNotNull("Handler found", handler);
       MultiViewPerspective[] arr = handler.getPerspectives();
       assertEquals("Two perspetives found", 2, arr.length);
       assertEquals("Figaro", arr[0].getDisplayName());
       assertEquals("Figaro", arr[1].getDisplayName());
MultiViewDescription description = Accessor.DEFAULT.extractDescription(arr[0]);
assertTrue(description instanceof ContextAwareDescription);
       assertFalse("First one is not for split", ((ContextAwareDescription)description).isSplitDescription());
description = Accessor.DEFAULT.extractDescription(arr[1]);
assertTrue(description instanceof ContextAwareDescription);
       assertTrue("Second one is for split", ((ContextAwareDescription)description).isSplitDescription());

       CloseH.retValue = true;
       MVE.closeState = MultiViewFactory.createUnsafeCloseState("warn", new AbstractAction() {

           @Override
           public void actionPerformed( ActionEvent e ) {
               MVE.closeState = null;
           }
       }, null);
       assertTrue("Closed OK", mvc.close());
       assertNotNull(CloseH.globalElements);
       assertEquals("One handle", 1, CloseH.globalElements.length);
       assertEquals("states are the same", MVE.closeState, CloseH.globalElements[0]);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:MultiViewProcessorTest.java

示例4: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
final CloseOperationState canCloseElement(TopComponent tc) {
    // if this is not the last cloned java editor component, closing is OK
    if (!isLastView(tc)) {
        return CloseOperationState.STATE_OK;
    }

    if (!isModified()) {
        return CloseOperationState.STATE_OK;
    }

    AbstractAction save = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                saveDocument();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    };
    save.putValue(Action.LONG_DESCRIPTION, NbBundle.getMessage(BIEditorSupport.class, "MSG_MODIFIED", getDataObject().getPrimaryFile().getNameExt()));

    // return a placeholder state - to be sure our CloseHandler is called
    return MultiViewFactory.createUnsafeCloseState(
            "ID_BEANINFO_CLOSING", // NOI18N
            save,
            MultiViewFactory.NOOP_CLOSE_ACTION);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:BIEditorSupport.java

示例5: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
public CloseOperationState canCloseElement() {
    try {
        editor.fireVetoableChange(TreePanelDesignEditor.PROPERTY_FLUSH_DATA, this, null);
    } catch (PropertyVetoException e) {
        return MultiViewFactory.createUnsafeCloseState(TreePanelDesignEditor.PROPERTY_FLUSH_DATA, null, null);
    }
    return super.canCloseElement();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:TreePanelMultiViewElement.java

示例6: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
public CloseOperationState canCloseElement() {
    if (!editorValidate()) {
        return MultiViewFactory.createUnsafeCloseState(ToolBarDesignEditor.PROPERTY_FLUSH_DATA, null, null);
    } else {
        return super.canCloseElement();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ToolBarMultiViewElement.java

示例7: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
@Messages({
    "MSG_SaveModified=File {0} is modified. Save?"
})
@Override
public CloseOperationState canCloseElement() {
    final CloneableEditorSupport sup = getLookup().lookup(CloneableEditorSupport.class);
    Enumeration en = getReference().getComponents();
    if (en.hasMoreElements()) {
        en.nextElement();
        if (en.hasMoreElements()) {
            // at least two is OK
            return CloseOperationState.STATE_OK;
        }
    }
    
    PropertiesDataObject dataObject = getDataObject();
    if (dataObject.isModified()) {
        AbstractAction save = new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    sup.saveDocument();
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        };
        save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified(FileUtil.getFileDisplayName(dataObject.getPrimaryFile())));
        return MultiViewFactory.createUnsafeCloseState("editor", save, null);
    } 
    return CloseOperationState.STATE_OK;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:PropertiesEditorSupport.java

示例8: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
@Messages({
     "MSG_SaveModified=File {0} is modified. Save?"
 })
 @Override
 public CloseOperationState canCloseElement() {
     if (sqlEditorSupport().isConsole()) {
         return CloseOperationState.STATE_OK;
     } else {
         DataObject sqlDO = sqlEditorSupport().getDataObject();
         FileObject sqlFO = sqlEditorSupport().getDataObject().getPrimaryFile();
         if (sqlDO.isModified()) {
             if (sqlFO.canWrite()) {
                 Savable sav = sqlDO.getLookup().lookup(Savable.class);
                 if (sav != null) {
                     AbstractAction save = new AbstractAction() {
                         @Override
                         public void actionPerformed(ActionEvent e) {
                             try {
                                 sqlEditorSupport().saveDocument();
                             } catch (IOException ex) {
                                 Exceptions.printStackTrace(ex);
                             }
                         }
                     };
                     save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_SaveModified(sqlFO.getNameExt()));
                     return MultiViewFactory.createUnsafeCloseState("editor", save, null);
                 }
             }
         }
     }
     return CloseOperationState.STATE_OK;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:SQLCloneableEditor.java

示例9: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
@Messages({
    "MSG_MODIFIED=File {0} is modified. Save?"
})
final CloseOperationState canCloseElement(TopComponent tc) {
    // if this is not the last cloned java editor component, closing is OK
    if (!FormEditorSupport.isLastView(tc)) {
        return CloseOperationState.STATE_OK;
    }

    if (!isModified()) {
        return CloseOperationState.STATE_OK;
    }
    
    AbstractAction save = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                saveDocument();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    };
    save.putValue(Action.LONG_DESCRIPTION, Bundle.MSG_MODIFIED(
        getDataObject().getPrimaryFile().getNameExt()
    ));

    // return a placeholder state - to be sure our CloseHandler is called
    return MultiViewFactory.createUnsafeCloseState(
            "ID_FORM_CLOSING", // NOI18N
            save,
            MultiViewFactory.NOOP_CLOSE_ACTION);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:FormEditorSupport.java

示例10: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
public CloseOperationState canCloseElement() {
    if(getEditorSupport().isModified()){
        return MultiViewFactory.createUnsafeCloseState(PREFERRED_ID,
                null,null);
    }
    return CloseOperationState.STATE_OK;
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:8,代码来源:JRTXVisualView.java

示例11: createCompositeState

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
private CloseOperationState createCompositeState(List<CloseOperationState> states) {
    StringBuilder id = new StringBuilder();
    StateAction proceed = new StateAction();
    StateAction discard = new StateAction();
    for(CloseOperationState state : states) {
        if(id.length() > 0)
            id.append(" | ");
        id.append(state.getCloseWarningID());
        
        proceed.actions.add(state.getProceedAction());
        discard.actions.add(state.getDiscardAction());
    }
    
    return MultiViewFactory.createUnsafeCloseState(id.toString(), proceed, discard);
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:16,代码来源:AbstractExpandableContainerHandler.java

示例12: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
@Override
public CloseOperationState canCloseElement() {
    Savable sav = getLookup().lookup(Savable.class);
    if(sav == null)
        return CloseOperationState.STATE_OK;
    
    Action proceed = null;
    Action cancel = null;
    return MultiViewFactory.createUnsafeCloseState("editor", proceed, cancel);
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:11,代码来源:GRScriptEditor.java

示例13: canCloseElement

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
public CloseOperationState canCloseElement() {
    return MultiViewFactory.createUnsafeCloseState("ID", MultiViewFactory.NOOP_CLOSE_ACTION, MultiViewFactory.NOOP_CLOSE_ACTION);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:CloseOperationHandlerTest.java

示例14: testCloneableMultiViewsCreate

import org.netbeans.core.spi.multiview.MultiViewFactory; //导入方法依赖的package包/类
public void testCloneableMultiViewsCreate() {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    
    CloneableTopComponent cmv = MultiViews.createCloneableMultiView("text/context", new LP(lookup));
    assertNotNull("MultiViewComponent created", cmv);
    cmv.open();
    TopComponent mvc = cmv.cloneTopComponent();
    doCheck(mvc, ic);
    
    assertTrue("First component can be closed without any questions", cmv.close());
    
    CntAction accept = new CntAction() {
        @Override
        public void actionPerformed( ActionEvent e ) {
            super.actionPerformed( e );
            MVE.closeState = null;
        }

    };
    CntAction discard = new CntAction();
    CloseH.retValue = false;
    MVE.closeState = MultiViewFactory.createUnsafeCloseState("warn", accept, discard);
    DD.ret = 2;
    mvc.open();
    assertFalse("Closed cancelled", mvc.close());
    assertEquals("No accept", 0, accept.cnt);
    assertEquals("No discard", 0, discard.cnt);
    MVE.closeState = MultiViewFactory.createUnsafeCloseState("warn", accept, discard);
    DD.ret = 1;
    DD.d = null;
    mvc.open();
    assertTrue("Changes discarded, close accepted", mvc.close());
    assertEquals("Still no accept", 0, accept.cnt);
    assertEquals("One discard", 1, discard.cnt);
    MVE.closeState = MultiViewFactory.createUnsafeCloseState("warn", accept, discard);
    DD.ret = 0;
    DD.d = null;
    mvc.open();
    assertTrue("Closed accepted OK", mvc.close());
    assertEquals("Three buttons", 3, DD.d.getOptions().length);
    assertNull("Not called, we use default handler", CloseH.globalElements);
    MVE.closeState = null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:MultiViewProcessorTest.java


注:本文中的org.netbeans.core.spi.multiview.MultiViewFactory.createUnsafeCloseState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。