Package com.ktu.fd2.uml

Examples of com.ktu.fd2.uml.FileLibrary


      if (!diagramsList.getDiagrams().isEmpty())
        return diagramsList.getDiagrams().toArray(parents);

    } else if (parentElement instanceof Diagram) {
      Diagram diag = (Diagram) parentElement;
      Object[] childs = new Object[diag.getDiagramAssociations()
          .getElements().size()];

      if (!diag.getDiagramAssociations().getElements().isEmpty())
        return diag.getDiagramAssociations().getElements().toArray(
            childs);
    }
//    } else if (parentElement instanceof AssociatedElement){
//      ArrayList<Object> mandatoryElements = ((AssociatedElement)parentElement).getMandatoryRelations();
//      ArrayList<Object> optionalElements = ((AssociatedElement)parentElement).getOptionalRelations();
View Full Code Here


  /*
   * Paima diagramos konfiguracija ir jai sukuria nauja .uml faila.
   */
  public static void CreateUmlFromFeatureConfiguration(Diagram diagram){
   
    DiagramAssociation diagramAssociation = diagram.getDiagramAssociations();
   
    //DiagramImpl fdDiagram = (DiagramImpl) ReadFile(diagram.getFeaturePath());
    //fd2.Diagram fdModel = (fd2.Diagram) ReadFile(diagram.getFeaturePath().replace("_diagram", ""));
   
    org.eclipse.uml2.uml.Package uml = (org.eclipse.uml2.uml.Package) ReadFile(diagram.getClassPath().replace("class", ""));
   
    ArrayList<AssociatedElement> associatedElements = diagramAssociation.getElements();
   
    for (AssociatedElement association : associatedElements){
      String classElement = association.getClassElement();
      //String fdElement = association.getFeatureElement();
      boolean include = association.isChecked();
View Full Code Here

 
  @Override
  public Object[] getChildren(Object parentElement) {
   
    if(parentElement instanceof DiagramList){
      DiagramList diagramsList = (DiagramList) parentElement;
      Object[] parents = new Object[diagramsList.getDiagrams().size()];

      if (!diagramsList.getDiagrams().isEmpty())
        return diagramsList.getDiagrams().toArray(parents);

    } else if (parentElement instanceof Diagram) {
      Diagram diag = (Diagram) parentElement;
      Object[] childs = new Object[diag.getDiagramAssociations()
          .getElements().size()];
View Full Code Here

  }

  @Override
  public Object getParent(Object element) {
   
    DiagramList DL = FdToUml.getInstance().getDiagramsObj();
   
    if(element instanceof Diagram){
     
      for(Diagram DG : DL.getDiagrams()){
        if(DG.equals(element)) return DL;
      }
      //return this._fd2uml.getDiagramsObj().getDiagrams();
    } else if(element instanceof AssociatedElement){
      for(Diagram DG : DL.getDiagrams()){
        for(AssociatedElement AE : DG.getDiagramAssociations().getElements())
          if(AE.equals(element)) return DG;
      }
    }
View Full Code Here

              && fileName.contains(FileLibrary.ASSOC_EXT)) {

            try {
             

              DiagramList DL = DiagramListFileHelper
                  .read(fileName);
             
              fd2uml.setDiagramsObj(DL);

              fd2uml.setCurrentDiagramId(DL.getDiagrams().get(0)
                  .getID());
             
              FdToUml.refreshConfigurationElementsDataFromDiagram();
             
              tree.getTree().removeAll();
              tree.setInput(DL);
              tree.refresh();
             
              FdToUml.setCurrentConfigurationFile(fileName);

              if (!DL.isEmpty())
                for (Diagram diagram : DL.getDiagrams()) {
                  if (!diagram.getDiagramAssociations()
                      .getElements().isEmpty())
                    for (AssociatedElement element : diagram
                        .getDiagramAssociations()
                        .getElements()) {
View Full Code Here

    this.saveAs = new Action("Save As...") {

      public void run() {

        FdToUml fd2uml = FdToUml.getInstance();

        try {
         
          FileDialog FDialog = new FileDialog(FileLibrary.getShell(),
              SWT.SAVE);
         
          FDialog.setFilterPath(FileLibrary.getActiveProject()
              .getLocation().toOSString()); // Current project path
          FDialog.setFilterExtensions(new String[] { "*"+FileLibrary.ASSOC_EXT });
         
          String fileName = FDialog.open();
         
          if(fileName != null){
            DiagramListFileHelper.write(fd2uml.getDiagramsObj(),
                fileName);
           
            FdToUml.setCurrentConfigurationFile(fileName);
          }
          try {
            FileLibrary.getActiveProject().refreshLocal(1, null);
          } catch (CoreException e) {

          }
        } catch (Exception e) {
          e.printStackTrace();
        }

      }
    };

    this.saveAs.setImageDescriptor(FileLibrary
            .getFile("SaveAs.gif"));

    this.save = new Action("Save") {

      public void run() {

        FdToUml fd2uml = FdToUml.getInstance();

        try {
         
          if(!FdToUml.getCurrentConfigurationFile().isEmpty()){
            DiagramListFileHelper.write(fd2uml.getDiagramsObj(),
                FdToUml.getCurrentConfigurationFile());
          } else {
            FileDialog FDialog = new FileDialog(FileLibrary.getShell(),
                SWT.SAVE);
           
            FDialog.setFilterPath(FileLibrary.getActiveProject()
                .getLocation().toOSString()); // Current project path
            FDialog.setFilterExtensions(new String[] { "*"+FileLibrary.ASSOC_EXT });
           
            String fileName = FDialog.open();
           
            if(fileName != null){
              DiagramListFileHelper.write(fd2uml.getDiagramsObj(),
                  fileName);
             
              FdToUml.setCurrentConfigurationFile(fileName);
            }           
          }
          try {
            FileLibrary.getActiveProject().refreshLocal(1, null);
          } catch (CoreException e) {

          }
        } catch (Exception e) {
          e.printStackTrace();
        }

      }
    };

    this.save.setImageDescriptor(FileLibrary
        .getFile("save.gif"));
   
    this.load = new Action("Load") {
      public void run() {

        if (FileLibrary.getActiveProject() != null) {

          FdToUml fd2uml = FdToUml.getInstance();

          FileDialog FDialog = new FileDialog(FileLibrary.getShell(),
              SWT.OPEN);

          FDialog.setFilterPath(FileLibrary.getActiveProject()
              .getLocation().toOSString()); // Current project
                              // path
          FDialog.setFilterExtensions(new String[] { "*"
              + FileLibrary.ASSOC_EXT });

          String fileName = FDialog.open();

          if (fileName != null
              && fileName.contains(FileLibrary.ASSOC_EXT)) {

            try {
             

              DiagramList DL = DiagramListFileHelper
                  .read(fileName);
             
              fd2uml.setDiagramsObj(DL);

              fd2uml.setCurrentDiagramId(DL.getDiagrams().get(0)
                  .getID());
             
              FdToUml.refreshConfigurationElementsDataFromDiagram();
             
              tree.getTree().removeAll();
              tree.setInput(DL);
              tree.refresh();
             
              FdToUml.setCurrentConfigurationFile(fileName);

              if (!DL.isEmpty())
                for (Diagram diagram : DL.getDiagrams()) {
                  if (!diagram.getDiagramAssociations()
                      .getElements().isEmpty())
                    for (AssociatedElement element : diagram
                        .getDiagramAssociations()
                        .getElements()) {

                      tree.setChecked(element, element
                          .isChecked());
                    }
                }

              tree.expandAll();
            } catch (Exception e) {
              MessageDialog
              .openError(FileLibrary.getShell(),
                  "File Read Error",
                  "Invalid data in configuration file '"+FileLibrary.getFileName(fileName)+"'!");
           
              //e.printStackTrace();
            }
          }
        } else {
          MessageDialog
          .openInformation(FileLibrary.getShell(),
              "Open Configuration",
              "Please open atleast one FD diagram to load configuration.");
        }
      }
    };

    this.load.setImageDescriptor(FileLibrary.getFile("load.gif"));

    this.selectAllAction = new Action("Slelect All Diagrams") {
      public void run() {

        FdToUml fd2uml = FdToUml.getInstance();

        for (Diagram DG : fd2uml.getDiagramsObj().getDiagrams()) {
          tree.setChecked(DG, true);
        }
      }
    };

    this.selectAllAction.setImageDescriptor(FileLibrary
            .getFile("SelectAll.gif"));

    this.deSelectAllAction = new Action("Select None Diagrams") {
      public void run() {
        FdToUml fd2uml = FdToUml.getInstance();

        for (Diagram DG : fd2uml.getDiagramsObj().getDiagrams()) {
          tree.setChecked(DG, false);
        }
      }
    };

    this.deSelectAllAction.setImageDescriptor(FileLibrary
            .getFile("DeSelectAll.gif"));

    this.deleteItemAction = new Action("Clear All") {
      public void run() {
        // Object[] o = tree.getCheckedElements();
        FdToUml fd2uml = FdToUml.getInstance();
        if (!fd2uml.getDiagramsObj().isEmpty()) {
          if (MessageDialog
              .openConfirm(FileLibrary.getShell(),
                  "Confirm Delete",
                  "Are you sure you want to clear all diagram associations?")) {

           

            tree.getTree().removeAll();

            fd2uml.getDiagramsObj().emptyDiagramList();

            fd2uml.setCurrentDiagramId("");
            tree.refresh();
          }
        }
      }
     
     
    };
   
    this.deleteItemAction.setImageDescriptor(FileLibrary
            .getFile("Delete.gif"));

    this.generateClassDiagram = new Action("Generate UML Class") {
      public void run() {
        FdToUml.refreshConfigurationElementsDataFromDiagram();
       
        Object[] oArray = tree.getCheckedElements();
        ArrayList<Diagram> diagrams = new ArrayList<Diagram>();
        FdToUml fd2uml = FdToUml.getInstance();

        boolean wereSelectedDiagrams = false;
        for (Object o : oArray)
          if (o instanceof Diagram) {
            diagrams.add((Diagram) o);
View Full Code Here

    });

  }
 
  public static void refill(Menu menu, int index){
    FdToUml _fd2uml = FdToUml.getInstance();

    MenuItem[] menuItems = menu.getItems ();
   
    for (int i = 0; i < menuItems.length; i++) {
      menuItems[i].dispose ();
    }
   
    if (_fd2uml.getDiagramsObj().isEmpty()) {
     
      MenuItem menuItem = new MenuItem(menu, SWT.PUSH, index);
      menuItem.setText("No diagram associations...");
      menuItem.setEnabled(false);
     
    } else {
      int i = 0;
      for (Diagram DG : _fd2uml.getDiagramsObj().getDiagrams()) {

        MenuItem menuItem = new MenuItem(menu, SWT.RADIO, index + i);
        menuItem.setText(FileLibrary.getFileName(DG.getFeaturePath()) + " -> "
            + FileLibrary.getFileName(DG.getClassPath()));
       
        menuItem.setData("elementID", DG.getID());

        if (DG.getID() == _fd2uml.getCurrentDiagramId()) {
          menuItem.setSelection(true);
        }

        menuItem.addSelectionListener(new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
View Full Code Here

public class CheckboxHelper {
  public static void checkRecurrentNode(Object element,
      CheckboxTreeViewer tree, boolean state, boolean userClick) {

    AssociationsViewContent contentProvider = (AssociationsViewContent) tree
        .getContentProvider();
    Object parentElement = contentProvider.getParent(element);

    if (element instanceof AssociatedElement) {
      AssociatedElement assocElement = (AssociatedElement) element;

      assocElement.setChecked(state);
View Full Code Here

  }

  public static void checkRecurrentUpNode(Object element,
      CheckboxTreeViewer tree, boolean state, boolean userClick) {

    AssociationsViewContent contentProvider = (AssociationsViewContent) tree
        .getContentProvider();
    Object parentElement = contentProvider.getParent(element);

    if (element instanceof AssociatedElement) {
      AssociatedElement assocElement = (AssociatedElement) element;

      assocElement.setChecked(state);
View Full Code Here

TOP

Related Classes of com.ktu.fd2.uml.FileLibrary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.