/** Create head client in the {@link #mainForm}. Sub-classes can implement if needed. */
  protected void createHeadClient() {
    Composite headClient = new Composite(mainForm.getHead(), SWT.NONE);
    GridLayout gl = new GridLayout(3, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    headClient.setLayout(gl);

    new Label(headClient, SWT.NONE).setText("Show:");

    environmentSelection = new Button(headClient, SWT.RADIO);
    environmentSelection.setText("Environments");
    environmentSelection.setSelection(true);

    profileSelection = new Button(headClient, SWT.RADIO);
    profileSelection.setText("Profiles");

    environmentSelection.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            performUpdate(false);
          }
        });

    mainForm.setHeadClient(headClient);
  }
Example #2
0
  /**
   * Add image to a widget or window
   *
   * @param parent
   * @param image
   * @throws JellyTagException
   */
  protected void setImage(Object parent, Image image) throws GroovyException {
    if (parent instanceof Label) {
      Label label = (Label) parent;
      label.setImage(image);

    } else if (parent instanceof Button) {
      Button button = (Button) parent;
      button.setImage(image);

    } else if (parent instanceof Item) {
      Item item = (Item) parent;
      item.setImage(image);

    } else if (parent instanceof Decorations) {
      Decorations item = (Decorations) parent;
      item.setImage(image);

    } else if (parent instanceof Form) {
      Form form = (Form) parent;
      form.setBackgroundImage(image);

    } else if (parent instanceof ScrolledForm) {
      ScrolledForm form = (ScrolledForm) parent;
      form.setBackgroundImage(image);

    } else if (parent instanceof Window) {
      Window window = (Window) parent;
      window.getShell().setImage(image);

    } else {
      throw new GroovyException("This tag must be nested inside a <label>, <button> or <item> tag");
    }
  }
Example #3
0
 /** @since 3.1 */
 public String getMessage() {
   if (getHeaderForm() != null && getHeaderForm().getForm() != null) {
     if (!getHeaderForm().getForm().isDisposed()) {
       Form form = getHeaderForm().getForm().getForm();
       return form.getMessage();
     }
   }
   return null;
 }
Example #4
0
  @Override
  public void createPartControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    container.setLayout(new FormLayout());

    FormToolkit toolkit = new FormToolkit(container.getDisplay());
    Form form = toolkit.createForm(container);

    FormData data = new FormData();
    data.top = new FormAttachment(0, 20);
    data.left = new FormAttachment(50, -100);
    data.right = new FormAttachment(50, 100);
    data.bottom = new FormAttachment(100, -20);

    form.setLayoutData(data);

    // form.setText(Messages.IntroTitle);

    FillLayout layout = new FillLayout();
    layout.marginHeight = layout.marginWidth = 5;
    form.getBody().setLayout(layout);

    FormText text = toolkit.createFormText(form.getBody(), true);

    StringBuilder buf = new StringBuilder();
    buf.append("<form>"); // $NON-NLS-1$
    buf.append("<p><img href=\"logo\"/></p>"); // $NON-NLS-1$
    buf.append("<p><span color=\"header\" font=\"header\">") // $NON-NLS-1$
        .append(Messages.IntroTitle) //
        .append("</span></p>"); // $NON-NLS-1$
    addLink(buf, "action:open", Messages.IntroOpenFile, Messages.IntroOpenFileText); // $NON-NLS-1$
    addLink(buf, "action:new", Messages.IntroNewFile, Messages.IntroNewFileText); // $NON-NLS-1$
    addLink(
        buf,
        "action:sample",
        Messages.IntroOpenSample,
        Messages.IntroOpenSampleText); // $NON-NLS-1$
    addLink(
        buf,
        "action:daxsample",
        Messages.IntroOpenDaxSample,
        Messages.IntroOpenDaxSampleText); // $NON-NLS-1$
    addLink(
        buf,
        "http://buchen.github.com/portfolio/new_and_noteworthy.html", //$NON-NLS-1$
        Messages.IntroReadNews,
        Messages.IntroReadNewsText);
    buf.append("</form>"); // $NON-NLS-1$
    text.setText(buf.toString(), true, false);
    text.setImage("logo", PortfolioPlugin.image(PortfolioPlugin.IMG_LOGO)); // $NON-NLS-1$
    text.setColor("header", toolkit.getColors().getColor(IFormColors.TITLE)); // $NON-NLS-1$
    text.setFont("header", JFaceResources.getHeaderFont()); // $NON-NLS-1$
    text.addHyperlinkListener(this);
  }
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.emf.eef.runtime.api.parts.IFormPropertiesEditionPart#
  *     createFigure(org.eclipse.swt.widgets.Composite, org.eclipse.ui.forms.widgets.FormToolkit)
  */
 public Composite createFigure(final Composite parent, final FormToolkit widgetFactory) {
   ScrolledForm scrolledForm = widgetFactory.createScrolledForm(parent);
   Form form = scrolledForm.getForm();
   view = form.getBody();
   GridLayout layout = new GridLayout();
   layout.numColumns = 3;
   view.setLayout(layout);
   createControls(widgetFactory, view);
   return scrolledForm;
 }
 /** {@inheritDoc} */
 @Override
 protected void createHeadClient(Form form) {
   Composite infoComposite = new Composite(form.getHead(), SWT.NONE);
   infoComposite.setLayout(new GridLayout(2, false));
   Label infoLabel = new Label(infoComposite, SWT.NONE);
   infoLabel.setImage(InspectIT.getDefault().getImage(InspectITImages.IMG_INFORMATION));
   infoLabel.setToolTipText(BusinessContextManagerViewPart.APP_ORDER_INFO_TOOLTIP);
   Label infoLabelText = new Label(infoComposite, SWT.NONE);
   infoLabelText.setText("Pay attention to the order of application definitions!");
   infoLabelText.setToolTipText(BusinessContextManagerViewPart.APP_ORDER_INFO_TOOLTIP);
   form.setHeadClient(infoComposite);
 }
 @Override
 public final void createControls(
     Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
   super.createControls(parent, aTabbedPropertySheetPage);
   GridDataFactory.fillDefaults().grab(true, true).applyTo(parent);
   parent.setLayout(new GridLayout(1, true));
   toolkit = new FormToolkit(parent.getDisplay());
   form = toolkit.createForm(parent);
   toolkit.decorateFormHeading(form);
   GridDataFactory.fillDefaults().grab(true, true).applyTo(form);
   form.getBody().setLayout(createBodyLayout());
   createControls(form.getBody());
 }
  /** Updates the form menu. Sub-classes can extend if needed. */
  protected void updateFormMenuManager() {
    IMenuManager menuManager = mainForm.getMenuManager();
    menuManager.removeAll();

    for (CmrRepositoryDefinition cmrRepositoryDefinition :
        cmrRepositoryManager.getCmrRepositoryDefinitions()) {
      if (!Objects.equals(cmrRepositoryDefinition, displayedCmrRepositoryDefinition)) {
        menuManager.add(new SelectCmrAction(cmrRepositoryDefinition));
      }
    }
    menuManager.update(true);
    mainForm.getHead().layout();
  }
Example #9
0
  private void installTitleDrag(Form form) {
    if (titleDragSourceListener == null /*&& !hasLeftToolBar()*/) {
      Transfer[] transferTypes;
      if (null == task) {
        transferTypes = new Transfer[] {TextTransfer.getInstance()};
      } else {
        transferTypes =
            new Transfer[] {
              LocalSelectionTransfer.getTransfer(),
              TextTransfer.getInstance(),
              FileTransfer.getInstance()
            };
      }
      titleDragSourceListener =
          new TaskDragSourceListener(
              new SelectionProviderAdapter() {
                @Override
                public ISelection getSelection() {
                  return new StructuredSelection(task);
                }
              });

      if (titleLabel != null) {
        DragSource source = new DragSource(titleLabel, DND.DROP_MOVE | DND.DROP_LINK);
        source.setTransfer(transferTypes);
        source.addDragListener(titleDragSourceListener);
      } else {
        form.addTitleDragSupport(
            DND.DROP_MOVE | DND.DROP_LINK, transferTypes, titleDragSourceListener);
      }
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see org.topcased.doc2model.requirement.ui.NotifyElement#handleModelChange()
  */
 public void handleModelChange() {
   regexInput = componentHelpTextField.getInput();
   if (!"".equals(regexInput)) // $NON-NLS-1$
   {
     try {
       Pattern.compile(regexInput, Pattern.MULTILINE);
       form.setMessage(null, IMessageProvider.NONE);
       this.getButton(IDialogConstants.OK_ID).setEnabled(true);
     } catch (PatternSyntaxException e) {
       form.setMessage("Regex doesn't compile", IMessageProvider.ERROR); // $NON-NLS-1$
       this.getButton(IDialogConstants.OK_ID).setEnabled(false);
     }
   } else {
     form.setMessage(null, IMessageProvider.NONE);
     this.getButton(IDialogConstants.OK_ID).setEnabled(true);
   }
 }
 /** {@inheritDoc} */
 @Override
 public void setFocus() {
   if (tableViewer.getTable().isVisible()) {
     tableViewer.getTable().setFocus();
   } else {
     mainForm.setFocus();
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
   */
  protected Control createDialogArea(Composite parent) {

    getShell().setText("New Regex"); // $NON-NLS-1$

    // getShell().setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_WHITE));
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new FillLayout());

    FormToolkit toolkit = new FormToolkit(Display.getDefault());
    form = toolkit.createForm(composite);
    form.getBody().setLayout(new GridLayout());
    toolkit.decorateFormHeading(form);

    sec = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    sec.setText("Regular Expression"); // $NON-NLS-1$
    sec.setLayoutData(new GridData(SWT.FILL, SWT.Expand, true, false, 1, 1));
    Composite compo = toolkit.createComposite(sec);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    compo.setLayout(layout);
    sec.setClient(compo);
    createContent(toolkit, compo);

    // Create field for Regex
    toolkit.createLabel(compo, "Regex: "); // $NON-NLS-1$
    String helpText = Messages.PopupRegexDialog_REGEX;
    componentHelpTextField = new ComponentHelpTextField(this, compo, toolkit, SWT.NONE, helpText);
    GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
    componentHelpTextField.setLayoutData(data);

    // Add regex viewer component to the dialog
    regex =
        new RegexViewerComposite(
            form.getBody(),
            SWT.NONE,
            RegexViewerComposite.EXPANDABLE
                | RegexViewerComposite.MATCH
                | RegexViewerComposite.DESCRIPTION
                | RegexViewerComposite.GROUP,
            Pattern.MULTILINE | patterns);
    regex.setDescription("Regex Test Area"); // $NON-NLS-1$
    regex.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));

    return composite;
  }
 /**
  * Displays the message on the provided composite.
  *
  * @param text Text of message.
  * @param image Image to show.
  */
 protected void displayMessage(String text, Image image) {
   clearFormBody();
   if (null == messageComposite || messageComposite.isDisposed()) {
     messageComposite = toolkit.createComposite(mainForm.getBody());
   } else {
     for (Control c : messageComposite.getChildren()) {
       if (!c.isDisposed()) {
         c.dispose();
       }
     }
   }
   messageComposite.setLayout(new GridLayout(2, false));
   messageComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
   toolkit.createLabel(messageComposite, null).setImage(image);
   toolkit
       .createLabel(messageComposite, text, SWT.WRAP)
       .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
   mainForm.getBody().layout();
 }
 /*
  * (non-Javadoc)
  *
  * @see org.fusesource.ide.camel.editor.propertysheet.NodeSectionSupport#
  * onNodeChanged(org.fusesource.ide.camel.model.AbstractNode)
  */
 @Override
 protected void onNodeChanged(AbstractNode node) {
   this.node = node;
   form.setText(
       node != null
           ? String.format(
               "%s - %s", EditorMessages.propertiesDocumentationTitle, node.getPatternName())
           : EditorMessages.propertiesDocumentationTitle);
   showDocumentationPage();
 }
Example #15
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);
          }
        }
      }
    }
  }
Example #16
0
 private void setBestellung(final Bestellung b) {
   actBestellung = b;
   if (b != null) {
     form.setText(b.getLabel());
     tv.refresh();
     saveAction.setEnabled(true);
     checkInAction.setEnabled(true);
   } else {
     saveAction.setEnabled(false);
     checkInAction.setEnabled(false);
   }
 }
Example #17
0
  /** @since 2.3 */
  public void setMessage(String message, int type, IHyperlinkListener listener) {
    if (isHeaderFormDisposed()) {
      return;
    }

    try {
      // avoid flicker of the left header toolbar
      getHeaderForm().getForm().setRedraw(false);

      Form form = getHeaderForm().getForm().getForm();
      if (message != null) {
        message = message.replace('\n', ' ');
      }
      form.setMessage(message, type, null);
      if (messageHyperLinkListener != null) {
        form.removeMessageHyperlinkListener(messageHyperLinkListener);
        if (messageHyperLinkListener instanceof IDisposable) {
          ((IDisposable) messageHyperLinkListener).dispose();
        }
      }
      if (listener != null) {
        form.addMessageHyperlinkListener(listener);
      }
      messageHyperLinkListener = listener;

      // make sure the busyLabel image is large enough to accommodate the tool bar
      if (hasLeftToolBar()) {
        BusyIndicator busyLabel = getBusyLabel();
        if (message != null && busyLabel != null) {
          setHeaderImage(busyLabel.getImage());
        } else {
          setHeaderImage(null);
        }
      }
    } finally {
      getHeaderForm().getForm().setRedraw(true);
    }
  }
 /** Updates the form title. Sub-classes can extend if needed. */
 protected void updateFormTitle() {
   if (null != displayedCmrRepositoryDefinition) {
     mainForm.setImage(
         ImageFormatter.getCmrRepositoryImage(displayedCmrRepositoryDefinition, true));
     mainForm.setText(displayedCmrRepositoryDefinition.getName());
     mainForm.setToolTipText(
         TextFormatter.getCmrRepositoryDescription(displayedCmrRepositoryDefinition));
     mainForm.setMessage(null);
   } else {
     mainForm.setImage(null);
     mainForm.setText("No repository exists");
     mainForm.setMessage(
         "Repositories can be added from the Repository Manager", IMessageProvider.WARNING);
     mainForm.setToolTipText(null);
   }
 }
Example #19
0
 public VHostTabControl(TabFolder tabFolder, JMXManagedObject mbean, MBeanServerConnection mbsc) {
   super(tabFolder);
   _mbean = mbean;
   _serverRegistry = ApplicationRegistry.getServerRegistry(mbean);
   _ApiVersion = _serverRegistry.getManagementApiVersion();
   _vhmb =
       (ManagedBroker)
           MBeanServerInvocationHandler.newProxyInstance(
               mbsc, mbean.getObjectName(), ManagedBroker.class, false);
   _toolkit = new FormToolkit(_tabFolder.getDisplay());
   _form = _toolkit.createForm(_tabFolder);
   _form.getBody().setLayout(new GridLayout());
   createComposites();
   createWidgets();
 }
 /** Updates the tree input and refreshes the tree. */
 protected void updateFormBody() {
   clearFormBody();
   if (null == displayedCmrRepositoryDefinition) {
     displayMessage(
         "No CMR repository present. Please add the CMR repository via 'Add CMR repository' action.",
         Display.getDefault().getSystemImage(SWT.ICON_INFORMATION));
   } else if (displayedCmrRepositoryDefinition.getOnlineStatus() == OnlineStatus.OFFLINE) {
     displayMessage(
         "Selected CMR repository is currently unavailable.",
         Display.getDefault().getSystemImage(SWT.ICON_WARNING));
   } else if (isShowEnvironments()) {
     List<?> inputList = environmentLeafs;
     if (CollectionUtils.isEmpty(inputList)) {
       displayMessage(
           "No environment exists on selected CMR repository.",
           Display.getDefault().getSystemImage(SWT.ICON_INFORMATION));
     } else {
       createTableColumns();
       tableViewer.getTable().setHeaderVisible(true);
       tableViewer.getTable().setLinesVisible(true);
       tableViewer.getTable().setVisible(true);
       tableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
       tableViewer.setInput(inputList);
     }
   } else if (isShowProfiles()) {
     List<?> inputList = profileLeafs;
     if (CollectionUtils.isEmpty(inputList)) {
       displayMessage(
           "No profile exists on selected CMR repository.",
           Display.getDefault().getSystemImage(SWT.ICON_INFORMATION));
     } else {
       createTableColumns();
       tableViewer.getTable().setHeaderVisible(true);
       tableViewer.getTable().setLinesVisible(true);
       tableViewer.getTable().setVisible(true);
       tableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
       tableViewer.setInput(inputList);
     }
   }
   mainForm.getBody().layout();
 }
  @Override
  public void createPartControl(Composite parent) {
    // TODO Auto-generated method stub
    toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createForm(parent);
    form.setText("MetaData Editor:");

    toolkit.decorateFormHeading(form);

    GridData gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.minimumWidth = 200;
    //		FormLayout gridLayout = new FormLayout();
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    gridLayout.horizontalSpacing = 5;
    form.getBody().setLayout(gridLayout);

    FormData formDate = new FormData();
    formDate.height = 250;
    formDate.width = 300;

    FormData formDate0 = new FormData();
    formDate0.height = 150;
    formDate0.width = 300;
    FormData formDate2 = new FormData();
    formDate2.height = 550;
    formDate2.width = 550;

    Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section.setText("Attribute Modifier");
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new FormLayout());
    section.setClient(sectionClient);

    GridData gridData2 = new GridData();
    gridData2.verticalSpan = 2;
    section.setLayoutData(gridData2);

    Section section2 = toolkit.createSection(form.getBody(), Section.TITLE_BAR);
    section2.setText("Collector");
    Composite sectionClient2 = toolkit.createComposite(section2);
    sectionClient2.setLayout(new FormLayout());
    section2.setClient(sectionClient2);

    Section section3 = toolkit.createSection(form.getBody(), Section.TITLE_BAR); // printStackTrace
    section3.setText("Collection Code");
    Composite sectionClient3 = toolkit.createComposite(section3);
    sectionClient3.setLayout(new FormLayout());
    section3.setClient(sectionClient3);

    final Table table2 =
        toolkit.createTable(
            sectionClient2, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table2.setHeaderVisible(true);

    final Button submitCollectionCode = toolkit.createButton(sectionClient2, "submit", SWT.None);

    TableColumn column01 = new TableColumn(table2, SWT.NONE);
    column01.setWidth(25);
    column01.setText("#");
    TableColumn column02 = new TableColumn(table2, SWT.NONE);
    column02.setWidth(100);
    column02.setText("Name");
    TableColumn column03 = new TableColumn(table2, SWT.NONE);
    column03.setWidth(100);
    column03.setText("Collection No");
    table2.setLayoutData(formDate);
    int index = 1;
    for (SpecCollectorMap map : spec.getSpecCollectorMaps()) {
      Collector c = map.getCollector();
      TableItem item = new TableItem(table2, SWT.FULL_SELECTION);
      item.setData("collector", c);
      item.setText(0, index + "");
      index++;
      item.setText(1, c.getCollectorFullName()); // c.exe
      if (spec.getRecordNumber() == null) {
        item.setText(2, "");
      } else item.setText(2, spec.getRecordNumber());

      table2.setSelection(index);
    }

    table2.addListener(
        SWT.MouseDoubleClick,
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            int ret;
            for (final TableItem item : table2.getItems()) {

              for (int i = 0; i < table2.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Collector c = (Collector) item.getData("collector");
                  CollectorModDialog dialog =
                      new CollectorModDialog(Display.getDefault().getActiveShell(), c);
                  ret = dialog.open();
                }
              }
            }
          }
        });
    final Table table3 =
        toolkit.createTable(
            sectionClient3, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.NONE);
    table3.setHeaderVisible(true);

    TableColumn column31 = new TableColumn(table3, SWT.NONE);
    column31.setWidth(25);
    column31.setText("#");
    TableColumn column32 = new TableColumn(table3, SWT.NONE);
    column32.setWidth(50);
    column32.setText("Collection Code");
    TableColumn column33 = new TableColumn(table3, SWT.NONE);
    column33.setWidth(150);
    column33.setText("Collection Info");
    table3.setLayoutData(formDate0);

    Collection ccc = this.spec.getCollection();

    TableItem item31 = new TableItem(table3, SWT.NONE);
    item31.setText(0, "1");
    if (ccc != null) {
      if (ccc.getCollectionCode() == null) ccc.setCollectionCode("");
      if (ccc.getCollectionInfo() == null) ccc.setCollectionInfo("");
      item31.setText(1, ccc.getCollectionCode());
      item31.setText(2, ccc.getCollectionInfo());
    }

    final TableEditor collectionEditor = new TableEditor(table3);
    collectionEditor.horizontalAlignment = SWT.LEFT;
    collectionEditor.grabHorizontal = true;
    collectionEditor.minimumWidth = 50;
    collectionSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = collectionEditor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    table3.addSelectionListener(collectionSelectionListener);
    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {}
            }
          }
        };

    tableListener2 =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table3.getItems()) {

              for (int i = 0; i < table3.getColumnCount(); i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                  Control oldEditor = collectionEditor.getEditor();
                  if (oldEditor != null) oldEditor.dispose();

                  final Combo newEditor = new Combo(table3, SWT.NONE);
                  DataUtilsService service = new DataUtilsService();
                  DataUtilsDelegate delegate = service.getDataUtilsPort();
                  final List<Collection> collections = delegate.getCollections();
                  for (Collection col : collections) {
                    newEditor.add(col.getCollectionCode());
                  }

                  newEditor.addDisposeListener(
                      new DisposeListener() {
                        @Override
                        public void widgetDisposed(DisposeEvent e) {
                          // TODO Auto-generated method stub
                          Combo combo = (Combo) collectionEditor.getEditor();
                          Collection collection = collections.get(combo.getSelectionIndex());
                          collectionEditor.getItem().setText(1, collection.getCollectionCode());
                          collectionEditor.getItem().setText(2, collection.getCollectionInfo());
                          collectionEditor
                              .getItem()
                              .setBackground(new Color(Display.getCurrent(), 255, 250, 160));

                          String methodName = (String) item.getData();
                        }
                      });

                  newEditor.setFocus();
                  collectionEditor.setEditor(newEditor, item, 1);
                }
              }
            }
          }
        };
    table3.addListener(SWT.MouseDoubleClick, tableListener2);

    final Table table =
        toolkit.createTable(sectionClient, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    table.setHeaderVisible(true);
    table.setLayoutData(formDate2);
    TableColumn column = new TableColumn(table, SWT.NONE);
    column.setWidth(200);
    column.setText("Name");
    TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setWidth(250);
    column2.setText("Data");
    TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setWidth(100);

    //		table.setLayoutData(gridData);
    /*
    		final TableItem itemName = new TableItem(table,SWT.NONE);
    		itemName.setText(0,"Scientific Name:");
    		final TableItem itemFamily = new TableItem(table, SWT.NONE);
    		itemFamily.setText(0, "Family:");
    		itemFamily.setData("setFamily");
    		final TableItem itemGenus = new TableItem(table, SWT.NONE);
    		itemGenus.setText(0, "Genus:");
    		itemGenus.setData("setGenus");
    		final TableItem itemSpecies = new TableItem(table, SWT.NONE);
    		itemSpecies.setText(0, "Species:");
    		itemSpecies.setData("setSpecies");
    		final TableItem itemCollectAt = new TableItem(table, SWT.NONE);
    		itemCollectAt.setText(0, "Collect At:");
    		itemCollectAt.setData("setCountry");
    		final TableItem itemCollectAtDarwin = new TableItem(table, SWT.NONE);
    		itemCollectAtDarwin.setText(0, "Name in Darwin's time:");
    		itemCollectAtDarwin.setData("setDcountry");
    		final TableItem itemSheetNote = new TableItem(table, SWT.NONE);
    		itemSheetNote.setText(0, "Sheet Notes:");
    		itemSheetNote.setData("setSheetNotes");
    		final TableItem itemState = new TableItem(table, SWT.NONE);
    		itemState.setText(0, "State:");
    		itemState.setData("setStateProvince");
    		final TableItem itemTown = new TableItem(table, SWT.NONE);
    		itemTown.setText(0, "Town:");
    		itemTown.setData("setTown");


    		itemName.setText(1,spec.getScientificName());
    		itemFamily.setText(1, spec.getFamily());
    		itemGenus.setText(1, spec.getGenus());
    		itemSpecies.setText(1, spec.getSpecificEpithet());
    		itemCollectAt.setText(1, spec.getCountry());
    		itemCollectAtDarwin.setText(1, spec.getDarwinCountry());
    		itemSheetNote.setText(1, spec.getSheetNotes());
    		itemState.setText(1, spec.getStateProvince());
    		itemTown.setText(1, spec.getTown());
    */

    try {
      Element root = this.configXml.selectElement("system/editor");
      for (int i = 0; i < root.getChildNodes().getLength(); i++) {
        if (root.getChildNodes().item(i).getNodeType() == Element.ELEMENT_NODE) {
          Element child = (Element) root.getChildNodes().item(i);
          System.out.println("child name = " + child.getAttribute("field"));
          if (child.getAttribute("display").equals("true")) {
            final TableItem itemName = new TableItem(table, SWT.NONE);
            System.out.println(itemName);
            itemName.setData("set" + child.getAttribute("field"));
            itemName.setData("editable", child.getAttribute("editable"));
            itemName.setData("type", child.getAttribute("type"));
            itemName.setText(0, child.getAttribute("name"));
            if (child.getAttribute("field").equals("RecordNumber")) {
              System.out.println(child.getAttribute("editable"));
            }
            Method m;

            try {
              m = spec.getClass().getMethod("get" + child.getAttribute("field"));
              System.out.println("function name = " + m.getName());
              if (child.getAttribute("type").equals("date")) {
                XMLGregorianCalendar cal = (XMLGregorianCalendar) m.invoke(spec);

                String calstr = "";
                if (cal != null) {
                  calstr = cal.toString();
                  itemName.setText(1, calstr);
                  itemName.setData("date", cal);
                }
              } else if (child.getAttribute("type").equals("string")) {
                String str = (String) m.invoke(spec);
                if (str == null) {
                  str = "";
                }
                itemName.setText(1, str);
              } else if (child.getAttribute("type").equals("int")) {
                Integer inte = (Integer) m.invoke(spec);
                itemName.setText(1, inte + "");
              }
            } catch (NoSuchMethodException e) {
              // TODO Auto-generated catch block
              System.out.println("field==" + child.getAttribute("field"));
              //						e.printStackTrace();
            } catch (SecurityException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalAccessException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IllegalArgumentException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (InvocationTargetException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      }
    } catch (XmlToolException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    final TableEditor editor = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    editor.horizontalAlignment = SWT.LEFT;
    editor.grabHorizontal = true;
    editor.minimumWidth = 50;
    // editing the second column
    final int EDITABLECOLUMN = 1;
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };

    final Button submitButton = toolkit.createButton(form.getBody(), "submit", SWT.None);
    submitButton.setEnabled(false);
    final Label label2 = new Label(form.getBody(), SWT.NONE);
    label2.setData("name", "label2");
    label2.setText("Modification Save Successfully");
    label2.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label2.setForeground(new Color(Display.getCurrent(), 0, 128, 64));
    label2.setVisible(false);

    final Label label3 = new Label(form.getBody(), SWT.NONE);
    label3.setData("name", "label2");
    label3.setText("Modification Save Error!");
    label3.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label3.setForeground(new Color(Display.getCurrent(), 128, 0, 0));
    label3.setVisible(false);

    final Label label4 = new Label(form.getBody(), SWT.NONE);
    label4.setData("name", "label4");
    label4.setFont(new Font(Display.getCurrent(), "Arial", 10, SWT.BOLD));
    label4.setForeground(new Color(Display.getCurrent(), 200, 0, 0));
    label4.setVisible(false);

    final TableEditor edit = new TableEditor(table);
    // The editor must have the same size as the cell and must
    // not be any smaller than 50 pixels.
    edit.horizontalAlignment = SWT.LEFT;
    edit.grabHorizontal = true;
    edit.minimumWidth = 50;
    // editing the second column
    tableSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            Control oldEditor = editor.getEditor();
            if (oldEditor != null) oldEditor.dispose();
          }
        };
    table.addSelectionListener(tableSelectionListener);
    tableListener =
        new Listener() {
          @Override
          public void handleEvent(Event arg0) {
            // TODO Auto-generated method stub
            Point pt = new Point(arg0.x, arg0.y);
            for (final TableItem item : table.getItems()) {
              String editable = (String) item.getData("editable");
              if (editable.equals("true")) {
                for (int i = 0; i < table.getColumnCount(); i++) {
                  Rectangle rect = item.getBounds(i);
                  if (rect.contains(pt)) {
                    Control oldEditor = editor.getEditor();
                    if (oldEditor != null) oldEditor.dispose();

                    if (item.getData("type").equals("int")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {Integer.parseInt(text.getText())});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    }

                    if (item.getData("type").equals("string")) {
                      Text newEditor = new Text(table, SWT.NONE);
                      newEditor.setText(item.getText(EDITABLECOLUMN));
                      newEditor.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              Text text = (Text) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, text.getText());
                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    m.invoke(spec, new Object[] {text.getText()});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });
                      newEditor.selectAll();
                      newEditor.setFocus();
                      editor.setEditor(newEditor, item, EDITABLECOLUMN);
                      break;
                    } else if (item.getData("type").equals("date")) {
                      CalendarCombo calendar = new CalendarCombo(table, SWT.CALENDAR);
                      XMLGregorianCalendar cal = (XMLGregorianCalendar) item.getData("date");
                      if (cal == null) {
                        calendar.setDate(new Date(System.currentTimeMillis()));
                      } else {
                        GregorianCalendar ca = cal.toGregorianCalendar();
                        calendar.setDate(ca.getTime());
                      }
                      //
                      calendar.addDisposeListener(
                          new DisposeListener() {
                            @Override
                            public void widgetDisposed(DisposeEvent arg0) {
                              // TODO Auto-generated method stub
                              CalendarCombo cc = (CalendarCombo) editor.getEditor();
                              editor.getItem().setText(EDITABLECOLUMN, cc.getDateAsString());

                              String methodName = (String) item.getData();
                              for (Method m : spec.getClass().getMethods()) {
                                if (m.getName().equals(methodName)) {
                                  try {
                                    GregorianCalendar gc = new GregorianCalendar();
                                    gc.setTime(cc.getDate().getTime());
                                    XMLGregorianCalendar date2 =
                                        DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
                                    m.invoke(spec, new Object[] {date2});
                                  } catch (IllegalArgumentException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (IllegalAccessException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (InvocationTargetException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  } catch (DatatypeConfigurationException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                  }
                                  break;
                                }
                              }

                              item.setBackground(new Color(Display.getCurrent(), 255, 250, 160));
                              item.setData("modified", "true");
                              submitButton.setEnabled(true);
                            }
                          });

                      calendar.setFocus();
                      editor.setEditor(calendar, item, EDITABLECOLUMN);
                      break;
                    }
                  }
                } // for
              }
            }
          }
        };
    table.addListener(SWT.MouseDoubleClick, tableListener);
    submitButton.setLayoutData(gridData);
    buttonSelectionListener =
        new SelectionListener() {
          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub
            try {
              //					Specimen speca = null;
              //					for(IWorkbenchPage p : pages){
              //						IViewReference ivrs [] = p.getViewReferences();
              //						for(IViewReference ivr : ivrs){
              //							if(ivr.getId().equals("TestView.view")){
              //								View v = (View)ivr.getView(true);
              //								speca = v.getGallery().getSelection()[0].getData("spec", spec);
              //								if(spec.getMissingInfo()==0){
              //									v.getGallery().getSelection()[0].setBackground(new
              // Color(Display.getCurrent(), 255,255,255));
              //								}
              //								break;
              //							}
              //						}
              //					}
              DataUtilsService service = new DataUtilsService(); // Missing
              DataUtilsDelegate delegate = service.getDataUtilsPort();
              //					Specimen ss = delegate.getSpecimenById(spec.getSpecimenId());//getView

              List<SpecCollectorMap> scms = delegate.getScms(spec.getSpecimenId());
              //					System.out.println(ss.getSpecimenId()+"***"+scms.size());
              if (spec == null) {
                System.out.println("NULL ID!");
              }
              if (scms == null) {
                System.out.println("NULL SCMS!");
              }
              String scmIds = "";
              int index = 0;
              for (SpecCollectorMap scm : scms) {
                if (index == 0) {
                  scmIds += scm.getSpecCollectorMapId();
                } else {
                  scmIds += ("-" + scm.getSpecCollectorMapId());
                }
                index++;
              }
              System.out.println("scmIds = " + scmIds);
              System.out.println("specimen Id = " + spec.getSpecimenId());
              if (scmIds.equals("")) scmIds = "0";
              Specimen updatedSpecimen = delegate.updateSpecimen(spec, scmIds);
              for (TableItem item : table.getItems()) {
                item.setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                submitButton.setEnabled(false);
              }
              IWorkbenchPage pages[] = getEditorSite().getWorkbenchWindow().getPages();
              for (IWorkbenchPage p : pages) {
                IViewReference ivrs[] = p.getViewReferences();
                for (IViewReference ivr : ivrs) {
                  if (ivr.getId().equals("TestView.view")) {
                    View v = (View) ivr.getView(true);
                    v.getGallery().getSelection()[0].setData(updatedSpecimen);
                    if (spec.getMissingInfo() == 0) {
                      v.getGallery()
                          .getSelection()[0]
                          .setBackground(new Color(Display.getCurrent(), 255, 255, 255));
                    }
                    spec = updatedSpecimen;
                    break;
                  }
                }
              }
              label2.setVisible(true);
              label3.setVisible(false);
              label4.setVisible(false);
            } catch (Exception e) {
              label2.setVisible(false);
              label3.setVisible(true);
              //					label4.setText(e.getMessage());
              label4.setVisible(true);
              e.printStackTrace();
            }
          }
        }; // scientific name inserting
    submitButton.addSelectionListener(buttonSelectionListener);
    System.out.println(Platform.getInstallLocation().getURL().getPath());
    System.out.println(Platform.getInstanceLocation().getURL().getPath());
    Image image = ImageFactory.loadImage(Display.getCurrent(), ImageFactory.ACTION_SYNC);
    IStatusLineManager manager = this.getEditorSite().getActionBars().getStatusLineManager();
    Action toggleBotton =
        new SyncIDropAction("Sync with iDrop", ImageDescriptor.createFromImage(image), manager);
    if (spec.getIdropSync() == null || spec.getIdropSync() == 0) {
      toggleBotton.setEnabled(true);
    } else toggleBotton.setEnabled(true);
    form.getToolBarManager().add(toggleBotton);
    form.getToolBarManager().update(true);
  }
Example #22
0
  @Override
  protected synchronized void onNodeChanged(AbstractNode node) {
    if (form != null && !form.isDisposed()) {
      try {
        form.dispose();
      } catch (Exception e) {
        // ignore any expose exceptions
      }
    }
    form = null;

    if (parent.isDisposed()) return;

    parent.setLayout(new GridLayout());
    // parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    form = toolkit.createForm(parent);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    form.setText(EditorMessages.propertiesDetailsTitle);
    toolkit.decorateFormHeading(form);

    form.getBody().setLayout(new GridLayout(2, false));

    Composite sbody = form.getBody();

    if (node != null) {
      final IMessageManager mmng = form.getMessageManager();

      form.setText(node.getPatternName());

      IPropertyDescriptor idDescriptor = null;
      IPropertyDescriptor descriptionDescriptor = null;

      IPropertyDescriptor[] propertyDescriptors = node.getPropertyDescriptors();

      for (int i = 0; i < 2; i++) {
        for (IPropertyDescriptor descriptor : propertyDescriptors) {
          final Object id = descriptor.getId();
          if ("AbstractNode.Id".equals(id)) {
            idDescriptor = descriptor;
          } else if (NODE_DESCRIPTION.equals(id)) {
            descriptionDescriptor = descriptor;
          } else {
            String propertyName = getPropertyName(id);
            boolean mandatory =
                descriptor instanceof ExpressionPropertyDescriptor
                    || isMandatory(node, propertyName);
            if ((mandatory && i == 0) || (!mandatory && i == 1)) {
              createDecoratedTextField(descriptor, toolkit, sbody, mmng);
            }
          }
        }
      }

      if (idDescriptor != null || descriptionDescriptor != null) {
        if (idDescriptor != null) {
          createDecoratedTextField(idDescriptor, toolkit, sbody, mmng);
        }
        if (descriptionDescriptor != null) {
          createDecoratedTextField(descriptionDescriptor, toolkit, sbody, mmng);
        }
      }

      // ref ECLIPSE-1012: unsaved nodes may be disposed
      // mmng.update();
    } else {
      form.setText(EditorMessages.propertiesDetailsTitle);
    }

    layoutForm();
  }
Example #23
0
  @Override
  public void createPartControl(final Composite parent) {
    parent.setLayout(new FillLayout());
    form = tk.createForm(parent);
    Composite body = form.getBody();
    body.setLayout(new GridLayout());
    Table table = new Table(body, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.SINGLE);
    TableColumn tc0 = new TableColumn(table, SWT.CENTER);
    tc0.setText(Messages.getString("BestellView.Number")); // $NON-NLS-1$
    tc0.setWidth(40);
    TableColumn tc1 = new TableColumn(table, SWT.LEFT);
    tc1.setText(Messages.getString("BestellView.Article")); // $NON-NLS-1$
    tc1.setWidth(280);
    TableColumn tc2 = new TableColumn(table, SWT.LEFT);
    tc2.setText(Messages.getString("BestellView.Dealer")); // $NON-NLS-1$
    tc2.setWidth(250);
    table.setLayoutData(SWTHelper.getFillGridData(1, true, 1, true));
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    tv = new TableViewer(table);
    tv.setContentProvider(
        new IStructuredContentProvider() {
          public Object[] getElements(final Object inputElement) {
            if (actBestellung != null) {
              return actBestellung.asList().toArray();
            }
            return new Object[0];
          }

          public void dispose() {}

          public void inputChanged(
              final Viewer viewer, final Object oldInput, final Object newInput) {}
        });
    tv.setLabelProvider(new BestellungLabelProvider());
    tv.setSorter(
        new ViewerSorter() {
          @Override
          public int compare(final Viewer viewer, final Object e1, final Object e2) {
            String s1 = ((Item) e1).art.getName();
            String s2 = ((Item) e2).art.getName();
            return s1.compareTo(s2);
          }
        });
    Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
    tv.addDropSupport(
        DND.DROP_COPY,
        types,
        new DropTargetAdapter() {

          @Override
          public void dragEnter(final DropTargetEvent event) {
            event.detail = DND.DROP_COPY;
          }

          @Override
          public void drop(final DropTargetEvent event) {
            String drp = (String) event.data;
            String[] dl = drp.split(","); // $NON-NLS-1$
            if (actBestellung == null) {
              InputDialog dlg =
                  new InputDialog(
                      getViewSite().getShell(),
                      Messages.getString("BestellView.CreateNewOrder"), // $NON-NLS-1$
                      Messages.getString("BestellView.EnterOrderTitle"), // $NON-NLS-1$
                      StringTool.leer,
                      null);
              if (dlg.open() == Dialog.OK) {
                setBestellung(new Bestellung(dlg.getValue(), Hub.actUser));
              } else {
                return;
              }
            }
            for (String obj : dl) {
              PersistentObject dropped = Hub.poFactory.createFromString(obj);
              if (dropped instanceof Artikel) {
                actBestellung.addItem((Artikel) dropped, 1);
              }
            }
            tv.refresh();
          }
        });
    makeActions();
    viewmenus = new ViewMenus(getViewSite());
    viewmenus.createToolbar(wizardAction, saveAction, loadAction, printAction, sendAction);
    viewmenus.createMenu(
        wizardAction, saveAction, loadAction, printAction, sendAction, exportClipboardAction);
    viewmenus.createViewerContextMenu(tv, new IAction[] {removeAction, countAction});
    form.getToolBarManager().add(checkInAction);
    form.updateToolBar();
    setBestellung(null);
    tv.setInput(getViewSite());
  }
  @Override
  public void createPartControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FillLayout(SWT.HORIZONTAL));

    Form frmServiosPrestados = formToolkit.createForm(container);
    formToolkit.paintBordersFor(frmServiosPrestados);
    frmServiosPrestados.setText("Servi\u00E7os Prestados");
    frmServiosPrestados.getBody().setLayout(new GridLayout(5, false));

    Label lblBuscar = new Label(frmServiosPrestados.getBody(), SWT.NONE);
    lblBuscar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    formToolkit.adapt(lblBuscar, true, true);
    lblBuscar.setText("Buscar:");

    txtFiltro = new Text(frmServiosPrestados.getBody(), SWT.BORDER);
    txtFiltro.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            filtro.setSearch(txtFiltro.getText());
            tvServicoPrestado.refresh();
          }
        });
    txtFiltro.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));
    txtFiltro.setMessage("Filtro...");
    formToolkit.adapt(txtFiltro, true, true);

    Label lblPeriodoDe =
        formToolkit.createLabel(frmServiosPrestados.getBody(), "Per\u00EDodo de", SWT.NONE);
    lblPeriodoDe.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));

    txtDataInicial = new MecasoftText(frmServiosPrestados.getBody(), SWT.NONE);
    txtDataInicial.setOptions(MecasoftText.NUMEROS, 10);
    txtDataInicial.addChars(FormatterHelper.MECASOFTTXTDATA, new Integer[] {2, 4}, null, null);
    formToolkit.adapt(txtDataInicial);
    formToolkit.paintBordersFor(txtDataInicial);

    Calendar c = Calendar.getInstance();
    c.add(Calendar.MONTH, -1);
    txtDataInicial.setText(FormatterHelper.getDateFormatData().format(c.getTime()));

    Label lblAte = new Label(frmServiosPrestados.getBody(), SWT.NONE);
    formToolkit.adapt(lblAte, true, true);
    lblAte.setText("at\u00E9");

    txtDataFinal = new MecasoftText(frmServiosPrestados.getBody(), SWT.NONE);
    txtDataFinal.setOptions(MecasoftText.NUMEROS, 10);
    txtDataFinal.addChars(FormatterHelper.MECASOFTTXTDATA, new Integer[] {2, 4}, null, null);
    formToolkit.adapt(txtDataFinal);
    formToolkit.paintBordersFor(txtDataFinal);

    txtDataFinal.setText(FormatterHelper.getDateFormatData().format(new Date()));

    tvServicoPrestado =
        new TableViewer(frmServiosPrestados.getBody(), SWT.BORDER | SWT.FULL_SELECTION);
    tvServicoPrestado.addDoubleClickListener(
        new IDoubleClickListener() {
          public void doubleClick(DoubleClickEvent event) {
            try {
              IStructuredSelection selecao =
                  (IStructuredSelection) tvServicoPrestado.getSelection();

              if (selecao.isEmpty()) return;

              ServicoPrestado sp = (ServicoPrestado) selecao.getFirstElement();

              getSite()
                  .getPage()
                  .openEditor(new AbrirOrdemServicoEditorInput(sp), AbrirOrdemServicoEditor.ID);
            } catch (PartInitException e) {
              e.printStackTrace();
            }
          }
        });
    table = tvServicoPrestado.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
    tvServicoPrestado.setContentProvider(ArrayContentProvider.getInstance());
    tvServicoPrestado.addFilter(filtro);
    formToolkit.paintBordersFor(table);

    TableViewerColumn tvcNumero = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcNumero.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((ServicoPrestado) element).getId().toString();
          }
        });
    TableColumn tblclmnNumero = tvcNumero.getColumn();
    tblclmnNumero.setWidth(100);
    tblclmnNumero.setText("N\u00FAmero");

    TableViewerColumn tvcCliente = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcCliente.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((ServicoPrestado) element).getCliente().getNomeFantasia();
          }
        });
    TableColumn tblclmnCliente = tvcCliente.getColumn();
    tblclmnCliente.setWidth(203);
    tblclmnCliente.setText("Cliente");

    TableViewerColumn tvcVeiculo = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcVeiculo.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            return ((ServicoPrestado) element).getVeiculo().getModelo();
          }
        });
    TableColumn tblclmnVeculo = tvcVeiculo.getColumn();
    tblclmnVeculo.setWidth(148);
    tblclmnVeculo.setText("Ve\u00EDculo");

    TableViewerColumn tvcMecanico = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcMecanico.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            service.setServicoPrestado((ServicoPrestado) element);
            StatusServico status = service.getServicoPrestado().getUltimoStatus();

            if (status != null) return status.getFuncionario().getNomeFantasia();

            return "Não há mecânico";
          }
        });
    TableColumn tblclmnMecnico = tvcMecanico.getColumn();
    tblclmnMecnico.setWidth(152);
    tblclmnMecnico.setText("Mec\u00E2nico");

    TableViewerColumn tvcStatus = new TableViewerColumn(tvServicoPrestado, SWT.NONE);
    tvcStatus.setLabelProvider(
        new ColumnLabelProvider() {
          @Override
          public String getText(Object element) {
            service.setServicoPrestado((ServicoPrestado) element);
            StatusServico status = service.getServicoPrestado().getUltimoStatus();

            if (status != null) return status.getStatus().getDescricao();

            return "Serviço não iniciado";
          }
        });
    TableColumn tblclmnStatusAtual = tvcStatus.getColumn();
    tblclmnStatusAtual.setWidth(137);
    tblclmnStatusAtual.setText("Status Atual");
    frmServiosPrestados.getToolBarManager().add(actionAtualizar);
    frmServiosPrestados.getToolBarManager().add(actionNovo);
    frmServiosPrestados.updateToolBar();
  }
Example #25
0
 private void createComposites() {
   _paramsComposite = _toolkit.createComposite(_form.getBody(), SWT.NONE);
   _paramsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
   _paramsComposite.setLayout(new GridLayout(2, true));
 }
Example #26
0
 public void layout() {
   _form.layout(true);
   _form.getBody().layout(true, true);
 }
Example #27
0
  @Override
  protected void okPressed() {

    if (currentWorkType == null) {
      parentForm.setMessage("Wählen Sie eine Tätigkeit!", IMessageProvider.ERROR);
      return;
    } else {
      if (currentWorkType.isAffectBand() == null || !currentWorkType.isAffectBand()) {
        entry.setBandAction(null);
      } else {
        if (entry.getBandAction() == null) {
          parentForm.setMessage("Unbekanntes Problem bei Bändern!", IMessageProvider.ERROR);
          return;
        }
        if (entry.getBandAction().getBandType() == null) {
          parentForm.setMessage("Kein Bandtyp ausgewählt!", IMessageProvider.ERROR);
          return;
        }
        if (entry.getBandAction().getAmount() == null || entry.getBandAction().getAmount() == 0) {
          boolean confirm =
              MessageDialog.openQuestion(
                  getShell(),
                  "Anzahl bestätigen",
                  "Sie wollen bei einer Tätigkeit, die ein oder mehrere Bänder betreffen kann, eine Anzahl von '0' angeben...\n"
                      + "Sind Sie sich sicher?");
          if (confirm) entry.getBandAction().setAmount(0);
          else return;
        }
      }
    }

    if (currentPersonType == null) {
      parentForm.setMessage("Wählen Sie eine Person!", IMessageProvider.ERROR);
      return;
    }

    if (entry.getDate() == null) {
      Calendar c = Calendar.getInstance();
      c.set(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay());
      entry.setDate(c.getTime());
    }
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    c.add(Calendar.DATE, +1);
    if (entry.getDate() == null || c.getTime().before(entry.getDate())) {
      parentForm.setMessage("Kein Datum, oder Datum in der Zukunft!", IMessageProvider.ERROR);
      return;
    }

    if (entry.getTime() == null || entry.getTime() == 0) {
      boolean confirm =
          MessageDialog.openQuestion(
              getShell(),
              "Dauer bestätigen",
              "Sie wollen bei einer Tätigkeit, eine Dauer von '0' Stunden angeben...\n"
                  + "Sind Sie sich sicher?");
      if (confirm) entry.setTime(new Float(0));
      else return;
    }

    super.okPressed();
  }
Example #28
0
  /**
   * Create contents of the dialog.
   *
   * @param parent
   */
  @Override
  protected Control createDialogArea(Composite parent) {

    getShell().setText("Geleistete Arbeit anlegen oder anpassen");

    Composite container = (Composite) super.createDialogArea(parent);
    container.setLayout(new FillLayout(SWT.HORIZONTAL));

    parentForm = formToolkit.createForm(container);
    formToolkit.paintBordersFor(parentForm);
    formToolkit.decorateFormHeading(parentForm);
    parentForm.setText("Geleistete Arbeit anlegen oder anpassen");

    IToolBarManager toolbar = parentForm.getToolBarManager();
    Action reuseSelectionAction = new InternalReuseEntryAction();
    toolbar.add(reuseSelectionAction);
    toolbar.update(true);

    parentForm.getBody().setLayout(new GridLayout(1, false));

    Composite composite = formToolkit.createComposite(parentForm.getBody(), SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    formToolkit.paintBordersFor(composite);
    composite.setLayout(new GridLayout(4, false));

    Label dateLabel = new Label(composite, SWT.NONE);
    dateLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
    formToolkit.adapt(dateLabel, true, true);
    dateLabel.setText("Datum");

    dateTime = new DateTime(composite, SWT.BORDER | SWT.CALENDAR);
    formToolkit.adapt(dateTime);
    formToolkit.paintBordersFor(dateTime);

    Label timeLabel = new Label(composite, SWT.NONE);
    timeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
    formToolkit.adapt(timeLabel, true, true);
    timeLabel.setText("Dauer (in h)");

    timeText = new Text(composite, SWT.NONE);
    timeText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
    formToolkit.adapt(timeText, true, true);

    Label workLabel = new Label(composite, SWT.NONE);
    workLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    formToolkit.adapt(workLabel, true, true);
    workLabel.setText("Tätigkeit");

    workComboViewer = new ComboViewer(composite, SWT.NONE);
    Combo workCombo = workComboViewer.getCombo();
    workCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    formToolkit.paintBordersFor(workCombo);

    Label personLabel = new Label(composite, SWT.NONE);
    personLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    formToolkit.adapt(personLabel, true, true);
    personLabel.setText("Person");

    personComboViewer = new ComboViewer(composite, SWT.NONE);
    Combo personCombo = personComboViewer.getCombo();
    personCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    formToolkit.paintBordersFor(personCombo);

    Label commentLabel = new Label(composite, SWT.NONE);
    commentLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
    formToolkit.adapt(commentLabel, true, true);
    commentLabel.setText("Bemerkungen");

    commentText = new Text(composite, SWT.WRAP | SWT.V_SCROLL | SWT.MULTI);
    GridData gd_commentText = new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1);
    gd_commentText.heightHint = 50;
    commentText.setLayoutData(gd_commentText);
    formToolkit.adapt(commentText, true, true);

    Label label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    GridData gd_label = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1);
    gd_label.heightHint = 10;
    label.setLayoutData(gd_label);
    formToolkit.adapt(label, true, true);

    bandTypeLabel = new Label(composite, SWT.NONE);
    bandTypeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    formToolkit.adapt(bandTypeLabel, true, true);
    bandTypeLabel.setText("Band Typ");

    bandTypeComboViewer = new ComboViewer(composite, SWT.NONE);
    bandTypeCombo = bandTypeComboViewer.getCombo();
    bandTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    formToolkit.paintBordersFor(bandTypeCombo);

    amountLabel = new Label(composite, SWT.NONE);
    amountLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    formToolkit.adapt(amountLabel, true, true);
    amountLabel.setText("Anzahl");

    amountText = new Text(composite, SWT.NONE);
    amountText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    formToolkit.adapt(amountText, true, true);

    new Label(composite, SWT.NONE);
    new Label(composite, SWT.NONE);

    trackLink = new Link(composite, SWT.NONE);
    trackLink.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    formToolkit.adapt(trackLink, true, true);
    trackLink.setText("<a>Bahn(en)</a>");

    trackText = new Text(composite, SWT.NONE);
    trackText.setEditable(false);
    trackText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    formToolkit.adapt(trackText, true, true);

    bandTypeLabel.setEnabled(false);
    bandTypeCombo.setEnabled(false);
    amountLabel.setEnabled(false);
    amountText.setEnabled(false);
    trackLink.setEnabled(false);
    trackText.setEnabled(false);

    DefaultStructuredContentProvider provider = new DefaultStructuredContentProvider();
    workComboViewer.setContentProvider(provider);
    personComboViewer.setContentProvider(provider);
    bandTypeComboViewer.setContentProvider(provider);

    InternalLabelProvider labelProvider = new InternalLabelProvider();
    workComboViewer.setLabelProvider(labelProvider);
    personComboViewer.setLabelProvider(labelProvider);
    bandTypeComboViewer.setLabelProvider(labelProvider);

    if (root.getWorks() != null && !root.getWorks().getWork().isEmpty()) {
      if (bandActionOnly) {
        workComboViewer.addFilter(new IntenalViewerFilter());
      }
      workComboViewer.setInput(root.getWorks().getWork());
    } else {
      workLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
    }
    if (root.getPersons() != null && !root.getPersons().getPerson().isEmpty()) {
      personComboViewer.setInput(root.getPersons().getPerson());
    } else {
      personLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
    }

    bandTypeComboViewer.setInput(BandTypes.values());

    if (editMode) {
      if (entry.getDate() != null) {
        Calendar c = Calendar.getInstance();
        c.setTime(entry.getDate());
        dateTime.setDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE));
      }
      if (entry.getTime() != null) {
        timeText.setText("" + entry.getTime());
      }
      if (entry.getComment() != null) {
        commentText.setText(entry.getComment());
      }
      if (entry.getPersonId() != null) {
        PersonType pt = null;
        if (root.getPersons() != null) {
          for (PersonType p : root.getPersons().getPerson()) {
            if (p.getId().equals(entry.getPersonId())) {
              pt = p;
              break;
            }
          }
        }
        if (pt != null) {
          StructuredSelection s = new StructuredSelection(pt);
          personComboViewer.setSelection(s);
          currentPersonType = pt;
        }
        personCombo.setEnabled(false);
      }
      if (entry.getWorkId() != null) {
        WorkType wt = null;
        if (root.getWorks() != null) {
          for (WorkType w : root.getWorks().getWork()) {
            if (w.getId().equals(entry.getWorkId())) {
              wt = w;
              break;
            }
          }
        }
        if (wt != null) {
          StructuredSelection s = new StructuredSelection(wt);
          workComboViewer.setSelection(s);
          currentWorkType = wt;
        }
        workCombo.setEnabled(false);
      }
      if (entry.getBandAction() != null) {
        if (entry.getBandAction().getBandType() != null) {
          StructuredSelection s = new StructuredSelection(entry.getBandAction().getBandType());
          bandTypeComboViewer.setSelection(s);
        }
        bandTypeLabel.setEnabled(true);
        bandTypeCombo.setEnabled(true);
        if (entry.getBandAction().getAmount() != null) {
          amountText.setText("" + entry.getBandAction().getAmount());
        }
        amountLabel.setEnabled(true);
        amountText.setEnabled(true);
        trackText.setText(getTrackString(entry.getBandAction()));
        trackLink.setEnabled(true);
        trackText.setEnabled(true);
      }
    }

    ModifyListener modifyListener =
        new ModifyListener() {
          @Override
          public void modifyText(ModifyEvent e) {
            if (e.widget == timeText) {
              entry.setTime(!timeText.getText().isEmpty() ? Float.valueOf(timeText.getText()) : 0);
            } else if (e.widget == commentText) {
              entry.setComment(!commentText.getText().isEmpty() ? commentText.getText() : null);
            } else if (e.widget == amountText) {
              if (entry.getBandAction() == null)
                entry.setBandAction(factory.createBandActionType());
              if (!amountText.getText().isEmpty()) {
                entry.getBandAction().setAmount(Integer.parseInt(amountText.getText()));
              } else {
                entry.getBandAction().setAmount(null);
              }
            }
          }
        };
    timeText.addModifyListener(modifyListener);
    commentText.addModifyListener(modifyListener);
    amountText.addModifyListener(modifyListener);

    SelectionAdapter selectionAdapter =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            if (e.widget == dateTime) {
              Calendar c = Calendar.getInstance();
              c.set(dateTime.getYear(), dateTime.getMonth(), dateTime.getDay());
              entry.setDate(c.getTime());
            } else if (e.widget == trackLink) {
              InternalTrackSelectionDialog dialog =
                  new InternalTrackSelectionDialog(getShell(), entry.getBandAction());
              if (InternalTrackSelectionDialog.OK == dialog.open()) {
                BandActionType ba = dialog.getBandAction();
                if (entry.getBandAction() == null) entry.setBandAction(ba);
                else {
                  entry.getBandAction().getTrack().clear();
                  entry.getBandAction().getTrack().addAll(ba.getTrack());
                }
                trackText.setText(getTrackString(entry.getBandAction()));
              }
            }
          }
        };
    dateTime.addSelectionListener(selectionAdapter);
    trackLink.addSelectionListener(selectionAdapter);

    ISelectionChangedListener seleChangedListener =
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            if (event.getSource() == workComboViewer) {
              WorkType wt =
                  (WorkType)
                      ((IStructuredSelection) workComboViewer.getSelection()).getFirstElement();
              if (wt != null) {
                currentWorkType = wt;
                entry.setWorkId(wt.getId());
                if (wt.isAffectBand() != null && wt.isAffectBand()) {
                  bandTypeLabel.setEnabled(true);
                  bandTypeCombo.setEnabled(true);
                  amountLabel.setEnabled(true);
                  amountText.setEnabled(true);
                  trackLink.setEnabled(true);
                  trackText.setEnabled(true);
                } else {
                  bandTypeLabel.setEnabled(false);
                  bandTypeCombo.setEnabled(false);
                  amountLabel.setEnabled(false);
                  amountText.setEnabled(false);
                  trackLink.setEnabled(false);
                  trackText.setEnabled(false);
                }
              } else {
                currentWorkType = null;
              }
            } else if (event.getSource() == personComboViewer) {
              PersonType pt =
                  (PersonType)
                      ((IStructuredSelection) personComboViewer.getSelection()).getFirstElement();
              if (pt != null) {
                currentPersonType = pt;
                entry.setPersonId(pt.getId());
              } else {
                currentPersonType = null;
              }
            } else if (event.getSource() == bandTypeComboViewer) {
              BandTypes bt =
                  (BandTypes)
                      ((IStructuredSelection) bandTypeComboViewer.getSelection()).getFirstElement();
              if (entry.getBandAction() == null)
                entry.setBandAction(factory.createBandActionType());
              if (bt != null) {
                entry.getBandAction().setBandType(bt);
              } else {
                entry.getBandAction().setBandType(null);
              }
            }
          }
        };
    workComboViewer.addSelectionChangedListener(seleChangedListener);
    personComboViewer.addSelectionChangedListener(seleChangedListener);
    bandTypeComboViewer.addSelectionChangedListener(seleChangedListener);

    return container;
  }
Example #29
0
  /** @since 3.0 */
  public void updateHeaderToolBar() {
    if (isHeaderFormDisposed()) {
      return;
    }

    final Form form = getHeaderForm().getForm().getForm();
    toolBarManager = form.getToolBarManager();

    toolBarManager.removeAll();
    //		toolBarManager.update(true);

    TaskRepository outgoingNewRepository = TasksUiUtil.getOutgoingNewTaskRepository(task);
    final TaskRepository taskRepository =
        (outgoingNewRepository != null)
            ? outgoingNewRepository
            : taskEditorInput.getTaskRepository();
    ControlContribution repositoryLabelControl =
        new ControlContribution(Messages.AbstractTaskEditorPage_Title) {
          @Override
          protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            Composite composite = toolkit.createComposite(parent);
            RowLayout layout = new RowLayout();
            if (PlatformUiUtil.hasNarrowToolBar()) {
              layout.marginTop = 0;
              layout.marginBottom = 0;
              layout.center = true;
            }
            composite.setLayout(layout);
            composite.setBackground(null);
            String label = taskRepository.getRepositoryLabel();
            if (label.indexOf("//") != -1) { // $NON-NLS-1$
              label =
                  label.substring(
                      (taskRepository.getRepositoryUrl().indexOf("//") + 2)); // $NON-NLS-1$
            }

            ImageHyperlink link = new ImageHyperlink(composite, SWT.NONE);
            link.setText(label);
            link.setFont(JFaceResources.getBannerFont());
            link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            link.setToolTipText(Messages.TaskEditor_Edit_Task_Repository_ToolTip);
            link.addHyperlinkListener(
                new HyperlinkAdapter() {
                  @Override
                  public void linkActivated(HyperlinkEvent e) {
                    TasksUiUtil.openEditRepositoryWizard(taskRepository);
                  }
                });

            return composite;
          }
        };
    toolBarManager.add(repositoryLabelControl);

    toolBarManager.add(new GroupMarker("repository")); // $NON-NLS-1$
    toolBarManager.add(new GroupMarker("new")); // $NON-NLS-1$
    toolBarManager.add(new GroupMarker("open")); // $NON-NLS-1$
    toolBarManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

    openWithBrowserAction = new OpenWithBrowserAction();
    openWithBrowserAction.selectionChanged(new StructuredSelection(task));
    if (openWithBrowserAction.isEnabled()) {
      //			ImageDescriptor overlay =
      // TasksUiPlugin.getDefault().getOverlayIcon(taskRepository.getConnectorKind());
      //			ImageDescriptor compositeDescriptor = new
      // TaskListImageDescriptor(TasksUiImages.REPOSITORY_SMALL_TOP,
      //					overlay, false, true);
      openWithBrowserAction.setImageDescriptor(CommonImages.WEB);
      // openWithBrowserAction.setImageDescriptor(CommonImages.BROWSER_OPEN_TASK);
      openWithBrowserAction.setToolTipText(Messages.AbstractTaskEditorPage_Open_with_Web_Browser);
      toolBarManager.appendToGroup("open", openWithBrowserAction); // $NON-NLS-1$
    } else {
      openWithBrowserAction = null;
    }

    if (activateAction == null) {
      activateAction =
          new ToggleTaskActivationAction(task) {
            @Override
            public void run() {
              TaskList taskList = TasksUiPlugin.getTaskList();
              if (taskList.getTask(task.getRepositoryUrl(), task.getTaskId()) == null) {
                setMessage(
                    Messages.TaskEditor_Task_added_to_the_Uncategorized_container,
                    IMessageProvider.INFORMATION);
              }
              super.run();
            }
          };
    }

    toolBarManager.add(new Separator("planning")); // $NON-NLS-1$
    disposeScheduleAction();
    scheduleAction = new TaskEditorScheduleAction(task);
    toolBarManager.add(scheduleAction);

    toolBarManager.add(new GroupMarker("page")); // $NON-NLS-1$
    for (IFormPage page : getPages()) {
      if (page instanceof TaskFormPage) {
        TaskFormPage taskEditorPage = (TaskFormPage) page;
        taskEditorPage.fillToolBar(toolBarManager);
      }
    }

    toolBarManager.add(new Separator("activation")); // $NON-NLS-1$

    //		ContributionItem spacer = new ContributionItem() {
    //			@Override
    //			public void fill(ToolBar toolbar, int index) {
    //				ToolItem item = new ToolItem(toolbar, SWT.NONE);
    //				int scaleHeight = 42;
    //				if (PlatformUtil.needsCarbonToolBarFix()) {
    //					scaleHeight = 32;
    //				}
    //				final Image image = new Image(toolbar.getDisplay(),
    // CommonImages.getImage(CommonImages.BLANK)
    //						.getImageData()
    //						.scaledTo(1, scaleHeight));
    //				item.setImage(image);
    //				item.addDisposeListener(new DisposeListener() {
    //					public void widgetDisposed(DisposeEvent e) {
    //						image.dispose();
    //					}
    //				});
    //				item.setWidth(5);
    //				item.setEnabled(false);
    //			}
    //		};
    //		toolBarManager.add(spacer);

    //		for (IFormPage page : getPages()) {
    //			if (page instanceof AbstractTaskEditorPage) {
    //				AbstractTaskEditorPage taskEditorPage = (AbstractTaskEditorPage) page;
    //				taskEditorPage.fillLeftHeaderToolBar(toolBarManager);
    //			} else if (page instanceof TaskPlanningEditor) {
    //				TaskPlanningEditor taskEditorPage = (TaskPlanningEditor) page;
    //				taskEditorPage.fillLeftHeaderToolBar(toolBarManager);
    //			}
    //		}

    // add external contributions
    menuService = (IMenuService) getSite().getService(IMenuService.class);
    if (menuService != null && toolBarManager instanceof ContributionManager) {
      menuService.populateContributionManager(
          (ContributionManager) toolBarManager,
          "toolbar:" //$NON-NLS-1$
              + ID_TOOLBAR_HEADER
              + "."
              + taskRepository.getConnectorKind()); // $NON-NLS-1$
      menuService.populateContributionManager(
          (ContributionManager) toolBarManager,
          "toolbar:" //$NON-NLS-1$
              + ID_TOOLBAR_HEADER);
    }

    toolBarManager.update(true);

    // XXX move this call
    updateLeftHeaderToolBar();
    updateHeader();
  }
Example #30
0
  private void createTryProjectConfigurationForm(FormToolkit toolkit, Composite parent) {
    Form form = toolkit.createForm(parent);
    form.setText("Project Configuration");

    Label lblRemoteHost = new Label(form.getBody(), SWT.NONE);
    lblRemoteHost.setBounds(10, 14, 102, 25);
    lblRemoteHost.setText("Remote host:");

    remoteHostText = new Text(form.getBody(), SWT.BORDER);
    remoteHostText.setBounds(158, 10, 172, 25);

    Label lblUsername = new Label(form.getBody(), SWT.NONE);
    lblUsername.setText("Username:"******"Password:"******"Instructor account:");
    lblInstructorAccount.setBounds(10, 98, 143, 25);

    instructorAccountText = new Text(form.getBody(), SWT.BORDER);
    instructorAccountText.setBounds(158, 97, 172, 25);

    Label lblAssignmentCode = new Label(form.getBody(), SWT.NONE);
    lblAssignmentCode.setText("Assignment code:");
    lblAssignmentCode.setBounds(10, 126, 143, 25);

    assignmentCodeText = new Text(form.getBody(), SWT.BORDER);
    assignmentCodeText.setBounds(158, 126, 172, 25);

    Button btnRun = new Button(form.getBody(), SWT.NONE);

    /*
     * Business logic when running the plugin
     */
    btnRun.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            // create try command runner object
            TryCommandRunner runner = new TryCommandRunner();

            // create the remote server configuration
            ServerConfig config =
                new ServerConfig(
                    remoteHostText.getText(), usernameText.getText(), passwordText.getText());

            // get the files to uploaded
            ArrayList<String> filenames = new ArrayList<String>();
            for (FileModel fileModel : tryElement) filenames.add(fileModel.fullPath);

            // create the try project configuration
            TryProject project =
                new TryProject(
                    instructorAccountText.getText(), assignmentCodeText.getText(), filenames);

            // set the view listener to SSH events
            runner.setView(tryCommandView);

            // run the try command
            runner.run(config, project);
          }
        });

    btnRun.setBounds(10, 160, 60, 60);
    btnRun.setText("Run");
  }