Example #1
0
 public void selectionChanged(IWorkbenchPart part, ISelection selection) {
   super.selectionChanged(part, selection);
   if (selection instanceof IStructuredSelection) {
     openPropertyAction.update((IStructuredSelection) selection);
     openOutlineAction.update((IStructuredSelection) selection);
     saveAsImageAction.update((IStructuredSelection) selection);
     updateDiagramAction(selection);
   }
 }
Example #2
0
 public void commandStackChanged(EventObject event) {
   if (isDirty()) {
     if (!savePreviouslyNeeded()) {
       setSavePreviouslyNeeded(true);
       firePropertyChange(IEditorPart.PROP_DIRTY);
     }
   } else {
     setSavePreviouslyNeeded(false);
     firePropertyChange(IEditorPart.PROP_DIRTY);
   }
   super.commandStackChanged(event);
 }
Example #3
0
 protected void setInput(IEditorInput input) {
   super.setInput(input);
   setPartName(input.getName());
 }
Example #4
0
 public void dispose() {
   UMLPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
   ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
   super.dispose();
 }
Example #5
0
  protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(createEditPartFactory());

    ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
    viewer.setRootEditPart(rootEditPart);

    // ZoomManagerの取得
    ZoomManager manager = rootEditPart.getZoomManager();

    // ズームレベルの設定
    double[] zoomLevels =
        new double[] {0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0};
    manager.setZoomLevels(zoomLevels);

    // ズーム レベル コントリビューションの設定
    ArrayList<String> zoomContributions = new ArrayList<String>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);
    // 拡大アクションの作成と登録
    getActionRegistry().registerAction(new ZoomInAction(manager));
    // 縮小アクションの作成と登録
    getActionRegistry().registerAction(new ZoomOutAction(manager));

    getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer()));

    // コンテクストメニューの作成
    String menuId = this.getClass().getName() + ".EditorContext";

    MenuManager menuMgr = new MenuManager(menuId, menuId);
    openPropertyAction = new OpenPropertyViewAction(viewer);
    openOutlineAction = new OpenOutlineViewAction(viewer);
    saveAsImageAction = new SaveAsImageAction(viewer);
    copyAsImageAction = new CopyAsImageAction(viewer);
    createDiagramAction(viewer);

    getSite().registerContextMenu(menuId, menuMgr, viewer);

    PrintAction printAction = new PrintAction(this);
    printAction.setImageDescriptor(UMLPlugin.getImageDescriptor("icons/print.gif"));
    getActionRegistry().registerAction(printAction);

    final DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) this);
    deleteAction.setSelectionProvider(getGraphicalViewer());
    getActionRegistry().registerAction(deleteAction);
    viewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          public void selectionChanged(SelectionChangedEvent event) {
            deleteAction.update();
          }
        });

    // Actions
    //		IAction showRulers = new ToggleRulerVisibilityAction(getGraphicalViewer());
    //		getActionRegistry().registerAction(showRulers);
    //
    //		IAction snapAction = new ToggleSnapToGeometryAction(getGraphicalViewer());
    //		getActionRegistry().registerAction(snapAction);
    //
    //		IAction showGrid = new ToggleGridAction(getGraphicalViewer());
    //		getActionRegistry().registerAction(showGrid);

    menuMgr.add(new Separator("edit"));
    menuMgr.add(getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    menuMgr.add(getActionRegistry().getAction(ActionFactory.UNDO.getId()));
    menuMgr.add(getActionRegistry().getAction(ActionFactory.REDO.getId()));
    //		menuMgr.add(getActionRegistry().getAction(ActionFactory.COPY.getId()));
    //		menuMgr.add(getActionRegistry().getAction(ActionFactory.PASTE.getId()));
    menuMgr.add(new Separator("zoom"));
    menuMgr.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    menuMgr.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
    fillDiagramPopupMenu(menuMgr);
    menuMgr.add(new Separator("print"));
    menuMgr.add(saveAsImageAction);
    menuMgr.add(copyAsImageAction);
    menuMgr.add(printAction);
    menuMgr.add(new Separator("views"));
    menuMgr.add(openPropertyAction);
    menuMgr.add(openOutlineAction);
    menuMgr.add(new Separator("generate"));
    menuMgr.add(new Separator("additions"));
    viewer.setContextMenu(menuMgr);
    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
  }