예제 #1
0
    @Override
    public Image getImage(Object element) {
      if (element instanceof IStructuredSelection)
        element = ((IStructuredSelection) element).getFirstElement();

      String imageKey = ISharedImages.IMG_OBJ_ELEMENT;

      if (element instanceof Repository)
        return Activator.getImageDescriptor("icons/folder-icon_16.png").createImage();

      if (element instanceof Resource) {
        if (((Resource) element).getDescriptor() == null) {
          return Activator.getImageDescriptor("icons/schema16.png").createImage();
        } else {
          if (((Resource) element).isAlive())
            return Activator.getImageDescriptor("icons/3d_objects_16.png").createImage();
          else {
            return Activator.getImageDescriptor("icons/3d_objects_off_16.png").createImage();
          }
        }
      }

      return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
    }
예제 #2
0
  private void makeActions() {
    addRepository =
        new Action() {
          public void run() {
            WizardDialog wizardDialog = new WizardDialog(null, new NewRepositoryWizardDialog());
            if (wizardDialog.open() == Window.OK) {
              MessageDialog.openConfirm(null, "Add Repository", "Repository has been added");
            } else {
              MessageDialog.openError(null, "Add Repository", "Repository could not be added");
            }
          }
        };

    addRepository.setText("Add Repository");
    addRepository.setToolTipText("");
    addRepository.setImageDescriptor(Activator.getImageDescriptor("icons/newfolder_wiz.gif"));

    addFolder =
        new Action() {
          public void run() {
            WizardDialog wizardDialog =
                new WizardDialog(null, new AddFolderResourceListWizardDialog());
            if (wizardDialog.open() == Window.OK) {
              MessageDialog.openConfirm(null, "Add Folder", "Resources imported");
            } else {
              MessageDialog.openError(null, "Add Folder", "Resources could not be imported");
            }
          }
        };

    addFolder.setText("Add Folder");
    addFolder.setToolTipText("");
    addFolder.setImageDescriptor(Activator.getImageDescriptor("icons/package.gif"));

    addResourceToExistingRepository =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();

            if (selection != null & selection instanceof IStructuredSelection) {
              IStructuredSelection strucSelection = (IStructuredSelection) selection;
              Object element = strucSelection.getFirstElement();

              if (element instanceof Repository) {
                WizardDialog wizardDialog =
                    new WizardDialog(
                        null,
                        new AddAResourceToExistingRepositoryWizardDialog((Repository) element));
                if (wizardDialog.open() == Window.OK) {
                  MessageDialog.openConfirm(
                      null, "Add resource to repository", "Resource has been added");
                } else {
                  MessageDialog.openError(
                      null, "Add resource to repository", "Resource could not be added");
                }
              } else {
                MessageDialog.openError(
                    null, "Add resource to repository", "Repository must be selected");
              }
            }
          }
        };

    addResourceToExistingRepository.setText("Add resource to repository");
    addResourceToExistingRepository.setImageDescriptor(
        Activator.getImageDescriptor("icons/3d_objects_16.png"));

    changeResourceToDescriptor =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();

            if (selection != null & selection instanceof IStructuredSelection) {
              IStructuredSelection strucSelection = (IStructuredSelection) selection;
              Object element = strucSelection.getFirstElement();

              if (element instanceof Resource) {
                Resource resource = (Resource) element;

                if (resource.getDescriptor() != null) {
                  resource.getDescriptor().getRepositoryFrom().getResources().add(resource);
                }
              } else {
                MessageDialog.openError(
                    null, "Change descriptor to resource", "Resource must be selected");
              }
            }
          }
        };

    changeResourceToDescriptor.setText("Change resource to descriptor");
    changeResourceToDescriptor.setImageDescriptor(Activator.getImageDescriptor("icons/left16.png"));

    changeDescriptorToResource =
        new Action() {
          public void run() {
            ISelection selection = viewer.getSelection();

            if (selection != null & selection instanceof IStructuredSelection) {
              IStructuredSelection strucSelection = (IStructuredSelection) selection;
              Object element = strucSelection.getFirstElement();

              if (element instanceof Resource) {
                Resource resource = (Resource) element;

                if (resource.getDescriptor() == null) {
                  WizardDialog wizardDialog =
                      new WizardDialog(null, new ChangeDescriptorToResourceWizardDialog(resource));
                  if (wizardDialog.open() == Window.OK) {
                    MessageDialog.openConfirm(
                        null, "Add resource to repository", "Resource has been added");
                  } else {
                    MessageDialog.openError(
                        null, "Add resource to repository", "Resource could not be added");
                  }
                } else {
                  MessageDialog.openError(
                      null,
                      "Change descriptor to resource",
                      "Resource is not a descriptor. It cannot be changed");
                }
              } else {
                MessageDialog.openError(
                    null, "Change descriptor to resource", "Resource must be selected");
              }
            }
          }
        };

    changeDescriptorToResource.setText("Change descriptor to resource");
    changeDescriptorToResource.setImageDescriptor(
        Activator.getImageDescriptor("icons/right16.png"));
  }