private void switchPerspective(final String perspectiveId) {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   try {
     workbench.showPerspective(perspectiveId, window);
   } catch (WorkbenchException e) {
     e.printStackTrace();
   }
 }
 void switchPerspective() {
   IPreferenceStore store = DdmsPlugin.getDefault().getPreferenceStore();
   if (store.getBoolean(PreferenceInitializer.ATTR_SWITCH_PERSPECTIVE)) {
     IWorkbench workbench = PlatformUI.getWorkbench();
     IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
     IPerspectiveRegistry perspectiveRegistry = workbench.getPerspectiveRegistry();
     String perspectiveId = store.getString(PreferenceInitializer.ATTR_PERSPECTIVE_ID);
     if (perspectiveId != null
         && perspectiveId.length() > 0
         && perspectiveRegistry.findPerspectiveWithId(perspectiveId) != null) {
       try {
         workbench.showPerspective(perspectiveId, window);
       } catch (WorkbenchException e) {
         e.printStackTrace();
       }
     }
   }
 }
  public void run(final IAction action) {
    if (this.selecteMethod != null) {
      InteractionModelBuilder interactionModelBuilder = new InteractionModelBuilder();
      InteractionModel interactionModel =
          interactionModelBuilder.buildInteractionModel(this.selecteMethod);

      try {
        IWorkbenchWindow dw =
            ModelGoonActivator.getDefault().getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage page = dw.getActivePage();

        String fileName =
            this.selecteMethod.getDeclaringType().getElementName()
                + "#"
                + this.selecteMethod.getElementName();
        IWorkspace workspace = ResourcesPlugin.getWorkspace();

        IFile file =
            this.selecteMethod
                .getCompilationUnit()
                .getResource()
                .getProject()
                .getFile(fileName + ".mgs");
        // file.setHidden(true);
        // if (!file.exists()) {
        // file.create(new ByteArrayInputStream(new byte[] {}), false,
        // null);
        // }

        if (page != null) {
          SequenceDiagramEditor editor = (SequenceDiagramEditor) IDE.openEditor(page, file, true);
          editor.setModel(interactionModel);
        }
      } catch (WorkbenchException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Exemple #4
0
  public static void deSerialize() {
    IPath path = URLWaypointPlugin.getDefault().getStateLocation().append(URL_FILE);
    File mementoFile = path.toFile();

    if (mementoFile.exists()) {
      try {
        FileInputStream input = new FileInputStream(mementoFile);
        BufferedReader reader =
            new BufferedReader(new InputStreamReader(input, "utf-8")); // $NON-NLS-1$
        IMemento memento = XMLMemento.createReadRoot(reader);
        restoreStateFromMemento(memento);
      } catch (FileNotFoundException e) {
        e.printStackTrace();
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      } catch (WorkbenchException e) {
        e.printStackTrace();
      }
    }
  }