本文整理汇总了Java中org.netbeans.core.spi.multiview.CloseOperationState类的典型用法代码示例。如果您正苦于以下问题:Java CloseOperationState类的具体用法?Java CloseOperationState怎么用?Java CloseOperationState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloseOperationState类属于org.netbeans.core.spi.multiview包,在下文中一共展示了CloseOperationState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateUnsafeCloseState
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的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());
}
示例2: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的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());
}
}
示例3: resolveCloseOperation
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
public boolean resolveCloseOperation(CloseOperationState[] elements) {
wasUsed = true;
if (supposed != elements.length) {
throw new IllegalStateException("A different number of elements returned. Expected=" + supposed + " but was:" + elements.length);
}
return canClose;
}
示例4: resolveCloseOperation
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
@Override
public boolean resolveCloseOperation(CloseOperationState[] elements) {
assertNull("globalElement not specified yet", globalElements);
assertNotNull("We know what to return", retValue);
boolean r = retValue;
retValue = null;
globalElements = elements;
return r;
}
示例5: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
@Override
public CloseOperationState canCloseElement() {
if (closeState != null) {
return closeState;
}
return CloseOperationState.STATE_OK;
}
示例6: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的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);
}
示例7: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的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();
}
示例8: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
public CloseOperationState canCloseElement() {
if (!editorValidate()) {
return MultiViewFactory.createUnsafeCloseState(ToolBarDesignEditor.PROPERTY_FLUSH_DATA, null, null);
} else {
return super.canCloseElement();
}
}
示例9: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的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;
}
示例10: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的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;
}
示例11: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的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);
}
示例12: resolveCloseOperation
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
public boolean resolveCloseOperation(CloseOperationState[] elements) {
try {
support.getDataObject().setValid(false);
} catch (PropertyVetoException ex) {
return false;
}
System.gc();
return true;
/*
//support.getDataObject().setModified(false);
NotifyDescriptor nd = new NotifyDescriptor.Confirmation(
"Save before closing?");
DialogDisplayer.getDefault().notify(nd);
if (nd.getValue().equals(NotifyDescriptor.YES_OPTION)) {
// Let's consider only the first...
for (CloseOperationState element : elements) {
System.out.println("Executing action procees on element: " + element.getCloseWarningID());
System.out.flush();
element.getProceedAction().actionPerformed(
new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "xxx"));
}
return true;
} else if (nd.getValue().equals(NotifyDescriptor.NO_OPTION)) {
for (CloseOperationState element : elements) {
System.out.println("Executing action procees on element: " + element.getCloseWarningID());
System.out.flush();
element.getDiscardAction().actionPerformed(
new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "xxx"));
}
return true;
} else {
// Cancel
return false;
}
*/
}
示例13: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
public CloseOperationState canCloseElement() {
if(getEditorSupport().isModified()){
return MultiViewFactory.createUnsafeCloseState(PREFERRED_ID,
null,null);
}
return CloseOperationState.STATE_OK;
}
示例14: canCloseElement
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
@Override
public CloseOperationState canCloseElement() {
List<CloseOperationState> states = getInvalidStates();
return states.isEmpty()?
CloseOperationState.STATE_OK :
createCompositeState(states);
}
示例15: getInvalidStates
import org.netbeans.core.spi.multiview.CloseOperationState; //导入依赖的package包/类
private List<CloseOperationState> getInvalidStates() {
List<CloseOperationState> states = new ArrayList<CloseOperationState>(elements.length);
for(ExpandableElementDescription description : elements) {
CloseOperationState state = description.getElement().canCloseElement();
if(CloseOperationState.STATE_OK != state)
states.add(state);
}
return states;
}