/* * Created on Aug 16, 2004 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package CELLDEV.buttons; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.runtime.IPath; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; import CDBuilder.console.ConsoleDocument; /** * @author ali monadi * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class Drawlog3DAction extends Action implements IWorkbenchWindowActionDelegate{ public void dispose() { } public void init(IWorkbenchWindow window) { } public void run(IAction action) { try { //shows console view PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("ConsoleView"); ConsoleDocument cdos = ConsoleDocument.getCDOS(); //get active page IWorkspaceRoot root = (IWorkspaceRoot)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getInput(); //get path of project IPath projectPath = root.getLocation(); // get path of internal folder IPath internalPath = root.getLocation().removeLastSegments(1); internalPath = internalPath.append("/plugins/CD++Builder_1.1.0/internal/"); String selectPath = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(IPageLayout.ID_RES_NAV).toString(); selectPath = selectPath.substring(selectPath.indexOf("/")+1, selectPath.length()-1); //concatenate the string to get rid of [] projectPath = projectPath.append(selectPath +"/"); IContainer container = root.getContainerForLocation(projectPath); //check if project is not empty IFile files = root.getFileForLocation(projectPath); if (files != null) { if (files.exists()){ projectPath = projectPath.removeLastSegments(1); //get ride of the last segment of the path name (file name) projectPath = projectPath.append("/"); //add a / in the path } container = root.getContainerForLocation(projectPath); } container.refreshLocal(1, null); cdos.clear(); //open panel Shell parent=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); Drawlog3DGUI dlgDialog = new Drawlog3DGUI(parent,internalPath, projectPath); dlgDialog.create(); dlgDialog.open(); dlgDialog.close(); } catch (Exception e) { MessageBox npGui = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK); npGui.setMessage("You must select a file or project folder to start simulations! "); npGui.setText("Project Not Selected"); npGui.open(); ConsoleDocument.getCDOS().set("Please select a project or folder from the navigator."); } } public void selectionChanged(IAction action, ISelection selection) { } }