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


Java UndoRedo类代码示例

本文整理汇总了Java中org.openide.awt.UndoRedo的典型用法代码示例。如果您正苦于以下问题:Java UndoRedo类的具体用法?Java UndoRedo怎么用?Java UndoRedo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testGetUndoRedo

import org.openide.awt.UndoRedo; //导入依赖的package包/类
public void testGetUndoRedo() throws Exception {
    final MVElem elem1 = new MVElem(new Action[] {new Act1("act1")} );
    UndoRedo redo = new UndoRedo.Empty();
    elem1.setUndoRedo(redo);
    final MVElem elem2 = new MVElem(new Action[] {new Act1("act2")} );
    MultiViewDescription desc1 = new MVDesc("desc1", null, 0, elem1);
    MultiViewDescription desc2 = new MVDesc("desc2", null, 0, elem2);
    MultiViewDescription[] descs = new MultiViewDescription[] { desc1, desc2 };
    TopComponent tc = callFactory(descs, desc2);
    
    tc.open();
    UndoRedo result = tc.getUndoRedo();
    MultiViewHandler hand = MultiViews.findMultiViewHandler(tc);
    
    assertNotNull(result);
    assertTrue(redo != result);
    
    hand.requestActive(Accessor.DEFAULT.createPerspective(desc1));
    result = tc.getUndoRedo();
    assertFalse(redo.canRedo());
    assertFalse(redo.canUndo());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:AbstractMultiViewTopComponentTestCase.java

示例2: getEditToBeUndoneRedoneOfType

import org.openide.awt.UndoRedo; //导入依赖的package包/类
private static <T extends UndoableEdit> T getEditToBeUndoneRedoneOfType(EditorCookie ec, Class<T> type, boolean redone) {
    UndoRedo ur;
    if (ec instanceof CloneableEditorSupport &&
            ((ur = ((CloneableEditorSupport)ec).getUndoRedo()) instanceof UndoRedoManager))
    {
        UndoRedoManager urManager = (UndoRedoManager) ur;
        UndoableEdit edit = urManager.editToBeUndoneRedone(redone);
        if (type.isInstance(edit)) {
            return type.cast(edit);
        } else if (edit instanceof List) {
            @SuppressWarnings("unchecked")
            List<UndoableEdit> listEdit = (List<UndoableEdit>) edit;
            for (int i = listEdit.size() -1; i >= 0; i--) { // Go from most wrapped back
                edit = listEdit.get(i);
                if (type.isInstance(edit)) {
                    @SuppressWarnings("unchecked") T inst = (T) edit;
                    return inst;
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:NbDocument.java

示例3: getUndoRedo

import org.openide.awt.UndoRedo; //导入依赖的package包/类
/**
     * Gets the undo redo manager.
     * @return the manager
     */
    protected final synchronized UndoRedo.Manager getUndoRedo() {
        CloneableEditorSupport redirect = CloneableEditorSupportRedirector.findRedirect(this);
        if (redirect != null) {
            return redirect.getUndoRedo();
        }
        
        if (undoRedo == null) {
            UndoRedo.Manager mgr = createUndoRedoManager();
//            if (!(mgr instanceof UndoRedoManager)) {
//                ERR.info("createUndoRedoManager(): ignoring created instance of class " + // NOI18N
//                        mgr.getClass() + " since CloneableEditorSupport requires instance of " + // NOI18N"
//                        UndoRedoManager.class.getName() + "\n"); // NOI18N
//                mgr = new UndoRedoManager(this);
//            }
            undoRedo = mgr;
        }

        return undoRedo;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:CloneableEditorSupport.java

示例4: flushUndoQueue

import org.openide.awt.UndoRedo; //导入依赖的package包/类
static void flushUndoQueue(Document d) {
    SwingUtilities.invokeLater(() -> {
    if (d == null) {
        return;
    }
    for (TopComponent tc : TopComponent.getRegistry().getOpened()) {
        if (!(tc instanceof ConsoleEditor)) {
            continue;
        }
        ConsoleEditor cake = (ConsoleEditor)tc;
        if (cake.getEditorPane() == null) {
            continue;
        }
        Document check = cake.getEditorPane().getDocument();
        if (check != d) {
            continue;
        }
        UndoRedo ur = tc.getUndoRedo();
        if (ur instanceof UndoManager) {
            ((UndoManager)ur).discardAllEdits();
        }
    }});
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:OverrideEditorActions.java

示例5: getNextUndo

import org.openide.awt.UndoRedo; //导入依赖的package包/类
/** Gets manager which undo edit comes to play.*/
private UndoRedo getNextUndo() {
    UndoRedo chosenManager = null;
    long time = 0L; // time to compare with
    long timeManager; // time of next undo of actual manager
    
    for (Iterator<Manager> it = managers.iterator(); it.hasNext(); ) {
        PropertiesEditorSupport.UndoRedoStampFlagManager manager = (PropertiesEditorSupport.UndoRedoStampFlagManager)it.next();
        timeManager = manager.getTimeStampOfEditToBeUndone();
        if(timeManager > time) {
            time = timeManager;
            chosenManager = manager;
        }
    }
    return chosenManager;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PropertiesOpen.java

示例6: getNextRedo

import org.openide.awt.UndoRedo; //导入依赖的package包/类
/** Gets manager which redo edit comes to play.*/
private UndoRedo getNextRedo() {
    UndoRedo chosenManager = null;
    long time = 0L; // time to compare with
    long timeManager; // time of next redo of actual manager
    
    for (Iterator<Manager> it = managers.iterator(); it.hasNext(); ) {
        PropertiesEditorSupport.UndoRedoStampFlagManager manager = (PropertiesEditorSupport.UndoRedoStampFlagManager)it.next();
        timeManager = manager.getTimeStampOfEditToBeRedone();
        if(timeManager > time) {
            time = timeManager;
            chosenManager = manager;
        }
    }
    return chosenManager;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PropertiesOpen.java

示例7: run

import org.openide.awt.UndoRedo; //导入依赖的package包/类
@Override
public void run() {
    if (!EventQueue.isDispatchThread()) {
        EventQueue.invokeLater(this);
        return;
    }

    UndoRedo ur = getUndoRedo();
    last.removeChangeListener(weakCL);

    if (doUndo) {
        setEnabled(ur.canUndo());
    } else {
        setEnabled(ur.canRedo());
    }
    putValue(NAME, getName());
    
    last = ur;
    last.addChangeListener(weakCL);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:UndoRedoAction.java

示例8: getUndoRedo

import org.openide.awt.UndoRedo; //导入依赖的package包/类
private UndoRedo getUndoRedo() {
    assert EventQueue.isDispatchThread();
    for (UndoRedo.Provider provider : result.allInstances()) {
        UndoRedo ur = provider.getUndoRedo();
        if (ur != null) {
            return ur;
        }
    }

    if (fallback) {
        TopComponent el = WindowManager.getDefault().getRegistry().getActivated();
        if (el != null) {
            UndoRedo ur = el.getUndoRedo();
            if (ur != null) {
                return ur;
            }
        }
    }
    return UndoRedo.NONE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:UndoRedoAction.java

示例9: updateStatus

import org.openide.awt.UndoRedo; //导入依赖的package包/类
/** Update status of action.
*/
static synchronized void updateStatus() {
    if (undoAction == null) {
        undoAction = findObject (UndoAction.class, false);
    }

    if (redoAction == null) {
        redoAction = findObject (RedoAction.class, false);
    }

    SwingUtilities.invokeLater(
        new Runnable() {
            public void run() {
                UndoRedo ur = getUndoRedo();

                if (undoAction != null) {
                    undoAction.setEnabled(ur.canUndo());
                }

                if (redoAction != null) {
                    redoAction.setEnabled(ur.canRedo());
                }
            }
        }
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:UndoAction.java

示例10: createUndoTask

import org.openide.awt.UndoRedo; //导入依赖的package包/类
/** Creates <code>Runnable</code> which tries to make one undo. Helper method.
 * @see #revertUpcomingUndo */
private Runnable createUndoTask() {
    return new Runnable() {
        public void run() {
            StyledDocument sd = doc;
            if(sd == null) {
                // #20883, doc can be null(!), doCloseDocument was faster.
                return;
            }
            UndoRedo ur = getUndoRedo();
            sd.removeDocumentListener(getListener());
            try {
                if(ur.canUndo()) {
                    Toolkit.getDefaultToolkit().beep();
                    ur.undo();
                }
            } catch(CannotUndoException cne) {
                ErrorManager.getDefault().notify(
                    ErrorManager.INFORMATIONAL, cne);
            } finally {
                sd.addDocumentListener(getListener());
            }
        }
    };
}
 
开发者ID:CharlesSkelton,项目名称:studio,代码行数:27,代码来源:CloneableEditorSupport.java

示例11: createDefaultVectorDataNode

import org.openide.awt.UndoRedo; //导入依赖的package包/类
public static VectorDataNode createDefaultVectorDataNode(Product product, String name, String description) {
    CoordinateReferenceSystem modelCrs = product.getSceneCRS();
    SimpleFeatureType type = PlainFeatureFactory.createDefaultFeatureType(modelCrs);
    VectorDataNode vectorDataNode = new VectorDataNode(name, type);
    vectorDataNode.setDescription(description);
    product.getVectorDataGroup().add(vectorDataNode);
    vectorDataNode.getPlacemarkGroup();
    String oldLayerId = selectVectorDataLayer(vectorDataNode);

    UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product);
    if (undoManager != null) {
        undoManager.addEdit(new UndoableVectorDataNodeInsertion(product, vectorDataNode, oldLayerId));
    }

    return vectorDataNode;
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:17,代码来源:CreateVectorDataNodeAction.java

示例12: newPin

import org.openide.awt.UndoRedo; //导入依赖的package包/类
void newPin() {
    Guardian.assertNotNull("product", product);
    String[] uniquePinNameAndLabel = PlacemarkNameFactory.createUniqueNameAndLabel(placemarkDescriptor, product);
    Placemark newPlacemark = Placemark.createPointPlacemark(placemarkDescriptor, uniquePinNameAndLabel[0],
                                                            uniquePinNameAndLabel[1],
                                                            "",
                                                            new PixelPos(0, 0), null,
                                                            product.getSceneGeoCoding());
    if (PlacemarkDialog.showEditPlacemarkDialog(
            SwingUtilities.getWindowAncestor(this), product, newPlacemark, placemarkDescriptor)) {
        makePlacemarkNameUnique(newPlacemark);
        UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product);
        if (undoManager != null) {
            undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkInsertion(product, newPlacemark, placemarkDescriptor));
        }
        updateUIState();
    }
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:19,代码来源:PlacemarkManagerTopComponent.java

示例13: copyActivePlacemark

import org.openide.awt.UndoRedo; //导入依赖的package包/类
void copyActivePlacemark() {
    Guardian.assertNotNull("product", product);
    Placemark activePlacemark = getSelectedPlacemark();
    Guardian.assertNotNull("activePlacemark", activePlacemark);
    Placemark newPlacemark = Placemark.createPointPlacemark(activePlacemark.getDescriptor(),
                                                            "copy_of_" + activePlacemark.getName(),
                                                            activePlacemark.getLabel(),
                                                            activePlacemark.getDescription(),
                                                            activePlacemark.getPixelPos(),
                                                            activePlacemark.getGeoPos(),
                                                            activePlacemark.getProduct().getSceneGeoCoding());
    newPlacemark.setStyleCss(activePlacemark.getStyleCss());
    if (PlacemarkDialog.showEditPlacemarkDialog(
            SwingUtilities.getWindowAncestor(this), product, newPlacemark, placemarkDescriptor)) {
        makePlacemarkNameUnique(newPlacemark);
        UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product);
        if (undoManager != null) {
            undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkCopying(product, newPlacemark, placemarkDescriptor));
        }
        updateUIState();
    }
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:23,代码来源:PlacemarkManagerTopComponent.java

示例14: editActivePin

import org.openide.awt.UndoRedo; //导入依赖的package包/类
void editActivePin() {
    Guardian.assertNotNull("product", product);
    Placemark activePlacemark = getSelectedPlacemark();
    Placemark originalPlacemark = Placemark.createPointPlacemark(activePlacemark.getDescriptor(),
                                                                 activePlacemark.getName(),
                                                                 activePlacemark.getLabel(),
                                                                 activePlacemark.getDescription(),
                                                                 activePlacemark.getPixelPos(),
                                                                 activePlacemark.getGeoPos(),
                                                                 activePlacemark.getProduct().getSceneGeoCoding());
    Guardian.assertNotNull("activePlacemark", activePlacemark);
    if (PlacemarkDialog.showEditPlacemarkDialog(SwingUtilities.getWindowAncestor(this), product, activePlacemark,
                                                placemarkDescriptor)) {
        makePlacemarkNameUnique(activePlacemark);
        UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product);
        if (undoManager != null) {
            undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkEditing(product, originalPlacemark, activePlacemark, placemarkDescriptor));
        }
        updateUIState();
    }
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:22,代码来源:PlacemarkManagerTopComponent.java

示例15: removeSelectedPins

import org.openide.awt.UndoRedo; //导入依赖的package包/类
void removeSelectedPins() {
    final List<Placemark> placemarks = getSelectedPlacemarks();
    for (Placemark placemark : placemarks) {
        getPlacemarkGroup(product).remove(placemark);
    }
    int selectedRow = placemarkTable.getSelectedRow();
    if (selectedRow >= getPlacemarkGroup(product).getNodeCount()) {
        selectedRow = getPlacemarkGroup(product).getNodeCount() - 1;
    }
    if (selectedRow >= 0) {
        placemarkTable.getSelectionModel().setSelectionInterval(selectedRow, selectedRow);
    }
    UndoRedo.Manager undoManager = SnapApp.getDefault().getUndoManager(product);
    if (undoManager != null) {
        undoManager.addEdit(UndoablePlacemarkActionFactory.createUndoablePlacemarkRemoval(product, placemarks, placemarkDescriptor));
    }
    updateUIState();
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:19,代码来源:PlacemarkManagerTopComponent.java


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