Esempio n. 1
0
  void executeCommand(String cmdLine) {
    clearStatus();

    IOSGiFrameworkConsole console =
        (IOSGiFrameworkConsole)
            getServer().getOriginal().loadAdapter(IOSGiFrameworkConsole.class, null);

    if (console == null) {
      IStatus status =
          EditorUIPlugin.newErrorStatus("Console editor part is not integrated with the runtime.");
      EditorUIPlugin.log(status);
      setStatus(status);
      return;
    }

    try {
      String result = console.executeCommand(cmdLine);
      manifestText.append("osgi> " + cmdLine + "\n");
      manifestText.append(result + "\n");
      forwardAction.setEnabled(history.canForward());
      backAction.setEnabled(history.canBack());
      toolBarManager.update(true);
      manifestText.setTopIndex(manifestText.getLineCount() - 1);
    } catch (CoreException e) {
      EditorUIPlugin.log(e);
      setStatus(
          EditorUIPlugin.newErrorStatus("Failed to execute command. See Error Log for details."));
    }

    commandText.setText("");
  }
 /**
  * Init the toolbar for the receiver
  *
  * <p>You can override this method if you want - but remember to call <code>super.initToolBar()
  * </code>.
  *
  * @param manager the tool bar manager of this view
  */
 private void initToolBar(IToolBarManager manager) {
   if (expandAllAction != null) manager.add(expandAllAction);
   if (collapseAllAction != null) manager.add(collapseAllAction);
   if (hideShowColAction != null) manager.add(hideShowColAction);
   if (exportToCSVAction != null) manager.add(exportToCSVAction);
   if (sortAction != null) manager.add(sortAction);
   contributeToToolbar(manager);
   manager.update(true);
 }
 public void addActionsToMenu() {
   for (Action action : additionalActions) {
     if (toolbarMM.getItems().length != additionalActions.size() + 2) {
       barMM.add(action);
       barMM.update(true);
       toolbarMM.add(action);
       toolbarMM.update(true);
     }
   }
   additionalActions.clear();
 }
Esempio n. 4
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;
  }
Esempio n. 5
0
  /**
   * @see
   *     org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
   */
  protected void createHeaderContents(IManagedForm headerForm) {
    RepositoryCommit commit = getCommit();
    ScrolledForm form = headerForm.getForm();
    new HeaderText(form.getForm(), commit.getRevCommit().name());
    form.setToolTipText(commit.getRevCommit().name());
    getToolkit().decorateFormHeading(form.getForm());

    IToolBarManager toolbar = form.getToolBarManager();

    ControlContribution repositoryLabelControl =
        new ControlContribution("repositoryLabel") { // $NON-NLS-1$
          @Override
          protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            Composite composite = toolkit.createComposite(parent);
            RowLayout layout = new RowLayout();
            composite.setLayout(layout);
            composite.setBackground(null);
            String label = getCommit().getRepositoryName();

            ImageHyperlink link = new ImageHyperlink(composite, SWT.NONE);
            link.setText(label);
            link.setFont(JFaceResources.getBannerFont());
            link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            link.setToolTipText(UIText.CommitEditor_showGitRepo);
            link.addHyperlinkListener(
                new HyperlinkAdapter() {
                  @Override
                  public void linkActivated(HyperlinkEvent event) {
                    RepositoriesView view;
                    try {
                      view =
                          (RepositoriesView)
                              PlatformUI.getWorkbench()
                                  .getActiveWorkbenchWindow()
                                  .getActivePage()
                                  .showView(RepositoriesView.VIEW_ID);
                      view.showRepository(getCommit().getRepository());
                    } catch (PartInitException e) {
                      Activator.handleError(UIText.CommitEditor_couldNotShowRepository, e, false);
                    }
                  }
                });

            return composite;
          }
        };
    toolbar.add(repositoryLabelControl);
    toolbar.add(createCommandContributionItem(CreateTagHandler.ID));
    toolbar.add(createCommandContributionItem(CreateBranchHandler.ID));
    toolbar.add(createCommandContributionItem(CheckoutHandler.ID));
    toolbar.add(createCommandContributionItem(CherryPickHandler.ID));
    toolbar.add(createCommandContributionItem(RevertHandler.ID));
    addContributions(toolbar);
    toolbar.update(true);
    getSite()
        .setSelectionProvider(
            new ISelectionProvider() {

              public void setSelection(ISelection selection) {
                // Ignored
              }

              public void removeSelectionChangedListener(ISelectionChangedListener listener) {
                // Ignored
              }

              public ISelection getSelection() {
                return new StructuredSelection(getCommit());
              }

              public void addSelectionChangedListener(ISelectionChangedListener listener) {
                // Ignored
              }
            });
  }
Esempio n. 6
0
  /** @since 3.0 */
  public void updateHeaderToolBar() {
    if (isHeaderFormDisposed()) {
      return;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    toolBarManager.update(true);

    // XXX move this call
    updateLeftHeaderToolBar();
    updateHeader();
  }