Ejemplo n.º 1
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);
  }
 @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());
 }
Ejemplo n.º 3
0
  /*
   * (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();
 }
 /**
  * {@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;
 }
Ejemplo n.º 6
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();
 }
Ejemplo n.º 8
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);
          }
        }
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls
   * (org.eclipse.swt.widgets.Composite,
   * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
   */
  @Override
  public void createControls(
      final Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {

    this.parent = parent;
    this.toolkit = new FormToolkit(parent.getDisplay());
    super.createControls(parent, aTabbedPropertySheetPage);

    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.propertiesDocumentationTitle);
    toolkit.decorateFormHeading(form);

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

    Composite sbody = form.getBody();

    ToolBar navBar = new ToolBar(sbody, SWT.NONE);
    toolkit.adapt(navBar);
    navBar.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
    final ToolItem back = new ToolItem(navBar, SWT.PUSH);
    back.setText("<");
    back.setEnabled(false);
    final ToolItem forward = new ToolItem(navBar, SWT.PUSH);
    forward.setText(">");
    forward.setEnabled(false);

    back.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.back();
          }
        });
    forward.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.forward();
          }
        });

    final LocationListener locationListener =
        new LocationListener() {
          public void changed(LocationEvent event) {
            Browser browser = (Browser) event.widget;
            back.setEnabled(browser.isBackEnabled());
            forward.setEnabled(browser.isForwardEnabled());
          }

          public void changing(LocationEvent event) {}
        };

    browser = new Browser(sbody, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    browser.setLayoutData(data);
    IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    URL url = helpSystem.resolve("org.fusesource.ide.help/index.html", true);
    browser.setUrl(url.toExternalForm());
    browser.addLocationListener(locationListener);

    // section.pack();
    // form.pack();
    form.layout(true, true);
    parent.layout(true, true);

    // in case of timing issues, lets do another layout just in case...
    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              @Override
              public void run() {
                if (form != null && !form.isDisposed()) {
                  form.layout(true, true);
                }
                if (parent != null && !parent.isDisposed()) {
                  parent.layout(true, true);
                }
              }
            });
  }
Ejemplo n.º 10
0
  @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);
  }
Ejemplo n.º 11
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();
  }
Ejemplo n.º 12
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());
  }
Ejemplo n.º 13
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));
 }
Ejemplo n.º 14
0
  @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();
  }
Ejemplo n.º 15
0
 public void layout() {
   _form.layout(true);
   _form.getBody().layout(true, true);
 }
Ejemplo n.º 16
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;
  }
  /** {@inheritDoc} */
  @Override
  public void createPartControl(Composite parent) {
    createViewToolbar();

    toolkit = new FormToolkit(parent.getDisplay());

    mainComposite = new SashForm(parent, SWT.VERTICAL);
    GridLayout mainLayout = new GridLayout(1, true);
    mainLayout.marginWidth = 0;
    mainLayout.marginHeight = 0;
    mainComposite.setLayout(mainLayout);

    mainForm = toolkit.createForm(mainComposite);
    mainForm.getBody().setLayout(new GridLayout(1, true));
    mainForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    createHeadClient();
    toolkit.decorateFormHeading(mainForm);

    int borderStyle = toolkit.getBorderStyle();
    toolkit.setBorderStyle(SWT.NULL);
    Table table = toolkit.createTable(mainForm.getBody(), SWT.V_SCROLL | SWT.H_SCROLL);
    toolkit.setBorderStyle(borderStyle);
    tableViewer = new TableViewer(table);

    // create tree content provider
    tableViewer.setContentProvider(getContentProvider());
    tableViewer.setLabelProvider(getLabelProvider());

    ViewerComparator comparator = getViewerComparator();
    if (null != comparator) {
      tableViewer.setComparator(comparator);
    }
    ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);

    // double-click listener
    IDoubleClickListener doubleClickListener = getTreeDoubleClickListener();
    if (null != doubleClickListener) {
      tableViewer.addDoubleClickListener(doubleClickListener);
    }

    // menu
    String menuId = getMenuId();
    if (null != menuId) {
      MenuManager menuManager = new MenuManager();
      menuManager.setRemoveAllWhenShown(true);
      getSite().registerContextMenu(menuId, menuManager, tableViewer);
      Control control = tableViewer.getControl();
      Menu menu = menuManager.createContextMenu(control);
      control.setMenu(menu);
    }

    // resizing listener
    mainComposite.addControlListener(
        new ControlAdapter() {
          private boolean verticaLayout;

          @Override
          public void controlResized(ControlEvent e) {
            int width = mainComposite.getBounds().width;
            int height = mainComposite.getBounds().height;

            if (width > height && verticaLayout) {
              verticaLayout = false;
              mainComposite.setOrientation(SWT.HORIZONTAL);
            } else if (width < height && !verticaLayout) {
              verticaLayout = true;
              mainComposite.setOrientation(SWT.VERTICAL);
            }

            mainComposite.layout();
          }
        });

    // update all
    updateFormTitle();
    updateFormMenuManager();
    updateFormBody();

    tableViewer.addSelectionChangedListener(
        new ISelectionChangedListener() {
          @Override
          public void selectionChanged(SelectionChangedEvent event) {
            StructuredSelection ss = (StructuredSelection) tableViewer.getSelection();
            if (ss.getFirstElement() instanceof IProfileProvider
                || ss.getFirstElement() instanceof IEnvironmentProvider) {
              selectionProviderAdapter.setSelection(ss);
            } else {
              // setting selection to the CMR so that we can perform all the necessary
              // operations
              selectionProviderAdapter.setSelection(
                  new StructuredSelection(displayedCmrRepositoryDefinition));
            }
          }
        });
    getSite().setSelectionProvider(selectionProviderAdapter);
    selectionProviderAdapter.setSelection(
        new StructuredSelection(displayedCmrRepositoryDefinition));

    // TODO: This needs to be removed as soon as the configuration interface is fully
    // functional.
    UnfinishedWarningUtils.inform(
        "The configuration interface is not yet connected with the agent instrumentation. You can play around with this preview, but the instrumentations will not be effective.",
        "UNFINISHED_WARNING_CONFIGURATION_INTERFACE");
  }
Ejemplo n.º 18
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");
  }