Package org.fusesource.ide.commons.ui.actions

Examples of org.fusesource.ide.commons.ui.actions.ActionSupport


  };

  public ContainerTableSheetPage(Fabric8Node fabric) {
    super(fabric, VIEW_ID, new ContainerTableView(VIEW_ID));
    this.fabric = fabric;
    openTerminalAction = new ActionSupport(Messages.openTerminalLabel,
        Messages.openTerminalToolTip, Fabric8JMXPlugin.getDefault()
            .getImageDescriptor("terminal_view.gif")) {
      @Override
      public void run() {
        List<Container> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          Container container = selectedContainers.get(0);
          if (container != null) {
            System.err.println("TODO: open terminal");
//            ContainerNode.openTerminal(getFabric(), container, null);
          }
        }
      }
    };
    startAction = new ActionSupport(Messages.StartAgentAction,
        Messages.StartAgentActionToolTip, Fabric8JMXPlugin.getDefault()
            .getImageDescriptor("start_task.gif")) {
      @Override
      public void run() {
        start();
      }
    };
    stopAction = new ActionSupport(Messages.StopAgentAction,
        Messages.StopAgentActionToolTip, Fabric8JMXPlugin.getDefault()
            .getImageDescriptor("stop_task.gif")) {
      @Override
      public void run() {
        stop();
      }
    };
    destroyAction = new ActionSupport(Messages.DestroyContainerAction,
        Messages.DestroyContainerActionToolTip, Fabric8JMXPlugin
            .getDefault().getImageDescriptor("delete.gif")) {
      @Override
      public void run() {
        destroy();
View Full Code Here


    }
  };

  public AbstractContainersTabSection() {
    super(ContainerTableSheetPage.VIEW_ID);
    openTerminalAction = new ActionSupport(Messages.openTerminalLabel,
        Messages.openTerminalToolTip, Fabric8JMXPlugin.getDefault()
            .getImageDescriptor("terminal_view.gif")) {
      @Override
      public void run() {
        List<Container> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          Container container = selectedContainers.get(0);
          if (container != null) {
            System.err.println("TODO: open terminal");
//            ContainerNode
//                .openTerminal(getFabric(), container, null);
          }
        }
      }
    };
    startAction = new ActionSupport(Messages.StartAgentAction,
        Messages.StartAgentActionToolTip, Fabric8JMXPlugin.getDefault()
            .getImageDescriptor("start_task.gif")) {
      @Override
      public void run() {
        start();
      }

      @Override
      public boolean isEnabled() {
        List<Container> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          Container container = selectedContainers.get(0);
          if (container != null && container.isRoot()) {
            return false;
          }
        }
        return true;
      }
    };
    stopAction = new ActionSupport(Messages.StopAgentAction,
        Messages.StopAgentActionToolTip, Fabric8JMXPlugin.getDefault()
            .getImageDescriptor("stop_task.gif")) {
      @Override
      public void run() {
        stop();
      }

      @Override
      public boolean isEnabled() {
        List<Container> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          Container container = selectedContainers.get(0);
          if (container != null && container.isRoot()) {
            return false;
          }
        }
        return true;
      }
    };
    destroyAction = new ActionSupport(Messages.DestroyContainerAction,
        Messages.DestroyContainerActionToolTip, Fabric8JMXPlugin
            .getDefault().getImageDescriptor("delete.gif")) {
      @Override
      public void run() {
        destroy();
View Full Code Here

    }
  };

  public AbstractContainersTabSection() {
    super(ContainerTableSheetPage.VIEW_ID);
    openTerminalAction = new ActionSupport(Messages.openTerminalLabel,
        Messages.openTerminalToolTip, FabricPlugin.getDefault()
            .getImageDescriptor("terminal_view.gif")) {
      @Override
      public void run() {
        List<ContainerDTO> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          ContainerDTO container = selectedContainers.get(0);
          if (container != null) {
            ContainerNode
                .openTerminal(getFabric(), container, null);
          }
        }
      }
    };

    startAction = new ActionSupport(Messages.StartAgentAction,
        Messages.StartAgentActionToolTip, FabricPlugin.getDefault()
            .getImageDescriptor("start_task.gif")) {
      @Override
      public void run() {
        start();
      }

      @Override
      public boolean isEnabled() {
        List<ContainerDTO> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          ContainerDTO container = selectedContainers.get(0);
          if (container != null && container.isRoot()) {
            return false;
          }
        }
        return true;
      }
    };

    stopAction = new ActionSupport(Messages.StopAgentAction,
        Messages.StopAgentActionToolTip, FabricPlugin.getDefault()
            .getImageDescriptor("stop_task.gif")) {
      @Override
      public void run() {
        stop();
      }

      @Override
      public boolean isEnabled() {
        List<ContainerDTO> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          ContainerDTO container = selectedContainers.get(0);
          if (container != null && container.isRoot()) {
            return false;
          }
        }
        return true;
      }
    };

    destroyAction = new ActionSupport(Messages.DestroyContainerAction,
        Messages.DestroyContainerActionToolTip, FabricPlugin
            .getDefault().getImageDescriptor("delete.gif")) {
      @Override
      public void run() {
        destroy();
View Full Code Here

    return Objects.equal(getContainer().getVersionId(), Fabrics.getVersionName(version));
  }

  @Override
  public void provideContextMenu(IMenuManager menu) {
    Action openTerminalAction = new ActionSupport(
        Messages.openTerminalLabel, Messages.openTerminalToolTip,
        FabricPlugin.getDefault().getImageDescriptor(
            "terminal_view.gif")) {
      @Override
      public void run() {
View Full Code Here

      }
    });


    // TODO add a wizard...
    addAction = new ActionSupport(Messages.jcloud_addNodeButton, Messages.jcloud_addNodeButtonTooktip, FabricPlugin.getPlugin().getImageDescriptor("add_obj.gif")) {
      @Override
      public void run() {
        // TODO open a wizard to choose an image to start..
      }

    };

    openTerminalAction = new ActionSupport(Messages.jcloud_openTerminalLabel, Messages.jcloud_openTerminalTooltip, FabricPlugin.getPlugin().getImageDescriptor("terminal_view.gif")) {
      @Override
      public void run() {
        openTerminal();
      }
    };

    suspendAction = new ActionSupport(Messages.jcloud_suspendNodeButton, Messages.jcloud_suspendNodeButtonTooktip, FabricPlugin.getPlugin().getImageDescriptor("stop_task.gif")) {

      @Override
      public void run() {
        final List<ComputeMetadata> selectedNodes = getSelectedNodes();
        String message = makeNodesString(selectedNodes, "Suspending ", "");

        Jobs.schedule(message, new Runnable() {

          @Override
          public void run() {
            foreachNode(selectedNodes, "Suspend node failed", new Function<ComputeMetadata, Void>() {

              @Override
              public Void apply(ComputeMetadata node) {
                String id = JClouds.id(node);
                if (id != null) {
                  getComputeService().suspendNode(id);
                }
                return null;
              }
            });
            asyncReload();
          }

        });
      }

    };

    resumeAction = new ActionSupport(Messages.jcloud_resumeNodeButton, Messages.jcloud_resumeNodeButtonTooktip, FabricPlugin.getPlugin().getImageDescriptor("start_task.gif")) {

      @Override
      public void run() {
        final List<ComputeMetadata> selectedNodes = getSelectedNodes();
        String message = makeNodesString(selectedNodes, "Resuming ", "");

        Jobs.schedule(message, new Runnable() {

          @Override
          public void run() {
            foreachNode(selectedNodes, "Resume node failed", new Function<ComputeMetadata, Void>() {

              @Override
              public Void apply(ComputeMetadata node) {
                String id = JClouds.id(node);
                if (id != null) {
                  getComputeService().resumeNode(id);
                }
                return null;
              }
            });
            asyncReload();
          }
        });
      }

    };

    rebootAction = new ActionSupport(Messages.jcloud_rebootNodeButton, Messages.jcloud_rebootNodeButtonTooktip, FabricPlugin.getPlugin().getImageDescriptor("restart_task.gif")) {

      @Override
      public void run() {
        final List<ComputeMetadata> selectedNodes = getSelectedNodes();
        String message = makeNodesString(selectedNodes, "Rebooting ", "");

        Jobs.schedule(message, new Runnable() {

          @Override
          public void run() {
            foreachNode(selectedNodes, "Reboot node failed", new Function<ComputeMetadata, Void>() {

              @Override
              public Void apply(ComputeMetadata node) {
                String id = JClouds.id(node);
                if (id != null) {
                  getComputeService().rebootNode(id);
                }
                return null;
              }
            });
            asyncReload();
          }
        });
      }
    };

    destroyAction = new ActionSupport(Messages.jcloud_destroyNodeButton, Messages.jcloud_destroyNodeButtonTooktip, FabricPlugin.getPlugin().getImageDescriptor("delete.gif")) {

      @Override
      public void run() {
        final List<ComputeMetadata> selectedNodes = getSelectedNodes();
        if (!selectedNodes.isEmpty()) {
View Full Code Here

  public ContainerTableSheetPage(Fabric fabric) {
    super(fabric, VIEW_ID, new ContainerTableView(VIEW_ID));
    this.fabric = fabric;

    openTerminalAction = new ActionSupport(Messages.openTerminalLabel, Messages.openTerminalToolTip, FabricPlugin.getDefault().getImageDescriptor("terminal_view.gif")) {
      @Override
      public void run() {
        List<ContainerDTO> selectedContainers = getSelectedContainers();
        if (selectedContainers.size() > 0) {
          ContainerDTO container = selectedContainers.get(0);
          if (container != null) {
            ContainerNode.openTerminal(getFabric(), container, null);
          }
        }
      }
    };

    startAction = new ActionSupport(Messages.StartAgentAction, Messages.StartAgentActionToolTip, FabricPlugin.getDefault().getImageDescriptor("start_task.gif")) {
      @Override
      public void run() {
        start();
      }

    };

    stopAction = new ActionSupport(Messages.StopAgentAction, Messages.StopAgentActionToolTip, FabricPlugin.getDefault().getImageDescriptor("stop_task.gif")) {
      @Override
      public void run() {
        stop();
      }

    };

    destroyAction = new ActionSupport(Messages.DestroyContainerAction, Messages.DestroyContainerActionToolTip, FabricPlugin.getDefault().getImageDescriptor("delete.gif")) {
      @Override
      public void run() {
        destroy();
      }
View Full Code Here

public abstract class ProfilesFormSupport extends FormSupport {
  protected ListViewer featuresList;

  public static void createAddEditDeleteButtons(final ListEditor<String> editor, final ListViewer viewer, Composite buttonBar) {
    final ActionSupport addAction = new ActionSupport(editor.getAddButtonLabel(), editor.getAddButtonTooltip(), editor.getAddImageDescriptor()) {

      @Override
      public void run() {
        InputDialog dialog = new InputDialog(Shells.getShell(), editor.getAddDialogLabel(), editor.getAddDialogText(), "", null);
        int result = dialog.open();
        if (result == Window.OK) {
          String value = dialog.getValue();
          editor.addValue(value);
          viewer.setInput(editor.getList());
          Viewers.refresh(viewer);
          viewer.setSelection(new StructuredSelection(value));

        }
      }
    };
    final ActionSupport editAction = new ActionSupport(editor.getEditButtonLabel(), editor.getEditButtonTooltip(), editor.getEditImageDescriptor()) {

      @Override
      public void run() {
        final Object old = Selections.getFirstSelection(viewer);
        if (old != null) {
          InputDialog dialog = new InputDialog(Shells.getShell(), editor.getEditDialogLabel(), editor.getEditDialogText(), old.toString(), null);
          int result = dialog.open();
          if (result == Window.OK) {
            String value = dialog.getValue();
            editor.editValue(value,  old.toString());
            viewer.setInput(editor.getList());
            Viewers.refresh(viewer);
            viewer.setSelection(new StructuredSelection(value));
          }
        }
      }
    };


    Widgets.setDoubleClickAction(viewer, editAction);

    final ActionSupport deleteAction = new ActionSupport(editor.getDeleteButtonLabel(), editor.getDeleteButtonTooltip(), editor.getDeleteImageDescriptor()) {

      @Override
      public void run() {
        final Object old = Selections.getFirstSelection(viewer);
        if (old != null) {
          editor.removeValue(old.toString());
          viewer.setInput(editor.getList());
          Viewers.refresh(viewer);
        }
      }
    };

    final Button addButton = Widgets.createActionButton(buttonBar,  addAction);
    final Button editButton = Widgets.createActionButton(buttonBar,  editAction);
    final Button deleteButton = Widgets.createActionButton(buttonBar,  deleteAction);

    ISelectionChangedListener listener = new ISelectionChangedListener() {

      @Override
      public void selectionChanged(SelectionChangedEvent event) {
        boolean selected = Selections.getFirstSelection(viewer) != null;
        editAction.setEnabled(selected);
        editButton.setEnabled(selected);
        deleteAction.setEnabled(selected);
        deleteButton.setEnabled(selected);

      }
    };
    viewer.addSelectionChangedListener(listener);
View Full Code Here

TOP

Related Classes of org.fusesource.ide.commons.ui.actions.ActionSupport

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.