Exemplo n.º 1
0
 @Inject
 protected void setImages(PluginImageHelper imageHelper) {
   setImageDescriptor(
       ImageDescriptor.createFromImage(imageHelper.getImage("elcl16/arrangeall.gif")));
   setDisabledImageDescriptor(
       ImageDescriptor.createFromImage(imageHelper.getImage("dlcl16/arrangeall.gif")));
 }
Exemplo n.º 2
0
  /** Create the actions for navigation. */
  private void createActions() {
    // Only do this once.
    if (homeAction != null) {
      return;
    }

    // Home.
    homeAction =
        new Action(Messages.GoHome_text) {
          public void run() {
            goHome();
          }
        };
    homeAction.setToolTipText(Messages.GoHome_toolTip);
    homeAction.setImageDescriptor(
        ImageDescriptor.createFromImage(pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_HOME_NAV)));

    // Back.
    backAction =
        new Action(Messages.GoBack_text) {
          public void run() {
            goBack();
          }
        };
    backAction.setToolTipText(Messages.GoBack_toolTip);
    backAction.setImageDescriptor(
        ImageDescriptor.createFromImage(pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_BACK)));
    backAction.setDisabledImageDescriptor(
        ImageDescriptor.createFromImage(
            pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_BACK_DISABLED)));

    // Forward.
    forwardAction =
        new Action(Messages.GoInto_text) {
          public void run() {
            goInto();
          }
        };
    forwardAction.setToolTipText(Messages.GoInto_toolTip);
    forwardAction.setImageDescriptor(
        ImageDescriptor.createFromImage(pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_FORWARD)));
    forwardAction.setDisabledImageDescriptor(
        ImageDescriptor.createFromImage(
            pool.getImageUnchecked(SharedImageKeys.IMG_TOOL_FORWARD_DISABLED)));

    // Update the buttons when a selection change occurs.
    fChildTree.addSelectionChangedListener(this);
    updateNavigationButtons();
  }
Exemplo n.º 3
0
  private void addActionsForSelection(IMenuManager menuManager) {
    IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection();

    if (selection.size() == 1) {
      Object element = selection.getFirstElement();

      if (!(element instanceof IMarker)) {
        return;
      }

      final IMarker marker = (IMarker) element;

      IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);

      for (final IMarkerResolution resolution : resolutions) {
        Action action =
            new Action(escapeSpecialChars(resolution.getLabel())) {
              @Override
              public void run() {
                resolution.run(marker);
              }
            };

        if (resolution instanceof IMarkerResolution2) {
          IMarkerResolution2 resolution2 = (IMarkerResolution2) resolution;
          Image image = resolution2.getImage();
          if (image != null) {
            action.setImageDescriptor(ImageDescriptor.createFromImage(image));
          }
        }

        menuManager.add(action);
      }
    }
  }
 /**
  * Default constructor.
  *
  * @param cmrRepositoryDefinition {@link CmrRepositoryDefinition}
  */
 public SelectCmrAction(CmrRepositoryDefinition cmrRepositoryDefinition) {
   this.cmrRepositoryDefinition = cmrRepositoryDefinition;
   setText(cmrRepositoryDefinition.getName());
   setImageDescriptor(
       ImageDescriptor.createFromImage(
           ImageFormatter.getCmrRepositoryImage(cmrRepositoryDefinition, true)));
 }
 private ImageDescriptor getJavaModelImageDescriptor() {
   JavaElementLabelProvider lp =
       new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_SMALL_ICONS);
   Image modelImage = lp.getImage(getJavaModel());
   ImageDescriptor modelImageDescriptor = ImageDescriptor.createFromImage(modelImage);
   lp.dispose();
   return modelImageDescriptor;
 }
 public ImageDescriptor getImageDescriptor() {
   Image image = preferenceNode.getLabelImage();
   if (image != null) {
     ImageDescriptor descriptor = ImageDescriptor.createFromImage(image);
     return descriptor;
   }
   return null;
 }
Exemplo n.º 7
0
  /**
   * Creates a new data import wizard and sets the window title.
   *
   * @param controller Reference to controller
   * @param model Reference to model
   */
  public ImportWizard(Controller controller, Model model) {

    setWindowTitle(Resources.getMessage("ImportWizard.0")); // $NON-NLS-1$
    this.setDefaultPageImageDescriptor(
        ImageDescriptor.createFromImage(
            controller.getResources().getManagedImage("import.png"))); // $NON-NLS-1$
    this.data = new ImportWizardModel(model);
    this.controller = controller;
    this.model = model;
  }
Exemplo n.º 8
0
  /**
   * Constructor
   *
   * @param handle
   */
  public AddLevelHandleAction(DesignElementHandle handle) {
    super(handle);
    setId(ID);
    setText(TEXT);
    ExtendedItemHandle extendedHandle = CrosstabAdaptUtil.getExtendedItemHandle(handle);
    setHandle(extendedHandle);
    viewHandle = CrosstabAdaptUtil.getDimensionViewHandle(extendedHandle);

    Image image = CrosstabUIHelper.getImage(CrosstabUIHelper.SHOW_HIDE_LEVEL);
    setImageDescriptor(ImageDescriptor.createFromImage(image));
  }
Exemplo n.º 9
0
 public ModelImportWizard(
     Class<? extends MApplicationElement> applicationElement,
     AbstractComponentEditor editor,
     String hint,
     IResourcePool resourcePool) {
   this.applicationElement = applicationElement;
   this.editor = editor;
   this.hint = hint;
   this.application = (MApplication) editor.getEditor().getModelProvider().getRoot().get(0);
   setWindowTitle("Model " + applicationElement.getSimpleName() + " Import Wizard");
   setDefaultPageImageDescriptor(
       ImageDescriptor.createFromImage(
           resourcePool.getImageUnchecked(ResourceProvider.IMG_Wizban16_imp3x_wiz)));
   Assert.isNotNull(
       RegistryUtil.getStruct(applicationElement, getHint()),
       "Unknown Element: " + applicationElement.getClass().getName());
 }
Exemplo n.º 10
0
    @Override
    public void addPages() {
      getShell().setText(Messages.CommandWizard_ShellTitle);
      setDefaultPageImageDescriptor(
          ImageDescriptor.createFromImage(
              resourcePool.getImageUnchecked(ResourceProvider.IMG_Wizban16_newexp_wiz)));
      handlerPage = new HandlerCommandPage("Handler and Command");
      addPage(handlerPage);

      keyPage = new KeybindingPage("Keybinding", application);
      addPage(keyPage);

      menuPage = new MenuWizardPage("Menu", application);
      addPage(menuPage);

      toolbarPage = new ToolbarWizardPage("Toolbar", application);
      addPage(toolbarPage);
    }
Exemplo n.º 11
0
  private void registerImage(
      ImageRegistry registry, String key, String fileName, String overlayFileName) {
    try {
      IPath path = new Path("icons/" + fileName); // $NON-NLS-1$
      URL url = find(path);
      if (url != null) {
        ImageDescriptor desc = ImageDescriptor.createFromURL(url);

        if (overlayFileName != null) {
          path = new Path("icons/" + overlayFileName); // $NON-NLS-1$
          url = find(path);
          ImageDescriptor descOverlay = ImageDescriptor.createFromURL(url);
          Image overlayImg = createOverlayImg(desc.createImage(), descOverlay.createImage());
          desc = ImageDescriptor.createFromImage(overlayImg);
        }
        registry.put(key, desc);
      }
    } catch (Exception e) {
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createCommand()
  */
 public Command createCommand(Button button) {
   Object data = button.getData(NAME);
   if (data != null) {
     if (ICON_SELECTION.equals(data)) {
       FileDialog dial = new FileDialog(composite.getShell(), SWT.NONE);
       dial.setFilterExtensions(
           new String[] {"*.jpg", "*.png", "*.gif"}); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
       String propertyName = (String) button.getData(PARAMETER_NAME);
       String file = dial.open();
       if (file != null) {
         if (!file.equals("")) { // $NON-NLS-1$
           if (!elem.getPropertyValue(propertyName).equals(file)) {
             ImageData imageData = new ImageData(file);
             if (ImageUtils.checkSize(
                 ImageDescriptor.createFromImageData(imageData), ImageUtils.ICON_SIZE.ICON_32)) {
               if (elem instanceof IProcess2) {
                 refreshIcon(imageData);
                 return new IconSelectionCommand(
                     (IProcess2) elem, ImageDescriptor.createFromImageData(imageData), file);
               }
             } else {
               MessageDialog.openError(
                   composite.getShell(),
                   Messages.getString("IconSelectionController.MessageTitle"), // $NON-NLS-1$
                   Messages.getString("IconSelectionController.Messages")); // $NON-NLS-1$
             }
           }
         }
       }
     } else if (ICON_REVERT.equals(data)) {
       if (elem instanceof IProcess2) {
         Image defaultIcon = RepositoryLabelProvider.getDefaultJobletImage();
         ImageDescriptor imageData = ImageDescriptor.createFromImage(defaultIcon);
         refreshIcon(defaultIcon.getImageData());
         return new IconSelectionCommand((IProcess2) elem, imageData, null);
       }
     }
   }
   return null;
 }
  private static void initializeRegistry() {
    // Taken from org.eclipse.ui.internal.WorkbenchImages
    Display d = Display.getCurrent();

    Image viewMenu = new Image(d, 11, 16);
    Image viewMenuMask = new Image(d, 11, 16);

    GC gc = new GC(viewMenu);
    GC maskgc = new GC(viewMenuMask);
    drawViewMenu(gc, maskgc);
    gc.dispose();
    maskgc.dispose();

    ImageData data = viewMenu.getImageData();
    data.transparentPixel = data.getPixel(0, 0);

    Image vm2 = new Image(d, viewMenu.getImageData(), viewMenuMask.getImageData());
    viewMenu.dispose();
    viewMenuMask.dispose();

    getImageRegistry().put(EDITOR_MENU, vm2);
    getImageDescriptorRegistry().put(EDITOR_MENU, ImageDescriptor.createFromImage(vm2));
  }
 protected SecondWizardPage() {
   super(
       "Second",
       "Second Page",
       ImageDescriptor.createFromImage(new Image(Display.getDefault(), 16, 16)));
 }
 protected FirstWizardPage() {
   super(
       "First",
       "First Page",
       ImageDescriptor.createFromImage(new Image(Display.getDefault(), 16, 16)));
 }
Exemplo n.º 16
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);
  }
Exemplo n.º 17
0
 public SimpleReportAction(ApplicationWindow win, Config cfg) {
   super("Расходы времени", AS_PUSH_BUTTON);
   this.setAccelerator(SWT.CTRL + 'P');
   this.win = win;
   setImageDescriptor(ImageDescriptor.createFromImage(cfg.getImage(Config.REPORT)));
 }
 protected ImageDescriptor computeImageDescriptor() {
   if (part != null) {
     return ImageDescriptor.createFromImage(part.getTitleImage(), Display.getCurrent());
   }
   return defaultImageDescriptor;
 }
Exemplo n.º 19
0
 public ImageDescriptor getImageDescriptor() {
   return ImageDescriptor.createFromImage(
       SWTResourceManager.getImage(this.getClass(), "/icons/appfac.png"));
 }
Exemplo n.º 20
0
 public static ImageDescriptor getImageDescriptor(Display display, String fileName) {
   InputStream is = PlantUmlUtils.class.getResourceAsStream(fileName);
   Image image = new Image(display, is);
   return ImageDescriptor.createFromImage(image);
 }
  /**
   * Method decorateImage.
   *
   * @param aBaseImage Image
   * @param aElement Object
   * @return Image
   * @see org.eclipse.jface.viewers.ILabelDecorator#decorateImage(Image, Object)
   */
  public Image decorateImage(Image aBaseImage, Object aElement) { // $codepro.audit.disable

    // If the image is not already loaded, do it here
    Image currentOverlayImage;
    if (null != aBaseImage) {
      currentOverlayImage = aBaseImage;
    } else {
      currentOverlayImage =
          ((IR4EUIModelElement) aElement)
              .getImage(((IR4EUIModelElement) aElement).getImageLocation());
    }

    ImageDescriptor topLeftOverlay = null;
    String topLeftOverlayId = ""; // $NON-NLS-1$

    ImageDescriptor topRightOverlay = null;
    String topRightOverlayId = ""; // $NON-NLS-1$

    ImageDescriptor bottomLeftOverlay = null;
    String bottomLeftOverlayId = ""; // $NON-NLS-1$

    ImageDescriptor bottomRightOverlay = null;
    String bottomRightOverlayId = ""; // $NON-NLS-1$

    ImageRegistry registry = R4EUIPlugin.getDefault().getImageRegistry();

    // Disabled element decorator
    if (!((IR4EUIModelElement) aElement).isEnabled()) {
      bottomRightOverlay =
          ImageDescriptor.createFromImage(((IR4EUIModelElement) aElement).getDisabledImage());
      bottomRightOverlayId = DECORATOR_DISABLED_ID;
    } else {
      if (((IR4EUIModelElement) aElement).isUserReviewed()
          || (aElement instanceof R4EUIAnomalyExtended
              && ((R4EUIAnomalyExtended) aElement).isTerminalState())) {
        // Completed element decorator
        bottomRightOverlay =
            ImageDescriptor.createFromImage(((IR4EUIModelElement) aElement).getUserReviewedImage());
        bottomRightOverlayId = DECORATOR_REVIEWED_ID;
      }

      // Added, Removed or Modified file
      if (aElement instanceof R4EUIFileContext) {
        if (null == ((R4EUIFileContext) aElement).getBaseFileVersion()
            && null != ((R4EUIFileContext) aElement).getTargetFileVersion()) {
          // Only target present, file was added
          bottomLeftOverlay =
              ImageDescriptor.createFromImage(((R4EUIFileContext) aElement).getAddedImage());
          bottomLeftOverlayId = DECORATOR_ADDED_ID;
        } else if (null != ((R4EUIFileContext) aElement).getBaseFileVersion()
            && null == ((R4EUIFileContext) aElement).getTargetFileVersion()) {
          // Only base present, file was removed
          bottomLeftOverlay =
              ImageDescriptor.createFromImage(((R4EUIFileContext) aElement).getRemovedImage());
          bottomLeftOverlayId = DECORATOR_REMOVED_ID;
        } // else modified file
      }

      // Read-Only
      if (((IR4EUIModelElement) aElement).isReadOnly()) {
        topRightOverlay =
            ImageDescriptor.createFromImage(((IR4EUIModelElement) aElement).getReadOnlyImage());
        topRightOverlayId = DECORATOR_READONLY_ID;
      }

      // Due date passed
      if (((IR4EUIModelElement) aElement).isDueDatePassed()) {
        topLeftOverlay =
            ImageDescriptor.createFromImage(
                ((IR4EUIModelElement) aElement).getDueDatePassedImage());
        topLeftOverlayId = DECORATOR_OVERDUE_ID;
      }
    }

    // Construct a new image identifier
    String baseImageId = ((IR4EUIModelElement) aElement).getImageLocation();
    String decoratedImageId =
        baseImageId
            + topLeftOverlayId
            + topRightOverlayId
            + bottomLeftOverlayId
            + bottomRightOverlayId;

    // Return the stored image if we have one
    if (registry.get(decoratedImageId) == null) {
      DecorationOverlayIcon decoratedImage =
          new DecorationOverlayIcon(
              currentOverlayImage,
              new ImageDescriptor[] {
                topLeftOverlay, topRightOverlay, bottomLeftOverlay, bottomRightOverlay, null
              }) {};
      registry.put(decoratedImageId, decoratedImage);
    }
    return registry.get(decoratedImageId);
  }
Exemplo n.º 22
0
 public InternalReuseEntryAction() {
   super("Vorauswahl übernehmen", IAction.AS_PUSH_BUTTON);
   setImageDescriptor(
       ImageDescriptor.createFromImage(
           PFSCoreIconProvider.getImageByIconName("fugue_arrow-split-270.png", true)));
 }