本文整理汇总了Java中javax.swing.undo.UndoableEditSupport.beginUpdate方法的典型用法代码示例。如果您正苦于以下问题:Java UndoableEditSupport.beginUpdate方法的具体用法?Java UndoableEditSupport.beginUpdate怎么用?Java UndoableEditSupport.beginUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.undo.UndoableEditSupport
的用法示例。
在下文中一共展示了UndoableEditSupport.beginUpdate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cut
import javax.swing.undo.UndoableEditSupport; //导入方法依赖的package包/类
/**
* Deletes items and post a cut operation to undo support.
*/
public void cut(List<? extends Selectable> items)
{
// Start a compound edit that deletes items and changes presentation name
UndoableEditSupport undoSupport = getUndoableEditSupport();
undoSupport.beginUpdate();
getPlanController().deleteItems(items);
// Add a undoable edit to change presentation name
undoSupport.postEdit(new AbstractUndoableEdit()
{
@Override
public String getPresentationName()
{
return preferences.getLocalizedString(HomeController.class, "undoCutName");
}
});
// End compound edit
undoSupport.endUpdate();
}
示例2: pasteToGroup
import javax.swing.undo.UndoableEditSupport; //导入方法依赖的package包/类
/**
* Paste the furniture in clipboard to the selected group in home.
* @since 5.0
*/
public void pasteToGroup()
{
// Start a compound edit that adds furniture
UndoableEditSupport undoSupport = getUndoableEditSupport();
undoSupport.beginUpdate();
List<HomePieceOfFurniture> addedFurniture = Home.getFurnitureSubList(getView().getClipboardItems());
adjustFurnitureSizeAndElevation(addedFurniture, true);
getFurnitureController().addFurnitureToGroup(addedFurniture,
(HomeFurnitureGroup) this.home.getSelectedItems().get(0));
undoSupport.postEdit(new AbstractUndoableEdit()
{
@Override
public String getPresentationName()
{
return preferences.getLocalizedString(HomeController.class, "undoPasteToGroupName");
}
});
// End compound edit
undoSupport.endUpdate();
}
示例3: addPastedItems
import javax.swing.undo.UndoableEditSupport; //导入方法依赖的package包/类
/**
* Adds items to home.
*/
private void addPastedItems(final List<? extends Selectable> items, float dx, float dy,
final boolean isDropInPlanView, final String presentationNameKey)
{
if (items.size() > 1 || (items.size() == 1 && !(items.get(0) instanceof Compass)))
{
// Always use selection mode after a drop or a paste operation
getPlanController().setMode(PlanController.Mode.SELECTION);
// Start a compound edit that adds walls, furniture, rooms, dimension lines, polylines and labels to home
UndoableEditSupport undoSupport = getUndoableEditSupport();
undoSupport.beginUpdate();
List<HomePieceOfFurniture> addedFurniture = Home.getFurnitureSubList(items);
adjustFurnitureSizeAndElevation(addedFurniture, dx == 0 && dy == 0);
getPlanController().moveItems(items, dx, dy);
if (isDropInPlanView && this.preferences.isMagnetismEnabled() && items.size() == 1
&& addedFurniture.size() == 1)
{
// Adjust piece when it's dropped in plan view
getPlanController().adjustMagnetizedPieceOfFurniture((HomePieceOfFurniture) items.get(0), dx, dy);
}
getPlanController().addItems(items);
undoSupport.postEdit(new AbstractUndoableEdit()
{
@Override
public String getPresentationName()
{
return preferences.getLocalizedString(HomeController.class, presentationNameKey);
}
});
// End compound edit
undoSupport.endUpdate();
}
}
示例4: dropFiles
import javax.swing.undo.UndoableEditSupport; //导入方法依赖的package包/类
/**
* Adds imported models to home, moves them of (dx, dy)
* and post a drop operation to undo support.
*/
public void dropFiles(final List<String> importableModels, float dx, float dy)
{
// Always use selection mode after a drop operation
getPlanController().setMode(PlanController.Mode.SELECTION);
// Add to home a listener to track imported furniture
final List<HomePieceOfFurniture> importedFurniture = new ArrayList<HomePieceOfFurniture>(
importableModels.size());
CollectionListener<HomePieceOfFurniture> addedFurnitureListener = new CollectionListener<HomePieceOfFurniture>()
{
public void collectionChanged(CollectionEvent<HomePieceOfFurniture> ev)
{
importedFurniture.add(ev.getItem());
}
};
this.home.addFurnitureListener(addedFurnitureListener);
// Start a compound edit that adds furniture to home
UndoableEditSupport undoSupport = getUndoableEditSupport();
undoSupport.beginUpdate();
// Import furniture
for (String model : importableModels)
{
getFurnitureController().importFurniture(model);
}
this.home.removeFurnitureListener(addedFurnitureListener);
if (importedFurniture.size() > 0)
{
getPlanController().moveItems(importedFurniture, dx, dy);
this.home.setSelectedItems(importedFurniture);
// Add a undoable edit that will select the imported furniture at redo
undoSupport.postEdit(new AbstractUndoableEdit()
{
@Override
public void redo() throws CannotRedoException
{
super.redo();
home.setSelectedItems(importedFurniture);
}
@Override
public String getPresentationName()
{
return preferences.getLocalizedString(HomeController.class, "undoDropName");
}
});
}
// End compound edit
undoSupport.endUpdate();
}