u.p(ex);
}
}
public DocContext setupNewDoc(DocModeHelper modeHelper, final CanvasDocument origDoc) throws Exception {
final DocContext context = modeHelper.createDocContext(this);
contexts.add(context);
CanvasDocument doc = origDoc;
//create a new doc if one wasn't passed in
if(doc == null) {
doc = modeHelper.createNewDoc();
}
context.setupActions();
context.setupPalettes();
context.stackPanel = new StackPanel();
ScrollPane scrollPane = new ScrollPane(
context.getCanvas()
.setWidth(300)
.setHeight(300)
);
final Ruler hruler = new Ruler(false,scrollPane,context);
final Ruler vruler = new Ruler(true,scrollPane,context);
final CanvasDocument fdoc = doc;
context.stackPanel.add(
new Panel() {
@Override
public void doLayout() {
hruler.setVisible(fdoc.isRulersVisible());
vruler.setVisible(fdoc.isRulersVisible());
super.doLayout();
for(Control c : controlChildren()) {
if(c == hruler && fdoc.isRulersVisible()) {
c.setWidth(getWidth()-30);
c.setHeight(30);
c.setTranslateX(30);
c.setTranslateY(0);
}
if(c == vruler && fdoc.isRulersVisible()) {
c.setWidth(30);
c.setHeight(getHeight()-30);
c.setTranslateX(0);
c.setTranslateY(30);
}
if(c instanceof ScrollPane) {
if(fdoc.isRulersVisible()) {
c.setWidth(getWidth()-30);
c.setHeight(getHeight()-30);
c.setTranslateX(30);
c.setTranslateY(30);
} else {
c.setWidth(getWidth()-0);
c.setHeight(getHeight()-0);
c.setTranslateX(0);
c.setTranslateY(0);
}
}
if(c == context.getNotificationIndicator()) {
c.setTranslateX(40);
c.setTranslateY(getHeight()-c.getHeight()-25);
}
c.doLayout();
}
}
}
.add(hruler,vruler)
.add(scrollPane)
.add(context.getNotificationIndicator())
);
if(context instanceof VectorDocContext) {
context.pageList = new PageListPanel((VectorDocContext)context);
}
context.setupTools();
context.setupSidebar();
setupStage(context, modeHelper);
context.setDocument(doc);
hruler.setDocument(doc);
vruler.setDocument(doc);
context.getStage().setTitle(context.getDocument().getTitle());
if(modeHelper.isPageListVisible()) {
context.mainPanel.add(context.pageList);
}
if(context.pageMenu != null) {
context.menubar.remove(context.pageMenu);
}
context.pageMenu = modeHelper.buildPageMenu(context);
if(context.pageMenu != null) {
context.menubar.add(context.pageMenu);
}
rebuildWindowMenu();
//focus on the canvas
Core.getShared().getFocusManager().setFocusedNode(context.getCanvas());
return context;
}