Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Violet/VioletProductEclipsePlugin/VioletProduct.eclipse-plugin/trunk/src/com/horstmann/violet/eclipseplugin/actions/PrintAction.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
99 lines (84 sloc)
2.82 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Violet - A program for editing UML diagrams. | |
Copyright (C) 2007 Cay S. Horstmann (http://horstmann.com) | |
Alexandre de Pellegrin (http://alexdp.free.fr); | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation; either version 2 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
*/ | |
package com.horstmann.violet.eclipseplugin.actions; | |
import org.eclipse.jface.action.IAction; | |
import org.eclipse.jface.viewers.ISelection; | |
import org.eclipse.swt.widgets.Shell; | |
import org.eclipse.ui.IEditorActionDelegate; | |
import org.eclipse.ui.IEditorPart; | |
import com.horstmann.violet.eclipseplugin.editors.VioletUMLEditor; | |
import com.horstmann.violet.eclipseplugin.tools.DiagramPrinter; | |
import com.horstmann.violet.workspace.IWorkspace; | |
/** | |
* Eclipse plugin print action | |
* | |
* @author Alexandre de Pellegrin | |
* | |
*/ | |
public class PrintAction implements IEditorActionDelegate | |
{ | |
/* | |
* (non-Javadoc) | |
* | |
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface .action.IAction, org.eclipse.ui.IEditorPart) | |
*/ | |
public void setActiveEditor(IAction action, IEditorPart targetEditor) | |
{ | |
this.setActiveEditor((VioletUMLEditor) targetEditor); | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) | |
*/ | |
public void run(IAction action) | |
{ | |
IWorkspace workspace = this.getActiveEditor().getUMLDiagramPanel(); | |
Shell shell = this.getActiveEditor().getSite().getShell(); | |
DiagramPrinter printer = new DiagramPrinter(workspace, shell); | |
printer.print(); | |
} | |
/* | |
* (non-Javadoc) | |
* | |
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action .IAction, org.eclipse.jface.viewers.ISelection) | |
*/ | |
public void selectionChanged(IAction action, ISelection selection) | |
{ | |
// TODO Auto-generated method stub | |
} | |
/** | |
* @return editor instance | |
*/ | |
private VioletUMLEditor getActiveEditor() | |
{ | |
return activeEditor; | |
} | |
/** | |
* Sets editor instance | |
* | |
* @param activeEditor | |
*/ | |
private void setActiveEditor(VioletUMLEditor activeEditor) | |
{ | |
this.activeEditor = activeEditor; | |
} | |
/** | |
* Editor instance | |
*/ | |
private VioletUMLEditor activeEditor; | |
} |