Ejemplo n.º 1
0
  /**
   * Deletes the contents of the temporary files folder, including subfolders
   *
   * @param monitor progress monitor
   * @throws CoreException if an error occurs
   */
  public void cleanTempFiles(IProgressMonitor monitor) throws CoreException {
    if (tempDir != null && tempDir.exists()) {
      monitor.beginTask(
          TexlipsePlugin.getResourceString("builderSubTaskClean"), tempDir.members().length);
      monitor.subTask(TexlipsePlugin.getResourceString("builderSubTaskCleanTemp"));

      // Retrieve current temp folder content
      final Set<IPath> currentTmpFiles = tracking.getTempFolderNames(monitor);

      // Perform deletion
      deleteFiles(currentTmpFiles, monitor);
    }
    tracking.clearSnapshots();
  }
Ejemplo n.º 2
0
 /**
  * Checks whether all includes exists, if they are outside of the project, add a link to the file
  * to the project
  *
  * @param includes
  */
 private void processIncludes(List<OutlineNode> includes, IEditorInput input) {
   IProject project = getCurrentProject();
   if (project == null) return;
   IFile referFile = (IFile) input.getAdapter(IFile.class);
   if (referFile == null) return;
   for (OutlineNode node : includes) {
     IFile f = null;
     IFile mainTexFile = TexlipseProperties.getProjectSourceFile(project);
     if (mainTexFile != null) {
       // Includes are always relative to the main file
       f = TexProjectParser.findIFile(node.getName(), mainTexFile, project);
     }
     if (f == null) {
       // Try finding it relative to refering file
       f = TexProjectParser.findIFile(node.getName(), referFile, project);
     }
     if (f == null) {
       MarkerHandler marker = MarkerHandler.getInstance();
       String errorMsg =
           MessageFormat.format(
               TexlipsePlugin.getResourceString("parseErrorIncludeNotFound"),
               new Object[] {node.getName()});
       marker.createErrorMarker(referFile, errorMsg, node.getBeginLine());
     }
   }
 }
Ejemplo n.º 3
0
  /**
   * Performs actions after the LaTeX builder has finished building a document for the current
   * source; namely:
   *
   * <ul>
   *   <li>renaming and/or moving output (and other derived) files out of the build directory into
   *       the output folder
   *   <li>moving old and new temporary files out of the build directory into the temporary files
   *       folder
   * </ul>
   *
   * @param inputFile name of the input file; this can be <code>null</code>, if the current main
   *     document has just been built, but should be set after partial builds
   * @param monitor progress monitor
   * @throws CoreException if an error occurs
   */
  public void performAfterBuild(IProgressMonitor monitor) throws CoreException {
    // keeping first exception, which occurs when moving files; however, attempts
    // to still perform following steps
    CoreException ex = null;

    // make sure this has access to all files (if this fails, it means trouble to
    // all following steps)
    refreshView(monitor);

    Set<IPath> outputFiles = null;
    try { // possibly move output files away from the source dir and mark as derived
      outputFiles = moveOutputFiles(monitor);
    } catch (CoreException e) {
      // store exception for throwing it later
      ex =
          new BuilderCoreException(
              TexlipsePlugin.stat(TexlipsePlugin.getResourceString("builderCoreErrorOutputBlock")));
    }

    try { // move temp files out of this folder and mark as derived
      moveTempFiles(outputFiles, monitor);
    } catch (CoreException e) {
      // we only worry about this one, if the build was okay
      if (ex == null) {
        ex =
            new BuilderCoreException(
                TexlipsePlugin.stat(TexlipsePlugin.getResourceString("builderCoreErrorTempBlock")));
      }
    }

    try {
      refreshView(monitor);
    } catch (CoreException e) {
      // this is not irrelevant, but not as severe as the others
      if (ex == null) {
        ex = e;
      }
    }

    tracking.clearSnapshots();
    // now throw any pending exception, after cleaning up
    if (ex != null) {
      throw ex;
    }
  }
Ejemplo n.º 4
0
  /**
   * Deletes the output file.
   *
   * @param monitor progress monitor
   * @throws CoreException if an error occurs
   */
  public void cleanOutputFile(IProgressMonitor monitor) throws CoreException {
    monitor.subTask(TexlipsePlugin.getResourceString("builderSubTaskCleanOutput"));

    IFile outputFile = getSelectedOutputFile();
    if (outputFile != null && outputFile.exists()) {
      outputFile.delete(true, monitor);
    }

    monitor.worked(1);
  }
Ejemplo n.º 5
0
 /** Shows user a message */
 private void showMessage(String message) {
   MessageDialog.openInformation(
       viewer.getControl().getShell(),
       TexlipsePlugin.getResourceString("tableviewTableTitle"),
       message);
 }
Ejemplo n.º 6
0
  /**
   * Creates the table component attaching it to the given composite object
   *
   * @param parent composite object
   * @return The created table component
   */
  public Table createTable(Composite parent) {
    int style =
        SWT.SINGLE
            | SWT.BORDER
            | SWT.H_SCROLL
            | SWT.V_SCROLL
            | SWT.HIDE_SELECTION
            | SWT.FULL_SELECTION;

    Table table = new Table(parent, style);

    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalSpan = 3;
    table.setLayoutData(gridData);

    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    table.setToolTipText(TexlipsePlugin.getResourceString("tableviewTableTooltip"));

    TableColumn column;
    for (int i = 0; i < TexRow.COLUMNS; i++) {
      column = new TableColumn(table, SWT.LEFT, 0);
      column.setText(columnNames[i]);
      column.setWidth(50);
    }

    // The way to add listener to column, so that rows are sorted when header is clicked
    /*
    column.addSelectionListener(new SelectionAdapter() {
    public void widgetSelected(SelectionEvent e) {
    tableViewer.setSorter(new TexRowSorter());
    }
    });
    */

    menu = new Menu(parent);
    MenuItem mi;
    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewInsertRow"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TexRow row = (TexRow) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            int index = -1;
            if (row != null) index = rowList.indexOf(row);
            if (index != -1) rowList.insertRow(index);
            else rowList.addRow(); // FIXME this is probably never executed
          }
        });
    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewDeleteRow"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TexRow row = (TexRow) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (row != null) {
              rowList.removeRow(row);
            }
          }
        });
    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewClearAll"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            rowList.clearAll();
          }
        });

    new MenuItem(menu, SWT.SEPARATOR);

    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewRowUp"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TexRow row = (TexRow) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (row != null) {
              rowList.move(row, rowList.indexOf(row) - 1);
            }
          }
        });
    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewRowDown"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TexRow row = (TexRow) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (row != null) {
              rowList.move(row, rowList.indexOf(row) + 2);
            }
          }
        });
    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewDuplicateRow"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            TexRow row = (TexRow) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            if (row != null) {
              rowList.copy(row, rowList.indexOf(row));
            }
          }
        });

    new MenuItem(menu, SWT.SEPARATOR);

    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewEditorImport"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Get selection from texteditor
            IEditorPart targetEditor = TexlipsePlugin.getCurrentWorkbenchPage().getActiveEditor();

            if (!(targetEditor instanceof ITextEditor)) {
              return;
            }
            TexSelections selection = new TexSelections((ITextEditor) targetEditor);
            TexRow row = (TexRow) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
            int index = 0;
            if (row != null) index = rowList.indexOf(row);
            rowList.importSelection(selection, index);
          }
        });

    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewEditorExport"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String value = rowList.export();

            // transfer string to clipboard
            Clipboard cb = new Clipboard(null);
            TextTransfer textTransfer = TextTransfer.getInstance();
            cb.setContents(new Object[] {value}, new Transfer[] {textTransfer});
          }
        });

    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewRawExport"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            String value = rowList.exportRaw();

            // transfer string to clipboard
            Clipboard cb = new Clipboard(null);
            TextTransfer textTransfer = TextTransfer.getInstance();
            cb.setContents(new Object[] {value}, new Transfer[] {textTransfer});
          }
        });

    new MenuItem(menu, SWT.SEPARATOR);

    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewFlipRows"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            rowList.flipRowsAndColumns();
          }
        });
    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewMirrorColumns"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            rowList.mirrorColumns();
          }
        });
    mi = new MenuItem(menu, SWT.SINGLE);
    mi.setText(TexlipsePlugin.getResourceString("tableviewMirrorRows"));
    mi.setEnabled(true);
    mi.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            rowList.mirrorRows();
          }
        });

    table.setMenu(menu);

    return (table);
  }