Esempio n. 1
0
 /** Create the description */
 private void createDescription() {
   final StyledText labelDescription = new StyledText(this, SWT.WRAP | SWT.READ_ONLY);
   labelDescription.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
   labelDescription.setEnabled(false);
   labelDescription.setFont(getFont());
   labelDescription.setForeground(getForeground());
   labelDescription.setText(this.description);
   SWTGraphicUtil.applyHTMLFormating(labelDescription);
 }
 public void setEnabled(boolean enabled) {
   if (enabled != fEnabled) {
     fEnabled = enabled;
     StyledText c = getSourceViewer().getTextWidget();
     if (c != null) {
       c.setEnabled(enabled);
       Display d = c.getDisplay();
       c.setBackground(enabled ? d.getSystemColor(SWT.COLOR_LIST_BACKGROUND) : null);
     }
   }
 }
Esempio n. 3
0
  @Override
  public void showBusy(boolean busy) {
    if (editorBusyIndicator != null) {
      if (busy) {
        if (TasksUiInternal.isAnimationsEnabled()) {
          editorBusyIndicator.start();
        }
      } else {
        editorBusyIndicator.stop();
      }
    }

    if (!isHeaderFormDisposed()) {
      Form form = getHeaderForm().getForm().getForm();
      if (form != null && !form.isDisposed()) {
        // TODO consider only disabling certain actions
        IToolBarManager toolBarManager = form.getToolBarManager();
        if (toolBarManager instanceof ToolBarManager) {
          ToolBar control = ((ToolBarManager) toolBarManager).getControl();
          if (control != null) {
            control.setEnabled(!busy);
          }
        }

        if (leftToolBar != null) {
          leftToolBar.setEnabled(!busy);
        }
        if (titleLabel != null) {
          titleLabel.setEnabled(!busy);
        }

        CommonUiUtil.setEnabled(form.getBody(), !busy);
        for (IFormPage page : getPages()) {
          if (page instanceof WorkbenchPart) {
            WorkbenchPart part = (WorkbenchPart) page;
            part.showBusy(busy);
          }
        }
      }
    }
  }
Esempio n. 4
0
  public CommandLineUIFactory(StyledText parentText) {
    parent = parentText;

    StyledText widget = new StyledText(parent, SWT.ON_TOP);
    widget.setFont(parent.getFont());
    widget.setMargins(COMMAND_CHAR_INDENT, 3, 3, 3);
    widget.setSize(5, 5);
    widget.setBackground(parent.getBackground());
    widget.setForeground(parent.getForeground());
    widget.setWordWrap(true);
    widget.setEnabled(true);
    //        widget.setCaretOffset(2);
    widget.moveAbove(parent);
    widget.setVisible(false);
    widget.addPaintListener(new BorderPaintListener());
    commandLineText = widget;

    parent.addPaintListener(new TextEditorPaintListener());
    parent.addFocusListener(
        new FocusAdapter() {
          @Override
          public void focusGained(FocusEvent e) {
            if (commandLineUI != null && commandLineUI.isOpen()) {
              commandLineText.forceFocus();
            }
          }
        });
    parent.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            commandLineText.dispose();
            if (commandLineUI != null) {
              commandLineUI.dispose();
            }
          }
        });
  }
  /* (non-Javadoc)
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);
    container.setLayout(new GridLayout(3, false));

    Group runtimeGrp = new Group(container, SWT.NONE);
    GridData runtimeGrpData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    runtimeGrp.setLayout(new GridLayout(3, false));
    runtimeGrp.setLayoutData(runtimeGrpData);
    runtimeGrp.setText(Messages.newProjectWizardRuntimePageRuntimeGroupLabel);

    Label runtimeLabel = new Label(runtimeGrp, SWT.NONE);
    GridData runtimeLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    runtimeLabel.setLayoutData(runtimeLabelData);
    runtimeLabel.setText(Messages.newProjectWizardRuntimePageRuntimeLabel);

    runtimeComboViewer = new ComboViewer(runtimeGrp, SWT.NONE | SWT.READ_ONLY);
    runtimeComboViewer.setComparator(
        new ViewerComparator(
            new Comparator<String>() {

              @Override
              public int compare(String o1, String o2) {
                if (Messages.newProjectWizardRuntimePageNoRuntimeSelectedLabel.equals(o1)) {
                  return -1;
                }
                return o1.compareTo(o2);
              }
            }));

    GridData runtimeComboData = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1);
    runtimeComboViewer.getCombo().setLayoutData(runtimeComboData);
    runtimeComboViewer
        .getCombo()
        .setToolTipText(Messages.newProjectWizardRuntimePageRuntimeDescription);
    runtimeComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    runtimeComboViewer
        .getCombo()
        .addModifyListener(
            new ModifyListener() {
              /*
               * (non-Javadoc)
               * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
               */
              @Override
              public void modifyText(ModifyEvent e) {
                lastSelectedRuntime = runtimeComboViewer.getSelection().toString();
                preselectCamelVersionForRuntime(determineRuntimeCamelVersion(getSelectedRuntime()));
                validate();
              }
            });

    try {
      configureRuntimeCombo();
    } catch (CoreException ex) {
      ProjectTemplatesActivator.pluginLog().logError(ex);
    }

    Button runtimeNewButton = new Button(runtimeGrp, SWT.NONE);
    GridData runtimeNewButtonData = new GridData(SWT.FILL, SWT.CENTER, false, false);
    runtimeNewButton.setLayoutData(runtimeNewButtonData);
    runtimeNewButton.setText(Messages.newProjectWizardRuntimePageRuntimeNewButtonLabel);
    runtimeNewButton.setToolTipText(
        Messages.newProjectWizardRuntimePageRuntimeNewButtonDescription);
    runtimeNewButton.addSelectionListener(
        new SelectionAdapter() {
          /*
           * (non-Javadoc)
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */

          @Override
          public void widgetSelected(SelectionEvent e) {
            String[] oldRuntimes = runtimeComboViewer.getCombo().getItems();
            boolean created = ServerUIUtil.showNewRuntimeWizard(getShell(), null, null);
            if (created) {
              String[] newRuntimes = runtimeComboViewer.getCombo().getItems();
              String newRuntime = getNewRuntime(oldRuntimes, newRuntimes);
              if (newRuntime != null) {
                runtimeComboViewer.setSelection(new StructuredSelection(newRuntime));
              }
            }
          }
        });

    new Label(runtimeGrp, SWT.None);

    Group camelGrp = new Group(container, SWT.NONE);
    GridData camelGrpData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 20);
    camelGrp.setLayout(new GridLayout(3, false));
    camelGrp.setLayoutData(camelGrpData);
    camelGrp.setText(Messages.newProjectWizardRuntimePageCamelGroupLabel);

    Label camelVersionLabel = new Label(camelGrp, SWT.NONE);
    GridData camelLabelData = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    camelVersionLabel.setLayoutData(camelLabelData);
    camelVersionLabel.setText(Messages.newProjectWizardRuntimePageCamelLabel);

    camelVersionCombo = new Combo(camelGrp, SWT.RIGHT | SWT.READ_ONLY);
    GridData camelComboData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
    camelVersionCombo.setLayoutData(camelComboData);
    camelVersionCombo.setItems(getSupportedCamelVersions());
    camelVersionCombo.select(Math.max(camelVersionCombo.getItemCount() - 1, 0));
    camelVersionCombo.setToolTipText(Messages.newProjectWizardRuntimePageCamelDescription);
    camelVersionCombo.addSelectionListener(
        new SelectionAdapter() {
          /* (non-Javadoc)
           * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          @Override
          public void widgetSelected(SelectionEvent e) {
            validate();
          }
        });
    // TODO: leaving that out until we decide to support other camel versions than the ones we ship
    //		camelVersionCombo.addFocusListener(new FocusAdapter() {
    //			/* (non-Javadoc)
    //			 * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
    //			 */
    //			@Override
    //			public void focusLost(FocusEvent e) {
    //				super.focusLost(e);
    //				validate();
    //			}
    //
    //			/* (non-Javadoc)
    //			 * @see org.eclipse.swt.events.FocusAdapter#focusGained(org.eclipse.swt.events.FocusEvent)
    //			 */
    //			@Override
    //			public void focusGained(FocusEvent e) {
    //				super.focusGained(e);
    //				setPageComplete(false);
    //			}
    //		});

    new Label(camelGrp, SWT.None);

    warningIconLabel = new Label(camelGrp, SWT.None);
    GridData camelLblData = new GridData(SWT.FILL, SWT.TOP, false, true, 1, 20);
    camelLblData.verticalIndent = 20;
    warningIconLabel.setImage(getSWTImage(SWT.ICON_WARNING));
    warningIconLabel.setLayoutData(camelLblData);
    warningIconLabel.setVisible(false);

    camelInfoText = new StyledText(camelGrp, SWT.WRAP | SWT.MULTI);
    GridData camelInfoData = new GridData(SWT.FILL, SWT.TOP, true, true, 2, 20);
    camelInfoData.verticalIndent = 0;
    camelInfoData.heightHint = 150;
    camelInfoText.setLayoutData(camelInfoData);
    camelInfoText.setEnabled(false);
    camelInfoText.setEditable(false);
    camelInfoText.setBackground(container.getBackground());

    new Label(camelGrp, SWT.None);

    setControl(container);

    IRuntimeLifecycleListener listener =
        new IRuntimeLifecycleListener() {

          @Override
          public void runtimeRemoved(IRuntime runtime) {
            runInUIThread();
          }

          @Override
          public void runtimeChanged(IRuntime runtime) {
            runInUIThread();
          }

          @Override
          public void runtimeAdded(IRuntime runtime) {
            runInUIThread();
          }

          private void runInUIThread() {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {

                      @Override
                      public void run() {
                        try {
                          configureRuntimeCombo();
                        } catch (CoreException ex) {
                          ProjectTemplatesActivator.pluginLog()
                              .logError("Unable to handle runtime change event", ex); // $NON-NLS-1$
                        }
                      }
                    });
          }
        };
    ServerCore.addRuntimeLifecycleListener(listener);
    validate();
  }
 /** Disable the widget. */
 public void setDisabled() {
   textWidget.setEnabled(false);
   textWidget.setBackground(gray);
 }
 /**
  * Sets whether the widget content can be edited.
  *
  * @param inEditable boolean
  * @see StyledText#setEditable(boolean)
  */
 public void setEditable(final boolean inEditable) {
   textWidget.setEnabled(true);
   textWidget.setEditable(inEditable);
   textWidget.setBackground(inEditable ? white : gray);
 }